[libvirt] [libvirt-glib] events: Mark 'eventlock' as static
by Christophe Fergeau
It's not used outside of the libvirt-glib-event.c file, so there is no
good reason for not having it static. As it was not listed in
libvirt-glib.sym, this will make no change to the publicly exported
symbols (ie this is not an ABI change).
---
libvirt-glib/libvirt-glib-event.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libvirt-glib/libvirt-glib-event.c b/libvirt-glib/libvirt-glib-event.c
index f8227d6..4548aa6 100644
--- a/libvirt-glib/libvirt-glib-event.c
+++ b/libvirt-glib/libvirt-glib-event.c
@@ -110,7 +110,7 @@ struct gvir_event_timeout
virFreeCallback ff;
};
-GMutex *eventlock = NULL;
+static GMutex *eventlock = NULL;
static int nextwatch = 1;
static GPtrArray *handles;
--
2.5.0
8 years, 6 months
[libvirt] [PATCH] build: work around gcc 6.0 warnings
by Eric Blake
gcc 6.0 added an annoying warning:
fdstream.c: In function 'virFDStreamWrite':
fdstream.c:390:29: error: logical 'or' of equal expressions [-Werror=logical-op]
if (errno == EAGAIN || errno == EWOULDBLOCK) {
^~
fdstream.c: In function 'virFDStreamRead':
fdstream.c:440:29: error: logical 'or' of equal expressions [-Werror=logical-op]
if (errno == EAGAIN || errno == EWOULDBLOCK) {
^~
This makes it impossible to build out-of-the-box on rawhide,
and we aren't guaranteed that the gcc bug will be fixed in a
timely manner:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602
So work around it by further complicating the logic to thwart the
compiler.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
This is a build-breaker fix for rawhide; but I'll wait for a day
for any reasons why I should not push it during freeze.
src/fdstream.c | 8 +++++---
src/rpc/virnetsshsession.c | 10 +++++++---
src/security/security_selinux.c | 5 +++--
3 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/src/fdstream.c b/src/fdstream.c
index a85cf9d..1c34321 100644
--- a/src/fdstream.c
+++ b/src/fdstream.c
@@ -1,7 +1,7 @@
/*
* fdstream.c: generic streams impl for file descriptors
*
- * Copyright (C) 2009-2012, 2014, 2016 Red Hat, Inc.
+ * Copyright (C) 2009-2012, 2014, 2016 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -387,7 +387,8 @@ static int virFDStreamWrite(virStreamPtr st, const char *bytes, size_t nbytes)
retry:
ret = write(fdst->fd, bytes, nbytes);
if (ret < 0) {
- if (errno == EAGAIN || errno == EWOULDBLOCK) {
+ if (errno == EAGAIN ||
+ (EAGAIN != EWOULDBLOCK && errno == EWOULDBLOCK)) {
ret = -2;
} else if (errno == EINTR) {
goto retry;
@@ -437,7 +438,8 @@ static int virFDStreamRead(virStreamPtr st, char *bytes, size_t nbytes)
retry:
ret = read(fdst->fd, bytes, nbytes);
if (ret < 0) {
- if (errno == EAGAIN || errno == EWOULDBLOCK) {
+ if (errno == EAGAIN ||
+ (EAGAIN != EWOULDBLOCK && errno == EWOULDBLOCK)) {
ret = -2;
} else if (errno == EINTR) {
goto retry;
diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c
index 406a831..d7d1c1a 100644
--- a/src/rpc/virnetsshsession.c
+++ b/src/rpc/virnetsshsession.c
@@ -1,7 +1,7 @@
/*
* virnetsshsession.c: ssh network transport provider based on libssh2
*
- * Copyright (C) 2012-2013 Red Hat, Inc.
+ * Copyright (C) 2012-2013, 2016 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -546,7 +546,9 @@ virNetSSHAuthenticateAgent(virNetSSHSessionPtr sess,
return 0; /* key accepted */
if (ret != LIBSSH2_ERROR_AUTHENTICATION_FAILED &&
- ret != LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED &&
+ (LIBSSH2_ERROR_AUTHENTICATION_FAILED !=
+ LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED &&
+ ret != LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED) &&
ret != LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED) {
libssh2_session_last_error(sess->session, &errmsg, NULL, 0);
virReportError(VIR_ERR_AUTH_FAILED,
@@ -674,7 +676,9 @@ virNetSSHAuthenticatePrivkey(virNetSSHSessionPtr sess,
priv->filename, errmsg);
if (ret == LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED ||
- ret == LIBSSH2_ERROR_AUTHENTICATION_FAILED)
+ (LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED !=
+ LIBSSH2_ERROR_AUTHENTICATION_FAILED &&
+ ret == LIBSSH2_ERROR_AUTHENTICATION_FAILED))
return 1;
else
return -1;
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 26d95d1..25f0bdf 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2014 Red Hat, Inc.
+ * Copyright (C) 2008-2014, 2016 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -911,7 +911,8 @@ virSecuritySELinuxSetFileconHelper(const char *path, char *tcon,
* hopefully sets one of the necessary SELinux virt_use_{nfs,usb,pci}
* boolean tunables to allow it ...
*/
- if (setfilecon_errno != EOPNOTSUPP && setfilecon_errno != ENOTSUP &&
+ if (setfilecon_errno != EOPNOTSUPP &&
+ (EOPNOTSUPP != ENOTSUP && setfilecon_errno != ENOTSUP) &&
setfilecon_errno != EROFS) {
virReportSystemError(setfilecon_errno,
_("unable to set security context '%s' on '%s'"),
--
2.5.0
8 years, 6 months
[libvirt] [PATCH v2] add func to set shared drivers after libvirtd init
by Mikhail Feoktistov
Diff from v1:
Remove vz prefix from the title of this letter. Because this is the common case
for all drivers in libvirt.
Description:
Built-in drivers in libvirt are initialized before libvirtd initialization.
Libvirt loads shared drivers on libvirtd initialization step.
For built-in drivers we can't set shared drivers, because they are not initialized yet.
This patch adds function to set shared drivers after libvirtd init.
---
daemon/libvirtd.c | 4 ++++
src/libvirt.c | 41 +++++++++++++++++++++++++++++++++++++++++
src/libvirt_internal.h | 1 +
src/libvirt_private.syms | 1 +
4 files changed, 47 insertions(+)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 250094b..aac1826 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -431,6 +431,10 @@ static void daemonInitialize(void)
bhyveRegister();
# endif
#endif
+# ifdef WITH_VZ
+ virAssignSharedDrivers("vz");
+ virAssignSharedDrivers("Parallels");
+# endif
}
diff --git a/src/libvirt.c b/src/libvirt.c
index 25a0040..1763be7 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -1433,3 +1433,44 @@ virTypedParameterValidateSet(virConnectPtr conn,
}
return 0;
}
+
+/**
+ * virAssignSharedDrivers:
+ * @name: name of connection driver
+ *
+ * This function fills in any empty pointers for shared drivers
+ * in connect driver structure
+ *
+ * Returns 0 in case of success, -1 in case of error
+*/
+int
+virAssignSharedDrivers(const char *name)
+{
+ size_t i;
+
+ if (name == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Driver name must be specified"));
+ return -1;
+ }
+
+ for (i = 0; i < virConnectDriverTabCount; i++) {
+ if (STREQ(virConnectDriverTab[i]->hypervisorDriver->name, name)) {
+ if (virConnectDriverTab[i]->interfaceDriver == NULL)
+ virConnectDriverTab[i]->interfaceDriver = virSharedInterfaceDriver;
+ if (virConnectDriverTab[i]->networkDriver == NULL)
+ virConnectDriverTab[i]->networkDriver = virSharedNetworkDriver;
+ if (virConnectDriverTab[i]->nodeDeviceDriver == NULL)
+ virConnectDriverTab[i]->nodeDeviceDriver = virSharedNodeDeviceDriver;
+ if (virConnectDriverTab[i]->nwfilterDriver == NULL)
+ virConnectDriverTab[i]->nwfilterDriver = virSharedNWFilterDriver;
+ if (virConnectDriverTab[i]->secretDriver == NULL)
+ virConnectDriverTab[i]->secretDriver = virSharedSecretDriver;
+ if (virConnectDriverTab[i]->storageDriver == NULL)
+ virConnectDriverTab[i]->storageDriver = virSharedStorageDriver;
+ break;
+ }
+ }
+
+ return 0;
+}
diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h
index 1313b58..2a7227b 100644
--- a/src/libvirt_internal.h
+++ b/src/libvirt_internal.h
@@ -289,4 +289,5 @@ virTypedParameterValidateSet(virConnectPtr conn,
virTypedParameterPtr params,
int nparams);
+int virAssignSharedDrivers(const char *name);
#endif
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index a835f18..a0fcdf5 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -943,6 +943,7 @@ virFDStreamSetInternalCloseCb;
# libvirt_internal.h
+virAssignSharedDrivers;
virConnectSupportsFeature;
virDomainMigrateBegin3;
virDomainMigrateBegin3Params;
--
1.8.3.1
8 years, 6 months
[libvirt] [PATCH 00/10] Introduce worker tuning APIs
by Erik Skultety
Erik Skultety (10):
libvirt-host: Move virTypedParam* to libvirt-common
admin: Enable usage of typed parameters
admin: Introduce virAdmConnectServerLookupByName
util: Refactor thread creation by introducing virThreadPoolExpand
util: Report system error when virThreadCreateFull fails
util: Add more getters to threadpool parameters
admin: Prepare admin protocol for future worker related procedures
admin: Introduce virAdmServerGethreadPoolParameters
admin: Introduce virAdmServerSetThreadPoolParameters
virt-admin: Introduce srv-workertune command
cfg.mk | 2 +-
daemon/admin.c | 129 ++++++++++++++++++++++++
daemon/admin_server.c | 129 ++++++++++++++++++++++++
daemon/admin_server.h | 15 +++
include/libvirt/libvirt-admin.h | 74 ++++++++++++++
include/libvirt/libvirt-common.h.in | 185 ++++++++++++++++++++++++++++++++++
include/libvirt/libvirt-host.h | 186 ----------------------------------
include/libvirt/virterror.h | 1 +
po/POTFILES.in | 4 +-
src/admin/admin_protocol.x | 67 +++++++++++-
src/admin/admin_remote.c | 104 +++++++++++++++++++
src/admin_protocol-structs | 52 ++++++++++
src/libvirt-admin.c | 114 +++++++++++++++++++++
src/libvirt_admin_private.syms | 5 +
src/libvirt_admin_public.syms | 3 +
src/libvirt_private.syms | 4 +
src/rpc/virnetserver.c | 37 +++++++
src/rpc/virnetserver.h | 13 +++
src/util/virerror.c | 6 ++
src/util/virthreadpool.c | 196 ++++++++++++++++++++++++------------
src/util/virthreadpool.h | 8 ++
tools/virt-admin.c | 132 ++++++++++++++++++++++++
22 files changed, 1212 insertions(+), 254 deletions(-)
--
2.4.3
8 years, 7 months
[libvirt] Block replication driver
by Simon Kollberg
Hi!
I'm working on supporting a new FT/HA solution for qemu called COLO
(http://wiki.qemu.org/Features/COLO). The part that is currently being
focused
on for libvirt integration is Block Replication
(http://wiki.qemu.org/Features/BlockReplication) which enables guest state
synchronization for disks.
Right now there are three issues that I'd like to get your input on:
1.
As you can see on the block replication wiki-page we need to reference the
secondary disk id.
Example from the wiki:
-drive if=none,driver=raw,file.filename=1.raw,id=colo1 \
-drive if=xxx,driver=replication,mode=secondary,\
...
file.backing.backing=colo1
My initial thought was to manually set the alias of the
disk and add a new reference element to the backingStore:
<disk type='file' device='disk'>
...
<alias name='colo1'/>
</disk>
<disk type='file' device='disk'>
...
<backingStore type='file'>
...
<reference name='colo1'/>
</backingStore>
</disk>
Though, I quickly realized that setting the alias is only done by the
hypervisor and is therefore not an option with the current code.
Would it be bad letting the user set the alias, and if so, do you have any
ideas of how to solve the referencing?
2.
The format of the disk and the driver type currently shares the same
attribute in libvirt (the type attribute on driver XML element). However,
with
the new replication disk driver you need to be able to set both the disk
format
and also the driver name.
Example from the wiki:
-drive if=xxx,driver=replication,mode=secondary,\
file.file.filename=active_disk.qcow2,\
file.driver=qcow2,\
...
I saw that there was a function in libvirt called virStorageFileProbeFormat
that could let us get the format of the disk without stating it in the XML.
But
as I'm sure you know, it's strongly advised not to be used since you can
trick
the function by modifying the disk file.
3.
When using the replication driver the secondary disk is supposed to be added
but not attached.
Example from the wiki:
-drive if=none,driver=raw,file.filename=1.raw,id=colo1 \
-drive if=xxx,driver=replication,mode=secondary,\
...
Clearly, trying to setup a disk without a target is not allowed at the
moment.
Is there any better way of doing it?
Any comments and insights in general are also greatly appreciated!
/Simon
8 years, 7 months
[libvirt] [PATCH lxc_ethernet] lxc:support network type with ethernet
by zhongguocheng1@163.com
From: z00209963 <z00209963(a)szxbz472.huaweiobz.com>
---
src/lxc/lxc_process.c | 35 +++++++++++++++++++++++++++++++++++
src/lxc/lxc_process.h | 3 +++
2 files changed, 38 insertions(+)
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 57e3880..1ffd9ac 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -359,6 +359,38 @@ char *virLXCProcessSetupInterfaceDirect(virConnectPtr conn,
return ret;
}
+char *virLXCProcessSetupInterfaceEthernet(virDomainDefPtr vm,
+ virDomainNetDefPtr net)
+{
+ char *ret = NULL;
+ char *parentVeth;
+ char *containerVeth = NULL;
+
+ VIR_DEBUG("calling vethCreate()");
+ parentVeth = net->ifname;
+ if (virNetDevVethCreate(&parentVeth, &containerVeth) < 0)
+ goto cleanup;
+ VIR_DEBUG("parentVeth: %s, containerVeth: %s", parentVeth, containerVeth);
+
+ if (net->ifname == NULL)
+ net->ifname = parentVeth;
+
+ if (virNetDevSetMAC(containerVeth, &net->mac) < 0)
+ goto cleanup;
+
+ if (virNetDevSetOnline(parentVeth, true) < 0)
+ goto cleanup;
+
+ if (net->filter &&
+ virDomainConfNWFilterInstantiate(vm->uuid, net) < 0)
+ goto cleanup;
+
+ ret = containerVeth;
+
+ cleanup:
+ return ret;
+}
+
static const char *nsInfoLocal[VIR_LXC_DOMAIN_NAMESPACE_LAST] = {
[VIR_LXC_DOMAIN_NAMESPACE_SHARENET] = "net",
[VIR_LXC_DOMAIN_NAMESPACE_SHAREIPC] = "ipc",
@@ -559,6 +591,9 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
break;
case VIR_DOMAIN_NET_TYPE_ETHERNET:
+ if (!(veth = virLXCProcessSetupInterfaceEthernet(def,
+ net)))
+ goto cleanup;
break;
case VIR_DOMAIN_NET_TYPE_USER:
diff --git a/src/lxc/lxc_process.h b/src/lxc/lxc_process.h
index b6c8083..cc8e707 100644
--- a/src/lxc/lxc_process.h
+++ b/src/lxc/lxc_process.h
@@ -53,5 +53,8 @@ char *virLXCProcessSetupInterfaceBridged(virDomainDefPtr vm,
char *virLXCProcessSetupInterfaceDirect(virConnectPtr conn,
virDomainDefPtr def,
virDomainNetDefPtr net);
+char *virLXCProcessSetupInterfaceEthernet(virDomainDefPtr vm,
+ virDomainNetDefPtr net);
+
#endif /* __LXC_PROCESS_H__ */
--
2.5.1.windows.1
8 years, 7 months
[libvirt] Libvirt bite sized tasks
by Michal Privoznik
Dear lists,
I've just started new wiki page which aim is to summarize small and
trivial tasks, that starting contributors can take, investigate and
implement. The aim is to give them something easy to start with while
not scaring them out about complexity of our code. The page can be found
here:
http://wiki.libvirt.org/page/BiteSizedTasks
The name is copied from qemu wiki:
http://wiki.qemu.org/BiteSizedTasks
Please, feel free to extend the list. I plan to use it in the future
when interviewing GSoC candidates.
Michal
8 years, 7 months
[libvirt] [PATCH v2] migration: add option to set target ndb server port
by Nikolay Shirokovskiy
Current libvirt + qemu pair lacks secure migrations in case of
VMs with non-shared disks. The only option to migrate securely
natively is to use tunneled mode and some kind of secure
destination URI. But tunelled mode does not support non-shared
disks.
The other way to make migration secure is to organize a tunnel
by external means. This is possible in case of shared disks
migration thru use of proper combination of destination URI,
migration URI and VIR_MIGRATE_PARAM_LISTEN_ADDRESS migration
param. But again this is not possible in case of non shared disks
migration as we have no option to control target nbd server port.
But fixing this much more simplier that supporting non-shared
disks in tunneled mode.
So this patch adds option to set target ndb port.
Finally all qemu migration connections will be secured AFAIK but
even in this case this patch could be convinient if one wants
all migration traffic be put in a single connection.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
---
Difference from v1:
1. fix indentation
2. fix uninitialized variable case in qemuDomainMigratePerform3Params
3. remove check that nbd port that passed from target back
to source on preparation step in cookie is requested one.
First the check was malformed. Second we don't need it anyway.
In case target does not support setting nbd port we get
error ealier when checking variable parameters list. After
this check is removed we don't need to pass port parameter
here and there on perform step except for the tunnel case
when we convert all parameters back to parameter list.
include/libvirt/libvirt-domain.h | 10 +++++
src/qemu/qemu_driver.c | 25 ++++++++----
src/qemu/qemu_migration.c | 85 ++++++++++++++++++++++++++++------------
src/qemu/qemu_migration.h | 3 ++
tools/virsh-domain.c | 12 ++++++
tools/virsh.pod | 5 ++-
6 files changed, 106 insertions(+), 34 deletions(-)
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 65f1618..aa380f5 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -757,6 +757,16 @@ typedef enum {
*/
# define VIR_MIGRATE_PARAM_MIGRATE_DISKS "migrate_disks"
+/**
+ * VIR_MIGRATE_PARAM_NBD_PORT:
+ *
+ * virDomainMigrate* params field: port that destination nbd server should use
+ * for incoming disks migration. Type is VIR_TYPED_PARAM_INT. If set to 0 or
+ * omitted, libvirt will choose a suitable default. At the moment this is only
+ * supported by the QEMU driver.
+ */
+# define VIR_MIGRATE_PARAM_NBD_PORT "nbd_port"
+
/* Domain migration. */
virDomainPtr virDomainMigrate (virDomainPtr domain, virConnectPtr dconn,
unsigned long flags, const char *dname,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2bbc724..6230087 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12005,7 +12005,7 @@ qemuDomainMigratePrepare2(virConnectPtr dconn,
ret = qemuMigrationPrepareDirect(driver, dconn,
NULL, 0, NULL, NULL, /* No cookies */
uri_in, uri_out,
- &def, origname, NULL, 0, NULL, flags);
+ &def, origname, NULL, 0, NULL, 0, flags);
cleanup:
VIR_FREE(origname);
@@ -12058,7 +12058,7 @@ qemuDomainMigratePerform(virDomainPtr dom,
* Consume any cookie we were able to decode though
*/
ret = qemuMigrationPerform(driver, dom->conn, vm,
- NULL, dconnuri, uri, NULL, NULL, 0, NULL,
+ NULL, dconnuri, uri, NULL, NULL, 0, NULL, 0,
cookie, cookielen,
NULL, NULL, /* No output cookies in v2 */
flags, dname, resource, false);
@@ -12231,7 +12231,7 @@ qemuDomainMigratePrepare3(virConnectPtr dconn,
cookiein, cookieinlen,
cookieout, cookieoutlen,
uri_in, uri_out,
- &def, origname, NULL, 0, NULL, flags);
+ &def, origname, NULL, 0, NULL, 0, flags);
cleanup:
VIR_FREE(origname);
@@ -12257,6 +12257,7 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn,
const char *dname = NULL;
const char *uri_in = NULL;
const char *listenAddress = cfg->migrationAddress;
+ int nbdPort = 0;
int nmigrate_disks;
const char **migrate_disks = NULL;
char *origname = NULL;
@@ -12277,7 +12278,10 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn,
&uri_in) < 0 ||
virTypedParamsGetString(params, nparams,
VIR_MIGRATE_PARAM_LISTEN_ADDRESS,
- &listenAddress) < 0)
+ &listenAddress) < 0 ||
+ virTypedParamsGetInt(params, nparams,
+ VIR_MIGRATE_PARAM_NBD_PORT,
+ &nbdPort) < 0)
goto cleanup;
nmigrate_disks = virTypedParamsGetStringList(params, nparams,
@@ -12308,7 +12312,8 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn,
cookieout, cookieoutlen,
uri_in, uri_out,
&def, origname, listenAddress,
- nmigrate_disks, migrate_disks, flags);
+ nmigrate_disks, migrate_disks,
+ nbdPort, flags);
cleanup:
VIR_FREE(migrate_disks);
@@ -12442,7 +12447,7 @@ qemuDomainMigratePerform3(virDomainPtr dom,
}
return qemuMigrationPerform(driver, dom->conn, vm, xmlin,
- dconnuri, uri, NULL, NULL, 0, NULL,
+ dconnuri, uri, NULL, NULL, 0, NULL, 0,
cookiein, cookieinlen,
cookieout, cookieoutlen,
flags, dname, resource, true);
@@ -12469,6 +12474,7 @@ qemuDomainMigratePerform3Params(virDomainPtr dom,
int nmigrate_disks;
const char **migrate_disks = NULL;
unsigned long long bandwidth = 0;
+ int nbdPort = 0;
int ret = -1;
virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
@@ -12492,7 +12498,10 @@ qemuDomainMigratePerform3Params(virDomainPtr dom,
&graphicsuri) < 0 ||
virTypedParamsGetString(params, nparams,
VIR_MIGRATE_PARAM_LISTEN_ADDRESS,
- &listenAddress) < 0)
+ &listenAddress) < 0 ||
+ virTypedParamsGetInt(params, nparams,
+ VIR_MIGRATE_PARAM_NBD_PORT,
+ &nbdPort) < 0)
goto cleanup;
nmigrate_disks = virTypedParamsGetStringList(params, nparams,
@@ -12512,7 +12521,7 @@ qemuDomainMigratePerform3Params(virDomainPtr dom,
ret = qemuMigrationPerform(driver, dom->conn, vm, dom_xml,
dconnuri, uri, graphicsuri, listenAddress,
- nmigrate_disks, migrate_disks,
+ nmigrate_disks, migrate_disks, nbdPort,
cookiein, cookieinlen, cookieout, cookieoutlen,
flags, dname, bandwidth, true);
cleanup:
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index f2c7b61..4cadf34 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1709,7 +1709,8 @@ qemuMigrationStartNBDServer(virQEMUDriverPtr driver,
virDomainObjPtr vm,
const char *listenAddr,
size_t nmigrate_disks,
- const char **migrate_disks)
+ const char **migrate_disks,
+ int nbdPort)
{
int ret = -1;
qemuDomainObjPrivatePtr priv = vm->privateData;
@@ -1717,6 +1718,12 @@ qemuMigrationStartNBDServer(virQEMUDriverPtr driver,
char *diskAlias = NULL;
size_t i;
+ if (nbdPort < 0 || nbdPort > USHRT_MAX) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("nbd port must be in range 0-65535"));
+ return -1;
+ }
+
for (i = 0; i < vm->def->ndisks; i++) {
virDomainDiskDefPtr disk = vm->def->disks[i];
@@ -1733,10 +1740,15 @@ qemuMigrationStartNBDServer(virQEMUDriverPtr driver,
QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
goto cleanup;
- if (!port &&
- ((virPortAllocatorAcquire(driver->migrationPorts, &port) < 0) ||
- (qemuMonitorNBDServerStart(priv->mon, listenAddr, port) < 0))) {
- goto exit_monitor;
+ if (port == 0) {
+ if (nbdPort)
+ port = nbdPort;
+ else
+ if (virPortAllocatorAcquire(driver->migrationPorts, &port) < 0)
+ goto exit_monitor;
+
+ if (qemuMonitorNBDServerStart(priv->mon, listenAddr, port) < 0)
+ goto exit_monitor;
}
if (qemuMonitorNBDServerAdd(priv->mon, diskAlias, true) < 0)
@@ -1750,7 +1762,8 @@ qemuMigrationStartNBDServer(virQEMUDriverPtr driver,
cleanup:
VIR_FREE(diskAlias);
- if (ret < 0)
+ // second clause means port is autoselected
+ if (ret < 0 && nbdPort == 0)
virPortAllocatorRelease(driver->migrationPorts, port);
return ret;
@@ -3312,6 +3325,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
const char *listenAddress,
size_t nmigrate_disks,
const char **migrate_disks,
+ int nbdPort,
unsigned long flags)
{
virDomainObjPtr vm = NULL;
@@ -3513,7 +3527,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_INC) &&
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NBD_SERVER)) {
if (qemuMigrationStartNBDServer(driver, vm, incoming->address,
- nmigrate_disks, migrate_disks) < 0) {
+ nmigrate_disks, migrate_disks,
+ nbdPort) < 0) {
goto stopjob;
}
cookieFlags |= QEMU_MIGRATION_COOKIE_NBD;
@@ -3565,6 +3580,10 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
if (autoPort)
priv->migrationPort = port;
+ // in this case port is autoselected and we don't need to manage it anymore
+ // after cookie is baked
+ if (nbdPort != 0)
+ priv->nbdPort = 0;
ret = 0;
cleanup:
@@ -3576,7 +3595,10 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
/* priv is set right after vm is added to the list of domains
* and there is no 'goto cleanup;' in the middle of those */
VIR_FREE(priv->origname);
- virPortAllocatorRelease(driver->migrationPorts, priv->nbdPort);
+ // release if port is auto selected which is not the case if
+ // it is given in parameters
+ if (nbdPort == 0)
+ virPortAllocatorRelease(driver->migrationPorts, priv->nbdPort);
priv->nbdPort = 0;
qemuDomainRemoveInactive(driver, vm);
}
@@ -3633,7 +3655,7 @@ qemuMigrationPrepareTunnel(virQEMUDriverPtr driver,
ret = qemuMigrationPrepareAny(driver, dconn, cookiein, cookieinlen,
cookieout, cookieoutlen, def, origname,
- st, NULL, 0, false, NULL, 0, NULL, flags);
+ st, NULL, 0, false, NULL, 0, NULL, 0, flags);
return ret;
}
@@ -3675,6 +3697,7 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
const char *listenAddress,
size_t nmigrate_disks,
const char **migrate_disks,
+ int nbdPort,
unsigned long flags)
{
unsigned short port = 0;
@@ -3688,11 +3711,11 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
VIR_DEBUG("driver=%p, dconn=%p, cookiein=%s, cookieinlen=%d, "
"cookieout=%p, cookieoutlen=%p, uri_in=%s, uri_out=%p, "
"def=%p, origname=%s, listenAddress=%s, "
- "nmigrate_disks=%zu, migrate_disks=%p, flags=%lx",
+ "nmigrate_disks=%zu, migrate_disks=%p, nbdPort=%d, flags=%lx",
driver, dconn, NULLSTR(cookiein), cookieinlen,
cookieout, cookieoutlen, NULLSTR(uri_in), uri_out,
*def, origname, NULLSTR(listenAddress),
- nmigrate_disks, migrate_disks, flags);
+ nmigrate_disks, migrate_disks, nbdPort, flags);
*uri_out = NULL;
@@ -3797,7 +3820,7 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
cookieout, cookieoutlen, def, origname,
NULL, uri ? uri->scheme : "tcp",
port, autoPort, listenAddress,
- nmigrate_disks, migrate_disks, flags);
+ nmigrate_disks, migrate_disks, nbdPort, flags);
cleanup:
virURIFree(uri);
VIR_FREE(hostname);
@@ -4867,6 +4890,7 @@ doPeer2PeerMigrate3(virQEMUDriverPtr driver,
const char *listenAddress,
size_t nmigrate_disks,
const char **migrate_disks,
+ int nbdPort,
unsigned long long bandwidth,
bool useParams,
unsigned long flags)
@@ -4890,11 +4914,11 @@ doPeer2PeerMigrate3(virQEMUDriverPtr driver,
VIR_DEBUG("driver=%p, sconn=%p, dconn=%p, dconnuri=%s, vm=%p, xmlin=%s, "
"dname=%s, uri=%s, graphicsuri=%s, listenAddress=%s, "
- "nmigrate_disks=%zu, migrate_disks=%p, bandwidth=%llu, "
- "useParams=%d, flags=%lx",
+ "nmigrate_disks=%zu, migrate_disks=%p, nbdPort=%d, "
+ "bandwidth=%llu, useParams=%d, flags=%lx",
driver, sconn, dconn, NULLSTR(dconnuri), vm, NULLSTR(xmlin),
NULLSTR(dname), NULLSTR(uri), NULLSTR(graphicsuri),
- NULLSTR(listenAddress), nmigrate_disks, migrate_disks,
+ NULLSTR(listenAddress), nmigrate_disks, migrate_disks, nbdPort,
bandwidth, useParams, flags);
/* Unlike the virDomainMigrateVersion3 counterpart, we don't need
@@ -4944,6 +4968,11 @@ doPeer2PeerMigrate3(virQEMUDriverPtr driver,
VIR_MIGRATE_PARAM_MIGRATE_DISKS,
migrate_disks[i]) < 0)
goto cleanup;
+ if (nbdPort &&
+ virTypedParamsAddInt(¶ms, &nparams, &maxparams,
+ VIR_MIGRATE_PARAM_NBD_PORT,
+ nbdPort) < 0)
+ goto cleanup;
}
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED)
@@ -5210,6 +5239,7 @@ static int doPeer2PeerMigrate(virQEMUDriverPtr driver,
const char *listenAddress,
size_t nmigrate_disks,
const char **migrate_disks,
+ int nbdPort,
unsigned long flags,
const char *dname,
unsigned long resource,
@@ -5225,10 +5255,12 @@ static int doPeer2PeerMigrate(virQEMUDriverPtr driver,
VIR_DEBUG("driver=%p, sconn=%p, vm=%p, xmlin=%s, dconnuri=%s, uri=%s, "
"graphicsuri=%s, listenAddress=%s, nmigrate_disks=%zu, "
- "migrate_disks=%p, flags=%lx, dname=%s, resource=%lu",
+ "migrate_disks=%p, nbdPort=%d, flags=%lx, dname=%s, "
+ "resource=%lu",
driver, sconn, vm, NULLSTR(xmlin), NULLSTR(dconnuri),
NULLSTR(uri), NULLSTR(graphicsuri), NULLSTR(listenAddress),
- nmigrate_disks, migrate_disks, flags, NULLSTR(dname), resource);
+ nmigrate_disks, migrate_disks, nbdPort, flags, NULLSTR(dname),
+ resource);
if (flags & VIR_MIGRATE_TUNNELLED && uri) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
@@ -5323,8 +5355,8 @@ static int doPeer2PeerMigrate(virQEMUDriverPtr driver,
if (*v3proto) {
ret = doPeer2PeerMigrate3(driver, sconn, dconn, dconnuri, vm, xmlin,
dname, uri, graphicsuri, listenAddress,
- nmigrate_disks, migrate_disks, resource,
- useParams, flags);
+ nmigrate_disks, migrate_disks, nbdPort,
+ resource, useParams, flags);
} else {
ret = doPeer2PeerMigrate2(driver, sconn, dconn, vm,
dconnuri, flags, dname, resource);
@@ -5361,6 +5393,7 @@ qemuMigrationPerformJob(virQEMUDriverPtr driver,
const char *listenAddress,
size_t nmigrate_disks,
const char **migrate_disks,
+ int nbdPort,
const char *cookiein,
int cookieinlen,
char **cookieout,
@@ -5396,7 +5429,7 @@ qemuMigrationPerformJob(virQEMUDriverPtr driver,
if ((flags & (VIR_MIGRATE_TUNNELLED | VIR_MIGRATE_PEER2PEER))) {
ret = doPeer2PeerMigrate(driver, conn, vm, xmlin,
dconnuri, uri, graphicsuri, listenAddress,
- nmigrate_disks, migrate_disks,
+ nmigrate_disks, migrate_disks, nbdPort,
flags, dname, resource, &v3proto);
} else {
qemuMigrationJobSetPhase(driver, vm, QEMU_MIGRATION_PHASE_PERFORM2);
@@ -5529,6 +5562,7 @@ qemuMigrationPerform(virQEMUDriverPtr driver,
const char *listenAddress,
size_t nmigrate_disks,
const char **migrate_disks,
+ int nbdPort,
const char *cookiein,
int cookieinlen,
char **cookieout,
@@ -5540,13 +5574,14 @@ qemuMigrationPerform(virQEMUDriverPtr driver,
{
VIR_DEBUG("driver=%p, conn=%p, vm=%p, xmlin=%s, dconnuri=%s, "
"uri=%s, graphicsuri=%s, listenAddress=%s, "
- "nmigrate_disks=%zu, migrate_disks=%p, "
+ "nmigrate_disks=%zu, migrate_disks=%p, nbdPort=%d, "
"cookiein=%s, cookieinlen=%d, cookieout=%p, cookieoutlen=%p, "
"flags=%lx, dname=%s, resource=%lu, v3proto=%d",
driver, conn, vm, NULLSTR(xmlin), NULLSTR(dconnuri),
NULLSTR(uri), NULLSTR(graphicsuri), NULLSTR(listenAddress),
- nmigrate_disks, migrate_disks, NULLSTR(cookiein), cookieinlen,
- cookieout, cookieoutlen, flags, NULLSTR(dname), resource, v3proto);
+ nmigrate_disks, migrate_disks, nbdPort,
+ NULLSTR(cookiein), cookieinlen, cookieout, cookieoutlen,
+ flags, NULLSTR(dname), resource, v3proto);
if ((flags & (VIR_MIGRATE_TUNNELLED | VIR_MIGRATE_PEER2PEER))) {
if (cookieinlen) {
@@ -5557,7 +5592,7 @@ qemuMigrationPerform(virQEMUDriverPtr driver,
return qemuMigrationPerformJob(driver, conn, vm, xmlin, dconnuri, uri,
graphicsuri, listenAddress,
- nmigrate_disks, migrate_disks,
+ nmigrate_disks, migrate_disks, nbdPort,
cookiein, cookieinlen,
cookieout, cookieoutlen,
flags, dname, resource, v3proto);
@@ -5578,7 +5613,7 @@ qemuMigrationPerform(virQEMUDriverPtr driver,
} else {
return qemuMigrationPerformJob(driver, conn, vm, xmlin, NULL,
uri, graphicsuri, listenAddress,
- nmigrate_disks, migrate_disks,
+ nmigrate_disks, migrate_disks, nbdPort,
cookiein, cookieinlen,
cookieout, cookieoutlen, flags,
dname, resource, v3proto);
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index 2445e13..2796361 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -51,6 +51,7 @@
VIR_MIGRATE_PARAM_BANDWIDTH, VIR_TYPED_PARAM_ULLONG, \
VIR_MIGRATE_PARAM_GRAPHICS_URI, VIR_TYPED_PARAM_STRING, \
VIR_MIGRATE_PARAM_LISTEN_ADDRESS, VIR_TYPED_PARAM_STRING, \
+ VIR_MIGRATE_PARAM_NBD_PORT, VIR_TYPED_PARAM_INT, \
VIR_MIGRATE_PARAM_MIGRATE_DISKS, VIR_TYPED_PARAM_STRING | \
VIR_TYPED_PARAM_MULTIPLE, \
NULL
@@ -134,6 +135,7 @@ int qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
const char *listenAddress,
size_t nmigrate_disks,
const char **migrate_disks,
+ int nbdPort,
unsigned long flags);
int qemuMigrationPerform(virQEMUDriverPtr driver,
@@ -146,6 +148,7 @@ int qemuMigrationPerform(virQEMUDriverPtr driver,
const char *listenAddress,
size_t nmigrate_disks,
const char **migrate_disks,
+ int nbdPort,
const char *cookiein,
int cookieinlen,
char **cookieout,
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index bf65a60..e648a3a 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9653,6 +9653,10 @@ static const vshCmdOptDef opts_migrate[] = {
.type = VSH_OT_STRING,
.help = N_("comma separated list of disks to be migrated")
},
+ {.name = "nbd-port",
+ .type = VSH_OT_INT,
+ .help = N_("port to use by target nbd server")
+ },
{.name = NULL}
};
@@ -9663,6 +9667,7 @@ doMigrate(void *opaque)
virDomainPtr dom = NULL;
const char *desturi = NULL;
const char *opt = NULL;
+ int optInt = 0;
unsigned int flags = 0;
virshCtrlData *data = opaque;
vshControl *ctl = data->ctl;
@@ -9705,6 +9710,13 @@ doMigrate(void *opaque)
VIR_MIGRATE_PARAM_LISTEN_ADDRESS, opt) < 0)
goto save_error;
+ if (vshCommandOptInt(ctl, cmd, "nbd-port", &optInt) < 0)
+ goto out;
+ if (optInt &&
+ virTypedParamsAddInt(¶ms, &nparams, &maxparams,
+ VIR_MIGRATE_PARAM_NBD_PORT, optInt) < 0)
+ goto save_error;
+
if (vshCommandOptStringReq(ctl, cmd, "dname", &opt) < 0)
goto out;
if (opt &&
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 435c649..66418b2 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1532,7 +1532,7 @@ to the I<uri> namespace is displayed instead of being modified.
[I<--compressed>] [I<--abort-on-error>] [I<--auto-converge>]
I<domain> I<desturi> [I<migrateuri>] [I<graphicsuri>] [I<listen-address>]
[I<dname>] [I<--timeout> B<seconds>] [I<--xml> B<file>]
-[I<--migrate-disks> B<disk-list>]
+[I<--migrate-disks> B<disk-list>] [I<--nbd-port> B<port>]
Migrate domain to another host. Add I<--live> for live migration; <--p2p>
for peer-2-peer migration; I<--direct> for direct migration; or I<--tunnelled>
@@ -1659,6 +1659,9 @@ addresses are accepted as well as hostnames (the resolving is done on
destination). Some hypervisors do not support this feature and will return an
error if this parameter is used.
+Optional I<nbd-port> sets the port that hypervisor on destination side should
+bind to for incoming nbd traffic. Currently it is supported only by qemu.
+
=item B<migrate-setmaxdowntime> I<domain> I<downtime>
Set maximum tolerable downtime for a domain which is being live-migrated to
--
1.8.3.1
8 years, 7 months
[libvirt] [PATCH] qemu migration: assign addresses in xml passed as parameter
by Nikolay Shirokovskiy
Usecase:
1. define domain with xml A where addresses are not set
2. migrate with '--xml A'
You get ABI incompatibility because we comprare xmls with addresses
set and not. This patch assign addresses in parameter xml so
the comprasion is fair.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
---
src/qemu/qemu_migration.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 1443d96..7cceaa1 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2992,6 +2992,7 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
virDomainDefPtr def = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
virCapsPtr caps = NULL;
+ virQEMUCapsPtr qemuCaps = NULL;
unsigned int cookieFlags = QEMU_MIGRATION_COOKIE_LOCKSTATE;
VIR_DEBUG("driver=%p, vm=%p, xmlin=%s, dname=%s,"
@@ -3105,6 +3106,13 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
VIR_DOMAIN_DEF_PARSE_INACTIVE)))
goto cleanup;
+ if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
+ def->emulator)))
+ goto cleanup;
+
+ if (qemuDomainAssignAddresses(def, qemuCaps, NULL) < 0)
+ goto cleanup;
+
if (!qemuDomainDefCheckABIStability(driver, vm->def, def))
goto cleanup;
@@ -3117,6 +3125,7 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
qemuMigrationCookieFree(mig);
virObjectUnref(caps);
virDomainDefFree(def);
+ virObjectUnref(qemuCaps);
return rv;
}
--
1.8.3.1
8 years, 7 months
[libvirt] [PATCH] schema: support 'default' cache mode
by Jim Fehlig
The docs claims the cache attribute of the disk <driver>
element supports 'default' as one of its permissible values,
but such configuration fails virt-xml-validate. Add 'default'
as one of the cache attribute choices in domaincommon.rng.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
docs/schemas/domaincommon.rng | 1 +
1 file changed, 1 insertion(+)
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 67af93a..d4e375f 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1596,6 +1596,7 @@
<define name="driverCache">
<attribute name="cache">
<choice>
+ <value>default</value>
<value>none</value>
<value>writeback</value>
<value>writethrough</value>
--
2.1.4
8 years, 7 months