[libvirt] [PATCH libvirt-glib] Avoid triggering deprecation warnings on newest GLib
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
---
libvirt-glib/libvirt-glib-event.c | 4 ++++
libvirt-glib/libvirt-glib-main.c | 4 ++++
libvirt-gobject/libvirt-gobject-compat.h | 5 +++++
libvirt-gobject/libvirt-gobject-manager.c | 1 +
4 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/libvirt-glib/libvirt-glib-event.c b/libvirt-glib/libvirt-glib-event.c
index c1761e8..6d54b10 100644
--- a/libvirt-glib/libvirt-glib-event.c
+++ b/libvirt-glib/libvirt-glib-event.c
@@ -31,6 +31,10 @@
#include "libvirt-glib/libvirt-glib.h"
+#if GLIB_CHECK_VERSION(2, 31, 0)
+#define g_mutex_new() g_new0(GMutex, 1)
+#endif
+
struct gvir_event_handle
{
int watch;
diff --git a/libvirt-glib/libvirt-glib-main.c b/libvirt-glib/libvirt-glib-main.c
index 8f50cc8..0cb2dd5 100644
--- a/libvirt-glib/libvirt-glib-main.c
+++ b/libvirt-glib/libvirt-glib-main.c
@@ -63,8 +63,12 @@ gboolean gvir_init_check(int *argc G_GNUC_UNUSED,
GError **err G_GNUC_UNUSED)
{
virSetErrorFunc(NULL, gvir_error_func);
+
+ /* Threading is always enabled from 2.31.0 onwards */
+#if !GLIB_CHECK_VERSION(2, 31, 0)
if (!g_thread_supported())
g_thread_init(NULL);
+#endif
virInitialize();
diff --git a/libvirt-gobject/libvirt-gobject-compat.h b/libvirt-gobject/libvirt-gobject-compat.h
index 0c37537..839dfe1 100644
--- a/libvirt-gobject/libvirt-gobject-compat.h
+++ b/libvirt-gobject/libvirt-gobject-compat.h
@@ -26,6 +26,11 @@
#include <glib-object.h>
#include <gio/gio.h>
+#if GLIB_CHECK_VERSION(2, 31, 0)
+#define g_mutex_new() g_new0(GMutex, 1)
+#define g_mutex_free(m) g_free(m)
+#endif
+
#if !GLIB_CHECK_VERSION(2,26,0)
#define G_DEFINE_BOXED_TYPE(TypeName, type_name, copy_func, free_func) G_DEFINE_BOXED_TYPE_WITH_CODE (TypeName, type_name, copy_func, free_func, {})
#define G_DEFINE_BOXED_TYPE_WITH_CODE(TypeName, type_name, copy_func, free_func, _C_) _G_DEFINE_BOXED_TYPE_BEGIN (TypeName, type_name, copy_func, free_func) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
diff --git a/libvirt-gobject/libvirt-gobject-manager.c b/libvirt-gobject/libvirt-gobject-manager.c
index aef519f..da5d31d 100644
--- a/libvirt-gobject/libvirt-gobject-manager.c
+++ b/libvirt-gobject/libvirt-gobject-manager.c
@@ -28,6 +28,7 @@
#include "libvirt-glib/libvirt-glib.h"
#include "libvirt-gobject/libvirt-gobject.h"
+#include "libvirt-gobject/libvirt-gobject-compat.h"
#define GVIR_MANAGER_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_MANAGER, GVirManagerPrivate))
--
1.7.7.6
12 years, 9 months
[libvirt] [PATCH 0/2 v3] Implement DomainPMSuspendForDuration for qemu
by Michal Privoznik
This is basically v3 for:
https://www.redhat.com/archives/libvir-list/2012-February/msg00533.html
This time, I've split it into 2 patches so it can be reviewed easier.
Michal Privoznik (2):
qemu: Set capabilities based on supported monitor commands
qemu: Implement DomainPMSuspendForDuration
src/qemu/qemu_agent.c | 31 +++++++++++++++
src/qemu/qemu_agent.h | 2 +
src/qemu/qemu_capabilities.c | 1 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_driver.c | 87 ++++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor.c | 21 +++++-----
src/qemu/qemu_monitor.h | 4 +-
src/qemu/qemu_monitor_json.c | 15 ++++---
src/qemu/qemu_monitor_json.h | 5 ++-
src/qemu/qemu_process.c | 2 +-
10 files changed, 149 insertions(+), 20 deletions(-)
--
1.7.3.4
12 years, 9 months
[libvirt] libvirtError: internal error cannot create rule since ebtables tool is missing.
by Phantomcircuit
# libvirtd --version
libvirtd (libvirt) 0.9.8
# which ebtables
/sbin/ebtables
2012-02-15 09:40:59.083+0000: 17675: error :
ebtablesCreateRuleInstance:1943 : internal error cannot create rule
since ebtables tool is missing.
2012-02-15 09:40:59.107+0000: 17675: error : virNetDevGetIndex:656 :
Unable to get index for interface vnet0: No such device
ebtables_cmd_path = virFindFileInPath("ebtables");
I can't figure out why ebtables_cmd_path is NULL when
12 years, 9 months
[libvirt] Fail to import available VM image
by Jun Koi
hi,
i am trying to import an available KVM image to use with libvirt.
i am not sure if this is the problem of libvirt or not, so bear in me
if that is not the case.
i run the following command, and got error:
# virt-install -n winxp -r 800 -f img.winxp --accelerate --vnc
--noautoconsole -v --import
ERROR [Errno 10] No child processes
all the softwares are of latest version (libvirt 0.9.10 and virtinst-0.60.1)
where am i wrong?
many thanks,
Jun
12 years, 9 months
[libvirt] [PATCH] storage: Allow runtime detection of scrub
by Michal Privoznik
Currently, if scrub (used for wiping algorithms) is not present
at compile time, we don't support any other wiping algorithms than
zeroing, even if it was installed later. Switch to runtime detection
instead.
---
configure.ac | 30 ++++--------------------------
src/storage/storage_driver.c | 4 ----
2 files changed, 4 insertions(+), 30 deletions(-)
diff --git a/configure.ac b/configure.ac
index 67351d9..5320f71 100644
--- a/configure.ac
+++ b/configure.ac
@@ -213,6 +213,8 @@ AC_PATH_PROG([UDEVSETTLE], [udevsettle], [],
[/sbin:/usr/sbin:/usr/local/sbin:$PATH])
AC_PATH_PROG([MODPROBE], [modprobe], [],
[/sbin:/usr/sbin:/usr/local/sbin:$PATH])
+AC_PATH_PROG([SCRUB], [scrub], [],
+ [/sbin:/usr/sbin:/usr/local/sbin:$PATH])
AC_DEFINE_UNQUOTED([DNSMASQ],["$DNSMASQ"],
[Location or name of the dnsmasq program])
@@ -232,6 +234,8 @@ if test -n "$MODPROBE"; then
AC_DEFINE_UNQUOTED([MODPROBE],["$MODPROBE"],
[Location or name of the modprobe program])
fi
+AC_DEFINE_UNQUOTED([SCRUB],["$SCRUB"],
+ [Location or name of the scrub program (for wiping algorithms)])
dnl Specific dir for HTML output ?
AC_ARG_WITH([html-dir], [AC_HELP_STRING([--with-html-dir=path],
@@ -2500,32 +2504,6 @@ AM_CONDITIONAL([HAVE_LIBNL], [test "$have_libnl" = "yes"])
AC_SUBST([LIBNL_CFLAGS])
AC_SUBST([LIBNL_LIBS])
-dnl scrub program for different volume wiping algorithms
-
-AC_ARG_WITH([scrub],
- AC_HELP_STRING([--with-scrub], [enable different volume wiping algorithms
- @<:@default=check@:>@]),
- [with_macvtap=${withval}],
- [with_scrub=check])
-
-if test "$with_scrub" != "no"; then
- AC_PATH_PROG([SCRUB], [scrub])
- if test -z "$SCRUB" ; then
- if test "$with_scrub" = "check"; then
- with_scrub=no
- else
- AC_MSG_ERROR([You must install the 'scrub' binary to enable
- different volume wiping algorithms])
- fi
- else
- with_scrub=yes
- fi
- if test "$with_scrub" = "yes"; then
- AC_DEFINE_UNQUOTED([SCRUB], ["$SCRUB"],
- [Location of the scrub program])
- fi
-fi
-
# Only COPYING.LIB is under version control, yet COPYING
# is included as part of the distribution tarball.
# Copy one to the other, but only if this is a srcdir-build.
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 9170a17..df0e291 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -1918,7 +1918,6 @@ storageVolumeWipeInternal(virStorageVolDefPtr def,
if (algorithm != VIR_STORAGE_VOL_WIPE_ALG_ZERO) {
const char *alg_char ATTRIBUTE_UNUSED = NULL;
switch (algorithm) {
-#ifdef SCRUB
case VIR_STORAGE_VOL_WIPE_ALG_NNSA:
alg_char = "nnsa";
break;
@@ -1943,13 +1942,11 @@ storageVolumeWipeInternal(virStorageVolDefPtr def,
case VIR_STORAGE_VOL_WIPE_ALG_RANDOM:
alg_char = "random";
break;
-#endif
default:
virStorageReportError(VIR_ERR_INVALID_ARG,
_("unsupported algorithm %d"),
algorithm);
}
-#ifdef SCRUB
cmd = virCommandNew(SCRUB);
virCommandAddArgList(cmd, "-f", "-p", alg_char,
def->target.path, NULL);
@@ -1958,7 +1955,6 @@ storageVolumeWipeInternal(virStorageVolDefPtr def,
goto out;
ret = 0;
-#endif
goto out;
} else {
if (S_ISREG(st.st_mode) && st.st_blocks < (st.st_size / DEV_BSIZE)) {
--
1.7.3.4
12 years, 9 months
[libvirt] [PATCHv3 0/3] Xen: Fix <clock> handling
by Philipp Hahn
Before version 3.1 xen only implemented clock/@offset='utc' and 'localtime'.
With the introduction of managed domains in 3.1 xend keeps track of the
rtc_timeoffset, even over reboots. This translates to libvirts
clock/@offset='variable' variant. Be advised that only HV domains have a RTC.
In addition xen also supports a variant where the offset is tracked to
'localtime', which is currently not supported by libvirt. To make matters
worse, this was somehow broken in some versions of xen and was finally fixed
with version xen-3.4.
The following patch set ...
* adds support for handling variable offsets relative to localtime,
* fixes libvirt to use clock/@offset='variable' for newer xen versions,
* adapts the test suit accordingly
I've tested this on CenOS5 (xend-3.0.3 + 3.1.2 hypervisor?), UCS-2.3
(xen-3.2.1), UCS-2.4 (xen-3.4.3) and UCS-3.0 (xen-4.1.2).
Since v1:
+ fix handling of direct-PV-domains
+ added handling of localtime=1 + rtc_timeoffset
+ fixed test suite
Since v2: (on feedback by Eric)
+ add the adjustment='reset' attribute to force the old behaviour
+ handle adjustment='$timeDelta' as a short-cut for the conversion to variable.
+ simplify error path handling
+ update version numbers to 0.9.11
Philipp Hahn (3):
Support clock=variable relative to localtime
Xen: Fix <clock> handling
Xen: Adapt <clock> tests
docs/formatdomain.html.in | 18 ++-
docs/schemas/domaincommon.rng | 30 +++-
src/conf/domain_conf.c | 60 +++++++-
src/conf/domain_conf.h | 17 ++-
src/libvirt_private.syms | 1 +
src/qemu/qemu_command.c | 8 +-
src/qemu/qemu_process.c | 2 +-
src/xenxs/xen_sxpr.c | 167 +++++++++++++++-----
src/xenxs/xen_xm.c | 123 ++++++++++++---
.../qemuxml2argv-clock-variable.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-boot-grub.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-bridge-ipaddr.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-curmem.xml | 2 +-
.../sexpr2xml-disk-block-shareable.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-disk-block.xml | 2 +-
.../sexpr2xml-disk-drv-blktap-qcow.xml | 2 +-
.../sexpr2xml-disk-drv-blktap-raw.xml | 2 +-
.../sexpr2xml-disk-drv-blktap2-raw.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-disk-file.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-empty-kernel.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-force-hpet.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-force-nohpet.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-kernel.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-legacy-vfb.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-localtime.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.xml | 2 +-
.../sexpr2xml-fv-serial-dev-2-ports.xml | 2 +-
.../sexpr2xml-fv-serial-dev-2nd-port.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml | 2 +-
.../sexpr2xml-fv-serial-tcp-telnet.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-sound-all.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-sound.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-usbmouse.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-usbtablet.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-utc.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-v2.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-net-bridged.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-net-e1000.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-net-routed.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-pci-devs.xml | 2 +-
.../sexpr2xml-pv-bootloader-cmdline.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-pv-bootloader.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-pv-vcpus.xml | 2 +-
.../sexpr2xml-pv-vfb-new-vncdisplay.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml | 2 +-
.../sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-pv.xml | 2 +-
tests/xmconfigdata/sexpr2xml-pv-bootloader.cfg | 1 +
tests/xmconfigdata/test-escape-paths.xml | 2 +-
tests/xmconfigdata/test-fullvirt-force-hpet.cfg | 2 +-
tests/xmconfigdata/test-fullvirt-force-hpet.xml | 2 +-
tests/xmconfigdata/test-fullvirt-force-nohpet.cfg | 2 +-
tests/xmconfigdata/test-fullvirt-force-nohpet.xml | 2 +-
tests/xmconfigdata/test-fullvirt-localtime.xml | 2 +-
tests/xmconfigdata/test-fullvirt-net-ioemu.xml | 2 +-
tests/xmconfigdata/test-fullvirt-net-netfront.xml | 2 +-
tests/xmconfigdata/test-fullvirt-new-cdrom.xml | 2 +-
tests/xmconfigdata/test-fullvirt-old-cdrom.cfg | 2 +-
tests/xmconfigdata/test-fullvirt-old-cdrom.xml | 2 +-
tests/xmconfigdata/test-fullvirt-parallel-tcp.xml | 2 +-
.../test-fullvirt-serial-dev-2-ports.xml | 2 +-
.../test-fullvirt-serial-dev-2nd-port.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-file.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-null.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-pipe.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-pty.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-stdio.xml | 2 +-
.../test-fullvirt-serial-tcp-telnet.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-tcp.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-udp.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-unix.xml | 2 +-
tests/xmconfigdata/test-fullvirt-sound.xml | 2 +-
tests/xmconfigdata/test-fullvirt-usbmouse.xml | 2 +-
.../test-fullvirt-usbtablet-no-bus.xml | 2 +-
tests/xmconfigdata/test-fullvirt-usbtablet.xml | 2 +-
tests/xmconfigdata/test-fullvirt-utc.xml | 2 +-
tests/xmconfigdata/test-no-source-cdrom.xml | 2 +-
tests/xmconfigdata/test-paravirt-net-e1000.cfg | 1 +
tests/xmconfigdata/test-paravirt-net-e1000.xml | 2 +-
tests/xmconfigdata/test-paravirt-net-vifname.cfg | 1 +
tests/xmconfigdata/test-paravirt-net-vifname.xml | 2 +-
.../test-paravirt-new-pvfb-vncdisplay.cfg | 1 +
.../test-paravirt-new-pvfb-vncdisplay.xml | 2 +-
tests/xmconfigdata/test-paravirt-new-pvfb.cfg | 1 +
tests/xmconfigdata/test-paravirt-new-pvfb.xml | 2 +-
.../test-paravirt-old-pvfb-vncdisplay.cfg | 1 +
.../test-paravirt-old-pvfb-vncdisplay.xml | 2 +-
tests/xmconfigdata/test-paravirt-old-pvfb.cfg | 1 +
tests/xmconfigdata/test-paravirt-old-pvfb.xml | 2 +-
tests/xmconfigdata/test-paravirt-vcpu.cfg | 1 +
tests/xmconfigdata/test-paravirt-vcpu.xml | 2 +-
tests/xmconfigdata/test-pci-devs.xml | 2 +-
tests/xml2sexprdata/xml2sexpr-boot-grub.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-bridge-ipaddr.sexpr | 4 +-
tests/xml2sexprdata/xml2sexpr-curmem.sexpr | 1 +
.../xml2sexpr-disk-block-shareable.sexpr | 4 +-
tests/xml2sexprdata/xml2sexpr-disk-block.sexpr | 4 +-
.../xml2sexprdata/xml2sexpr-disk-drv-blkback.sexpr | 4 +-
.../xml2sexpr-disk-drv-blktap-qcow.sexpr | 4 +-
.../xml2sexpr-disk-drv-blktap-raw.sexpr | 4 +-
.../xml2sexprdata/xml2sexpr-disk-drv-blktap.sexpr | 4 +-
.../xml2sexpr-disk-drv-blktap2-raw.sexpr | 4 +-
.../xml2sexprdata/xml2sexpr-disk-drv-blktap2.sexpr | 4 +-
tests/xml2sexprdata/xml2sexpr-disk-drv-loop.sexpr | 4 +-
tests/xml2sexprdata/xml2sexpr-disk-file.sexpr | 4 +-
tests/xml2sexprdata/xml2sexpr-escape.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-force-hpet.sexpr | 1 +
.../xml2sexprdata/xml2sexpr-fv-force-nohpet.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-kernel.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr | 5 +-
tests/xml2sexprdata/xml2sexpr-fv-net-ioemu.sexpr | 3 +-
.../xml2sexprdata/xml2sexpr-fv-net-netfront.sexpr | 3 +-
.../xml2sexprdata/xml2sexpr-fv-parallel-tcp.sexpr | 1 +
.../xml2sexpr-fv-serial-dev-2-ports.sexpr | 3 +-
.../xml2sexpr-fv-serial-dev-2nd-port.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-serial-file.sexpr | 3 +-
tests/xml2sexprdata/xml2sexpr-fv-serial-null.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-serial-pipe.sexpr | 3 +-
tests/xml2sexprdata/xml2sexpr-fv-serial-pty.sexpr | 1 +
.../xml2sexprdata/xml2sexpr-fv-serial-stdio.sexpr | 1 +
.../xml2sexpr-fv-serial-tcp-telnet.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-serial-tcp.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-serial-udp.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-serial-unix.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-sound.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-usbmouse.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-usbtablet.sexpr | 3 +-
tests/xml2sexprdata/xml2sexpr-fv-utc.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-v2.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-vncunused.sexpr | 3 +-
tests/xml2sexprdata/xml2sexpr-fv.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-net-bridged.sexpr | 2 +-
tests/xml2sexprdata/xml2sexpr-net-e1000.sexpr | 2 +-
tests/xml2sexprdata/xml2sexpr-net-routed.sexpr | 2 +-
.../xml2sexprdata/xml2sexpr-no-source-cdrom.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-pci-devs.sexpr | 2 +-
.../xml2sexpr-pv-bootloader-cmdline.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-pv-bootloader.sexpr | 4 +-
tests/xml2sexprdata/xml2sexpr-pv-vcpus.sexpr | 2 +-
.../xml2sexprdata/xml2sexpr-pv-vfb-new-auto.sexpr | 2 +-
tests/xml2sexprdata/xml2sexpr-pv-vfb-new.sexpr | 2 +-
tests/xml2sexprdata/xml2sexpr-pv-vfb-orig.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-pv.sexpr | 2 +-
157 files changed, 525 insertions(+), 200 deletions(-)
12 years, 9 months
[libvirt] [PATCHv2 0/3] Xen: Fix <clock> handling
by Philipp Hahn
Before version 3.1 xen only implemented clock/@offset='utc' and 'localtime'.
With the introduction of managed domains in 3.1 xend keeps track of the
rtc_timeoffset, even over reboots. This translates to libvirts
clock/@offset='variable' variant. Be advised that only HV domains have a RTC.
In addition xen also supports a variant where the offset is tracked to
'localtime', which is currently not supported by libvirt. To make matters
worse, this was somehow broken in some versions of xen and was finally fixed
with version xen-3.4.
The following patch set ...
* adds support for handling variable offsets relative to localtime,
* fixes libvirt to use clock/@offset='variable' for newer xen versions,
* adapts the test suit accordingly
I've tested this on CenOS5 (xend-3.0.3 + 3.1.2 hypervisor?), UCS-2.3
(xen-3.2.1), UCS-2.4 (xen-3.4.3) and UCS-3.0 (xen-4.1.2).
Since v1:
+ fix handling of direct-PV-domains
+ added handling of localtime=1 + rtc_timeoffset
+ fixed test suite
Questions:
1. Handling of legacy XML domain configurations
I'm reluctant to define LIBVIRT_XEND_CLOCK_STRICT, since this would probably
break many existing XML configuration files, since they would be rejected
libvirt now for still using clock/@offset='utc'/'localtime'. Luckily for us
libvirt doesn't support snapshots with xen, because then this XML
configuration would be stored in the snapshot meta data, rendering them all
invalid.
2. Error path handling
There are now a lot of different cases (PV, HV<3.1, HV>3.1), which all have
the same error path. This is somehow ugly to code in C, I hope it's okay to
use vmlocaltime=-1 to indicate an error instead of using "goto". But if you
have a better idea, please feel free to comments.
3. libvirt-0.9.10 or .11
This patch-series should probably receive some more testing, so for 0.9.10
it's too late. If it's not included, I'd need to update the reference to the
version when this patch will get in.
Philipp Hahn (3):
Support clock=variable relative to localtime
Xen: Fix <clock> handling
Xen: Adapt <clock> tests
docs/formatdomain.html.in | 7 +-
docs/schemas/domaincommon.rng | 8 +
src/conf/domain_conf.c | 24 +++-
src/conf/domain_conf.h | 15 ++-
src/libvirt_private.syms | 1 +
src/qemu/qemu_command.c | 8 +-
src/qemu/qemu_process.c | 2 +-
src/xenxs/xen_sxpr.c | 161 +++++++++++++++-----
src/xenxs/xen_xm.c | 116 +++++++++++---
.../qemuxml2argv-clock-variable.xml | 2 +-
tests/xmconfigdata/sexpr2xml-pv-bootloader.cfg | 1 +
tests/xmconfigdata/test-fullvirt-force-hpet.cfg | 2 +-
tests/xmconfigdata/test-fullvirt-force-nohpet.cfg | 2 +-
tests/xmconfigdata/test-fullvirt-old-cdrom.cfg | 2 +-
tests/xmconfigdata/test-paravirt-net-e1000.cfg | 1 +
tests/xmconfigdata/test-paravirt-net-vifname.cfg | 1 +
.../test-paravirt-new-pvfb-vncdisplay.cfg | 1 +
tests/xmconfigdata/test-paravirt-new-pvfb.cfg | 1 +
.../test-paravirt-old-pvfb-vncdisplay.cfg | 1 +
tests/xmconfigdata/test-paravirt-old-pvfb.cfg | 1 +
tests/xmconfigdata/test-paravirt-vcpu.cfg | 1 +
tests/xml2sexprdata/xml2sexpr-boot-grub.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-bridge-ipaddr.sexpr | 4 +-
tests/xml2sexprdata/xml2sexpr-curmem.sexpr | 1 +
.../xml2sexpr-disk-block-shareable.sexpr | 4 +-
tests/xml2sexprdata/xml2sexpr-disk-block.sexpr | 4 +-
.../xml2sexprdata/xml2sexpr-disk-drv-blkback.sexpr | 4 +-
.../xml2sexpr-disk-drv-blktap-qcow.sexpr | 4 +-
.../xml2sexpr-disk-drv-blktap-raw.sexpr | 4 +-
.../xml2sexprdata/xml2sexpr-disk-drv-blktap.sexpr | 4 +-
.../xml2sexpr-disk-drv-blktap2-raw.sexpr | 4 +-
.../xml2sexprdata/xml2sexpr-disk-drv-blktap2.sexpr | 4 +-
tests/xml2sexprdata/xml2sexpr-disk-drv-loop.sexpr | 4 +-
tests/xml2sexprdata/xml2sexpr-disk-file.sexpr | 4 +-
tests/xml2sexprdata/xml2sexpr-escape.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-force-hpet.sexpr | 1 +
.../xml2sexprdata/xml2sexpr-fv-force-nohpet.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-kernel.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr | 5 +-
tests/xml2sexprdata/xml2sexpr-fv-net-ioemu.sexpr | 3 +-
.../xml2sexprdata/xml2sexpr-fv-net-netfront.sexpr | 3 +-
.../xml2sexprdata/xml2sexpr-fv-parallel-tcp.sexpr | 1 +
.../xml2sexpr-fv-serial-dev-2-ports.sexpr | 3 +-
.../xml2sexpr-fv-serial-dev-2nd-port.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-serial-file.sexpr | 3 +-
tests/xml2sexprdata/xml2sexpr-fv-serial-null.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-serial-pipe.sexpr | 3 +-
tests/xml2sexprdata/xml2sexpr-fv-serial-pty.sexpr | 1 +
.../xml2sexprdata/xml2sexpr-fv-serial-stdio.sexpr | 1 +
.../xml2sexpr-fv-serial-tcp-telnet.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-serial-tcp.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-serial-udp.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-serial-unix.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-sound.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-usbmouse.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-usbtablet.sexpr | 3 +-
tests/xml2sexprdata/xml2sexpr-fv-utc.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-v2.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-fv-vncunused.sexpr | 3 +-
tests/xml2sexprdata/xml2sexpr-fv.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-net-bridged.sexpr | 2 +-
tests/xml2sexprdata/xml2sexpr-net-e1000.sexpr | 2 +-
tests/xml2sexprdata/xml2sexpr-net-routed.sexpr | 2 +-
.../xml2sexprdata/xml2sexpr-no-source-cdrom.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-pci-devs.sexpr | 2 +-
.../xml2sexpr-pv-bootloader-cmdline.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-pv-bootloader.sexpr | 4 +-
tests/xml2sexprdata/xml2sexpr-pv-vcpus.sexpr | 2 +-
.../xml2sexprdata/xml2sexpr-pv-vfb-new-auto.sexpr | 2 +-
tests/xml2sexprdata/xml2sexpr-pv-vfb-new.sexpr | 2 +-
tests/xml2sexprdata/xml2sexpr-pv-vfb-orig.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-pv.sexpr | 2 +-
72 files changed, 363 insertions(+), 108 deletions(-)
12 years, 9 months
[libvirt] virsh bash completion file
by Serge E. Hallyn
Hi,
I've been trying out a bash autocompletion file by Geoff Low (slight hack
by me, don't blame him for my hack), and it's working pretty nicely.
I'm not sure where to put it in the git tree, but it seems like it'd be
nice to have upstream?
thanks,
-serge
====================================================
#!/bin/bash
#############################################################################
#
# virsh bash completion
# Author: Geoff Low (glow(a)cmedresearch.com)
#
############################################################################
VIRSH=$(which virsh)
function get_main_option_list
{
# assume options are specified as [--option1 | --option2 | ...]
OPTIONS=$(${VIRSH} help | grep '|' | sed -e 's/.*\[\(.*\)\]/\1/g;s/|//g')
}
function get_option_list
{
# get the options for a choice
local option=$1;
# assume options are specified as [--option1 | --option2 | ...]
OPTIONS=$(${VIRSH} help ${option} 2> /dev/null | grep '|' | sed -e 's/.*\[\(.*\)\]/\1/g;s/|//g')
}
function _virsh_complete()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
cnxn=""
i=0
while [[ $i -lt $COMP_CWORD ]]; do
if [ ${COMP_WORDS[i]} = "-c" ]; then
tgt=`echo ${COMP_LINE} | sed -e 's/^.* -c \([^ \t]*\).*$/\1/'`
cnxn="-c $tgt"
break
fi
let i++
done
if [ ! -z $tgt ]; then
if [ $COMP_CWORD -eq 5 ]; then
prev="${COMP_WORDS[0]}"
fi
fi
_all_domains=$(${VIRSH} ${cnxn} --q list --all 2> /dev/null | grep -E "(running|shut off)$" | awk '{print $2,$3}')
all_domains=$(echo "$_all_domains" | cut -d " " -f 1)
all_networks=$(${VIRSH} --q net-list --all 2> /dev/null | grep 'active' | cut -d " " -f 1)
live_domains=$(echo "$_all_domains" | grep -E "running$" | awk '{print $1}')
shutoff_domains=$(echo "$_all_domains" | grep -E "shut$" | awk '{print $1}')
case "${prev}" in
virsh | --help)
get_main_option_list
ALL_OPTS=$(${VIRSH} -q help 2> /dev/null | sed '1,2d' | awk '{print $1}')
COMPREPLY=( $(compgen -W "$OPTIONS $ALL_OPTS" -- ${cur}) )
;;
list)
get_option_list ${prev}
COMPREPLY=( $(compgen -W "$OPTIONS" -- ${cur}) )
;;
autostart | dominfo | domuuid | domid | dominfo | domname | dumpxml | setmem )
get_option_list ${prev}
COMPREPLY=( $(compgen -W "$OPTIONS $all_domains" -- ${cur}) )
;;
start | undefine)
get_option_list ${prev}
COMPREPLY=( $(compgen -W "$OPTIONS $shutoff_domains" -- ${cur}) )
;;
create | define)
get_option_list ${prev}
xml_files=$(ls *.xml)
COMPREPLY=( $(compgen -W "$OPTIONS $xml_files" -- ${cur}) )
;;
shutdown | domstate | console | destroy | reboot | save | suspend | resume | vcpuinfo | vncdisplay)
get_option_list ${prev}
COMPREPLY=( $(compgen -W "$OPTIONS $live_domains" -- ${cur}) )
;;
connect)
get_option_list ${prev}
URI_TEMPLATES="xen:// qemu:// test:// xen+ssh:// test+tcp:// qemu+unix:// qemu+tls:// qemu+ssh://"
COMPREPLY=( $(compgen -W "$OPTIONS $URI_TEMPLATES" -- ${cur}) )
;;
*)
COMPREPLY=( $(compgen -f -- ${cur}) )
return 0
;;
esac
}
complete -F _virsh_complete virsh
12 years, 9 months
[libvirt] [PATCH v2] qemu: Implement DomainPMSuspendForDuration
by Michal Privoznik
via user agent.
---
diff to v1:
-allow mem and hybrid targets iff system_wakeup monitor command is presented
src/qemu/qemu_agent.c | 31 +++++++++++++++
src/qemu/qemu_agent.h | 2 +
src/qemu/qemu_capabilities.c | 1 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_driver.c | 87 ++++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor.c | 21 +++++-----
src/qemu/qemu_monitor.h | 4 +-
src/qemu/qemu_monitor_json.c | 15 ++++---
src/qemu/qemu_monitor_json.h | 5 ++-
src/qemu/qemu_process.c | 2 +-
10 files changed, 149 insertions(+), 20 deletions(-)
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 9df5546..a17d025 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -1184,3 +1184,34 @@ cleanup:
virJSONValueFree(reply);
return ret;
}
+
+VIR_ENUM_DECL(qemuAgentSuspendMode);
+
+VIR_ENUM_IMPL(qemuAgentSuspendMode,
+ VIR_NODE_SUSPEND_TARGET_LAST,
+ "guest-suspend-ram",
+ "guest-suspend-disk",
+ "guest-suspend-hybrid");
+
+int
+qemuAgentSuspend(qemuAgentPtr mon,
+ unsigned int target)
+{
+ int ret = -1;
+ virJSONValuePtr cmd;
+ virJSONValuePtr reply = NULL;
+
+ cmd = qemuAgentMakeCommand(qemuAgentSuspendModeTypeToString(target),
+ NULL);
+ if (!cmd)
+ return -1;
+
+ ret = qemuAgentCommand(mon, cmd, &reply);
+
+ if (ret == 0)
+ ret = qemuAgentCheckError(cmd, reply);
+
+ virJSONValueFree(cmd);
+ virJSONValueFree(reply);
+ return ret;
+}
diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h
index df59ef7..98c23b0 100644
--- a/src/qemu/qemu_agent.h
+++ b/src/qemu/qemu_agent.h
@@ -69,4 +69,6 @@ int qemuAgentShutdown(qemuAgentPtr mon,
int qemuAgentFSFreeze(qemuAgentPtr mon);
int qemuAgentFSThaw(qemuAgentPtr mon);
+int qemuAgentSuspend(qemuAgentPtr mon,
+ unsigned int target);
#endif /* __QEMU_AGENT_H__ */
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 426637c..6d35676 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -152,6 +152,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
"fsdev-writeout",
"drive-iotune", /* 85 */
+ "system_wakeup",
);
struct qemu_feature_flags {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 18d6bc8..b9666e1 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -120,6 +120,7 @@ enum qemuCapsFlags {
QEMU_CAPS_CPU_HOST = 83, /* support for -cpu host */
QEMU_CAPS_FSDEV_WRITEOUT = 84, /* -fsdev writeout supported */
QEMU_CAPS_DRIVE_IOTUNE = 85, /* -drive bps= and friends */
+ QEMU_CAPS_WAKEUP = 86, /* system_wakeup monitor command */
QEMU_CAPS_LAST, /* this must always be the last item */
};
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 160cb37..d342fae 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12041,6 +12041,92 @@ cleanup:
return ret;
}
+static int
+qemuDomainPMSuspendForDuration(virDomainPtr dom,
+ unsigned int target,
+ unsigned long long duration,
+ unsigned int flags)
+{
+ struct qemud_driver *driver = dom->conn->privateData;
+ qemuDomainObjPrivatePtr priv;
+ virDomainObjPtr vm;
+ int ret = -1;
+
+ virCheckFlags(0, -1);
+
+ if (duration) {
+ qemuReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("Duration not supported. Use 0 for now"));
+ return -1;
+ }
+
+ if (!(target == VIR_NODE_SUSPEND_TARGET_MEM ||
+ target == VIR_NODE_SUSPEND_TARGET_DISK ||
+ target == VIR_NODE_SUSPEND_TARGET_HYBRID)) {
+ qemuReportError(VIR_ERR_INVALID_ARG,
+ _("Unknown suspend target: %u"),
+ target);
+ return -1;
+ }
+
+ qemuDriverLock(driver);
+ vm = virDomainFindByUUID(&driver->domains, dom->uuid);
+ qemuDriverUnlock(driver);
+
+ if (!vm) {
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+ virUUIDFormat(dom->uuid, uuidstr);
+ qemuReportError(VIR_ERR_NO_DOMAIN,
+ _("no domain with matching uuid '%s'"), uuidstr);
+ goto cleanup;
+ }
+
+ priv = vm->privateData;
+
+ if (!qemuCapsGet(priv->qemuCaps, QEMU_CAPS_WAKEUP) &&
+ (target == VIR_NODE_SUSPEND_TARGET_MEM ||
+ target == VIR_NODE_SUSPEND_TARGET_HYBRID)) {
+ qemuReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("Unable to suspend domain due to "
+ "missing system_wakeup monitor command"));
+ goto cleanup;
+ }
+
+ if (priv->agentError) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("QEMU guest agent is not available due to an error"));
+ goto cleanup;
+ }
+
+ if (!priv->agent) {
+ qemuReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
+ _("QEMU guest agent is not configured"));
+ goto cleanup;
+ }
+
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
+ goto cleanup;
+
+ if (!virDomainObjIsActive(vm)) {
+ qemuReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto endjob;
+ }
+
+ qemuDomainObjEnterAgent(driver, vm);
+ ret = qemuAgentSuspend(priv->agent, target);
+ qemuDomainObjExitAgent(driver, vm);
+
+endjob:
+ if (qemuDomainObjEndJob(driver, vm) == 0)
+ vm = NULL;
+
+cleanup:
+ if (vm)
+ virDomainObjUnlock(vm);
+ return ret;
+}
+
static virDriver qemuDriver = {
.no = VIR_DRV_QEMU,
.name = "QEMU",
@@ -12198,6 +12284,7 @@ static virDriver qemuDriver = {
.domainGetDiskErrors = qemuDomainGetDiskErrors, /* 0.9.10 */
.domainSetMetadata = qemuDomainSetMetadata, /* 0.9.10 */
.domainGetMetadata = qemuDomainGetMetadata, /* 0.9.10 */
+ .domainPMSuspendForDuration = qemuDomainPMSuspendForDuration, /* 0.9.10 */
};
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 7872e3d..93f3505 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -996,9 +996,11 @@ int qemuMonitorEmitBlockJob(qemuMonitorPtr mon,
-int qemuMonitorSetCapabilities(qemuMonitorPtr mon)
+int qemuMonitorSetCapabilities(qemuMonitorPtr mon,
+ virBitmapPtr qemuCaps)
{
int ret;
+ int json_hmp;
VIR_DEBUG("mon=%p", mon);
if (!mon) {
@@ -1009,19 +1011,16 @@ int qemuMonitorSetCapabilities(qemuMonitorPtr mon)
if (mon->json) {
ret = qemuMonitorJSONSetCapabilities(mon);
- if (ret == 0) {
- int hmp = qemuMonitorJSONCheckHMP(mon);
- if (hmp < 0) {
- /* qemu may quited unexpectedly when we call
- * qemuMonitorJSONCheckHMP() */
- ret = -1;
- } else {
- mon->json_hmp = hmp > 0;
- }
- }
+ if (ret)
+ goto cleanup;
+
+ ret = qemuMonitorJSONCheckCommands(mon, qemuCaps, &json_hmp);
+ mon->json_hmp = json_hmp > 0;
} else {
ret = 0;
}
+
+cleanup:
return ret;
}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 5945d3e..7c6c52b 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -29,6 +29,7 @@
# include "domain_conf.h"
# include "qemu_conf.h"
+# include "bitmap.h"
# include "virhash.h"
typedef struct _qemuMonitor qemuMonitor;
@@ -135,7 +136,8 @@ qemuMonitorPtr qemuMonitorOpen(virDomainObjPtr vm,
void qemuMonitorClose(qemuMonitorPtr mon);
-int qemuMonitorSetCapabilities(qemuMonitorPtr mon);
+int qemuMonitorSetCapabilities(qemuMonitorPtr mon,
+ virBitmapPtr qemuCaps);
int qemuMonitorCheckHMP(qemuMonitorPtr mon, const char *cmd);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index b0ae570..513788a 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -34,6 +34,7 @@
#include "qemu_monitor_text.h"
#include "qemu_monitor_json.h"
#include "qemu_command.h"
+#include "qemu_capabilities.h"
#include "memory.h"
#include "logging.h"
#include "driver.h"
@@ -800,7 +801,9 @@ qemuMonitorJSONSetCapabilities(qemuMonitorPtr mon)
* human-monitor-command worked or -1 on failure
*/
int
-qemuMonitorJSONCheckHMP(qemuMonitorPtr mon)
+qemuMonitorJSONCheckCommands(qemuMonitorPtr mon,
+ virBitmapPtr qemuCaps,
+ int *json_hmp)
{
int ret = -1;
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("query-commands", NULL);
@@ -828,13 +831,13 @@ qemuMonitorJSONCheckHMP(qemuMonitorPtr mon)
!(name = virJSONValueObjectGetString(entry, "name")))
goto cleanup;
- if (STREQ(name, "human-monitor-command")) {
- ret = 1;
- goto cleanup;
- }
+ if (STREQ(name, "human-monitor-command"))
+ *json_hmp = 1;
+
+ if (STREQ(name, "system_wakeup"))
+ qemuCapsSet(qemuCaps, QEMU_CAPS_WAKEUP);
}
- /* human-monitor-command is not supported */
ret = 0;
cleanup:
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index d221e59..d0b3000 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -28,6 +28,7 @@
# include "internal.h"
# include "qemu_monitor.h"
+# include "bitmap.h"
int qemuMonitorJSONIOProcess(qemuMonitorPtr mon,
const char *data,
@@ -41,7 +42,9 @@ int qemuMonitorJSONHumanCommandWithFd(qemuMonitorPtr mon,
int qemuMonitorJSONSetCapabilities(qemuMonitorPtr mon);
-int qemuMonitorJSONCheckHMP(qemuMonitorPtr mon);
+int qemuMonitorJSONCheckCommands(qemuMonitorPtr mon,
+ virBitmapPtr qemuCaps,
+ int *json_hmp);
int qemuMonitorJSONStartCPUs(qemuMonitorPtr mon,
virConnectPtr conn);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 2d92d66..7afb585 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1086,7 +1086,7 @@ qemuConnectMonitor(struct qemud_driver *driver, virDomainObjPtr vm)
qemuDomainObjEnterMonitorWithDriver(driver, vm);
- ret = qemuMonitorSetCapabilities(priv->mon);
+ ret = qemuMonitorSetCapabilities(priv->mon, priv->qemuCaps);
qemuDomainObjExitMonitorWithDriver(driver, vm);
error:
--
1.7.3.4
12 years, 9 months
[libvirt] [PATCH] python: Avoid memory leaks on libvirt_virNodeGetMemoryStats
by ajia@redhat.com
From: Alex Jia <ajia(a)redhat.com>
Detected by valgrind. Leaks are introduced in commit 17c7795.
* python/libvirt-override.c (libvirt_virNodeGetMemoryStats): fix memory leaks
and improve codes return value.
For details, please see the following link:
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=770944
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
python/libvirt-override.c | 41 ++++++++++++++++++++++++++++++-----------
1 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 4e8a97e..ecb11ea 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -2426,7 +2426,9 @@ libvirt_virNodeGetCPUStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
static PyObject *
libvirt_virNodeGetMemoryStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
{
- PyObject *ret;
+ PyObject *info, *ret;
+ PyObject *key = NULL;
+ PyObject *val = NULL;
PyObject *pyobj_conn;
virConnectPtr conn;
unsigned int flags;
@@ -2446,28 +2448,45 @@ libvirt_virNodeGetMemoryStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
if (nparams) {
if (VIR_ALLOC_N(stats, nparams) < 0)
- return VIR_PY_NONE;
+ return PyErr_NoMemory();
LIBVIRT_BEGIN_ALLOW_THREADS;
c_retval = virNodeGetMemoryStats(conn, cellNum, stats, &nparams, flags);
LIBVIRT_END_ALLOW_THREADS;
if (c_retval < 0) {
- VIR_FREE(stats);
- return VIR_PY_NONE;
+ ret = VIR_PY_NONE;
+ goto cleanup;
}
}
- if (!(ret = PyDict_New())) {
- VIR_FREE(stats);
- return VIR_PY_NONE;
+ if (!(info = PyDict_New())) {
+ ret = VIR_PY_NONE;
+ goto cleanup;
}
+
for (i = 0; i < nparams; i++) {
- PyDict_SetItem(ret,
- libvirt_constcharPtrWrap(stats[i].field),
- libvirt_ulonglongWrap(stats[i].value));
+ key = libvirt_constcharPtrWrap(stats[i].field);
+ val = libvirt_ulonglongWrap(stats[i].value);
+
+ if (!key || !val)
+ goto cleanup;
+
+ if (PyDict_SetItem(info, key, val) < 0) {
+ Py_DECREF(info);
+ goto cleanup;
+ }
+
+ Py_DECREF(key);
+ Py_DECREF(val);
}
VIR_FREE(stats);
- return ret;
+ return info;
+
+cleanup:
+ VIR_FREE(stats);
+ Py_XDECREF(key);
+ Py_XDECREF(val);
+ return NULL;
}
static PyObject *
--
1.7.1
12 years, 9 months