[libvirt] [Patch v2 0/2] Some fixes about p2p migration

When we migrate a guest from remote host to localhost by p2p, the libvirtd on remote host will be deadlock. This patch fixes a bug and we can avoid the deadlock with this patch. The steps to reproduce this bug: # virsh -c qemu+ssh://<remotehost IP>/system migrate --p2p <domain name> qemu+ssh:///system v2: - report error instead of changing the desturi as Daniel suggested - improve the documentation of desturi Wen Congyang (2): report error when specifying wrong desturi doc: improve the documentation of desturi src/libvirt.c | 17 +++++++++++++++++ tools/virsh.c | 2 +- tools/virsh.pod | 13 +++++++++++++ 3 files changed, 31 insertions(+), 1 deletions(-)

When we do peer2peer migration, the dest uri is an address of the target host as seen from the source machine. So we must specify the ip or hostname of target host in dest uri. If we do not specify it, report an error to the user. Signed-off-by: Wen Congyang <wency@cn.fujitsu.com> --- src/libvirt.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index a4789bc..52d3278 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -3571,12 +3571,29 @@ virDomainMigratePeer2Peer (virDomainPtr domain, const char *uri, unsigned long bandwidth) { + xmlURIPtr tempuri = NULL; + if (!domain->conn->driver->domainMigratePerform) { virLibConnError (domain->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__); virDispatchError(domain->conn); return -1; } + tempuri = xmlParseURI(uri); + if (!tempuri) { + virLibConnError (domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__); + virDispatchError(domain->conn); + return -1; + } + + if (!tempuri->server || STRPREFIX(tempuri->server, "localhost")) { + virLibConnError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__); + virDispatchError(domain->conn); + xmlFreeURI(tempuri); + return -1; + } + xmlFreeURI(tempuri); + /* Perform the migration. The driver isn't supposed to return * until the migration is complete. */ -- 1.7.1

