[libvirt] test failures with -Bsymbolic-functions on Ubuntu
by Claudio Bley
Hi.
I'm trying to build an Ubuntu package of the latest liberty release in
order to deploy it on a few different machines.
Unfortunately, 1 of the 93 tests failed:
----------------------------------------------------------------------
TEST: virnetserverclienttest
libvirt: error : An error occurred, but the cause is unknown
! 1 FAIL
FAIL: virnetserverclienttest
----------------------------------------------------------------------
Apparently, Ubuntu is passing the -Bsymbolic-functions flag to the
linker which causes the pre-loading and mocking of the
virEventAddTimeout function of libvirt.so to fail.
Other tests print error messages as well, but they won't fail.
Now, I'm wondering whether there is a way to prevent passing the
-Bsymbolic-functions flag to the linker when compiling the library,
but force re-linking using this flag when installing using libtool?
I'd appreciate any other ideas as well of course. Thanks!
Claudio
--
AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany
Phone: +49 341 265 310 19
Web:<http://www.av-test.org>
Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076)
Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern
11 years, 1 month
[libvirt] [PATCH 0/3] fix removal of <interface type='hostdev'>
by Laine Stump
1/3 is a cleanup, but not strictly necessary to solve the current bug
2/3 is just code movement of an entire function to avoid a forward ref.
3/3 is what actually fixes the bug.
This resolves https://bugzilla.redhat.com/show_bug.cgi?id=1005682
Laine Stump (3):
qemu: simplify calling qemuDomainHostdevNetConfigRestore
qemu: move qemuDomainRemoveNetDevice to avoid forward reference
qemu: fix removal of <interface type='hostdev'>
src/qemu/qemu_hostdev.c | 33 +++++-------
src/qemu/qemu_hotplug.c | 141 ++++++++++++++++++++++++------------------------
2 files changed, 85 insertions(+), 89 deletions(-)
--
1.8.3.1
11 years, 1 month
[libvirt] [PATCH] Fix perms for virConnectDomainXML{To, From}Native (CVE-2013-4401)
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The virConnectDomainXMLToNative API should require 'connect:write'
not 'connect:read', since it will trigger execution of the QEMU
binaries listed in the XML.
Also make virConnectDomainXMLFromNative API require a full
read-write connection and 'connect:write' permission. Although the
current impl doesn't trigger execution of QEMU, we should not
rely on that impl detail from an API permissioning POV.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
Pushed as a security fix
---
src/libvirt.c | 4 ++++
src/remote/remote_protocol.x | 4 ++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index 9f579a6..7fa675a 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -4611,6 +4611,10 @@ char *virConnectDomainXMLFromNative(virConnectPtr conn,
virDispatchError(NULL);
return NULL;
}
+ if (conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
+ }
virCheckNonNullArgGoto(nativeFormat, error);
virCheckNonNullArgGoto(nativeConfig, error);
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 810eeca..f942670 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -3826,13 +3826,13 @@ enum remote_procedure {
/**
* @generate: both
- * @acl: connect:read
+ * @acl: connect:write
*/
REMOTE_PROC_CONNECT_DOMAIN_XML_FROM_NATIVE = 135,
/**
* @generate: both
- * @acl: connect:read
+ * @acl: connect:write
*/
REMOTE_PROC_CONNECT_DOMAIN_XML_TO_NATIVE = 136,
--
1.8.3.1
11 years, 1 month
[libvirt] [PATCH]doc: fix a typo in formatdomain
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
s/effect/affect
Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
---
docs/formatdomain.html.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index c5a3fa8..7cf6b58 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -272,7 +272,7 @@
no arguments. To specify the initial argv, use the <code>initarg</code>
element, repeated as many time as is required. The <code>cmdline</code>
element, if set will be used to provide an equivalent to <code>/proc/cmdline</code>
- but will not effect init argv.
+ but will not affect init argv.
</p>
<pre>
--
1.8.2.1
11 years, 1 month
[libvirt] [PATCH] qemu: Fix augeas support for migration ports
by Michal Privoznik
Commit e3ef20d7 allows user to configure migration ports range via
qemu.conf. However, it forgot to update augeas definition file and
even the test data was malicious.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Pushed under trivial and build breaker rules.
src/qemu/libvirtd_qemu.aug | 2 ++
src/qemu/test_libvirtd_qemu.aug.in | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug
index 93a2a29..a9ff421 100644
--- a/src/qemu/libvirtd_qemu.aug
+++ b/src/qemu/libvirtd_qemu.aug
@@ -82,6 +82,8 @@ module Libvirtd_qemu =
| int_entry "keepalive_count"
let network_entry = str_entry "migration_address"
+ | int_entry "migration_port_min"
+ | int_entry "migration_port_max"
(* Each entry in the config is one of the following ... *)
let entry = vnc_entry
diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in
index 8f4b3a9..81fedd6 100644
--- a/src/qemu/test_libvirtd_qemu.aug.in
+++ b/src/qemu/test_libvirtd_qemu.aug.in
@@ -70,5 +70,5 @@ module Test_libvirtd_qemu =
{ "keepalive_count" = "5" }
{ "seccomp_sandbox" = "1" }
{ "migration_address" = "127.0.0.1" }
-{ "migration_port_min" = "1234" }
-{ "migration_port_max" = "12345" }
+{ "migration_port_min" = "49152" }
+{ "migration_port_max" = "49215" }
--
1.8.1.5
11 years, 1 month
Re: [libvirt] [Users] vdsmd seg fault
by Dan Kenigsberg
On Fri, Oct 18, 2013 at 11:32:51AM -0700, Jason Brooks wrote:
>
> On Fri, 2013-10-18 at 14:16 +0300, Dan Kenigsberg wrote:
> > On Thu, Oct 17, 2013 at 05:15:48PM -0400, Jason Brooks wrote:
> > >
> > >
> > > ----- Original Message -----
> > > > From: "Dan Ferris" <dferris(a)prometheusresearch.com>
> > > > To: "<users(a)ovirt.org>" <users(a)ovirt.org>
> > > > Sent: Tuesday, October 15, 2013 9:24:44 AM
> > > > Subject: [Users] vdsmd seg fault
> > > >
> > > > I updated to the latest Fedora 19 on two test servers, and now vdsmd
> > > > will not start.
> > > >
> > > > Systedctl says this:
> > > >
> > > > dsmd.service - Virtual Desktop Server Manager
> > > > Loaded: loaded (/usr/lib/systemd/system/vdsmd.service; enabled)
> > > > Active: failed (Result: exit-code) since Mon 2013-10-14 12:31:30
> > > > EDT; 23h ago
> > > > Process: 1788 ExecStart=/lib/systemd/systemd-vdsmd start
> > > > (code=exited, status=139)
> > > >
> > > > Oct 14 12:31:30 rs0-ovirt0.rexdb.us python[1862]: DIGEST-MD5 ask_user_info()
> > > > Oct 14 12:31:30 rs0-ovirt0.rexdb.us python[1862]: DIGEST-MD5 client step 2
> > > > Oct 14 12:31:30 rs0-ovirt0.rexdb.us python[1862]: DIGEST-MD5 ask_user_info()
> > > > Oct 14 12:31:30 rs0-ovirt0.rexdb.us python[1862]: DIGEST-MD5
> > > > make_client_response()
> > > > Oct 14 12:31:30 rs0-ovirt0.rexdb.us python[1862]: DIGEST-MD5 client step 3
> > > > Oct 14 12:31:30 rs0-ovirt0.rexdb.us systemd-vdsmd[1788]:
> > > > /lib/systemd/systemd-vdsmd: line 185: 1862 Segmentation fault
> > > > "$VDSM_TOOL" nwfilter
> > > > Oct 14 12:31:30 rs0-ovirt0.rexdb.us systemd-vdsmd[1788]: vdsm: Failed to
> > > > define network filters on libvirt[FAILED]
> > > > Oct 14 12:31:30 rs0-ovirt0.rexdb.us systemd[1]: vdsmd.service: control
> > > > process exited, code=exited status=139
> > > > Oct 14 12:31:30 rs0-ovirt0.rexdb.us systemd[1]: Failed to start Virtual
> > > > Desktop Server Manager.
> > > > Oct 14 12:31:30 rs0-ovirt0.rexdb.us systemd[1]: Unit vdsmd.service
> > > > entered failed state.
> > > >
> > > > Has anyone else experienced this?
> > >
> > > I just hit this on one of my test installs.
> > >
> > > I did yum downgrade libvirt* and then vdsmd would start
> >
> > Which was the faulty libvirt? Was there anything interesting at the
> > /var/log/libvirtd.log?
>
> libvirt-1.0.5.6-3.fc19 -- it started fine until I rebooted. SElinux is
> permissive on these machines, btw. These machines are nested inside of
> my main oVirt install, as well.
>
> I couldn't see anything in the libvirtd.log that looked different from
> the libvirtd.log on a node w/ the downgraded libvirt.
Maybe someone on libvir-list can suggest why something like
conn.nwfilterLookupByName(self.filterName).undefine()
conn.nwfilterDefineXML(self.buildFilterXml()
suddenly segfaults when run in a systemd unit context?
11 years, 1 month
[libvirt] [PATCH] Fix a problem introduced by commit 99889012
by Geoff Hickey
The meaning of one line of code was accidentally inverted.
---
src/esx/esx_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 5d8baa5..886d984 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -1003,7 +1003,7 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
}
/* Connect to vCenter */
- if (!priv->parsedUri->vCenter) {
+ if (priv->parsedUri->vCenter) {
if (STREQ(priv->parsedUri->vCenter, "*")) {
if (!potentialVCenterIpAddress) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
--
1.8.1.2
11 years, 1 month
[libvirt] [PATCH] docs: Expand description of host-model CPU mode
by Jiri Denemark
host-model is a nice idea but it's current implementation make it
useless on some hosts so it should be used with care.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
docs/formatdomain.html.in | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index c5a3fa8..491a6a9 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -924,7 +924,16 @@
model even if the destination host contains more capable CPUs for
the running instance of the guest; but shutting down and restarting
the guest may present different hardware to the guest according to
- the capabilities of the new host.</dd>
+ the capabilities of the new host. <strong>Beware</strong>, due to the
+ way libvirt detects host CPU and due to the fact libvirt does not
+ talk to QEMU/KVM when creating the CPU model, CPU configuration
+ created using <code>host-model</code> may not work as expected. The
+ guest CPU may differ from the configuration and it may also confuse
+ guest OS by using a combination of CPU features and other parameters
+ (such as CPUID level) that don't work. Until these issues are fixed,
+ it's a good idea to avoid using <code>host-model</code> and use
+ <code>custom</code> mode with just the CPU model from host
+ capabilities XML.</dd>
<dt><code>host-passthrough</code></dt>
<dd>With this mode, the CPU visible to the guest should be exactly
the same as the host CPU even in the aspects that libvirt does not
--
1.8.4
11 years, 1 month
[libvirt] [PATCH] qemu: Make migration port range configurable
by Jiri Denemark
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu.conf | 11 +++++++++++
src/qemu/qemu_conf.c | 21 +++++++++++++++++++++
src/qemu/qemu_conf.h | 2 ++
src/qemu/qemu_driver.c | 4 ++--
src/qemu/test_libvirtd_qemu.aug.in | 2 ++
5 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index bf57b9c..a6d7c15 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -436,3 +436,14 @@
# Override the listen address for all incoming migrations. Defaults to
# 0.0.0.0 or :: in case if both host and qemu are capable of IPv6.
#migration_address = "127.0.0.1"
+
+
+# Override the port range used for incoming migrations.
+#
+# Minimum must be greater than 0, however when QEMU is not running as root,
+# setting the minimum to be lower than 1024 will not work.
+#
+# Maximum must be lower then 65535.
+#
+#migration_port_min = 49152
+#migration_port_max = 49215
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 44a2296..b80f399 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -225,6 +225,9 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged)
cfg->webSocketPortMin = QEMU_WEBSOCKET_PORT_MIN;
cfg->webSocketPortMax = QEMU_WEBSOCKET_PORT_MAX;
+ cfg->migrationPortMin = QEMU_MIGRATION_PORT_MIN;
+ cfg->migrationPortMax = QEMU_MIGRATION_PORT_MAX;
+
#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
/* For privileged driver, try and find hugepage mount automatically.
* Non-privileged driver requires admin to create a dir for the
@@ -459,6 +462,24 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
goto cleanup;
}
+ GET_VALUE_LONG("migration_port_min", cfg->migrationPortMin);
+ if (cfg->migrationPortMin <= 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("%s: migration_port_min: port must be greater than 0"),
+ filename);
+ goto cleanup;
+ }
+
+ GET_VALUE_LONG("migration_port_max", cfg->migrationPortMax);
+ if (cfg->migrationPortMax > 65535 ||
+ cfg->migrationPortMax < cfg->migrationPortMin) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("%s: migration_port_max: port must be between "
+ "the minimal port %d and 65535"),
+ filename, cfg->migrationPortMin);
+ goto cleanup;
+ }
+
p = virConfGetValue(conf, "user");
CHECK_TYPE("user", VIR_CONF_STRING);
if (p && p->str &&
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 863d215..2b04cdb 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -159,6 +159,8 @@ struct _virQEMUDriverConfig {
/* The default for -incoming */
char *migrationAddress;
+ int migrationPortMin;
+ int migrationPortMax;
};
/* Main driver state */
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 895681b..4977b12 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -688,8 +688,8 @@ qemuStateInitialize(bool privileged,
goto error;
if ((qemu_driver->migrationPorts =
- virPortAllocatorNew(QEMU_MIGRATION_PORT_MIN,
- QEMU_MIGRATION_PORT_MAX)) == NULL)
+ virPortAllocatorNew(cfg->migrationPortMin,
+ cfg->migrationPortMax)) == NULL)
goto error;
if (qemuSecurityInit(qemu_driver) < 0)
diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in
index 7af3f64..71a29df 100644
--- a/src/qemu/test_libvirtd_qemu.aug.in
+++ b/src/qemu/test_libvirtd_qemu.aug.in
@@ -68,3 +68,5 @@ module Test_libvirtd_qemu =
{ "keepalive_count" = "5" }
{ "seccomp_sandbox" = "1" }
{ "migration_address" = "127.0.0.1" }
+{ "migration_port_min" = "1234" }
+{ "migration_port_max" = "12345" }
--
1.8.3.2
11 years, 1 month
[libvirt] [PATCH] qemu: Avoid assigning unavailable migration ports
by Jiri Denemark
From: WangYufei <james.wangyufei(a)huawei.com>
https://bugzilla.redhat.com/show_bug.cgi?id=1019053
When we migrate vms concurrently, there's a chance that libvirtd on
destination assigns the same port for different migrations, which will
lead to migration failure during prepare phase on destination. So we use
virPortAllocator here to solve the problem.
Signed-off-by: WangYufei <james.wangyufei(a)huawei.com>
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_command.h | 3 +++
src/qemu/qemu_conf.h | 6 +++---
src/qemu/qemu_domain.h | 1 +
src/qemu/qemu_driver.c | 6 ++++++
src/qemu/qemu_migration.c | 39 +++++++++++++++++++++++++--------------
5 files changed, 38 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 2e2acfb..3277ba4 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -51,6 +51,9 @@
# define QEMU_WEBSOCKET_PORT_MIN 5700
# define QEMU_WEBSOCKET_PORT_MAX 65535
+# define QEMU_MIGRATION_PORT_MIN 49152
+# define QEMU_MIGRATION_PORT_MAX 49215
+
typedef struct _qemuBuildCommandLineCallbacks qemuBuildCommandLineCallbacks;
typedef qemuBuildCommandLineCallbacks *qemuBuildCommandLineCallbacksPtr;
struct _qemuBuildCommandLineCallbacks {
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index ea3c691..863d215 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -225,6 +225,9 @@ struct _virQEMUDriver {
/* Immutable pointer, self-locking APIs */
virPortAllocatorPtr webSocketPorts;
+ /* Immutable pointer, self-locking APIs */
+ virPortAllocatorPtr migrationPorts;
+
/* Immutable pointer, lockless APIs*/
virSysinfoDefPtr hostsysinfo;
@@ -246,9 +249,6 @@ struct _qemuDomainCmdlineDef {
char **env_value;
};
-/* Port numbers used for KVM migration. */
-# define QEMUD_MIGRATION_FIRST_PORT 49152
-# define QEMUD_MIGRATION_NUM_PORTS 64
void qemuDomainCmdlineDefFree(qemuDomainCmdlineDefPtr def);
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 5d9fab9..2f9d20f 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -160,6 +160,7 @@ struct _qemuDomainObjPrivate {
unsigned long migMaxBandwidth;
char *origname;
int nbdPort; /* Port used for migration with NBD */
+ int migrationPort;
virChrdevsPtr devs;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 746da26..895681b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -687,6 +687,11 @@ qemuStateInitialize(bool privileged,
cfg->webSocketPortMax)) == NULL)
goto error;
+ if ((qemu_driver->migrationPorts =
+ virPortAllocatorNew(QEMU_MIGRATION_PORT_MIN,
+ QEMU_MIGRATION_PORT_MAX)) == NULL)
+ goto error;
+
if (qemuSecurityInit(qemu_driver) < 0)
goto error;
@@ -993,6 +998,7 @@ qemuStateCleanup(void) {
virObjectUnref(qemu_driver->domains);
virObjectUnref(qemu_driver->remotePorts);
virObjectUnref(qemu_driver->webSocketPorts);
+ virObjectUnref(qemu_driver->migrationPorts);
virObjectUnref(qemu_driver->xmlopt);
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 38edadb..a77aeb7 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2141,6 +2141,9 @@ qemuMigrationPrepareCleanup(virQEMUDriverPtr driver,
qemuDomainJobTypeToString(priv->job.active),
qemuDomainAsyncJobTypeToString(priv->job.asyncJob));
+ virPortAllocatorRelease(driver->migrationPorts, priv->migrationPort);
+ priv->migrationPort = 0;
+
if (!qemuMigrationJobIsActive(vm, QEMU_ASYNC_JOB_MIGRATION_IN))
return;
qemuDomainObjDiscardAsyncJob(driver, vm);
@@ -2156,7 +2159,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
virDomainDefPtr *def,
const char *origname,
virStreamPtr st,
- unsigned int port,
+ unsigned short port,
+ bool autoPort,
const char *listenAddress,
unsigned long flags)
{
@@ -2436,6 +2440,8 @@ done:
goto cleanup;
}
+ if (autoPort)
+ priv->migrationPort = port;
ret = 0;
cleanup:
@@ -2503,7 +2509,7 @@ qemuMigrationPrepareTunnel(virQEMUDriverPtr driver,
ret = qemuMigrationPrepareAny(driver, dconn, cookiein, cookieinlen,
cookieout, cookieoutlen, def, origname,
- st, 0, NULL, flags);
+ st, 0, false, NULL, flags);
return ret;
}
@@ -2522,8 +2528,8 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
const char *listenAddress,
unsigned long flags)
{
- static int port = 0;
- int this_port;
+ unsigned short port = 0;
+ bool autoPort = true;
char *hostname = NULL;
const char *p;
char *uri_str = NULL;
@@ -2550,8 +2556,8 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
* to be a correct hostname which refers to the target machine).
*/
if (uri_in == NULL) {
- this_port = QEMUD_MIGRATION_FIRST_PORT + port++;
- if (port == QEMUD_MIGRATION_NUM_PORTS) port = 0;
+ if (virPortAllocatorAcquire(driver->migrationPorts, &port) < 0)
+ goto cleanup;
/* Get hostname */
if ((hostname = virGetHostname()) == NULL)
@@ -2570,7 +2576,7 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
* new targets accept both syntaxes though.
*/
/* Caller frees */
- if (virAsprintf(uri_out, "tcp:%s:%d", hostname, this_port) < 0)
+ if (virAsprintf(uri_out, "tcp:%s:%d", hostname, port) < 0)
goto cleanup;
} else {
/* Check the URI starts with "tcp:". We will escape the
@@ -2607,16 +2613,16 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
if (uri->port == 0) {
/* Generate a port */
- this_port = QEMUD_MIGRATION_FIRST_PORT + port++;
- if (port == QEMUD_MIGRATION_NUM_PORTS)
- port = 0;
+ if (virPortAllocatorAcquire(driver->migrationPorts, &port) < 0)
+ goto cleanup;
/* Caller frees */
- if (virAsprintf(uri_out, "%s:%d", uri_in, this_port) < 0)
+ if (virAsprintf(uri_out, "%s:%d", uri_in, port) < 0)
goto cleanup;
} else {
- this_port = uri->port;
+ port = uri->port;
+ autoPort = false;
}
}
@@ -2625,12 +2631,15 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
ret = qemuMigrationPrepareAny(driver, dconn, cookiein, cookieinlen,
cookieout, cookieoutlen, def, origname,
- NULL, this_port, listenAddress, flags);
+ NULL, port, autoPort, listenAddress, flags);
cleanup:
virURIFree(uri);
VIR_FREE(hostname);
- if (ret != 0)
+ if (ret != 0) {
VIR_FREE(*uri_out);
+ if (autoPort)
+ virPortAllocatorRelease(driver->migrationPorts, port);
+ }
return ret;
}
@@ -4410,6 +4419,8 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
}
qemuMigrationStopNBDServer(driver, vm, mig);
+ virPortAllocatorRelease(driver->migrationPorts, priv->migrationPort);
+ priv->migrationPort = 0;
if (flags & VIR_MIGRATE_PERSIST_DEST) {
virDomainDefPtr vmdef;
--
1.8.3.2
11 years, 1 month