[libvirt] [dbus PATCH] "foo* [bar]" should be "foo *[bar]"
by Katerina Koukiou
Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
We forgot to include this in the last code style fixes.
src/connect.c | 6 +++---
src/domain.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/connect.c b/src/connect.c
index fd335e3..1c87bf2 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -227,7 +227,7 @@ virtDBusConnectBaselineCPU(GVariant *inArgs,
ncpus = g_variant_iter_n_children(iter);
if (ncpus > 0) {
- xmlCPUs = g_new0(const gchar*, ncpus);
+ xmlCPUs = g_new0(const gchar *, ncpus);
tmp = xmlCPUs;
while (g_variant_iter_next(iter, "&s", tmp))
tmp++;
@@ -517,7 +517,7 @@ virtDBusConnectGetAllDomainStats(GVariant *inArgs,
g_variant_builder_init(&builder, G_VARIANT_TYPE("a(sa{sv})"));
for (gint i = 0; i < nstats; i++) {
- const gchar* name;
+ const gchar *name;
GVariant *grecords;
g_variant_builder_open(&builder, G_VARIANT_TYPE("(sa{sv})"));
@@ -582,7 +582,7 @@ virtDBusConnectGetDomainCapabilities(GVariant *inArgs,
const gchar *machine;
const gchar *virttype;
guint flags;
- g_autofree gchar* domCapabilities = NULL;
+ g_autofree gchar *domCapabilities = NULL;
g_variant_get(inArgs, "(&s&s&s&su)", &emulatorbin, &arch, &machine,
&virttype, &flags);
diff --git a/src/domain.c b/src/domain.c
index 2ba58e0..3127f6c 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -118,7 +118,7 @@ virtDBusDomainGVariantToMountpoints(GVariantIter *iter,
*nmountpoints = g_variant_iter_n_children(iter);
if (*nmountpoints > 0) {
- *mountpoints = g_new0(const gchar*, *nmountpoints);
+ *mountpoints = g_new0(const gchar *, *nmountpoints);
tmp = *mountpoints;
while (g_variant_iter_next(iter, "&s", tmp))
tmp++;
--
2.15.0
6 years, 7 months
[libvirt] [PATCH 09/12] virsh: Enable multiple --event flags to 'event' command
by Lin Ma
Signed-off-by: Lin Ma <lma(a)suse.com>
---
tools/virsh-domain.c | 76 +++++++++++++++++++++++++++-------------------------
1 file changed, 39 insertions(+), 37 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 89aefbf86a..b35c9adaaa 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -13347,10 +13347,6 @@ static const vshCmdInfo info_event[] = {
static const vshCmdOptDef opts_event[] = {
VIRSH_COMMON_OPT_DOMAIN_OT_STRING(N_("filter by domain name, id or uuid"),
0),
- {.name = "event",
- .type = VSH_OT_STRING,
- .help = N_("which event type to wait for")
- },
{.name = "all",
.type = VSH_OT_BOOL,
.help = N_("wait for all events instead of just one type")
@@ -13371,6 +13367,10 @@ static const vshCmdOptDef opts_event[] = {
.type = VSH_OT_BOOL,
.help = N_("show timestamp for each printed event")
},
+ {.name = "event",
+ .type = VSH_OT_ARGV,
+ .help = N_("which event type to wait for")
+ },
{.name = NULL}
};
@@ -13382,12 +13382,14 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd)
int timeout = 0;
virshDomEventData *data = NULL;
size_t i;
- const char *eventName = NULL;
+ int *eventIdxList = NULL;
+ size_t nevents = 0;
int event = -1;
bool all = vshCommandOptBool(cmd, "all");
bool loop = vshCommandOptBool(cmd, "loop");
bool timestamp = vshCommandOptBool(cmd, "timestamp");
int count = 0;
+ const vshCmdOpt *opt = NULL;
virshControlPtr priv = ctl->privData;
if (vshCommandOptBool(cmd, "list")) {
@@ -13396,15 +13398,25 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd)
return true;
}
- if (vshCommandOptStringReq(ctl, cmd, "event", &eventName) < 0)
- return false;
- if (eventName) {
- for (event = 0; event < VIR_DOMAIN_EVENT_ID_LAST; event++)
- if (STREQ(eventName, vshEventCallbacks[event].name))
- break;
- if (event == VIR_DOMAIN_EVENT_ID_LAST) {
- vshError(ctl, _("unknown event type %s"), eventName);
- return false;
+ if (vshCommandOptBool(cmd, "event")) {
+ if (VIR_ALLOC_N(eventIdxList, 1) < 0)
+ goto cleanup;
+ nevents = 1;
+ while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
+ if (opt->data) {
+ for (event = 0; event < VIR_DOMAIN_EVENT_ID_LAST; event++)
+ if (STREQ(opt->data, vshEventCallbacks[event].name))
+ break;
+ if (event == VIR_DOMAIN_EVENT_ID_LAST) {
+ vshError(ctl, _("unknown event type %s"), opt->data);
+ return false;
+ }
+ if (VIR_INSERT_ELEMENT(eventIdxList,
+ nevents - 1,
+ nevents,
+ event) < 0)
+ goto cleanup;
+ }
}
} else if (!all) {
vshError(ctl, "%s",
@@ -13412,26 +13424,15 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd)
return false;
}
- if (all) {
- if (VIR_ALLOC_N(data, VIR_DOMAIN_EVENT_ID_LAST) < 0)
- goto cleanup;
- for (i = 0; i < VIR_DOMAIN_EVENT_ID_LAST; i++) {
- data[i].ctl = ctl;
- data[i].loop = loop;
- data[i].count = &count;
- data[i].timestamp = timestamp;
- data[i].cb = &vshEventCallbacks[i];
- data[i].id = -1;
- }
- } else {
- if (VIR_ALLOC_N(data, 1) < 0)
- goto cleanup;
- data[0].ctl = ctl;
- data[0].loop = vshCommandOptBool(cmd, "loop");
- data[0].count = &count;
- data[0].timestamp = timestamp;
- data[0].cb = &vshEventCallbacks[event];
- data[0].id = -1;
+ if (VIR_ALLOC_N(data, all ? VIR_DOMAIN_EVENT_ID_LAST : nevents - 1) < 0)
+ goto cleanup;
+ for (i = 0; i < (all ? VIR_DOMAIN_EVENT_ID_LAST : nevents - 1); i++) {
+ data[i].ctl = ctl;
+ data[i].loop = loop;
+ data[i].count = &count;
+ data[i].timestamp = timestamp;
+ data[i].cb = &vshEventCallbacks[all ? i : eventIdxList[i]];
+ data[i].id = -1;
}
if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
goto cleanup;
@@ -13441,9 +13442,9 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd)
if (vshEventStart(ctl, timeout) < 0)
goto cleanup;
- for (i = 0; i < (all ? VIR_DOMAIN_EVENT_ID_LAST : 1); i++) {
+ for (i = 0; i < (all ? VIR_DOMAIN_EVENT_ID_LAST : nevents - 1); i++) {
if ((data[i].id = virConnectDomainEventRegisterAny(priv->conn, dom,
- all ? i : event,
+ all ? i : eventIdxList[i],
data[i].cb->cb,
&data[i],
NULL)) < 0) {
@@ -13476,13 +13477,14 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd)
cleanup:
vshEventCleanup(ctl);
if (data) {
- for (i = 0; i < (all ? VIR_DOMAIN_EVENT_ID_LAST : 1); i++) {
+ for (i = 0; i < (all ? VIR_DOMAIN_EVENT_ID_LAST : nevents - 1); i++) {
if (data[i].id >= 0 &&
virConnectDomainEventDeregisterAny(priv->conn, data[i].id) < 0)
ret = false;
}
VIR_FREE(data);
}
+ VIR_FREE(eventIdxList);
virshDomainFree(dom);
return ret;
}
--
2.15.1
6 years, 7 months
Re: [libvirt] [PATCH 0/1] Bug: Sandbox: libvirt breakdowns qemu guest
by Christian Borntraeger
On 05/07/2018 05:32 AM, Yi Min Zhao wrote:
> 1. Problem Description
> ======================
> If QEMU is built without seccomp support, 'elevatorprivileges' remains compiled.
> This option of sandbox is treated as an indication for seccomp blacklist support
> in libvirt. This behavior is introduced by the libvirt commits 31ca6a5 and
> 3527f9d. It would make libvirt build wrong QEMU cmdline, and then the guest
> startup would fail.
Adding libvirt list.
This would still fail with older QEMUs, so the question is if we should also OR instead
change something in libvirt.
>
> 2. Libvirt Log
> ==============
> qemu-system-s390x: -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
> resourcecontrol=deny: seccomp support is disabled
>
> 3. Fixup
> ========
> Wrap the options except 'enable' for qemu_sandbox_opts by CONFIG_SECCOMP.
>
> Yi Min Zhao (1):
> sandbox: avoid to compile options if CONFIG_SECCOMP undefined
>
> vl.c | 2 ++
> 1 file changed, 2 insertions(+)
>
6 years, 7 months
[libvirt] [dbus PATCH 0/9] random fixes
by Pavel Hrdina
*** BLURB HERE ***
Pavel Hrdina (9):
Process input arguments before getting libvirt object
Use ++ operator instead of += in for loop
connect: Fix List* methods to return empty array for empty list
connect: Pass error into virtDBusConnectOpen function
domain: There is no need to check ret again
domain: Return error if libvirt API fails
domain: Introduce virtDBusDomainGVariantToMountpoints helper
domain: Introduce virtDBusDomainGVariantToCpumap helper
util: Use spaces around operators
src/connect.c | 28 ++++++---------
src/domain.c | 110 ++++++++++++++++++++++++++++------------------------------
src/main.c | 2 +-
src/network.c | 2 +-
src/util.c | 6 ++--
5 files changed, 70 insertions(+), 78 deletions(-)
--
2.14.3
6 years, 7 months
[libvirt] [PATCH 0/7] Couple of tiny fixes for virsh and translation.
by Lin Ma
Lin Ma (7):
virsh: Error out while domain not found for 'qemu-monitor-event'
command
virsh: Error out while domain not found for 'event' command
po: fix typo: remove a redundant Chinese character
virsh: Simplify control flow for 'desc' command
virsh: Simplify control flow for 'qemu-agent-command' command
qemu: stats: Display the net type and net source in bulk stats
qemu: stats: Display net count,type and source even if domain is
inactive
po/zh_CN.mini.po | 2 +-
src/libvirt-domain.c | 2 ++
src/qemu/qemu_driver.c | 11 ++++++++---
tools/virsh-domain.c | 33 ++++++++++++++++-----------------
tools/virsh.pod | 2 ++
5 files changed, 29 insertions(+), 21 deletions(-)
--
2.15.1
6 years, 7 months
[libvirt] [PATCH] xenconfig: Remove references to my name and email
by David Kiarie
Replace references to my name and email with a pseudonym
Signed-off-by: David Kiarie <davidkiarie4(a)gmail.com>
---
src/xenconfig/xen_xl.c | 2 +-
src/xenconfig/xen_xl.h | 2 +-
tests/xlconfigtest.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
index 35d52f8a..b383560d 100644
--- a/src/xenconfig/xen_xl.c
+++ b/src/xenconfig/xen_xl.c
@@ -17,7 +17,7 @@
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*
- * Author: Kiarie Kahurani <davidkiarie4(a)gmail.com>
+ * Author: Oneko <kawaiii.nekomata(a)mail.com>
* Author: Jim Fehlig <jfehlig(a)suse.com>
*/
diff --git a/src/xenconfig/xen_xl.h b/src/xenconfig/xen_xl.h
index 68f332ac..4ce13f05 100644
--- a/src/xenconfig/xen_xl.h
+++ b/src/xenconfig/xen_xl.h
@@ -17,7 +17,7 @@
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*
- * Author: Kiarie Kahurani<davidkiarie4(a)gmail.com>
+ * Author: Oneko <kawaiii.nekomata(a)gmail.com>
*/
#ifndef __VIR_XEN_XL_H__
diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c
index 39f51e2d..1bbc0b72 100644
--- a/tests/xlconfigtest.c
+++ b/tests/xlconfigtest.c
@@ -19,7 +19,7 @@
* <http://www.gnu.org/licenses/>.
*
* Author: Daniel P. Berrange <berrange(a)redhat.com>
- * Author: Kiarie Kahurani <davidkiarie4(a)gmail.com>
+ * Author: Oneko <kawaiii.nekomata(a)gmail.com>
*
*/
--
2.17.0
6 years, 7 months
[libvirt] ZFS backend does fail if used on non top level pools
by Christian Ehrhardt
Hi,
by discussing on bug [1] we found an issue in the ZFS storage backend.
When one defines a zfs pool through XML (virsh pool-create --build) a top
level ZFS pool will be created and works fine. The virsh pool-define-as
counterpart to this is:
$ fallocate -l 100M /tmp/Mzfs
$ sudo zpool create Mzfs /tmp/Mzfs
$ virsh pool-define-as --name zfs --source-name Mzfs --type zfs
$ virsh pool-start zfs
$ virsh vol-create-as --pool zfs --name vol1 --capacity 10M
$ virsh vol-list --pool zfs
vol1 /dev/zvol/Mzfs/vol1
$ virsh pool-refresh zfs
Pool zfs refreshed
$ virsh vol-list --pool zfs
vol1 /dev/zvol/Mzfs/vol1
Ok, all fine so far.
But if one wants to use a zfs-FS as sub-pool things work a while but fail
as soon as pool info is refreshed.
$ fallocate -l 100M /tmp/Xzfs
$ sudo zpool create Xzfs /tmp/Xzfs
$ sudo zfs create Xzfs/images
$ virsh pool-define-as --name Xzfs --source-name Xzfs/images --type zfs
I ended with the pool not being started (expected after pool-define-as),
but then
$ virsh pool-start Xzfs
$ virsh vol-create-as --pool Xzfs --name vol1 --capacity 10M
$ virsh vol-list --pool Xzfs
vol1 /dev/zvol/Xzfs/images/vol1
$ virsh pool-refresh zfs
Pool zfs refreshed
$ virsh vol-list --pool Xzfs
# no output anymore
We happened to find this in the libvirt log:
error : virCommandWait:2601 : internal error: Child process (/sbin/zpool
get -Hp health,size,free,allocated Xzfs/images) unexpected exit status 1:
cannot open 'Xzfs/images': invalid character '/' in pool name
So it seems the data refresh would need to become aware of filesytems and
strip this to the basename before doing the call.
This comes from src/storage/storage_backend_zfs.c
cmd = virCommandNewArgList(ZPOOL,
"get", "-Hp",
"health,size,free,allocated",
def->source.name,
NULL);
# fails
zfs list -Hp -t volume -r -o name,volsize,refreservation Xzfs/images
# would work
zfs list -Hp -t volume -r -o name,volsize,refreservation Xzfs
But there might be more to it than what I see, either more changes needed
to fully work with subpools or intentionally not working with them.
For the latter we should still consider improving the error handling, like
refusing right away with a reasonable message on "virsh pool-define-as".
I wondered if one with more experience in that area of libvirt would be
willing to pick this up or has an opinion why it would not need to be
changed that I might be missing?
[1]: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1767997
--
Christian Ehrhardt
Software Engineer, Ubuntu Server
Canonical Ltd
6 years, 8 months
[libvirt] [PATCH 0/5] Another batch of old capability cleanups
by Ján Tomko
Ján Tomko (5):
qemu: remove qemuBuildObsoleteAccelArg
qemuBuildMachineCommandLine: use a switch for virDomainVirtType
Deprecate QEMU_CAPS_NO_KVM_PIT
Depreacte QEMU_CAPS_TDF
Deprecate QEMU_CAPS_NESTING
src/qemu/qemu_capabilities.c | 6 +-
src/qemu/qemu_capabilities.h | 6 +-
src/qemu/qemu_command.c | 101 +++++++--------------
tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml | 1 -
tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml | 1 -
tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml | 1 -
tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml | 1 -
tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml | 1 -
tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml | 1 -
tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml | 1 -
tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml | 1 -
tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml | 1 -
tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml | 1 -
tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml | 1 -
tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 1 -
tests/qemuxml2argvdata/clock-hpet-off.args | 1 -
tests/qemuxml2argvdata/hugepages-numa.args | 1 -
tests/qemuxml2argvdata/no-kvm-pit-device.args | 28 ------
tests/qemuxml2argvdata/no-kvm-pit-device.xml | 29 ------
tests/qemuxml2argvdata/q35-virt-manager-basic.args | 1 -
tests/qemuxml2argvtest.c | 3 +-
tests/qemuxml2xmltest.c | 1 -
22 files changed, 40 insertions(+), 149 deletions(-)
delete mode 100644 tests/qemuxml2argvdata/no-kvm-pit-device.args
delete mode 100644 tests/qemuxml2argvdata/no-kvm-pit-device.xml
--
2.16.1
6 years, 8 months
[libvirt] [PATCH] lxc: convert to typesafe virConf accessors in lxc_native.c
by Prafull
From: Prafullkumar Tale <talep158(a)gmail.com>
Signed-off-by: Prafullkumar Tale <talep158(a)gmail.com>
---
src/lxc/lxc_native.c | 141 +++++++++++++++++++++++++--------------------------
1 file changed, 70 insertions(+), 71 deletions(-)
diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
index 55ea774..35077e1 100644
--- a/src/lxc/lxc_native.c
+++ b/src/lxc/lxc_native.c
@@ -199,19 +199,15 @@ lxcSetRootfs(virDomainDefPtr def,
virConfPtr properties)
{
int type = VIR_DOMAIN_FS_TYPE_MOUNT;
- virConfValuePtr value;
+ char *value = NULL;
- if (!(value = virConfGetValue(properties, "lxc.rootfs")) ||
- !value->str) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("Missing lxc.rootfs configuration"));
+ if (virConfGetValueString(properties, "lxc.rootfs", &value) <= 0)
return -1;
- }
- if (STRPREFIX(value->str, "/dev/"))
+ if (STRPREFIX(value, "/dev/"))
type = VIR_DOMAIN_FS_TYPE_BLOCK;
- if (lxcAddFSDef(def, type, value->str, "/", false, 0) < 0)
+ if (lxcAddFSDef(def, type, value, "/", false, 0) < 0)
return -1;
return 0;
@@ -684,17 +680,17 @@ lxcConvertNetworkSettings(virDomainDefPtr def, virConfPtr properties)
static int
lxcCreateConsoles(virDomainDefPtr def, virConfPtr properties)
{
- virConfValuePtr value;
+ char *value = NULL;
int nbttys = 0;
virDomainChrDefPtr console;
size_t i;
- if (!(value = virConfGetValue(properties, "lxc.tty")) || !value->str)
+ if (virConfGetValueString(properties, "lxc.tty", &value) <= 0)
return 0;
- if (virStrToLong_i(value->str, NULL, 10, &nbttys) < 0) {
+ if (virStrToLong_i(value, NULL, 10, &nbttys) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse int: '%s'"),
- value->str);
+ value);
return -1;
}
@@ -761,89 +757,91 @@ lxcIdmapWalkCallback(const char *name, virConfValuePtr value, void *data)
static int
lxcSetMemTune(virDomainDefPtr def, virConfPtr properties)
{
- virConfValuePtr value;
+ char *value = NULL;
unsigned long long size = 0;
- if ((value = virConfGetValue(properties,
- "lxc.cgroup.memory.limit_in_bytes")) &&
- value->str && STRNEQ(value->str, "-1")) {
- if (lxcConvertSize(value->str, &size) < 0)
- return -1;
+ if (virConfGetValueString(properties,
+ "lxc.cgroup.memory.limit_in_bytes",
+ &value) > 0) {
+ if (lxcConvertSize(value, &size) < 0)
+ goto error;
size = size / 1024;
virDomainDefSetMemoryTotal(def, size);
def->mem.hard_limit = virMemoryLimitTruncate(size);
}
- if ((value = virConfGetValue(properties,
- "lxc.cgroup.memory.soft_limit_in_bytes")) &&
- value->str && STRNEQ(value->str, "-1")) {
- if (lxcConvertSize(value->str, &size) < 0)
- return -1;
-
+ if (virConfGetValueString(properties,
+ "lxc.cgroup.memory.soft_limit_in_bytes",
+ &value) > 0) {
+ if (lxcConvertSize(value, &size) < 0)
+ goto error;
def->mem.soft_limit = virMemoryLimitTruncate(size / 1024);
}
- if ((value = virConfGetValue(properties,
- "lxc.cgroup.memory.memsw.limit_in_bytes")) &&
- value->str && STRNEQ(value->str, "-1")) {
- if (lxcConvertSize(value->str, &size) < 0)
- return -1;
-
+ if (virConfGetValueString(properties,
+ "lxc.cgroup.memory.memsw.limit_in_bytes",
+ &value) > 0) {
+ if (lxcConvertSize(value, &size) < 0)
+ goto error;
def->mem.swap_hard_limit = virMemoryLimitTruncate(size / 1024);
}
return 0;
+
+ error:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("failed to parse integer: '%s'"), value);
+ return -1;
+
}
static int
lxcSetCpuTune(virDomainDefPtr def, virConfPtr properties)
{
- virConfValuePtr value;
+ char *value = NULL;
- if ((value = virConfGetValue(properties, "lxc.cgroup.cpu.shares")) &&
- value->str) {
- if (virStrToLong_ull(value->str, NULL, 10, &def->cputune.shares) < 0)
+ if (virConfGetValueString(properties, "lxc.cgroup.cpu.shares",
+ &value) > 0) {
+ if (virStrToLong_ull(value, NULL, 10, &def->cputune.shares) < 0)
goto error;
def->cputune.sharesSpecified = true;
}
- if ((value = virConfGetValue(properties,
- "lxc.cgroup.cpu.cfs_quota_us")) &&
- value->str && virStrToLong_ll(value->str, NULL, 10,
- &def->cputune.quota) < 0)
- goto error;
+ if (virConfGetValueString(properties, "lxc.cgroup.cpu.cfs_quota_us",
+ &value) > 0) {
+ if (virStrToLong_ll(value, NULL, 10, &def->cputune.quota) < 0)
+ goto error;
+ }
- if ((value = virConfGetValue(properties,
- "lxc.cgroup.cpu.cfs_period_us")) &&
- value->str && virStrToLong_ull(value->str, NULL, 10,
- &def->cputune.period) < 0)
- goto error;
+ if (virConfGetValueString(properties, "lxc.cgroup.cpu.cfs_period_us",
+ &value) > 0) {
+ if (virStrToLong_ull(value, NULL, 10, &def->cputune.period) < 0)
+ goto error;
+ }
return 0;
error:
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("failed to parse integer: '%s'"), value->str);
+ _("failed to parse integer: '%s'"), value);
return -1;
}
static int
lxcSetCpusetTune(virDomainDefPtr def, virConfPtr properties)
{
- virConfValuePtr value;
+ char *value = NULL;
virBitmapPtr nodeset = NULL;
- if ((value = virConfGetValue(properties, "lxc.cgroup.cpuset.cpus")) &&
- value->str) {
- if (virBitmapParse(value->str, &def->cpumask,
- VIR_DOMAIN_CPUMASK_LEN) < 0)
+ if (virConfGetValueString(properties, "lxc.cgroup.cpuset.cpus",
+ &value) > 0) {
+ if (virBitmapParse(value, &def->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0)
return -1;
-
def->placement_mode = VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC;
}
- if ((value = virConfGetValue(properties, "lxc.cgroup.cpuset.mems")) &&
- value->str) {
- if (virBitmapParse(value->str, &nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0)
+ if (virConfGetValueString(properties, "lxc.cgroup.cpuset.mems",
+ &value) > 0) {
+ if (virBitmapParse(value, &nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0)
return -1;
if (virDomainNumatuneSet(def->numa,
def->placement_mode ==
@@ -952,14 +950,15 @@ lxcBlkioDeviceWalkCallback(const char *name, virConfValuePtr value, void *data)
static int
lxcSetBlkioTune(virDomainDefPtr def, virConfPtr properties)
{
- virConfValuePtr value;
+ char *value = NULL;
- if ((value = virConfGetValue(properties, "lxc.cgroup.blkio.weight")) &&
- value->str && virStrToLong_ui(value->str, NULL, 10,
- &def->blkio.weight) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("failed to parse integer: '%s'"), value->str);
- return -1;
+ if (virConfGetValueString(properties, "lxc.cgroup.blkio.weight",
+ &value) > 0) {
+ if (virStrToLong_ui(value, NULL, 10, &def->blkio.weight) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("failed to parse integer: '%s'"), value);
+ return -1;
+ }
}
if (virConfWalk(properties, lxcBlkioDeviceWalkCallback, def) < 0)
@@ -971,13 +970,13 @@ lxcSetBlkioTune(virDomainDefPtr def, virConfPtr properties)
static void
lxcSetCapDrop(virDomainDefPtr def, virConfPtr properties)
{
- virConfValuePtr value;
+ char *value = NULL;
char **toDrop = NULL;
const char *capString;
size_t i;
- if ((value = virConfGetValue(properties, "lxc.cap.drop")) && value->str)
- toDrop = virStringSplit(value->str, " ", 0);
+ if (virConfGetValueString(properties, "lxc.cap.drop", &value) > 0)
+ toDrop = virStringSplit(value, " ", 0);
for (i = 0; i < VIR_DOMAIN_CAPS_FEATURE_LAST; i++) {
capString = virDomainCapsFeatureTypeToString(i);
@@ -998,7 +997,7 @@ lxcParseConfigString(const char *config,
{
virDomainDefPtr vmdef = NULL;
virConfPtr properties = NULL;
- virConfValuePtr value;
+ char *value = NULL;
if (!(properties = virConfReadString(config, VIR_CONF_FLAG_LXC_FORMAT)))
return NULL;
@@ -1031,11 +1030,11 @@ lxcParseConfigString(const char *config,
vmdef->nfss = 0;
vmdef->os.type = VIR_DOMAIN_OSTYPE_EXE;
- if ((value = virConfGetValue(properties, "lxc.arch")) && value->str) {
- virArch arch = virArchFromString(value->str);
- if (arch == VIR_ARCH_NONE && STREQ(value->str, "x86"))
+ if (virConfGetValueString(properties, "lxc.arch", &value) > 0) {
+ virArch arch = virArchFromString(value);
+ if (arch == VIR_ARCH_NONE && STREQ(value, "x86"))
arch = VIR_ARCH_I686;
- else if (arch == VIR_ARCH_NONE && STREQ(value->str, "amd64"))
+ else if (arch == VIR_ARCH_NONE && STREQ(value, "amd64"))
arch = VIR_ARCH_X86_64;
vmdef->os.arch = arch;
}
@@ -1043,8 +1042,8 @@ lxcParseConfigString(const char *config,
if (VIR_STRDUP(vmdef->os.init, "/sbin/init") < 0)
goto error;
- if (!(value = virConfGetValue(properties, "lxc.utsname")) ||
- !value->str || (VIR_STRDUP(vmdef->name, value->str) < 0))
+ if (virConfGetValueString(properties, "lxc.utsname", &value) <= 0 ||
+ VIR_STRDUP(vmdef->name, value) < 0)
goto error;
if (!vmdef->name && (VIR_STRDUP(vmdef->name, "unnamed") < 0))
goto error;
--
2.7.4
6 years, 8 months
[libvirt] [dbus PATCH] Add detail argument to DomainEvent signal
by Katerina Koukiou
Adjust all DomainEvent tests to do detail type checking.
Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
This commit is rebased on top of unmerged patches for removing enum<->string
translation.
data/org.libvirt.Connect.xml | 1 +
src/events.c | 4 ++--
tests/libvirttest.py | 55 ++++++++++++++++++++++++++++++++++++++++++++
tests/test_connect.py | 6 +++--
tests/test_domain.py | 15 ++++++++----
5 files changed, 72 insertions(+), 9 deletions(-)
diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 8272da6..0f1456f 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -171,6 +171,7 @@
value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEven..."/>
<arg name="domain" type="o"/>
<arg name="event" type="u"/>
+ <arg name="detail" type="u"/>
</signal>
<signal name="NetworkEvent">
<annotation name="org.gtk.GDBus.DocString"
diff --git a/src/events.c b/src/events.c
index b432535..ea55180 100644
--- a/src/events.c
+++ b/src/events.c
@@ -8,7 +8,7 @@ static gint
virtDBusEventsDomainLifecycle(virConnectPtr connection G_GNUC_UNUSED,
virDomainPtr domain,
gint event,
- gint detail G_GNUC_UNUSED,
+ gint detail,
gpointer opaque)
{
virtDBusConnect *connect = opaque;
@@ -21,7 +21,7 @@ virtDBusEventsDomainLifecycle(virConnectPtr connection G_GNUC_UNUSED,
connect->connectPath,
VIRT_DBUS_CONNECT_INTERFACE,
"DomainEvent",
- g_variant_new("(ou)", path, event),
+ g_variant_new("(ouu)", path, event, detail),
NULL);
return 0;
diff --git a/tests/libvirttest.py b/tests/libvirttest.py
index 06ac0e4..eee67a0 100644
--- a/tests/libvirttest.py
+++ b/tests/libvirttest.py
@@ -100,6 +100,61 @@ class DomainEvent(IntEnum):
CRASHED = 8
+class DomainEventDefinedDetailType(IntEnum):
+ ADDED = 0
+ UPDATED = 1
+ RENAMED = 2
+ FROM_SNAPSHOT = 3
+ LAST = 4
+
+
+class DomainEventResumedDetailType(IntEnum):
+ UNPAUSED = 0
+ MIGRATED = 1
+ FROM_SNAPSHOT = 2
+ POSTCOPY = 3
+ LAST = 4
+
+
+class DomainEventStartedDetailType(IntEnum):
+ BOOTED = 0
+ MIGRATED = 1
+ RESTORED = 2
+ FROM_SNAPSHOT = 3
+ WAKEUP = 4
+ LAST = 5
+
+
+class DomainEventStoppedDetailType(IntEnum):
+ SHUTDOWN = 0
+ DESTROYED = 1
+ CRASHED = 2
+ MIGRATED = 3
+ SAVED = 4
+ FAILED = 5
+ FROM_SNAPSHOT = 6
+ LAST = 7
+
+
+class DomainEventSuspendedDetailType(IntEnum):
+ PAUSED = 0
+ MIGRATED = 1
+ IOERROR = 2
+ WATCHDOG = 3
+ RESTORED = 4
+ FROM_SNAPSHOT = 5
+ API_ERROR = 6
+ POSTCOPY = 7
+ POSTCOPY_FAILED = 8
+ LAST = 9
+
+
+class DomainEventUndefinedDetailType(IntEnum):
+ REMOVED = 0
+ RENAMED = 1
+ LAST = 2
+
+
class DomainState(IntEnum):
NOSTATE = 0
RUNNING = 1
diff --git a/tests/test_connect.py b/tests/test_connect.py
index 7748822..a2bd17f 100755
--- a/tests/test_connect.py
+++ b/tests/test_connect.py
@@ -31,9 +31,10 @@ class TestConnect(libvirttest.BaseTestClass):
'''
def test_connect_domain_create_xml(self):
- def domain_started(path, event):
+ def domain_started(path, event, detail):
if event != libvirttest.DomainEvent.STARTED:
return
+ assert detail == libvirttest.DomainEventStartedDetailType.BOOTED
assert isinstance(path, dbus.ObjectPath)
self.loop.quit()
@@ -45,9 +46,10 @@ class TestConnect(libvirttest.BaseTestClass):
self.main_loop()
def test_comnect_domain_define_xml(self):
- def domain_defined(path, event):
+ def domain_defined(path, event, detail):
if event != libvirttest.DomainEvent.DEFINED:
return
+ assert detail == libvirttest.DomainEventDefinedDetailType.ADDED
assert isinstance(path, dbus.ObjectPath)
self.loop.quit()
diff --git a/tests/test_domain.py b/tests/test_domain.py
index c7e09cd..dfa19ed 100755
--- a/tests/test_domain.py
+++ b/tests/test_domain.py
@@ -47,9 +47,10 @@ class TestDomain(libvirttest.BaseTestClass):
assert autostart_current == dbus.Boolean(autostart_expected)
def test_domain_managed_save(self):
- def domain_stopped(path, event):
+ def domain_stopped(path, event, detail):
if event != libvirttest.DomainEvent.STOPPED:
return
+ assert detail == libvirttest.DomainEventStoppedDetailType.SAVED
assert isinstance(path, dbus.ObjectPath)
self.loop.quit()
@@ -74,9 +75,10 @@ class TestDomain(libvirttest.BaseTestClass):
assert description_expected == domain.GetMetadata(metadata_description, "", 0)
def test_resume(self):
- def domain_resumed(path, event):
+ def domain_resumed(path, event, detail):
if event != libvirttest.DomainEvent.RESUMED:
return
+ assert detail == libvirttest.DomainEventResumedDetailType.UNPAUSED
assert isinstance(path, dbus.ObjectPath)
self.loop.quit()
@@ -92,9 +94,10 @@ class TestDomain(libvirttest.BaseTestClass):
self.main_loop()
def test_shutdown(self):
- def domain_stopped(path, event):
+ def domain_stopped(path, event, detail):
if event != libvirttest.DomainEvent.STOPPED:
return
+ assert detail == libvirttest.DomainEventStoppedDetailType.SHUTDOWN
assert isinstance(path, dbus.ObjectPath)
self.loop.quit()
@@ -109,9 +112,10 @@ class TestDomain(libvirttest.BaseTestClass):
self.main_loop()
def test_suspend(self):
- def domain_suspended(path, event):
+ def domain_suspended(path, event, detail):
if event != libvirttest.DomainEvent.SUSPENDED:
return
+ assert detail == libvirttest.DomainEventSuspendedDetailType.PAUSED
assert isinstance(path, dbus.ObjectPath)
self.loop.quit()
@@ -126,9 +130,10 @@ class TestDomain(libvirttest.BaseTestClass):
self.main_loop()
def test_undefine(self):
- def domain_undefined(path, event):
+ def domain_undefined(path, event, detail):
if event != libvirttest.DomainEvent.UNDEFINED:
return
+ assert detail == libvirttest.DomainEventUndefinedDetailType.REMOVED
assert isinstance(path, dbus.ObjectPath)
self.loop.quit()
--
2.15.0
6 years, 8 months