[libvirt] [python PATCH] maint: balance {} usage
by Eric Blake
Emacs gets lost when finding function boundaries when #ifdef
sections do not have balanced {}.
* libvirt-override.c (virPyDictToTypedParams): Avoid unbalanced {}
across ifdef.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
This feels trivial, but it's also hacky enough that I'll wait
for a review.
libvirt-override.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libvirt-override.c b/libvirt-override.c
index aecf25d..3a21bcc 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -321,10 +321,12 @@ virPyDictToTypedParams(PyObject *dict,
}
if (type == -1) {
+ if (false) {
+ /* hack to keep balanced {} */
#if PY_MAJOR_VERSION > 2
- if (PyUnicode_Check(value)) {
+ } else if (PyUnicode_Check(value)) {
#else
- if (PyString_Check(value)) {
+ } else if (PyString_Check(value)) {
#endif
type = VIR_TYPED_PARAM_STRING;
} else if (PyBool_Check(value)) {
--
1.8.5.3
10 years, 9 months
[libvirt] [libvirt-python PATCH] setup: Make libvirt API XML path configurable
by Martin Kletzander
Adding a support for LIBVIRT_API_PATH evironment variable, which can
control where the script should look for the 'libvirt-api.xml' file.
This allows building libvirt-python against different libvirt than the
one installed in the system. This may be used for example in autotest
or by packagers without the need to install libvirt into the system.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
setup.py | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
index 17b4722..566c210 100755
--- a/setup.py
+++ b/setup.py
@@ -109,7 +109,17 @@ class my_build(build):
"""Check with pkg-config that libvirt is present and extract
the API XML file paths we need from it"""
- libvirt_api = get_pkgconfig_data(["--variable", "libvirt_api"], "libvirt")
+ libvirt_api = os.getenv("LIBVIRT_API_PATH")
+
+ if libvirt_api:
+ if not libvirt_api.endswith("-api.xml"):
+ raise ValueError("Invalid path '%s' for API XML" % libvirt_api)
+ if not os.path.exists(libvirt_api):
+ raise ValueError("API XML '%s' does not exist, "
+ "have you built libvirt?" % libvirt_api)
+ else:
+ libvirt_api = get_pkgconfig_data(["--variable", "libvirt_api"],
+ "libvirt")
offset = libvirt_api.index("-api.xml")
libvirt_qemu_api = libvirt_api[0:offset] + "-qemu-api.xml"
--
1.8.4.3
10 years, 9 months
[libvirt] Error while running event-test.c from libvirt
by Avanti Ajay
Hi..
I compiled event-test.c as : gcc event-test.c -o events -lvirt
and then running as : ./events
But I am getting this output and the code terminates without detecting
events :
main:471: Registering domain event cbs
myFreeFunc: Freeing [tray change]
libvir: XML-RPC error : internal error unsupported event ID 10
myFreeFunc: Freeing [pmwakeup]
libvir: XML-RPC error : internal error unsupported event ID 11
myFreeFunc: Freeing [pmsuspend]
libvir: XML-RPC error : internal error unsupported event ID 12
myFreeFunc: Freeing [callback balloonchange]
libvir: XML-RPC error : internal error unsupported event ID 13
main:580: Closing connection
done
Please help
Thank you
avanti
10 years, 9 months
[libvirt] [TCK][PATCH] Enable tests with a .pl extension
by Mike Latimer
The main libvirt-tck script only executes tests using the default (.t)
extension. This patch adds .t and .pl as valid extensions using the --ext
parameter. This is required to enable storage tests added in commit 97c6a506.
---
Build.PL | 2 +-
bin/libvirt-tck | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/Build.PL b/Build.PL
index e682c3a..c93637d 100644
--- a/Build.PL
+++ b/Build.PL
@@ -29,7 +29,7 @@ sub process_pkgdata_files {
my $name = $File::Find::name;
if (-d) {
$tck_dirs{$name} = [];
- } elsif (-f && /\.(t|sh|fwall|xml|dat)$/) {
+ } elsif (-f && /\.(t|sh|fwall|xml|dat|pl)$/) {
push @{$tck_dirs{$dir}}, $name;
}
};
diff --git a/bin/libvirt-tck b/bin/libvirt-tck
index 816234b..6261538 100644
--- a/bin/libvirt-tck
+++ b/bin/libvirt-tck
@@ -214,6 +214,11 @@ if ($timer) {
push @newargv, "--timer";
}
+# Run tests ending in both .t and .pl extensions
+foreach my $extension ('.t', '.pl') {
+ push @newargv, "--ext=$extension";
+}
+
# This env variable is the only way to pass config into
# the Sys::Virt::TCK module from here
$ENV{LIBVIRT_TCK_CONFIG} = $config;
--
1.8.4.5
10 years, 9 months
[libvirt] [python PATCH] maint: set up preferred emacs settings
by Eric Blake
Copy the relevant settings from libvirt.git, so that emacs users
maintain the style previously used before the two repos split.
* .dir-locals.el: New file.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing under the trivial rule.
.dir-locals.el | 8 ++++++++
1 file changed, 8 insertions(+)
create mode 100644 .dir-locals.el
diff --git a/.dir-locals.el b/.dir-locals.el
new file mode 100644
index 0000000..7c483d2
--- /dev/null
+++ b/.dir-locals.el
@@ -0,0 +1,8 @@
+(
+ (c-mode . (
+ (c-file-style . "K&R")
+ (indent-tabs-mode . nil)
+ (c-indent-level . 4)
+ (c-basic-offset . 4)
+ ))
+ )
--
1.8.5.3
10 years, 9 months
[libvirt] [PATCH] qemuDomainGetImageIds: Skip <seclabel/> without label
by Michal Privoznik
It's easy to shed the daemon these days. With this XML snippet:
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/some/dummy/path/test.bin'>
<seclabel model='dac' relabel='no'/>
</source>
<target dev='vdb' bus='virtio'/>
<readonly/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</disk>
I get the SIGSEGV when starting the domain. The thing is, when
starting a domain, we check for its disk presence. For some reason,
when determining the disk chain, we parse the <seclabel/> (don't ask
me why). However, there's no label attribute in the XML, so we end up
calling virParseOwnershipIds() over NULL string:
[Switching to Thread 0x7ffff10c4700 (LWP 30956)]
__strchr_sse42 () at ../sysdeps/x86_64/multiarch/strchr.S:136
136 ../sysdeps/x86_64/multiarch/strchr.S: No such file or directory.
(gdb) bt
#0 __strchr_sse42 () at ../sysdeps/x86_64/multiarch/strchr.S:136
#1 0x00007ffff749f800 in virParseOwnershipIds (label=0x0, uidPtr=uidPtr@entry=0x7ffff10c2df0, gidPtr=gidPtr@entry=0x7ffff10c2df4) at util/virutil.c:2115
#2 0x00007fffe929f006 in qemuDomainGetImageIds (gid=0x7ffff10c2df4, uid=0x7ffff10c2df0, disk=0x7fffe40cb000, vm=0x7fffe40a6410, cfg=0x7fffe409ae00) at qemu/qemu_domain.c:2385
#3 qemuDomainDetermineDiskChain (driver=driver@entry=0x7fffe40120e0, vm=vm@entry=0x7fffe40a6410, disk=disk@entry=0x7fffe40cb000, force=force@entry=false) at qemu/qemu_domain.c:2414
#4 0x00007fffe929f128 in qemuDomainCheckDiskPresence (driver=driver@entry=0x7fffe40120e0, vm=vm@entry=0x7fffe40a6410, cold_boot=cold_boot@entry=true) at qemu/qemu_domain.c:2250
#5 0x00007fffe92b6fc8 in qemuProcessStart (conn=conn@entry=0x7fffd4000b60, driver=driver@entry=0x7fffe40120e0, vm=vm@entry=0x7fffe40a6410, migrateFrom=migrateFrom@entry=0x0, stdin_fd=stdin_fd@entry=-1, stdin_path=stdin_path@entry=0x0, snapshot=snapshot@entry=0x0,
vmop=vmop@entry=VIR_NETDEV_VPORT_PROFILE_OP_CREATE, flags=flags@entry=1) at qemu/qemu_process.c:3813
#6 0x00007fffe93087e8 in qemuDomainObjStart (conn=0x7fffd4000b60, driver=driver@entry=0x7fffe40120e0, vm=vm@entry=0x7fffe40a6410, flags=flags@entry=0) at qemu/qemu_driver.c:6051
#7 0x00007fffe9308e32 in qemuDomainCreateWithFlags (dom=0x7fffcc000d50, flags=0) at qemu/qemu_driver.c:6105
#8 0x00007ffff753c5cc in virDomainCreate (domain=domain@entry=0x7fffcc000d50) at libvirt.c:8861
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_domain.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 7d375e5..c76b872 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2381,7 +2381,8 @@ qemuDomainGetImageIds(virQEMUDriverConfigPtr cfg,
if (vm && (vmlabel = virDomainDefGetSecurityLabelDef(vm->def, "dac")))
virParseOwnershipIds(vmlabel->label, uid, gid);
- if ((disklabel = virDomainDiskDefGetSecurityLabelDef(disk, "dac")))
+ if ((disklabel = virDomainDiskDefGetSecurityLabelDef(disk, "dac")) &&
+ disklabel->label)
virParseOwnershipIds(disklabel->label, uid, gid);
}
--
1.9.0
10 years, 9 months
[libvirt] [PATCH] bhyve: add domainCreateWithFlags support
by Michal Privoznik
From: Roman Bogorodskiy <bogorodskiy(a)gmail.com>
The only supported flag for now is 'autodestroy'. In order to
support 'autodestroy', add support for close callbacks.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/bhyve/bhyve_driver.c | 28 ++++++++++++++++++++++++---
src/bhyve/bhyve_process.c | 49 +++++++++++++++++++++++++++++++++++------------
src/bhyve/bhyve_process.h | 7 ++++++-
src/bhyve/bhyve_utils.h | 3 +++
4 files changed, 71 insertions(+), 16 deletions(-)
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 1cf3be2..a524d35 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -178,6 +178,9 @@ bhyveConnectOpen(virConnectPtr conn,
static int
bhyveConnectClose(virConnectPtr conn)
{
+ bhyveConnPtr privconn = conn->privateData;
+
+ virCloseCallbacksRun(privconn->closeCallbacks, conn, privconn->domains, privconn);
conn->privateData = NULL;
return 0;
@@ -530,16 +533,23 @@ cleanup:
}
static int
-bhyveDomainCreate(virDomainPtr dom)
+bhyveDomainCreateWithFlags(virDomainPtr dom,
+ unsigned int flags)
{
bhyveConnPtr privconn = dom->conn->privateData;
virDomainObjPtr vm;
+ unsigned int start_flags = 0;
int ret = -1;
+ virCheckFlags(VIR_DOMAIN_START_AUTODESTROY, -1);
+
+ if (flags & VIR_DOMAIN_START_AUTODESTROY)
+ start_flags |= VIR_BHYVE_PROCESS_START_AUTODESTROY;
+
if (!(vm = bhyveDomObjFromDomain(dom)))
goto cleanup;
- if (virDomainCreateEnsureACL(dom->conn, vm->def) < 0)
+ if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
if (virDomainObjIsActive(vm)) {
@@ -549,7 +559,8 @@ bhyveDomainCreate(virDomainPtr dom)
}
ret = virBhyveProcessStart(dom->conn, privconn, vm,
- VIR_DOMAIN_RUNNING_BOOTED);
+ VIR_DOMAIN_RUNNING_BOOTED,
+ start_flags);
cleanup:
virObjectUnlock(vm);
@@ -557,6 +568,12 @@ cleanup:
}
static int
+bhyveDomainCreate(virDomainPtr dom)
+{
+ return bhyveDomainCreateWithFlags(dom, 0);
+}
+
+static int
bhyveDomainDestroy(virDomainPtr dom)
{
bhyveConnPtr privconn = dom->conn->privateData;
@@ -629,6 +646,7 @@ bhyveStateCleanup(void)
virObjectUnref(bhyve_driver->domains);
virObjectUnref(bhyve_driver->caps);
virObjectUnref(bhyve_driver->xmlopt);
+ virObjectUnref(bhyve_driver->closeCallbacks);
virMutexDestroy(&bhyve_driver->lock);
VIR_FREE(bhyve_driver);
@@ -655,6 +673,9 @@ bhyveStateInitialize(bool priveleged ATTRIBUTE_UNUSED,
return -1;
}
+ if (!(bhyve_driver->closeCallbacks = virCloseCallbacksNew()))
+ goto cleanup;
+
if (!(bhyve_driver->caps = bhyveBuildCapabilities()))
goto cleanup;
@@ -773,6 +794,7 @@ static virDriver bhyveDriver = {
.connectListDefinedDomains = bhyveConnectListDefinedDomains, /* 1.2.2 */
.connectNumOfDefinedDomains = bhyveConnectNumOfDefinedDomains, /* 1.2.2 */
.domainCreate = bhyveDomainCreate, /* 1.2.2 */
+ .domainCreateWithFlags = bhyveDomainCreateWithFlags, /* 1.2.3 */
.domainDestroy = bhyveDomainDestroy, /* 1.2.2 */
.domainLookupByUUID = bhyveDomainLookupByUUID, /* 1.2.2 */
.domainLookupByName = bhyveDomainLookupByName, /* 1.2.2 */
diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c
index f5433f3..423185a 100644
--- a/src/bhyve/bhyve_process.c
+++ b/src/bhyve/bhyve_process.c
@@ -46,11 +46,29 @@
VIR_LOG_INIT("bhyve.bhyve_process");
+static virDomainObjPtr
+bhyveProcessAutoDestroy(virDomainObjPtr vm,
+ virConnectPtr conn ATTRIBUTE_UNUSED,
+ void *opaque)
+{
+ bhyveConnPtr driver = opaque;
+
+ virBhyveProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED);
+
+ if (!vm->persistent) {
+ virDomainObjListRemove(driver->domains, vm);
+ vm = NULL;
+ }
+
+ return vm;
+}
+
int
virBhyveProcessStart(virConnectPtr conn,
bhyveConnPtr driver,
virDomainObjPtr vm,
- virDomainRunningReason reason)
+ virDomainRunningReason reason,
+ unsigned int flags)
{
char *logfile = NULL;
int logfd = -1;
@@ -121,21 +139,25 @@ virBhyveProcessStart(virConnectPtr conn,
/* Now we can start the domain */
VIR_DEBUG("Starting domain '%s'", vm->def->name);
- ret = virCommandRun(cmd, NULL);
+ if (virCommandRun(cmd, NULL) < 0)
+ goto cleanup;
- if (ret == 0) {
- if (virPidFileReadPath(privconn->pidfile, &vm->pid) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Domain %s didn't show up"), vm->def->name);
- goto cleanup;
- }
-
- vm->def->id = vm->pid;
- virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, reason);
- } else {
+ if (virPidFileReadPath(privconn->pidfile, &vm->pid) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Domain %s didn't show up"), vm->def->name);
goto cleanup;
}
+ if (flags & VIR_BHYVE_PROCESS_START_AUTODESTROY &&
+ virCloseCallbacksSet(driver->closeCallbacks, vm,
+ conn, bhyveProcessAutoDestroy) < 0)
+ goto cleanup;
+
+ vm->def->id = vm->pid;
+ virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, reason);
+
+ ret = 0;
+
cleanup:
if (ret < 0) {
virCommandPtr destroy_cmd;
@@ -203,6 +225,9 @@ virBhyveProcessStop(bhyveConnPtr driver,
ret = 0;
+ virCloseCallbacksUnset(driver->closeCallbacks, vm,
+ bhyveProcessAutoDestroy);
+
virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, reason);
vm->pid = -1;
vm->def->id = -1;
diff --git a/src/bhyve/bhyve_process.h b/src/bhyve/bhyve_process.h
index 66548ae..f91504e 100644
--- a/src/bhyve/bhyve_process.h
+++ b/src/bhyve/bhyve_process.h
@@ -27,10 +27,15 @@
int virBhyveProcessStart(virConnectPtr conn,
bhyveConnPtr driver,
virDomainObjPtr vm,
- virDomainRunningReason reason);
+ virDomainRunningReason reason,
+ unsigned int flags);
int virBhyveProcessStop(bhyveConnPtr driver,
virDomainObjPtr vm,
virDomainShutoffReason reason);
+typedef enum {
+ VIR_BHYVE_PROCESS_START_AUTODESTROY = 1 << 0,
+} bhyveProcessStartFlags;
+
#endif /* __BHYVE_PROCESS_H__ */
diff --git a/src/bhyve/bhyve_utils.h b/src/bhyve/bhyve_utils.h
index 0810caa..6c76770 100644
--- a/src/bhyve/bhyve_utils.h
+++ b/src/bhyve/bhyve_utils.h
@@ -26,6 +26,7 @@
# include "domain_conf.h"
# include "configmake.h"
# include "virthread.h"
+# include "virclosecallbacks.h"
# define BHYVE_AUTOSTART_DIR SYSCONFDIR "/libvirt/bhyve/autostart"
# define BHYVE_CONFIG_DIR SYSCONFDIR "/libvirt/bhyve"
@@ -38,6 +39,8 @@ struct _bhyveConn {
virCapsPtr caps;
virDomainXMLOptionPtr xmlopt;
char *pidfile;
+
+ virCloseCallbacksPtr closeCallbacks;
};
typedef struct _bhyveConn bhyveConn;
--
1.9.0
10 years, 9 months
[libvirt] Memory allocation/usage
by Vikas Kokare
We are trying to understand the memory allocation and usage for a KVM guest
using the libvirt java API version 0.5.0. A certain memoryStats(int) on the
Domain class allows you to fetch MemoryStatistic values.
Each of this statistic has a tag and a value. In our case, the values
returned were
[tag: 6 val:8388608
, tag:7 val:8466792
]
What are these tag values(6 and 7) representative of? Do they mean memory
allocated and memory used. If yes, how can we confirm that?
10 years, 9 months