On Wed, Jan 12, 2011 at 02:12:29PM +0800, Wen Congyang wrote:
When we do peer2peer migration, the dest uri is an address of the target host as seen from the source machine. So we must specify the ip or hostname of target host in dest uri. If we do not specify it, report an error to the user.
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
--- src/libvirt.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c index a4789bc..52d3278 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -3571,12 +3571,29 @@ virDomainMigratePeer2Peer (virDomainPtr domain, const char *uri, unsigned long bandwidth) { + xmlURIPtr tempuri = NULL; + if (!domain->conn->driver->domainMigratePerform) { virLibConnError (domain->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__); virDispatchError(domain->conn); return -1; }
+ tempuri = xmlParseURI(uri); + if (!tempuri) { + virLibConnError (domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__); + virDispatchError(domain->conn); + return -1; + } + + if (!tempuri->server || STRPREFIX(tempuri->server, "localhost")) { + virLibConnError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__); + virDispatchError(domain->conn); + xmlFreeURI(tempuri); + return -1; + } + xmlFreeURI(tempuri);
Technically we should do this in the QEMU driver, but since no other hypervisor supports p2p migration, this is fine for now. ACK Daniel

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com> --- tools/virsh.c | 2 +- tools/virsh.pod | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index 55e2a68..018e363 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -3375,7 +3375,7 @@ static const vshCmdOptDef opts_migrate[] = { {"copy-storage-all", VSH_OT_BOOL, 0, N_("migration with non-shared storage with full disk copy")}, {"copy-storage-inc", VSH_OT_BOOL, 0, N_("migration with non-shared storage with incremental copy (same base image shared between source and destination)")}, {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")}, - {"desturi", VSH_OT_DATA, VSH_OFLAG_REQ, N_("connection URI of the destination host")}, + {"desturi", VSH_OT_DATA, VSH_OFLAG_REQ, N_("connection URI of the destination host as seen from the client(normal migration) or source(p2p migration)")}, {"migrateuri", VSH_OT_DATA, 0, N_("migration URI, usually can be omitted")}, {"dname", VSH_OT_DATA, 0, N_("rename to new name during migration (if supported)")}, {NULL, 0, 0, NULL} diff --git a/tools/virsh.pod b/tools/virsh.pod index 9c45a61..0e03d68 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -505,6 +505,19 @@ I<migrateuri> is the migration URI, which usually can be omitted. I<dname> is used for renaming the domain to new name during migration, which also usually can be omitted. +B<Note>: The I<desturi> parameter for normal migration and peer2peer migration +has different semantics: + +=over 4 + +=item * normal migration: the I<desturi> is an address of the target host as +seen from the client machine. + +=item * peer2peer migration: the I<desturi> is an address of the target host as +seen from the source machine. + +=back + =item B<migrate-setmaxdowntime> I<domain-id> I<downtime> Set maximum tolerable downtime for a domain which is being live-migrated to -- 1.7.1

On Wed, Jan 12, 2011 at 02:12:39PM +0800, Wen Congyang wrote:
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
--- tools/virsh.c | 2 +- tools/virsh.pod | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c index 55e2a68..018e363 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -3375,7 +3375,7 @@ static const vshCmdOptDef opts_migrate[] = { {"copy-storage-all", VSH_OT_BOOL, 0, N_("migration with non-shared storage with full disk copy")}, {"copy-storage-inc", VSH_OT_BOOL, 0, N_("migration with non-shared storage with incremental copy (same base image shared between source and destination)")}, {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")}, - {"desturi", VSH_OT_DATA, VSH_OFLAG_REQ, N_("connection URI of the destination host")}, + {"desturi", VSH_OT_DATA, VSH_OFLAG_REQ, N_("connection URI of the destination host as seen from the client(normal migration) or source(p2p migration)")}, {"migrateuri", VSH_OT_DATA, 0, N_("migration URI, usually can be omitted")}, {"dname", VSH_OT_DATA, 0, N_("rename to new name during migration (if supported)")}, {NULL, 0, 0, NULL} diff --git a/tools/virsh.pod b/tools/virsh.pod index 9c45a61..0e03d68 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -505,6 +505,19 @@ I<migrateuri> is the migration URI, which usually can be omitted. I<dname> is used for renaming the domain to new name during migration, which also usually can be omitted.
+B<Note>: The I<desturi> parameter for normal migration and peer2peer migration +has different semantics: + +=over 4 + +=item * normal migration: the I<desturi> is an address of the target host as +seen from the client machine. + +=item * peer2peer migration: the I<desturi> is an address of the target host as +seen from the source machine. + +=back + =item B<migrate-setmaxdowntime> I<domain-id> I<downtime>
Set maximum tolerable downtime for a domain which is being live-migrated to
ACK Daniel

On 01/12/2011 05:25 AM, Daniel P. Berrange wrote:
On Wed, Jan 12, 2011 at 02:12:39PM +0800, Wen Congyang wrote:
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
+=item * normal migration: the I<desturi> is an address of the target host as +seen from the client machine. + +=item * peer2peer migration: the I<desturi> is an address of the target host as +seen from the source machine. + +=back + =item B<migrate-setmaxdowntime> I<domain-id> I<downtime>
Set maximum tolerable downtime for a domain which is being live-migrated to
ACK
I've pushed both patches. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

At 01/13/2011 12:54 AM, Eric Blake Write:
On 01/12/2011 05:25 AM, Daniel P. Berrange wrote:
On Wed, Jan 12, 2011 at 02:12:39PM +0800, Wen Congyang wrote:
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
+=item * normal migration: the I<desturi> is an address of the target host as +seen from the client machine. + +=item * peer2peer migration: the I<desturi> is an address of the target host as +seen from the source machine. + +=back + =item B<migrate-setmaxdowntime> I<domain-id> I<downtime>
Set maximum tolerable downtime for a domain which is being live-migrated to
ACK
I've pushed both patches.
Thanks.
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Wen Congyang