[libvirt] [tck PATCH] maint: Drop autobuild.sh
by Andrea Bolognani
The Test-AutoBuild project, that this script is supposed
to be used with, hasn't seen any activity in ~7 years;
these days, libvirt-tck CI builds are happening on the
Jenkins-based CentOS CI environment under the libvirt
umbrella[1], and in that context the script is not used
at all.
[1] https://ci.centos.org/view/libvirt/
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
autobuild.sh | 59 -----------------------------------------------------------
1 file changed, 59 deletions(-)
delete mode 100755 autobuild.sh
diff --git a/autobuild.sh b/autobuild.sh
deleted file mode 100755
index 005993d..0000000
--- a/autobuild.sh
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/sh
-#
-# This script is used to Test::AutoBuild (http://www.autobuild.org)
-# to perform automated builds of the Sys-Virt module
-#
-# Copyright (C) 2009 Red Hat, Inc.
-# Copyright (C) 2009 Daniel P. Berrange
-#
-# This program is free software; You can redistribute it and/or modify
-# it under the GNU General Public License as published by the Free
-# Software Foundation; either version 2, or (at your option) any
-# later version
-#
-# The file "LICENSE" distributed along with this file provides full
-# details of the terms and conditions
-#
-
-NAME=Sys-Virt-TCK
-
-set -e
-
-rm -rf MANIFEST blib _build Build
-
-test -z "$AUTOBUILD_INSTALL_ROOT" && AUTOBUILD_INSTALL_ROOT=$HOME/builder
-
-perl Build.PL install_base=$AUTOBUILD_INSTALL_ROOT
-
-./Build
-./Build manifest
-
-
-if [ -z "$USE_COVER" ]; then
- perl -MDevel::Cover -e '' 1>/dev/null 2>&1 && USE_COVER=1 || USE_COVER=0
-fi
-
-if [ -z "$SKIP_TESTS" -o "$SKIP_TESTS" = "0" ]; then
- if [ "$USE_COVER" = "1" ]; then
- ./Build test
- else
- ./Build test
- fi
-fi
-
-./Build install
-
-rm -f $NAME-*.tar.gz
-./Build dist
-
-if [ -f /usr/bin/rpmbuild ]; then
- if [ -n "$AUTOBUILD_COUNTER" ]; then
- EXTRA_RELEASE=".auto$AUTOBUILD_COUNTER"
- else
- NOW=`date +"%s"`
- EXTRA_RELEASE=".$USER$NOW"
- fi
- rpmbuild -ta --define "extra_release $EXTRA_RELEASE" --clean $NAME-*.tar.gz
-fi
-
-exit 0
--
2.14.3
7 years, 1 month
[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
7 years, 1 month
[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
7 years, 1 month
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(+)
>
7 years, 1 month
[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
7 years, 1 month
[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
7 years, 1 month
[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
7 years, 1 month
[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
7 years, 1 month
[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
7 years, 1 month
[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
7 years, 1 month