[libvirt] [RFC 0/6] Probe and expose GIC capabilities
by Andrea Bolognani
This series implements support for asking QEMU what GIC versions can
be used for guests, eg:
<features>
<gic version='2'/>
</features>
and exposing such information to users via domain capabilities.
QEMU patches that implement the query-gic-capabilities QMP command:
https://lists.gnu.org/archive/html/qemu-devel/2016-03/msg04465.html
Cheers.
Andrea Bolognani (6):
conf: Get rid of virDomainCapsDevice
qemu: Probe GIC capabilities
schema: Validate GIC capabilities
conf: Expose GIC capabilities
qemu: Fill in GIC capabilities
qemu: Cache GIC capabilities
docs/schemas/domaincaps.rng | 18 +++
src/conf/domain_capabilities.c | 26 +++-
src/conf/domain_capabilities.h | 24 ++--
src/qemu/qemu_capabilities.c | 157 ++++++++++++++++++++-
src/qemu/qemu_monitor.c | 10 ++
src/qemu/qemu_monitor.h | 4 +
src/qemu/qemu_monitor_json.c | 90 ++++++++++++
src/qemu/qemu_monitor_json.h | 4 +
src/util/virgic.h | 13 ++
tests/domaincapsschemadata/domaincaps-basic.xml | 3 +
tests/domaincapsschemadata/domaincaps-full.xml | 3 +
.../domaincaps-qemu_1.6.50-1.xml | 3 +
tests/domaincapstest.c | 8 +-
13 files changed, 341 insertions(+), 22 deletions(-)
--
2.5.5
8 years, 7 months
[libvirt] [PATCH v4 0/2] persistent live migration with specified XML
by Dmitry Andreev
v4: wrong param name in commit msg
v3:
- use shorter name for param and rename args
- move qemuMigrationCookieAddPersistent out from
qemuMigrationBakeCookie
- rebase to master
v2: reimplemented with new migration param
Libvirt doesn't allow to specify destination persistent domain
configuration. VIR_MIGRATE_PARAM_DEST_XML migration param is used for
active configuration and persistent configuration is taken from source
domain. The problem is mentioned in this bug:
https://bugzilla.redhat.com/show_bug.cgi?id=835300
This patch-set introduces new migration param VIR_MIGRATE_PARAM_PERSIST_XML
and implements its support in qemu driver.
Dmitry Andreev (2):
qemuMigrationCookieAddPersistent: move it out and change argument type
qemu: migration: new migration param for persistent destination XML
include/libvirt/libvirt-domain.h | 15 ++++++++++
src/qemu/qemu_driver.c | 12 +++++---
src/qemu/qemu_migration.c | 64 ++++++++++++++++++++++++----------------
src/qemu/qemu_migration.h | 2 ++
4 files changed, 63 insertions(+), 30 deletions(-)
--
1.8.3.1
8 years, 7 months
[libvirt] [PATCH] ZFS: Support sparse volumes
by Richard Laager
By default, `zfs create -V ...` reserves space for the entire volsize,
plus some extra (which attempts to account for overhead).
If `zfs create -s -V ...` is used instead, zvols are (fully) sparse.
A middle ground (partial allocation) can be achieved with
`zfs create -s -o refreservation=... -V ...`. Both libvirt and ZFS
support this approach, so the ZFS storage backend should support it.
Signed-off-by: Richard Laager <rlaager(a)wiktel.com>
---
src/storage/storage_backend_zfs.c | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backend_zfs.c
index 2e6e407..6dc3cec 100644
--- a/src/storage/storage_backend_zfs.c
+++ b/src/storage/storage_backend_zfs.c
@@ -112,7 +112,7 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool,
if (!(tokens = virStringSplitCount(volume_string, "\t", 0, &count)))
return -1;
- if (count != 2)
+ if (count != 3)
goto cleanup;
if (!(name_tokens = virStringSplit(tokens[0], "/", 2)))
@@ -151,6 +151,20 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool,
goto cleanup;
}
+ if (virStrToLong_ull(tokens[2], NULL, 10, &volume->target.allocation) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("malformed refreservation reported"));
+ goto cleanup;
+ }
+ if (volume->target.allocation >= volume->target.capacity) {
+ /* A zvol created without -s will have a refreservation slightly larger
+ * than volblocksize.
+ */
+ volume->target.allocation = volume->target.capacity;
+ } else {
+ volume->target.sparse = true;
+ }
+
if (is_new_vol &&
VIR_APPEND_ELEMENT(pool->volumes.objs,
pool->volumes.count,
@@ -190,7 +204,7 @@ virStorageBackendZFSFindVols(virStoragePoolObjPtr pool,
cmd = virCommandNewArgList(ZFS,
"list", "-Hp",
"-t", "volume", "-r",
- "-o", "name,volsize",
+ "-o", "name,volsize,refreservation",
pool->def->source.name,
NULL);
virCommandSetOutputBuffer(cmd, &volumes_list);
@@ -320,15 +334,28 @@ virStorageBackendZFSCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
goto cleanup;
/**
* $ zfs create -o volmode=dev -V 10240K test/volname
+ * $ zfs create -o volmode=dev -s -V 10240K test/volname
+ * $ zfs create -o volmode=dev -s -o refreservation=1024K -V 10240K test/volname
*
* -o volmode=dev -- we want to get volumes exposed as cdev
* devices. If we don't specify that zfs
* will lookup vfs.zfs.vol.mode sysctl value
+ * -s -- create a sparse volume
+ * -o refreservation -- reserve the specified amount of space
* -V -- tells to create a volume with the specified size
*/
cmd = virCommandNewArgList(ZFS, "create", NULL);
if (volmode_needed)
virCommandAddArgList(cmd, "-o", "volmode=dev", NULL);
+ if (vol->target.capacity != vol->target.allocation) {
+ virCommandAddArg(cmd, "-s");
+ if (vol->target.allocation > 0) {
+ virCommandAddArg(cmd, "-o");
+ virCommandAddArgFormat(cmd, "refreservation=%lluK",
+ VIR_DIV_UP(vol->target.allocation, 1024));
+ }
+ vol->target.sparse = true;
+ }
virCommandAddArg(cmd, "-V");
virCommandAddArgFormat(cmd, "%lluK",
VIR_DIV_UP(vol->target.capacity, 1024));
--
2.1.4
8 years, 7 months
[libvirt] [PATCH 0/6] vz: misc fixes
by Nikolay Shirokovskiy
Mikhail Feoktistov (2):
vz: handle sourceless cdroms
vz: fix template ct creation
Nikolay Shirokovskiy (4):
vz: remove check for auto file format for disks
vz: fix vzCheckUnsupportedDisks format checks for cdroms
vz: fix error message for readonly fs
vz: make error path code idiomatic
src/vz/vz_sdk.c | 31 ++++++++++++++++++++-----------
src/vz/vz_utils.c | 23 +++++++++--------------
2 files changed, 29 insertions(+), 25 deletions(-)
--
1.8.3.1
8 years, 7 months
[libvirt] [PATCH] virsh: support up to 64 migration options for command
by Nikolay Shirokovskiy
Upcoming compression options for migration command patch
series hits current limit of 32 possible options for a command.
Lets take one step further and support 64 possible options.
And all it takes is moving from 32 bit integers to 64 bit ones.
The only less then trivial change i found is moving from
'ffs' to 'ffsl'.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
---
tools/vsh.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/tools/vsh.c b/tools/vsh.c
index 6bdc082..5659110 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -40,7 +40,6 @@
#include <limits.h>
#include <sys/stat.h>
#include <inttypes.h>
-#include <strings.h>
#include <signal.h>
#if WITH_READLINE
@@ -329,8 +328,8 @@ vshCmddefGetInfo(const vshCmdDef * cmd, const char *name)
/* Validate that the options associated with cmd can be parsed. */
static int
-vshCmddefOptParse(const vshCmdDef *cmd, uint32_t *opts_need_arg,
- uint32_t *opts_required)
+vshCmddefOptParse(const vshCmdDef *cmd, uint64_t *opts_need_arg,
+ uint64_t *opts_required)
{
size_t i;
bool optional = false;
@@ -344,7 +343,7 @@ vshCmddefOptParse(const vshCmdDef *cmd, uint32_t *opts_need_arg,
for (i = 0; cmd->opts[i].name; i++) {
const vshCmdOptDef *opt = &cmd->opts[i];
- if (i > 31)
+ if (i > 63)
return -1; /* too many options */
if (opt->type == VSH_OT_BOOL) {
optional = true;
@@ -407,7 +406,7 @@ static vshCmdOptDef helpopt = {
};
static const vshCmdOptDef *
vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name,
- uint32_t *opts_seen, int *opt_index, char **optstr)
+ uint64_t *opts_seen, int *opt_index, char **optstr)
{
size_t i;
const vshCmdOptDef *ret = NULL;
@@ -464,8 +463,8 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name,
}
static const vshCmdOptDef *
-vshCmddefGetData(const vshCmdDef *cmd, uint32_t *opts_need_arg,
- uint32_t *opts_seen)
+vshCmddefGetData(const vshCmdDef *cmd, uint64_t *opts_need_arg,
+ uint64_t *opts_seen)
{
size_t i;
const vshCmdOptDef *opt;
@@ -474,7 +473,7 @@ vshCmddefGetData(const vshCmdDef *cmd, uint32_t *opts_need_arg,
return NULL;
/* Grab least-significant set bit */
- i = ffs(*opts_need_arg) - 1;
+ i = ffsl(*opts_need_arg) - 1;
opt = &cmd->opts[i];
if (opt->type != VSH_OT_ARGV)
*opts_need_arg &= ~(1 << i);
@@ -486,8 +485,8 @@ vshCmddefGetData(const vshCmdDef *cmd, uint32_t *opts_need_arg,
* Checks for required options
*/
static int
-vshCommandCheckOpts(vshControl *ctl, const vshCmd *cmd, uint32_t opts_required,
- uint32_t opts_seen)
+vshCommandCheckOpts(vshControl *ctl, const vshCmd *cmd, uint64_t opts_required,
+ uint64_t opts_seen)
{
const vshCmdDef *def = cmd->def;
size_t i;
@@ -598,8 +597,8 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname)
const char *desc = vshCmddefGetInfo(def, "desc");
const char *help = _(vshCmddefGetInfo(def, "help"));
char buf[256];
- uint32_t opts_need_arg;
- uint32_t opts_required;
+ uint64_t opts_need_arg;
+ uint64_t opts_required;
bool shortopt = false; /* true if 'arg' works instead of '--opt arg' */
if (vshCmddefOptParse(def, &opts_need_arg, &opts_required)) {
@@ -1350,9 +1349,9 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser)
const vshCmdDef *cmd = NULL;
vshCommandToken tk;
bool data_only = false;
- uint32_t opts_need_arg = 0;
- uint32_t opts_required = 0;
- uint32_t opts_seen = 0;
+ uint64_t opts_need_arg = 0;
+ uint64_t opts_required = 0;
+ uint64_t opts_seen = 0;
first = NULL;
--
1.8.3.1
8 years, 7 months
[libvirt] [PATCH 0/3] qemu: Fix hotplug of guest agent
by Martin Kletzander
Martin Kletzander (3):
qemuhotplugtest: Allow testing of live data
qemu: Move channel path generation out of command creation
qemu: Generate channel target paths on hotplug as well
src/qemu/qemu_command.c | 25 ++--------
src/qemu/qemu_command.h | 5 +-
src/qemu/qemu_domain.c | 19 +++++++
src/qemu/qemu_domain.h | 4 ++
src/qemu/qemu_hotplug.c | 3 ++
src/qemu/qemu_process.c | 12 +++--
tests/qemuhotplugtest.c | 42 ++++++++++++----
.../qemuhotplug-hotplug-base+qemu-agent-detach.xml | 58 ++++++++++++++++++++++
.../qemuhotplug-hotplug-base+qemu-agent.xml | 58 ++++++++++++++++++++++
.../qemuhotplug-qemu-agent-detach.xml | 5 ++
.../qemuhotplugtestdata/qemuhotplug-qemu-agent.xml | 5 ++
11 files changed, 197 insertions(+), 39 deletions(-)
create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+qemu-agent-detach.xml
create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+qemu-agent.xml
create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-qemu-agent-detach.xml
create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-qemu-agent.xml
--
2.8.0
8 years, 7 months
[libvirt] [libxl] shutdown a domain before it finishes starting
by Zhangbo (Oscar)
Hi all:
Suppose we have a guest domain which is pvops, for example, rhel6.4.
Steps to produce the problem:
1 start the guest by virDomainCreate()
2 the API returns before the guest domain fully available, which means, the disks, network interfaces and some import services are not available inside the guest.
3 we call virDomainShutdown() to shutdown the guest.
Expected result:
The guest got shutdown.
The result in fact:
Because the guest is not available when we call virDomainShutdown(), it couldn't respond to our 'shutdown' xenstore request, the guest turns on later, rather than shutting down.
So , the question is:
In libxl_driver( xen-hypervisor environment), how can we tell that the guest is available or not, and is it suitable to shutdown the guest at that moment?
Thanks in advance.
Oscar.
8 years, 7 months
[libvirt] [PATCH] qemuxml2argvtest: Adapt to ethernet automatic tap creation
by Michal Privoznik
After 9c17d665fdc5 the tap device for ethernet network type is
automatically precreated before spawning qemu. Problem is, the
qemuxml2argvtest wasn't updated and thus is failing. Because of
all the APIs that new code is calling, I had to mock a lot. Also,
since the tap FDs are labeled separately from the rest of the
devices/files I had to enable NOP security driver for the test
too.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
There are only 2 problems with this patch. All of them are in
virNetDevTapCreate mock implementation:
1) new tap device has constant name. Even within one domain
2) new tap FDs are constant. Even within one domain
I'm unable to come with better approach though. Having a static variable that
is incremented each time the mock is called would not fly as it will give
different results when combined with VIR_TEST_RANGE.
Therefore I assume we are good so far with these two limitations.
cfg.mk | 2 +-
tests/qemuhotplugtest.c | 7 ----
.../qemuxml2argv-graphics-spice-timeout.args | 2 +-
.../qemuxml2argv-net-eth-ifname.args | 2 +-
.../qemuxml2argv-net-eth-names.args | 4 +-
tests/qemuxml2argvdata/qemuxml2argv-net-eth.args | 2 +-
tests/qemuxml2argvmock.c | 49 ++++++++++++++++++++--
tests/testutilsqemu.c | 9 ++++
8 files changed, 61 insertions(+), 16 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 6f28eef..f5573db 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -1139,7 +1139,7 @@ exclude_file_name_regexp--sc_copyright_usage = \
^COPYING(|\.LESSER)$$
exclude_file_name_regexp--sc_flags_usage = \
- ^(docs/|src/util/virnetdevtap\.c$$|tests/(vir(cgroup|pci|usb)|nss)mock\.c$$)
+ ^(docs/|src/util/virnetdevtap\.c$$|tests/(vir(cgroup|pci|usb)|nss|qemuxml2argv)mock\.c$$)
exclude_file_name_regexp--sc_libvirt_unmarked_diagnostics = \
^(src/rpc/gendispatch\.pl$$|tests/)
diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index 2298a68..1eb2b6a 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -341,7 +341,6 @@ mymain(void)
{
int ret = 0;
struct qemuHotplugTestData data = {0};
- virSecurityManagerPtr mgr;
#if !WITH_YAJL
fputs("libvirt not compiled with yajl, skipping this test\n", stderr);
@@ -369,12 +368,6 @@ mymain(void)
if (!driver.lockManager)
return EXIT_FAILURE;
- if (!(mgr = virSecurityManagerNew("none", "qemu",
- VIR_SECURITY_MANAGER_PRIVILEGED)))
- return EXIT_FAILURE;
- if (!(driver.securityManager = virSecurityManagerNewStack(mgr)))
- return EXIT_FAILURE;
-
/* wait only 100ms for DEVICE_DELETED event */
qemuDomainRemoveDeviceWaitTime = 100;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args
index 7ca17ae..8a29a7e 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args
@@ -26,7 +26,7 @@ id=virtio-disk0 \
media=cdrom,id=drive-ide0-1-0 \
-device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \
-device rtl8139,vlan=0,id=net0,mac=52:54:00:71:70:89,bus=pci.0,addr=0x7 \
--net tap,script=/etc/qemu-ifup,vlan=0,name=hostnet0 \
+-net tap,fd=3,vlan=0,name=hostnet0 \
-serial pty \
-device usb-tablet,id=input0 \
-spice port=5900 \
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.args b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.args
index 22d6dd0..b96c933 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.args
@@ -20,4 +20,4 @@ QEMU_AUDIO_DRV=none \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
-device rtl8139,vlan=0,id=net0,mac=00:11:22:33:44:55,bus=pci.0,addr=0x3 \
--net tap,ifname=nic02,script=/etc/qemu-ifup,vlan=0,name=hostnet0
+-net tap,fd=3,vlan=0,name=hostnet0
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-eth-names.args b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-names.args
index 0704178..a2c3f87 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-eth-names.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-names.args
@@ -20,7 +20,7 @@ QEMU_AUDIO_DRV=none \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
-device rtl8139,vlan=0,id=net0,mac=00:11:22:33:44:55,bus=pci.0,addr=0x3 \
--net tap,script=/etc/qemu-ifup,vlan=0,name=hostnet0 \
+-net tap,fd=3,vlan=0,name=hostnet0 \
-device e1000,vlan=1,id=net1,mac=00:11:22:33:44:56,bus=pci.0,addr=0x4 \
--net tap,script=/etc/qemu-ifup,vlan=1,name=hostnet1 \
+-net tap,fd=3,vlan=1,name=hostnet1 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-eth.args b/tests/qemuxml2argvdata/qemuxml2argv-net-eth.args
index b69cf52..b96c933 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-eth.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-eth.args
@@ -20,4 +20,4 @@ QEMU_AUDIO_DRV=none \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
-device rtl8139,vlan=0,id=net0,mac=00:11:22:33:44:55,bus=pci.0,addr=0x3 \
--net tap,script=/etc/qemu-ifup,vlan=0,name=hostnet0
+-net tap,fd=3,vlan=0,name=hostnet0
diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
index b7dfebb..e2c19a6 100644
--- a/tests/qemuxml2argvmock.c
+++ b/tests/qemuxml2argvmock.c
@@ -21,12 +21,15 @@
#include <config.h>
#include "internal.h"
-#include "virnuma.h"
+#include "vircommand.h"
#include "virmock.h"
-#include "virutil.h"
+#include "virnetdev.h"
+#include "virnetdevtap.h"
+#include "virnuma.h"
+#include "virscsi.h"
#include "virstring.h"
#include "virtpm.h"
-#include "virscsi.h"
+#include "virutil.h"
#include <time.h>
#include <unistd.h>
@@ -98,3 +101,43 @@ virSCSIDeviceGetSgName(const char *sysfs_prefix ATTRIBUTE_UNUSED,
ignore_value(VIR_STRDUP(ret, "sg0"));
return ret;
}
+
+int
+virNetDevTapCreate(char **ifname,
+ const char *tunpath ATTRIBUTE_UNUSED,
+ int *tapfd,
+ size_t tapfdSize,
+ unsigned int flags ATTRIBUTE_UNUSED)
+{
+ size_t i;
+
+ for (i = 0; i < tapfdSize; i++)
+ tapfd[i] = STDERR_FILENO + 1 + i;
+
+ return VIR_STRDUP(*ifname, "vnet0");
+}
+
+int
+virNetDevSetMAC(const char *ifname ATTRIBUTE_UNUSED,
+ const virMacAddr *macaddr ATTRIBUTE_UNUSED)
+{
+ return 0;
+}
+
+int
+virCommandRun(virCommandPtr cmd ATTRIBUTE_UNUSED,
+ int *exitstatus)
+{
+ if (exitstatus)
+ *exitstatus = 0;
+
+ return 0;
+}
+
+void
+virCommandPassFD(virCommandPtr cmd ATTRIBUTE_UNUSED,
+ int fd ATTRIBUTE_UNUSED,
+ unsigned int flags ATTRIBUTE_UNUSED)
+{
+ /* nada */
+}
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 1f854f5..eb4c6c8 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -555,6 +555,8 @@ int qemuTestCapsCacheInsert(virQEMUCapsCachePtr cache, const char *binary,
int qemuTestDriverInit(virQEMUDriver *driver)
{
+ virSecurityManagerPtr mgr = NULL;
+
memset(driver, 0, sizeof(*driver));
if (virMutexInit(&driver->lock) < 0)
@@ -588,9 +590,16 @@ int qemuTestDriverInit(virQEMUDriver *driver)
if (qemuTestCapsCacheInsert(driver->qemuCapsCache, "empty", NULL) < 0)
goto error;
+ if (!(mgr = virSecurityManagerNew("none", "qemu",
+ VIR_SECURITY_MANAGER_PRIVILEGED)))
+ goto error;
+ if (!(driver->securityManager = virSecurityManagerNewStack(mgr)))
+ goto error;
+
return 0;
error:
+ virObjectUnref(mgr);
qemuTestDriverFree(driver);
return -1;
}
--
2.7.3
8 years, 7 months
[libvirt] [PATCH 00/15] support for pxb and pxb-pcie controllers
by Laine Stump
These two controllers are used to create a new root bus on a 440fx
(pxb) or q35 (pxb-pie) virtual machine. There may be other use cases,
but the main reason for me taking the time to support a separate root
bus is to have assigned devices be visible in the guest on a different
NUMA node, so that the guest can be aware of the locality of the
device wrt CPU and memory that are on different NUMA nodes - although
you aren't required to, you can add a <node>N</node> subelement to the
bus' <target> element to indicate which NUMA node it is on (it's up to
the management application to place devices on that bus that really
are on the given NUMA node in the host).
There are several differences between pxb and pxb-pcie, which are
detailed in the individual commit log messages, but in short:
1) pxb is for 440fx, pxb-pcie for q35 (they *might* work on other
arches/machinetypes that have a PCI or PCIe bus, but I haven't enabled
that)
2) pxb has an integrate d pci-bridge with 32 slots that are (should
be) hotplug-capable, while pxb-pcie supplies only a single slot, and
it will only accept a pcie-root-port (which will then accept a single
device, hotplug-capable) or a pcie-switch-upstream-port.
Along the way I encountered a few minor problems/ugliness that I took
care of in patches 01/15 - 09/15. pxb support is in 10-12, and
pxb-pcie is in 13-15
There is a bugzilla record associated with this:
https://bugzilla.redhat.com/show_bug.cgi?id=1103314
Laine Stump (15):
schema: make pci slot and function optional
schema: rename uint8range/uint24range to uint8/uint24
schema: new basic type - uint16
schema: allow pci address attributes to be in decimal
conf: use #define instead of literal for highest slot in upstream port
conf: allow use of slot 0 in a dmi-to-pci-bridge
conf/qemu: change the way VIR_PCI_CONNECT_TYPE_* flags work
conf: utility function to convert PCI controller model into connect
type
qemu: set PCI controller default modelName in a separate function
qemu: add capabilities bit for device "pxb"
conf: new pci controller model pci-expander-bus
qemu: support new pci controller model "pci-expander-bus"
qemu: add capabilities bit for device "pxb-pcie"
conf: new pci controller model pcie-expander-bus
qemu: support new pci controller model "pcie-expander-bus"
docs/formatdomain.html.in | 74 +++-
docs/schemas/basictypes.rng | 63 ++--
docs/schemas/domaincommon.rng | 23 +-
docs/schemas/networkcommon.rng | 12 +-
docs/schemas/nwfilter.rng | 16 +-
src/bhyve/bhyve_device.c | 10 +-
src/conf/domain_addr.c | 119 +++++--
src/conf/domain_addr.h | 68 ++--
src/conf/domain_conf.c | 61 +++-
src/conf/domain_conf.h | 11 +-
src/libvirt_private.syms | 1 +
src/qemu/qemu_capabilities.c | 4 +
src/qemu/qemu_capabilities.h | 2 +
src/qemu/qemu_command.c | 74 ++++
src/qemu/qemu_domain.c | 42 +++
src/qemu/qemu_domain_address.c | 305 +++++++++-------
tests/qemucapabilitiesdata/caps_2.4.0-1.caps | 1 +
tests/qemucapabilitiesdata/caps_2.5.0-1.caps | 1 +
tests/qemucapabilitiesdata/caps_2.6.0-1.caps | 2 +
tests/qemucapabilitiesdata/caps_2.6.0-1.replies | 3 +
.../qemuxml2argv-aarch64-virtio-pci-default.args | 2 +-
...l2argv-aarch64-virtio-pci-manual-addresses.args | 2 +-
.../qemuxml2argv-pci-expander-bus-bad-machine.xml | 167 +++++++++
.../qemuxml2argv-pci-expander-bus-bad-node.xml | 160 +++++++++
.../qemuxml2argv-pci-expander-bus.args | 87 +++++
.../qemuxml2argv-pci-expander-bus.xml | 167 +++++++++
.../qemuxml2argv-pcie-expander-bus-bad-machine.xml | 36 ++
.../qemuxml2argv-pcie-expander-bus.args | 123 +++++++
.../qemuxml2argv-pcie-expander-bus.xml | 247 +++++++++++++
.../qemuxml2argv-pcie-root-port.args | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-pcie-root.args | 2 +-
.../qemuxml2argv-pcie-switch-downstream-port.args | 2 +-
.../qemuxml2argv-pcie-switch-upstream-port.args | 2 +-
.../qemuxml2argv-pcihole64-q35.args | 2 +-
.../qemuxml2argv-q35-pm-disable-fallback.args | 2 +-
.../qemuxml2argv-q35-pm-disable.args | 2 +-
.../qemuxml2argv-q35-usb2-multi.args | 2 +-
.../qemuxml2argv-q35-usb2-reorder.args | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-q35-usb2.args | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-q35.args | 2 +-
.../qemuxml2argv-usb-controller-default-q35.args | 2 +-
.../qemuxml2argv-usb-controller-explicit-q35.args | 2 +-
tests/qemuxml2argvtest.c | 25 ++
.../qemuxml2xmlout-aarch64-virtio-pci-default.xml | 2 +-
...2xmlout-aarch64-virtio-pci-manual-addresses.xml | 2 +-
.../qemuxml2xmlout-pci-expander-bus.xml | 207 +++++++++++
.../qemuxml2xmlout-pcie-expander-bus.xml | 384 +++++++++++++++++++++
.../qemuxml2xmlout-pcie-root-port.xml | 2 +-
.../qemuxml2xmlout-pcie-root.xml | 2 +-
.../qemuxml2xmlout-pcie-switch-downstream-port.xml | 2 +-
.../qemuxml2xmlout-pcie-switch-upstream-port.xml | 2 +-
.../qemuxml2xmlout-pcihole64-q35.xml | 2 +-
.../qemuxml2xmlout-q35-usb2-multi.xml | 2 +-
.../qemuxml2xmlout-q35-usb2-reorder.xml | 2 +-
.../qemuxml2xmloutdata/qemuxml2xmlout-q35-usb2.xml | 2 +-
tests/qemuxml2xmloutdata/qemuxml2xmlout-q35.xml | 2 +-
tests/qemuxml2xmltest.c | 10 +
57 files changed, 2296 insertions(+), 261 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus-bad-machine.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus-bad-node.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-expander-bus-bad-machine.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-expander-bus.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-expander-bus.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-expander-bus.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-pcie-expander-bus.xml
--
2.5.5
8 years, 7 months
[libvirt] [PATCH/GSoC] Use virGetLastErrorMessage() rather than open code it
by Hui Yiqun
getting err using virGetLastError() and then retrieving
message from err make developer have to test the value
of err and err->message and default to self-defined
unkown error message.
It's better to avoid it and using uniform
virGetLastErrorMessage
---
daemon/libvirtd.c | 8 +---
examples/object-events/event-test.c | 9 ++---
src/bhyve/bhyve_driver.c | 3 +-
src/libvirt.c | 3 +-
src/libxl/libxl_domain.c | 3 +-
src/libxl/libxl_driver.c | 3 +-
src/locking/lock_daemon.c | 8 +---
src/logging/log_daemon.c | 8 +---
src/lxc/lxc_container.c | 8 +---
src/lxc/lxc_controller.c | 7 +---
src/lxc/lxc_domain.c | 3 +-
src/lxc/lxc_process.c | 6 +--
src/network/bridge_driver.c | 3 +-
src/node_device/node_device_hal.c | 3 +-
src/rpc/virnettlscontext.c | 3 +-
src/secret/secret_driver.c | 6 +--
src/storage/storage_driver.c | 16 ++------
src/uml/uml_driver.c | 3 +-
src/util/iohelper.c | 8 +---
src/util/virhook.c | 3 +-
src/util/virhostdev.c | 20 ++++-----
src/util/virpci.c | 4 +-
tests/commandtest.c | 81 +++++++++++++------------------------
tests/libvirtdconftest.c | 3 +-
tests/openvzutilstest.c | 6 +--
tests/securityselinuxlabeltest.c | 6 +--
tests/securityselinuxtest.c | 6 +--
tests/virnettlscontexttest.c | 3 +-
28 files changed, 75 insertions(+), 168 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 3d38a46..e526e55 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1273,12 +1273,8 @@ int main(int argc, char **argv) {
/* Read the config file if it exists*/
if (remote_config_file &&
daemonConfigLoadFile(config, remote_config_file, implicit_conf) < 0) {
- virErrorPtr err = virGetLastError();
- if (err && err->message)
- VIR_ERROR(_("Can't load config file: %s: %s"),
- err->message, remote_config_file);
- else
- VIR_ERROR(_("Can't load config file: %s"), remote_config_file);
+ VIR_ERROR(_("Can't load config file: %s: %s"),
+ virGetLastErrorMessage(), remote_config_file);
exit(EXIT_FAILURE);
}
diff --git a/examples/object-events/event-test.c b/examples/object-events/event-test.c
index 7be1d21..4a4ef86 100644
--- a/examples/object-events/event-test.c
+++ b/examples/object-events/event-test.c
@@ -654,9 +654,8 @@ int main(int argc, char **argv)
}
if (virEventRegisterDefaultImpl() < 0) {
- virErrorPtr err = virGetLastError();
fprintf(stderr, "Failed to register event implementation: %s\n",
- err && err->message ? err->message: "Unknown error");
+ virGetLastErrorMessage());
goto cleanup;
}
@@ -794,17 +793,15 @@ int main(int argc, char **argv)
goto cleanup;
if (virConnectSetKeepAlive(dconn, 5, 3) < 0) {
- virErrorPtr err = virGetLastError();
fprintf(stderr, "Failed to start keepalive protocol: %s\n",
- err && err->message ? err->message : "Unknown error");
+ virGetLastErrorMessage());
run = 0;
}
while (run) {
if (virEventRunDefaultImpl() < 0) {
- virErrorPtr err = virGetLastError();
fprintf(stderr, "Failed to run event loop: %s\n",
- err && err->message ? err->message : "Unknown error");
+ virGetLastErrorMessage());
}
}
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 9219890..6f2423c 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -88,9 +88,8 @@ bhyveAutostartDomain(virDomainObjPtr vm, void *opaque)
ret = virBhyveProcessStart(data->conn, data->driver, vm,
VIR_DOMAIN_RUNNING_BOOTED, 0);
if (ret < 0) {
- virErrorPtr err = virGetLastError();
VIR_ERROR(_("Failed to autostart VM '%s': %s"),
- vm->def->name, err ? err->message : _("unknown error"));
+ vm->def->name, virGetLastErrorMessage());
}
}
virObjectUnlock(vm);
diff --git a/src/libvirt.c b/src/libvirt.c
index dd58e9c..99b1c47 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -777,10 +777,9 @@ virStateInitialize(bool privileged,
if (virStateDriverTab[i]->stateInitialize(privileged,
callback,
opaque) < 0) {
- virErrorPtr err = virGetLastError();
VIR_ERROR(_("Initialization of %s state driver failed: %s"),
virStateDriverTab[i]->name,
- err && err->message ? err->message : _("Unknown problem"));
+ virGetLastErrorMessage());
return -1;
}
}
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index c8d09b1..a814ae5 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -514,9 +514,8 @@ libxlDomainShutdownThread(void *opaque)
libxlDomainDestroyInternal(driver, vm);
libxlDomainCleanup(driver, vm);
if (libxlDomainStart(driver, vm, false, -1) < 0) {
- virErrorPtr err = virGetLastError();
VIR_ERROR(_("Failed to restart VM '%s': %s"),
- vm->def->name, err ? err->message : _("unknown error"));
+ vm->def->name, virGetLastErrorMessage());
}
endjob:
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 87ec5a5..767ebbc 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -324,10 +324,9 @@ libxlAutostartDomain(virDomainObjPtr vm,
if (vm->autostart && !virDomainObjIsActive(vm) &&
libxlDomainStart(driver, vm, false, -1) < 0) {
- err = virGetLastError();
VIR_ERROR(_("Failed to autostart VM '%s': %s"),
vm->def->name,
- err ? err->message : _("unknown error"));
+ virGetLastErrorMessage());
goto endjob;
}
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index 973e691..b755a02 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -1266,12 +1266,8 @@ int main(int argc, char **argv) {
/* Read the config file if it exists*/
if (remote_config_file &&
virLockDaemonConfigLoadFile(config, remote_config_file, implicit_conf) < 0) {
- virErrorPtr err = virGetLastError();
- if (err && err->message)
- VIR_ERROR(_("Can't load config file: %s: %s"),
- err->message, remote_config_file);
- else
- VIR_ERROR(_("Can't load config file: %s"), remote_config_file);
+ VIR_ERROR(_("Can't load config file: %s: %s"),
+ virGetLastErrorMessage(), remote_config_file);
exit(EXIT_FAILURE);
}
diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c
index 68f0647..83f0475 100644
--- a/src/logging/log_daemon.c
+++ b/src/logging/log_daemon.c
@@ -1023,12 +1023,8 @@ int main(int argc, char **argv) {
/* Read the config file if it exists*/
if (remote_config_file &&
virLogDaemonConfigLoadFile(config, remote_config_file, implicit_conf) < 0) {
- virErrorPtr err = virGetLastError();
- if (err && err->message)
- VIR_ERROR(_("Can't load config file: %s: %s"),
- err->message, remote_config_file);
- else
- VIR_ERROR(_("Can't load config file: %s"), remote_config_file);
+ VIR_ERROR(_("Can't load config file: %s: %s"),
+ virGetLastErrorMessage(), remote_config_file);
exit(EXIT_FAILURE);
}
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 348bbfb..4daba3a 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -2290,12 +2290,8 @@ static int lxcContainerChild(void *data)
if (ret != 0) {
VIR_DEBUG("Tearing down container");
- virErrorPtr err = virGetLastError();
- if (err && err->message)
- fprintf(stderr, "%s\n", err->message);
- else
- fprintf(stderr, "%s\n",
- _("Unknown failure in libvirt_lxc startup"));
+ fprintf(stderr, "Failure in libvirt_lxc startup%s\n",
+ virGetLastErrorMessage());
}
virCommandFree(cmd);
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 8b5ec4c..b20a46f 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -2731,12 +2731,7 @@ int main(int argc, char *argv[])
cleanup:
if (rc < 0) {
- virErrorPtr err = virGetLastError();
- if (err && err->message)
- fprintf(stderr, "%s\n", err->message);
- else
- fprintf(stderr, "%s\n",
- _("Unknown failure in libvirt_lxc startup"));
+ fprintf(stderr, "Failure in libvirt_lxc startup: %s\n", virGetLastErrorMessage());
}
virPidFileDelete(LXC_STATE_DIR, name);
diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c
index 3177a62..5267797 100644
--- a/src/lxc/lxc_domain.c
+++ b/src/lxc/lxc_domain.c
@@ -221,8 +221,7 @@ virLXCDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
unsigned long long thepid;
if (virXPathULongLong("string(./init[1]/@pid)", ctxt, &thepid) < 0) {
- virErrorPtr err = virGetLastError();
- VIR_WARN("Failed to load init pid from state %s", err ? err->message : "null");
+ VIR_WARN("Failed to load init pid from state %s", virGetLastErrorMessage());
priv->initpid = 0;
} else {
priv->initpid = thepid;
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 5e0bbe2..6f6df84 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -757,10 +757,9 @@ static void virLXCProcessMonitorInitNotify(virLXCMonitorPtr mon ATTRIBUTE_UNUSED
priv->initpid = initpid;
if (virLXCProcessGetNsInode(initpid, "pid", &inode) < 0) {
- virErrorPtr err = virGetLastError();
VIR_WARN("Cannot obtain pid NS inode for %llu: %s",
(unsigned long long)initpid,
- err && err->message ? err->message : "<unknown>");
+ virGetLastErrorMessage());
virResetLastError();
}
virDomainAuditInit(vm, initpid, inode);
@@ -1619,10 +1618,9 @@ virLXCProcessAutostartDomain(virDomainObjPtr vm,
VIR_DOMAIN_RUNNING_BOOTED);
virDomainAuditStart(vm, "booted", ret >= 0);
if (ret < 0) {
- virErrorPtr err = virGetLastError();
VIR_ERROR(_("Failed to autostart VM '%s': %s"),
vm->def->name,
- err ? err->message : "");
+ virGetLastErrorMessage());
} else {
virObjectEventPtr event =
virDomainEventLifecycleNewFromObj(vm,
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index a09a7e4..f82ad24 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -694,9 +694,8 @@ networkStateInitialize(bool privileged,
#ifdef HAVE_FIREWALLD
if (!(sysbus = virDBusGetSystemBus())) {
- virErrorPtr err = virGetLastError();
VIR_WARN("DBus not available, disabling firewalld support "
- "in bridge_network_driver: %s", err->message);
+ "in bridge_network_driver: %s", virGetLastErrorMessage());
} else {
/* add matches for
* NameOwnerChanged on org.freedesktop.DBus for firewalld start/stop
diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c
index 6d18a87..6ddfad0 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -641,9 +641,8 @@ nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED,
dbus_error_init(&err);
if (!(sysbus = virDBusGetSystemBus())) {
- virErrorPtr verr = virGetLastError();
VIR_ERROR(_("DBus not available, disabling HAL driver: %s"),
- verr->message);
+ virGetLastErrorMessage());
ret = 0;
goto failure;
}
diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c
index 947038d..6e78623 100644
--- a/src/rpc/virnettlscontext.c
+++ b/src/rpc/virnettlscontext.c
@@ -1141,8 +1141,7 @@ int virNetTLSContextCheckCertificate(virNetTLSContextPtr ctxt,
virObjectLock(ctxt);
virObjectLock(sess);
if (virNetTLSContextValidCertificate(ctxt, sess) < 0) {
- virErrorPtr err = virGetLastError();
- VIR_WARN("Certificate check failed %s", err && err->message ? err->message : "<unknown>");
+ VIR_WARN("Certificate check failed %s", virGetLastErrorMessage());
if (ctxt->requireValidCert) {
virReportError(VIR_ERR_AUTH_FAILED, "%s",
_("Failed to verify peer's certificate"));
diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c
index 4d15797..b9c82c6 100644
--- a/src/secret/secret_driver.c
+++ b/src/secret/secret_driver.c
@@ -484,11 +484,9 @@ secretLoadAllConfigs(virSecretObjPtr *dest,
VIR_FREE(base64name);
if (!(secret = secretLoad(&list, de->d_name, path, base64path))) {
- virErrorPtr err = virGetLastError();
-
VIR_ERROR(_("Error reading secret: %s"),
- err != NULL ? err->message: _("unknown error"));
- virResetError(err);
+ virGetLastErrorMessage());
+ virResetLastError();
VIR_FREE(path);
VIR_FREE(base64path);
continue;
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 1d96618..ccf1fc1 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -97,10 +97,8 @@ storagePoolUpdateState(virStoragePoolObjPtr pool)
active = false;
if (backend->checkPool &&
backend->checkPool(pool, &active) < 0) {
- virErrorPtr err = virGetLastError();
VIR_ERROR(_("Failed to initialize storage pool '%s': %s"),
- pool->def->name, err ? err->message :
- _("no error message found"));
+ pool->def->name, virGetLastErrorMessage());
goto error;
}
@@ -111,12 +109,10 @@ storagePoolUpdateState(virStoragePoolObjPtr pool)
if (active) {
virStoragePoolObjClearVols(pool);
if (backend->refreshPool(NULL, pool) < 0) {
- virErrorPtr err = virGetLastError();
if (backend->stopPool)
backend->stopPool(NULL, pool);
VIR_ERROR(_("Failed to restart storage pool '%s': %s"),
- pool->def->name, err ? err->message :
- _("no error message found"));
+ pool->def->name, virGetLastErrorMessage());
goto error;
}
}
@@ -175,10 +171,8 @@ storageDriverAutostart(void)
!virStoragePoolObjIsActive(pool)) {
if (backend->startPool &&
backend->startPool(conn, pool) < 0) {
- virErrorPtr err = virGetLastError();
VIR_ERROR(_("Failed to autostart storage pool '%s': %s"),
- pool->def->name, err ? err->message :
- _("no error message found"));
+ pool->def->name, virGetLastErrorMessage());
virStoragePoolObjUnlock(pool);
continue;
}
@@ -194,14 +188,12 @@ storageDriverAutostart(void)
if (!stateFile ||
virStoragePoolSaveState(stateFile, pool->def) < 0 ||
backend->refreshPool(conn, pool) < 0) {
- virErrorPtr err = virGetLastError();
if (stateFile)
unlink(stateFile);
if (backend->stopPool)
backend->stopPool(conn, pool);
VIR_ERROR(_("Failed to autostart storage pool '%s': %s"),
- pool->def->name, err ? err->message :
- _("no error message found"));
+ pool->def->name, virGetLastErrorMessage());
} else {
pool->active = true;
}
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 84e1df8..923c3f6 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -188,9 +188,8 @@ umlAutostartDomain(virDomainObjPtr vm,
ret = umlStartVMDaemon(data->conn, data->driver, vm, false);
virDomainAuditStart(vm, "booted", ret >= 0);
if (ret < 0) {
- virErrorPtr err = virGetLastError();
VIR_ERROR(_("Failed to autostart VM '%s': %s"),
- vm->def->name, err ? err->message : _("unknown error"));
+ vm->def->name, virGetLastErrorMessage());
} else {
virObjectEventPtr event =
virDomainEventLifecycleNewFromObj(vm,
diff --git a/src/util/iohelper.c b/src/util/iohelper.c
index 8a3c377..9fe0f81 100644
--- a/src/util/iohelper.c
+++ b/src/util/iohelper.c
@@ -310,12 +310,6 @@ main(int argc, char **argv)
return 0;
error:
- err = virGetLastError();
- if (err) {
- fprintf(stderr, "%s: %s\n", program_name, err->message);
- } else {
- fprintf(stderr, _("%s: unknown failure with %s\n"),
- program_name, path);
- }
+ fprintf(stderr, "%s: %s\n", program_name, virGetLastErrorMessage());
exit(EXIT_FAILURE);
}
diff --git a/src/util/virhook.c b/src/util/virhook.c
index ba50598..d37d6da 100644
--- a/src/util/virhook.c
+++ b/src/util/virhook.c
@@ -297,9 +297,8 @@ virHookCall(int driver,
ret = virCommandRun(cmd, NULL);
if (ret < 0) {
/* Convert INTERNAL_ERROR into known error. */
- virErrorPtr err = virGetLastError();
virReportError(VIR_ERR_HOOK_SCRIPT_FAILED, "%s",
- err ? err->message : _("unknown error"));
+ virGetLastErrorMessage());
}
virCommandFree(cmd);
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index b397b79..42c146a 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -801,10 +801,9 @@ virHostdevReattachPCIDevice(virHostdevManagerPtr mgr,
VIR_DEBUG("Reattaching PCI device %s", virPCIDeviceGetName(actual));
if (virPCIDeviceReattach(actual, mgr->activePCIHostdevs,
mgr->inactivePCIHostdevs) < 0) {
- virErrorPtr err = virGetLastError();
VIR_ERROR(_("Failed to re-attach PCI device: %s"),
- err ? err->message : _("unknown error"));
- virResetError(err);
+ virGetLastErrorMessage());
+ virResetLastError();
}
}
@@ -829,10 +828,9 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr,
virObjectLock(mgr->inactivePCIHostdevs);
if (!(pcidevs = virHostdevGetPCIHostDeviceList(hostdevs, nhostdevs))) {
- virErrorPtr err = virGetLastError();
VIR_ERROR(_("Failed to allocate PCI device list: %s"),
- err ? err->message : _("unknown error"));
- virResetError(err);
+ virGetLastErrorMessage());
+ virResetLastError();
goto cleanup;
}
@@ -883,10 +881,9 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr,
if (!actual ||
virPCIDeviceListAdd(mgr->inactivePCIHostdevs, actual) < 0) {
- virErrorPtr err = virGetLastError();
VIR_ERROR(_("Failed to add PCI device %s to the inactive list"),
- err ? err->message : _("unknown error"));
- virResetError(err);
+ virGetLastErrorMessage());
+ virResetLastError();
}
}
@@ -928,10 +925,9 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr,
VIR_DEBUG("Resetting PCI device %s", virPCIDeviceGetName(pci));
if (virPCIDeviceReset(pci, mgr->activePCIHostdevs,
mgr->inactivePCIHostdevs) < 0) {
- virErrorPtr err = virGetLastError();
VIR_ERROR(_("Failed to reset PCI device: %s"),
- err ? err->message : _("unknown error"));
- virResetError(err);
+ virGetLastErrorMessage());
+ virResetLastError();
}
}
diff --git a/src/util/virpci.c b/src/util/virpci.c
index f7921f8..2349d7f 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -989,12 +989,10 @@ virPCIDeviceReset(virPCIDevicePtr dev,
ret = virPCIDeviceTrySecondaryBusReset(dev, fd, inactiveDevs);
if (ret < 0) {
- virErrorPtr err = virGetLastError();
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to reset PCI device %s: %s"),
dev->name,
- err ? err->message :
- _("no FLR, PM reset or bus reset available"));
+ virGetLastErrorMessage());
}
cleanup:
diff --git a/tests/commandtest.c b/tests/commandtest.c
index cf5f44a..6430e20 100644
--- a/tests/commandtest.c
+++ b/tests/commandtest.c
@@ -178,8 +178,7 @@ static int test2(const void *unused ATTRIBUTE_UNUSED)
int ret;
if (virCommandRun(cmd, NULL) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
virCommandFree(cmd);
return -1;
}
@@ -190,8 +189,7 @@ static int test2(const void *unused ATTRIBUTE_UNUSED)
}
if (virCommandRun(cmd, NULL) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
virCommandFree(cmd);
return -1;
}
@@ -218,8 +216,7 @@ static int test3(const void *unused ATTRIBUTE_UNUSED)
VIR_COMMAND_PASS_FD_CLOSE_PARENT);
if (virCommandRun(cmd, NULL) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
goto cleanup;
}
@@ -260,8 +257,7 @@ static int test4(const void *unused ATTRIBUTE_UNUSED)
virCommandDaemonize(cmd);
if (virCommandRun(cmd, NULL) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
goto cleanup;
}
@@ -294,8 +290,7 @@ static int test5(const void *unused ATTRIBUTE_UNUSED)
virCommandAddEnvPassCommon(cmd);
if (virCommandRun(cmd, NULL) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
virCommandFree(cmd);
return -1;
}
@@ -318,8 +313,7 @@ static int test6(const void *unused ATTRIBUTE_UNUSED)
virCommandAddEnvPassBlockSUID(cmd, "DOESNOTEXIST", NULL);
if (virCommandRun(cmd, NULL) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
virCommandFree(cmd);
return -1;
}
@@ -343,8 +337,7 @@ static int test7(const void *unused ATTRIBUTE_UNUSED)
virCommandAddEnvPassBlockSUID(cmd, "DOESNOTEXIST", NULL);
if (virCommandRun(cmd, NULL) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
virCommandFree(cmd);
return -1;
}
@@ -368,8 +361,7 @@ static int test8(const void *unused ATTRIBUTE_UNUSED)
virCommandAddEnvPair(cmd, "USER", "test");
if (virCommandRun(cmd, NULL) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
virCommandFree(cmd);
return -1;
}
@@ -406,8 +398,7 @@ static int test9(const void *unused ATTRIBUTE_UNUSED)
}
if (virCommandRun(cmd, NULL) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
virCommandFree(cmd);
return -1;
}
@@ -432,8 +423,7 @@ static int test10(const void *unused ATTRIBUTE_UNUSED)
virCommandAddArgSet(cmd, args);
if (virCommandRun(cmd, NULL) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
virCommandFree(cmd);
return -1;
}
@@ -456,8 +446,7 @@ static int test11(const void *unused ATTRIBUTE_UNUSED)
virCommandPtr cmd = virCommandNewArgs(args);
if (virCommandRun(cmd, NULL) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
virCommandFree(cmd);
return -1;
}
@@ -478,8 +467,7 @@ static int test12(const void *unused ATTRIBUTE_UNUSED)
virCommandSetInputBuffer(cmd, "Hello World\n");
if (virCommandRun(cmd, NULL) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
virCommandFree(cmd);
return -1;
}
@@ -506,8 +494,7 @@ static int test13(const void *unused ATTRIBUTE_UNUSED)
virCommandSetOutputBuffer(cmd, &outactual);
if (virCommandRun(cmd, NULL) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
goto cleanup;
}
if (!outactual)
@@ -559,8 +546,7 @@ static int test14(const void *unused ATTRIBUTE_UNUSED)
virCommandSetErrorBuffer(cmd, &erractual);
if (virCommandRun(cmd, NULL) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
goto cleanup;
}
if (!outactual || !erractual)
@@ -573,8 +559,7 @@ static int test14(const void *unused ATTRIBUTE_UNUSED)
virCommandSetOutputBuffer(cmd, &jointactual);
virCommandSetErrorBuffer(cmd, &jointactual);
if (virCommandRun(cmd, NULL) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
goto cleanup;
}
if (!jointactual)
@@ -620,8 +605,7 @@ static int test15(const void *unused ATTRIBUTE_UNUSED)
virCommandSetUmask(cmd, 002);
if (virCommandRun(cmd, NULL) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
goto cleanup;
}
@@ -651,8 +635,7 @@ static int test16(const void *unused ATTRIBUTE_UNUSED)
virCommandAddArg(cmd, "G H");
if ((outactual = virCommandToString(cmd)) == NULL) {
- virErrorPtr err = virGetLastError();
- printf("Cannot convert to string: %s\n", err->message);
+ printf("Cannot convert to string: %s\n", virGetLastErrorMessage());
goto cleanup;
}
if ((fd = open(abs_builddir "/commandhelper.log",
@@ -697,8 +680,7 @@ static int test17(const void *unused ATTRIBUTE_UNUSED)
}
if (virCommandRun(cmd, NULL) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
goto cleanup;
}
@@ -720,8 +702,7 @@ static int test17(const void *unused ATTRIBUTE_UNUSED)
}
if (virCommandRun(cmd, NULL) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
goto cleanup;
}
@@ -756,8 +737,7 @@ static int test18(const void *unused ATTRIBUTE_UNUSED)
alarm(5);
if (virCommandRun(cmd, NULL) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
goto cleanup;
}
alarm(0);
@@ -798,8 +778,7 @@ static int test19(const void *unused ATTRIBUTE_UNUSED)
alarm(5);
if (virCommandRunAsync(cmd, &pid) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
goto cleanup;
}
@@ -848,8 +827,7 @@ static int test20(const void *unused ATTRIBUTE_UNUSED)
virCommandSetInputBuffer(cmd, buf);
if (virCommandRun(cmd, NULL) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
goto cleanup;
}
@@ -891,8 +869,7 @@ static int test21(const void *unused ATTRIBUTE_UNUSED)
virCommandDoAsyncIO(cmd);
if (virCommandRunAsync(cmd, NULL) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
goto cleanup;
}
@@ -930,8 +907,7 @@ test22(const void *unused ATTRIBUTE_UNUSED)
cmd = virCommandNewArgList("/bin/sh", "-c", "exit 3", NULL);
if (virCommandRun(cmd, &status) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
goto cleanup;
}
if (status != 3) {
@@ -941,8 +917,7 @@ test22(const void *unused ATTRIBUTE_UNUSED)
virCommandRawStatus(cmd);
if (virCommandRun(cmd, &status) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
goto cleanup;
}
if (!WIFEXITED(status) || WEXITSTATUS(status) != 3) {
@@ -960,8 +935,7 @@ test22(const void *unused ATTRIBUTE_UNUSED)
virCommandRawStatus(cmd);
if (virCommandRun(cmd, &status) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
goto cleanup;
}
if (!WIFSIGNALED(status) || WTERMSIG(status) != SIGKILL) {
@@ -1057,8 +1031,7 @@ static int test24(const void *unused ATTRIBUTE_UNUSED)
virCommandPassListenFDs(cmd);
if (virCommandRun(cmd, NULL) < 0) {
- virErrorPtr err = virGetLastError();
- printf("Cannot run child %s\n", err->message);
+ printf("Cannot run child %s\n", virGetLastErrorMessage());
goto cleanup;
}
diff --git a/tests/libvirtdconftest.c b/tests/libvirtdconftest.c
index 61d861d..06830bb 100644
--- a/tests/libvirtdconftest.c
+++ b/tests/libvirtdconftest.c
@@ -212,8 +212,7 @@ mymain(void)
}
if (virFileReadAll(filename, 1024*1024, &filedata) < 0) {
- virErrorPtr err = virGetLastError();
- fprintf(stderr, "Cannot load %s for testing: %s", filename, err->message);
+ fprintf(stderr, "Cannot load %s for testing: %s", filename, virGetLastErrorMessage());
ret = -1;
goto cleanup;
}
diff --git a/tests/openvzutilstest.c b/tests/openvzutilstest.c
index ccde636..57a8601 100644
--- a/tests/openvzutilstest.c
+++ b/tests/openvzutilstest.c
@@ -110,16 +110,14 @@ testReadNetworkConf(const void *data ATTRIBUTE_UNUSED)
def->os.type = VIR_DOMAIN_OSTYPE_EXE;
if (openvzReadNetworkConf(def, 1) < 0) {
- err = virGetLastError();
- fprintf(stderr, "ERROR: %s\n", err != NULL ? err->message : "<unknown>");
+ fprintf(stderr, "ERROR: %s\n", virGetLastErrorMessage());
goto cleanup;
}
actual = virDomainDefFormat(def, NULL, VIR_DOMAIN_DEF_FORMAT_INACTIVE);
if (actual == NULL) {
- err = virGetLastError();
- fprintf(stderr, "ERROR: %s\n", err != NULL ? err->message : "<unknown>");
+ fprintf(stderr, "ERROR: %s\n", virGetLastErrorMessage());
goto cleanup;
}
diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c
index c82b3f2..f6caa30 100644
--- a/tests/securityselinuxlabeltest.c
+++ b/tests/securityselinuxlabeltest.c
@@ -332,8 +332,7 @@ testSELinuxLabeling(const void *opaque)
}
VIR_FREE(files);
if (ret < 0) {
- virErrorPtr err = virGetLastError();
- VIR_TEST_VERBOSE("%s\n", err ? err->message : "<unknown>");
+ VIR_TEST_VERBOSE("%s\n", virGetLastErrorMessage());
}
return ret;
}
@@ -354,9 +353,8 @@ mymain(void)
if (!(mgr = virSecurityManagerNew("selinux", "QEMU",
VIR_SECURITY_MANAGER_DEFAULT_CONFINED |
VIR_SECURITY_MANAGER_PRIVILEGED))) {
- virErrorPtr err = virGetLastError();
VIR_TEST_VERBOSE("Unable to initialize security driver: %s\n",
- err->message);
+ virGetLastErrorMessage());
return EXIT_FAILURE;
}
diff --git a/tests/securityselinuxtest.c b/tests/securityselinuxtest.c
index 49694f3..3423e66 100644
--- a/tests/securityselinuxtest.c
+++ b/tests/securityselinuxtest.c
@@ -230,8 +230,7 @@ testSELinuxGenLabel(const void *opaque)
goto cleanup;
if (virSecurityManagerGenLabel(data->mgr, def) < 0) {
- virErrorPtr err = virGetLastError();
- fprintf(stderr, "Cannot generate label: %s\n", err->message);
+ fprintf(stderr, "Cannot generate label: %s\n", virGetLastErrorMessage());
goto cleanup;
}
@@ -275,9 +274,8 @@ mymain(void)
if (!(mgr = virSecurityManagerNew("selinux", "QEMU",
VIR_SECURITY_MANAGER_DEFAULT_CONFINED |
VIR_SECURITY_MANAGER_PRIVILEGED))) {
- virErrorPtr err = virGetLastError();
fprintf(stderr, "Unable to initialize security driver: %s\n",
- err->message);
+ virGetLastErrorMessage());
return EXIT_FAILURE;
}
diff --git a/tests/virnettlscontexttest.c b/tests/virnettlscontexttest.c
index a3e24a3..d33b896 100644
--- a/tests/virnettlscontexttest.c
+++ b/tests/virnettlscontexttest.c
@@ -90,13 +90,12 @@ static int testTLSContextInit(const void *opaque)
goto cleanup;
}
} else {
- virErrorPtr err = virGetLastError();
if (!data->expectFail) {
VIR_WARN("Unexpected failure %s against %s",
data->cacrt, data->crt);
goto cleanup;
}
- VIR_DEBUG("Got error %s", err ? err->message : "<unknown>");
+ VIR_DEBUG("Got error %s", virGetLastErrorMessage());
}
ret = 0;
--
2.7.4
8 years, 7 months