qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Cam Macdonell <cam@cs.ualberta.ca>
To: anthony@codemonkey.ws
Cc: Cam Macdonell <cam@cs.ualberta.ca>,
	qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: [Qemu-devel] [PATCH RFC] Mark a device as non-migratable
Date: Tue, 15 Jun 2010 10:16:43 -0600	[thread overview]
Message-ID: <1276618603-24184-1-git-send-email-cam@cs.ualberta.ca> (raw)
In-Reply-To: <4C16558A.5010005@codemonkey.ws>

How does this look for marking the device as non-migratable?  It adds a field
'no_migrate' to the SaveStateEntry and tests for it in vmstate_save.  This would
replace anything that touches memory.

Cam

---
 hw/hw.h  |    1 +
 savevm.c |   32 +++++++++++++++++++++++++++++---
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/hw/hw.h b/hw/hw.h
index d78d814..7c93f08 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -263,6 +263,7 @@ int register_savevm_live(const char *idstr,
                          void *opaque);
 
 void unregister_savevm(const char *idstr, void *opaque);
+void mark_no_migrate(const char *idstr, void *opaque);
 
 typedef void QEMUResetHandler(void *opaque);
 
diff --git a/savevm.c b/savevm.c
index 017695b..2642a9c 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1023,6 +1023,7 @@ typedef struct SaveStateEntry {
     LoadStateHandler *load_state;
     const VMStateDescription *vmsd;
     void *opaque;
+    int no_migrate;
 } SaveStateEntry;
 
 
@@ -1069,6 +1070,7 @@ int register_savevm_live(const char *idstr,
     se->load_state = load_state;
     se->opaque = opaque;
     se->vmsd = NULL;
+    se->no_migrate = 0;
 
     if (instance_id == -1) {
         se->instance_id = calculate_new_instance_id(idstr);
@@ -1103,6 +1105,19 @@ void unregister_savevm(const char *idstr, void *opaque)
     }
 }
 
+/* mark a device as not to be migrated, that is the device should be
+   unplugged before migration */
+void mark_no_migrate(const char *idstr, void *opaque)
+{
+    SaveStateEntry *se;
+
+    QTAILQ_FOREACH(se, &savevm_handlers, entry) {
+        if (strcmp(se->idstr, idstr) == 0 && se->opaque == opaque) {
+            se->no_migrate = 1;
+        }
+    }
+}
+
 int vmstate_register_with_alias_id(int instance_id,
                                    const VMStateDescription *vmsd,
                                    void *opaque, int alias_id,
@@ -1277,13 +1292,19 @@ static int vmstate_load(QEMUFile *f, SaveStateEntry *se, int version_id)
     return vmstate_load_state(f, se->vmsd, se->opaque, version_id);
 }
 
-static void vmstate_save(QEMUFile *f, SaveStateEntry *se)
+static int vmstate_save(QEMUFile *f, SaveStateEntry *se)
 {
+    if (se->no_migrate) {
+        return -1;
+    }
+
     if (!se->vmsd) {         /* Old style */
         se->save_state(f, se->opaque);
-        return;
+        return 0;
     }
     vmstate_save_state(f,se->vmsd, se->opaque);
+
+    return 0;
 }
 
 #define QEMU_VM_FILE_MAGIC           0x5145564d
@@ -1377,6 +1398,7 @@ int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f)
 int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f)
 {
     SaveStateEntry *se;
+    int r;
 
     cpu_synchronize_all_states();
 
@@ -1409,7 +1431,11 @@ int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f)
         qemu_put_be32(f, se->instance_id);
         qemu_put_be32(f, se->version_id);
 
-        vmstate_save(f, se);
+        r = vmstate_save(f, se);
+        if (r < 0) {
+            monitor_printf(mon, "cannot migrate with device '%s'\n", se->idstr);
+            return r;
+        }
     }
 
     qemu_put_byte(f, QEMU_VM_EOF);
-- 
1.6.3.2.198.g6096d

  reply	other threads:[~2010-06-15 16:18 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-04 21:45 [Qemu-devel] [PATCH v6 0/6] Inter-VM Shared Memory Device with migration support Cam Macdonell
2010-06-04 21:45 ` [Qemu-devel] [PATCH v6 1/6] Device specification for shared memory PCI device Cam Macdonell
2010-06-04 21:45   ` [Qemu-devel] [PATCH v6 2/6] Add function to assign ioeventfd to MMIO Cam Macdonell
2010-06-04 21:45     ` [Qemu-devel] [PATCH v6 3/6] Change phys_ram_dirty to phys_ram_status Cam Macdonell
2010-06-04 21:45       ` [Qemu-devel] [PATCH v6 4/6] Add support for marking memory to not be migrated. On migration, memory is checked for the NO_MIGRATION_FLAG Cam Macdonell
2010-06-04 21:45         ` [Qemu-devel] [PATCH v6 5/6] Inter-VM shared memory PCI device Cam Macdonell
2010-06-04 21:45           ` [Qemu-devel] [PATCH v6 6/6] the stand-alone shared memory server for inter-VM shared memory Cam Macdonell
2010-06-04 21:47             ` [Qemu-devel] [PATCH v6] Shared memory uio_pci driver Cam Macdonell
2010-06-14 15:53             ` [Qemu-devel] [PATCH v6 6/6] the stand-alone shared memory server for inter-VM shared memory Anthony Liguori
2010-06-14 22:03               ` Cam Macdonell
2010-06-23 13:12               ` Avi Kivity
2010-06-23 21:54                 ` Anthony Liguori
2010-06-05  9:44           ` [Qemu-devel] [PATCH v6 5/6] Inter-VM shared memory PCI device Blue Swirl
2010-06-06 15:02             ` Avi Kivity
2010-06-07 16:41             ` Cam Macdonell
2010-06-09 20:12               ` Blue Swirl
2010-06-14 15:51         ` [Qemu-devel] [PATCH v6 4/6] Add support for marking memory to not be migrated. On migration, memory is checked for the NO_MIGRATION_FLAG Anthony Liguori
2010-06-14 16:08           ` Cam Macdonell
2010-06-14 16:15             ` Anthony Liguori
2010-06-15 16:16               ` Cam Macdonell [this message]
2010-06-15 16:32                 ` [Qemu-devel] Re: [PATCH RFC] Mark a device as non-migratable Anthony Liguori
2010-06-15 17:45                   ` Markus Armbruster
2010-06-15 22:26                   ` Cam Macdonell
2010-06-15 22:33                     ` Anthony Liguori
2010-06-16  5:05                       ` Cam Macdonell
2010-06-16 12:34                         ` Anthony Liguori
2010-06-17  4:18                           ` Cam Macdonell
2010-06-11 22:03 ` [Qemu-devel] Re: [PATCH v6 0/6] Inter-VM Shared Memory Device with migration support Cam Macdonell
2010-06-14 15:54   ` Anthony Liguori

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=1276618603-24184-1-git-send-email-cam@cs.ualberta.ca \
    --to=cam@cs.ualberta.ca \
    --cc=anthony@codemonkey.ws \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    /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).