5544c1b
From 7544abf3b783fc82b031d40d0685d2047709492a Mon Sep 17 00:00:00 2001
5544c1b
From: Jason Baron <jbaron@redhat.com>
5544c1b
Date: Wed, 8 Aug 2012 14:29:12 -0400
5544c1b
Subject: [PATCH] pcie: drop version_id field for live migration
5544c1b
5544c1b
While testing q35 live migration, I found that the migration would abort with
5544c1b
the following error: "Unknown savevm section type 76".
5544c1b
5544c1b
The error is due to this check failing in 'vmstate_load_state()':
5544c1b
5544c1b
    while(field->name) {
5544c1b
        if ((field->field_exists &&
5544c1b
             field->field_exists(opaque, version_id)) ||
5544c1b
            (!field->field_exists &&
5544c1b
             field->version_id <= version_id)) {
5544c1b
5544c1b
The VMSTATE_PCIE_DEVICE() currently has a 'version_id' set to 2. However,
5544c1b
'version_id' in the above check is 1. And thus we fail to load the pcie device
5544c1b
field. Further the code returns to 'qemu_loadvm_state()' which produces the
5544c1b
error that I saw.
5544c1b
5544c1b
I'm proposing to fix this by simply dropping the 'version_id' field from
5544c1b
VMSTATE_PCIE_DEVICE(). VMSTATE_PCI_DEVICE() defines no such field and further
5544c1b
the vmstate_pcie_device that VMSTATE_PCI_DEVICE() refers to is already
5544c1b
versioned. Thus, any versioning issues could be detected at the vmsd level.
5544c1b
5544c1b
Taking a step back, I think that the 'field->version_id' should be compared
5544c1b
against a saved version number for the field not the 'version_id'. Futhermore,
5544c1b
once vmstate_load_state() is called recursively on another vmsd, the check of:
5544c1b
5544c1b
    if (version_id > vmsd->version_id) {
5544c1b
        return -EINVAL;
5544c1b
    }
5544c1b
5544c1b
Will never fail since version_id is always equal to vmsd->version_id. So I'm
5544c1b
wondering why we aren't storing the vmsd version id of the source in the
5544c1b
migration stream?
5544c1b
5544c1b
This patch also renames the 'name' field of vmstate_pcie_device from:
5544c1b
PCIDevice -> PCIEDevice to differentiate it from vmstate_pci_device.
5544c1b
5544c1b
Signed-off-by: Jason Baron <jbaron@redhat.com>
5544c1b
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
5544c1b
(cherry picked from commit 1de53459272d89c52bb21b45d5d970de40fbb642)
5544c1b
5544c1b
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1b
---
5544c1b
 hw/pci.c  | 2 +-
5544c1b
 hw/pcie.h | 1 -
5544c1b
 2 files changed, 1 insertion(+), 2 deletions(-)
5544c1b
5544c1b
diff --git a/hw/pci.c b/hw/pci.c
5544c1b
index 4d95984..f855cf3 100644
5544c1b
--- a/hw/pci.c
5544c1b
+++ b/hw/pci.c
5544c1b
@@ -439,7 +439,7 @@ const VMStateDescription vmstate_pci_device = {
5544c1b
 };
5544c1b
 
5544c1b
 const VMStateDescription vmstate_pcie_device = {
5544c1b
-    .name = "PCIDevice",
5544c1b
+    .name = "PCIEDevice",
5544c1b
     .version_id = 2,
5544c1b
     .minimum_version_id = 1,
5544c1b
     .minimum_version_id_old = 1,
5544c1b
diff --git a/hw/pcie.h b/hw/pcie.h
5544c1b
index b8ab0c7..4889194 100644
5544c1b
--- a/hw/pcie.h
5544c1b
+++ b/hw/pcie.h
5544c1b
@@ -133,7 +133,6 @@ extern const VMStateDescription vmstate_pcie_device;
5544c1b
 
5544c1b
 #define VMSTATE_PCIE_DEVICE(_field, _state) {                        \
5544c1b
     .name       = (stringify(_field)),                               \
5544c1b
-    .version_id = 2,                                                 \
5544c1b
     .size       = sizeof(PCIDevice),                                 \
5544c1b
     .vmsd       = &vmstate_pcie_device,                              \
5544c1b
     .flags      = VMS_STRUCT,                                        \
5544c1b
-- 
f375e62
1.8.0.2
5544c1b