From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=59227 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PbHLm-0007Us-Be for qemu-devel@nongnu.org; Fri, 07 Jan 2011 13:47:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PbHLk-0005Eu-RX for qemu-devel@nongnu.org; Fri, 07 Jan 2011 13:47:46 -0500 Received: from fmmailgate01.web.de ([217.72.192.221]:49567) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PbHLd-0005Dd-0Z for qemu-devel@nongnu.org; Fri, 07 Jan 2011 13:47:44 -0500 Message-ID: <4D275FC6.9010204@web.de> Date: Fri, 07 Jan 2011 19:47:34 +0100 From: Jan Kiszka MIME-Version: 1.0 References: <20110107155817.12891.70829.stgit@s20.home> <20110107183518.13483.52633.stgit@s20.home> In-Reply-To: <20110107183518.13483.52633.stgit@s20.home> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig72B36F5389555C959F320EB9" Sender: jan.kiszka@web.de Subject: [Qemu-devel] Re: [PATCH v3] savevm: Fix no_migrate List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Williamson Cc: mst@redhat.com, qemu-devel@nongnu.org, quintela@redhat.com This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig72B36F5389555C959F320EB9 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Am 07.01.2011 19:39, Alex Williamson wrote: > 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. >=20 > 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. >=20 > Signed-off-by: Alex Williamson > --- >=20 > Daniel, adding you to see if libvirt cares about the difference in > whether the target exits on migration failure as noted above. >=20 > Also adding Michael as he's complained about the no_migrate check > happening so late in the process. >=20 > migration.c | 4 ++++ > savevm.c | 39 +++++++++++++++++++++++++-------------- > sysemu.h | 1 + > 3 files changed, 30 insertions(+), 14 deletions(-) >=20 > 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, QOb= ject **ret_data) > return -1; > } > =20 > + if (qemu_savevm_state_blocked(mon)) { > + return -1; > + } > + > if (strstart(uri, "tcp:", &p)) { > s =3D tcp_start_outgoing_migration(mon, p, max_throttle, detac= h, > blk, inc); > diff --git a/savevm.c b/savevm.c > index 90aa237..6675c33 100644 > --- a/savevm.c > +++ b/savevm.c > @@ -1401,19 +1401,13 @@ static int vmstate_load(QEMUFile *f, SaveStateE= ntry *se, int version_id) > return vmstate_load_state(f, se->vmsd, se->opaque, version_id); > } > =20 > -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; > } > =20 > #define QEMU_VM_FILE_MAGIC 0x5145564d > @@ -1427,6 +1421,20 @@ static int vmstate_save(QEMUFile *f, SaveStateEn= try *se) > #define QEMU_VM_SECTION_FULL 0x04 > #define QEMU_VM_SUBSECTION 0x05 > =20 > +int 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 devic= e '%s'\n", > + se->idstr); > + return -EINVAL; > + } > + } > + return 0; > +} > + > 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, QEMUF= ile *f) > int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f) > { > SaveStateEntry *se; > - int r; > =20 > cpu_synchronize_all_states(); > =20 > @@ -1541,11 +1548,7 @@ int qemu_savevm_state_complete(Monitor *mon, QEM= UFile *f) > qemu_put_be32(f, se->instance_id); > qemu_put_be32(f, se->version_id); > =20 > - r =3D vmstate_save(f, se); > - if (r < 0) { > - monitor_printf(mon, "cannot migrate with device '%s'\n", s= e->idstr); > - return r; > - } > + vmstate_save(f, se); > } > =20 > qemu_put_byte(f, QEMU_VM_EOF); > @@ -1575,6 +1578,10 @@ static int qemu_savevm_state(Monitor *mon, QEMUF= ile *f) > saved_vm_running =3D vm_running; > vm_stop(0); > =20 > + ret =3D qemu_savevm_state_blocked(mon); > + if (ret < 0) > + goto out; > + { } :) (Is there really no one bored out there and wants to write a check-patch script?) > ret =3D qemu_savevm_state_begin(mon, f, 0, 0); > if (ret < 0) > goto out; > @@ -1692,6 +1699,10 @@ int qemu_loadvm_state(QEMUFile *f) > unsigned int v; > int ret; > =20 > + if (qemu_savevm_state_blocked(default_mon)) { > + return -EINVAL; > + } > + > v =3D qemu_get_be32(f); > if (v !=3D QEMU_VM_FILE_MAGIC) > return -EINVAL; > diff --git a/sysemu.h b/sysemu.h > index e728ea1..eefaba5 100644 > --- a/sysemu.h > +++ b/sysemu.h > @@ -75,6 +75,7 @@ void qemu_announce_self(void); > =20 > void main_loop_wait(int nonblocking); > =20 > +int 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); >=20 Much nicer! Jan --------------enig72B36F5389555C959F320EB9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.15 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/ iEYEARECAAYFAk0nX8YACgkQitSsb3rl5xQvqgCbBAKNW2t5/+KgXslifut7hT+M CXQAniyIyNXSkuVJyj/vcHf9GK65Twf1 =UJnr -----END PGP SIGNATURE----- --------------enig72B36F5389555C959F320EB9--