From 8cb8e85de65c4b51ca7537186e60dd560a4ed9db Mon Sep 17 00:00:00 2001 From: Dave Anderson Date: Mon, 16 May 2016 11:13:54 -0400 Subject: [PATCH] Recognize and parse the new QEMU_VM_CONFIGURATION and QEMU_VM_FOOTER sections used for live migration of KVM guests, which are seen in the "kvmdump" format generated if "virsh dump" is used without the "--memory-only" option. (pagupta@redhat.com) --- qemu-load.c | 21 +++++++++++++++++++++ qemu-load.h | 4 +++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/qemu-load.c b/qemu-load.c index 8b4372e..1c17fd9 100644 --- a/qemu-load.c +++ b/qemu-load.c @@ -208,6 +208,16 @@ get_string (FILE *fp, char *name) name[sz] = 0; return sz; } +static int +get_string_len (FILE *fp, char *name, uint32_t sz) +{ + size_t items ATTRIBUTE_UNUSED; + if (sz == EOF) + return -1; + items = fread (name, sz, 1, fp); + name[sz] = 0; + return sz; +} static void ram_read_blocks (FILE *fp, uint64_t size) @@ -924,6 +934,8 @@ qemu_load (const struct qemu_device_loader *devices, uint32_t required_features, struct qemu_device_list *result = NULL; struct qemu_device *last = NULL;; size_t items ATTRIBUTE_UNUSED; + uint32_t footerSecId ATTRIBUTE_UNUSED; + char name[257]; switch (get_be32 (fp)) { case QEMU_VM_FILE_MAGIC: @@ -961,6 +973,15 @@ qemu_load (const struct qemu_device_loader *devices, uint32_t required_features, break; if (sec == QEMU_VM_EOF) break; + if (sec == QEMU_VM_SECTION_FOOTER) { + footerSecId = get_be32 (fp); + continue; + } + if (sec == QEMU_VM_CONFIGURATION) { + uint32_t len = get_be32 (fp); + get_string_len (fp, name, len); + continue; + } d = device_get (devices, result, sec, fp); if (!d) diff --git a/qemu-load.h b/qemu-load.h index e52b068..f4fbb06 100644 --- a/qemu-load.h +++ b/qemu-load.h @@ -29,7 +29,9 @@ enum qemu_save_section { QEMU_VM_SECTION_PART, QEMU_VM_SECTION_END, QEMU_VM_SECTION_FULL, - QEMU_VM_SUBSECTION + QEMU_VM_SUBSECTION, + QEMU_VM_CONFIGURATION = 0x07, + QEMU_VM_SECTION_FOOTER = 0x7e }; enum qemu_features {