From: Alex Williamson <alex.williamson@redhat.com>
To: qemu-devel@nongnu.org
Cc: alex.williamson@redhat.com, mst@redhat.com, jan.kiszka@web.de,
quintela@redhat.com
Subject: [Qemu-devel] [PATCH v5] savevm: Fix no_migrate
Date: Tue, 11 Jan 2011 14:39:43 -0700 [thread overview]
Message-ID: <20110111213731.20822.21354.stgit@s20.home> (raw)
In-Reply-To: <20110107220801.15395.38757.stgit@s20.home>
The no_migrate save state flag is currently only checked in the
last phase of migration. This means that we potentially waste
a lot of time and bandwidth with the live state handlers before
we ever check the no_migrate flags. The error message printed
when we catch a non-migratable device doesn't get printed for
a detached migration. And, no_migrate does nothing to prevent
an incoming migration to a target that includes a non-migratable
device. This attempts to fix all of these.
One notable difference in behavior is that an outgoing migration
now checks for non-migratable devices before ever connecting to
the target system. This means the target will remain listening
rather than exit from failure.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
v5:
- change qemu_savevm_state_blocked() to return bool
- Daniel confirmed libvirt will not have a problem with the behavior
change on the target end.
migration.c | 4 ++++
savevm.c | 40 ++++++++++++++++++++++++++--------------
sysemu.h | 1 +
3 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/migration.c b/migration.c
index e5ba51c..d593b1d 100644
--- a/migration.c
+++ b/migration.c
@@ -88,6 +88,10 @@ int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
return -1;
}
+ if (qemu_savevm_state_blocked(mon)) {
+ return -1;
+ }
+
if (strstart(uri, "tcp:", &p)) {
s = tcp_start_outgoing_migration(mon, p, max_throttle, detach,
blk, inc);
diff --git a/savevm.c b/savevm.c
index 90aa237..fcd8db4 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1401,19 +1401,13 @@ static int vmstate_load(QEMUFile *f, SaveStateEntry *se, int version_id)
return vmstate_load_state(f, se->vmsd, se->opaque, version_id);
}
-static int vmstate_save(QEMUFile *f, SaveStateEntry *se)
+static void vmstate_save(QEMUFile *f, SaveStateEntry *se)
{
- if (se->no_migrate) {
- return -1;
- }
-
if (!se->vmsd) { /* Old style */
se->save_state(f, se->opaque);
- return 0;
+ return;
}
vmstate_save_state(f,se->vmsd, se->opaque);
-
- return 0;
}
#define QEMU_VM_FILE_MAGIC 0x5145564d
@@ -1427,6 +1421,20 @@ static int vmstate_save(QEMUFile *f, SaveStateEntry *se)
#define QEMU_VM_SECTION_FULL 0x04
#define QEMU_VM_SUBSECTION 0x05
+bool qemu_savevm_state_blocked(Monitor *mon)
+{
+ SaveStateEntry *se;
+
+ QTAILQ_FOREACH(se, &savevm_handlers, entry) {
+ if (se->no_migrate) {
+ monitor_printf(mon, "state blocked by non-migratable device '%s'\n",
+ se->idstr);
+ return true;
+ }
+ }
+ return false;
+}
+
int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable,
int shared)
{
@@ -1508,7 +1516,6 @@ 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();
@@ -1541,11 +1548,7 @@ int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f)
qemu_put_be32(f, se->instance_id);
qemu_put_be32(f, se->version_id);
- r = vmstate_save(f, se);
- if (r < 0) {
- monitor_printf(mon, "cannot migrate with device '%s'\n", se->idstr);
- return r;
- }
+ vmstate_save(f, se);
}
qemu_put_byte(f, QEMU_VM_EOF);
@@ -1575,6 +1578,11 @@ static int qemu_savevm_state(Monitor *mon, QEMUFile *f)
saved_vm_running = vm_running;
vm_stop(0);
+ if (qemu_savevm_state_blocked(mon)) {
+ ret = -EINVAL;
+ goto out;
+ }
+
ret = qemu_savevm_state_begin(mon, f, 0, 0);
if (ret < 0)
goto out;
@@ -1692,6 +1700,10 @@ int qemu_loadvm_state(QEMUFile *f)
unsigned int v;
int ret;
+ if (qemu_savevm_state_blocked(default_mon)) {
+ return -EINVAL;
+ }
+
v = qemu_get_be32(f);
if (v != QEMU_VM_FILE_MAGIC)
return -EINVAL;
diff --git a/sysemu.h b/sysemu.h
index d8fceec..0c969f2 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -75,6 +75,7 @@ void qemu_announce_self(void);
void main_loop_wait(int nonblocking);
+bool qemu_savevm_state_blocked(Monitor *mon);
int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable,
int shared);
int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f);
next prev parent reply other threads:[~2011-01-11 21:40 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-07 7:18 [Qemu-devel] [PATCH] savevm: print migration failure to stderr rather than monitor Alex Williamson
2011-01-07 8:51 ` [Qemu-devel] " Jan Kiszka
2011-01-07 15:39 ` Alex Williamson
2011-01-07 15:46 ` Jan Kiszka
2011-01-07 15:56 ` Alex Williamson
2011-01-07 15:58 ` [Qemu-devel] [PATCH V2] savevm: use error_report for vmstate_save error Alex Williamson
2011-01-07 16:03 ` [Qemu-devel] " Jan Kiszka
2011-01-07 16:10 ` Alex Williamson
2011-01-07 16:27 ` Jan Kiszka
2011-01-07 18:41 ` Alex Williamson
2011-01-07 18:39 ` [Qemu-devel] [PATCH v3] savevm: Fix no_migrate Alex Williamson
2011-01-07 18:47 ` [Qemu-devel] " Jan Kiszka
2011-01-09 9:57 ` Michael S. Tsirkin
2011-01-09 11:44 ` Blue Swirl
2011-01-07 22:13 ` [Qemu-devel] [PATCH v4] " Alex Williamson
2011-01-09 10:02 ` [Qemu-devel] " Michael S. Tsirkin
2011-01-09 10:47 ` Michael S. Tsirkin
2011-01-10 17:47 ` Alex Williamson
2011-01-10 21:19 ` Michael S. Tsirkin
2011-01-10 10:24 ` Daniel P. Berrange
2011-01-10 14:52 ` Alex Williamson
2011-01-11 21:39 ` Alex Williamson [this message]
2011-01-11 22:39 ` [Qemu-devel] Re: [PATCH v5] " Michael S. Tsirkin
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=20110111213731.20822.21354.stgit@s20.home \
--to=alex.williamson@redhat.com \
--cc=jan.kiszka@web.de \
--cc=mst@redhat.com \
--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).