Patchwork [6/6] savevm: Remove register_device_unmigratable()

login
register
mail settings
Submitter Alex Williamson
Date Oct. 6, 2010, 8:59 p.m.
Message ID <20101006205934.32127.70233.stgit@s20.home>
Download mbox | patch
Permalink /patch/66969/
State New
Headers show

Comments

Alex Williamson - Oct. 6, 2010, 8:59 p.m.
Now that the save state handlers can return error, individual drivers
can cancel a migration if they hit an error or don't support it.  This
makes the unmigratable callback redundant.  Remove it and change the
only user to cancel the migration in a set_params callback, which
actually happens much earlier in the migration than the unmigratable
flag was checked.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---

 hw/hw.h      |    2 --
 hw/ivshmem.c |   20 ++++++++++++++------
 savevm.c     |   31 -------------------------------
 3 files changed, 14 insertions(+), 39 deletions(-)

Patch

diff --git a/hw/hw.h b/hw/hw.h
index 95f2d52..6c0aefe 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -264,8 +264,6 @@  int register_savevm_live(DeviceState *dev,
                          void *opaque);
 
 void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque);
-void register_device_unmigratable(DeviceState *dev, const char *idstr,
-                                                                void *opaque);
 
 typedef void QEMUResetHandler(void *opaque);
 
diff --git a/hw/ivshmem.c b/hw/ivshmem.c
index 3726a7f..4164861 100644
--- a/hw/ivshmem.c
+++ b/hw/ivshmem.c
@@ -616,6 +616,18 @@  static void ivshmem_setup_msi(IVShmemState * s) {
     s->eventfd_table = qemu_mallocz(s->vectors * sizeof(EventfdEntry));
 }
 
+static int ivshmem_set_param(int blk_enable, int shared, void *opaque)
+{
+    IVShmemState *proxy = opaque;
+
+    if (proxy->role_val == IVSHMEM_PEER) {
+        fprintf(stderr,
+                "ivshmem device in peer role, cannot be migrated or saved\n");
+        return -EINVAL;
+    }
+    return 0;
+}
+
 static int ivshmem_save(QEMUFile* f, void *opaque)
 {
     IVShmemState *proxy = opaque;
@@ -683,8 +695,8 @@  static int pci_ivshmem_init(PCIDevice *dev)
         s->ivshmem_size = ivshmem_get_size(s);
     }
 
-    register_savevm(&s->dev.qdev, "ivshmem", 0, 0, ivshmem_save, ivshmem_load,
-                                                                        dev);
+    register_savevm_live(&s->dev.qdev, "ivshmem", 0, 0, ivshmem_set_param,
+                         NULL, ivshmem_save, ivshmem_load, dev);
 
     /* IRQFD requires MSI */
     if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD) &&
@@ -707,10 +719,6 @@  static int pci_ivshmem_init(PCIDevice *dev)
         s->role_val = IVSHMEM_MASTER; /* default */
     }
 
-    if (s->role_val == IVSHMEM_PEER) {
-        register_device_unmigratable(&s->dev.qdev, "ivshmem", s);
-    }
-
     pci_conf = s->dev.config;
     pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_REDHAT_QUMRANET);
     pci_conf[0x02] = 0x10;
diff --git a/savevm.c b/savevm.c
index ad3ab86..1b4ee08 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1018,7 +1018,6 @@  typedef struct SaveStateEntry {
     const VMStateDescription *vmsd;
     void *opaque;
     CompatEntry *compat;
-    int no_migrate;
 } SaveStateEntry;
 
 
@@ -1082,7 +1081,6 @@  int register_savevm_live(DeviceState *dev,
     se->load_state = load_state;
     se->opaque = opaque;
     se->vmsd = NULL;
-    se->no_migrate = 0;
 
     if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) {
         char *id = dev->parent_bus->info->get_dev_path(dev);
@@ -1149,31 +1147,6 @@  void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque)
     }
 }
 
-/* mark a device as not to be migrated, that is the device should be
-   unplugged before migration */
-void register_device_unmigratable(DeviceState *dev, const char *idstr,
-                                                            void *opaque)
-{
-    SaveStateEntry *se;
-    char id[256] = "";
-
-    if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) {
-        char *path = dev->parent_bus->info->get_dev_path(dev);
-        if (path) {
-            pstrcpy(id, sizeof(id), path);
-            pstrcat(id, sizeof(id), "/");
-            qemu_free(path);
-        }
-    }
-    pstrcat(id, sizeof(id), idstr);
-
-    QTAILQ_FOREACH(se, &savevm_handlers, entry) {
-        if (strcmp(se->idstr, id) == 0 && se->opaque == opaque) {
-            se->no_migrate = 1;
-        }
-    }
-}
-
 int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
                                    const VMStateDescription *vmsd,
                                    void *opaque, int alias_id,
@@ -1389,10 +1362,6 @@  static int vmstate_load(QEMUFile *f, SaveStateEntry *se, int version_id)
 
 static int vmstate_save(QEMUFile *f, SaveStateEntry *se)
 {
-    if (se->no_migrate) {
-        return -1;
-    }
-
     if (!se->vmsd) {         /* Old style */
         return se->save_state(f, se->opaque);
     }