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)
This commit is contained in:
Dave Anderson 2016-05-16 11:13:54 -04:00
parent 5649088bcc
commit 8cb8e85de6
2 changed files with 24 additions and 1 deletions

View File

@ -208,6 +208,16 @@ get_string (FILE *fp, char *name)
name[sz] = 0; name[sz] = 0;
return sz; 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 static void
ram_read_blocks (FILE *fp, uint64_t size) 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_list *result = NULL;
struct qemu_device *last = NULL;; struct qemu_device *last = NULL;;
size_t items ATTRIBUTE_UNUSED; size_t items ATTRIBUTE_UNUSED;
uint32_t footerSecId ATTRIBUTE_UNUSED;
char name[257];
switch (get_be32 (fp)) { switch (get_be32 (fp)) {
case QEMU_VM_FILE_MAGIC: case QEMU_VM_FILE_MAGIC:
@ -961,6 +973,15 @@ qemu_load (const struct qemu_device_loader *devices, uint32_t required_features,
break; break;
if (sec == QEMU_VM_EOF) if (sec == QEMU_VM_EOF)
break; 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); d = device_get (devices, result, sec, fp);
if (!d) if (!d)

View File

@ -29,7 +29,9 @@ enum qemu_save_section {
QEMU_VM_SECTION_PART, QEMU_VM_SECTION_PART,
QEMU_VM_SECTION_END, QEMU_VM_SECTION_END,
QEMU_VM_SECTION_FULL, QEMU_VM_SECTION_FULL,
QEMU_VM_SUBSECTION QEMU_VM_SUBSECTION,
QEMU_VM_CONFIGURATION = 0x07,
QEMU_VM_SECTION_FOOTER = 0x7e
}; };
enum qemu_features { enum qemu_features {