[libvirt] [PATCH] libxl: find virDomainObj in libxlDomainShutdownThread
by Jim Fehlig
libxl events are delivered to libvirt via the libxlDomainEventHandler
callback registered with libxl. Documenation in
$xensrc/tools/libxl/libxl_event.h states that the callback "may occur
on any thread in which the application calls libxl". This can result
in deadlock since many of the libvirt callees of libxl hold a lock on
the virDomainObj they are working on. When the callback is invoked, it
attempts to find a virDomainObj corresponding to the domain ID provided
by libxl. Searching the domain obj list results in locking each obj
before checking if it is active, and its ID equals the requested ID.
Deadlock is possible when attempting to lock an obj that is already
locked further up the call stack. Indeed, Max Ustermann reported an
instance of this deadlock
https://www.redhat.com/archives/libvir-list/2015-November/msg00130.html
Guido Rossmueller also recently stumbled across it
https://www.redhat.com/archives/libvir-list/2016-September/msg00287.html
Fix the deadlock by moving the lookup of virDomainObj to the
libxlDomainShutdownThread. After this patch, libxl events are
enqueued on the libvirt side and processed by dedicated thread,
avoiding the described deadlock.
Reported-by: Max Ustermann <ustermann78(a)web.de>
Reported-by: Guido Rossmueller <Guido.Rossmueller(a)gdata.de>
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
Essentially this is a V2 of
https://www.redhat.com/archives/libvir-list/2015-November/msg00520.html
But that patch is nearly a year old and "V2" takes a completely
different (and IMO much better) approach to fixing the deadlock.
src/libxl/libxl_domain.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 43f4a7f..a472751 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -421,7 +421,6 @@ virDomainDefParserConfig libxlDomainDefParserConfig = {
struct libxlShutdownThreadInfo
{
libxlDriverPrivatePtr driver;
- virDomainObjPtr vm;
libxl_event *event;
};
@@ -430,7 +429,7 @@ static void
libxlDomainShutdownThread(void *opaque)
{
struct libxlShutdownThreadInfo *shutdown_info = opaque;
- virDomainObjPtr vm = shutdown_info->vm;
+ virDomainObjPtr vm = NULL;
libxl_event *ev = shutdown_info->event;
libxlDriverPrivatePtr driver = shutdown_info->driver;
virObjectEventPtr dom_event = NULL;
@@ -439,6 +438,12 @@ libxlDomainShutdownThread(void *opaque)
cfg = libxlDriverConfigGet(driver);
+ vm = virDomainObjListFindByIDRef(driver->domains, ev->domid);
+ if (!vm) {
+ VIR_INFO("Received event for unknown domain ID %d", ev->domid);
+ goto cleanup;
+ }
+
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
goto cleanup;
@@ -547,7 +552,6 @@ void
libxlDomainEventHandler(void *data, VIR_LIBXL_EVENT_CONST libxl_event *event)
{
libxlDriverPrivatePtr driver = data;
- virDomainObjPtr vm = NULL;
libxl_shutdown_reason xl_reason = event->u.domain_shutdown.shutdown_reason;
struct libxlShutdownThreadInfo *shutdown_info = NULL;
virThread thread;
@@ -565,12 +569,6 @@ libxlDomainEventHandler(void *data, VIR_LIBXL_EVENT_CONST libxl_event *event)
if (xl_reason == LIBXL_SHUTDOWN_REASON_SUSPEND)
goto error;
- vm = virDomainObjListFindByIDRef(driver->domains, event->domid);
- if (!vm) {
- VIR_INFO("Received event for unknown domain ID %d", event->domid);
- goto error;
- }
-
/*
* Start a thread to handle shutdown. We don't want to be tying up
* libxl's event machinery by doing a potentially lengthy shutdown.
@@ -579,7 +577,6 @@ libxlDomainEventHandler(void *data, VIR_LIBXL_EVENT_CONST libxl_event *event)
goto error;
shutdown_info->driver = driver;
- shutdown_info->vm = vm;
shutdown_info->event = (libxl_event *)event;
if (virThreadCreate(&thread, false, libxlDomainShutdownThread,
shutdown_info) < 0) {
@@ -591,7 +588,7 @@ libxlDomainEventHandler(void *data, VIR_LIBXL_EVENT_CONST libxl_event *event)
}
/*
- * VM is unlocked and libxl_event freed in shutdown thread
+ * libxlShutdownThreadInfo and libxl_event are freed in shutdown thread
*/
return;
@@ -600,7 +597,6 @@ libxlDomainEventHandler(void *data, VIR_LIBXL_EVENT_CONST libxl_event *event)
/* Cast away any const */
libxl_event_free(cfg->ctx, (libxl_event *)event);
virObjectUnref(cfg);
- virDomainObjEndAPI(&vm);
VIR_FREE(shutdown_info);
}
--
2.6.6
8 years, 6 months
[libvirt] [PATCH] qemu: Fix crash in qemucapsprobe
by Jiri Denemark
The qemucapsprobe helper calls virQEMUCapsInitHostCPUModel with
caps == NULL, causing the following crash:
Program received signal SIGSEGV, Segmentation fault.
#0 0x00007ffff788775f in virQEMUCapsInitHostCPUModel
(qemuCaps=qemuCaps@entry=0x649680, host=host@entry=0x10) at
src/qemu/qemu_capabilities.c:2969
#1 0x00007ffff7889dbf in virQEMUCapsNewForBinaryInternal
(caps=caps@entry=0x0, binary=<optimized out>,
libDir=libDir@entry=0x4033f6 "/tmp", cacheDir=cacheDir@entry=0x0,
runUid=runUid@entry=4294967295, runGid=runGid@entry=4294967295,
qmpOnly=true) at src/qemu/qemu_capabilities.c:4039
#2 0x0000000000401702 in main (argc=2, argv=0x7fffffffd968) at
tests/qemucapsprobe.c:73
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 4d859c4..73a7fd4 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -4036,7 +4036,8 @@ virQEMUCapsNewForBinaryInternal(virCapsPtr caps,
virQEMUCapsRememberCached(qemuCaps, cacheDir) < 0)
goto error;
- virQEMUCapsInitHostCPUModel(qemuCaps, &caps->host);
+ if (caps)
+ virQEMUCapsInitHostCPUModel(qemuCaps, &caps->host);
}
cleanup:
--
2.10.0
8 years, 6 months
[libvirt] [PATCH] virsh domdisplay: introduce '--all' for showing all possible graphical display
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)gmail.com>
For one VM, it could have more than one graphical display.
Such as we coud add both vnc and spice display to a VM.
This patch introduces '--all' for showing all
possible type of graphical display for a active VM.
Signed-off-by: Chen Hanxiao <chenhanxiao(a)gmail.com>
---
tools/virsh-domain.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 3829b17..7194153 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -10648,6 +10648,10 @@ static const vshCmdOptDef opts_domdisplay[] = {
.help = N_("select particular graphical display "
"(e.g. \"vnc\", \"spice\", \"rdp\")")
},
+ {.name = "all",
+ .type = VSH_OT_BOOL,
+ .help = N_("show all possible graphical displays")
+ },
{.name = NULL}
};
@@ -10671,6 +10675,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
int tmp;
int flags = 0;
bool params = false;
+ bool all = false;
const char *xpath_fmt = "string(/domain/devices/graphics[@type='%s']/%s)";
virSocketAddr addr;
@@ -10685,6 +10690,9 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "include-password"))
flags |= VIR_DOMAIN_XML_SECURE;
+ if (vshCommandOptBool(cmd, "all"))
+ all = true;
+
if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0)
goto cleanup;
@@ -10845,7 +10853,15 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
/* We got what we came for so return successfully */
ret = true;
- break;
+ if (!all) {
+ break;
+ } else {
+ VIR_FREE(xpath);
+ VIR_FREE(passwd);
+ VIR_FREE(listen_addr);
+ VIR_FREE(output);
+ vshPrint(ctl, "\n");
+ }
}
if (!ret) {
--
1.8.3.1
8 years, 6 months
[libvirt] [PATCH] mingw: Package cputypes.rng for mingw32 too
by Jiri Denemark
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
Pushed as trivial.
mingw-libvirt.spec.in | 1 +
1 file changed, 1 insertion(+)
diff --git a/mingw-libvirt.spec.in b/mingw-libvirt.spec.in
index c8476d9..c9bf503 100644
--- a/mingw-libvirt.spec.in
+++ b/mingw-libvirt.spec.in
@@ -210,6 +210,7 @@ rm -rf $RPM_BUILD_ROOT%{mingw64_libexecdir}/libvirt-guests.sh
%dir %{mingw32_datadir}/libvirt/schemas/
%{mingw32_datadir}/libvirt/schemas/basictypes.rng
%{mingw32_datadir}/libvirt/schemas/capability.rng
+%{mingw32_datadir}/libvirt/schemas/cputypes.rng
%{mingw32_datadir}/libvirt/schemas/domain.rng
%{mingw32_datadir}/libvirt/schemas/domaincaps.rng
%{mingw32_datadir}/libvirt/schemas/domaincommon.rng
--
2.10.0
8 years, 6 months
[libvirt] [PATCH] mingw: Package cputypes.rng
by Jiri Denemark
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
Pushed as trivial.
mingw-libvirt.spec.in | 1 +
1 file changed, 1 insertion(+)
diff --git a/mingw-libvirt.spec.in b/mingw-libvirt.spec.in
index 5c7183f..c8476d9 100644
--- a/mingw-libvirt.spec.in
+++ b/mingw-libvirt.spec.in
@@ -292,6 +292,7 @@ rm -rf $RPM_BUILD_ROOT%{mingw64_libexecdir}/libvirt-guests.sh
%dir %{mingw64_datadir}/libvirt/schemas/
%{mingw64_datadir}/libvirt/schemas/basictypes.rng
%{mingw64_datadir}/libvirt/schemas/capability.rng
+%{mingw64_datadir}/libvirt/schemas/cputypes.rng
%{mingw64_datadir}/libvirt/schemas/domain.rng
%{mingw64_datadir}/libvirt/schemas/domaincaps.rng
%{mingw64_datadir}/libvirt/schemas/domaincommon.rng
--
2.10.0
8 years, 6 months
[libvirt] [PATCH] spec: Package cputypes.rng
by Jiri Denemark
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
Pushed as trivial.
libvirt.spec.in | 1 +
1 file changed, 1 insertion(+)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index a389e88..00b95b8 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1814,6 +1814,7 @@ exit 0
%{_datadir}/libvirt/schemas/basictypes.rng
%{_datadir}/libvirt/schemas/capability.rng
+%{_datadir}/libvirt/schemas/cputypes.rng
%{_datadir}/libvirt/schemas/domain.rng
%{_datadir}/libvirt/schemas/domaincaps.rng
%{_datadir}/libvirt/schemas/domaincommon.rng
--
2.10.0
8 years, 6 months
[libvirt] [PATCH] qemu: make qemuGetCompressionProgram return int not an enum
by Daniel P. Berrange
enum types are unsigned and the qemuGetCompressionProgram
function can return -1 on error. It is therefore inappropriate
to return an enum type. This fixes a build error where the
internal 'ret' variable was used in a comparison with -1
../../src/qemu/qemu_driver.c: In function 'qemuGetCompressionProgram':
../../src/qemu/qemu_driver.c:3280:5: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
../../src/qemu/qemu_driver.c:3289:5: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
cc1: all warnings being treated as errors
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
Pushed as a CI broken build fix.
src/qemu/qemu_driver.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index eaea96f..7873a68 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3264,13 +3264,13 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
* no there was an error, then just return RAW
* indicating none.
*/
-static virQEMUSaveFormat ATTRIBUTE_NONNULL(2)
+static int ATTRIBUTE_NONNULL(2)
qemuGetCompressionProgram(const char *imageFormat,
char **compresspath,
const char *styleFormat,
bool use_raw_on_fail)
{
- virQEMUSaveFormat ret;
+ int ret;
*compresspath = NULL;
--
2.7.4
8 years, 6 months
[libvirt] Plan for next release
by Daniel Veillard
Time flies, I didn't realized we were that close from the end of the month.
So if we want to have 2.3.0 for next Monday I think we should start the freeze
today, possibly tonight.
Does this work ? Sorry for late notice,
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, 6 months
[libvirt] [PATCH] Fix coding style issues.
by Nitesh Konkar
Signed-off-by: Nitesh Konkar <nitkon12(a)linux.vnet.ibm.com>
---
src/uml/uml_conf.h | 2 +-
src/vbox/vbox_common.h | 2 +-
tests/qemumonitorjsontest.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/uml/uml_conf.h b/src/uml/uml_conf.h
index 9a45d10..5da55e5 100644
--- a/src/uml/uml_conf.h
+++ b/src/uml/uml_conf.h
@@ -35,7 +35,7 @@
# include "vircommand.h"
# include "virhash.h"
-# define umlDebug(fmt, ...) do {} while(0)
+# define umlDebug(fmt, ...) do {} while (0)
# define UML_CPUMASK_LEN CPU_SETSIZE
diff --git a/src/vbox/vbox_common.h b/src/vbox/vbox_common.h
index c8787c3..b178878 100644
--- a/src/vbox/vbox_common.h
+++ b/src/vbox/vbox_common.h
@@ -435,6 +435,6 @@ typedef nsISupports IKeyboard;
} else { \
result = -1; \
} \
- } while(0)
+ } while (0)
#endif /* VBOX_COMMON_H */
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index cbc39c6..9823a9d 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -721,7 +721,7 @@ testQemuMonitorJSONAttachChardev(const void *data)
goto cleanup; \
if (qemuMonitorAttachCharDev(qemuMonitorTestGetMonitor(test), \
chrID, &chr) < 0) \
- ret = fail ? ret : -1; \
+ ret = fail ? ret : -1; \
else \
ret = fail ? -1 : ret; \
--
2.1.0
8 years, 6 months
[libvirt] virsh can list ("virsh list" is empty) Guest domains created by "xl create DomU"
by Volo M.
Hi,
We use Centos 7 Xen hypervisor, start VMs with xl toolkit (libxl), but we
can't list with "virsh list" command DomUs created with "xl create ..."
command.
Can anybody, please, explain why this happens? Why does it work like this?
It worked before with "libvirt+xm" toolkits, but xm toolkit was deprecated
for latest Xen sortware on Centos 7.
Can this be fixed ever?
Thank you.
Example:
[root@c7xen2 ~]# xl create /onapp/config/w62tp7db1txk12
...
[root@c7xen2 ~]# xl list
Name ID Mem VCPUs State Time(s)
Domain-0 0 400 2 r-----
102.0
w62tp7db1txk12 1 512 1 -b----
2.6
[root@c7xen2 ~]# virsh list
Id Name State
----------------------------------------------------
0 Domain-0 running
[root@c7xen2 ~]#
8 years, 6 months