[libvirt] [PATCH] virpci: Resolve coverity issues
by John Ferlan
Coverity complains about "USE_AFTER_FREE" due to how virPCIDeviceSetStubDriver
"could" return either -1, 0, or 1 from the VIR_STRDUP() and then possibly makes
a call to virPCIDeviceDetach().
The only way this could happen is if NULL were passed as the "driver" name
and virStrdup() returned 0. Since the calling functions check < 0 on the
initial function call, the 0 possibility causes Coverity to complain.
To fix this - enforce that the second parameter is not NULL using
ATTRIBUTE_NONNULL(2) for the function prototype, then in virPCIDeviceDetach
add an sa_assert(dev->stubDriver). This will result in Coverity not complaining
any more.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
NOTE: This replaces Pavel's patch posted yesterday:
http://www.redhat.com/archives/libvir-list/2014-February/msg00319.html
src/util/virpci.c | 4 +++-
src/util/virpci.h | 3 ++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/util/virpci.c b/src/util/virpci.c
index c3d211f..00d1064 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1327,6 +1327,8 @@ virPCIDeviceDetach(virPCIDevicePtr dev,
virPCIDeviceList *activeDevs,
virPCIDeviceList *inactiveDevs)
{
+ sa_assert(dev->stubDriver);
+
if (virPCIProbeStubDriver(dev->stubDriver) < 0)
return -1;
@@ -1657,7 +1659,7 @@ int
virPCIDeviceSetStubDriver(virPCIDevicePtr dev, const char *driver)
{
VIR_FREE(dev->stubDriver);
- return driver ? VIR_STRDUP(dev->stubDriver, driver) : 0;
+ return VIR_STRDUP(dev->stubDriver, driver);
}
const char *
diff --git a/src/util/virpci.h b/src/util/virpci.h
index 42c3c95..ac6dae1 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -63,7 +63,8 @@ void virPCIDeviceSetManaged(virPCIDevice *dev,
bool managed);
unsigned int virPCIDeviceGetManaged(virPCIDevice *dev);
int virPCIDeviceSetStubDriver(virPCIDevicePtr dev,
- const char *driver);
+ const char *driver)
+ ATTRIBUTE_NONNULL(2);
const char *virPCIDeviceGetStubDriver(virPCIDevicePtr dev);
void virPCIDeviceSetUsedBy(virPCIDevice *dev,
const char *used_by);
--
1.8.4.2
10 years, 9 months
[libvirt] [PATCH] virpcitest: fix coverity issues
by Pavel Hrdina
The coverity server complains about the dev->stubDriver that it was
freed by the virPCIDeviceSetStubDriver function, but it somehow don't
get the fact that into the variable is immediately assigned new string.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
tests/virpcitest.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/virpcitest.c b/tests/virpcitest.c
index 994b300..8ff3b1d 100644
--- a/tests/virpcitest.c
+++ b/tests/virpcitest.c
@@ -248,6 +248,7 @@ testVirPCIDeviceDetachSingle(const void *opaque)
if (!dev)
goto cleanup;
+ /* coverity[freed_arg] */
if (virPCIDeviceSetStubDriver(dev, "pci-stub") < 0 ||
virPCIDeviceDetach(dev, NULL, NULL) < 0)
goto cleanup;
@@ -269,6 +270,7 @@ testVirPCIDeviceDetachFail(const void *opaque)
if (!dev)
goto cleanup;
+ /* coverity[freed_arg] */
if (virPCIDeviceSetStubDriver(dev, "vfio-pci") < 0)
goto cleanup;
--
1.8.3.1
10 years, 9 months
[libvirt] [PATCH 0/4] allow OVMF users to disable qemu's "-boot strict=on"
by Laszlo Ersek
Recently,
commit 96fddee322c7d39a57cfdc5e7be71326d597d30a
Author: Laine Stump <laine(a)laine.org>
Date: Mon Dec 2 14:07:12 2013 +0200
qemu: add "-boot strict" to commandline whenever possible
introduced a regression for OVMF guests. The symptoms and causes are
described in patch 3/4, and in
https://bugzilla.redhat.com/show_bug.cgi?id=1056258
Let's allow users to opt-out of "-boot strict=on" while preserving it as
default.
Please review.
Thanks,
Laszlo
Laszlo Ersek (4):
domain: introduce os.bootStrict
domain: parse and format os.bootStrict from/to XML
qemu: parse and format os.bootStrict from/to command line
parallels: reject non-default os.bootStrict
src/conf/domain_conf.h | 11 ++++
src/conf/domain_conf.c | 26 +++++++++
src/parallels/parallels_driver.c | 1 +
src/qemu/qemu_command.c | 17 +++++-
tests/qemuxml2argvtest.c | 4 ++
docs/formatdomain.html.in | 9 +++
docs/schemas/domaincommon.rng | 10 ++++
src/libvirt_private.syms | 2 +
tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-boot-floppy.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-boot-network.xml | 1 +
.../qemuxml2argv-boot-strict-off.args | 36 ++++++++++++
.../qemuxml2argv-boot-strict-off.xml | 67 ++++++++++++++++++++++
.../qemuxml2argv-clock-localtime.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-clock-utc.xml | 1 +
.../qemuxml2argv-console-compat.xml | 1 +
.../qemuxml2argv-disk-cdrom-empty.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.xml | 1 +
.../qemuxml2argv-disk-drive-boot-cdrom.xml | 1 +
.../qemuxml2argv-disk-drive-boot-disk.xml | 1 +
.../qemuxml2argv-disk-drive-cache-directsync.xml | 1 +
.../qemuxml2argv-disk-drive-cache-unsafe.xml | 1 +
.../qemuxml2argv-disk-drive-cache-v1-none.xml | 1 +
.../qemuxml2argv-disk-drive-cache-v1-wb.xml | 1 +
.../qemuxml2argv-disk-drive-cache-v2-none.xml | 1 +
.../qemuxml2argv-disk-drive-cache-v2-wb.xml | 1 +
.../qemuxml2argv-disk-drive-cache-v2-wt.xml | 1 +
...muxml2argv-disk-drive-error-policy-enospace.xml | 1 +
.../qemuxml2argv-disk-drive-error-policy-stop.xml | 1 +
...rgv-disk-drive-error-policy-wreport-rignore.xml | 1 +
.../qemuxml2argv-disk-drive-fmt-qcow.xml | 1 +
.../qemuxml2argv-disk-drive-network-gluster.xml | 1 +
.../qemuxml2argv-disk-drive-network-iscsi.xml | 1 +
.../qemuxml2argv-disk-drive-network-nbd-export.xml | 1 +
...xml2argv-disk-drive-network-nbd-ipv6-export.xml | 1 +
.../qemuxml2argv-disk-drive-network-nbd-ipv6.xml | 1 +
.../qemuxml2argv-disk-drive-network-nbd-unix.xml | 1 +
.../qemuxml2argv-disk-drive-network-nbd.xml | 1 +
...emuxml2argv-disk-drive-network-rbd-ceph-env.xml | 1 +
.../qemuxml2argv-disk-drive-network-rbd-ipv6.xml | 1 +
.../qemuxml2argv-disk-drive-network-rbd.xml | 1 +
.../qemuxml2argv-disk-drive-network-sheepdog.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-disk-floppy.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-disk-many.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-disk-usb.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-disk-virtio.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-disk-xenvbd.xml | 1 +
.../qemuxml2argv-graphics-sdl-fullscreen.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml | 1 +
.../qemuxml2argv-graphics-vnc-policy.xml | 1 +
.../qemuxml2argv-graphics-vnc-sasl.xml | 1 +
.../qemuxml2argv-graphics-vnc-socket.xml | 1 +
.../qemuxml2argv-graphics-vnc-tls.xml | 1 +
.../qemuxml2argv-graphics-vnc-websocket.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml | 1 +
.../qemuxml2argv-hostdev-pci-address.xml | 1 +
.../qemuxml2argv-hostdev-usb-address.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml | 1 +
.../qemuxml2argv-input-usbmouse.xml | 1 +
.../qemuxml2argv-input-usbtablet.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-kvmclock.xml | 1 +
.../qemuxml2argv-machine-core-off.xml | 1 +
.../qemuxml2argv-machine-core-on.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-migrate.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.xml | 1 +
.../qemuxml2argv-misc-disable-s3.xml | 1 +
.../qemuxml2argv-misc-disable-suspends.xml | 1 +
.../qemuxml2argv-misc-enable-s4.xml | 1 +
.../qemuxml2argv-misc-no-reboot.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.xml | 1 +
.../qemuxml2argv-net-eth-ifname.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-net-eth.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-net-user.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-net-virtio.xml | 1 +
.../qemuxml2argv-nographics-vga.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-nosharepages.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-parallel-tcp.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-pseries-disk.xml | 1 +
.../qemuxml2argv-pseries-nvram.xml | 1 +
.../qemuxml2argv-qemu-ns-no-env.xml | 1 +
.../qemuxml2argv-reboot-timeout-disabled.xml | 1 +
.../qemuxml2argv-reboot-timeout-enabled.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-restore-v1.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-restore-v2.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-serial-dev.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-serial-file.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-serial-many.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-serial-pty.xml | 1 +
.../qemuxml2argv-serial-tcp-telnet.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-serial-tcp.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-serial-udp.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-serial-unix.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-serial-vc.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-smp.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-sound.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-watchdog.xml | 1 +
96 files changed, 268 insertions(+), 1 deletion(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-boot-strict-off.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-boot-strict-off.xml
--
1.8.3.1
10 years, 9 months
[libvirt] [PATCHv2 0/3] add support for HyperV RTC enlightenment
by Peter Krempa
Version 2 now adds the as a timer mode instead of the hyperv feature as this is a timer in fact.
Peter Krempa (3):
schema: Fix guest timer specification schema according to the docs
conf: Enforce supported options for certain timers
qemu: hyperv: Add support for reference time couter enlightenment
docs/formatdomain.html.in | 7 +-
docs/schemas/domaincommon.rng | 156 +++++++++++++--------
src/conf/domain_conf.c | 59 +++++++-
src/conf/domain_conf.h | 1 +
src/qemu/qemu_command.c | 31 ++--
.../qemuxml2argv-clock-timer-hyperv-rtc.args | 5 +
.../qemuxml2argv-clock-timer-hyperv-rtc.xml | 26 ++++
tests/qemuxml2argvtest.c | 1 +
tests/qemuxml2xmltest.c | 1 +
9 files changed, 212 insertions(+), 75 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-clock-timer-hyperv-rtc.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-clock-timer-hyperv-rtc.xml
--
1.8.5.3
10 years, 9 months
[libvirt] how to adjust the value passed by xml dynamicly
by yue
hi,all
we can pass value throught xml when start vm. how to adjust the value dynamicly as needed while vm is running via API calls?
for example , change from
<filterref filter='hcount'>
<parameter name='HC' value='6'/>
<parameter name='HC' value='10'/>
</filterref>
to
<filterref filter='hcount'>
<parameter name='HC' value='16'/>
<parameter name='HC' value='20'/>
</filterref>
i do not want to restart or interrupt the running state of vms(via api, not command line tools).
10 years, 9 months
[libvirt] [PATCH] qemu: keep pre-migration domain state after failed migration
by Martin Kletzander
Couple of codepaths shared the same code which can be moved out to a
function and on one of such places, qemuMigrationConfirmPhase(), the
domain was resumed even if it wasn't running before the migration
started.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1057407
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/qemu/qemu_domain.h | 3 +-
src/qemu/qemu_migration.c | 117 +++++++++++++++++++++++++---------------------
2 files changed, 66 insertions(+), 54 deletions(-)
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 6a92351..84624f9 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -1,7 +1,7 @@
/*
* qemu_domain.h: QEMU domain private state
*
- * Copyright (C) 2006-2013 Red Hat, Inc.
+ * Copyright (C) 2006-2014 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -161,6 +161,7 @@ struct _qemuDomainObjPrivate {
char *origname;
int nbdPort; /* Port used for migration with NBD */
unsigned short migrationPort;
+ int preMigrationState;
virChrdevsPtr devs;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 407fb70..1a29efa 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1075,6 +1075,53 @@ error:
return NULL;
}
+static void
+qemuDomainObjStorePreMigrationState(virDomainObjPtr vm)
+{
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+ priv->preMigrationState = virDomainObjGetState(vm, NULL);
+
+ VIR_DEBUG("Storing pre-migration state=%d domain=%p",
+ priv->preMigrationState, vm);
+}
+
+/* Returns true if the domain was resumed, false otherwise */
+static bool
+qemuDomainObjRestorePreMigrationState(virConnectPtr conn, virDomainObjPtr vm)
+{
+ virQEMUDriverPtr driver = conn->privateData;
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+ int state = virDomainObjGetState(vm, NULL);
+ bool ret = false;
+
+ VIR_DEBUG("driver=%p, vm=%p, pre-mig-state=%d, state=%d",
+ driver, vm, priv->preMigrationState, state);
+
+ if (state == VIR_DOMAIN_PAUSED &&
+ priv->preMigrationState == VIR_DOMAIN_RUNNING) {
+ /* This is basically the only restore possibility that's safe
+ * and we should attemt to do */
+
+ VIR_DEBUG("Restoring pre-migration state due to migration error");
+
+ /* we got here through some sort of failure; start the domain again */
+ if (qemuProcessStartCPUs(driver, vm, conn,
+ VIR_DOMAIN_RUNNING_MIGRATION_CANCELED,
+ QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) {
+ /* Hm, we already know we are in error here. We don't want to
+ * overwrite the previous error, though, so we just throw something
+ * to the logs and hope for the best */
+ VIR_ERROR(_("Failed to resume guest %s after failure"), vm->def->name);
+ goto cleanup;
+ }
+ ret = true;
+ }
+
+ cleanup:
+ priv->preMigrationState = VIR_DOMAIN_NOSTATE;
+ return ret;
+}
+
/**
* qemuMigrationStartNBDServer:
* @driver: qemu driver
@@ -1952,8 +1999,8 @@ cleanup:
/* The caller is supposed to lock the vm and start a migration job. */
-static char
-*qemuMigrationBeginPhase(virQEMUDriverPtr driver,
+static char *
+qemuMigrationBeginPhase(virQEMUDriverPtr driver,
virDomainObjPtr vm,
const char *xmlin,
const char *dname,
@@ -2075,6 +2122,8 @@ qemuMigrationBegin(virConnectPtr conn,
asyncJob = QEMU_ASYNC_JOB_NONE;
}
+ qemuDomainObjStorePreMigrationState(vm);
+
if (!virDomainObjIsActive(vm) && !(flags & VIR_MIGRATE_OFFLINE)) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
@@ -2744,22 +2793,12 @@ qemuMigrationConfirmPhase(virQEMUDriverPtr driver,
/* cancel any outstanding NBD jobs */
qemuMigrationCancelDriveMirror(mig, driver, vm);
- /* run 'cont' on the destination, which allows migration on qemu
- * >= 0.10.6 to work properly. This isn't strictly necessary on
- * older qemu's, but it also doesn't hurt anything there
- */
- if (qemuProcessStartCPUs(driver, vm, conn,
- VIR_DOMAIN_RUNNING_MIGRATED,
- QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) {
- if (virGetLastError() == NULL)
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("resume operation failed"));
- goto cleanup;
+ if (qemuDomainObjRestorePreMigrationState(conn, vm)) {
+ event = virDomainEventLifecycleNewFromObj(vm,
+ VIR_DOMAIN_EVENT_RESUMED,
+ VIR_DOMAIN_EVENT_RESUMED_MIGRATED);
}
- event = virDomainEventLifecycleNewFromObj(vm,
- VIR_DOMAIN_EVENT_RESUMED,
- VIR_DOMAIN_EVENT_RESUMED_MIGRATED);
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) {
VIR_WARN("Failed to save status on vm %s", vm->def->name);
goto cleanup;
@@ -4065,7 +4104,6 @@ qemuMigrationPerformJob(virQEMUDriverPtr driver,
{
virObjectEventPtr event = NULL;
int ret = -1;
- int resume = 0;
virErrorPtr orig_err = NULL;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
bool abort_on_error = !!(flags & VIR_MIGRATE_ABORT_ON_ERROR);
@@ -4085,7 +4123,7 @@ qemuMigrationPerformJob(virQEMUDriverPtr driver,
if (!(flags & VIR_MIGRATE_UNSAFE) && !qemuMigrationIsSafe(vm->def))
goto endjob;
- resume = virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING;
+ qemuDomainObjStorePreMigrationState(vm);
if ((flags & (VIR_MIGRATE_TUNNELLED | VIR_MIGRATE_PEER2PEER))) {
ret = doPeer2PeerMigrate(driver, conn, vm, xmlin,
@@ -4112,25 +4150,13 @@ qemuMigrationPerformJob(virQEMUDriverPtr driver,
VIR_DOMAIN_EVENT_STOPPED,
VIR_DOMAIN_EVENT_STOPPED_MIGRATED);
}
- resume = 0;
endjob:
if (ret < 0)
orig_err = virSaveLastError();
- if (resume && virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
- /* we got here through some sort of failure; start the domain again */
- if (qemuProcessStartCPUs(driver, vm, conn,
- VIR_DOMAIN_RUNNING_MIGRATION_CANCELED,
- QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) {
- /* Hm, we already know we are in error here. We don't want to
- * overwrite the previous error, though, so we just throw something
- * to the logs and hope for the best
- */
- VIR_ERROR(_("Failed to resume guest %s after failure"),
- vm->def->name);
- }
-
+ if (!v3proto &&
+ qemuDomainObjRestorePreMigrationState(conn, vm)) {
event = virDomainEventLifecycleNewFromObj(vm,
VIR_DOMAIN_EVENT_RESUMED,
VIR_DOMAIN_EVENT_RESUMED_MIGRATED);
@@ -4179,7 +4205,6 @@ qemuMigrationPerformPhase(virQEMUDriverPtr driver,
{
virObjectEventPtr event = NULL;
int ret = -1;
- bool resume;
bool hasrefs;
/* If we didn't start the job in the begin phase, start it now. */
@@ -4194,32 +4219,18 @@ qemuMigrationPerformPhase(virQEMUDriverPtr driver,
virCloseCallbacksUnset(driver->closeCallbacks, vm,
qemuMigrationCleanup);
- resume = virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING;
ret = doNativeMigrate(driver, vm, uri, cookiein, cookieinlen,
cookieout, cookieoutlen,
flags, resource, NULL, graphicsuri);
- if (ret < 0 && resume &&
- virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
- /* we got here through some sort of failure; start the domain again */
- if (qemuProcessStartCPUs(driver, vm, conn,
- VIR_DOMAIN_RUNNING_MIGRATION_CANCELED,
- QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) {
- /* Hm, we already know we are in error here. We don't want to
- * overwrite the previous error, though, so we just throw something
- * to the logs and hope for the best
- */
- VIR_ERROR(_("Failed to resume guest %s after failure"),
- vm->def->name);
+ if (ret < 0) {
+ if (qemuDomainObjRestorePreMigrationState(conn, vm)) {
+ event = virDomainEventLifecycleNewFromObj(vm,
+ VIR_DOMAIN_EVENT_RESUMED,
+ VIR_DOMAIN_EVENT_RESUMED_MIGRATED);
}
-
- event = virDomainEventLifecycleNewFromObj(vm,
- VIR_DOMAIN_EVENT_RESUMED,
- VIR_DOMAIN_EVENT_RESUMED_MIGRATED);
- }
-
- if (ret < 0)
goto endjob;
+ }
qemuMigrationJobSetPhase(driver, vm, QEMU_MIGRATION_PHASE_PERFORM3_DONE);
--
1.8.5.3
10 years, 9 months
[libvirt] [PATCH v2 0/2] small gluster fixes
by Christophe Fergeau
Hi,
I noticed that "virsh pool-list --type gluster" is not giving me an empty
list as expected, but rather the list of active pools. This is happening because
virConnectListAllStoragePools() is returning VIR_ERROR_INVALID_ARG because
VIR_CONNECT_LIST_STORAGE_POOLS_GLUSTER is unrecognized.
vshStoragePoolListCollect then goes to retry with only
VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE | VIR_CONNECT_LIST_STORAGE_POOLS_INACTIVE
in the flags, which is questionable, but explains the result I got.
Adding VIR_CONNECT_LIST_STORAGE_POOLS_GLUSTER to VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_POOL_TYPE
is enough to fix that.
I've played a bit with adding some compile time checks to avoid this in the future, but
while they work, they are a bit ugly-looking, and they would require some changes in
docs/apibuild.py to teach it to parse 1 << N, or to make it ignore values
in #ifdef VIR_ENUM_SENTINELS, so before spending too much time on this, I'd like to know
if these checks would be a welcome/useful addition.
The checks are:
commit 2aee2a1827497ebde19738c88d2ababfe2dbb13d
Author: Christophe Fergeau <cfergeau(a)redhat.com>
Date: Thu Feb 6 17:39:43 2014 +0100
add pool related compile-time checks
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index b3ce000..9d79ae6 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -3104,6 +3104,10 @@ typedef enum {
VIR_CONNECT_LIST_STORAGE_POOLS_RBD = 1 << 14,
VIR_CONNECT_LIST_STORAGE_POOLS_SHEEPDOG = 1 << 15,
VIR_CONNECT_LIST_STORAGE_POOLS_GLUSTER = 1 << 16,
+
+#ifdef VIR_ENUM_SENTINELS
+ VIR_CONNECT_LIST_STORAGE_POOLS_LAST
+#endif
} virConnectListAllStoragePoolsFlags;
int virConnectListAllStoragePools(virConnectPtr conn,
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index eaa9325..c8d4df4 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -36,6 +36,7 @@
#include "virerror.h"
#include "datatypes.h"
#include "storage_conf.h"
+#include "verify.h"
#include "virstoragefile.h"
#include "virxml.h"
@@ -51,6 +52,16 @@
#define DEFAULT_POOL_PERM_MODE 0755
#define DEFAULT_VOL_PERM_MODE 0600
+/* Check if VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_POOL_TYPE seems to
+ * contain all virConnectListAllStoragePoolsFlags elements
+ */
+verify(VIR_CONNECT_LIST_STORAGE_POOLS_LAST < VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_POOL_TYPE);
+
+/* Check if virConnectListAllStorageFlags has one flag per known storage
+ * pool type */
+verify(1 << (5+VIR_STORAGE_POOL_LAST) == VIR_CONNECT_LIST_STORAGE_POOLS_LAST - 1);
+
+
VIR_ENUM_IMPL(virStorageVol,
VIR_STORAGE_VOL_LAST,
"file", "block", "dir", "network", "netdir")
@@ -281,6 +292,8 @@ static virStoragePoolTypeInfo poolTypeInfo[] = {
}
};
+/* Check if poolTypeInfo has one entry per known storage pool type */
+verify(ARRAY_CARDINALITY(poolTypeInfo) == VIR_STORAGE_POOL_LAST);
static virStoragePoolTypeInfoPtr
virStoragePoolTypeInfoLookup(int type)
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
10 years, 9 months
[libvirt] [PATCH 0/2] glusterfs related fixes
by Christophe Fergeau
Hi,
I noticed that "virsh pool-list --type gluster" is not giving me an empty
list as expected, but rather the list of active pools. This is happening because
virConnectListAllStoragePools() is returning VIR_ERROR_INVALID_ARG because
VIR_CONNECT_LIST_STORAGE_POOLS_GLUSTER is unrecognized.
vshStoragePoolListCollect then goes to retry with only
VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE | VIR_CONNECT_LIST_STORAGE_POOLS_INACTIVE
in the flags, which is questionable, but explains the result I got.
Adding VIR_CONNECT_LIST_STORAGE_POOLS_GLUSTER to VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_POOL_TYPE
is enough to fix that.
I've played a bit with adding some compile time checks to avoid this in the future, but
while they work, they are a bit ugly-looking, and they would require some changes in
docs/apibuild.py to teach it to parse 1 << N, or to make it ignore values
in #ifdef VIR_ENUM_SENTINELS, so before spending too much time on this, I'd like to know
if these checks would be a welcome/useful addition.
The checks are:
commit 2aee2a1827497ebde19738c88d2ababfe2dbb13d
Author: Christophe Fergeau <cfergeau(a)redhat.com>
Date: Thu Feb 6 17:39:43 2014 +0100
add pool related compile-time checks
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index b3ce000..9d79ae6 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -3104,6 +3104,10 @@ typedef enum {
VIR_CONNECT_LIST_STORAGE_POOLS_RBD = 1 << 14,
VIR_CONNECT_LIST_STORAGE_POOLS_SHEEPDOG = 1 << 15,
VIR_CONNECT_LIST_STORAGE_POOLS_GLUSTER = 1 << 16,
+
+#ifdef VIR_ENUM_SENTINELS
+ VIR_CONNECT_LIST_STORAGE_POOLS_LAST
+#endif
} virConnectListAllStoragePoolsFlags;
int virConnectListAllStoragePools(virConnectPtr conn,
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index eaa9325..c8d4df4 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -36,6 +36,7 @@
#include "virerror.h"
#include "datatypes.h"
#include "storage_conf.h"
+#include "verify.h"
#include "virstoragefile.h"
#include "virxml.h"
@@ -51,6 +52,16 @@
#define DEFAULT_POOL_PERM_MODE 0755
#define DEFAULT_VOL_PERM_MODE 0600
+/* Check if VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_POOL_TYPE seems to
+ * contain all virConnectListAllStoragePoolsFlags elements
+ */
+verify(VIR_CONNECT_LIST_STORAGE_POOLS_LAST < VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_POOL_TYPE);
+
+/* Check if virConnectListAllStorageFlags has one flag per known storage
+ * pool type */
+verify(1 << (5+VIR_STORAGE_POOL_LAST) == VIR_CONNECT_LIST_STORAGE_POOLS_LAST - 1);
+
+
VIR_ENUM_IMPL(virStorageVol,
VIR_STORAGE_VOL_LAST,
"file", "block", "dir", "network", "netdir")
@@ -281,6 +292,8 @@ static virStoragePoolTypeInfo poolTypeInfo[] = {
}
};
+/* Check if poolTypeInfo has one entry per known storage pool type */
+verify(ARRAY_CARDINALITY(poolTypeInfo) == VIR_STORAGE_POOL_LAST);
static virStoragePoolTypeInfoPtr
virStoragePoolTypeInfoLookup(int type)
10 years, 9 months
[libvirt] [PATCH] libxl: remove unneeded locking of driver when restoring
by Jim Fehlig
libxlDomainRestoreFlags acquires the driver lock while reading the
domain config from the save file and adding it to
libxlDriverPrivatePtr->domains. But virDomainObjList provides
self-locking APIs, so remove the needless driver locking.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
I noticed this while working on the recent series to improve event handling
in the libxl driver, but it got lost when I reshuffled the patches a bit
before sending to the list.
src/libxl/libxl_driver.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index b852279..03aa463 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -1956,11 +1956,6 @@ libxlDomainRestoreFlags(virConnectPtr conn, const char *from,
return -1;
}
- /* Lock the driver until domain def is read from the saved
- image and a virDomainObj is created and locked.
- */
- libxlDriverLock(driver);
-
fd = libxlSaveImageOpen(driver, cfg, from, &def, &hdr);
if (fd < 0)
goto cleanup_unlock;
@@ -1975,7 +1970,6 @@ libxlDomainRestoreFlags(virConnectPtr conn, const char *from,
NULL)))
goto cleanup_unlock;
- libxlDriverUnlock(driver);
def = NULL;
ret = libxlVmStart(driver, vm, (flags & VIR_DOMAIN_SAVE_PAUSED) != 0, fd);
--
1.8.1.4
10 years, 9 months
[libvirt] [PATCH 0/4] libxl: fixes related to concurrency improvements
by Jim Fehlig
While reviving old patches to add job support to the libxl driver,
testing revealed some problems that were difficult to encounter
in the current, more serialized processing approach used in the
driver.
The first patch is a bug fix, plugging leaks of libxlDomainObjPrivate
objects. The second patch removes the list of libxl timer registrations
maintained in the driver - a hack I was never fond of. The third patch
moves domain shutdown handling to a thread, instead of doing all the
shutdown work in the event handler. The fourth patch fixes an issue wrt
child process handling discussed in this thread
http://lists.xen.org/archives/html/xen-devel/2014-01/msg01553.html
Ian Jackson's latest patches on the libxl side are here
http://lists.xen.org/archives/html/xen-devel/2014-02/msg00124.html
Jim Fehlig (4):
libxl: fix leaking libxlDomainObjPrivate
libxl: remove list of timer registrations from libxlDomainObjPrivate
libxl: handle domain shutdown events in a thread
libxl: improve subprocess handling
src/libxl/libxl_conf.h | 5 +-
src/libxl/libxl_domain.c | 102 ++++++++---------------------------
src/libxl/libxl_domain.h | 8 +--
src/libxl/libxl_driver.c | 135 +++++++++++++++++++++++++++++++----------------
4 files changed, 115 insertions(+), 135 deletions(-)
--
1.8.1.4
10 years, 9 months