qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: qemu-devel@nongnu.org
Cc: alex.williamson@redhat.com, cam@cs.ualberta.ca, quintela@redhat.com
Subject: [Qemu-devel] [PATCH RESEND 6/6] savevm: Remove register_device_unmigratable()
Date: Fri, 05 Nov 2010 15:16:55 -0600	[thread overview]
Message-ID: <20101105211653.19958.49845.stgit@s20.home> (raw)
In-Reply-To: <20101105211426.19958.86894.stgit@s20.home>

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(-)

diff --git a/hw/hw.h b/hw/hw.h
index dac89c7..42bdb7f 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 521edc8..17e4c2f 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1039,7 +1039,6 @@ typedef struct SaveStateEntry {
     const VMStateDescription *vmsd;
     void *opaque;
     CompatEntry *compat;
-    int no_migrate;
 } SaveStateEntry;
 
 
@@ -1103,7 +1102,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);
@@ -1170,31 +1168,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,
@@ -1410,10 +1383,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);
     }

      parent reply	other threads:[~2010-11-05 21:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-05 21:16 [Qemu-devel] [PATCH RESEND 0/6] Save state error handling (kill off no_migrate) Alex Williamson
2010-11-05 21:16 ` [Qemu-devel] [PATCH RESEND 1/6] savevm: Allow SaveStateHandler() to return error Alex Williamson
2010-11-05 21:16 ` [Qemu-devel] [PATCH RESEND 2/6] savevm: Allow vmsd->pre_save " Alex Williamson
2010-11-05 21:16 ` [Qemu-devel] [PATCH RESEND 3/6] pci: Allow pci_device_save() " Alex Williamson
2010-11-05 21:16 ` [Qemu-devel] [PATCH RESEND 4/6] virtio: Allow virtio_save() errors Alex Williamson
2010-11-05 21:16 ` [Qemu-devel] [PATCH RESEND 5/6] savevm: Allow set_params and save_live_state to error Alex Williamson
2010-11-05 21:16 ` Alex Williamson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101105211653.19958.49845.stgit@s20.home \
    --to=alex.williamson@redhat.com \
    --cc=cam@cs.ualberta.ca \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).