From: Juan Quintela <quintela@redhat.com>
To: qemu-devel@nongnu.org
Cc: Juan Quintela <quintela@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Laurent Vivier <lvivier@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Eric Blake <eblake@redhat.com>, Thomas Huth <thuth@redhat.com>
Subject: [Qemu-devel] [PATCH v2 8/8] multifd: rest of zlib compression (WIP)
Date: Wed, 3 Apr 2019 13:49:58 +0200 [thread overview]
Message-ID: <20190403114958.3705-9-quintela@redhat.com> (raw)
In-Reply-To: <20190403114958.3705-1-quintela@redhat.com>
This is still a work in progress, but get everything sent as expected
and it is faster than the code that is already there.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
migration/ram.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 88 insertions(+), 5 deletions(-)
diff --git a/migration/ram.c b/migration/ram.c
index 06b25ac66d..1b3b88d711 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1118,7 +1118,41 @@ static void *multifd_send_thread(void *opaque)
uint64_t packet_num = p->packet_num;
uint32_t flags = p->flags;
- p->next_packet_size = used * qemu_target_page_size();
+ if (used) {
+ if (migrate_use_multifd_zlib()) {
+ struct iovec *iov = p->pages->iov;
+ z_stream *zs = &p->zs;
+ uint32_t out_size = 0;
+ int i;
+
+ for (i = 0; i < used; i++ ) {
+ uint32_t available = p->zbuff_len - out_size;
+ int flush = Z_NO_FLUSH;
+
+ if (i == used - 1) {
+ flush = Z_SYNC_FLUSH;
+ }
+
+ zs->avail_in = iov[i].iov_len;
+ zs->next_in = iov[i].iov_base;
+
+ zs->avail_out = available;
+ zs->next_out = p->zbuff + out_size;
+
+ ret = deflate(zs, flush);
+ if (ret != Z_OK) {
+ printf("problem with deflate? %d\n", ret);
+ qemu_mutex_unlock(&p->mutex);
+ break;
+ }
+ out_size += available - zs->avail_out;
+ }
+ p->next_packet_size = out_size;
+ } else {
+ p->next_packet_size = used * qemu_target_page_size();
+ }
+ }
+
multifd_send_fill_packet(p);
p->flags = 0;
p->num_packets++;
@@ -1136,8 +1170,13 @@ static void *multifd_send_thread(void *opaque)
}
if (used) {
- ret = qio_channel_writev_all(p->c, p->pages->iov,
- used, &local_err);
+ if (migrate_use_multifd_zlib()) {
+ ret = qio_channel_write_all(p->c, (void *)p->zbuff,
+ p->next_packet_size, &local_err);
+ } else {
+ ret = qio_channel_writev_all(p->c, p->pages->iov,
+ used, &local_err);
+ }
if (ret != 0) {
break;
}
@@ -1384,8 +1423,52 @@ static void *multifd_recv_thread(void *opaque)
qemu_mutex_unlock(&p->mutex);
if (used) {
- ret = qio_channel_readv_all(p->c, p->pages->iov,
- used, &local_err);
+ uint32_t in_size = p->next_packet_size;
+ uint32_t out_size = 0;
+ uint32_t expected_size = used * qemu_target_page_size();
+ int i;
+
+ if (migrate_use_multifd_zlib()) {
+ z_stream *zs = &p->zs;
+
+ ret = qio_channel_read_all(p->c, (void *)p->zbuff,
+ in_size, &local_err);
+
+ if (ret != 0) {
+ break;
+ }
+
+ zs->avail_in = in_size;
+ zs->next_in = p->zbuff;
+
+ for (i = 0; i < used; i++ ) {
+ struct iovec *iov = &p->pages->iov[i];
+ int flush = Z_NO_FLUSH;
+
+ if (i == used - 1) {
+ flush = Z_SYNC_FLUSH;
+ }
+
+ zs->avail_out = iov->iov_len;
+ zs->next_out = iov->iov_base;
+
+ ret = inflate(zs, flush);
+ if (ret != Z_OK) {
+ printf("%d: problem with inflate? %d\n", p->id, ret);
+ qemu_mutex_unlock(&p->mutex);
+ break;
+ }
+ out_size += iov->iov_len;
+ }
+ if (out_size != expected_size) {
+ printf("out size %d expected size %d\n",
+ out_size, expected_size);
+ break;
+ }
+ } else {
+ ret = qio_channel_readv_all(p->c, p->pages->iov,
+ used, &local_err);
+ }
if (ret != 0) {
break;
}
--
2.20.1
next prev parent reply other threads:[~2019-04-03 11:58 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-03 11:49 [Qemu-devel] [PATCH v2 0/8] WIP: Multifd compression support Juan Quintela
2019-04-03 11:49 ` [Qemu-devel] [PATCH v2 1/8] migration: Fix migrate_set_parameter Juan Quintela
2019-04-03 16:31 ` Dr. David Alan Gilbert
2019-04-05 14:32 ` Dr. David Alan Gilbert
2019-04-05 14:32 ` Dr. David Alan Gilbert
2019-04-03 11:49 ` [Qemu-devel] [PATCH v2 2/8] migration: fix multifd_recv event typo Juan Quintela
2019-04-03 16:46 ` Dr. David Alan Gilbert
2019-04-03 11:49 ` [Qemu-devel] [PATCH v2 3/8] migration-test: rename parameter to parameter_int Juan Quintela
2019-04-03 16:47 ` Dr. David Alan Gilbert
2019-04-03 11:49 ` [Qemu-devel] [PATCH v2 4/8] tests: Add migration multifd test Juan Quintela
2019-04-03 11:49 ` [Qemu-devel] [PATCH v2 5/8] migration-test: introduce functions to handle string parameters Juan Quintela
2019-04-03 11:49 ` [Qemu-devel] [PATCH v2 6/8] migration: Add multifd-compress parameter Juan Quintela
2019-04-08 9:15 ` Markus Armbruster
2019-04-08 9:15 ` Markus Armbruster
2019-05-15 10:48 ` Juan Quintela
2019-05-15 12:28 ` Markus Armbruster
2019-04-10 17:54 ` Dr. David Alan Gilbert
2019-04-10 17:54 ` Dr. David Alan Gilbert
2019-04-03 11:49 ` [Qemu-devel] [PATCH v2 7/8] multifd: Add zlib compression support Juan Quintela
2019-04-03 11:49 ` Juan Quintela [this message]
2019-04-03 12:11 ` [Qemu-devel] [PATCH v2 0/8] WIP: Multifd " no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190403114958.3705-9-quintela@redhat.com \
--to=quintela@redhat.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).