|
|
9119d9 |
From 01a7d6da44bbfe7719fbfe37dec840e05338dcc6 Mon Sep 17 00:00:00 2001
|
|
|
9119d9 |
Message-Id: <01a7d6da44bbfe7719fbfe37dec840e05338dcc6@dist-git>
|
|
|
9119d9 |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
Date: Tue, 23 Sep 2014 15:47:55 +0200
|
|
|
9119d9 |
Subject: [PATCH] qemu: Prepare support for arbitrary migration protocol
|
|
|
9119d9 |
|
|
|
9119d9 |
Currently we only support TCP protocol for native QEMU migration but
|
|
|
9119d9 |
this is going to be changed. Let's make the code more general and remove
|
|
|
9119d9 |
hardcoded TCP protocol from several places.
|
|
|
9119d9 |
|
|
|
9119d9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1013055
|
|
|
9119d9 |
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
(cherry picked from commit e16a39fcd3bda4021e953c817bfb62307785ab61)
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
---
|
|
|
9119d9 |
src/qemu/qemu_migration.c | 36 ++++++++++++++++++++++++------------
|
|
|
9119d9 |
src/qemu/qemu_monitor.c | 3 ++-
|
|
|
9119d9 |
src/qemu/qemu_monitor.h | 1 +
|
|
|
9119d9 |
3 files changed, 27 insertions(+), 13 deletions(-)
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
|
|
|
9119d9 |
index a66ea54..6b690b8 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_migration.c
|
|
|
9119d9 |
+++ b/src/qemu/qemu_migration.c
|
|
|
9119d9 |
@@ -2457,6 +2457,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
|
|
|
9119d9 |
virDomainDefPtr *def,
|
|
|
9119d9 |
const char *origname,
|
|
|
9119d9 |
virStreamPtr st,
|
|
|
9119d9 |
+ const char *protocol,
|
|
|
9119d9 |
unsigned short port,
|
|
|
9119d9 |
bool autoPort,
|
|
|
9119d9 |
const char *listenAddress,
|
|
|
9119d9 |
@@ -2569,6 +2570,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
|
|
|
9119d9 |
struct addrinfo *info = NULL;
|
|
|
9119d9 |
struct addrinfo hints = { .ai_flags = AI_ADDRCONFIG,
|
|
|
9119d9 |
.ai_socktype = SOCK_STREAM };
|
|
|
9119d9 |
+ const char *incFormat;
|
|
|
9119d9 |
|
|
|
9119d9 |
if (getaddrinfo("::", NULL, &hints, &info) == 0) {
|
|
|
9119d9 |
freeaddrinfo(info);
|
|
|
9119d9 |
@@ -2605,21 +2607,27 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
|
|
|
9119d9 |
} else {
|
|
|
9119d9 |
/* listenAddress is a hostname */
|
|
|
9119d9 |
}
|
|
|
9119d9 |
- } else {
|
|
|
9119d9 |
+ } else if (qemuIPv6Capable && hostIPv6Capable) {
|
|
|
9119d9 |
/* Listen on :: instead of 0.0.0.0 if QEMU understands it
|
|
|
9119d9 |
* and there is at least one IPv6 address configured
|
|
|
9119d9 |
*/
|
|
|
9119d9 |
- listenAddress = qemuIPv6Capable && hostIPv6Capable ?
|
|
|
9119d9 |
- encloseAddress = true, "::" : "0.0.0.0";
|
|
|
9119d9 |
+ listenAddress = "::";
|
|
|
9119d9 |
+ encloseAddress = true;
|
|
|
9119d9 |
+ } else {
|
|
|
9119d9 |
+ listenAddress = "0.0.0.0";
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
- /* QEMU will be started with -incoming [<IPv6 addr>]:port,
|
|
|
9119d9 |
- * -incoming <IPv4 addr>:port or -incoming <hostname>:port
|
|
|
9119d9 |
+ /* QEMU will be started with
|
|
|
9119d9 |
+ * -incoming protocol:[<IPv6 addr>]:port,
|
|
|
9119d9 |
+ * -incoming protocol:<IPv4 addr>:port, or
|
|
|
9119d9 |
+ * -incoming protocol:<hostname>:port
|
|
|
9119d9 |
*/
|
|
|
9119d9 |
- if ((encloseAddress &&
|
|
|
9119d9 |
- virAsprintf(&migrateFrom, "tcp:[%s]:%d", listenAddress, port) < 0) ||
|
|
|
9119d9 |
- (!encloseAddress &&
|
|
|
9119d9 |
- virAsprintf(&migrateFrom, "tcp:%s:%d", listenAddress, port) < 0))
|
|
|
9119d9 |
+ if (encloseAddress)
|
|
|
9119d9 |
+ incFormat = "%s:[%s]:%d";
|
|
|
9119d9 |
+ else
|
|
|
9119d9 |
+ incFormat = "%s:%s:%d";
|
|
|
9119d9 |
+ if (virAsprintf(&migrateFrom, incFormat,
|
|
|
9119d9 |
+ protocol, listenAddress, port) < 0)
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
@@ -2812,7 +2820,7 @@ qemuMigrationPrepareTunnel(virQEMUDriverPtr driver,
|
|
|
9119d9 |
|
|
|
9119d9 |
ret = qemuMigrationPrepareAny(driver, dconn, cookiein, cookieinlen,
|
|
|
9119d9 |
cookieout, cookieoutlen, def, origname,
|
|
|
9119d9 |
- st, 0, false, NULL, flags);
|
|
|
9119d9 |
+ st, NULL, 0, false, NULL, flags);
|
|
|
9119d9 |
return ret;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
@@ -2955,7 +2963,8 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
|
|
|
9119d9 |
|
|
|
9119d9 |
ret = qemuMigrationPrepareAny(driver, dconn, cookiein, cookieinlen,
|
|
|
9119d9 |
cookieout, cookieoutlen, def, origname,
|
|
|
9119d9 |
- NULL, port, autoPort, listenAddress, flags);
|
|
|
9119d9 |
+ NULL, uri ? uri->scheme : "tcp",
|
|
|
9119d9 |
+ port, autoPort, listenAddress, flags);
|
|
|
9119d9 |
cleanup:
|
|
|
9119d9 |
virURIFree(uri);
|
|
|
9119d9 |
VIR_FREE(hostname);
|
|
|
9119d9 |
@@ -3171,6 +3180,7 @@ struct _qemuMigrationSpec {
|
|
|
9119d9 |
enum qemuMigrationDestinationType destType;
|
|
|
9119d9 |
union {
|
|
|
9119d9 |
struct {
|
|
|
9119d9 |
+ const char *protocol;
|
|
|
9119d9 |
const char *name;
|
|
|
9119d9 |
int port;
|
|
|
9119d9 |
} host;
|
|
|
9119d9 |
@@ -3538,6 +3548,7 @@ qemuMigrationRun(virQEMUDriverPtr driver,
|
|
|
9119d9 |
switch (spec->destType) {
|
|
|
9119d9 |
case MIGRATION_DEST_HOST:
|
|
|
9119d9 |
ret = qemuMonitorMigrateToHost(priv->mon, migrate_flags,
|
|
|
9119d9 |
+ spec->dest.host.protocol,
|
|
|
9119d9 |
spec->dest.host.name,
|
|
|
9119d9 |
spec->dest.host.port);
|
|
|
9119d9 |
break;
|
|
|
9119d9 |
@@ -3678,7 +3689,7 @@ qemuMigrationRun(virQEMUDriverPtr driver,
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
-/* Perform migration using QEMU's native TCP migrate support,
|
|
|
9119d9 |
+/* Perform migration using QEMU's native migrate support,
|
|
|
9119d9 |
* not encrypted obviously
|
|
|
9119d9 |
*/
|
|
|
9119d9 |
static int doNativeMigrate(virQEMUDriverPtr driver,
|
|
|
9119d9 |
@@ -3712,6 +3723,7 @@ static int doNativeMigrate(virQEMUDriverPtr driver,
|
|
|
9119d9 |
spec.destType = MIGRATION_DEST_CONNECT_HOST;
|
|
|
9119d9 |
else
|
|
|
9119d9 |
spec.destType = MIGRATION_DEST_HOST;
|
|
|
9119d9 |
+ spec.dest.host.protocol = uribits->scheme;
|
|
|
9119d9 |
spec.dest.host.name = uribits->server;
|
|
|
9119d9 |
spec.dest.host.port = uribits->port;
|
|
|
9119d9 |
spec.fwdType = MIGRATION_FWD_DIRECT;
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
|
|
|
9119d9 |
index db2fe71..ab252fd 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_monitor.c
|
|
|
9119d9 |
+++ b/src/qemu/qemu_monitor.c
|
|
|
9119d9 |
@@ -2209,6 +2209,7 @@ int qemuMonitorMigrateToFd(qemuMonitorPtr mon,
|
|
|
9119d9 |
|
|
|
9119d9 |
int qemuMonitorMigrateToHost(qemuMonitorPtr mon,
|
|
|
9119d9 |
unsigned int flags,
|
|
|
9119d9 |
+ const char *protocol,
|
|
|
9119d9 |
const char *hostname,
|
|
|
9119d9 |
int port)
|
|
|
9119d9 |
{
|
|
|
9119d9 |
@@ -2224,7 +2225,7 @@ int qemuMonitorMigrateToHost(qemuMonitorPtr mon,
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
|
|
|
9119d9 |
- if (virAsprintf(&uri, "tcp:%s:%d", hostname, port) < 0)
|
|
|
9119d9 |
+ if (virAsprintf(&uri, "%s:%s:%d", protocol, hostname, port) < 0)
|
|
|
9119d9 |
return -1;
|
|
|
9119d9 |
|
|
|
9119d9 |
if (mon->json)
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
|
|
|
9119d9 |
index ed2cf71..ed96011 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_monitor.h
|
|
|
9119d9 |
+++ b/src/qemu/qemu_monitor.h
|
|
|
9119d9 |
@@ -485,6 +485,7 @@ int qemuMonitorMigrateToFd(qemuMonitorPtr mon,
|
|
|
9119d9 |
|
|
|
9119d9 |
int qemuMonitorMigrateToHost(qemuMonitorPtr mon,
|
|
|
9119d9 |
unsigned int flags,
|
|
|
9119d9 |
+ const char *protocol,
|
|
|
9119d9 |
const char *hostname,
|
|
|
9119d9 |
int port);
|
|
|
9119d9 |
|
|
|
9119d9 |
--
|
|
|
9119d9 |
2.1.1
|
|
|
9119d9 |
|