[libvirt] [PATCH] cmdNetworkUpdate: Prefer VSH_EXCLUSIVE_OPTIONS over if-else tree
by Michal Privoznik
We have macros that check and reject mutually exclusive
parameters to our commands. Use those instead of if-else tree.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tools/virsh-network.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 1ae206a..d0bd7a3 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -907,9 +907,12 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd)
bool current = vshCommandOptBool(cmd, "current");
bool config = vshCommandOptBool(cmd, "config");
bool live = vshCommandOptBool(cmd, "live");
- unsigned int flags = 0;
+ unsigned int flags = VIR_NETWORK_UPDATE_AFFECT_CURRENT;
const char *affected;
+ VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
+ VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
+
if (!(network = virshCommandOptNetwork(ctl, cmd, NULL)))
return false;
@@ -962,18 +965,10 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd)
xml = xmlFromFile;
}
- if (current) {
- if (live || config) {
- vshError(ctl, "%s", _("--current must be specified exclusively"));
- goto cleanup;
- }
- flags |= VIR_NETWORK_UPDATE_AFFECT_CURRENT;
- } else {
- if (config)
- flags |= VIR_NETWORK_UPDATE_AFFECT_CONFIG;
- if (live)
- flags |= VIR_NETWORK_UPDATE_AFFECT_LIVE;
- }
+ if (config)
+ flags |= VIR_NETWORK_UPDATE_AFFECT_CONFIG;
+ if (live)
+ flags |= VIR_NETWORK_UPDATE_AFFECT_LIVE;
if (virNetworkUpdate(network, command,
section, parentIndex, xml, flags) < 0) {
--
2.4.10
8 years, 8 months
[libvirt] [PATCH v2] Migration with --live --offline option performs offline migration without warning/error.
by Nitesh Konkar
This patch gives an error when migration is attempted with both
--live and --offline options.
Signed-off-by: Nitesh Konkar <nitkon12(a)linux.vnet.ibm.com>
---
tools/virsh-domain.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 43c8436..7b4a08e 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9837,6 +9837,10 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd)
int timeout = 0;
bool live_flag = false;
virshCtrlData data = { .dconn = NULL };
+ bool live = vshCommandOptBool(cmd, "live");
+ bool offline = vshCommandOptBool(cmd, "offline");
+
+ VSH_EXCLUSIVE_OPTIONS_VAR(live, offline);
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
return false;
--
1.8.3.1
8 years, 8 months
[libvirt] [PATCH] qemu_process: mark auto-generated spice ports as reserved
by Pavel Hrdina
In case you will specify graphics like this:
<graphics type='spice' port='-1'/>
or
<graphics type='spice' port='-1' tlsPort='6000'/>
libvirt will automatically add autoport='no'. This leads to an issue
that in qemuProcessStop() we don't release that port because we are
releasing both port if autoport=yes or only port marked as reserved.
If autoport=no but we request to generate port via '-1' we need to mark
that port as reserved in order to release it.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1299696
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/qemu/qemu_process.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index eaf9fea..e7f19a6 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3694,6 +3694,9 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
goto error;
graphics->data.spice.port = port;
+
+ if (!graphics->data.spice.autoport)
+ graphics->data.spice.portReserved = true;
}
if (needTLSPort || graphics->data.spice.tlsPort == -1) {
@@ -3708,6 +3711,9 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
goto error;
graphics->data.spice.tlsPort = tlsPort;
+
+ if (!graphics->data.spice.autoport)
+ graphics->data.spice.tlsPortReserved = true;
}
return 0;
--
2.7.1
8 years, 8 months
[libvirt] [PATCH rfc v4 0/6] storage:dir: ploop volumes support
by Olga Krishtal
v4:
- fixed identation issues.
- in case of .uploadVol, DiskDescriptor.xml is restored.
- added check of ploops'accessibility
v3:
- no VIR_STORAGE_VOL_PLOOP type any more
- adapted all patches according to previous change
- fixed comments
v2:
- fixed memory leak
- chenged the return value of all helper functions to 0/-1.
Now check for success is smth like that: vir****Ploop() < 0
- fixed some identation issues.
8 years, 8 months
[libvirt] Plans for next release
by Daniel Veillard
So we are getting close to the end of the month and it's time to push
a new release. I think that if we want to push it by March 1st we should
start the freeze Wednesday at the latest, maybe RC1 on Wed, RC2 friday
and release next Mon if everything looks okay.
If there is an issue with this plan, please tell :)
Daniel
--
Daniel Veillard | Open Source and Standards, Red Hat
veillard(a)redhat.com | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | virtualization library http://libvirt.org/
8 years, 8 months
[libvirt] [PATCH] Migration with --live --offline option performs offline migration without warning/error.
by Nitesh Konkar
This patch gives an error when migration is attempted with both
--live and --offline options.
Signed-off-by: Nitesh Konkar <nitkon12(a)linux.vnet.ibm.com>
---
tools/virsh-domain.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 62acecb..527db38 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9795,6 +9795,12 @@ doMigrate(void *opaque)
} else {
/* For traditional live migration, connect to the destination host directly. */
virDomainPtr ddom = NULL;
+
+ if ((flags & VIR_MIGRATE_OFFLINE) && (flags & VIR_MIGRATE_LIVE)){
+ vshError(ctl, "%s", _("migrate: Using both --live and --offline option together is not permitted."));
+ goto out;
+ }
if ((ddom = virDomainMigrate3(dom, dconn, params, nparams, flags))) {
virDomainFree(ddom);
--
1.8.3.1
8 years, 8 months
[libvirt] [PATCH] virDomainDefFormatInternal: Drop useless check
by Michal Privoznik
There's a check if a domain definition has any graphics card and
if so, we iterate over each one of them. This makes no sense,
because even if it has none we can still iterate over.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/conf/domain_conf.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e47d613..56bd1aa 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -22363,11 +22363,9 @@ virDomainDefFormatInternal(virDomainDefPtr def,
goto error;
}
- if (def->ngraphics > 0) {
- for (n = 0; n < def->ngraphics; n++)
- if (virDomainGraphicsDefFormat(buf, def->graphics[n], flags) < 0)
- goto error;
- }
+ for (n = 0; n < def->ngraphics; n++)
+ if (virDomainGraphicsDefFormat(buf, def->graphics[n], flags) < 0)
+ goto error;
for (n = 0; n < def->nsounds; n++)
if (virDomainSoundDefFormat(buf, def->sounds[n], flags) < 0)
--
2.4.10
8 years, 8 months
[libvirt] [PATCH] adminDaemonListServers: Don't leak @srv_names array
by Michal Privoznik
When getting a list of servers registered for a daemon, it's
returned as a dynamically allocated array filled in with pointers
to constant strings. Because the array is dynamic, it should be
freed when no longer needed (but not the strings!). Even the
function that creates the array suggests that.
==19446== 48 bytes in 3 blocks are definitely lost in loss record 821 of 1,034
==19446== at 0x4C2C28E: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==19446== by 0x54BAFC8: virReallocN (viralloc.c:245)
==19446== by 0x54BB0BE: virExpandN (viralloc.c:294)
==19446== by 0x54BB391: virInsertElementsN (viralloc.c:436)
==19446== by 0x164E3D: virNetDaemonGetServerNames (virnetdaemon.c:217)
==19446== by 0x15616F: adminDaemonListServers (admin_server.c:52)
==19446== by 0x155B8C: adminDispatchConnectListServers (admin.c:151)
==19446== by 0x155FD8: adminDispatchConnectListServersHelper (admin_dispatch.h:101)
==19446== by 0x568E862: virNetServerProgramDispatchCall (virnetserverprogram.c:437)
==19446== by 0x568E3C3: virNetServerProgramDispatch (virnetserverprogram.c:307)
==19446== by 0x5687B5B: virNetServerProcessMsg (virnetserver.c:135)
==19446== by 0x5687C1B: virNetServerHandleJob (virnetserver.c:156)
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
daemon/admin_server.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/daemon/admin_server.c b/daemon/admin_server.c
index 7521e82..0196bfe 100644
--- a/daemon/admin_server.c
+++ b/daemon/admin_server.c
@@ -68,6 +68,7 @@ adminDaemonListServers(virNetDaemonPtr dmn,
ret = nsrvs;
cleanup:
+ VIR_FREE(srv_names);
virObjectListFree(srvs);
return ret;
}
--
2.4.10
8 years, 8 months
[libvirt] [PATCH 0/3] make virDomainObjGetPersistentDef return only persistent definition
by Nikolay Shirokovskiy
I want to make virDomainObjGetPersistentDef return only persistent definition
as one can infer from its name. Patches 1 and 2 clean things up to make
reasoning that this operation is possible more clear.
Nikolay Shirokovskiy (3):
domain: reuse update flags checking functions
libxl: remove check duplicates
common-impl: make virDomainObjGetPersistentDef return only persistent config
src/conf/domain_conf.c | 19 ++++-----
src/libxl/libxl_driver.c | 103 ++++-------------------------------------------
src/lxc/lxc_driver.c | 75 +++-------------------------------
3 files changed, 24 insertions(+), 173 deletions(-)
--
1.8.3.1
8 years, 8 months
[libvirt] [PATCH] libxl: support assignment from a pool of SRIOV VFs
by Chunyan Liu
Add codes to support creating domain with network defition of assigning
SRIOV VF from a pool. And fix hot plug and unplug SRIOV VF under this
kind of network defition.
Signed-off-by: Chunyan Liu <cyliu(a)suse.com>
---
src/libxl/libxl_conf.c | 5 +++--
src/libxl/libxl_domain.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
src/libxl/libxl_driver.c | 12 ++++++++++++
tests/Makefile.am | 3 +++
4 files changed, 65 insertions(+), 3 deletions(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 6320421..f50c68a 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -1260,7 +1260,8 @@ libxlMakeNicList(virDomainDefPtr def, libxl_domain_config *d_config)
return -1;
for (i = 0; i < nnics; i++) {
- if (l_nics[i]->type == VIR_DOMAIN_NET_TYPE_HOSTDEV)
+ if (l_nics[i]->type == VIR_DOMAIN_NET_TYPE_HOSTDEV ||
+ l_nics[i]->data.network.actual->type == VIR_DOMAIN_NET_TYPE_HOSTDEV)
continue;
if (libxlMakeNic(def, l_nics[i], &x_nics[nvnics]))
@@ -1278,7 +1279,7 @@ libxlMakeNicList(virDomainDefPtr def, libxl_domain_config *d_config)
VIR_SHRINK_N(x_nics, nnics, nnics - nvnics);
d_config->nics = x_nics;
- d_config->num_nics = nnics;
+ d_config->num_nics = nvnics;
return 0;
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index cf5c9f6..9bf7a5a 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -35,6 +35,7 @@
#include "virstring.h"
#include "virtime.h"
#include "locking/domain_lock.h"
+#include "network/bridge_driver.h"
#define VIR_FROM_THIS VIR_FROM_LIBXL
@@ -314,7 +315,7 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
virDomainHostdevSubsysPCIPtr pcisrc;
if (dev->type == VIR_DOMAIN_DEVICE_NET)
- hostdev = &(dev->data.net)->data.hostdev.def;
+ hostdev = &dev->data.net->data.hostdev.def;
else
hostdev = dev->data.hostdev;
pcisrc = &hostdev->source.subsys.u.pci;
@@ -916,6 +917,48 @@ libxlConsoleCallback(libxl_ctx *ctx, libxl_event *ev, void *for_callback)
libxl_event_free(ctx, ev);
}
+static int
+libxlNetworkPrepareDevices(virDomainDefPtr def)
+{
+ int ret = -1;
+ size_t i;
+
+ for (i = 0; i < def->nnets; i++) {
+ virDomainNetDefPtr net = def->nets[i];
+ int actualType;
+
+ /* If appropriate, grab a physical device from the configured
+ * network's pool of devices, or resolve bridge device name
+ * to the one defined in the network definition.
+ */
+ if (networkAllocateActualDevice(def, net) < 0)
+ goto cleanup;
+
+ actualType = virDomainNetGetActualType(net);
+ if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV &&
+ net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
+ /* Each type='hostdev' network device must also have a
+ * corresponding entry in the hostdevs array. For netdevs
+ * that are hardcoded as type='hostdev', this is already
+ * done by the parser, but for those allocated from a
+ * network / determined at runtime, we need to do it
+ * separately.
+ */
+ virDomainHostdevDefPtr hostdev = virDomainNetGetActualHostdev(net);
+ virDomainHostdevSubsysPCIPtr pcisrc = &hostdev->source.subsys.u.pci;
+
+ if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+ hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
+ pcisrc->backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN;
+
+ if (virDomainHostdevInsert(def, hostdev) < 0)
+ goto cleanup;
+ }
+ }
+ ret = 0;
+ cleanup:
+ return ret;
+}
/*
* Start a domain through libxenlight.
@@ -992,6 +1035,9 @@ libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
vm, true) < 0)
goto cleanup;
+ if (libxlNetworkPrepareDevices(vm->def) < 0)
+ goto cleanup;
+
if (libxlBuildDomainConfig(driver->reservedGraphicsPorts, vm->def,
cfg->ctx, &d_config) < 0)
goto cleanup;
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 4a9134e..6aca042 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -3047,6 +3047,12 @@ libxlDomainAttachHostPCIDevice(libxlDriverPrivatePtr driver,
libxl_device_pci_init(&pcidev);
+ /* For those allocated from a network pool/ determined at runtime, it's
+ * not handled by libxlDomainDeviceDefPostParse as hostdev, we need to
+ * set backend correctly.
+ */
+ pcisrc->backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN;
+
if (virDomainHostdevFind(vm->def, hostdev, &found) >= 0) {
virReportError(VIR_ERR_OPERATION_FAILED,
_("target pci device %.4x:%.2x:%.2x.%.1x already exists"),
@@ -3388,6 +3394,12 @@ libxlDomainDetachHostPCIDevice(libxlDriverPrivatePtr driver,
libxl_device_pci_init(&pcidev);
+ /* For those allocated from a network pool/ determined at runtime, it's
+ * not handled by libxlDomainDeviceDefPostParse as hostdev, we need to
+ * set backend correctly.
+ */
+ pcisrc->backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN;
+
idx = virDomainHostdevFind(vm->def, hostdev, &detach);
if (idx < 0) {
virReportError(VIR_ERR_OPERATION_FAILED,
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ee16666..6a9fb19 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -526,6 +526,9 @@ endif ! WITH_XEN
if WITH_LIBXL
libxl_LDADDS = ../src/libvirt_driver_libxl_impl.la
+if WITH_NETWORK
+libxl_LDADDS += ../src/libvirt_driver_network_impl.la
+endif WITH_NETWORK
libxl_LDADDS += $(LDADDS)
xlconfigtest_SOURCES = \
--
1.8.5.6
8 years, 8 months