Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/amit-migration/tags/migration-f…
Browse files Browse the repository at this point in the history
…or-2.7-5' into staging

Migration:

 - many compression/decompression fixes
 - trace improvements
 - static checker fix for detecting size mismatch in unused fields
 - fix VM save after snapshot

# gpg: Signature made Fri 17 Jun 2016 13:59:44 BST
# gpg:                using RSA key 0xEB0B4DFC657EF670
# gpg: Good signature from "Amit Shah <amit@amitshah.net>"
# gpg:                 aka "Amit Shah <amit@kernel.org>"
# gpg:                 aka "Amit Shah <amitshah@gmx.net>"
# Primary key fingerprint: 48CA 3722 5FE7 F4A8 B337  2735 1E9A 3B5F 8540 83B6
#      Subkey fingerprint: CC63 D332 AB8F 4617 4529  6534 EB0B 4DFC 657E F670

* remotes/amit-migration/tags/migration-for-2.7-5:
  vmstate-static-checker: fix size mismatch detection in unused fields
  migration: code clean up
  migration: refine the decompression code
  migration: refine the compression code
  migration: protect the quit flag by lock
  migration: refine ram_save_compressed_page
  qemu-file: Fix qemu_put_compression_data flaw
  migration: remove useless code
  migration: Fix a potential issue
  migration: Fix multi-thread compression bug
  migration: fix inability to save VM after snapshot
  migration: Trace improvements
  migration: Don't use *_to_cpup() and cpu_to_*w()

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Jun 17, 2016
2 parents 4acc8fd + 0794d88 commit 98b5b74
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 129 deletions.
12 changes: 6 additions & 6 deletions migration/migration.c
Expand Up @@ -1384,7 +1384,7 @@ static void *source_return_path_thread(void *opaque)
/* OK, we have the message and the data */
switch (header_type) {
case MIG_RP_MSG_SHUT:
sibling_error = be32_to_cpup((uint32_t *)buf);
sibling_error = ldl_be_p(buf);
trace_source_return_path_thread_shut(sibling_error);
if (sibling_error) {
error_report("RP: Sibling indicated error %d", sibling_error);
Expand All @@ -1398,22 +1398,22 @@ static void *source_return_path_thread(void *opaque)
goto out;

case MIG_RP_MSG_PONG:
tmp32 = be32_to_cpup((uint32_t *)buf);
tmp32 = ldl_be_p(buf);
trace_source_return_path_thread_pong(tmp32);
break;

case MIG_RP_MSG_REQ_PAGES:
start = be64_to_cpup((uint64_t *)buf);
len = be32_to_cpup((uint32_t *)(buf + 8));
start = ldq_be_p(buf);
len = ldl_be_p(buf + 8);
migrate_handle_rp_req_pages(ms, NULL, start, len);
break;

case MIG_RP_MSG_REQ_PAGES_ID:
expected_len = 12 + 1; /* header + termination */

if (header_len >= expected_len) {
start = be64_to_cpup((uint64_t *)buf);
len = be32_to_cpup((uint32_t *)(buf + 8));
start = ldq_be_p(buf);
len = ldl_be_p(buf + 8);
/* Now we expect an idstr */
tmp32 = buf[12]; /* Length of the following idstr */
buf[13 + tmp32] = '\0';
Expand Down
23 changes: 21 additions & 2 deletions migration/qemu-file.c
Expand Up @@ -615,8 +615,14 @@ uint64_t qemu_get_be64(QEMUFile *f)
return v;
}

/* compress size bytes of data start at p with specific compression
/* Compress size bytes of data start at p with specific compression
* level and store the compressed data to the buffer of f.
*
* When f is not writable, return -1 if f has no space to save the
* compressed data.
* When f is wirtable and it has no space to save the compressed data,
* do fflush first, if f still has no space to save the compressed
* data, return -1.
*/

ssize_t qemu_put_compression_data(QEMUFile *f, const uint8_t *p, size_t size,
Expand All @@ -625,15 +631,28 @@ ssize_t qemu_put_compression_data(QEMUFile *f, const uint8_t *p, size_t size,
ssize_t blen = IO_BUF_SIZE - f->buf_index - sizeof(int32_t);

if (blen < compressBound(size)) {
return 0;
if (!qemu_file_is_writable(f)) {
return -1;
}
qemu_fflush(f);
blen = IO_BUF_SIZE - sizeof(int32_t);
if (blen < compressBound(size)) {
return -1;
}
}
if (compress2(f->buf + f->buf_index + sizeof(int32_t), (uLongf *)&blen,
(Bytef *)p, size, level) != Z_OK) {
error_report("Compress Failed!");
return 0;
}
qemu_put_be32(f, blen);
if (f->ops->writev_buffer) {
add_to_iovec(f, f->buf + f->buf_index, blen);
}
f->buf_index += blen;
if (f->buf_index == IO_BUF_SIZE) {
qemu_fflush(f);
}
return blen + sizeof(int32_t);
}

Expand Down

0 comments on commit 98b5b74

Please sign in to comment.