[libvirt] [PATCH 1/2] virCommandDoAsyncIO: Resolve race
by Michal Privoznik
With current implementation, virCommandWait unregister the stdio
callback and finish reading itself. However, the eventloop may
already have been in process of executing the callback in which
case one obtain these obscure error messages, like:
2013-02-06 11:41:43.766+0000: 19078: warning : virEventPollRemoveHandle:183 : Ignoring invalid remove watch -1
2013-02-06 11:41:43.766+0000: 19078: warning : virFileClose:65 : Tried to close invalid fd 25
The solution is to introduce a mutex and condition to virCommand,
and wait in virCommandWait for the eventloop to process all IOs.
This, however, requires all callees to unlock all mutexes held,
otherwise the eventloop may try to lock one of them and experience
deadlock. If that's the case, we will never be woken up to unlock
the problematic mutex.
---
src/qemu/qemu_driver.c | 58 +++++++++++++++++++++++++---
src/qemu/qemu_migration.c | 15 +++++++-
src/util/vircommand.c | 98 ++++++++++++++++++++++++++++++++++++-----------
src/util/virfile.c | 4 ++
4 files changed, 146 insertions(+), 29 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 979a027..e10fc89 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2757,6 +2757,7 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
int fd = -1;
int directFlag = 0;
virFileWrapperFdPtr wrapperFd = NULL;
+ int wrapperFd_ret;
unsigned int wrapperFlags = VIR_FILE_WRAPPER_NON_BLOCKING;
unsigned long long pad;
unsigned long long offset;
@@ -2833,7 +2834,15 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
goto cleanup;
}
- if (virFileWrapperFdClose(wrapperFd) < 0)
+ /* virCommandDoAsyncIO requires us to release all locks held */
+ virObjectRef(vm);
+ virObjectUnlock(vm);
+ qemuDriverUnlock(driver);
+ wrapperFd_ret = virFileWrapperFdClose(wrapperFd);
+ qemuDriverLock(driver);
+ virObjectLock(vm);
+ virObjectUnref(vm);
+ if (wrapperFd_ret < 0)
goto cleanup;
if ((fd = qemuOpenFile(driver, path, O_WRONLY, NULL, NULL)) < 0)
@@ -3240,6 +3249,7 @@ doCoreDump(virQEMUDriverPtr driver,
int fd = -1;
int ret = -1;
virFileWrapperFdPtr wrapperFd = NULL;
+ int wrapperFd_ret;
int directFlag = 0;
unsigned int flags = VIR_FILE_WRAPPER_NON_BLOCKING;
@@ -3281,7 +3291,16 @@ doCoreDump(virQEMUDriverPtr driver,
path);
goto cleanup;
}
- if (virFileWrapperFdClose(wrapperFd) < 0)
+
+ /* virCommandDoAsyncIO requires us to release all locks held */
+ virObjectRef(vm);
+ virObjectUnlock(vm);
+ qemuDriverUnlock(driver);
+ wrapperFd_ret = virFileWrapperFdClose(wrapperFd);
+ qemuDriverLock(driver);
+ virObjectLock(vm);
+ virObjectUnref(vm);
+ if (wrapperFd_ret < 0)
goto cleanup;
ret = 0;
@@ -4854,6 +4873,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
virDomainEventPtr event;
int intermediatefd = -1;
virCommandPtr cmd = NULL;
+ int cmd_ret;
char *errbuf = NULL;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
@@ -4901,7 +4921,15 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
VIR_FORCE_CLOSE(*fd);
}
- if (virCommandWait(cmd, NULL) < 0) {
+ /* virCommandDoAsyncIO requires us to release all locks held */
+ virObjectRef(vm);
+ virObjectUnlock(vm);
+ qemuDriverUnlock(driver);
+ cmd_ret = virCommandWait(cmd, NULL);
+ qemuDriverLock(driver);
+ virObjectLock(vm);
+ virObjectUnref(vm);
+ if (cmd_ret < 0) {
qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, 0);
ret = -1;
}
@@ -4976,6 +5004,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
int ret = -1;
virQEMUSaveHeader header;
virFileWrapperFdPtr wrapperFd = NULL;
+ int wrapperFd_ret;
int state = -1;
virCheckFlags(VIR_DOMAIN_SAVE_BYPASS_CACHE |
@@ -5009,7 +5038,16 @@ qemuDomainRestoreFlags(virConnectPtr conn,
ret = qemuDomainSaveImageStartVM(conn, driver, vm, &fd, &header, path,
false);
- if (virFileWrapperFdClose(wrapperFd) < 0)
+
+ /* virCommandDoAsyncIO requires us to release all locks held */
+ virObjectRef(vm);
+ virObjectUnlock(vm);
+ qemuDriverUnlock(driver);
+ wrapperFd_ret = virFileWrapperFdClose(wrapperFd);
+ qemuDriverLock(driver);
+ virObjectLock(vm);
+ virObjectUnref(vm);
+ if (wrapperFd_ret < 0)
VIR_WARN("Failed to close %s", path);
if (qemuDomainObjEndJob(driver, vm) == 0)
@@ -5153,6 +5191,7 @@ qemuDomainObjRestore(virConnectPtr conn,
int ret = -1;
virQEMUSaveHeader header;
virFileWrapperFdPtr wrapperFd = NULL;
+ int wrapperFd_ret;
fd = qemuDomainSaveImageOpen(driver, path, &def, &header,
bypass_cache, &wrapperFd, NULL, -1, false,
@@ -5182,7 +5221,16 @@ qemuDomainObjRestore(virConnectPtr conn,
ret = qemuDomainSaveImageStartVM(conn, driver, vm, &fd, &header, path,
start_paused);
- if (virFileWrapperFdClose(wrapperFd) < 0)
+
+ /* virCommandDoAsyncIO requires us to release all locks held */
+ virObjectRef(vm);
+ virObjectUnlock(vm);
+ qemuDriverUnlock(driver);
+ wrapperFd_ret = virFileWrapperFdClose(wrapperFd);
+ qemuDriverLock(driver);
+ virObjectLock(vm);
+ virObjectUnref(vm);
+ if (wrapperFd_ret < 0)
VIR_WARN("Failed to close %s", path);
cleanup:
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index a75fb4e..ddbfd18 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3610,6 +3610,7 @@ qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm,
int rc;
bool restoreLabel = false;
virCommandPtr cmd = NULL;
+ int cmd_ret;
int pipeFD[2] = { -1, -1 };
unsigned long saveMigBandwidth = priv->migMaxBandwidth;
char *errbuf = NULL;
@@ -3729,8 +3730,18 @@ qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm,
if (rc < 0)
goto cleanup;
- if (cmd && virCommandWait(cmd, NULL) < 0)
- goto cleanup;
+ if (cmd) {
+ /* virCommandDoAsyncIO requires us to release all locks held */
+ virObjectRef(vm);
+ virObjectUnlock(vm);
+ qemuDriverUnlock(driver);
+ cmd_ret = virCommandWait(cmd, NULL);
+ qemuDriverLock(driver);
+ virObjectLock(vm);
+ virObjectUnref(vm);
+ if (cmd_ret < 0)
+ goto cleanup;
+ }
ret = 0;
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index db7dbca..97ff135 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -42,6 +42,7 @@
#include "virpidfile.h"
#include "virprocess.h"
#include "virbuffer.h"
+#include "virthread.h"
#define VIR_FROM_THIS VIR_FROM_NONE
@@ -90,6 +91,9 @@ struct _virCommand {
int outWatch;
int errWatch;
+ virMutex lock;
+ virCond cond;
+
bool handshake;
int handshakeWait[2];
int handshakeNotify[2];
@@ -788,9 +792,24 @@ virCommandNewArgs(const char *const*args)
cmd->inWatch = cmd->outWatch = cmd->errWatch = -1;
cmd->pid = -1;
+ if (virMutexInit(&cmd->lock) < 0) {
+ virReportSystemError(errno, "%s", _("Unable to init mutex"));
+ goto error;
+ }
+
+ if (virCondInit(&cmd->cond) < 0) {
+ virReportSystemError(errno, "%s", _("Unable to init cond"));
+ virMutexDestroy(&cmd->lock);
+ goto error;
+ }
+
virCommandAddArgSet(cmd, args);
return cmd;
+
+error:
+ VIR_FREE(cmd);
+ return NULL;
}
/**
@@ -2146,6 +2165,8 @@ virCommandHandleReadWrite(int watch, int fd, int events, void *opaque)
bool eof = false;
int *fdptr = NULL, **fdptrptr = NULL;
+ virMutexLock(&cmd->lock);
+
VIR_DEBUG("watch=%d fd=%d events=%d", watch, fd, events);
errno = 0;
@@ -2190,14 +2211,21 @@ virCommandHandleReadWrite(int watch, int fd, int events, void *opaque)
bufptr = &cmd->outbuf;
fdptr = &cmd->outfd;
fdptrptr = &cmd->outfdptr;
- } else {
+ } else if (watch == cmd->errWatch) {
watchPtr = &cmd->errWatch;
bufptr = &cmd->errbuf;
fdptr = &cmd->errfd;
fdptrptr = &cmd->errfdptr;
+ } else {
+ /* Suspicious wakeup ... */
+ virCondBroadcast(&cmd->cond);
+ virMutexUnlock(&cmd->lock);
+ return;
}
- if (events & VIR_EVENT_HANDLE_READABLE) {
+ if (events & (VIR_EVENT_HANDLE_READABLE |
+ VIR_EVENT_HANDLE_HANGUP |
+ VIR_EVENT_HANDLE_ERROR)) {
if (**bufptr)
len = strlen(**bufptr);
@@ -2241,7 +2269,9 @@ virCommandHandleReadWrite(int watch, int fd, int events, void *opaque)
*bufptr = NULL;
if (fdptrptr)
*fdptrptr = NULL;
+ virCondBroadcast(&cmd->cond);
}
+ virMutexUnlock(&cmd->lock);
}
@@ -2377,24 +2407,24 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid)
virReportError(VIR_ERR_INTERNAL_ERROR,
_("command is already running as pid %lld"),
(long long) cmd->pid);
- return -1;
+ goto cleanup;
}
if (!synchronous && (cmd->flags & VIR_EXEC_DAEMON)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("daemonized command cannot use virCommandRunAsync"));
- return -1;
+ goto cleanup;
}
if (cmd->pwd && (cmd->flags & VIR_EXEC_DAEMON)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("daemonized command cannot set working directory %s"),
cmd->pwd);
- return -1;
+ goto cleanup;
}
if (cmd->pidfile && !(cmd->flags & VIR_EXEC_DAEMON)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("creation of pid file requires daemonized command"));
- return -1;
+ goto cleanup;
}
str = virCommandToString(cmd);
@@ -2439,6 +2469,12 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid)
ret = virCommandRegisterEventLoop(cmd);
}
+cleanup:
+ if (ret < 0) {
+ VIR_FORCE_CLOSE(infd[0]);
+ VIR_FORCE_CLOSE(infd[1]);
+ cmd->infd = -1;
+ }
return ret;
}
@@ -2453,13 +2489,16 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid)
* completion. Returns 0 if the command
* finished with the exit status set. If @exitstatus is NULL, then the
* child must exit with status 0 for this to succeed.
+ *
+ * In case virCommandDoAsyncIO() has been requested previously on
+ * @cmd, this command may block. So you are required to unlock all
+ * locks held prior calling this function.
*/
int
virCommandWait(virCommandPtr cmd, int *exitstatus)
{
int ret;
int status = 0;
- const int events = VIR_EVENT_HANDLE_READABLE | VIR_EVENT_HANDLE_HANGUP;
if (!cmd ||cmd->has_error == ENOMEM) {
virReportOOMError();
@@ -2485,22 +2524,25 @@ virCommandWait(virCommandPtr cmd, int *exitstatus)
* and repeat the exitstatus check code ourselves. */
ret = virProcessWait(cmd->pid, exitstatus ? exitstatus : &status);
- if (cmd->inWatch != -1) {
- virEventRemoveHandle(cmd->inWatch);
- cmd->inWatch = -1;
- }
-
- if (cmd->outWatch != -1) {
- virEventRemoveHandle(cmd->outWatch);
- virCommandHandleReadWrite(cmd->outWatch, cmd->outfd, events, cmd);
- cmd->outWatch = -1;
- }
-
- if (cmd->errWatch != -1) {
- virEventRemoveHandle(cmd->errWatch);
- virCommandHandleReadWrite(cmd->errWatch, cmd->errfd, events, cmd);
- cmd->errWatch = -1;
+ /* Hopefully, all locks has been unlocked. Otherwise, the
+ * eventloop might be trying to lock one of them again, which
+ * will deadlock (obviously), and we will never be woken up here */
+ virMutexLock(&cmd->lock);
+ while (!(cmd->inWatch == -1 &&
+ cmd->outWatch == -1 &&
+ cmd->errWatch == -1)) {
+ VIR_DEBUG("Waiting on in=%d out=%d err=%d",
+ cmd->inWatch, cmd->outWatch, cmd->errWatch);
+
+ if (virCondWait(&cmd->cond, &cmd->lock) < 0) {
+ virReportSystemError(errno, "%s",
+ _("Unable to wait on condition"));
+ break;
+ }
+ VIR_DEBUG("Done waiting on in=%d out=%d err=%d",
+ cmd->inWatch, cmd->outWatch, cmd->errWatch);
}
+ virMutexUnlock(&cmd->lock);
if (ret == 0) {
cmd->pid = -1;
@@ -2719,6 +2761,9 @@ virCommandFree(virCommandPtr cmd)
VIR_FORCE_CLOSE(cmd->transfer[i]);
}
+ virMutexDestroy(&cmd->lock);
+ ignore_value(virCondDestroy(&cmd->cond));
+
VIR_FREE(cmd->inbuf);
VIR_FORCE_CLOSE(cmd->outfd);
VIR_FORCE_CLOSE(cmd->errfd);
@@ -2772,6 +2817,7 @@ virCommandFree(virCommandPtr cmd)
*
* ...
*
+ * // release all locks held (qemu, virDomainObj, ... )
* if (virCommandWait(cmd, NULL) < 0)
* goto cleanup;
*
@@ -2789,6 +2835,14 @@ virCommandFree(virCommandPtr cmd)
* of data to be written to @cmd's stdin, don't pass any binary
* data. If you want to re-run command, you need to call this and
* buffer setting functions (virCommandSet.*Buffer) prior each run.
+ *
+ * Moreover, you are required to unlock all mutexes held prior calling
+ * virCommandWait. Due to current implementation, the virCommandWait
+ * waits for the event loop to finish all IOs on @cmd. However, if we
+ * are holding a locked mutex already and the event loop decides to
+ * issue a different callback which tries to lock the mutex it will
+ * deadlock and don't call any other callbacks. Not even the one which
+ * will unlock us.
*/
void
virCommandDoAsyncIO(virCommandPtr cmd)
diff --git a/src/util/virfile.c b/src/util/virfile.c
index b4765fb..bb33801 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -278,6 +278,10 @@ virFileWrapperFdNew(int *fd ATTRIBUTE_UNUSED,
* callers can conditionally create a virFileWrapperFd wrapper but
* unconditionally call the cleanup code. To avoid deadlock, only
* call this after closing the fd resulting from virFileWrapperFdNew().
+ *
+ * Since the virFileWrapperFdNew has requested asynchronous IO on
+ * underlying virCommand and this uses virCommandWait so we are
+ * required to unlock all locks held.
*/
int
virFileWrapperFdClose(virFileWrapperFdPtr wfd)
--
1.8.0.2
11 years, 10 months
[libvirt] Fix bugs of Sheepdog storage driver
by harryxiyou@gmail.com
---
src/storage/storage_backend_sheepdog.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c
index cd18f33..2cbfe01 100644
--- a/src/storage/storage_backend_sheepdog.c
+++ b/src/storage/storage_backend_sheepdog.c
@@ -168,9 +168,12 @@ virStorageBackendSheepdogCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
virCommandAddArgFormat(cmd, "%llu", vol->capacity);
virStorageBackendSheepdogAddHostArg(cmd, pool);
ret = virCommandRun(cmd, NULL);
+ if (ret < 0)
+ goto cleanup;
- virStorageBackendSheepdogRefreshVol(conn, pool, vol);
+ ret = virStorageBackendSheepdogRefreshVol(conn, pool, vol);
+cleanup:
virCommandFree(cmd);
return ret;
}
--
1.7.0.4
11 years, 10 months
[libvirt] [PATCH 0/5]] S390: Support for native CCW bus
by Viktor Mihajlovski
Originally, QEMU did not implement a native I/O bus for s390.
The initial implementation had a machine type 's390-virtio'
featuring a fully paravirtualized I/O system with an artificial
bus type 'virtio-s390'.
This bus had a number of short-comings, like the need for a
non-standard device discovery mechanism, a limited number
of devices, limited hotplugging capabilites and the lack
of persistent device addresses.
To resolve these issues a new machine type 's390-ccw-virtio'
has been recently added to QEMU which implementa the native
s390 CCW I/O bus.
Guests with arch='s390x' and machine='s390-ccw-virtio' can
now be defined with up to 262144 virtio devices.
This series adds the support for the s390-ccw-virtio
machine type and the CCW bus to libvirt. As usual we start
with the documentation/schema, the generic configuration
stuff, continue with the QEMU driver including device
hotplug and finally add qemu2xml testcases.
J.B. Joret (1):
S390: Add hotplug support for s390 virtio devices
Viktor Mihajlovski (4):
S390: Documentation for CCW address type
S390: domain_conf support for CCW
S390: QEMU driver support for CCW addresses
S390: Testcases for virtio-ccw machines
docs/formatdomain.html.in | 12 +
docs/schemas/domaincommon.rng | 21 ++
src/conf/domain_conf.c | 80 +++++-
src/conf/domain_conf.h | 16 ++
src/libvirt_private.syms | 1 +
src/qemu/qemu_capabilities.c | 47 +++-
src/qemu/qemu_capabilities.h | 7 +-
src/qemu/qemu_command.c | 269 +++++++++++++++++++-
src/qemu/qemu_command.h | 6 +
src/qemu/qemu_domain.c | 1 +
src/qemu/qemu_domain.h | 3 +
src/qemu/qemu_driver.c | 26 +-
src/qemu/qemu_hotplug.c | 149 +++++++----
src/qemu/qemu_hotplug.h | 14 +-
src/qemu/qemu_process.c | 12 +-
.../qemuxml2argv-console-virtio-ccw.args | 10 +
.../qemuxml2argv-console-virtio-ccw.xml | 27 ++
.../qemuxml2argv-console-virtio-s390.args | 4 +-
.../qemuxml2argv-console-virtio-s390.xml | 2 +-
.../qemuxml2argv-disk-virtio-ccw-many.args | 12 +
.../qemuxml2argv-disk-virtio-ccw-many.xml | 39 +++
.../qemuxml2argv-disk-virtio-ccw.args | 8 +
.../qemuxml2argv-disk-virtio-ccw.xml | 30 +++
.../qemuxml2argv-net-virtio-ccw.args | 8 +
.../qemuxml2argv-net-virtio-ccw.xml | 30 +++
tests/qemuxml2argvtest.c | 11 +-
tests/testutilsqemu.c | 3 +-
27 files changed, 752 insertions(+), 96 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-virtio-ccw.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-virtio-ccw.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-ccw-many.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-ccw-many.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-ccw.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-ccw.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-ccw.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-ccw.xml
--
1.7.9.5
11 years, 10 months
[libvirt] [PATCH v3 00/13] More refactoring of QEMU driver objects & locking
by Daniel P. Berrange
An update of
https://www.redhat.com/archives/libvir-list/2013-January/msg01407.html
This series does more general refactoring to help in the goal of killing
the big QEMU driver lock. There are 3 key changes in this series
- Isolating all QEMU configuration parameters in one struct.
- Making virDomainObjList self-locking
- Add dedicated locking to PCI/USB device lists
There are all the really hard bits of the QEMU locking. As can be seen
from the last patch there is still more work to be done before the QEMU
driver lock can be said to be truely dead, but this is less critical.
In v3:
- Rebase, since previous series no longer applied to GIT
In v2:
- Rebase, since previous series no longer applied to GIT
11 years, 10 months
[libvirt] [libvirt-glib] [PATCH 0/3] minor improvements towards Vala usage
by Claudio Bley
Hi.
I'm currently evaluating libvirt-glib using the Vala bindings.
I found a few obstacles on the way. Here are some patches.
Claudio Bley (3):
Fix typo in gvir_config_init's comment
Add "transfer none" annotation to argv parameter
gvir_stream_receive: annotate buffer parameter with "element-type
guint8"
libvirt-gconfig/libvirt-gconfig-main.c | 6 +++---
libvirt-glib/libvirt-glib-main.c | 4 ++--
libvirt-gobject/libvirt-gobject-stream.c | 4 ++--
3 files changed, 7 insertions(+), 7 deletions(-)
--
1.7.11.7
11 years, 10 months
[libvirt] [PATCH] virCondDestroy: Loose attribute RETURN_CHECK
by Michal Privoznik
We are wrapping it in ignore_value() anyway.
---
src/nwfilter/nwfilter_dhcpsnoop.c | 2 +-
src/qemu/qemu_agent.c | 2 +-
src/qemu/qemu_domain.c | 6 +++---
src/qemu/qemu_monitor.c | 3 +--
src/rpc/virnetclient.c | 6 +++---
src/util/virthread.h | 2 +-
src/util/virthreadpool.c | 6 +++---
tools/console.c | 2 +-
8 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c
index 90b5615..5124069 100644
--- a/src/nwfilter/nwfilter_dhcpsnoop.c
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -636,7 +636,7 @@ virNWFilterSnoopReqFree(virNWFilterSnoopReqPtr req)
virNWFilterHashTableFree(req->vars);
virMutexDestroy(&req->lock);
- ignore_value(virCondDestroy(&req->threadStatusCond));
+ virCondDestroy(&req->threadStatusCond);
VIR_FREE(req);
}
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 05641da..ebe777b 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -158,7 +158,7 @@ static void qemuAgentDispose(void *obj)
VIR_DEBUG("mon=%p", mon);
if (mon->cb && mon->cb->destroy)
(mon->cb->destroy)(mon, mon->vm);
- ignore_value(virCondDestroy(&mon->notify));
+ virCondDestroy(&mon->notify);
VIR_FREE(mon->buffer);
}
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 5bf0ab0..46c22e1 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -133,7 +133,7 @@ qemuDomainObjInitJob(qemuDomainObjPrivatePtr priv)
return -1;
if (virCondInit(&priv->job.asyncCond) < 0) {
- ignore_value(virCondDestroy(&priv->job.cond));
+ virCondDestroy(&priv->job.cond);
return -1;
}
@@ -194,8 +194,8 @@ qemuDomainObjTransferJob(virDomainObjPtr obj)
static void
qemuDomainObjFreeJob(qemuDomainObjPrivatePtr priv)
{
- ignore_value(virCondDestroy(&priv->job.cond));
- ignore_value(virCondDestroy(&priv->job.asyncCond));
+ virCondDestroy(&priv->job.cond);
+ virCondDestroy(&priv->job.asyncCond);
}
static bool
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 3f1aed8..7af571d 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -236,8 +236,7 @@ static void qemuMonitorDispose(void *obj)
VIR_DEBUG("mon=%p", mon);
if (mon->cb && mon->cb->destroy)
(mon->cb->destroy)(mon, mon->vm);
- if (virCondDestroy(&mon->notify) < 0)
- {}
+ virCondDestroy(&mon->notify);
VIR_FREE(mon->buffer);
}
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index 44638e2..4efa578 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -1382,7 +1382,7 @@ static bool virNetClientIOEventLoopRemoveDone(virNetClientCallPtr call,
VIR_DEBUG("Removing completed call %p", call);
if (call->expectReply)
VIR_WARN("Got a call expecting a reply but without a waiting thread");
- ignore_value(virCondDestroy(&call->cond));
+ virCondDestroy(&call->cond);
VIR_FREE(call->msg);
VIR_FREE(call);
}
@@ -1409,7 +1409,7 @@ virNetClientIOEventLoopRemoveAll(virNetClientCallPtr call,
return false;
VIR_DEBUG("Removing call %p", call);
- ignore_value(virCondDestroy(&call->cond));
+ virCondDestroy(&call->cond);
VIR_FREE(call->msg);
VIR_FREE(call);
return true;
@@ -1972,7 +1972,7 @@ static int virNetClientSendInternal(virNetClientPtr client,
if (ret == 1)
return 1;
- ignore_value(virCondDestroy(&call->cond));
+ virCondDestroy(&call->cond);
VIR_FREE(call);
return ret;
}
diff --git a/src/util/virthread.h b/src/util/virthread.h
index c209440..c59a2cf 100644
--- a/src/util/virthread.h
+++ b/src/util/virthread.h
@@ -87,7 +87,7 @@ void virMutexUnlock(virMutexPtr m);
int virCondInit(virCondPtr c) ATTRIBUTE_RETURN_CHECK;
-int virCondDestroy(virCondPtr c) ATTRIBUTE_RETURN_CHECK;
+int virCondDestroy(virCondPtr c);
/* virCondWait, virCondWaitUntil:
* These functions can return without the associated predicate
diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c
index 7b8ba70..e657145 100644
--- a/src/util/virthreadpool.c
+++ b/src/util/virthreadpool.c
@@ -271,11 +271,11 @@ void virThreadPoolFree(virThreadPoolPtr pool)
VIR_FREE(pool->workers);
virMutexUnlock(&pool->mutex);
virMutexDestroy(&pool->mutex);
- ignore_value(virCondDestroy(&pool->quit_cond));
- ignore_value(virCondDestroy(&pool->cond));
+ virCondDestroy(&pool->quit_cond);
+ virCondDestroy(&pool->cond);
if (priority) {
VIR_FREE(pool->prioWorkers);
- ignore_value(virCondDestroy(&pool->prioCond));
+ virCondDestroy(&pool->prioCond);
}
VIR_FREE(pool);
}
diff --git a/tools/console.c b/tools/console.c
index 29873ea..e423134 100644
--- a/tools/console.c
+++ b/tools/console.c
@@ -407,7 +407,7 @@ int vshRunConsole(virDomainPtr dom,
if (con->st)
virStreamFree(con->st);
virMutexDestroy(&con->lock);
- ignore_value(virCondDestroy(&con->cond));
+ virCondDestroy(&con->cond);
VIR_FREE(con);
}
--
1.8.0.2
11 years, 10 months
[libvirt] [PATCH] qemu: Fix crash when changing media of cdrom or floppy disk
by Osier Yang
The disk def could be free'ed by qemuDomainChangeEjectableMedia
for cdrom or floppy disk. This moves the setup/checking before
the attaching takes place.
---
src/qemu/qemu_driver.c | 29 ++++++++++++++---------------
src/qemu/qemu_process.c | 16 ++++++++++++----
src/qemu/qemu_process.h | 3 ++-
3 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 906501b..3509880 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5829,8 +5829,20 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
if (disk->type == VIR_DOMAIN_DISK_TYPE_BLOCK &&
disk->shared &&
- (qemuCheckSharedDisk(driver->sharedDisks, disk) < 0))
- goto end;
+ disk->src) {
+ if (qemuCheckSharedDisk(driver->sharedDisks, disk, false) < 0)
+ goto end;
+
+ if (qemuAddSharedDisk(driver->sharedDisks, disk->src) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to add disk '%s' to shared disk table"),
+ disk->src);
+ goto end;
+ }
+ }
+
+ if (qemuSetUnprivSGIO(disk) < 0)
+ goto end;
if (qemuDomainDetermineDiskChain(driver, disk, false) < 0)
goto end;
@@ -5883,19 +5895,6 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
NULLSTR(disk->src));
}
- if (ret == 0) {
- if (disk->type == VIR_DOMAIN_DISK_TYPE_BLOCK &&
- disk->shared &&
- disk->src) {
- if (qemuAddSharedDisk(driver->sharedDisks, disk->src) < 0)
- VIR_WARN("Failed to add disk '%s' to shared disk table",
- disk->src);
- }
-
- if (qemuSetUnprivSGIO(disk) < 0)
- VIR_WARN("Failed to set unpriv_sgio of disk '%s'", disk->src);
- }
-
end:
if (cgroup)
virCgroupFree(&cgroup);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 98ed552..ee5a10c 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3442,7 +3442,14 @@ qemuSetUnprivSGIO(virDomainDiskDefPtr disk)
return 0;
}
-/* Check if a shared disk's setting conflicts with the conf
+/* qemuCheckSharedDisk:
+ * @sharedDisks: Shared disk hash table
+ * @disk: Disk def
+ * @after_adding: Whether this function is involked after
+ * adding the disk to the hash table by
+ * qemuAddSharedDisk.
+ *
+ * Check if a shared disk's setting conflicts with the conf
* used by other domain(s). Currently only checks the sgio
* setting. Note that this should only be called for disk with
* block source.
@@ -3451,7 +3458,8 @@ qemuSetUnprivSGIO(virDomainDiskDefPtr disk)
*/
int
qemuCheckSharedDisk(virHashTablePtr sharedDisks,
- virDomainDiskDefPtr disk)
+ virDomainDiskDefPtr disk,
+ bool after_adding)
{
int val;
size_t *ref = NULL;
@@ -3470,7 +3478,7 @@ qemuCheckSharedDisk(virHashTablePtr sharedDisks,
if (!(ref = virHashLookup(sharedDisks, key)))
goto cleanup;
- if (ref == (void *)0x1)
+ if (after_adding && ref == (void *)0x1)
goto cleanup;
if (virGetDeviceUnprivSGIO(disk->src, NULL, &val) < 0) {
@@ -3846,7 +3854,7 @@ int qemuProcessStart(virConnectPtr conn,
if (qemuAddSharedDisk(driver->sharedDisks, disk->src) < 0)
goto cleanup;
- if (qemuCheckSharedDisk(driver->sharedDisks, disk) < 0)
+ if (qemuCheckSharedDisk(driver->sharedDisks, disk, true) < 0)
goto cleanup;
}
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index 313fa39..ff294e7 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -101,6 +101,7 @@ virBitmapPtr qemuPrepareCpumap(virQEMUDriverPtr driver,
int qemuSetUnprivSGIO(virDomainDiskDefPtr disk);
int qemuCheckSharedDisk(virHashTablePtr sharedDisks,
- virDomainDiskDefPtr disk);
+ virDomainDiskDefPtr disk,
+ bool after_adding);
#endif /* __QEMU_PROCESS_H__ */
--
1.7.7.6
11 years, 10 months
[libvirt] [PATCH v3 0/6] Introduce virCommandDoAsyncIO
by Michal Privoznik
Currently, if we want to use IO with asynchronous command we have
to copy code from virFileWrapperFd to misuse our event loop for
reading and writing to the command. However, we can extend our
virCommand implementation to automatically set things up.
All patches but the first has been ACKed already.
diff to v2:
-even more of Peter's suggestion worked in
diff to v1:
-drop usleep(100) while waiting for the event loop to process our string IOs
and do it ourselves instead.
Michal Privoznik (6):
virCommand: Introduce virCommandDoAsyncIO
Introduce event loop to commandtest
tests: Create test for virCommandDoAsyncIO
virFileWrapperFd: Switch to new virCommandDoAsyncIO
qemu: Catch stderr of image decompression binary
qemu: Catch stderr of image compression binary
src/libvirt_private.syms | 1 +
src/qemu/qemu_driver.c | 5 +
src/qemu/qemu_migration.c | 9 +-
src/util/vircommand.c | 308 +++++++++++++++++++++++++++++++++++++++++---
src/util/vircommand.h | 1 +
src/util/virfile.c | 82 +-----------
tests/commanddata/test3.log | 2 +-
tests/commandtest.c | 136 +++++++++++++++++++
8 files changed, 447 insertions(+), 97 deletions(-)
--
1.8.0.2
11 years, 10 months
[libvirt] [PATCH] qemu: Fix crash when using shared cdrom or floppy disk without source
by Osier Yang
How to reproduce the crash:
* Start a guest with a disk like:
<disk type='block' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='hdc' bus='ide'/>
<readonly/>
<shareable/>
<address type='drive' controller='0' bus='1' target='0' unit='0'/>
</disk>
It's caused by disk->src for this disk is NULL. This patch fixes it.
---
src/qemu/qemu_process.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index a2ce007..d1872c0 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3837,7 +3837,9 @@ int qemuProcessStart(virConnectPtr conn,
_("Raw I/O is not supported on this platform"));
#endif
- if (disk->type == VIR_DOMAIN_DISK_TYPE_BLOCK && disk->shared) {
+ if (disk->type == VIR_DOMAIN_DISK_TYPE_BLOCK &&
+ disk->shared &&
+ disk->src) {
if (qemuAddSharedDisk(driver->sharedDisks, disk->src) < 0)
goto cleanup;
@@ -4246,7 +4248,9 @@ void qemuProcessStop(virQEMUDriverPtr driver,
for (i = 0; i < vm->def->ndisks; i++) {
virDomainDiskDefPtr disk = vm->def->disks[i];
- if (disk->type == VIR_DOMAIN_DISK_TYPE_BLOCK && disk->shared) {
+ if (disk->type == VIR_DOMAIN_DISK_TYPE_BLOCK &&
+ disk->shared &&
+ disk->src) {
ignore_value(qemuRemoveSharedDisk(driver->sharedDisks, disk->src));
}
}
--
1.7.7.6
11 years, 10 months
[libvirt] [PATCH 1/2] Remove more trailing semicolons in Python files
by Guido Günther
---
docs/apibuild.py | 56 ++++----
docs/index.py | 32 ++---
examples/domain-events/events-python/event-test.py | 24 ++--
python/generator.py | 146 ++++++++++----------
python/libvirt-override-virConnect.py | 10 +-
python/tests/create.py | 2 +-
6 files changed, 135 insertions(+), 135 deletions(-)
diff --git a/docs/apibuild.py b/docs/apibuild.py
index 2bdbf2d..df12ba6 100755
--- a/docs/apibuild.py
+++ b/docs/apibuild.py
@@ -409,7 +409,7 @@ class CLexer:
return self.lineno
def push(self, token):
- self.tokens.insert(0, token);
+ self.tokens.insert(0, token)
def debug(self):
print "Last token: ", self.last
@@ -429,7 +429,7 @@ class CLexer:
if line[0] == '#':
self.tokens = map((lambda x: ('preproc', x)),
string.split(line))
- break;
+ break
l = len(line)
if line[0] == '"' or line[0] == "'":
end = line[0]
@@ -699,7 +699,7 @@ class CParser:
if self.top_comment == "":
self.top_comment = com
if self.comment == None or com[0] == '*':
- self.comment = com;
+ self.comment = com
else:
self.comment = self.comment + com
token = self.lexer.token()
@@ -897,7 +897,7 @@ class CParser:
while i < nbargs:
if args[i][1] == arg:
args[i] = (args[i][0], arg, desc)
- break;
+ break
i = i + 1
if i >= nbargs:
if not quiet:
@@ -1141,10 +1141,10 @@ class CParser:
type = type + token[1]
token = self.token()
elif token != None and token[0] == 'sep' and token[1] == ';':
- break;
+ break
elif token != None and token[0] == 'name':
type = base_type
- continue;
+ continue
else:
self.error("parsing typedef: expecting ';'", token)
return token
@@ -1239,7 +1239,7 @@ class CParser:
else:
self.error("parseStruct: name", token)
token = self.token()
- self.type = base_type;
+ self.type = base_type
self.struct_fields = fields
#self.debug("end parseStruct", token)
#print fields
@@ -1289,7 +1289,7 @@ class CParser:
else:
self.error("parseUnion: name", token)
token = self.token()
- self.type = base_type;
+ self.type = base_type
self.union_fields = fields
# self.debug("end parseUnion", token)
# print fields
@@ -1633,7 +1633,7 @@ class CParser:
self.type = self.type + token[1]
token = self.token()
if token == None or token[0] != "name" :
- self.error("parsing function type, name expected", token);
+ self.error("parsing function type, name expected", token)
return token
self.type = self.type + token[1]
nametok = token
@@ -1643,14 +1643,14 @@ class CParser:
token = self.token()
if token != None and token[0] == "sep" and token[1] == '(':
token = self.token()
- type = self.type;
- token = self.parseSignature(token);
- self.type = type;
+ type = self.type
+ token = self.parseSignature(token)
+ self.type = type
else:
- self.error("parsing function type, '(' expected", token);
+ self.error("parsing function type, '(' expected", token)
return token
else:
- self.error("parsing function type, ')' expected", token);
+ self.error("parsing function type, ')' expected", token)
return token
self.lexer.push(token)
token = nametok
@@ -1675,7 +1675,7 @@ class CParser:
self.type = self.type + token[1]
token = self.token()
else:
- self.error("parsing array type, ']' expected", token);
+ self.error("parsing array type, ']' expected", token)
return token
elif token != None and token[0] == "sep" and token[1] == ':':
# remove :12 in case it's a limited int size
@@ -1904,7 +1904,7 @@ class CParser:
self.index_add(self.name, self.filename, static,
"function", d)
token = self.token()
- token = self.parseBlock(token);
+ token = self.parseBlock(token)
elif token[1] == ',':
self.comment = None
self.index_add(self.name, self.filename, static,
@@ -2014,7 +2014,7 @@ class docBuilder:
for header in self.headers.keys():
parser = CParser(header)
idx = parser.parse()
- self.headers[header] = idx;
+ self.headers[header] = idx
self.idx.merge(idx)
def scanModules(self):
@@ -2032,19 +2032,19 @@ class docBuilder:
skip = 1
for incl in self.includes:
if string.find(file, incl) != -1:
- skip = 0;
+ skip = 0
break
if skip == 0:
- self.modules[file] = None;
+ self.modules[file] = None
files = glob.glob(directory + "/*.h")
for file in files:
skip = 1
for incl in self.includes:
if string.find(file, incl) != -1:
- skip = 0;
+ skip = 0
break
if skip == 0:
- self.headers[file] = None;
+ self.headers[file] = None
self.scanHeaders()
self.scanModules()
@@ -2067,11 +2067,11 @@ class docBuilder:
val = eval(info[0])
except:
val = info[0]
- output.write(" value='%s'" % (val));
+ output.write(" value='%s'" % (val))
if info[2] != None and info[2] != '':
- output.write(" type='%s'" % info[2]);
+ output.write(" type='%s'" % info[2])
if info[1] != None and info[1] != '':
- output.write(" info='%s'" % escape(info[1]));
+ output.write(" info='%s'" % escape(info[1]))
output.write("/>\n")
def serialize_macro(self, output, name):
@@ -2119,7 +2119,7 @@ class docBuilder:
if self.idx.structs.has_key(name) and ( \
type(self.idx.structs[name].info) == type(()) or
type(self.idx.structs[name].info) == type([])):
- output.write(">\n");
+ output.write(">\n")
try:
for field in self.idx.structs[name].info:
desc = field[2]
@@ -2136,7 +2136,7 @@ class docBuilder:
self.warning("Failed to serialize struct %s" % (name))
output.write(" </struct>\n")
else:
- output.write("/>\n");
+ output.write("/>\n")
else :
output.write(" <typedef name='%s' file='%s' type='%s'" % (
name, self.modulename_file(id.header), id.info))
@@ -2176,7 +2176,7 @@ class docBuilder:
if apstr != "":
apstr = apstr + " && "
apstr = apstr + cond
- output.write(" <cond>%s</cond>\n"% (apstr));
+ output.write(" <cond>%s</cond>\n"% (apstr))
try:
(ret, params, desc) = id.info
output.write(" <info><![CDATA[%s]]></info>\n" % (desc))
@@ -2388,7 +2388,7 @@ class docBuilder:
letter = id[0]
output.write(" <letter name='%s'>\n" % (letter))
output.write(" <word name='%s'>\n" % (id))
- tokens = index[id];
+ tokens = index[id]
tokens.sort()
tok = None
for token in tokens:
diff --git a/docs/index.py b/docs/index.py
index df6bd81..ce5180f 100755
--- a/docs/index.py
+++ b/docs/index.py
@@ -166,15 +166,15 @@ def checkTables(db, verbose = 1):
print "table %s missing" % (table)
createTable(db, table)
try:
- ret = c.execute("SELECT count(*) from %s" % table);
+ ret = c.execute("SELECT count(*) from %s" % table)
row = c.fetchone()
if verbose:
print "Table %s contains %d records" % (table, row[0])
except:
print "Troubles with table %s : repairing" % (table)
- ret = c.execute("repair table %s" % table);
+ ret = c.execute("repair table %s" % table)
print "repairing returned %d" % (ret)
- ret = c.execute("SELECT count(*) from %s" % table);
+ ret = c.execute("SELECT count(*) from %s" % table)
row = c.fetchone()
print "Table %s contains %d records" % (table, row[0])
if verbose:
@@ -600,7 +600,7 @@ def addWordHTML(word, resource, id, section, relevance):
pass
else:
wordsDictHTML[word] = {}
- d = wordsDictHTML[word];
+ d = wordsDictHTML[word]
d[resource] = (relevance, id, section)
return relevance
@@ -647,7 +647,7 @@ def addWordArchive(word, id, relevance):
pass
else:
wordsDictArchive[word] = {}
- d = wordsDictArchive[word];
+ d = wordsDictArchive[word]
d[id] = relevance
return relevance
@@ -989,7 +989,7 @@ def analyzeHTML(doc, resource, p, section, id):
return words
def analyzeHTML(doc, resource):
- para = 0;
+ para = 0
ctxt = doc.xpathNewContext()
try:
res = ctxt.xpathEval("//head/title")
@@ -1079,7 +1079,7 @@ def scanXMLMsgArchive(url, title, force = 0):
try:
print "Loading %s" % (url)
- doc = libxml2.htmlParseFile(url, None);
+ doc = libxml2.htmlParseFile(url, None)
except:
doc = None
if doc == None:
@@ -1102,7 +1102,7 @@ def scanXMLDateArchive(t = None, force = 0):
url = getXMLDateArchive(t)
print "loading %s" % (url)
try:
- doc = libxml2.htmlParseFile(url, None);
+ doc = libxml2.htmlParseFile(url, None)
except:
doc = None
if doc == None:
@@ -1150,7 +1150,7 @@ def analyzeArchives(t = None, force = 0):
refs = wordsDictArchive[word]
if refs == None:
skipped = skipped + 1
- continue;
+ continue
for id in refs.keys():
relevance = refs[id]
updateWordArchive(word, id, relevance)
@@ -1170,7 +1170,7 @@ def analyzeHTMLTop():
refs = wordsDictHTML[word]
if refs == None:
skipped = skipped + 1
- continue;
+ continue
for resource in refs.keys():
(relevance, id, section) = refs[resource]
updateWordHTML(word, resource, section, id, relevance)
@@ -1199,7 +1199,7 @@ def analyzeAPITop():
refs = wordsDict[word]
if refs == None:
skipped = skipped + 1
- continue;
+ continue
for (module, symbol) in refs.keys():
updateWord(word, symbol, refs[(module, symbol)])
i = i + 1
@@ -1228,26 +1228,26 @@ def main():
elif args[i] == '--archive':
analyzeArchives(None, force)
elif args[i] == '--archive-year':
- i = i + 1;
+ i = i + 1
year = args[i]
months = ["January" , "February", "March", "April", "May",
"June", "July", "August", "September", "October",
- "November", "December"];
+ "November", "December"]
for month in months:
try:
str = "%s-%s" % (year, month)
T = time.strptime(str, "%Y-%B")
- t = time.mktime(T) + 3600 * 24 * 10;
+ t = time.mktime(T) + 3600 * 24 * 10
analyzeArchives(t, force)
except:
print "Failed to index month archive:"
print sys.exc_type, sys.exc_value
elif args[i] == '--archive-month':
- i = i + 1;
+ i = i + 1
month = args[i]
try:
T = time.strptime(month, "%Y-%B")
- t = time.mktime(T) + 3600 * 24 * 10;
+ t = time.mktime(T) + 3600 * 24 * 10
analyzeArchives(t, force)
except:
print "Failed to index month archive:"
diff --git a/examples/domain-events/events-python/event-test.py b/examples/domain-events/events-python/event-test.py
index 3095e94..b456dec 100644
--- a/examples/domain-events/events-python/event-test.py
+++ b/examples/domain-events/events-python/event-test.py
@@ -289,7 +289,7 @@ class virEventLoopPure:
def update_timer(self, timerID, interval):
for h in self.timers:
if h.get_id() == timerID:
- h.set_interval(interval);
+ h.set_interval(interval)
self.interrupt()
debug("Update timer %d interval %d" % (timerID, interval))
@@ -325,25 +325,25 @@ class virEventLoopPure:
if events & libvirt.VIR_EVENT_HANDLE_WRITABLE:
ret |= select.POLLOUT
if events & libvirt.VIR_EVENT_HANDLE_ERROR:
- ret |= select.POLLERR;
+ ret |= select.POLLERR
if events & libvirt.VIR_EVENT_HANDLE_HANGUP:
- ret |= select.POLLHUP;
+ ret |= select.POLLHUP
return ret
# Convert from poll() event constants, to libvirt events constants
def events_from_poll(self, events):
- ret = 0;
+ ret = 0
if events & select.POLLIN:
- ret |= libvirt.VIR_EVENT_HANDLE_READABLE;
+ ret |= libvirt.VIR_EVENT_HANDLE_READABLE
if events & select.POLLOUT:
- ret |= libvirt.VIR_EVENT_HANDLE_WRITABLE;
+ ret |= libvirt.VIR_EVENT_HANDLE_WRITABLE
if events & select.POLLNVAL:
- ret |= libvirt.VIR_EVENT_HANDLE_ERROR;
+ ret |= libvirt.VIR_EVENT_HANDLE_ERROR
if events & select.POLLERR:
- ret |= libvirt.VIR_EVENT_HANDLE_ERROR;
+ ret |= libvirt.VIR_EVENT_HANDLE_ERROR
if events & select.POLLHUP:
- ret |= libvirt.VIR_EVENT_HANDLE_HANGUP;
- return ret;
+ ret |= libvirt.VIR_EVENT_HANDLE_HANGUP
+ return ret
###########################################################################
@@ -437,8 +437,8 @@ def eventToString(event):
"Resumed",
"Stopped",
"Shutdown",
- "PMSuspended" );
- return eventStrings[event];
+ "PMSuspended" )
+ return eventStrings[event]
def detailToString(event, detail):
eventStrings = (
diff --git a/python/generator.py b/python/generator.py
index ceade6b..02209f9 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -615,7 +615,7 @@ def print_function_wrapper(module, name, output, export, include):
# Don't delete the function entry in the caller.
return 1
- c_call = "";
+ c_call = ""
format=""
format_args=""
c_args=""
@@ -638,7 +638,7 @@ def print_function_wrapper(module, name, output, export, include):
c_args = c_args + " PyObject *pyobj_%s;\n" % (arg[0])
c_convert = c_convert + \
" %s = (%s) Py%s_Get(pyobj_%s);\n" % (arg[0],
- arg[1], t, arg[0]);
+ arg[1], t, arg[0])
else:
format_args = format_args + ", &%s" % (arg[0])
if f == 't#':
@@ -646,7 +646,7 @@ def print_function_wrapper(module, name, output, export, include):
c_args = c_args + " int py_buffsize%d;\n" % num_bufs
num_bufs = num_bufs + 1
if c_call != "":
- c_call = c_call + ", ";
+ c_call = c_call + ", "
c_call = c_call + "%s" % (arg[0])
else:
if skipped_types.has_key(arg[1]):
@@ -671,7 +671,7 @@ def print_function_wrapper(module, name, output, export, include):
c_call = "\n %s->%s = %s;\n" % (args[0][0], args[1][0],
args[1][0])
else:
- c_call = "\n %s(%s);\n" % (name, c_call);
+ c_call = "\n %s(%s);\n" % (name, c_call)
ret_convert = " Py_INCREF(Py_None);\n return Py_None;\n"
elif py_types.has_key(ret[0]):
(f, t, n, c) = py_types[ret[0]]
@@ -679,13 +679,13 @@ def print_function_wrapper(module, name, output, export, include):
if file == "python_accessor" and ret[2] != None:
c_call = "\n c_retval = %s->%s;\n" % (args[0][0], ret[2])
else:
- c_call = "\n c_retval = %s(%s);\n" % (name, c_call);
+ c_call = "\n c_retval = %s(%s);\n" % (name, c_call)
ret_convert = " py_retval = libvirt_%sWrap((%s) c_retval);\n" % (n,c)
ret_convert = ret_convert + " return py_retval;\n"
elif py_return_types.has_key(ret[0]):
(f, t, n, c) = py_return_types[ret[0]]
c_return = " %s c_retval;\n" % (ret[0])
- c_call = "\n c_retval = %s(%s);\n" % (name, c_call);
+ c_call = "\n c_retval = %s(%s);\n" % (name, c_call)
ret_convert = " py_retval = libvirt_%sWrap((%s) c_retval);\n" % (n,c)
ret_convert = ret_convert + " return py_retval;\n"
else:
@@ -705,31 +705,31 @@ def print_function_wrapper(module, name, output, export, include):
include.write("PyObject * ")
if module == "libvirt":
- include.write("libvirt_%s(PyObject *self, PyObject *args);\n" % (name));
+ include.write("libvirt_%s(PyObject *self, PyObject *args);\n" % (name))
export.write(" { (char *)\"%s\", libvirt_%s, METH_VARARGS, NULL },\n" %
(name, name))
elif module == "libvirt-lxc":
- include.write("libvirt_lxc_%s(PyObject *self, PyObject *args);\n" % (name));
+ include.write("libvirt_lxc_%s(PyObject *self, PyObject *args);\n" % (name))
export.write(" { (char *)\"%s\", libvirt_lxc_%s, METH_VARARGS, NULL },\n" %
(name, name))
elif module == "libvirt-qemu":
- include.write("libvirt_qemu_%s(PyObject *self, PyObject *args);\n" % (name));
+ include.write("libvirt_qemu_%s(PyObject *self, PyObject *args);\n" % (name))
export.write(" { (char *)\"%s\", libvirt_qemu_%s, METH_VARARGS, NULL },\n" %
(name, name))
if file == "python":
# Those have been manually generated
if cond != None and cond != "":
- include.write("#endif\n");
- export.write("#endif\n");
- output.write("#endif\n");
+ include.write("#endif\n")
+ export.write("#endif\n")
+ output.write("#endif\n")
return 1
if file == "python_accessor" and ret[0] != "void" and ret[2] is None:
# Those have been manually generated
if cond != None and cond != "":
- include.write("#endif\n");
- export.write("#endif\n");
- output.write("#endif\n");
+ include.write("#endif\n")
+ export.write("#endif\n")
+ output.write("#endif\n")
return 1
output.write("PyObject *\n")
@@ -756,9 +756,9 @@ def print_function_wrapper(module, name, output, export, include):
if c_convert != "":
output.write(c_convert + "\n")
- output.write(" LIBVIRT_BEGIN_ALLOW_THREADS;");
- output.write(c_call);
- output.write(" LIBVIRT_END_ALLOW_THREADS;\n");
+ output.write(" LIBVIRT_BEGIN_ALLOW_THREADS;")
+ output.write(c_call)
+ output.write(" LIBVIRT_END_ALLOW_THREADS;\n")
output.write(ret_convert)
output.write("}\n\n")
if cond != None and cond != "":
@@ -1195,7 +1195,7 @@ def writeDoc(module, name, args, indent, output):
if funcs[name][0] is None or funcs[name][0] == "":
return
val = funcs[name][0]
- val = string.replace(val, "NULL", "None");
+ val = string.replace(val, "NULL", "None")
output.write(indent)
output.write('"""')
i = string.find(val, "\n")
@@ -1261,7 +1261,7 @@ def buildWrappers(module):
ctypes_processed[type] = ()
for name in functions.keys():
- found = 0;
+ found = 0
(desc, ret, args, file, mod, cond) = functions[name]
for type in ctypes:
classe = classes_type[type][2]
@@ -1331,7 +1331,7 @@ def buildWrappers(module):
classes.write("%s" % arg[0])
n = n + 1
classes.write("):\n")
- writeDoc(module, name, args, ' ', classes);
+ writeDoc(module, name, args, ' ', classes)
for arg in args:
if classes_type.has_key(arg[1]):
@@ -1340,19 +1340,19 @@ def buildWrappers(module):
classes.write(" else: %s__o = %s%s\n" %
(arg[0], arg[0], classes_type[arg[1]][0]))
if ret[0] != "void":
- classes.write(" ret = ");
+ classes.write(" ret = ")
else:
- classes.write(" ");
+ classes.write(" ")
classes.write("libvirtmod.%s(" % name)
n = 0
for arg in args:
if n != 0:
- classes.write(", ");
+ classes.write(", ")
classes.write("%s" % arg[0])
if classes_type.has_key(arg[1]):
- classes.write("__o");
+ classes.write("__o")
n = n + 1
- classes.write(")\n");
+ classes.write(")\n")
if ret[0] != "void":
if classes_type.has_key(ret[0]):
@@ -1360,15 +1360,15 @@ def buildWrappers(module):
# Raise an exception
#
if functions_noexcept.has_key(name):
- classes.write(" if ret is None:return None\n");
+ classes.write(" if ret is None:return None\n")
else:
classes.write(
" if ret is None:raise libvirtError('%s() failed')\n" %
(name))
- classes.write(" return ");
- classes.write(classes_type[ret[0]][1] % ("ret"));
- classes.write("\n");
+ classes.write(" return ")
+ classes.write(classes_type[ret[0]][1] % ("ret"))
+ classes.write("\n")
# For functions returning an integral type there are
# several things that we can do, depending on the
@@ -1398,7 +1398,7 @@ def buildWrappers(module):
else:
classes.write(" return ret\n")
- classes.write("\n");
+ classes.write("\n")
for classname in classes_list:
if classname == "None":
@@ -1441,14 +1441,14 @@ def buildWrappers(module):
classes.write(" self._dom = dom\n")
classes.write(" self._conn = dom.connect()\n")
classes.write(" if _obj != None:self._o = _obj;return\n")
- classes.write(" self._o = None\n\n");
+ classes.write(" self._o = None\n\n")
destruct=None
if classes_destructors.has_key(classname):
classes.write(" def __del__(self):\n")
classes.write(" if self._o != None:\n")
classes.write(" libvirtmod.%s(self._o)\n" %
- classes_destructors[classname]);
- classes.write(" self._o = None\n\n");
+ classes_destructors[classname])
+ classes.write(" self._o = None\n\n")
destruct=classes_destructors[classname]
if not class_skip_connect_impl.has_key(classname):
@@ -1470,7 +1470,7 @@ def buildWrappers(module):
# to avoid double free
#
if name == destruct:
- continue;
+ continue
if file != oldfile:
if file == "python_accessor":
classes.write(" # accessors for %s\n" % (classname))
@@ -1487,7 +1487,7 @@ def buildWrappers(module):
classes.write(", %s" % arg[0])
n = n + 1
classes.write("):\n")
- writeDoc(module, name, args, ' ', classes);
+ writeDoc(module, name, args, ' ', classes)
n = 0
for arg in args:
if classes_type.has_key(arg[1]):
@@ -1498,24 +1498,24 @@ def buildWrappers(module):
(arg[0], arg[0], classes_type[arg[1]][0]))
n = n + 1
if ret[0] != "void":
- classes.write(" ret = ");
+ classes.write(" ret = ")
else:
- classes.write(" ");
+ classes.write(" ")
n = 0
classes.write("libvirtmod.%s(" % name)
for arg in args:
if n != 0:
- classes.write(", ");
+ classes.write(", ")
if n != index:
classes.write("%s" % arg[0])
if classes_type.has_key(arg[1]):
- classes.write("__o");
+ classes.write("__o")
else:
- classes.write("self");
+ classes.write("self")
if classes_type.has_key(arg[1]):
classes.write(classes_type[arg[1]][0])
n = n + 1
- classes.write(")\n");
+ classes.write(")\n")
if name == "virConnectClose":
classes.write(" self._o = None\n")
@@ -1528,7 +1528,7 @@ def buildWrappers(module):
#
if functions_noexcept.has_key(name):
classes.write(
- " if ret is None:return None\n");
+ " if ret is None:return None\n")
else:
if classname == "virConnect":
classes.write(
@@ -1566,9 +1566,9 @@ def buildWrappers(module):
#
# generate the returned class wrapper for the object
#
- classes.write(" __tmp = ");
- classes.write(classes_type[ret[0]][1] % ("ret"));
- classes.write("\n");
+ classes.write(" __tmp = ")
+ classes.write(classes_type[ret[0]][1] % ("ret"))
+ classes.write("\n")
#
# Sometime one need to keep references of the source
@@ -1586,28 +1586,28 @@ def buildWrappers(module):
# Post-processing - just before we return.
if function_post.has_key(name):
classes.write(" %s\n" %
- (function_post[name]));
+ (function_post[name]))
#
# return the class
#
- classes.write(" return __tmp\n");
+ classes.write(" return __tmp\n")
elif converter_type.has_key(ret[0]):
#
# Raise an exception
#
if functions_noexcept.has_key(name):
classes.write(
- " if ret is None:return None");
+ " if ret is None:return None")
# Post-processing - just before we return.
if function_post.has_key(name):
classes.write(" %s\n" %
- (function_post[name]));
+ (function_post[name]))
- classes.write(" return ");
- classes.write(converter_type[ret[0]] % ("ret"));
- classes.write("\n");
+ classes.write(" return ")
+ classes.write(converter_type[ret[0]] % ("ret"))
+ classes.write("\n")
# For functions returning an integral type there
# are several things that we can do, depending on
@@ -1650,7 +1650,7 @@ def buildWrappers(module):
# Post-processing - just before we return.
if function_post.has_key(name):
classes.write(" %s\n" %
- (function_post[name]));
+ (function_post[name]))
classes.write (" return ret\n")
@@ -1692,7 +1692,7 @@ def buildWrappers(module):
# Post-processing - just before we return.
if function_post.has_key(name):
classes.write(" %s\n" %
- (function_post[name]));
+ (function_post[name]))
classes.write (" return ret\n")
@@ -1700,11 +1700,11 @@ def buildWrappers(module):
# Post-processing - just before we return.
if function_post.has_key(name):
classes.write(" %s\n" %
- (function_post[name]));
+ (function_post[name]))
- classes.write(" return ret\n");
+ classes.write(" return ret\n")
- classes.write("\n");
+ classes.write("\n")
# Append "<classname>.py" to class def, iff it exists
try:
extra = open(os.path.join(srcPref,"libvirt-override-" + classname + ".py"), "r")
@@ -1726,7 +1726,7 @@ def buildWrappers(module):
items.sort(lambda i1,i2: cmp(long(i1[1]),long(i2[1])))
for name,value in items:
classes.write("%s = %s\n" % (name,value))
- classes.write("\n");
+ classes.write("\n")
classes.close()
@@ -1776,7 +1776,7 @@ def qemuBuildWrappers(module):
fd.write(" if str(cyg_e).count(\"No module named\"):\n")
fd.write(" raise lib_e\n\n")
- fd.write("import libvirt\n\n");
+ fd.write("import libvirt\n\n")
fd.write("#\n# Functions from module %s\n#\n\n" % module)
#
# Generate functions directly, no classes
@@ -1792,12 +1792,12 @@ def qemuBuildWrappers(module):
fd.write("%s" % arg[0])
n = n + 1
fd.write("):\n")
- writeDoc(module, name, args, ' ', fd);
+ writeDoc(module, name, args, ' ', fd)
if ret[0] != "void":
- fd.write(" ret = ");
+ fd.write(" ret = ")
else:
- fd.write(" ");
+ fd.write(" ")
fd.write("libvirtmod_qemu.%s(" % name)
n = 0
@@ -1808,7 +1808,7 @@ def qemuBuildWrappers(module):
conn = arg[0]
if n != 0:
- fd.write(", ");
+ fd.write(", ")
if arg[1] in ["virDomainPtr", "virConnectPtr"]:
# FIXME: This might have problem if the function
# has multiple args which are objects.
@@ -1816,7 +1816,7 @@ def qemuBuildWrappers(module):
else:
fd.write("%s" % arg[0])
n = n + 1
- fd.write(")\n");
+ fd.write(")\n")
if ret[0] != "void":
fd.write(" if ret is None: raise libvirt.libvirtError('" + name + "() failed')\n")
@@ -1837,7 +1837,7 @@ def qemuBuildWrappers(module):
items.sort(lambda i1,i2: cmp(long(i1[1]),long(i2[1])))
for name,value in items:
fd.write("%s = %s\n" % (name,value))
- fd.write("\n");
+ fd.write("\n")
fd.close()
@@ -1888,7 +1888,7 @@ def lxcBuildWrappers(module):
fd.write(" if str(cyg_e).count(\"No module named\"):\n")
fd.write(" raise lib_e\n\n")
- fd.write("import libvirt\n\n");
+ fd.write("import libvirt\n\n")
fd.write("#\n# Functions from module %s\n#\n\n" % module)
#
# Generate functions directly, no classes
@@ -1904,12 +1904,12 @@ def lxcBuildWrappers(module):
fd.write("%s" % arg[0])
n = n + 1
fd.write("):\n")
- writeDoc(module, name, args, ' ', fd);
+ writeDoc(module, name, args, ' ', fd)
if ret[0] != "void":
- fd.write(" ret = ");
+ fd.write(" ret = ")
else:
- fd.write(" ");
+ fd.write(" ")
fd.write("libvirtmod_lxc.%s(" % name)
n = 0
@@ -1920,7 +1920,7 @@ def lxcBuildWrappers(module):
conn = arg[0]
if n != 0:
- fd.write(", ");
+ fd.write(", ")
if arg[1] in ["virDomainPtr", "virConnectPtr"]:
# FIXME: This might have problem if the function
# has multiple args which are objects.
@@ -1928,7 +1928,7 @@ def lxcBuildWrappers(module):
else:
fd.write("%s" % arg[0])
n = n + 1
- fd.write(")\n");
+ fd.write(")\n")
if ret[0] != "void":
fd.write(" if ret is None: raise libvirt.libvirtError('" + name + "() failed')\n")
@@ -1949,7 +1949,7 @@ def lxcBuildWrappers(module):
items.sort(lambda i1,i2: cmp(long(i1[1]),long(i2[1])))
for name,value in items:
fd.write("%s = %s\n" % (name,value))
- fd.write("\n");
+ fd.write("\n")
fd.close()
diff --git a/python/libvirt-override-virConnect.py b/python/libvirt-override-virConnect.py
index 84d6cc3..121ef6f 100644
--- a/python/libvirt-override-virConnect.py
+++ b/python/libvirt-override-virConnect.py
@@ -132,7 +132,7 @@
opaque = cbData["opaque"]
cb(self, virDomain(self, _obj=dom), oldSrcPath, newSrcPath, devAlias, reason, opaque)
- return 0;
+ return 0
def _dispatchDomainEventTrayChangeCallback(self, dom, devAlias, reason, cbData):
"""Dispatches event to python user domain trayChange event callbacks
@@ -141,7 +141,7 @@
opaque = cbData["opaque"]
cb(self, virDomain(self, _obj=dom), devAlias, reason, opaque)
- return 0;
+ return 0
def _dispatchDomainEventPMWakeupCallback(self, dom, reason, cbData):
"""Dispatches event to python user domain pmwakeup event callbacks
@@ -150,7 +150,7 @@
opaque = cbData["opaque"]
cb(self, virDomain(self, _obj=dom), reason, opaque)
- return 0;
+ return 0
def _dispatchDomainEventPMSuspendCallback(self, dom, reason, cbData):
"""Dispatches event to python user domain pmsuspend event callbacks
@@ -159,7 +159,7 @@
opaque = cbData["opaque"]
cb(self, virDomain(self, _obj=dom), reason, opaque)
- return 0;
+ return 0
def _dispatchDomainEventBalloonChangeCallback(self, dom, actual, cbData):
"""Dispatches events to python user domain balloon change event callbacks
@@ -177,7 +177,7 @@
opaque = cbData["opaque"]
cb(self, virDomain(self, _obj=dom), reason, opaque)
- return 0;
+ return 0
def domainEventDeregisterAny(self, callbackID):
"""Removes a Domain Event Callback. De-registering for a
diff --git a/python/tests/create.py b/python/tests/create.py
index 95e31a9..815ccc4 100755
--- a/python/tests/create.py
+++ b/python/tests/create.py
@@ -128,7 +128,7 @@ while i < 30:
except:
okay = 0
t = -1
- break;
+ break
if t == 0:
break
--
1.7.10.4
11 years, 10 months