[libvirt] [PATCH] util: fix releasing pidfile in cleanup
by Martin Kletzander
Coverity found out the very obvious problem in the code. That is that
virPidFileReleasePath() was called only if
virPidFileAcquirePath() returned 0. But virPidFileAcquirePath() doesn't
return only 0 on success, but the FD that needs to be closed.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/util/virpidfile.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c
index 098458f..a77a326 100644
--- a/src/util/virpidfile.c
+++ b/src/util/virpidfile.c
@@ -592,9 +592,8 @@ virPidFileForceCleanupPath(const char *path)
if (virPidFileReadPath(path, &pid) < 0)
return -1;
- if (virPidFileAcquirePath(path, false, 0) == 0) {
- virPidFileReleasePath(path, fd);
- } else {
+ fd = virPidFileAcquirePath(path, false, 0);
+ if (fd < 0) {
virResetLastError();
/* Only kill the process if the pid is valid one. 0 means
@@ -607,5 +606,8 @@ virPidFileForceCleanupPath(const char *path)
return -1;
}
+ if (fd)
+ virPidFileReleasePath(path, fd);
+
return 0;
}
--
2.1.3
10 years, 5 months
[libvirt] [PATCH v5 0/3] add nodeset check in numatune
by Chen Fan
when setting elements memnode and nodeset in attribute numatune more
than the host nodes in XML file, VM boot should fail. so add check for
that.
Chen Fan (3):
bitmap: add virBitmapLastSetBit for finding the last bit position of
bitmap
numatune: add check for numatune nodeset range
virnuma: use virNumaNodesetIsAvailable checking nodeset in
virNumaSetupMemoryPolicy
src/conf/numatune_conf.c | 28 ++++++++++++
src/conf/numatune_conf.h | 1 +
src/libvirt_private.syms | 2 +
src/qemu/qemu_command.c | 4 ++
src/util/virbitmap.c | 45 ++++++++++++++++++
src/util/virbitmap.h | 3 ++
src/util/virnuma.c | 53 +++++++++++++++++-----
src/util/virnuma.h | 1 +
...rgv-numatune-static-nodeset-exceed-hostnode.xml | 35 ++++++++++++++
tests/qemuxml2argvmock.c | 9 ++++
tests/qemuxml2argvtest.c | 2 +
tests/virbitmaptest.c | 13 +++++-
12 files changed, 184 insertions(+), 12 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-numatune-static-nodeset-exceed-hostnode.xml
--
1.9.3
10 years, 5 months
[libvirt] [PATCH v4 0/3] add nodeset check in numatune
by Chen Fan
when setting elements memnode and nodeset in attribute numatune more
than the host nodes in XML file, VM boot should fail. so add check for
that.
Chen Fan (3):
bitmap: add virBitmapLastSetBit for finding the last bit position of
bitmap
numatune: add check for numatune nodeset range
virnuma: use virNumaNodesetIsAvailable checking nodeset in
virNumaSetupMemoryPolicy
src/conf/numatune_conf.c | 28 ++++++++++
src/conf/numatune_conf.h | 1 +
src/libvirt_private.syms | 2 +
src/qemu/qemu_command.c | 4 ++
src/util/virbitmap.c | 45 ++++++++++++++++
src/util/virbitmap.h | 3 ++
src/util/virnuma.c | 61 +++++++++++++++-------
src/util/virnuma.h | 1 +
...rgv-numatune-static-nodeset-exceed-hostnode.xml | 36 +++++++++++++
tests/qemuxml2argvmock.c | 9 ++++
tests/qemuxml2argvtest.c | 1 +
tests/virbitmaptest.c | 13 ++++-
12 files changed, 184 insertions(+), 20 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-numatune-static-nodeset-exceed-hostnode.xml
--
1.9.3
10 years, 5 months
[libvirt] [PATCH 2/2] qemu: migration: Ignore null ptr in qemuMigrationStopNBDServer
by weiwei li
qemuMigrationCookiePtr mig->nbd may be null when MigrationCookie
do not have nbd information ,but nbd port did allocated before and
must be released here, so ignore mig->nbd null ptr and just warn.
Signed-off-by: Weiwei Li <nuonuoli(a)tencent.com>
---
src/qemu/qemu_migration.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 0ad8054..134b041 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1584,7 +1584,7 @@ qemuMigrationStopNBDServer(virQEMUDriverPtr driver,
qemuDomainObjPrivatePtr priv = vm->privateData;
if (!mig->nbd)
- return;
+ VIR_WARN("mig->nbd is null");
if (qemuDomainObjEnterMonitorAsync(driver, vm,
QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
--
1.7.1
10 years, 5 months
[libvirt] [PATCH] vbox: Prevent from registering storage driver with NULL
by Taowei Luo
Since 5892944fc853 the virRegisterStorageDriver may be called with
a NULL storageDriver if it failed on vboxGetStorageDriver.
So make sure the storageDriver is not NULL before register.
---
src/vbox/vbox_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c
index c64d2d6..b2e35e9 100644
--- a/src/vbox/vbox_driver.c
+++ b/src/vbox/vbox_driver.c
@@ -74,7 +74,7 @@ int vboxStorageRegister(void)
if (VBoxCGlueInit(&uVersion) == 0)
storageDriver = vboxGetStorageDriver(uVersion);
- if (virRegisterStorageDriver(storageDriver) < 0)
+ if (storageDriver && virRegisterStorageDriver(storageDriver) < 0)
return -1;
return 0;
}
--
1.7.9.5
10 years, 5 months
[libvirt] [PATCH] examples: add systemtap script to ease lock debugging
by Martin Kletzander
As discussed before, this simple script should help with debugging
deadlocks, although there are still some caveats. RWLocks are not
handled by this and if your deadlock if very racy, it may not lock
up when running with this script due to the slowdown.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
examples/systemtap/lock-debug.stp | 118 ++++++++++++++++++++++++++++++++++++++
1 file changed, 118 insertions(+)
create mode 100644 examples/systemtap/lock-debug.stp
diff --git a/examples/systemtap/lock-debug.stp b/examples/systemtap/lock-debug.stp
new file mode 100644
index 0000000..8f06340
--- /dev/null
+++ b/examples/systemtap/lock-debug.stp
@@ -0,0 +1,118 @@
+#!/usr/bin/stap --ldd -d /usr/sbin/libvirtd -c libvirtd
+#
+# Usage with installed libvirt daemon:
+# stap --ldd -d /usr/sbin/libvirtd -c libvirtd \
+# lock-debug.stp /usr/lib/libvirt.so
+#
+# If made executable; simple './lock-debug.stp' should work too.
+#
+# TODOs:
+#
+# Document usage with uninstalled daemon and libs. Assuming CWD is toplevel
+# source git directory, it should be only slight modification to the following:
+#
+# ./run stap --ldd -c daemon/libvirtd -d daemon/libvirtd
+# examples/systemtap/lock-debug.stp src/.libs/libvirt.so
+#
+# Debug RWLock mechanisms as well.
+#
+# Author: Martin Kletzander <mkletzan(a)redhat.com>
+
+
+global mx_tolock
+global mx_locked
+
+
+function filter()
+{
+ if (pid() != target())
+ return 1
+
+ return 0
+}
+
+probe library = process( %( $# > 0 %? @1 %: "/usr/lib/libvirt.so" %) )
+{
+ if (filter()) next
+}
+
+probe lock = library.function("virMutexLock")
+{
+ lockname = usymdata($m)
+}
+
+probe unlock = library.function("virMutexUnlock")
+{
+ lockname = usymdata($m)
+}
+
+probe begin
+{
+ %( $# > 1 %? println("error: Too many parameters"); exit();
+ %: print("Started, press ^C when the proccess hangs\n"); %)
+}
+
+probe lock.call
+{
+ mx_tolock[lockname, tid()] = sprint_usyms(ubacktrace())
+}
+
+probe lock.return
+{
+ if ([lockname, tid()] in mx_tolock) {
+ mx_locked[lockname, tid()] = mx_tolock[lockname, tid()]
+ delete mx_tolock[lockname, tid()]
+ } else {
+ printf("internal error: lock acquired unwillingly?\n")
+ }
+}
+
+probe unlock.call
+{
+ found = 0
+
+ foreach ([lock, tid] in mx_locked) {
+ if (lock != lockname)
+ continue
+ if (tid != tid()) {
+ printf("Warning: lock released on different thread that locked it.\n")
+ printf("Lock trace:\n%s\n", mx_locked[lock, tid])
+ printf("Unlock trace:\n%s\n", sprint_usyms(ubacktrace()))
+ }
+
+ found = tid
+ break
+ }
+
+ if (found && [lockname, found] in mx_locked)
+ delete mx_locked[lockname, found]
+}
+
+probe end
+{
+ tmp = 0
+
+ printf("\n=============\n")
+
+ foreach (bt1 = [lock1, tid1] in mx_tolock) {
+ deadlock = 0
+
+ foreach (bt2 = [lock2, tid2] in mx_tolock) {
+ if (lock1 == lock2) {
+ if (!tmp++)
+ printf("The following locks cannot be acquired:\n")
+
+ if (!deadlock++)
+ printf("Lock %s was locked in thread %d with this trace:\n%s\n",
+ lock1, tid1, bt1)
+
+ printf("and is waiting to be locked by thread %d here:\n%s\n",
+ tid2, bt2)
+ }
+ }
+ if (deadlock)
+ printf("---\n")
+ }
+ if (!tmp)
+ printf("No deadlocks found, sorry.\n")
+}
--
2.1.2
10 years, 5 months
[libvirt] NBD TLS support in QEMU
by Stefan Hajnoczi
Hi,
QEMU offers both NBD client and server functionality. The NBD protocol
runs unencrypted, which is a problem when the client and server
communicate over an untrusted network.
The particular use case that prompted this mail is storage migration in
OpenStack. The goal is to encrypt the NBD connection between source and
destination hosts during storage migration.
I think we can integrate TLS into the NBD protocol as an optional flag.
A quick web search does not reveal existing open source SSL/TLS NBD
implementations. I do see a VMware NBDSSL protocol but there is no
specification so I guess it is proprietary.
The NBD protocol starts with a negotiation phase. This would be the
appropriate place to indicate that TLS will be used. After client and
server complete TLS setup the connection can continue as normal.
Besides QEMU, the userspace NBD tools (http://nbd.sf.net/) can also be
extended to support TLS. In this case the kernel needs a localhost
socket and userspace handles TLS.
Thoughts?
Stefan
10 years, 5 months
[libvirt] [PATCH] mingw: fix build failure
by Pavel Hrdina
This macro seems to be defined only on linux/unix and it fails during
mingw build. Its value is '16' (taken from net/if.h) so define it if
it's not defined.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
For now just define it for mingw but we should review all daemon related
code and not build it for mingw at all to save is those kind of failures.
src/util/virnetdev.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 6da3371..3831009 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -52,6 +52,10 @@
# include <net/if_dl.h>
#endue
+#offender's IFNAMSIZ
+# define IFNAMSIZ 16
+#endif
+
#define VIR_FROM_THIS VIR_FROM_NONE
VIR_LOG_INIT("util.netdev");
--
2.0.4
10 years, 5 months
[libvirt] [PATCH] vbox: remove unused code that causes build failures
by Martin Kletzander
Since 87dea4fcffb2d1b120e7841adc0e3d8ea97ed777 vboxGetDrivers() is not
used for getting the vbox network driver. The only call the code does
is using NULL as the @networkDriver_ret param , but the code still used
vbox[0-9][0-9]NetworkDriver that didn't exist anymore.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/vbox/vbox_driver.c | 17 +----------------
1 file changed, 1 insertion(+), 16 deletions(-)
diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c
index 7d7214a..4d13fbf 100644
--- a/src/vbox/vbox_driver.c
+++ b/src/vbox/vbox_driver.c
@@ -74,10 +74,8 @@ extern virStorageDriver vbox43_4StorageDriver;
#if !defined(WITH_DRIVER_MODULES) || defined(VBOX_STORAGE_DRIVER)
static void
vboxGetDrivers(virDriverPtr *driver_ret,
- virNetworkDriverPtr *networkDriver_ret,
virStorageDriverPtr *storageDriver_ret)
{
- virNetworkDriverPtr networkDriver;
virStorageDriverPtr storageDriver;
uint32_t uVersion;
@@ -87,7 +85,6 @@ vboxGetDrivers(virDriverPtr *driver_ret,
* if the user requests a vbox:// URI which we know will
* never work
*/
- networkDriver = &vbox22NetworkDriver;
storageDriver = &vbox22StorageDriver;
/* Init the glue and get the API version. */
@@ -104,43 +101,33 @@ vboxGetDrivers(virDriverPtr *driver_ret,
*/
if (uVersion >= 2001052 && uVersion < 2002051) {
VIR_DEBUG("VirtualBox API version: 2.2");
- networkDriver = &vbox22NetworkDriver;
storageDriver = &vbox22StorageDriver;
} else if (uVersion >= 2002051 && uVersion < 3000051) {
VIR_DEBUG("VirtualBox API version: 3.0");
- networkDriver = &vbox30NetworkDriver;
storageDriver = &vbox30StorageDriver;
} else if (uVersion >= 3000051 && uVersion < 3001051) {
VIR_DEBUG("VirtualBox API version: 3.1");
- networkDriver = &vbox31NetworkDriver;
storageDriver = &vbox31StorageDriver;
} else if (uVersion >= 3001051 && uVersion < 3002051) {
VIR_DEBUG("VirtualBox API version: 3.2");
- networkDriver = &vbox32NetworkDriver;
storageDriver = &vbox32StorageDriver;
} else if (uVersion >= 3002051 && uVersion < 4000051) {
VIR_DEBUG("VirtualBox API version: 4.0");
- networkDriver = &vbox40NetworkDriver;
storageDriver = &vbox40StorageDriver;
} else if (uVersion >= 4000051 && uVersion < 4001051) {
VIR_DEBUG("VirtualBox API version: 4.1");
- networkDriver = &vbox41NetworkDriver;
storageDriver = &vbox41StorageDriver;
} else if (uVersion >= 4001051 && uVersion < 4002020) {
VIR_DEBUG("VirtualBox API version: 4.2");
- networkDriver = &vbox42NetworkDriver;
storageDriver = &vbox42StorageDriver;
} else if (uVersion >= 4002020 && uVersion < 4002051) {
VIR_DEBUG("VirtualBox API version: 4.2.20 or higher");
- networkDriver = &vbox42_20NetworkDriver;
storageDriver = &vbox42_20StorageDriver;
} else if (uVersion >= 4002051 && uVersion < 4003004) {
VIR_DEBUG("VirtualBox API version: 4.3");
- networkDriver = &vbox43NetworkDriver;
storageDriver = &vbox43StorageDriver;
} else if (uVersion >= 4003004 && uVersion < 4003051) {
VIR_DEBUG("VirtualBox API version: 4.3.4 or higher");
- networkDriver = &vbox43_4NetworkDriver;
storageDriver = &vbox43_4StorageDriver;
} else {
VIR_DEBUG("Unsupported VirtualBox API version: %u", uVersion);
@@ -151,8 +138,6 @@ vboxGetDrivers(virDriverPtr *driver_ret,
if (driver_ret)
*driver_ret = NULL;
- if (networkDriver_ret)
- *networkDriver_ret = networkDriver;
if (storageDriver_ret)
*storageDriver_ret = storageDriver;
}
@@ -178,7 +163,7 @@ int vboxStorageRegister(void)
{
virStorageDriverPtr storageDriver;
- vboxGetDrivers(NULL, NULL, &storageDriver);
+ vboxGetDrivers(NULL, &storageDriver);
if (virRegisterStorageDriver(storageDriver) < 0)
return -1;
--
2.1.2
10 years, 5 months