[libvirt] [PATCH] hostdev: fix net config restore error
by Huanle Han
Fix for such a case:
1. Domain A and B xml contain the same SRIOV net hostdev(<interface
type='hostdev' /> with same pci address).
2. virsh start A (Successfully, and configure the SRIOV net with
custom mac)
3. virsh start B (Fail because of the hostdev used by domain A or other
reason.)
In step 3, 'virHostdevNetConfigRestore' is called for the hostdev
which is still used by domain A. It makes the mac/vlan of the SRIOV net
change.
Code Change in this fix:
1. As the pci used by other domain have been removed from
'pcidevs' in previous loop, we only restore the nic config for
the hostdev still in 'pcidevs'(used by this domain)
2. wrap a function 'virHostdevIsPCINetDevice', which detect whether the
hostdev is a pci net device or not.
3. update the comments to make it more clear
Signed-off-by: Huanle Han <hanxueluo(a)gmail.com>
---
src/util/virhostdev.c | 70 ++++++++++++++++++++++++++++++++++-----------------
1 file changed, 47 insertions(+), 23 deletions(-)
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index f583e54..a2719d3 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -350,6 +350,14 @@ virHostdevNetDevice(virDomainHostdevDefPtr hostdev, char **linkdev,
return ret;
}
+static int
+virHostdevIsPCINetDevice(virDomainHostdevDefPtr hostdev)
+{
+ return hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+ hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
+ hostdev->parent.type == VIR_DOMAIN_DEVICE_NET &&
+ hostdev->parent.data.net;
+}
static int
virHostdevNetConfigVirtPortProfile(const char *linkdev, int vf,
@@ -481,10 +489,7 @@ virHostdevNetConfigRestore(virDomainHostdevDefPtr hostdev,
/* This is only needed for PCI devices that have been defined
* using <interface type='hostdev'>. For all others, it is a NOP.
*/
- if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
- hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI ||
- hostdev->parent.type != VIR_DOMAIN_DEVICE_NET ||
- !hostdev->parent.data.net)
+ if (!virHostdevIsPCINetDevice(hostdev))
return 0;
isvf = virHostdevIsVirtualFunction(hostdev);
@@ -604,16 +609,11 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr,
* the network device, set the netdev config */
for (i = 0; i < nhostdevs; i++) {
virDomainHostdevDefPtr hostdev = hostdevs[i];
- if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
+ if (!virHostdevIsPCINetDevice(hostdev))
continue;
- if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
- continue;
- if (hostdev->parent.type == VIR_DOMAIN_DEVICE_NET &&
- hostdev->parent.data.net) {
- if (virHostdevNetConfigReplace(hostdev, uuid,
- hostdev_mgr->stateDir) < 0) {
- goto resetvfnetconfig;
- }
+ if (virHostdevNetConfigReplace(hostdev, uuid,
+ hostdev_mgr->stateDir) < 0) {
+ goto resetvfnetconfig;
}
last_processed_hostdev_vf = i;
}
@@ -781,19 +781,20 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr hostdev_mgr,
goto cleanup;
}
- /* Again 4 loops; mark all devices as inactive before reset
+ /* Here are 4 loops; mark all devices as inactive before reset
* them and reset all the devices before re-attach.
* Attach mac and port profile parameters to devices
*/
+
+ /* Loop 1: delete the copy of the dev from pcidevs if it's used by
+ * other domain. Or delete it from activePCIHostDevs if it had
+ * been used by this domain.
+ */
i = 0;
while (i < virPCIDeviceListCount(pcidevs)) {
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
virPCIDevicePtr activeDev = NULL;
- /* delete the copy of the dev from pcidevs if it's used by
- * other domain. Or delete it from activePCIHostDevs if it had
- * been used by this domain.
- */
activeDev = virPCIDeviceListFind(hostdev_mgr->activePCIHostdevs, dev);
if (activeDev) {
const char *usedby_drvname;
@@ -815,13 +816,33 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr hostdev_mgr,
*/
/*
- * For SRIOV net host devices, unset mac and port profile before
- * reset and reattach device
+ * Loop 2: For SRIOV net host devices used by this domain, unset mac and port profile before
+ * resetting and reattaching device
*/
- for (i = 0; i < nhostdevs; i++)
- virHostdevNetConfigRestore(hostdevs[i], hostdev_mgr->stateDir,
- oldStateDir);
+ for (i = 0; i < nhostdevs; i++) {
+ virDomainHostdevDefPtr hostdev = hostdevs[i];
+ if (virHostdevIsPCINetDevice(hostdev)) {
+ virDomainHostdevSubsysPCIPtr pcisrc = &hostdev->source.subsys.u.pci;
+ virPCIDevicePtr dev = NULL;
+ dev = virPCIDeviceNew(pcisrc->addr.domain, pcisrc->addr.bus,
+ pcisrc->addr.slot, pcisrc->addr.function);
+ if (dev) {
+ if (virPCIDeviceListFind(pcidevs, dev)) {
+ virHostdevNetConfigRestore(hostdev, hostdev_mgr->stateDir,
+ oldStateDir);
+ }
+ } else {
+ virErrorPtr err = virGetLastError();
+ VIR_ERROR(_("Failed to new PCI device: %s"),
+ err ? err->message : _("unknown error"));
+ virResetError(err);
+ }
+ virPCIDeviceFree(dev);
+ }
+ }
+
+ /* Loop 3: reset pci device used by this domain */
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
@@ -834,6 +855,9 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr hostdev_mgr,
}
}
+ /* Loop 4: reattach pci devices used by this domain
+ * and steal all the devices from pcidevs
+ */
while (virPCIDeviceListCount(pcidevs) > 0) {
virPCIDevicePtr dev = virPCIDeviceListStealIndex(pcidevs, 0);
virHostdevReattachPCIDevice(dev, hostdev_mgr);
--
1.9.1
9 years, 7 months
[libvirt] [PATCH 0/4] qemu: Fix issues with socket/nvram directories
by Cole Robinson
Couple cleanups and bug fixes dealing with qemu directory creation
and permissions.
Cole Robinson (4):
qemu: conf: Clarify paths that are relative to libDir
qemu: chown autoDumpPath on driver startup
qemu: Build channel autosocket directory at driver startup
qemu: Build nvram directory at driver startup
libvirt.spec.in | 6 ------
src/Makefile.am | 2 --
src/qemu/qemu_conf.c | 28 +++++++++++++++++++---------
src/qemu/qemu_conf.h | 2 ++
src/qemu/qemu_domain.c | 9 ++++-----
src/qemu/qemu_driver.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_process.c | 4 ++--
7 files changed, 76 insertions(+), 24 deletions(-)
--
2.3.5
9 years, 7 months
[libvirt] [PATCH] tests: qemu: Couple aarch64 CPU tests
by Cole Robinson
- Make sure aarch64 host-passthrough works correctly
- Make sure libvirt doesn't choke on cpu model=host, which is what
virt-install/virt-manager were incorrectly specifying up until recently.
---
.../qemuxml2argv-aarch64-cpu-model-host.args | 1 +
.../qemuxml2argv-aarch64-cpu-model-host.xml | 28 ++++++++++++++++++++++
.../qemuxml2argv-aarch64-cpu-passthrough.args | 1 +
.../qemuxml2argv-aarch64-cpu-passthrough.xml | 27 +++++++++++++++++++++
tests/qemuxml2argvtest.c | 6 +++++
.../qemuxml2argv-aarch64-cpu-passthrough.xml | 27 +++++++++++++++++++++
tests/qemuxml2xmltest.c | 2 ++
7 files changed, 92 insertions(+)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-model-host.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-model-host.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2argv-aarch64-cpu-passthrough.xml
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-model-host.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-model-host.args
new file mode 100644
index 0000000..802ea11
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-model-host.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none /usr/bin/qemu-system-aarch64 -S -M virt -cpu host -m 1024 -smp 1 -nographic -nodefconfig -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -boot c -usb -drive file=/aarch64.raw,if=none,id=drive-virtio-disk0 -device virtio-blk-device,drive=drive-virtio-disk0,id=virtio-disk0
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-model-host.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-model-host.xml
new file mode 100644
index 0000000..53d528f
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-model-host.xml
@@ -0,0 +1,28 @@
+<domain type='kvm'>
+ <name>aarch64test</name>
+ <uuid>496d7ea8-9739-544b-4ebd-ef08be936e8b</uuid>
+ <memory unit='KiB'>1048576</memory>
+ <currentMemory unit='KiB'>1048576</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='aarch64' machine='virt'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <features>
+ <acpi/>
+ <apic/>
+ <pae/>
+ </features>
+ <cpu mode='host-passthrough'/>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-aarch64</emulator>
+ <disk type='file' device='disk'>
+ <source file='/aarch64.raw'/>
+ <target dev='vda' bus='virtio'/>
+ </disk>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.args
new file mode 100644
index 0000000..802ea11
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none /usr/bin/qemu-system-aarch64 -S -M virt -cpu host -m 1024 -smp 1 -nographic -nodefconfig -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -boot c -usb -drive file=/aarch64.raw,if=none,id=drive-virtio-disk0 -device virtio-blk-device,drive=drive-virtio-disk0,id=virtio-disk0
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.xml
new file mode 100644
index 0000000..4cdf387
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-cpu-passthrough.xml
@@ -0,0 +1,27 @@
+<domain type="kvm">
+ <name>aarch64test</name>
+ <uuid>496d7ea8-9739-544b-4ebd-ef08be936e8b</uuid>
+ <memory>1048576</memory>
+ <currentMemory>1048576</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch="aarch64" machine="virt">hvm</type>
+ </os>
+ <features>
+ <acpi/>
+ <apic/>
+ <pae/>
+ </features>
+ <cpu mode='host-passthrough'/>
+ <clock offset="utc"/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-aarch64</emulator>
+ <disk type='file' device='disk'>
+ <source file='/aarch64.raw'/>
+ <target dev='vda' bus='virtio'/>
+ </disk>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 1fe445a..055ceee 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1525,6 +1525,12 @@ mymain(void)
DO_TEST("aarch64-virt-default-nic",
QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
QEMU_CAPS_DEVICE_VIRTIO_MMIO);
+ DO_TEST("aarch64-cpu-passthrough", QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE,
+ QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
+ QEMU_CAPS_CPU_HOST, QEMU_CAPS_KVM);
+ DO_TEST("aarch64-cpu-model-host", QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE,
+ QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
+ QEMU_CAPS_CPU_HOST, QEMU_CAPS_KVM);
DO_TEST("kvm-pit-device", QEMU_CAPS_KVM_PIT_TICK_POLICY);
DO_TEST("kvm-pit-delay", QEMU_CAPS_NO_KVM_PIT);
diff --git a/tests/qemuxml2xmloutdata/qemuxml2argv-aarch64-cpu-passthrough.xml b/tests/qemuxml2xmloutdata/qemuxml2argv-aarch64-cpu-passthrough.xml
new file mode 100644
index 0000000..4cdf387
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2argv-aarch64-cpu-passthrough.xml
@@ -0,0 +1,27 @@
+<domain type="kvm">
+ <name>aarch64test</name>
+ <uuid>496d7ea8-9739-544b-4ebd-ef08be936e8b</uuid>
+ <memory>1048576</memory>
+ <currentMemory>1048576</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch="aarch64" machine="virt">hvm</type>
+ </os>
+ <features>
+ <acpi/>
+ <apic/>
+ <pae/>
+ </features>
+ <cpu mode='host-passthrough'/>
+ <clock offset="utc"/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-aarch64</emulator>
+ <disk type='file' device='disk'>
+ <source file='/aarch64.raw'/>
+ <target dev='vda' bus='virtio'/>
+ </disk>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index bce04b2..45464cc 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -612,6 +612,8 @@ mymain(void)
DO_TEST("memory-hotplug-nonuma");
DO_TEST("memory-hotplug-dimm");
+ DO_TEST("aarch64-cpu-model-host");
+
virObjectUnref(driver.caps);
virObjectUnref(driver.xmlopt);
--
2.3.5
9 years, 7 months
[libvirt] [PATCH] qemu: detect-zeroes feature for drives
by Maros Zatko
This patch adds support for detect-zeroes feature in QEMU. It's intented to be
used by libguestfs in virt-sparsify tool.
Relates to: RHBZ#1130506
Maros Zatko (1):
qemu: add support for detect-zeroes feature
docs/schemas/domaincommon.rng | 12 ++++++++++++
src/conf/domain_conf.c | 19 +++++++++++++++++++
src/conf/domain_conf.h | 10 ++++++++++
src/libvirt_private.syms | 1 +
src/qemu/qemu_capabilities.c | 6 +++++-
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 11 +++++++++++
7 files changed, 59 insertions(+), 1 deletion(-)
--
1.9.3
9 years, 7 months
[libvirt] [PATCH v2 0/9] Additional host name check for network storage pools
by John Ferlan
v1 here:
http://www.redhat.com/archives/libvir-list/2015-April/msg00873.html
Essentially a rewrite of v1 changing to use virsocketaddr.* rather than
virutil.*
Also making check for hostname duplication prior to startPool rather
than during XML processing
John Ferlan (9):
socketaddr: Add isNumeric flag to virSocketAddrParseInternal
socketaddr: Introduce virSocketAddrParseName
iscsi: Check for validity of pool source hostname
netfs: Check for validity of pool source hostname
gluster: Check for validity of pool source hostname
sheepdog: Check for validity of pool source hostname
virsockaddr: Split up functionality of virSocketAddrFormatFull
virsocketaddr: Introduce virSocketAddrIsSameTCPHost
storage: Check for duplicate resolved host name at pool create
src/conf/storage_conf.c | 80 ++++++++++++++-
src/conf/storage_conf.h | 6 +-
src/libvirt_private.syms | 3 +
src/storage/storage_backend_fs.c | 5 +-
src/storage/storage_backend_gluster.c | 6 +-
src/storage/storage_backend_iscsi.c | 6 +-
src/storage/storage_backend_sheepdog.c | 38 ++++---
src/storage/storage_driver.c | 9 +-
src/util/virsocketaddr.c | 180 ++++++++++++++++++++++++++++-----
src/util/virsocketaddr.h | 9 +-
10 files changed, 295 insertions(+), 47 deletions(-)
--
2.1.0
9 years, 7 months
[libvirt] [PATCH] Fix memory leak in virNetSocketNewConnectUNIX
by Jiri Denemark
==26726== by 0x673CD67: __vasprintf_chk (vasprintf_chk.c:80)
==26726== by 0x5673605: UnknownInlinedFun (stdio2.h:210)
==26726== by 0x5673605: virVasprintfInternal (virstring.c:476)
==26726== by 0x56736EE: virAsprintfInternal (virstring.c:497)
==26726== by 0x5680C37: virGetUserRuntimeDirectory (virutil.c:866)
==26726== by 0x5783A89: virNetSocketNewConnectUNIX (virnetsocket.c:572)
==26726== by 0x57751AF: virNetClientNewUNIX (virnetclient.c:344)
==26726== by 0x57689B3: doRemoteOpen (remote_driver.c:895)
==26726== by 0x5769F8E: remoteConnectOpen (remote_driver.c:1195)
==26726== by 0x57092DF: do_open (libvirt.c:1189)
==26726== by 0x570A7BF: virConnectOpenAuth (libvirt.c:1341)
https://bugzilla.redhat.com/show_bug.cgi?id=1215042
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/rpc/virnetsocket.c | 44 +++++++++++++++++++++-----------------------
1 file changed, 21 insertions(+), 23 deletions(-)
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index a59e3e1..7ae2796 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -546,6 +546,7 @@ int virNetSocketNewConnectUNIX(const char *path,
virSocketAddr localAddr;
virSocketAddr remoteAddr;
char *rundir = NULL;
+ int ret = -1;
memset(&localAddr, 0, sizeof(localAddr));
memset(&remoteAddr, 0, sizeof(remoteAddr));
@@ -559,50 +560,50 @@ int virNetSocketNewConnectUNIX(const char *path,
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Auto-spawn of daemon requested, "
"but no binary specified"));
- goto error;
+ goto cleanup;
}
if (!(binname = last_component(binary)) || binname[0] == '\0') {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Cannot determine basename for binary '%s'"),
binary);
- goto error;
+ goto cleanup;
}
if (!(rundir = virGetUserRuntimeDirectory()))
- goto error;
+ goto cleanup;
if (virFileMakePathWithMode(rundir, 0700) < 0) {
virReportSystemError(errno,
_("Cannot create user runtime directory '%s'"),
rundir);
- goto error;
+ goto cleanup;
}
if (virAsprintf(&lockpath, "%s/%s.lock", rundir, binname) < 0)
- goto error;
+ goto cleanup;
if ((lockfd = open(lockpath, O_RDWR | O_CREAT, 0600)) < 0 ||
virSetCloseExec(lockfd) < 0) {
virReportSystemError(errno, _("Unable to create lock '%s'"), lockpath);
- goto error;
+ goto cleanup;
}
if (virFileLock(lockfd, false, 0, 1, true) < 0) {
virReportSystemError(errno, _("Unable to lock '%s'"), lockpath);
- goto error;
+ goto cleanup;
}
}
if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
virReportSystemError(errno, "%s", _("Failed to create socket"));
- goto error;
+ goto cleanup;
}
remoteAddr.data.un.sun_family = AF_UNIX;
if (virStrcpyStatic(remoteAddr.data.un.sun_path, path) == NULL) {
virReportSystemError(ENOMEM, _("Path %s too long for unix socket"), path);
- goto error;
+ goto cleanup;
}
if (remoteAddr.data.un.sun_path[0] == '@')
remoteAddr.data.un.sun_path[0] = '\0';
@@ -612,42 +613,39 @@ int virNetSocketNewConnectUNIX(const char *path,
if (!(spawnDaemon && errno == ENOENT)) {
virReportSystemError(errno, _("Failed to connect socket to '%s'"),
path);
- goto error;
+ goto cleanup;
}
if (virNetSocketForkDaemon(binary) < 0)
- goto error;
+ goto cleanup;
retries--;
usleep(5000);
}
- if (lockfd != -1) {
- unlink(lockpath);
- VIR_FORCE_CLOSE(lockfd);
- VIR_FREE(lockpath);
- }
-
localAddr.len = sizeof(localAddr.data);
if (getsockname(fd, &localAddr.data.sa, &localAddr.len) < 0) {
virReportSystemError(errno, "%s", _("Unable to get local socket name"));
- goto error;
+ goto cleanup;
}
if (!(*retsock = virNetSocketNew(&localAddr, &remoteAddr, true, fd, -1, 0)))
- goto error;
+ goto cleanup;
- return 0;
+ ret = 0;
- error:
+ cleanup:
if (lockfd != -1) {
unlink(lockpath);
VIR_FORCE_CLOSE(lockfd);
}
VIR_FREE(lockpath);
VIR_FREE(rundir);
- VIR_FORCE_CLOSE(fd);
- return -1;
+
+ if (ret == -1)
+ VIR_FORCE_CLOSE(fd);
+
+ return ret;
}
#else
int virNetSocketNewConnectUNIX(const char *path ATTRIBUTE_UNUSED,
--
2.3.5
9 years, 7 months
[libvirt] [PATCH] build: add pragma directive to fix build on some gcc
by Pavel Hrdina
Commit 1268820a removed obsolete index() function and replaced it by
strchr. Few versions of gcc has a bug and reports a warning about
strchr:
../../src/util/virstring.c:1006: error: logical '&&' with non-zero
constant will always evaluate as true [-Wlogical-op]
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
Pushed as build-breaker fix.
src/util/virstring.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/util/virstring.c b/src/util/virstring.c
index 7b0cad7..5794f96 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -986,6 +986,16 @@ virStringHasControlChars(const char *str)
}
+/* Work around spurious strchr() diagnostics given by -Wlogical-op
+ * for gcc < 4.6. Doing it via a local pragma keeps the damage
+ * smaller than disabling it on the package level. Unfortunately, the
+ * affected GCCs don't allow diagnostic push/pop which would have
+ * further reduced the impact. */
+#if BROKEN_GCC_WLOGICALOP
+# pragma GCC diagnostic ignored "-Wlogical-op"
+#endif
+
+
/**
* virStringStripControlChars:
* @str: the string to strip
--
2.0.5
9 years, 7 months
[libvirt] [PATCH 0/5] Make virDomainObjListFindByName run in O(1)
by Michal Privoznik
As discussed here:
https://www.redhat.com/archives/libvir-list/2015-April/msg01135.html
Michal Privoznik (5):
virDomainObjListAddLocked: s/false/NULL/ for @oldDef
virDomainObjListNew: Use virObjectFreeHashData
Introduce virDomainObjEndAPI
virDomainObjListFindByName: Return referenced object
virDomainObjList: Introduce yet another hash table
src/bhyve/bhyve_driver.c | 3 +-
src/conf/domain_conf.c | 83 +++++++++++++++++++++++------------
src/conf/domain_conf.h | 2 +
src/libvirt_private.syms | 1 +
src/libxl/libxl_driver.c | 10 ++---
src/lxc/lxc_driver.c | 3 +-
src/openvz/openvz_driver.c | 11 +++--
src/parallels/parallels_driver.c | 3 +-
src/qemu/qemu_domain.c | 7 +--
src/qemu/qemu_driver.c | 14 ++----
src/test/test_driver.c | 93 +++++++++++++---------------------------
src/uml/uml_driver.c | 15 +++----
12 files changed, 110 insertions(+), 135 deletions(-)
--
2.0.5
9 years, 7 months
[libvirt] [PATCH 0/4] tests: Cleanups and improvements
by Cole Robinson
First 3 patches are uninteresting cleanups, removing a bunch of
boiler plate code.
The last patch adds a way to easily regenerate test output, like when
adding a new test case (plop in the qemu XML, use the env var and the test
suite will create foo.args for you), or when a code changes causes test
suite output to expectedly change.
Cole Robinson (4):
tests: Add VIR_TEST_DEBUG and VIR_TEST_VERBOSE
tests: Use *DefParseFile more
tests: Add virtTestCompareToFile
tests: Add VIR_TEST_REGENERATE_OUTPUT
HACKING | 7 ++
docs/hacking.html.in | 12 +++
tests/bhyvexml2argvtest.c | 41 ++--------
tests/bhyvexml2xmltest.c | 18 +----
tests/cputest.c | 45 ++++-------
tests/domaincapstest.c | 9 +--
tests/domainconftest.c | 7 +-
tests/jsontest.c | 48 +++++-------
tests/lxcxml2xmltest.c | 17 +----
tests/networkxml2conftest.c | 16 +---
tests/networkxml2firewalltest.c | 9 +--
tests/networkxml2xmltest.c | 15 +---
tests/networkxml2xmlupdatetest.c | 15 +---
tests/nodeinfotest.c | 20 +----
tests/nwfilterxml2firewalltest.c | 11 +--
tests/nwfilterxml2xmltest.c | 15 +---
tests/qemuagenttest.c | 9 +--
tests/qemuargv2xmltest.c | 15 ++--
tests/qemucaps2xmltest.c | 27 +------
tests/qemuhelptest.c | 6 +-
tests/qemuhotplugtest.c | 19 ++---
tests/qemumonitorjsontest.c | 9 +--
tests/qemumonitortest.c | 24 +++---
tests/qemuxml2argvtest.c | 27 ++-----
tests/qemuxmlnstest.c | 19 +----
tests/secretxml2xmltest.c | 15 +---
tests/securityselinuxlabeltest.c | 13 +---
tests/sexpr2xmltest.c | 9 +--
tests/statstest.c | 3 +-
tests/storagebackendsheepdogtest.c | 20 +----
tests/storagepoolxml2xmltest.c | 15 +---
tests/storagevolxml2argvtest.c | 40 ++--------
tests/storagevolxml2xmltest.c | 21 +----
tests/sysinfotest.c | 10 +--
tests/testutils.c | 74 ++++++++++++++----
tests/testutils.h | 14 ++++
tests/testutilslxc.c | 2 +-
tests/testutilsqemu.c | 2 +-
tests/utiltest.c | 30 +++-----
tests/virbuftest.c | 60 +++++++--------
tests/vircaps2xmltest.c | 10 +--
tests/vircgrouptest.c | 9 +--
tests/virhashtest.c | 152 ++++++++++++-------------------------
tests/virpcitest.c | 4 +-
tests/virportallocatortest.c | 35 +++------
tests/vmx2xmltest.c | 9 +--
tests/xencapstest.c | 9 +--
tests/xlconfigtest.c | 27 +------
tests/xmconfigtest.c | 27 +------
tests/xml2sexprtest.c | 18 +----
tests/xml2vmxtest.c | 19 +----
51 files changed, 340 insertions(+), 767 deletions(-)
--
2.3.5
9 years, 7 months
[libvirt] [PATCH] qemu: cgroup: Fix priorities when setting emulatorpin
by Peter Krempa
Use the custom emulator pin setting with the highest priority same as
with vcpupin.
---
src/qemu/qemu_cgroup.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index e83342d..bf0621f 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -1110,10 +1110,10 @@ qemuSetupCgroupForEmulator(virDomainObjPtr vm)
if (virCgroupMoveTask(priv->cgroup, cgroup_emulator) < 0)
goto cleanup;
- if (def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO)
- cpumask = priv->autoCpuset;
- else if (def->cputune.emulatorpin)
+ if (def->cputune.emulatorpin)
cpumask = def->cputune.emulatorpin->cpumask;
+ else if (def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO)
+ cpumask = priv->autoCpuset;
else if (def->cpumask)
cpumask = def->cpumask;
--
2.3.5
9 years, 7 months