[libvirt] Add USB controller support
by Christophe Fergeau
Hey,
Here is the second version of the patch series implementing USB controller
support in libvirt-gconfig. There's a bug fixed in
GVirConfigDomainAddressUsb creation (type="usb" was missing) as well as a
few small bug fixes/changes in the test program. I also added an additional
patch implementing a gvir_config_domain_setup_default_usb_controllers to
make adding usb controllers easier following Marc-André's suggestion.
Christophe
12 years, 7 months
[libvirt] [PATCHv2] daemon: Plug memory leaks
by Alex Jia
* daemon/libvirtd-config.c (daemonConfigFree): fix memory leaks.
How to reproduce?
% make && make -C tests check TESTS=libvirtdconftest
% cd tests && valgrind -v --leak-check=full ./libvirtdconftest
actual result:
==11008== 185 bytes in 5 blocks are definitely lost in loss record 3 of 5
==11008== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==11008== by 0x39CF07F6E1: strdup (strdup.c:43)
==11008== by 0x406626: daemonConfigLoadOptions (libvirtd-config.c:438)
==11008== by 0x406800: daemonConfigLoadData (libvirtd-config.c:492)
==11008== by 0x403CCF: testCorrupt (libvirtdconftest.c:110)
==11008== by 0x404FAD: virtTestRun (testutils.c:145)
==11008== by 0x403A34: mymain (libvirtdconftest.c:219)
==11008== by 0x404687: virtTestMain (testutils.c:700)
==11008== by 0x39CF01ECDC: (below main) (libc-start.c:226)
==11008==
==11008== LEAK SUMMARY:
==11008== definitely lost: 185 bytes in 5 blocks
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
daemon/libvirtd-config.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/daemon/libvirtd-config.c b/daemon/libvirtd-config.c
index 4d041f0..471236c 100644
--- a/daemon/libvirtd-config.c
+++ b/daemon/libvirtd-config.c
@@ -358,6 +358,7 @@ daemonConfigFree(struct daemonConfig *data)
VIR_FREE(data->cert_file);
VIR_FREE(data->crl_file);
+ VIR_FREE(data->host_uuid);
VIR_FREE(data->log_filters);
VIR_FREE(data->log_outputs);
--
1.7.1
12 years, 7 months
[libvirt] [PATCH] daemon: Plug memory leaks
by Alex Jia
Detected by valgrind. Leaks are introduced in commit 6e6e9be.
* daemon/libvirtd-config.c (macro GET_CONF_STR): fix memory leaks.
How to reproduce?
% make && make -C tests check TESTS=libvirtdconftest
% cd tests && valgrind -v --leak-check=full ./libvirtdconftest
actual result:
==11008== 185 bytes in 5 blocks are definitely lost in loss record 3 of 5
==11008== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==11008== by 0x39CF07F6E1: strdup (strdup.c:43)
==11008== by 0x406626: daemonConfigLoadOptions (libvirtd-config.c:438)
==11008== by 0x406800: daemonConfigLoadData (libvirtd-config.c:492)
==11008== by 0x403CCF: testCorrupt (libvirtdconftest.c:110)
==11008== by 0x404FAD: virtTestRun (testutils.c:145)
==11008== by 0x403A34: mymain (libvirtdconftest.c:219)
==11008== by 0x404687: virtTestMain (testutils.c:700)
==11008== by 0x39CF01ECDC: (below main) (libc-start.c:226)
==11008==
==11008== LEAK SUMMARY:
==11008== definitely lost: 185 bytes in 5 blocks
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
daemon/libvirtd-config.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/daemon/libvirtd-config.c b/daemon/libvirtd-config.c
index 4d041f0..0a4323a 100644
--- a/daemon/libvirtd-config.c
+++ b/daemon/libvirtd-config.c
@@ -152,6 +152,7 @@ checkType (virConfValuePtr p, const char *filename,
virReportOOMError(); \
goto error; \
} \
+ VIR_FREE(data->var_name); \
} \
} while (0)
--
1.7.1
12 years, 7 months
[libvirt] [test-API PATCH 0/5] Destroy class definition in utils.py
by Osier Yang
These five patches are to change utils.py into a collection of functions.
And cleanup all of existing testcase to use the functions in it directly.
(1) Destroy Utils class definition
(2) Remove "util = utils.Utils()"
(3) Substitue "util." with "utils."
(4) Remove useless utils import "from utils import utils" in testcases where
none of functions in utils.py is called
In testcase
from utils import utils
...
utils.functions(...)
...
12 years, 7 months
[libvirt] [PATCH 0/5] fix block job bugs relative to upstream qemu
by Eric Blake
The following 5 patches are ready for review and application to
libvirt now, since they correspond to features that are currently in
the qemu 1.1 tree. (I've split these less-controversial parts from
v4 of my larger storage migration series [1]; so that this series has
no dependency on the yet-to-be-determined 'drive-mirror' semantics).
[1]https://www.redhat.com/archives/libvir-list/2012-April/msg00330.html
Patch 1 is new, and matches a qemu patch taken just today.
Patch 2 matches 2/18 in the block migration series, with some tweaks
to defer any qemu changes till later, as well as wording improvements
in the documentation to match the behavior implemented by this series.
Patch 3 matches an independent patch I sent earlier today, updated
to resolve review comments from that version.
Patch 4 matches 3/18 in the block migration series, with modifications
to now account for both RHEL 6.2 and qemu 1.1 behaviors. I've altered
this so much from Adam's original that I claimed authorship, although
I've left his Signed-off-by for the initial implementation.
Patch 5 matches 4/18 in the block migration series, with minor tweaks
due to rebasing.
Later, I will repost a v5 of my storage migration series based on
top of this one.
Adam Litke (1):
blockjob: add API for async virDomainBlockJobAbort
Eric Blake (4):
blockjob: add qemu capabilities related to block pull jobs
blockjob: optimize JSON event handler lookup
blockjob: wire up qemu async virDomainBlockJobAbort
blockjob: allow for fast-finishing job
include/libvirt/libvirt.h.in | 10 +++
src/libvirt.c | 13 +++-
src/qemu/qemu_capabilities.c | 3 +
src/qemu/qemu_capabilities.h | 2 +
src/qemu/qemu_driver.c | 106 ++++++++++++++++++++-----
src/qemu/qemu_monitor.c | 11 ++-
src/qemu/qemu_monitor.h | 8 +-
src/qemu/qemu_monitor_json.c | 179 +++++++++++++++++++++++++++---------------
src/qemu/qemu_monitor_json.h | 4 +-
tools/virsh.c | 51 ++++++++-----
tools/virsh.pod | 35 ++++++---
11 files changed, 300 insertions(+), 122 deletions(-)
--
1.7.7.6
12 years, 7 months
[libvirt] [PATCH] qemu: optimize JSON event handler lookup
by Eric Blake
Probably in the noise, but this will let us scale more efficiently
as we recognize ever more qemu events.
* src/qemu/qemu_monitor_json.c (eventHandlers): Sort.
(eventSearch): New helper function.
(qemuMonitorJSONIOProcessEvent): Optimize event lookup.
---
In reply to:
https://www.redhat.com/archives/libvir-list/2012-April/msg00416.html
src/qemu/qemu_monitor_json.c | 55 +++++++++++++++++++++++------------------
1 files changed, 31 insertions(+), 24 deletions(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 7c893d4..d142517 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -67,37 +67,45 @@ static void qemuMonitorJSONHandlePMSuspend(qemuMonitorPtr mon, virJSONValuePtr d
static void qemuMonitorJSONHandleBlockJobCompleted(qemuMonitorPtr mon, virJSONValuePtr data);
static void qemuMonitorJSONHandleBlockJobCanceled(qemuMonitorPtr mon, virJSONValuePtr data);
-static struct {
+typedef struct {
const char *type;
void (*handler)(qemuMonitorPtr mon, virJSONValuePtr data);
-} eventHandlers[] = {
- { "SHUTDOWN", qemuMonitorJSONHandleShutdown, },
- { "RESET", qemuMonitorJSONHandleReset, },
+} qemuEventHandler;
+static qemuEventHandler eventHandlers[] = {
+ { "BLOCK_IO_ERROR", qemuMonitorJSONHandleIOError, },
+ { "BLOCK_JOB_CANCELLED", qemuMonitorJSONHandleBlockJobCanceled, },
+ { "BLOCK_JOB_COMPLETED", qemuMonitorJSONHandleBlockJobCompleted, },
+ { "DEVICE_TRAY_MOVED", qemuMonitorJSONHandleTrayChange, },
{ "POWERDOWN", qemuMonitorJSONHandlePowerdown, },
- { "STOP", qemuMonitorJSONHandleStop, },
+ { "RESET", qemuMonitorJSONHandleReset, },
{ "RTC_CHANGE", qemuMonitorJSONHandleRTCChange, },
- { "WATCHDOG", qemuMonitorJSONHandleWatchdog, },
- { "BLOCK_IO_ERROR", qemuMonitorJSONHandleIOError, },
- { "VNC_CONNECTED", qemuMonitorJSONHandleVNCConnect, },
- { "VNC_INITIALIZED", qemuMonitorJSONHandleVNCInitialize, },
- { "VNC_DISCONNECTED", qemuMonitorJSONHandleVNCDisconnect, },
+ { "SHUTDOWN", qemuMonitorJSONHandleShutdown, },
{ "SPICE_CONNECTED", qemuMonitorJSONHandleSPICEConnect, },
- { "SPICE_INITIALIZED", qemuMonitorJSONHandleSPICEInitialize, },
{ "SPICE_DISCONNECTED", qemuMonitorJSONHandleSPICEDisconnect, },
- { "DEVICE_TRAY_MOVED", qemuMonitorJSONHandleTrayChange, },
- { "WAKEUP", qemuMonitorJSONHandlePMWakeup, },
+ { "SPICE_INITIALIZED", qemuMonitorJSONHandleSPICEInitialize, },
+ { "STOP", qemuMonitorJSONHandleStop, },
{ "SUSPEND", qemuMonitorJSONHandlePMSuspend, },
- { "BLOCK_JOB_COMPLETED", qemuMonitorJSONHandleBlockJobCompleted, },
- { "BLOCK_JOB_CANCELLED", qemuMonitorJSONHandleBlockJobCanceled, },
+ { "VNC_CONNECTED", qemuMonitorJSONHandleVNCConnect, },
+ { "VNC_DISCONNECTED", qemuMonitorJSONHandleVNCDisconnect, },
+ { "VNC_INITIALIZED", qemuMonitorJSONHandleVNCInitialize, },
+ { "WAKEUP", qemuMonitorJSONHandlePMWakeup, },
+ { "WATCHDOG", qemuMonitorJSONHandleWatchdog, },
+ /* We use bsearch, so keep this list sorted. */
};
+static int
+eventSearch(const void *key, const void *elt) {
+ const char *type = key;
+ const qemuEventHandler *handler = elt;
+ return strcmp(type, handler->type);
+}
static int
qemuMonitorJSONIOProcessEvent(qemuMonitorPtr mon,
virJSONValuePtr obj)
{
const char *type;
- int i;
+ qemuEventHandler *handler;
VIR_DEBUG("mon=%p obj=%p", mon, obj);
type = virJSONValueObjectGetString(obj, "event");
@@ -107,14 +115,13 @@ qemuMonitorJSONIOProcessEvent(qemuMonitorPtr mon,
return -1;
}
- for (i = 0 ; i < ARRAY_CARDINALITY(eventHandlers) ; i++) {
- if (STREQ(eventHandlers[i].type, type)) {
- virJSONValuePtr data = virJSONValueObjectGet(obj, "data");
- VIR_DEBUG("handle %s handler=%p data=%p", type,
- eventHandlers[i].handler, data);
- (eventHandlers[i].handler)(mon, data);
- break;
- }
+ handler = bsearch(type, eventHandlers, ARRAY_CARDINALITY(eventHandlers),
+ sizeof(eventHandlers[0]), eventSearch);
+ if (handler) {
+ virJSONValuePtr data = virJSONValueObjectGet(obj, "data");
+ VIR_DEBUG("handle %s handler=%p data=%p", type,
+ handler->handler, data);
+ (handler->handler)(mon, data);
}
return 0;
}
--
1.7.7.6
12 years, 7 months
[libvirt] [libvirt-glib] libvirt-gconfig: Move symbols introduced post 0.0.4 to the correct versions
by Guido Günther
Triggered by http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=667683
---
If this looks correct I'll have a look at libvirt-glib and
libvirt-gobject too.
-- Guido
libvirt-gconfig/libvirt-gconfig.sym | 50 +++++++++++++++++++++++------------
1 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index 717c3c9..405ad98 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -14,10 +14,6 @@ LIBVIRT_GCONFIG_0.0.4 {
gvir_config_domain_new;
gvir_config_domain_new_from_xml;
gvir_config_domain_set_clock;
- gvir_config_domain_set_custom_xml;
- gvir_config_domain_get_custom_xml;
- gvir_config_domain_get_description;
- gvir_config_domain_set_description;
gvir_config_domain_get_devices;
gvir_config_domain_set_devices;
gvir_config_domain_get_features;
@@ -51,10 +47,6 @@ LIBVIRT_GCONFIG_0.0.4 {
gvir_config_domain_chardev_source_pty_new_from_xml;
gvir_config_domain_source_pty_set_path;
- gvir_config_domain_chardev_source_spicevmc_get_type;
- gvir_config_domain_chardev_source_spicevmc_new;
- gvir_config_domain_chardev_source_spicevmc_new_from_xml;
-
gvir_config_domain_clock_get_type;
gvir_config_domain_clock_offset_get_type;
gvir_config_domain_clock_new;
@@ -79,8 +71,6 @@ LIBVIRT_GCONFIG_0.0.4 {
gvir_config_domain_disk_type_get_type;
gvir_config_domain_disk_new;
gvir_config_domain_disk_new_from_xml;
- gvir_config_domain_disk_get_driver_cache;
- gvir_config_domain_disk_set_driver_cache;
gvir_config_domain_disk_get_driver_name;
gvir_config_domain_disk_set_driver_name;
gvir_config_domain_disk_get_driver_type;
@@ -96,7 +86,6 @@ LIBVIRT_GCONFIG_0.0.4 {
gvir_config_domain_disk_get_target_dev;
gvir_config_domain_disk_set_target_dev;
gvir_config_domain_disk_get_disk_type;
- gvir_config_domain_disk_set_readonly;
gvir_config_domain_disk_set_type;
gvir_config_domain_filesys_get_type;
@@ -146,13 +135,9 @@ LIBVIRT_GCONFIG_0.0.4 {
gvir_config_domain_interface_get_type;
gvir_config_domain_interface_link_state_get_type;
gvir_config_domain_interface_set_ifname;
- gvir_config_domain_interface_get_ifname;
gvir_config_domain_interface_set_link_state;
- gvir_config_domain_interface_get_link_state;
gvir_config_domain_interface_set_mac;
- gvir_config_domain_interface_get_mac;
gvir_config_domain_interface_set_model;
- gvir_config_domain_interface_get_model;
gvir_config_domain_interface_bridge_get_type;
gvir_config_domain_interface_bridge_new;
@@ -327,8 +312,39 @@ LIBVIRT_GCONFIG_0.0.4 {
gvir_config_xml_doc_get_type;
gvir_config_xml_doc_new;
- local:
- *;
};
+LIBVIRT_GCONFIG_0.0.5 {
+ global:
+ gvir_config_domain_disk_get_driver_cache;
+ gvir_config_domain_disk_set_driver_cache;
+
+ gvir_config_domain_disk_set_readonly;
+
+ gvir_config_domain_set_custom_xml;
+ gvir_config_domain_get_custom_xml;
+ gvir_config_domain_get_description;
+ gvir_config_domain_set_description;
+} LIBVIRT_GCONFIG_0.0.4;
+
+LIBVIRT_GCONFIG_0.0.6 {
+ global:
+ gvir_config_domain_interface_get_ifname;
+ gvir_config_domain_interface_get_link_state;
+ gvir_config_domain_interface_get_mac;
+ gvir_config_domain_interface_get_model;
+} LIBVIRT_GCONFIG_0.0.5;
+
+LIBVIRT_GCONFIG_0.0.7 {
+ global:
+ gvir_config_domain_chardev_source_spicevmc_get_type;
+ gvir_config_domain_chardev_source_spicevmc_new;
+ gvir_config_domain_chardev_source_spicevmc_new_from_xml;
+} LIBVIRT_GCONFIG_0.0.6;
+
# .... define new API here using predicted next version number ....
+
+LIBVIRT_GCONFIG_PRIVATE_0.0.7 {
+ local:
+ *;
+};
--
1.7.9.1
12 years, 7 months
[libvirt] USB redirection support
by Christophe Fergeau
Hey,
This patch series adds the needed classes for apps to be able to
use USB redirection. I've followed
http://hansdegoede.livejournal.com/11084.html and added all the API needed
to be able to get the same XML. However, I'm not 100% sure all these
attributes are required, in particular the various addresses. Given
that for now libvirt-gconfig users tend to reuse what test-domain-create
does, it would be useful to know which parts are required and which are not
to get working USB redirection.
Thanks,
Christophe
12 years, 7 months
[libvirt] [PATCH] qemu: Fix deadlock when qemuDomainOpenConsole cleans up a connection
by Peter Krempa
The new safe console handling introduced a possibility to deadlock the
qemu driver when a new console connection forcibly disconnects a
previous console stream that belongs to an already closed connection.
The virStreamFree function calls subsequently a the virReleaseConnect
function that tries to lock the driver while discarding the connection,
but the driver was already locked in qemuDomainOpenConsole.
Backtrace of the deadlocked thread:
0 0x00007f66e5aa7f14 in __lll_lock_wait () from /lib64/libpthread.so.0
1 0x00007f66e5aa3411 in _L_lock_500 () from /lib64/libpthread.so.0
2 0x00007f66e5aa322a in pthread_mutex_lock () from/lib64/libpthread.so.0
3 0x0000000000462bbd in qemudClose ()
4 0x00007f66e6e178eb in virReleaseConnect () from/usr/lib64/libvirt.so.0
5 0x00007f66e6e19c8c in virUnrefStream () from /usr/lib64/libvirt.so.0
6 0x00007f66e6e3d1de in virStreamFree () from /usr/lib64/libvirt.so.0
7 0x00007f66e6e09a5d in virConsoleHashEntryFree () from/usr/lib64/libvirt.so.0
8 0x00007f66e6db7282 in virHashRemoveEntry () from/usr/lib64/libvirt.so.0
9 0x00007f66e6e09c4e in virConsoleOpen () from /usr/lib64/libvirt.so.0
10 0x00000000004526e9 in qemuDomainOpenConsole ()
11 0x00007f66e6e421f1 in virDomainOpenConsole () from/usr/lib64/libvirt.so.0
12 0x00000000004361e4 in remoteDispatchDomainOpenConsoleHelper ()
13 0x00007f66e6e80375 in virNetServerProgramDispatch () from/usr/lib64/libvirt.so.0
14 0x00007f66e6e7ae11 in virNetServerHandleJob () from/usr/lib64/libvirt.so.0
15 0x00007f66e6da897d in virThreadPoolWorker () from/usr/lib64/libvirt.so.0
16 0x00007f66e6da7ff6 in virThreadHelper () from/usr/lib64/libvirt.so.0
17 0x00007f66e5aa0c5c in start_thread () from /lib64/libpthread.so.0
18 0x00007f66e57e7fcd in clone () from /lib64/libc.so.6
* src/qemu/qemu_driver.c: qemuDomainOpenConsole()
-- unlock the qemu driver right after acquiring the domain
object
---
Found while writing tests for the libvirt-test-API, its 100% reproducible:
1: Start a domain with serial console and run "cat" on this console
2: download python reproducer: http://files.pipo.sk/console_deadlock.py
3: set guest name in the script
4: run the reproducer and "virsh console 'guestname' --force" after that
5: <deadlocked>
src/qemu/qemu_driver.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d9e35be..e18e72d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11494,6 +11494,7 @@ qemuDomainOpenConsole(virDomainPtr dom,
qemuDriverLock(driver);
virUUIDFormat(dom->uuid, uuidstr);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
+ qemuDriverUnlock(driver);
if (!vm) {
qemuReportError(VIR_ERR_NO_DOMAIN,
_("no domain with matching uuid '%s'"), uuidstr);
@@ -11558,7 +11559,6 @@ qemuDomainOpenConsole(virDomainPtr dom,
cleanup:
if (vm)
virDomainObjUnlock(vm);
- qemuDriverUnlock(driver);
return ret;
}
--
1.7.3.4
12 years, 7 months