[libvirt] Host information from libvirt KVM/Xen
by Parakkal, Navin S
Hi,
I'm able to get the CPU utilization metrics from libvirt for the guests (VM's) remotely . Is it possible to get the Host Cpu stat's through libvirt ?
I didn't find any information regarding the host cpu cycles and memory utilization to collect them remotely. Libvirt is installed on all the hosts.
Regards,
Navin
11 years, 8 months
[libvirt] [PATCH] Clean some comments about locking
by Martin Kletzander
Since the BQDL has been broken, this patch tries to cleanup some
information about it in various comments.
---
To be applied after Dan's patch [1] which removes unnecessary
qemuDriverLocks.
[1] https://www.redhat.com/archives/libvir-list/2013-February/msg00641.html
src/qemu/THREADS.txt | 9 ++-------
src/qemu/qemu_conf.c | 8 +++++---
src/qemu/qemu_conf.h | 5 +----
src/qemu/qemu_domain.c | 11 +++++------
src/qemu/qemu_domain.h | 3 +--
src/qemu/qemu_driver.c | 5 +----
src/qemu/qemu_migration.c | 4 ++--
src/qemu/qemu_process.c | 40 ++++++++++++++--------------------------
8 files changed, 31 insertions(+), 54 deletions(-)
diff --git a/src/qemu/THREADS.txt b/src/qemu/THREADS.txt
index 785be99..50a0cf9 100644
--- a/src/qemu/THREADS.txt
+++ b/src/qemu/THREADS.txt
@@ -128,7 +128,7 @@ To acquire the normal job condition
To acquire the asynchronous job condition
- qemuDomainObjBeginAsyncJob() (if driver is unlocked)
+ qemuDomainObjBeginAsyncJob()
- Increments ref count on virDomainObjPtr
- Waits until no async job is running
- Waits for job.cond condition 'job.active != 0' using virDomainObjPtr
@@ -155,8 +155,6 @@ To acquire the QEMU monitor lock
- Releases the qemuMonitorObjPtr lock
- Acquires the virDomainObjPtr lock
- NB: caller must take care to drop the driver lock if necessary
-
These functions must not be used by an asynchronous job.
@@ -166,12 +164,10 @@ To acquire the QEMU monitor lock as part of an asynchronous job
- Validates that the right async job is still running
- Acquires the qemuMonitorObjPtr lock
- Releases the virDomainObjPtr lock
- - Releases the driver lock
- Validates that the VM is still active
qemuDomainObjExitMonitor()
- Releases the qemuMonitorObjPtr lock
- - Acquires the driver lock
- Acquires the virDomainObjPtr lock
These functions are for use inside an asynchronous job; the caller
@@ -180,8 +176,7 @@ To acquire the QEMU monitor lock as part of an asynchronous job
used from a sync job (such as when first starting a domain).
-To keep a domain alive while waiting on a remote command, starting
-with the driver lock held
+To keep a domain alive while waiting on a remote command
qemuDomainObjEnterRemote()
- Increments ref count on virDomainObjPtr
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 5ac2004..4ff912d 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1,7 +1,7 @@
/*
* qemu_conf.c: QEMU configuration management
*
- * Copyright (C) 2006-2012 Red Hat, Inc.
+ * Copyright (C) 2006-2013 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -79,11 +79,13 @@ struct _qemuDriverCloseDef {
qemuDriverCloseCallback cb;
};
-void qemuDriverLock(virQEMUDriverPtr driver)
+static void
+qemuDriverLock(virQEMUDriverPtr driver)
{
virMutexLock(&driver->lock);
}
-void qemuDriverUnlock(virQEMUDriverPtr driver)
+static void
+qemuDriverUnlock(virQEMUDriverPtr driver)
{
virMutexUnlock(&driver->lock);
}
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 09eacce..14f1427 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -1,7 +1,7 @@
/*
* qemu_conf.h: QEMU configuration management
*
- * Copyright (C) 2006-2007, 2009-2012 Red Hat, Inc.
+ * Copyright (C) 2006-2007, 2009-2013 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -236,9 +236,6 @@ struct _qemuDomainCmdlineDef {
# define QEMUD_MIGRATION_NUM_PORTS 64
-void qemuDriverLock(virQEMUDriverPtr driver);
-void qemuDriverUnlock(virQEMUDriverPtr driver);
-
virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged);
int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index ec4c8f8..482f64a 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1,7 +1,7 @@
/*
* qemu_domain.h: QEMU domain private state
*
- * Copyright (C) 2006-2012 Red Hat, Inc.
+ * Copyright (C) 2006-2013 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -116,7 +116,6 @@ qemuDomainAsyncJobPhaseFromString(enum qemuDomainAsyncJob job,
}
-/* driver must be locked before calling */
void qemuDomainEventQueue(virQEMUDriverPtr driver,
virDomainEventPtr event)
{
@@ -760,7 +759,7 @@ qemuDomainJobAllowed(qemuDomainObjPrivatePtr priv, enum qemuDomainJob job)
#define QEMU_JOB_WAIT_TIME (1000ull * 30)
/*
- * obj must be locked before calling;
+ * obj must be locked before calling
*/
static int ATTRIBUTE_NONNULL(1)
qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
@@ -857,7 +856,7 @@ error:
}
/*
- * obj must be locked before calling, driver must NOT be locked
+ * obj must be locked before calling
*
* This must be called by anything that will change the VM state
* in any way, or anything that will use the QEMU monitor.
@@ -883,7 +882,7 @@ int qemuDomainObjBeginAsyncJob(virQEMUDriverPtr driver,
/*
- * obj must be locked before calling, driver does not matter
+ * obj must be locked before calling
*
* To be called after completing the work associated with the
* earlier qemuDomainBeginJob() call
@@ -1734,7 +1733,7 @@ qemuDomainSnapshotDiscardAllMetadata(virQEMUDriverPtr driver,
}
/*
- * The caller must hold a lock on both driver and vm, and there must
+ * The caller must hold a lock the vm and there must
* be no remaining references to vm.
*/
void
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index cfc952d..905b099 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-2012 Red Hat, Inc.
+ * Copyright (C) 2006-2013 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -175,7 +175,6 @@ int qemuDomainAsyncJobPhaseFromString(enum qemuDomainAsyncJob job,
void qemuDomainEventFlush(int timer, void *opaque);
-/* driver must be locked before calling */
void qemuDomainEventQueue(virQEMUDriverPtr driver,
virDomainEventPtr event);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 4d756f3..2ad21dc 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2746,8 +2746,7 @@ cleanup:
return ret;
}
-/* This internal function expects the driver lock to already be held on
- * entry and the vm must be active + locked. Vm will be unlocked and
+/* The vm must be active + locked. Vm will be unlocked and
* potentially free'd after this returns (eg transient VMs are freed
* shutdown). So 'vm' must not be referenced by the caller after
* this returns (whether returning success or failure).
@@ -10349,8 +10348,6 @@ cleanup:
}
-
-/* this function expects the driver lock to be held by the caller */
static int
qemuDomainSnapshotFSFreeze(virDomainObjPtr vm) {
qemuDomainObjPrivatePtr priv = vm->privateData;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 60cd47a..36e55d2 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2,7 +2,7 @@
/*
* qemu_migration.c: QEMU migration handling
*
- * Copyright (C) 2006-2012 Red Hat, Inc.
+ * Copyright (C) 2006-2013 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -3620,7 +3620,7 @@ cleanup:
}
-/* Helper function called while driver lock is held and vm is active. */
+/* Helper function called while vm is active. */
int
qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm,
int fd, off_t offset, const char *path,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 306f686..e5eadc0 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1,7 +1,7 @@
/*
* qemu_process.h: QEMU process management
*
- * Copyright (C) 2006-2012 Red Hat, Inc.
+ * Copyright (C) 2006-2013 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -599,8 +599,7 @@ endjob:
cleanup:
if (vm) {
if (ret == -1) {
- ignore_value(qemuProcessKill(vm,
- VIR_QEMU_PROCESS_KILL_FORCE));
+ ignore_value(qemuProcessKill(vm, VIR_QEMU_PROCESS_KILL_FORCE));
}
if (virObjectUnref(vm))
virObjectUnlock(vm);
@@ -625,13 +624,11 @@ qemuProcessShutdownOrReboot(virQEMUDriverPtr driver,
qemuProcessFakeReboot,
vm) < 0) {
VIR_ERROR(_("Failed to create reboot thread, killing domain"));
- ignore_value(qemuProcessKill(vm,
- VIR_QEMU_PROCESS_KILL_NOWAIT));
+ ignore_value(qemuProcessKill(vm, VIR_QEMU_PROCESS_KILL_NOWAIT));
virObjectUnref(vm);
}
} else {
- ignore_value(qemuProcessKill(vm,
- VIR_QEMU_PROCESS_KILL_NOWAIT));
+ ignore_value(qemuProcessKill(vm, VIR_QEMU_PROCESS_KILL_NOWAIT));
}
}
@@ -2792,9 +2789,8 @@ qemuProcessPrepareMonitorChr(virQEMUDriverConfigPtr cfg,
/*
- * Precondition: Both driver and vm must be locked,
- * and a job must be active. This method will call
- * {Enter,Exit}Monitor
+ * Precondition: vm must be locked, and a job must be active.
+ * This method will call {Enter,Exit}Monitor
*/
int
qemuProcessStartCPUs(virQEMUDriverPtr driver, virDomainObjPtr vm,
@@ -3374,23 +3370,15 @@ qemuProcessReconnectHelper(virDomainObjPtr obj,
memcpy(data, src, sizeof(*data));
data->payload = obj;
- /* This iterator is called with driver being locked.
+ /*
* We create a separate thread to run qemuProcessReconnect in it.
* However, qemuProcessReconnect needs to:
- * 1. lock driver
- * 2. just before monitor reconnect do lightweight MonitorEnter
+ * 1. just before monitor reconnect do lightweight MonitorEnter
* (increase VM refcount, unlock VM & driver)
- * 3. reconnect to monitor
- * 4. do lightweight MonitorExit (lock driver & VM)
- * 5. continue reconnect process
- * 6. EndJob
- * 7. unlock driver
- *
- * It is necessary to NOT hold driver lock for the entire run
- * of reconnect, otherwise we will get blocked if there is
- * unresponsive qemu.
- * However, iterating over hash table MUST be done on locked
- * driver.
+ * 2. reconnect to monitor
+ * 3. do lightweight MonitorExit (lock VM)
+ * 4. continue reconnect process
+ * 5. EndJob
*
* NB, we can't do normal MonitorEnter & MonitorExit because
* these two lock the monitor lock, which does not exists in
@@ -4184,8 +4172,8 @@ void qemuProcessStop(virQEMUDriverPtr driver,
}
/*
- * We may unlock the driver and vm in qemuProcessKill(), and another thread
- * can lock driver and vm, and then call qemuProcessStop(). So we should
+ * We may unlock the vm in qemuProcessKill(), and another thread
+ * can lock the vm, and then call qemuProcessStop(). So we should
* set vm->def->id to -1 here to avoid qemuProcessStop() to be called twice.
*/
vm->def->id = -1;
--
1.8.1.2
11 years, 8 months
[libvirt] [PATCH v2] Remove qemuDriverLock from almost everywhere
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
With the majority of fields in the virQEMUDriverPtr struct
now immutable or self-locking, there is no need for practically
any methods to be using the QEMU driver lock. Only a handful
of helper APIs in qemu_conf.c now need it
---
src/qemu/THREADS.txt | 194 +++--------------------
src/qemu/qemu_conf.c | 50 ++++--
src/qemu/qemu_domain.c | 213 +++++--------------------
src/qemu/qemu_domain.h | 40 +----
src/qemu/qemu_driver.c | 386 +++++++++++-----------------------------------
src/qemu/qemu_hotplug.c | 118 +++++++-------
src/qemu/qemu_migration.c | 66 ++++----
src/qemu/qemu_process.c | 223 +++++++++-----------------
src/qemu/qemu_process.h | 3 +-
9 files changed, 360 insertions(+), 933 deletions(-)
diff --git a/src/qemu/THREADS.txt b/src/qemu/THREADS.txt
index c3bad21..785be99 100644
--- a/src/qemu/THREADS.txt
+++ b/src/qemu/THREADS.txt
@@ -14,35 +14,24 @@ Basic locking primitives
There are a number of locks on various objects
- * struct qemud_driver: RWLock
+ * virQEMUDriverPtr
- This is the top level lock on the entire driver. Every API call in
- the QEMU driver is blocked while this is held, though some internal
- callbacks may still run asynchronously. This lock must never be held
- for anything which sleeps/waits (i.e. monitor commands)
+ The qemu_conf.h file has inline comments describing the locking
+ needs for each field. Any field marked immutable, self-locking
+ can be accessed without the driver lock. For other fields there
+ are typically helper APIs in qemu_conf.c that provide serialized
+ access to the data. No code outside qemu_conf.c should ever
+ acquire this lock
- When obtaining the driver lock, under *NO* circumstances must
- any lock be held on a virDomainObjPtr. This *WILL* result in
- deadlock.
-
-
-
- * virDomainObjPtr: Mutex
+ * virDomainObjPtr
Will be locked after calling any of the virDomainFindBy{ID,Name,UUID}
methods.
Lock must be held when changing/reading any variable in the virDomainObjPtr
- Once the lock is held, you must *NOT* try to lock the driver. You must
- release all virDomainObjPtr locks before locking the driver, or deadlock
- *WILL* occur.
-
If the lock needs to be dropped & then re-acquired for a short period of
time, the reference count must be incremented first using virDomainObjRef().
- If the reference count is incremented in this way, it is not necessary
- to have the driver locked when re-acquiring the dropped locked, since the
- reference count prevents it being freed by another thread.
This lock must not be held for anything which sleeps/waits (i.e. monitor
commands).
@@ -103,26 +92,10 @@ There are a number of locks on various objects
The virDomainObjPtr lock *MUST* then be released when invoking the
monitor command.
- The driver lock *MUST* be released when invoking the monitor commands.
-
- This ensures that the virDomainObjPtr & driver are both unlocked while
- sleeping/waiting for the monitor response.
-
-
Helper methods
--------------
-To lock the driver
-
- qemuDriverLock()
- - Acquires the driver lock
-
- qemuDriverUnlock()
- - Releases the driver lock
-
-
-
To lock the virDomainObjPtr
virObjectLock()
@@ -135,19 +108,8 @@ To lock the virDomainObjPtr
To acquire the normal job condition
- qemuDomainObjBeginJob() (if driver is unlocked)
- - Increments ref count on virDomainObjPtr
- - Waits until the job is compatible with current async job or no
- async job is running
- - Waits for job.cond condition 'job.active != 0' using virDomainObjPtr
- mutex
- - Rechecks if the job is still compatible and repeats waiting if it
- isn't
- - Sets job.active to the job type
-
- qemuDomainObjBeginJobWithDriver() (if driver needs to be locked)
+ qemuDomainObjBeginJob()
- Increments ref count on virDomainObjPtr
- - Unlocks driver
- Waits until the job is compatible with current async job or no
async job is running
- Waits for job.cond condition 'job.active != 0' using virDomainObjPtr
@@ -155,12 +117,6 @@ To acquire the normal job condition
- Rechecks if the job is still compatible and repeats waiting if it
isn't
- Sets job.active to the job type
- - Unlocks virDomainObjPtr
- - Locks driver
- - Locks virDomainObjPtr
-
- NB: this variant is required in order to comply with lock ordering
- rules for virDomainObjPtr vs. driver
qemuDomainObjEndJob()
@@ -181,22 +137,6 @@ To acquire the asynchronous job condition
and repeats waiting in that case
- Sets job.asyncJob to the asynchronous job type
- qemuDomainObjBeginAsyncJobWithDriver() (if driver needs to be locked)
- - Increments ref count on virDomainObjPtr
- - Unlocks driver
- - Waits until no async job is running
- - Waits for job.cond condition 'job.active != 0' using virDomainObjPtr
- mutex
- - Rechecks if any async job was started while waiting on job.cond
- and repeats waiting in that case
- - Sets job.asyncJob to the asynchronous job type
- - Unlocks virDomainObjPtr
- - Locks driver
- - Locks virDomainObjPtr
-
- NB: this variant is required in order to comply with lock ordering
- rules for virDomainObjPtr vs driver
-
qemuDomainObjEndAsyncJob()
- Sets job.asyncJob to 0
@@ -220,25 +160,7 @@ To acquire the QEMU monitor lock
These functions must not be used by an asynchronous job.
-To acquire the QEMU monitor lock with the driver lock held
-
- qemuDomainObjEnterMonitorWithDriver()
- - Acquires the qemuMonitorObjPtr lock
- - Releases the virDomainObjPtr lock
- - Releases the driver lock
-
- qemuDomainObjExitMonitorWithDriver()
- - Releases the qemuMonitorObjPtr lock
- - Acquires the driver lock
- - Acquires the virDomainObjPtr lock
-
- NB: caller must take care to drop the driver lock if necessary
-
- These functions must not be used inside an asynchronous job.
-
-
-To acquire the QEMU monitor lock with the driver lock held and as part
-of an asynchronous job
+To acquire the QEMU monitor lock as part of an asynchronous job
qemuDomainObjEnterMonitorAsync()
- Validates that the right async job is still running
@@ -247,13 +169,11 @@ of an asynchronous job
- Releases the driver lock
- Validates that the VM is still active
- qemuDomainObjExitMonitorWithDriver()
+ qemuDomainObjExitMonitor()
- Releases the qemuMonitorObjPtr lock
- Acquires the driver lock
- Acquires the virDomainObjPtr lock
- NB: caller must take care to drop the driver lock if necessary
-
These functions are for use inside an asynchronous job; the caller
must check for a return of -1 (VM not running, so nothing to exit).
Helper functions may also call this with QEMU_ASYNC_JOB_NONE when
@@ -263,13 +183,11 @@ of an asynchronous job
To keep a domain alive while waiting on a remote command, starting
with the driver lock held
- qemuDomainObjEnterRemoterWithDriver()
+ qemuDomainObjEnterRemote()
- Increments ref count on virDomainObjPtr
- Releases the virDomainObjPtr lock
- - Releases the driver lock
- qemuDomainObjExitRemoteWithDriver()
- - Acquires the driver lock
+ qemuDomainObjExitRemote()
- Acquires the virDomainObjPtr lock
- Decrements ref count on virDomainObjPtr
@@ -278,51 +196,22 @@ Design patterns
---------------
- * Accessing or updating something with just the driver
-
- qemuDriverLock(driver);
-
- ...do work...
-
- qemuDriverUnlock(driver);
-
-
-
* Accessing something directly to do with a virDomainObjPtr
virDomainObjPtr obj;
- qemuDriverLock(driver);
- obj = virDomainFindByUUID(driver->domains, dom->uuid);
- qemuDriverUnlock(driver);
-
- ...do work...
-
- virDomainObjUnlock(obj);
-
-
-
- * Accessing something directly to do with a virDomainObjPtr and driver
-
- virDomainObjPtr obj;
-
- qemuDriverLock(driver);
obj = virDomainFindByUUID(driver->domains, dom->uuid);
...do work...
virDomainObjUnlock(obj);
- qemuDriverUnlock(driver);
-
* Updating something directly to do with a virDomainObjPtr
virDomainObjPtr obj;
- qemuDriverLock(driver);
obj = virDomainFindByUUID(driver->domains, dom->uuid);
- qemuDriverUnlock(driver);
qemuDomainObjBeginJob(obj, QEMU_JOB_TYPE);
@@ -341,9 +230,7 @@ Design patterns
virDomainObjPtr obj;
qemuDomainObjPrivatePtr priv;
- qemuDriverLock(driver);
obj = virDomainFindByUUID(driver->domains, dom->uuid);
- qemuDriverUnlock(driver);
qemuDomainObjBeginJob(obj, QEMU_JOB_TYPE);
@@ -362,42 +249,14 @@ Design patterns
-
- * Invoking a monitor command on a virDomainObjPtr with driver locked too
-
+ * Running asynchronous job
virDomainObjPtr obj;
qemuDomainObjPrivatePtr priv;
- qemuDriverLock(driver);
obj = virDomainFindByUUID(driver->domains, dom->uuid);
- qemuDomainObjBeginJobWithDriver(obj, QEMU_JOB_TYPE);
-
- ...do prep work...
-
- if (virDomainObjIsActive(vm)) {
- qemuDomainObjEnterMonitorWithDriver(driver, obj);
- qemuMonitorXXXX(priv->mon);
- qemuDomainObjExitMonitorWithDriver(driver, obj);
- }
-
- ...do final work...
-
- qemuDomainObjEndJob(obj);
- virDomainObjUnlock(obj);
- qemuDriverUnlock(driver);
-
-
- * Running asynchronous job with driver lock held
-
- virDomainObjPtr obj;
- qemuDomainObjPrivatePtr priv;
-
- qemuDriverLock(driver);
- obj = virDomainFindByUUID(driver->domains, dom->uuid);
-
- qemuDomainObjBeginAsyncJobWithDriver(obj, QEMU_ASYNC_JOB_TYPE);
+ qemuDomainObjBeginAsyncJob(obj, QEMU_ASYNC_JOB_TYPE);
qemuDomainObjSetAsyncJobMask(obj, allowedJobs);
...do prep work...
@@ -408,7 +267,7 @@ Design patterns
goto error;
}
...start qemu job...
- qemuDomainObjExitMonitorWithDriver(driver, obj);
+ qemuDomainObjExitMonitor(driver, obj);
while (!finished) {
if (qemuDomainObjEnterMonitorAsync(driver, obj,
@@ -417,7 +276,7 @@ Design patterns
goto error;
}
...monitor job progress...
- qemuDomainObjExitMonitorWithDriver(driver, obj);
+ qemuDomainObjExitMonitor(driver, obj);
virObjectUnlock(obj);
sleep(aWhile);
@@ -428,7 +287,6 @@ Design patterns
qemuDomainObjEndAsyncJob(obj);
virDomainObjUnlock(obj);
- qemuDriverUnlock(driver);
* Coordinating with a remote server for migration
@@ -436,17 +294,16 @@ Design patterns
virDomainObjPtr obj;
qemuDomainObjPrivatePtr priv;
- qemuDriverLock(driver);
obj = virDomainFindByUUID(driver->domains, dom->uuid);
- qemuDomainObjBeginAsyncJobWithDriver(obj, QEMU_ASYNC_JOB_TYPE);
+ qemuDomainObjBeginAsyncJob(obj, QEMU_ASYNC_JOB_TYPE);
...do prep work...
if (virDomainObjIsActive(vm)) {
- qemuDomainObjEnterRemoteWithDriver(driver, obj);
+ qemuDomainObjEnterRemote(obj);
...communicate with remote...
- qemuDomainObjExitRemoteWithDriver(driver, obj);
+ qemuDomainObjExitRemote(obj);
/* domain may have been stopped while we were talking to remote */
if (!virDomainObjIsActive(vm)) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -458,14 +315,3 @@ Design patterns
qemuDomainObjEndAsyncJob(obj);
virDomainObjUnlock(obj);
- qemuDriverUnlock(driver);
-
-
-Summary
--------
-
- * Respect lock ordering rules: never lock driver if anything else is
- already locked
-
- * Don't hold locks in code which sleeps: unlock driver & virDomainObjPtr
- when using monitor
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 2bd1931..5ac2004 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -523,7 +523,11 @@ no_memory:
virQEMUDriverConfigPtr virQEMUDriverGetConfig(virQEMUDriverPtr driver)
{
- return virObjectRef(driver->config);
+ virQEMUDriverConfigPtr conf;
+ qemuDriverLock(driver);
+ conf = virObjectRef(driver->config);
+ qemuDriverUnlock(driver);
+ return conf;
}
@@ -613,16 +617,22 @@ err_exit:
virCapsPtr virQEMUDriverGetCapabilities(virQEMUDriverPtr driver,
bool refresh)
{
+ virCapsPtr ret = NULL;
if (refresh) {
virCapsPtr caps = NULL;
if ((caps = virQEMUDriverCreateCapabilities(driver)) == NULL)
return NULL;
+ qemuDriverLock(driver);
virObjectUnref(driver->caps);
driver->caps = caps;
+ } else {
+ qemuDriverLock(driver);
}
- return virObjectRef(driver->caps);
+ ret = virObjectRef(driver->caps);
+ qemuDriverUnlock(driver);
+ return ret;
}
@@ -657,7 +667,9 @@ qemuDriverCloseCallbackSet(virQEMUDriverPtr driver,
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
qemuDriverCloseDefPtr closeDef;
+ int ret = -1;
+ qemuDriverLock(driver);
virUUIDFormat(vm->def->uuid, uuidstr);
VIR_DEBUG("vm=%s, uuid=%s, conn=%p, cb=%p",
vm->def->name, uuidstr, conn, cb);
@@ -669,30 +681,34 @@ qemuDriverCloseCallbackSet(virQEMUDriverPtr driver,
_("Close callback for domain %s already registered"
" with another connection %p"),
vm->def->name, closeDef->conn);
- return -1;
+ goto cleanup;
}
if (closeDef->cb && closeDef->cb != cb) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Another close callback is already defined for"
" domain %s"), vm->def->name);
- return -1;
+ goto cleanup;
}
closeDef->cb = cb;
} else {
if (VIR_ALLOC(closeDef) < 0) {
virReportOOMError();
- return -1;
+ goto cleanup;
}
closeDef->conn = conn;
closeDef->cb = cb;
if (virHashAddEntry(driver->closeCallbacks, uuidstr, closeDef) < 0) {
VIR_FREE(closeDef);
- return -1;
+ goto cleanup;
}
}
- return 0;
+
+ ret = 0;
+cleanup:
+ qemuDriverUnlock(driver);
+ return ret;
}
int
@@ -702,23 +718,28 @@ qemuDriverCloseCallbackUnset(virQEMUDriverPtr driver,
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
qemuDriverCloseDefPtr closeDef;
+ int ret = -1;
+ qemuDriverLock(driver);
virUUIDFormat(vm->def->uuid, uuidstr);
VIR_DEBUG("vm=%s, uuid=%s, cb=%p",
vm->def->name, uuidstr, cb);
closeDef = virHashLookup(driver->closeCallbacks, uuidstr);
if (!closeDef)
- return -1;
+ goto cleanup;
if (closeDef->cb && closeDef->cb != cb) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Trying to remove mismatching close callback for"
" domain %s"), vm->def->name);
- return -1;
+ goto cleanup;
}
- return virHashRemoveEntry(driver->closeCallbacks, uuidstr);
+ ret = virHashRemoveEntry(driver->closeCallbacks, uuidstr);
+cleanup:
+ qemuDriverUnlock(driver);
+ return ret;
}
qemuDriverCloseCallback
@@ -730,6 +751,7 @@ qemuDriverCloseCallbackGet(virQEMUDriverPtr driver,
qemuDriverCloseDefPtr closeDef;
qemuDriverCloseCallback cb = NULL;
+ qemuDriverLock(driver);
virUUIDFormat(vm->def->uuid, uuidstr);
VIR_DEBUG("vm=%s, uuid=%s, conn=%p",
vm->def->name, uuidstr, conn);
@@ -739,6 +761,7 @@ qemuDriverCloseCallbackGet(virQEMUDriverPtr driver,
cb = closeDef->cb;
VIR_DEBUG("cb=%p", cb);
+ qemuDriverUnlock(driver);
return cb;
}
@@ -794,8 +817,9 @@ qemuDriverCloseCallbackRunAll(virQEMUDriverPtr driver,
driver, conn
};
VIR_DEBUG("conn=%p", conn);
-
+ qemuDriverLock(driver);
virHashForEach(driver->closeCallbacks, qemuDriverCloseCallbackRun, &data);
+ qemuDriverUnlock(driver);
}
/* Construct the hash key for sharedDisks as "major:minor" */
@@ -832,6 +856,7 @@ qemuAddSharedDisk(virQEMUDriverPtr driver,
char *key = NULL;
int ret = -1;
+ qemuDriverLock(driver);
if (!(key = qemuGetSharedDiskKey(disk_path)))
goto cleanup;
@@ -845,6 +870,7 @@ qemuAddSharedDisk(virQEMUDriverPtr driver,
ret = 0;
cleanup:
+ qemuDriverUnlock(driver);
VIR_FREE(key);
return ret;
}
@@ -860,6 +886,7 @@ qemuRemoveSharedDisk(virQEMUDriverPtr driver,
char *key = NULL;
int ret = -1;
+ qemuDriverLock(driver);
if (!(key = qemuGetSharedDiskKey(disk_path)))
goto cleanup;
@@ -876,6 +903,7 @@ qemuRemoveSharedDisk(virQEMUDriverPtr driver,
ret = 0;
cleanup:
+ qemuDriverUnlock(driver);
VIR_FREE(key);
return ret;
}
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 4917721..ec4c8f8 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -760,12 +760,10 @@ qemuDomainJobAllowed(qemuDomainObjPrivatePtr priv, enum qemuDomainJob job)
#define QEMU_JOB_WAIT_TIME (1000ull * 30)
/*
- * obj must be locked before calling; driver_locked says if qemu_driver is
- * locked or not.
+ * obj must be locked before calling;
*/
static int ATTRIBUTE_NONNULL(1)
qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
- bool driver_locked,
virDomainObjPtr obj,
enum qemuDomainJob job,
enum qemuDomainAsyncJob asyncJob)
@@ -786,8 +784,6 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
then = now + QEMU_JOB_WAIT_TIME;
virObjectRef(obj);
- if (driver_locked)
- qemuDriverUnlock(driver);
retry:
if (cfg->maxQueuedJobs &&
@@ -827,12 +823,6 @@ retry:
priv->job.start = now;
}
- if (driver_locked) {
- virObjectUnlock(obj);
- qemuDriverLock(driver);
- virObjectLock(obj);
- }
-
if (qemuDomainTrackJob(job))
qemuDomainObjSaveJob(driver, obj);
@@ -861,11 +851,6 @@ error:
virReportSystemError(errno,
"%s", _("cannot acquire job mutex"));
priv->jobs_queued--;
- if (driver_locked) {
- virObjectUnlock(obj);
- qemuDriverLock(driver);
- virObjectLock(obj);
- }
virObjectUnref(obj);
virObjectUnref(cfg);
return -1;
@@ -884,7 +869,7 @@ int qemuDomainObjBeginJob(virQEMUDriverPtr driver,
virDomainObjPtr obj,
enum qemuDomainJob job)
{
- return qemuDomainObjBeginJobInternal(driver, false, obj, job,
+ return qemuDomainObjBeginJobInternal(driver, obj, job,
QEMU_ASYNC_JOB_NONE);
}
@@ -892,40 +877,10 @@ int qemuDomainObjBeginAsyncJob(virQEMUDriverPtr driver,
virDomainObjPtr obj,
enum qemuDomainAsyncJob asyncJob)
{
- return qemuDomainObjBeginJobInternal(driver, false, obj, QEMU_JOB_ASYNC,
+ return qemuDomainObjBeginJobInternal(driver, obj, QEMU_JOB_ASYNC,
asyncJob);
}
-/*
- * obj and driver must be locked before calling.
- *
- * This must be called by anything that will change the VM state
- * in any way, or anything that will use the QEMU monitor.
- *
- * Upon successful return, the object will have its ref count increased,
- * successful calls must be followed by EndJob eventually
- */
-int qemuDomainObjBeginJobWithDriver(virQEMUDriverPtr driver,
- virDomainObjPtr obj,
- enum qemuDomainJob job)
-{
- if (job <= QEMU_JOB_NONE || job >= QEMU_JOB_ASYNC) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Attempt to start invalid job"));
- return -1;
- }
-
- return qemuDomainObjBeginJobInternal(driver, true, obj, job,
- QEMU_ASYNC_JOB_NONE);
-}
-
-int qemuDomainObjBeginAsyncJobWithDriver(virQEMUDriverPtr driver,
- virDomainObjPtr obj,
- enum qemuDomainAsyncJob asyncJob)
-{
- return qemuDomainObjBeginJobInternal(driver, true, obj, QEMU_JOB_ASYNC,
- asyncJob);
-}
/*
* obj must be locked before calling, driver does not matter
@@ -983,9 +938,17 @@ qemuDomainObjAbortAsyncJob(virDomainObjPtr obj)
priv->job.asyncAbort = true;
}
+/*
+ * obj must be locked before calling
+ *
+ * To be called immediately before any QEMU monitor API call
+ * Must have already either called qemuDomainObjBeginJob() and checked
+ * that the VM is still active; may not be used for nested async jobs.
+ *
+ * To be followed with qemuDomainObjExitMonitor() once complete
+ */
static int
qemuDomainObjEnterMonitorInternal(virQEMUDriverPtr driver,
- bool driver_locked,
virDomainObjPtr obj,
enum qemuDomainAsyncJob asyncJob)
{
@@ -1000,7 +963,7 @@ qemuDomainObjEnterMonitorInternal(virQEMUDriverPtr driver,
if (priv->job.asyncOwner != virThreadSelfID())
VIR_WARN("This thread doesn't seem to be the async job owner: %d",
priv->job.asyncOwner);
- if (qemuDomainObjBeginJobInternal(driver, driver_locked, obj,
+ if (qemuDomainObjBeginJobInternal(driver, obj,
QEMU_JOB_ASYNC_NESTED,
QEMU_ASYNC_JOB_NONE) < 0)
return -1;
@@ -1020,15 +983,12 @@ qemuDomainObjEnterMonitorInternal(virQEMUDriverPtr driver,
virObjectRef(priv->mon);
ignore_value(virTimeMillisNow(&priv->monStart));
virObjectUnlock(obj);
- if (driver_locked)
- qemuDriverUnlock(driver);
return 0;
}
static void ATTRIBUTE_NONNULL(1)
qemuDomainObjExitMonitorInternal(virQEMUDriverPtr driver,
- bool driver_locked,
virDomainObjPtr obj)
{
qemuDomainObjPrivatePtr priv = obj->privateData;
@@ -1039,8 +999,6 @@ qemuDomainObjExitMonitorInternal(virQEMUDriverPtr driver,
if (hasRefs)
virObjectUnlock(priv->mon);
- if (driver_locked)
- qemuDriverLock(driver);
virObjectLock(obj);
priv->monStart = 0;
@@ -1056,59 +1014,34 @@ qemuDomainObjExitMonitorInternal(virQEMUDriverPtr driver,
}
}
-/*
- * obj must be locked before calling, driver must be unlocked
- *
- * To be called immediately before any QEMU monitor API call
- * Must have already either called qemuDomainObjBeginJob() and checked
- * that the VM is still active; may not be used for nested async jobs.
- *
- * To be followed with qemuDomainObjExitMonitor() once complete
- */
void qemuDomainObjEnterMonitor(virQEMUDriverPtr driver,
virDomainObjPtr obj)
{
- ignore_value(qemuDomainObjEnterMonitorInternal(driver, false, obj,
+ ignore_value(qemuDomainObjEnterMonitorInternal(driver, obj,
QEMU_ASYNC_JOB_NONE));
}
-/* obj must NOT be locked before calling, driver must be unlocked
+/* obj must NOT be locked before calling
*
* Should be paired with an earlier qemuDomainObjEnterMonitor() call
*/
void qemuDomainObjExitMonitor(virQEMUDriverPtr driver,
virDomainObjPtr obj)
{
- qemuDomainObjExitMonitorInternal(driver, false, obj);
+ qemuDomainObjExitMonitorInternal(driver, obj);
}
/*
- * obj must be locked before calling, driver must be locked
- *
- * To be called immediately before any QEMU monitor API call
- * Must have already either called qemuDomainObjBeginJobWithDriver() and
- * checked that the VM is still active; may not be used for nested async jobs.
- *
- * To be followed with qemuDomainObjExitMonitorWithDriver() once complete
- */
-void qemuDomainObjEnterMonitorWithDriver(virQEMUDriverPtr driver,
- virDomainObjPtr obj)
-{
- ignore_value(qemuDomainObjEnterMonitorInternal(driver, true, obj,
- QEMU_ASYNC_JOB_NONE));
-}
-
-/*
- * obj and driver must be locked before calling
+ * obj must be locked before calling
*
* To be called immediately before any QEMU monitor API call.
- * Must have already either called qemuDomainObjBeginJobWithDriver()
+ * Must have already either called qemuDomainObjBeginJob()
* and checked that the VM is still active, with asyncJob of
* QEMU_ASYNC_JOB_NONE; or already called qemuDomainObjBeginAsyncJob,
* with the same asyncJob.
*
* Returns 0 if job was started, in which case this must be followed with
- * qemuDomainObjExitMonitorWithDriver(); or -1 if the job could not be
+ * qemuDomainObjExitMonitor(); or -1 if the job could not be
* started (probably because the vm exited in the meantime).
*/
int
@@ -1116,26 +1049,22 @@ qemuDomainObjEnterMonitorAsync(virQEMUDriverPtr driver,
virDomainObjPtr obj,
enum qemuDomainAsyncJob asyncJob)
{
- return qemuDomainObjEnterMonitorInternal(driver, true, obj, asyncJob);
-}
-
-/* obj must NOT be locked before calling, driver must be unlocked,
- * and will be locked after returning
- *
- * Should be paired with an earlier qemuDomainObjEnterMonitorWithDriver() call
- */
-void qemuDomainObjExitMonitorWithDriver(virQEMUDriverPtr driver,
- virDomainObjPtr obj)
-{
- qemuDomainObjExitMonitorInternal(driver, true, obj);
+ return qemuDomainObjEnterMonitorInternal(driver, obj, asyncJob);
}
-static int
-qemuDomainObjEnterAgentInternal(virQEMUDriverPtr driver,
- bool driver_locked,
- virDomainObjPtr obj)
+/*
+ * obj must be locked before calling
+ *
+ * To be called immediately before any QEMU agent API call.
+ * Must have already called qemuDomainObjBeginJob() and checked
+ * that the VM is still active.
+ *
+ * To be followed with qemuDomainObjExitAgent() once complete
+ */
+void
+qemuDomainObjEnterAgent(virDomainObjPtr obj)
{
qemuDomainObjPrivatePtr priv = obj->privateData;
@@ -1143,16 +1072,15 @@ qemuDomainObjEnterAgentInternal(virQEMUDriverPtr driver,
virObjectRef(priv->agent);
ignore_value(virTimeMillisNow(&priv->agentStart));
virObjectUnlock(obj);
- if (driver_locked)
- qemuDriverUnlock(driver);
-
- return 0;
}
-static void ATTRIBUTE_NONNULL(1)
-qemuDomainObjExitAgentInternal(virQEMUDriverPtr driver,
- bool driver_locked,
- virDomainObjPtr obj)
+
+/* obj must NOT be locked before calling
+ *
+ * Should be paired with an earlier qemuDomainObjEnterAgent() call
+ */
+void
+qemuDomainObjExitAgent(virDomainObjPtr obj)
{
qemuDomainObjPrivatePtr priv = obj->privateData;
bool hasRefs;
@@ -1162,8 +1090,6 @@ qemuDomainObjExitAgentInternal(virQEMUDriverPtr driver,
if (hasRefs)
virObjectUnlock(priv->agent);
- if (driver_locked)
- qemuDriverLock(driver);
virObjectLock(obj);
priv->agentStart = 0;
@@ -1171,69 +1097,14 @@ qemuDomainObjExitAgentInternal(virQEMUDriverPtr driver,
priv->agent = NULL;
}
-/*
- * obj must be locked before calling, driver must be unlocked
- *
- * To be called immediately before any QEMU agent API call.
- * Must have already called qemuDomainObjBeginJob() and checked
- * that the VM is still active.
- *
- * To be followed with qemuDomainObjExitAgent() once complete
- */
-void qemuDomainObjEnterAgent(virQEMUDriverPtr driver,
- virDomainObjPtr obj)
-{
- ignore_value(qemuDomainObjEnterAgentInternal(driver, false, obj));
-}
-
-/* obj must NOT be locked before calling, driver must be unlocked
- *
- * Should be paired with an earlier qemuDomainObjEnterAgent() call
- */
-void qemuDomainObjExitAgent(virQEMUDriverPtr driver,
- virDomainObjPtr obj)
-{
- qemuDomainObjExitAgentInternal(driver, false, obj);
-}
-
-/*
- * obj must be locked before calling, driver must be locked
- *
- * To be called immediately before any QEMU agent API call.
- * Must have already called qemuDomainObjBeginJobWithDriver() and
- * checked that the VM is still active; may not be used for nested async jobs.
- *
- * To be followed with qemuDomainObjExitAgentWithDriver() once complete
- */
-void qemuDomainObjEnterAgentWithDriver(virQEMUDriverPtr driver,
- virDomainObjPtr obj)
-{
- ignore_value(qemuDomainObjEnterAgentInternal(driver, true, obj));
-}
-
-/* obj must NOT be locked before calling, driver must be unlocked,
- * and will be locked after returning
- *
- * Should be paired with an earlier qemuDomainObjEnterAgentWithDriver() call
- */
-void qemuDomainObjExitAgentWithDriver(virQEMUDriverPtr driver,
- virDomainObjPtr obj)
-{
- qemuDomainObjExitAgentInternal(driver, true, obj);
-}
-
-void qemuDomainObjEnterRemoteWithDriver(virQEMUDriverPtr driver,
- virDomainObjPtr obj)
+void qemuDomainObjEnterRemote(virDomainObjPtr obj)
{
virObjectRef(obj);
virObjectUnlock(obj);
- qemuDriverUnlock(driver);
}
-void qemuDomainObjExitRemoteWithDriver(virQEMUDriverPtr driver,
- virDomainObjPtr obj)
+void qemuDomainObjExitRemote(virDomainObjPtr obj)
{
- qemuDriverLock(driver);
virObjectLock(obj);
virObjectUnref(obj);
}
@@ -1783,10 +1654,10 @@ qemuDomainSnapshotDiscard(virQEMUDriverPtr driver,
goto cleanup;
} else {
priv = vm->privateData;
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
/* we continue on even in the face of error */
qemuMonitorDeleteSnapshot(priv->mon, snap->def->name);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
}
}
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 51cd2dc..cfc952d 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -190,14 +190,6 @@ int qemuDomainObjBeginAsyncJob(virQEMUDriverPtr driver,
virDomainObjPtr obj,
enum qemuDomainAsyncJob asyncJob)
ATTRIBUTE_RETURN_CHECK;
-int qemuDomainObjBeginJobWithDriver(virQEMUDriverPtr driver,
- virDomainObjPtr obj,
- enum qemuDomainJob job)
- ATTRIBUTE_RETURN_CHECK;
-int qemuDomainObjBeginAsyncJobWithDriver(virQEMUDriverPtr driver,
- virDomainObjPtr obj,
- enum qemuDomainAsyncJob asyncJob)
- ATTRIBUTE_RETURN_CHECK;
bool qemuDomainObjEndJob(virQEMUDriverPtr driver,
virDomainObjPtr obj)
@@ -224,38 +216,22 @@ void qemuDomainObjEnterMonitor(virQEMUDriverPtr driver,
void qemuDomainObjExitMonitor(virQEMUDriverPtr driver,
virDomainObjPtr obj)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
-void qemuDomainObjEnterMonitorWithDriver(virQEMUDriverPtr driver,
- virDomainObjPtr obj)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
int qemuDomainObjEnterMonitorAsync(virQEMUDriverPtr driver,
virDomainObjPtr obj,
enum qemuDomainAsyncJob asyncJob)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
-void qemuDomainObjExitMonitorWithDriver(virQEMUDriverPtr driver,
- virDomainObjPtr obj)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
-void qemuDomainObjEnterAgent(virQEMUDriverPtr driver,
- virDomainObjPtr obj)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
-void qemuDomainObjExitAgent(virQEMUDriverPtr driver,
- virDomainObjPtr obj)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
-void qemuDomainObjEnterAgentWithDriver(virQEMUDriverPtr driver,
- virDomainObjPtr obj)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
-void qemuDomainObjExitAgentWithDriver(virQEMUDriverPtr driver,
- virDomainObjPtr obj)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+void qemuDomainObjEnterAgent(virDomainObjPtr obj)
+ ATTRIBUTE_NONNULL(1);
+void qemuDomainObjExitAgent(virDomainObjPtr obj)
+ ATTRIBUTE_NONNULL(1);
-void qemuDomainObjEnterRemoteWithDriver(virQEMUDriverPtr driver,
- virDomainObjPtr obj)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
-void qemuDomainObjExitRemoteWithDriver(virQEMUDriverPtr driver,
- virDomainObjPtr obj)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+void qemuDomainObjEnterRemote(virDomainObjPtr obj)
+ ATTRIBUTE_NONNULL(1);
+void qemuDomainObjExitRemote(virDomainObjPtr obj)
+ ATTRIBUTE_NONNULL(1);
int qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
virDomainDefPtr vm,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index a4fc0c9..4d756f3 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -153,16 +153,9 @@ virQEMUDriverPtr qemu_driver = NULL;
static void
-qemuVMDriverLock(void) {
- qemuDriverLock(qemu_driver);
-};
-
-
+qemuVMDriverLock(void) {}
static void
-qemuVMDriverUnlock(void) {
- qemuDriverUnlock(qemu_driver);
-};
-
+qemuVMDriverUnlock(void) {}
static int
qemuVMFilterRebuild(virConnectPtr conn ATTRIBUTE_UNUSED,
@@ -184,61 +177,32 @@ struct qemuAutostartData {
virConnectPtr conn;
};
+
/**
- * qemuDomObjFromDomainDriver:
+ * qemuDomObjFromDomain:
* @domain: Domain pointer that has to be looked up
- * @drv: Pointer to virQEMUDriverPtr to return the driver object
*
- * This function looks up @domain in the domain list and returns the
- * appropriate virDomainObjPtr. On successful lookup, both driver and domain
- * object are returned locked.
+ * This function looks up @domain and returns the appropriate
+ * virDomainObjPtr.
*
- * Returns the domain object if it's found and the driver. Both are locked.
- * In case of failure NULL is returned and the driver isn't locked.
+ * Returns the domain object which is locked on success, NULL
+ * otherwise.
*/
static virDomainObjPtr
-qemuDomObjFromDomainDriver(virDomainPtr domain, virQEMUDriverPtr *drv)
+qemuDomObjFromDomain(virDomainPtr domain)
{
- virQEMUDriverPtr driver = domain->conn->privateData;
virDomainObjPtr vm;
+ virQEMUDriverPtr driver = domain->conn->privateData;
char uuidstr[VIR_UUID_STRING_BUFLEN];
- qemuDriverLock(driver);
vm = virDomainObjListFindByUUID(driver->domains, domain->uuid);
if (!vm) {
virUUIDFormat(domain->uuid, uuidstr);
virReportError(VIR_ERR_NO_DOMAIN,
_("no domain with matching uuid '%s'"), uuidstr);
- qemuDriverUnlock(driver);
- *drv = NULL;
return NULL;
}
- *drv = driver;
- return vm;
-}
-
-/**
- * qemuDomObjFromDomain:
- * @domain: Domain pointer that has to be looked up
- *
- * This function looks up @domain and returns the appropriate
- * virDomainObjPtr. The driver is unlocked after the call.
- *
- * Returns the domain object which is locked on success, NULL
- * otherwise. The driver remains unlocked after the call.
- */
-static virDomainObjPtr
-qemuDomObjFromDomain(virDomainPtr domain)
-{
- virDomainObjPtr vm;
- virQEMUDriverPtr driver;
-
- if (!(vm = qemuDomObjFromDomainDriver(domain, &driver)))
- return NULL;
-
- qemuDriverUnlock(driver);
-
return vm;
}
@@ -293,8 +257,8 @@ qemuAutostartDomain(virDomainObjPtr vm,
virResetLastError();
if (vm->autostart &&
!virDomainObjIsActive(vm)) {
- if (qemuDomainObjBeginJobWithDriver(data->driver, vm,
- QEMU_JOB_MODIFY) < 0) {
+ if (qemuDomainObjBeginJob(data->driver, vm,
+ QEMU_JOB_MODIFY) < 0) {
err = virGetLastError();
VIR_ERROR(_("Failed to start job on VM '%s': %s"),
vm->def->name,
@@ -335,9 +299,7 @@ qemuAutostartDomains(virQEMUDriverPtr driver)
/* Ignoring NULL conn which is mostly harmless here */
struct qemuAutostartData data = { driver, conn };
- qemuDriverLock(driver);
virDomainObjListForEach(driver->domains, qemuAutostartDomain, &data);
- qemuDriverUnlock(driver);
if (conn)
virConnectClose(conn);
@@ -603,7 +565,6 @@ qemuStartup(bool privileged,
VIR_FREE(qemu_driver);
return -1;
}
- qemuDriverLock(qemu_driver);
qemu_driver->inhibitCallback = callback;
qemu_driver->inhibitOpaque = opaque;
@@ -841,8 +802,6 @@ qemuStartup(bool privileged,
if (!qemu_driver->workerPool)
goto error;
- qemuDriverUnlock(qemu_driver);
-
qemuAutostartDomains(qemu_driver);
if (conn)
@@ -854,8 +813,6 @@ qemuStartup(bool privileged,
out_of_memory:
virReportOOMError();
error:
- if (qemu_driver)
- qemuDriverUnlock(qemu_driver);
if (conn)
virConnectClose(conn);
VIR_FREE(driverConf);
@@ -893,7 +850,6 @@ qemuReload(void) {
if (!qemu_driver)
return 0;
- qemuDriverLock(qemu_driver);
if (!(caps = virQEMUDriverGetCapabilities(qemu_driver, false)))
goto cleanup;
@@ -904,9 +860,7 @@ qemuReload(void) {
cfg->autostartDir,
0, QEMU_EXPECTED_VIRT_TYPES,
qemuNotifyLoadDomain, qemu_driver);
-
cleanup:
- qemuDriverUnlock(qemu_driver);
virObjectUnref(cfg);
virObjectUnref(caps);
return 0;
@@ -987,7 +941,6 @@ qemuShutdown(void) {
if (!qemu_driver)
return -1;
- qemuDriverLock(qemu_driver);
virNWFilterUnRegisterCallbackDriver(&qemuCallbackDriver);
virObjectUnref(qemu_driver->activePciHostdevs);
virObjectUnref(qemu_driver->inactivePciHostdevs);
@@ -1016,7 +969,6 @@ qemuShutdown(void) {
virLockManagerPluginUnref(qemu_driver->lockManager);
- qemuDriverUnlock(qemu_driver);
virMutexDestroy(&qemu_driver->lock);
virThreadPoolFree(qemu_driver->workerPool);
VIR_FREE(qemu_driver);
@@ -1100,9 +1052,7 @@ static int qemuClose(virConnectPtr conn) {
virQEMUDriverPtr driver = conn->privateData;
/* Get rid of callbacks registered for this conn */
- qemuDriverLock(driver);
qemuDriverCloseCallbackRunAll(driver, conn);
- qemuDriverUnlock(driver);
conn->privateData = NULL;
@@ -1218,9 +1168,7 @@ static char *qemuGetCapabilities(virConnectPtr conn) {
virCapsPtr caps = NULL;
char *xml = NULL;
- qemuDriverLock(driver);
-
- if (!(caps = virQEMUDriverGetCapabilities(qemu_driver, true)))
+ if (!(caps = virQEMUDriverGetCapabilities(driver, true)))
goto cleanup;
if ((xml = virCapabilitiesFormatXML(caps)) == NULL)
@@ -1228,7 +1176,6 @@ static char *qemuGetCapabilities(virConnectPtr conn) {
virObjectUnref(caps);
cleanup:
- qemuDriverUnlock(driver);
return xml;
}
@@ -1316,9 +1263,7 @@ static virDomainPtr qemuDomainLookupByID(virConnectPtr conn,
virDomainObjPtr vm;
virDomainPtr dom = NULL;
- qemuDriverLock(driver);
vm = virDomainObjListFindByID(driver->domains, id);
- qemuDriverUnlock(driver);
if (!vm) {
virReportError(VIR_ERR_NO_DOMAIN,
@@ -1341,9 +1286,7 @@ static virDomainPtr qemuDomainLookupByUUID(virConnectPtr conn,
virDomainObjPtr vm;
virDomainPtr dom = NULL;
- qemuDriverLock(driver);
vm = virDomainObjListFindByUUID(driver->domains, uuid);
- qemuDriverUnlock(driver);
if (!vm) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -1368,9 +1311,7 @@ static virDomainPtr qemuDomainLookupByName(virConnectPtr conn,
virDomainObjPtr vm;
virDomainPtr dom = NULL;
- qemuDriverLock(driver);
vm = virDomainObjListFindByName(driver->domains, name);
- qemuDriverUnlock(driver);
if (!vm) {
virReportError(VIR_ERR_NO_DOMAIN,
@@ -1442,7 +1383,6 @@ static int qemuGetVersion(virConnectPtr conn, unsigned long *version) {
unsigned int qemuVersion;
virCapsPtr caps = NULL;
- qemuDriverLock(driver);
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
@@ -1456,7 +1396,6 @@ static int qemuGetVersion(virConnectPtr conn, unsigned long *version) {
cleanup:
virObjectUnref(caps);
- qemuDriverUnlock(driver);
return ret;
}
@@ -1464,9 +1403,7 @@ static int qemuListDomains(virConnectPtr conn, int *ids, int nids) {
virQEMUDriverPtr driver = conn->privateData;
int n;
- qemuDriverLock(driver);
n = virDomainObjListGetActiveIDs(driver->domains, ids, nids);
- qemuDriverUnlock(driver);
return n;
}
@@ -1475,9 +1412,7 @@ static int qemuNumDomains(virConnectPtr conn) {
virQEMUDriverPtr driver = conn->privateData;
int n;
- qemuDriverLock(driver);
n = virDomainObjListNumOfDomains(driver->domains, 1);
- qemuDriverUnlock(driver);
return n;
}
@@ -1525,8 +1460,6 @@ static virDomainPtr qemuDomainCreate(virConnectPtr conn, const char *xml,
if (flags & VIR_DOMAIN_START_AUTODESTROY)
start_flags |= VIR_QEMU_PROCESS_START_AUTODESROY;
- qemuDriverLock(driver);
-
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
@@ -1556,7 +1489,7 @@ static virDomainPtr qemuDomainCreate(virConnectPtr conn, const char *xml,
def = NULL;
- if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0)
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup; /* XXXX free the 'vm' we created ? */
if (qemuProcessStart(conn, driver, vm, NULL, -1, NULL, NULL,
@@ -1602,7 +1535,6 @@ cleanup:
}
virObjectUnref(caps);
virObjectUnref(qemuCaps);
- qemuDriverUnlock(driver);
return dom;
}
@@ -1619,7 +1551,6 @@ static int qemuDomainSuspend(virDomainPtr dom) {
virQEMUDriverConfigPtr cfg = NULL;
virCapsPtr caps = NULL;
- qemuDriverLock(driver);
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
if (!vm) {
@@ -1638,7 +1569,7 @@ static int qemuDomainSuspend(virDomainPtr dom) {
cfg = virQEMUDriverGetConfig(driver);
priv = vm->privateData;
- if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_SUSPEND) < 0)
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_SUSPEND) < 0)
goto cleanup;
if (!virDomainObjIsActive(vm)) {
@@ -1690,7 +1621,6 @@ cleanup:
if (event)
qemuDomainEventQueue(driver, event);
- qemuDriverUnlock(driver);
virObjectUnref(caps);
virObjectUnref(cfg);
return ret;
@@ -1706,7 +1636,6 @@ static int qemuDomainResume(virDomainPtr dom) {
virQEMUDriverConfigPtr cfg = NULL;
virCapsPtr caps = NULL;
- qemuDriverLock(driver);
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
if (!vm) {
@@ -1719,7 +1648,7 @@ static int qemuDomainResume(virDomainPtr dom) {
cfg = virQEMUDriverGetConfig(driver);
- if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0)
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
if (!virDomainObjIsActive(vm)) {
@@ -1761,7 +1690,6 @@ cleanup:
virObjectUnlock(vm);
if (event)
qemuDomainEventQueue(driver, event);
- qemuDriverUnlock(driver);
virObjectUnref(caps);
virObjectUnref(cfg);
return ret;
@@ -1819,9 +1747,9 @@ static int qemuDomainShutdownFlags(virDomainPtr dom, unsigned int flags) {
}
if (useAgent) {
- qemuDomainObjEnterAgent(driver, vm);
+ qemuDomainObjEnterAgent(vm);
ret = qemuAgentShutdown(priv->agent, QEMU_AGENT_SHUTDOWN_POWERDOWN);
- qemuDomainObjExitAgent(driver, vm);
+ qemuDomainObjExitAgent(vm);
} else {
qemuDomainSetFakeReboot(driver, vm, false);
@@ -1916,9 +1844,9 @@ qemuDomainReboot(virDomainPtr dom, unsigned int flags)
}
if (useAgent) {
- qemuDomainObjEnterAgent(driver, vm);
+ qemuDomainObjEnterAgent(vm);
ret = qemuAgentShutdown(priv->agent, QEMU_AGENT_SHUTDOWN_REBOOT);
- qemuDomainObjExitAgent(driver, vm);
+ qemuDomainObjExitAgent(vm);
} else {
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorSystemPowerdown(priv->mon);
@@ -2004,7 +1932,6 @@ qemuDomainDestroyFlags(virDomainPtr dom,
virCheckFlags(VIR_DOMAIN_DESTROY_GRACEFUL, -1);
- qemuDriverLock(driver);
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
if (!vm) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -2030,18 +1957,18 @@ qemuDomainDestroyFlags(virDomainPtr dom,
* it now means the job will be released
*/
if (flags & VIR_DOMAIN_DESTROY_GRACEFUL) {
- if (qemuProcessKill(driver, vm, 0) < 0) {
+ if (qemuProcessKill(vm, 0) < 0) {
priv->beingDestroyed = false;
goto cleanup;
}
} else {
- if (qemuProcessKill(driver, vm, VIR_QEMU_PROCESS_KILL_FORCE) < 0) {
+ if (qemuProcessKill(vm, VIR_QEMU_PROCESS_KILL_FORCE) < 0) {
priv->beingDestroyed = false;
goto cleanup;
}
}
- if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_DESTROY) < 0)
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_DESTROY) < 0)
goto cleanup;
priv->beingDestroyed = false;
@@ -2075,7 +2002,6 @@ cleanup:
virObjectUnlock(vm);
if (event)
qemuDomainEventQueue(driver, event);
- qemuDriverUnlock(driver);
return ret;
}
@@ -2235,7 +2161,6 @@ static int qemuDomainInjectNMI(virDomainPtr domain, unsigned int flags)
virCheckFlags(0, -1);
- qemuDriverLock(driver);
vm = virDomainObjListFindByUUID(driver->domains, domain->uuid);
if (!vm) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -2253,7 +2178,7 @@ static int qemuDomainInjectNMI(virDomainPtr domain, unsigned int flags)
priv = vm->privateData;
- if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0)
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
if (!virDomainObjIsActive(vm)) {
@@ -2262,9 +2187,9 @@ static int qemuDomainInjectNMI(virDomainPtr domain, unsigned int flags)
goto endjob;
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorInjectNMI(priv->mon);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0) {
@@ -2275,7 +2200,6 @@ endjob:
cleanup:
if (vm)
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
return ret;
}
@@ -2847,7 +2771,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
if (!qemuMigrationIsAllowed(driver, vm, vm->def, false))
goto cleanup;
- if (qemuDomainObjBeginAsyncJobWithDriver(driver, vm,
+ if (qemuDomainObjBeginAsyncJob(driver, vm,
QEMU_ASYNC_JOB_SAVE) < 0)
memset(&priv->job.info, 0, sizeof(priv->job.info));
@@ -2975,8 +2899,6 @@ qemuDomainSaveFlags(virDomainPtr dom, const char *path, const char *dxml,
VIR_DOMAIN_SAVE_RUNNING |
VIR_DOMAIN_SAVE_PAUSED, -1);
- qemuDriverLock(driver);
-
cfg = virQEMUDriverGetConfig(driver);
if (cfg->saveImageFormat == NULL)
compressed = QEMU_SAVE_FORMAT_RAW;
@@ -3018,7 +2940,6 @@ qemuDomainSaveFlags(virDomainPtr dom, const char *path, const char *dxml,
cleanup:
if (vm)
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
virObjectUnref(cfg);
return ret;
}
@@ -3048,7 +2969,7 @@ qemuDomainManagedSavePath(virQEMUDriverPtr driver, virDomainObjPtr vm)
static int
qemuDomainManagedSave(virDomainPtr dom, unsigned int flags)
{
- virQEMUDriverPtr driver;
+ virQEMUDriverPtr driver = dom->conn->privateData;
virDomainObjPtr vm;
char *name = NULL;
int ret = -1;
@@ -3058,7 +2979,7 @@ qemuDomainManagedSave(virDomainPtr dom, unsigned int flags)
VIR_DOMAIN_SAVE_RUNNING |
VIR_DOMAIN_SAVE_PAUSED, -1);
- if (!(vm = qemuDomObjFromDomainDriver(dom, &driver)))
+ if (!(vm = qemuDomObjFromDomain(dom)))
return -1;
if (!virDomainObjIsActive(vm)) {
@@ -3087,7 +3008,6 @@ qemuDomainManagedSave(virDomainPtr dom, unsigned int flags)
cleanup:
if (vm)
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
VIR_FREE(name);
return ret;
@@ -3135,14 +3055,14 @@ qemuDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags)
static int
qemuDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags)
{
- virQEMUDriverPtr driver;
+ virQEMUDriverPtr driver = dom->conn->privateData;
virDomainObjPtr vm;
int ret = -1;
char *name = NULL;
virCheckFlags(0, -1);
- if (!(vm = qemuDomObjFromDomainDriver(dom, &driver)))
+ if (!(vm = qemuDomObjFromDomain(dom)))
return -1;
if (!(name = qemuDomainManagedSavePath(driver, vm)))
@@ -3161,7 +3081,6 @@ qemuDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags)
cleanup:
VIR_FREE(name);
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
return ret;
}
@@ -3187,7 +3106,7 @@ static int qemuDumpToFd(virQEMUDriverPtr driver, virDomainObjPtr vm,
return -1;
ret = qemuMonitorDumpToFd(priv->mon, fd);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
return ret;
}
@@ -3305,7 +3224,6 @@ static int qemuDomainCoreDump(virDomainPtr dom,
VIR_DUMP_BYPASS_CACHE | VIR_DUMP_RESET |
VIR_DUMP_MEMORY_ONLY, -1);
- qemuDriverLock(driver);
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
if (!vm) {
@@ -3316,7 +3234,7 @@ static int qemuDomainCoreDump(virDomainPtr dom,
goto cleanup;
}
- if (qemuDomainObjBeginAsyncJobWithDriver(driver, vm,
+ if (qemuDomainObjBeginAsyncJob(driver, vm,
QEMU_ASYNC_JOB_DUMP) < 0)
goto cleanup;
@@ -3367,9 +3285,9 @@ endjob:
virDomainObjIsActive(vm)) {
if ((ret == 0) && (flags & VIR_DUMP_RESET)) {
priv = vm->privateData;
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorSystemReset(priv->mon);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
}
if (resume && qemuProcessStartCPUs(driver, vm, dom->conn,
@@ -3396,7 +3314,6 @@ cleanup:
virObjectUnlock(vm);
if (event)
qemuDomainEventQueue(driver, event);
- qemuDriverUnlock(driver);
return ret;
}
@@ -3497,7 +3414,6 @@ static void processWatchdogEvent(void *data, void *opaque)
virQEMUDriverPtr driver = opaque;
virQEMUDriverConfigPtr cfg;
- qemuDriverLock(driver);
virObjectLock(wdEvent->vm);
cfg = virQEMUDriverGetConfig(driver);
@@ -3515,7 +3431,7 @@ static void processWatchdogEvent(void *data, void *opaque)
goto unlock;
}
- if (qemuDomainObjBeginAsyncJobWithDriver(driver, wdEvent->vm,
+ if (qemuDomainObjBeginAsyncJob(driver, wdEvent->vm,
QEMU_ASYNC_JOB_DUMP) < 0) {
VIR_FREE(dumpfile);
goto unlock;
@@ -3559,7 +3475,6 @@ endjob:
unlock:
virObjectUnlock(wdEvent->vm);
virObjectUnref(wdEvent->vm);
- qemuDriverUnlock(driver);
VIR_FREE(wdEvent);
virObjectUnref(cfg);
}
@@ -4517,7 +4432,6 @@ static int qemuDomainGetSecurityLabel(virDomainPtr dom, virSecurityLabelPtr secl
virDomainObjPtr vm;
int ret = -1;
- qemuDriverLock(driver);
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
memset(seclabel, 0, sizeof(*seclabel));
@@ -4565,7 +4479,6 @@ static int qemuDomainGetSecurityLabel(virDomainPtr dom, virSecurityLabelPtr secl
cleanup:
if (vm)
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
return ret;
}
@@ -4577,7 +4490,6 @@ static int qemuDomainGetSecurityLabelList(virDomainPtr dom,
int i, ret = -1;
/* Protect domain data with qemu lock */
- qemuDriverLock(driver);
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
if (!vm) {
@@ -4638,9 +4550,10 @@ static int qemuDomainGetSecurityLabelList(virDomainPtr dom,
cleanup:
if (vm)
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
return ret;
}
+
+
static int qemuNodeGetSecurityModel(virConnectPtr conn,
virSecurityModelPtr secmodel)
{
@@ -4649,7 +4562,6 @@ static int qemuNodeGetSecurityModel(virConnectPtr conn,
int ret = 0;
virCapsPtr caps = NULL;
- qemuDriverLock(driver);
memset(secmodel, 0, sizeof(*secmodel));
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
@@ -4681,7 +4593,6 @@ static int qemuNodeGetSecurityModel(virConnectPtr conn,
strcpy(secmodel->doi, p);
cleanup:
- qemuDriverUnlock(driver);
virObjectUnref(caps);
return ret;
}
@@ -4988,7 +4899,6 @@ qemuDomainRestoreFlags(virConnectPtr conn,
VIR_DOMAIN_SAVE_RUNNING |
VIR_DOMAIN_SAVE_PAUSED, -1);
- qemuDriverLock(driver);
if (flags & VIR_DOMAIN_SAVE_RUNNING)
state = 1;
@@ -5013,7 +4923,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
goto cleanup;
def = NULL;
- if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0)
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
ret = qemuDomainSaveImageStartVM(conn, driver, vm, &fd, &header, path,
@@ -5035,7 +4945,6 @@ cleanup:
if (vm)
virObjectUnlock(vm);
virObjectUnref(caps);
- qemuDriverUnlock(driver);
return ret;
}
@@ -5059,8 +4968,6 @@ qemuDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *path,
/* We only take subset of virDomainDefFormat flags. */
virCheckFlags(VIR_DOMAIN_XML_SECURE, NULL);
- qemuDriverLock(driver);
-
fd = qemuDomainSaveImageOpen(driver, path, &def, &header, false, NULL,
NULL, -1, false, false);
@@ -5072,7 +4979,6 @@ qemuDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *path,
cleanup:
virDomainDefFree(def);
VIR_FORCE_CLOSE(fd);
- qemuDriverUnlock(driver);
return ret;
}
@@ -5092,8 +4998,6 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
virCheckFlags(VIR_DOMAIN_SAVE_RUNNING |
VIR_DOMAIN_SAVE_PAUSED, -1);
- qemuDriverLock(driver);
-
if (flags & VIR_DOMAIN_SAVE_RUNNING)
state = 1;
else if (flags & VIR_DOMAIN_SAVE_PAUSED)
@@ -5144,7 +5048,6 @@ cleanup:
virDomainDefFree(def);
VIR_FORCE_CLOSE(fd);
VIR_FREE(xml);
- qemuDriverUnlock(driver);
return ret;
}
@@ -5215,7 +5118,6 @@ static char *qemuDomainGetXMLDesc(virDomainPtr dom,
/* Flags checked by virDomainDefFormat */
- qemuDriverLock(driver);
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
if (!vm) {
@@ -5236,7 +5138,7 @@ static char *qemuDomainGetXMLDesc(virDomainPtr dom,
/* Don't delay if someone's using the monitor, just use
* existing most recent data instead */
if (qemuDomainJobAllowed(priv, QEMU_JOB_QUERY)) {
- if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_QUERY) < 0)
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
goto cleanup;
if (!virDomainObjIsActive(vm)) {
@@ -5245,9 +5147,9 @@ static char *qemuDomainGetXMLDesc(virDomainPtr dom,
goto endjob;
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
err = qemuMonitorGetBalloonInfo(priv->mon, &balloon);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0) {
@@ -5270,7 +5172,6 @@ endjob:
cleanup:
if (vm)
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
return ret;
}
@@ -5293,14 +5194,11 @@ static char *qemuDomainXMLFromNative(virConnectPtr conn,
goto cleanup;
}
- qemuDriverLock(driver);
-
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
def = qemuParseCommandLineString(caps, config,
NULL, NULL, NULL);
- qemuDriverUnlock(driver);
if (!def)
goto cleanup;
@@ -5336,7 +5234,6 @@ static char *qemuDomainXMLToNative(virConnectPtr conn,
virCheckFlags(0, NULL);
- qemuDriverLock(driver);
cfg = virQEMUDriverGetConfig(driver);
if (STRNEQ(format, QEMU_CONFIG_FORMAT_ARGV)) {
@@ -5444,7 +5341,6 @@ static char *qemuDomainXMLToNative(virConnectPtr conn,
ret = virCommandToString(cmd);
cleanup:
- qemuDriverUnlock(driver);
virObjectUnref(qemuCaps);
virCommandFree(cmd);
@@ -5460,9 +5356,7 @@ static int qemuListDefinedDomains(virConnectPtr conn,
virQEMUDriverPtr driver = conn->privateData;
int n;
- qemuDriverLock(driver);
n = virDomainObjListGetInactiveNames(driver->domains, names, nnames);
- qemuDriverUnlock(driver);
return n;
}
@@ -5470,9 +5364,7 @@ static int qemuNumDefinedDomains(virConnectPtr conn) {
virQEMUDriverPtr driver = conn->privateData;
int n;
- qemuDriverLock(driver);
n = virDomainObjListNumOfDomains(driver->domains, 0);
- qemuDriverUnlock(driver);
return n;
}
@@ -5567,7 +5459,6 @@ qemuDomainStartWithFlags(virDomainPtr dom, unsigned int flags)
VIR_DOMAIN_START_BYPASS_CACHE |
VIR_DOMAIN_START_FORCE_BOOT, -1);
- qemuDriverLock(driver);
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
if (!vm) {
@@ -5578,7 +5469,7 @@ qemuDomainStartWithFlags(virDomainPtr dom, unsigned int flags)
goto cleanup;
}
- if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0)
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
if (virDomainObjIsActive(vm)) {
@@ -5599,7 +5490,6 @@ endjob:
cleanup:
if (vm)
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
return ret;
}
@@ -5620,7 +5510,6 @@ static virDomainPtr qemuDomainDefine(virConnectPtr conn, const char *xml) {
virQEMUDriverConfigPtr cfg;
virCapsPtr caps = NULL;
- qemuDriverLock(driver);
cfg = virQEMUDriverGetConfig(driver);
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
@@ -5697,7 +5586,6 @@ cleanup:
if (event)
qemuDomainEventQueue(driver, event);
virObjectUnref(qemuCaps);
- qemuDriverUnlock(driver);
virObjectUnref(caps);
virObjectUnref(cfg);
return dom;
@@ -5718,7 +5606,6 @@ qemuDomainUndefineFlags(virDomainPtr dom,
virCheckFlags(VIR_DOMAIN_UNDEFINE_MANAGED_SAVE |
VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA, -1);
- qemuDriverLock(driver);
cfg = virQEMUDriverGetConfig(driver);
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
@@ -5797,7 +5684,6 @@ cleanup:
virObjectUnlock(vm);
if (event)
qemuDomainEventQueue(driver, event);
- qemuDriverUnlock(driver);
virObjectUnref(cfg);
return ret;
}
@@ -6446,7 +6332,6 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
affect = flags & (VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG);
- qemuDriverLock(driver);
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
@@ -6460,7 +6345,7 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
}
priv = vm->privateData;
- if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0)
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
if (virDomainObjIsActive(vm)) {
@@ -6588,7 +6473,6 @@ cleanup:
virDomainDeviceDefFree(dev);
if (vm)
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
virObjectUnref(caps);
virObjectUnref(cfg);
return ret;
@@ -6651,7 +6535,6 @@ static int qemuDomainSetAutostart(virDomainPtr dom,
int ret = -1;
virQEMUDriverConfigPtr cfg = NULL;
- qemuDriverLock(driver);
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
cfg = virQEMUDriverGetConfig(driver);
if (!vm) {
@@ -6708,7 +6591,6 @@ cleanup:
VIR_FREE(autostartLink);
if (vm)
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
virObjectUnref(cfg);
return ret;
}
@@ -6754,7 +6636,6 @@ static char *qemuGetSchedulerType(virDomainPtr dom,
char *ret = NULL;
int rc;
- qemuDriverLock(driver);
if (!qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPU)) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cgroup CPU controller is not mounted"));
@@ -6776,7 +6657,6 @@ static char *qemuGetSchedulerType(virDomainPtr dom,
virReportOOMError();
cleanup:
- qemuDriverUnlock(driver);
return ret;
}
@@ -6933,7 +6813,6 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
NULL) < 0)
return -1;
- qemuDriverLock(driver);
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
if (vm == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -7061,7 +6940,6 @@ cleanup:
virCgroupFree(&group);
if (vm)
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
virObjectUnref(caps);
virObjectUnref(cfg);
return ret;
@@ -7086,7 +6964,6 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
VIR_DOMAIN_AFFECT_CONFIG |
VIR_TYPED_PARAM_STRING_OKAY, -1);
- qemuDriverLock(driver);
/* We blindly return a string, and let libvirt.c and
* remote_driver.c do the filtering on behalf of older clients
@@ -7254,7 +7131,6 @@ cleanup:
if (vm)
virObjectUnlock(vm);
virObjectUnref(caps);
- qemuDriverUnlock(driver);
return ret;
}
@@ -7292,8 +7168,6 @@ qemuDomainSetMemoryParameters(virDomainPtr dom,
NULL) < 0)
return -1;
- qemuDriverLock(driver);
-
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
if (vm == NULL) {
@@ -7429,7 +7303,6 @@ cleanup:
virCgroupFree(&group);
if (vm)
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
virObjectUnref(caps);
virObjectUnref(cfg);
return ret;
@@ -7454,8 +7327,6 @@ qemuDomainGetMemoryParameters(virDomainPtr dom,
VIR_DOMAIN_AFFECT_CONFIG |
VIR_TYPED_PARAM_STRING_OKAY, -1);
- qemuDriverLock(driver);
-
/* We don't return strings, and thus trivially support this flag. */
flags &= ~VIR_TYPED_PARAM_STRING_OKAY;
@@ -7596,7 +7467,6 @@ cleanup:
if (vm)
virObjectUnlock(vm);
virObjectUnref(caps);
- qemuDriverUnlock(driver);
return ret;
}
@@ -7625,8 +7495,6 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
NULL) < 0)
return -1;
- qemuDriverLock(driver);
-
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
if (vm == NULL) {
@@ -7751,7 +7619,6 @@ cleanup:
virCgroupFree(&group);
if (vm)
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
virObjectUnref(caps);
virObjectUnref(cfg);
return ret;
@@ -7777,8 +7644,6 @@ qemuDomainGetNumaParameters(virDomainPtr dom,
VIR_DOMAIN_AFFECT_CONFIG |
VIR_TYPED_PARAM_STRING_OKAY, -1);
- qemuDriverLock(driver);
-
/* We blindly return a string, and let libvirt.c and
* remote_driver.c do the filtering on behalf of older clients
* that can't parse it. */
@@ -7871,7 +7736,6 @@ cleanup:
if (vm)
virObjectUnlock(vm);
virObjectUnref(caps);
- qemuDriverUnlock(driver);
return ret;
}
@@ -7993,8 +7857,6 @@ qemuSetSchedulerParametersFlags(virDomainPtr dom,
NULL) < 0)
return -1;
- qemuDriverLock(driver);
-
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
if (vm == NULL) {
@@ -8129,7 +7991,6 @@ cleanup:
virCgroupFree(&group);
if (vm)
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
virObjectUnref(caps);
virObjectUnref(cfg);
return ret;
@@ -8274,8 +8135,6 @@ qemuGetSchedulerParametersFlags(virDomainPtr dom,
VIR_DOMAIN_AFFECT_CONFIG |
VIR_TYPED_PARAM_STRING_OKAY, -1);
- qemuDriverLock(driver);
-
/* We don't return strings, and thus trivially support this flag. */
flags &= ~VIR_TYPED_PARAM_STRING_OKAY;
@@ -8395,7 +8254,6 @@ cleanup:
if (vm)
virObjectUnlock(vm);
virObjectUnref(caps);
- qemuDriverUnlock(driver);
return ret;
}
@@ -8821,7 +8679,6 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
NULL) < 0)
return -1;
- qemuDriverLock(driver);
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
if (vm == NULL) {
@@ -8962,7 +8819,6 @@ cleanup:
virCgroupFree(&group);
if (vm)
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
virObjectUnref(caps);
virObjectUnref(cfg);
return ret;
@@ -8989,8 +8845,6 @@ qemuDomainGetInterfaceParameters(virDomainPtr dom,
VIR_DOMAIN_AFFECT_CONFIG |
VIR_TYPED_PARAM_STRING_OKAY, -1);
- qemuDriverLock(driver);
-
flags &= ~VIR_TYPED_PARAM_STRING_OKAY;
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
@@ -9091,7 +8945,6 @@ cleanup:
if (vm)
virObjectUnlock(vm);
virObjectUnref(caps);
- qemuDriverUnlock(driver);
return ret;
}
@@ -9452,11 +9305,9 @@ qemuDomainEventRegister(virConnectPtr conn,
virQEMUDriverPtr driver = conn->privateData;
int ret;
- qemuDriverLock(driver);
ret = virDomainEventStateRegister(conn,
driver->domainEventState,
callback, opaque, freecb);
- qemuDriverUnlock(driver);
return ret;
}
@@ -9469,11 +9320,9 @@ qemuDomainEventDeregister(virConnectPtr conn,
virQEMUDriverPtr driver = conn->privateData;
int ret;
- qemuDriverLock(driver);
ret = virDomainEventStateDeregister(conn,
driver->domainEventState,
callback);
- qemuDriverUnlock(driver);
return ret;
}
@@ -9490,13 +9339,11 @@ qemuDomainEventRegisterAny(virConnectPtr conn,
virQEMUDriverPtr driver = conn->privateData;
int ret;
- qemuDriverLock(driver);
if (virDomainEventStateRegisterID(conn,
driver->domainEventState,
dom, eventID,
callback, opaque, freecb, &ret) < 0)
ret = -1;
- qemuDriverUnlock(driver);
return ret;
}
@@ -9509,11 +9356,9 @@ qemuDomainEventDeregisterAny(virConnectPtr conn,
virQEMUDriverPtr driver = conn->privateData;
int ret;
- qemuDriverLock(driver);
ret = virDomainEventStateDeregisterID(conn,
driver->domainEventState,
callbackID);
- qemuDriverUnlock(driver);
return ret;
}
@@ -9541,8 +9386,6 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn,
virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
- qemuDriverLock(driver);
-
if (!dom_xml) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("no domain XML passed"));
@@ -9571,7 +9414,6 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn,
st, dname, dom_xml, flags);
cleanup:
- qemuDriverUnlock(driver);
return ret;
}
@@ -9597,8 +9439,6 @@ qemuDomainMigratePrepare2(virConnectPtr dconn,
*uri_out = NULL;
- qemuDriverLock(driver);
-
if (virLockManagerPluginUsesState(driver->lockManager)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Cannot use migrate v2 protocol with lock manager %s"),
@@ -9631,7 +9471,6 @@ qemuDomainMigratePrepare2(virConnectPtr dconn,
dname, dom_xml, flags);
cleanup:
- qemuDriverUnlock(driver);
return ret;
}
@@ -9653,7 +9492,6 @@ qemuDomainMigratePerform(virDomainPtr dom,
virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
- qemuDriverLock(driver);
if (virLockManagerPluginUsesState(driver->lockManager)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Cannot use migrate v2 protocol with lock manager %s"),
@@ -9687,7 +9525,6 @@ qemuDomainMigratePerform(virDomainPtr dom,
flags, dname, resource, false);
cleanup:
- qemuDriverUnlock(driver);
return ret;
}
@@ -9708,7 +9545,6 @@ qemuDomainMigrateFinish2(virConnectPtr dconn,
virCheckFlags(QEMU_MIGRATION_FLAGS, NULL);
- qemuDriverLock(driver);
vm = virDomainObjListFindByName(driver->domains, dname);
if (!vm) {
virReportError(VIR_ERR_NO_DOMAIN,
@@ -9725,7 +9561,6 @@ qemuDomainMigrateFinish2(virConnectPtr dconn,
flags, retcode, false);
cleanup:
- qemuDriverUnlock(driver);
return dom;
}
@@ -9750,7 +9585,6 @@ qemuDomainMigrateBegin3(virDomainPtr domain,
virCheckFlags(QEMU_MIGRATION_FLAGS, NULL);
- qemuDriverLock(driver);
vm = virDomainObjListFindByUUID(driver->domains, domain->uuid);
if (!vm) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -9765,7 +9599,7 @@ qemuDomainMigrateBegin3(virDomainPtr domain,
goto cleanup;
asyncJob = QEMU_ASYNC_JOB_MIGRATION_OUT;
} else {
- if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0)
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
asyncJob = QEMU_ASYNC_JOB_NONE;
}
@@ -9811,7 +9645,6 @@ qemuDomainMigrateBegin3(virDomainPtr domain,
cleanup:
if (vm)
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
return xml;
endjob:
@@ -9845,7 +9678,6 @@ qemuDomainMigratePrepare3(virConnectPtr dconn,
*uri_out = NULL;
- qemuDriverLock(driver);
if (flags & VIR_MIGRATE_TUNNELLED) {
/* this is a logical error; we never should have gotten here with
* VIR_MIGRATE_TUNNELLED set
@@ -9868,7 +9700,6 @@ qemuDomainMigratePrepare3(virConnectPtr dconn,
dname, dom_xml, flags);
cleanup:
- qemuDriverUnlock(driver);
return ret;
}
@@ -9906,12 +9737,10 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn,
goto cleanup;
}
- qemuDriverLock(driver);
ret = qemuMigrationPrepareTunnel(driver, dconn,
cookiein, cookieinlen,
cookieout, cookieoutlen,
st, dname, dom_xml, flags);
- qemuDriverUnlock(driver);
cleanup:
return ret;
@@ -9937,7 +9766,6 @@ qemuDomainMigratePerform3(virDomainPtr dom,
virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
- qemuDriverLock(driver);
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
if (!vm) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -9953,7 +9781,6 @@ qemuDomainMigratePerform3(virDomainPtr dom,
flags, dname, resource, true);
cleanup:
- qemuDriverUnlock(driver);
return ret;
}
@@ -9976,7 +9803,6 @@ qemuDomainMigrateFinish3(virConnectPtr dconn,
virCheckFlags(QEMU_MIGRATION_FLAGS, NULL);
- qemuDriverLock(driver);
vm = virDomainObjListFindByName(driver->domains, dname);
if (!vm) {
virReportError(VIR_ERR_NO_DOMAIN,
@@ -9990,7 +9816,6 @@ qemuDomainMigrateFinish3(virConnectPtr dconn,
flags, cancelled, true);
cleanup:
- qemuDriverUnlock(driver);
return dom;
}
@@ -10009,7 +9834,6 @@ qemuDomainMigrateConfirm3(virDomainPtr domain,
virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
- qemuDriverLock(driver);
vm = virDomainObjListFindByUUID(driver->domains, domain->uuid);
if (!vm) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -10049,7 +9873,6 @@ qemuDomainMigrateConfirm3(virDomainPtr domain,
cleanup:
if (vm)
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
virObjectUnref(cfg);
return ret;
}
@@ -10117,7 +9940,6 @@ qemuNodeDeviceDettach(virNodeDevicePtr dev)
if (!pci)
return -1;
- qemuDriverLock(driver);
virObjectLock(driver->activePciHostdevs);
virObjectLock(driver->inactivePciHostdevs);
in_inactive_list = virPCIDeviceListFind(driver->inactivePciHostdevs, pci);
@@ -10130,7 +9952,6 @@ qemuNodeDeviceDettach(virNodeDevicePtr dev)
out:
virObjectUnlock(driver->inactivePciHostdevs);
virObjectUnlock(driver->activePciHostdevs);
- qemuDriverUnlock(driver);
if (in_inactive_list)
virPCIDeviceFree(pci);
return ret;
@@ -10152,7 +9973,6 @@ qemuNodeDeviceReAttach(virNodeDevicePtr dev)
if (!pci)
return -1;
- qemuDriverLock(driver);
virObjectLock(driver->activePciHostdevs);
virObjectLock(driver->inactivePciHostdevs);
other = virPCIDeviceListFind(driver->activePciHostdevs, pci);
@@ -10180,7 +10000,6 @@ qemuNodeDeviceReAttach(virNodeDevicePtr dev)
out:
virObjectUnlock(driver->inactivePciHostdevs);
virObjectUnlock(driver->activePciHostdevs);
- qemuDriverUnlock(driver);
virPCIDeviceFree(pci);
return ret;
}
@@ -10200,7 +10019,6 @@ qemuNodeDeviceReset(virNodeDevicePtr dev)
if (!pci)
return -1;
- qemuDriverLock(driver);
virObjectLock(driver->activePciHostdevs);
virObjectLock(driver->inactivePciHostdevs);
@@ -10212,7 +10030,6 @@ qemuNodeDeviceReset(virNodeDevicePtr dev)
out:
virObjectUnlock(driver->inactivePciHostdevs);
virObjectUnlock(driver->activePciHostdevs);
- qemuDriverUnlock(driver);
virPCIDeviceFree(pci);
return ret;
}
@@ -10228,8 +10045,6 @@ qemuCPUCompare(virConnectPtr conn,
virCheckFlags(0, VIR_CPU_COMPARE_ERROR);
- qemuDriverLock(driver);
-
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
@@ -10243,7 +10058,6 @@ qemuCPUCompare(virConnectPtr conn,
cleanup:
virObjectUnref(caps);
- qemuDriverUnlock(driver);
return ret;
}
@@ -10538,8 +10352,7 @@ cleanup:
/* this function expects the driver lock to be held by the caller */
static int
-qemuDomainSnapshotFSFreeze(virQEMUDriverPtr driver,
- virDomainObjPtr vm) {
+qemuDomainSnapshotFSFreeze(virDomainObjPtr vm) {
qemuDomainObjPrivatePtr priv = vm->privateData;
int freezed;
@@ -10555,16 +10368,15 @@ qemuDomainSnapshotFSFreeze(virQEMUDriverPtr driver,
return -1;
}
- qemuDomainObjEnterAgentWithDriver(driver, vm);
+ qemuDomainObjEnterAgent(vm);
freezed = qemuAgentFSFreeze(priv->agent);
- qemuDomainObjExitAgentWithDriver(driver, vm);
+ qemuDomainObjExitAgent(vm);
return freezed;
}
static int
-qemuDomainSnapshotFSThaw(virQEMUDriverPtr driver,
- virDomainObjPtr vm, bool report)
+qemuDomainSnapshotFSThaw(virDomainObjPtr vm, bool report)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
int thawed;
@@ -10584,13 +10396,13 @@ qemuDomainSnapshotFSThaw(virQEMUDriverPtr driver,
return -1;
}
- qemuDomainObjEnterAgent(driver, vm);
+ qemuDomainObjEnterAgent(vm);
if (!report)
err = virSaveLastError();
thawed = qemuAgentFSThaw(priv->agent);
if (!report)
virSetError(err);
- qemuDomainObjExitAgent(driver, vm);
+ qemuDomainObjExitAgent(vm);
virFreeError(err);
return thawed;
@@ -10734,7 +10546,7 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr conn,
bool resume = false;
int ret = -1;
- if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0)
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
return -1;
if (!virDomainObjIsActive(vm)) {
@@ -10760,9 +10572,9 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr conn,
}
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorCreateSnapshot(priv->mon, snap->def->name);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
if (ret < 0)
goto cleanup;
@@ -11199,7 +11011,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
}
}
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
cleanup:
virCgroupFree(&cgroup);
@@ -11235,7 +11047,7 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
int thaw = 0; /* 1 if freeze succeeded, -1 if freeze failed */
bool pmsuspended = false;
- if (qemuDomainObjBeginAsyncJobWithDriver(driver, vm,
+ if (qemuDomainObjBeginAsyncJob(driver, vm,
QEMU_ASYNC_JOB_SNAPSHOT) < 0)
goto cleanup;
@@ -11244,7 +11056,7 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
* fail if the guest is paused or the guest agent is not
* running. */
if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE) {
- if (qemuDomainSnapshotFSFreeze(driver, vm) < 0) {
+ if (qemuDomainSnapshotFSFreeze(vm) < 0) {
/* helper reported the error */
thaw = -1;
goto endjob;
@@ -11375,7 +11187,7 @@ endjob:
goto cleanup;
}
if (vm && thaw != 0 &&
- qemuDomainSnapshotFSThaw(driver, vm, thaw > 0) < 0) {
+ qemuDomainSnapshotFSThaw(vm, thaw > 0) < 0) {
/* helper reported the error, if it was needed */
if (thaw > 0)
ret = -1;
@@ -11441,7 +11253,6 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE)
parse_flags |= VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE;
- qemuDriverLock(driver);
virUUIDFormat(domain->uuid, uuidstr);
vm = virDomainObjListFindByUUID(driver->domains, domain->uuid);
if (!vm) {
@@ -11776,7 +11587,6 @@ cleanup:
}
virDomainSnapshotDefFree(def);
VIR_FREE(xml);
- qemuDriverUnlock(driver);
virObjectUnref(caps);
virObjectUnref(cfg);
return snapshot;
@@ -12149,7 +11959,6 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
* and use of FORCE can cause multiple transitions.
*/
- qemuDriverLock(driver);
virUUIDFormat(snapshot->domain->uuid, uuidstr);
vm = virDomainObjListFindByUUID(driver->domains, snapshot->domain->uuid);
if (!vm) {
@@ -12229,7 +12038,7 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
goto cleanup;
}
- if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0)
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
if (snap->def->state == VIR_DOMAIN_RUNNING
@@ -12290,9 +12099,9 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
goto endjob;
}
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
rc = qemuMonitorLoadSnapshot(priv->mon, snap->def->name);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
if (rc < 0) {
/* XXX resume domain if it was running before the
* failed loadvm attempt? */
@@ -12451,7 +12260,6 @@ cleanup:
}
if (vm)
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
virObjectUnref(caps);
virObjectUnref(cfg);
@@ -12520,7 +12328,6 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY |
VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY, -1);
- qemuDriverLock(driver);
virUUIDFormat(snapshot->domain->uuid, uuidstr);
vm = virDomainObjListFindByUUID(driver->domains, snapshot->domain->uuid);
if (!vm) {
@@ -12549,7 +12356,7 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
}
}
- if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0)
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
if (flags & (VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN |
@@ -12611,7 +12418,6 @@ endjob:
cleanup:
if (vm)
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
virObjectUnref(cfg);
return ret;
}
@@ -12684,8 +12490,6 @@ static virDomainPtr qemuDomainAttach(virConnectPtr conn,
virCheckFlags(0, NULL);
- qemuDriverLock(driver);
-
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
@@ -12732,7 +12536,7 @@ static virDomainPtr qemuDomainAttach(virConnectPtr conn,
def = NULL;
- if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0)
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
if (qemuProcessAttach(conn, driver, vm, pid,
@@ -12758,7 +12562,6 @@ cleanup:
virDomainChrSourceDefFree(monConfig);
if (vm)
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
VIR_FREE(pidfile);
virObjectUnref(caps);
return dom;
@@ -12971,10 +12774,10 @@ qemuDomainBlockPivot(virConnectPtr conn,
/* Probe the status, if needed. */
if (!disk->mirroring) {
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorBlockJob(priv->mon, device, NULL, 0, &info,
BLOCK_JOB_INFO, true);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
if (ret < 0)
goto cleanup;
if (!virDomainObjIsActive(vm)) {
@@ -13056,9 +12859,9 @@ qemuDomainBlockPivot(virConnectPtr conn,
}
/* Attempt the pivot. */
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorDrivePivot(priv->mon, device, disk->mirror, format);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
if (ret == 0) {
/* XXX We want to revoke security labels and disk lease, as
@@ -13127,7 +12930,6 @@ qemuDomainBlockJobImpl(virDomainPtr dom, const char *path, const char *base,
int idx;
virDomainDiskDefPtr disk;
- qemuDriverLock(driver);
virUUIDFormat(dom->uuid, uuidstr);
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
if (!vm) {
@@ -13180,7 +12982,7 @@ qemuDomainBlockJobImpl(virDomainPtr dom, const char *path, const char *base,
goto cleanup;
}
- if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0)
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
if (!virDomainObjIsActive(vm)) {
@@ -13195,13 +12997,13 @@ qemuDomainBlockJobImpl(virDomainPtr dom, const char *path, const char *base,
goto endjob;
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
/* XXX - libvirt should really be tracking the backing file chain
* itself, and validating that base is on the chain, rather than
* relying on qemu to do this. */
ret = qemuMonitorBlockJob(priv->mon, device, base, bandwidth, info, mode,
async);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
if (ret < 0)
goto endjob;
@@ -13239,20 +13041,18 @@ qemuDomainBlockJobImpl(virDomainPtr dom, const char *path, const char *base,
.tv_nsec = 50 * 1000 * 1000ull };
virDomainBlockJobInfo dummy;
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorBlockJob(priv->mon, device, NULL, 0, &dummy,
BLOCK_JOB_INFO, async);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
if (ret <= 0)
break;
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
nanosleep(&ts, NULL);
- qemuDriverLock(driver);
virObjectLock(vm);
if (!virDomainObjIsActive(vm)) {
@@ -13277,7 +13077,6 @@ cleanup:
virObjectUnlock(vm);
if (event)
qemuDomainEventQueue(driver, event);
- qemuDriverUnlock(driver);
return ret;
}
@@ -13685,7 +13484,6 @@ qemuDomainOpenGraphics(virDomainPtr dom,
virCheckFlags(VIR_DOMAIN_OPEN_GRAPHICS_SKIPAUTH, -1);
- qemuDriverLock(driver);
virUUIDFormat(dom->uuid, uuidstr);
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
if (!vm) {
@@ -13721,12 +13519,12 @@ qemuDomainOpenGraphics(virDomainPtr dom,
goto cleanup;
}
- if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0)
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorOpenGraphics(priv->mon, protocol, fd, "graphicsfd",
(flags & VIR_DOMAIN_OPEN_GRAPHICS_SKIPAUTH) != 0);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
if (qemuDomainObjEndJob(driver, vm) == 0) {
vm = NULL;
goto cleanup;
@@ -13735,7 +13533,6 @@ qemuDomainOpenGraphics(virDomainPtr dom,
cleanup:
if (vm)
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
return ret;
}
@@ -13782,7 +13579,6 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
memset(&info, 0, sizeof(info));
- qemuDriverLock(driver);
virUUIDFormat(dom->uuid, uuidstr);
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
if (!vm) {
@@ -13808,7 +13604,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
goto cleanup;
}
- if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0)
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
@@ -13873,9 +13669,9 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
info.read_iops_sec = oldinfo->read_iops_sec;
info.write_iops_sec = oldinfo->write_iops_sec;
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorSetBlockIoThrottle(priv->mon, device, &info);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
if (ret < 0)
goto endjob;
vm->def->disks[idx]->blkdeviotune = info;
@@ -13914,7 +13710,6 @@ cleanup:
VIR_FREE(device);
if (vm)
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
virObjectUnref(caps);
virObjectUnref(cfg);
return ret;
@@ -13945,7 +13740,6 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
/* We don't return strings, and thus trivially support this flag. */
flags &= ~VIR_TYPED_PARAM_STRING_OKAY;
- qemuDriverLock(driver);
virUUIDFormat(dom->uuid, uuidstr);
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
if (!vm) {
@@ -13970,7 +13764,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
goto cleanup;
}
- if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0)
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
@@ -13979,9 +13773,9 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
priv = vm->privateData;
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorGetBlockIoThrottle(priv->mon, device, &reply);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
if (ret < 0)
goto endjob;
}
@@ -14057,7 +13851,6 @@ cleanup:
if (vm)
virObjectUnlock(vm);
virObjectUnref(caps);
- qemuDriverUnlock(driver);
return ret;
}
@@ -14536,8 +14329,6 @@ qemuDomainGetCPUStats(virDomainPtr domain,
virCheckFlags(VIR_TYPED_PARAM_STRING_OKAY, -1);
- qemuDriverLock(driver);
-
vm = virDomainObjListFindByUUID(driver->domains, domain->uuid);
if (vm == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -14573,7 +14364,6 @@ cleanup:
virCgroupFree(&group);
if (vm)
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
return ret;
}
@@ -14664,9 +14454,9 @@ qemuDomainPMSuspendForDuration(virDomainPtr dom,
goto endjob;
}
- qemuDomainObjEnterAgent(driver, vm);
+ qemuDomainObjEnterAgent(vm);
ret = qemuAgentSuspend(priv->agent, target);
- qemuDomainObjExitAgent(driver, vm);
+ qemuDomainObjExitAgent(vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
@@ -14734,9 +14524,7 @@ qemuListAllDomains(virConnectPtr conn,
virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1);
- qemuDriverLock(driver);
ret = virDomainObjListExport(driver->domains, conn, domains, flags);
- qemuDriverUnlock(driver);
return ret;
}
@@ -14788,9 +14576,9 @@ qemuDomainAgentCommand(virDomainPtr domain,
goto endjob;
}
- qemuDomainObjEnterAgent(driver, vm);
+ qemuDomainObjEnterAgent(vm);
ret = qemuAgentArbitraryCommand(priv->agent, cmd, &result, timeout);
- qemuDomainObjExitAgent(driver, vm);
+ qemuDomainObjExitAgent(vm);
if (ret < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to execute agent command"));
@@ -14861,9 +14649,9 @@ qemuDomainFSTrim(virDomainPtr dom,
goto endjob;
}
- qemuDomainObjEnterAgent(driver, vm);
+ qemuDomainObjEnterAgent(vm);
ret = qemuAgentFSTrim(priv->agent, minimum);
- qemuDomainObjExitAgent(driver, vm);
+ qemuDomainObjExitAgent(vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 0c28a6a..488a440 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -107,7 +107,7 @@ int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
if (!(driveAlias = qemuDeviceDriveHostAlias(origdisk, priv->qemuCaps)))
goto error;
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorEjectMedia(priv->mon, driveAlias, force);
/* we don't want to report errors from media tray_open polling */
@@ -144,7 +144,7 @@ int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
disk->src, format);
}
exit_monitor:
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditDisk(vm, origdisk->src, disk->src, "update", ret >= 0);
@@ -194,7 +194,7 @@ qemuDomainCheckEjectableMedia(virQEMUDriverPtr driver,
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
table = qemuMonitorGetBlockInfo(priv->mon);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
}
if (!table)
@@ -276,7 +276,7 @@ int qemuDomainAttachPciDiskDevice(virConnectPtr conn,
goto error;
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
ret = qemuMonitorAddDrive(priv->mon, drivestr);
if (ret == 0) {
@@ -305,7 +305,7 @@ int qemuDomainAttachPciDiskDevice(virConnectPtr conn,
memcpy(&disk->info.addr.pci, &guestAddr, sizeof(guestAddr));
}
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditDisk(vm, NULL, disk->src, "attach", ret >= 0);
@@ -381,7 +381,7 @@ int qemuDomainAttachPciControllerDevice(virQEMUDriverPtr driver,
goto cleanup;
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
ret = qemuMonitorAddDevice(priv->mon, devstr);
} else {
@@ -389,7 +389,7 @@ int qemuDomainAttachPciControllerDevice(virQEMUDriverPtr driver,
type,
&controller->info.addr.pci);
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
if (ret == 0) {
controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
@@ -529,7 +529,7 @@ int qemuDomainAttachSCSIDisk(virConnectPtr conn,
goto error;
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
ret = qemuMonitorAddDrive(priv->mon, drivestr);
if (ret == 0) {
@@ -555,7 +555,7 @@ int qemuDomainAttachSCSIDisk(virConnectPtr conn,
disk->info.addr.drive.unit = driveAddr.unit;
}
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditDisk(vm, NULL, disk->src, "attach", ret >= 0);
@@ -633,7 +633,7 @@ int qemuDomainAttachUsbMassstorageDevice(virConnectPtr conn,
goto error;
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
ret = qemuMonitorAddDrive(priv->mon, drivestr);
if (ret == 0) {
@@ -648,7 +648,7 @@ int qemuDomainAttachUsbMassstorageDevice(virConnectPtr conn,
} else {
ret = qemuMonitorAddUSBDisk(priv->mon, disk->src);
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditDisk(vm, NULL, disk->src, "attach", ret >= 0);
@@ -807,24 +807,24 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
goto cleanup;
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV) &&
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
if (qemuMonitorAddNetdev(priv->mon, netstr, tapfd, tapfd_name,
vhostfd, vhostfd_name) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditNet(vm, NULL, net, "attach", false);
goto cleanup;
}
} else {
if (qemuMonitorAddHostNetwork(priv->mon, netstr, tapfd, tapfd_name,
vhostfd, vhostfd_name) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditNet(vm, NULL, net, "attach", false);
goto cleanup;
}
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
VIR_FORCE_CLOSE(tapfd);
VIR_FORCE_CLOSE(vhostfd);
@@ -843,10 +843,10 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
goto try_remove;
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
if (qemuMonitorAddDevice(priv->mon, nicstr) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditNet(vm, NULL, net, "attach", false);
goto try_remove;
}
@@ -854,14 +854,14 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
guestAddr = net->info.addr.pci;
if (qemuMonitorAddPCINetwork(priv->mon, nicstr,
&guestAddr) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditNet(vm, NULL, net, "attach", false);
goto try_remove;
}
net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
memcpy(&net->info.addr.pci, &guestAddr, sizeof(guestAddr));
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
/* set link state */
if (net->linkstate == VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN) {
@@ -869,11 +869,11 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("device alias not found: cannot set link state to down"));
} else {
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) {
if (qemuMonitorSetLink(priv->mon, net->info.alias, VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditNet(vm, NULL, net, "attach", false);
goto try_remove;
}
@@ -882,7 +882,7 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
_("setting of link state not supported: Link is up"));
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
}
/* link set to down */
}
@@ -934,11 +934,11 @@ try_remove:
char *netdev_name;
if (virAsprintf(&netdev_name, "host%s", net->info.alias) < 0)
goto no_memory;
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
if (qemuMonitorRemoveNetdev(priv->mon, netdev_name) < 0)
VIR_WARN("Failed to remove network backend for netdev %s",
netdev_name);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
VIR_FREE(netdev_name);
} else {
VIR_WARN("Unable to remove network backend");
@@ -947,11 +947,11 @@ try_remove:
char *hostnet_name;
if (virAsprintf(&hostnet_name, "host%s", net->info.alias) < 0)
goto no_memory;
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
if (qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0)
VIR_WARN("Failed to remove network backend for vlan %d, net %s",
vlan, hostnet_name);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
VIR_FREE(hostnet_name);
}
goto cleanup;
@@ -1009,18 +1009,18 @@ int qemuDomainAttachHostPciDevice(virQEMUDriverPtr driver,
priv->qemuCaps)))
goto error;
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorAddDeviceWithFd(priv->mon, devstr,
configfd, configfd_name);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
} else {
virDevicePCIAddress guestAddr = hostdev->info->addr.pci;
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorAddPCIHostDevice(priv->mon,
&hostdev->source.subsys.u.pci,
&guestAddr);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
hostdev->info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
memcpy(&hostdev->info->addr.pci, &guestAddr, sizeof(guestAddr));
@@ -1076,13 +1076,13 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriverPtr driver,
goto error;
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE))
ret = qemuMonitorAddDevice(priv->mon, devstr);
else
goto error;
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditRedirdev(vm, redirdev, "attach", ret == 0);
if (ret < 0)
goto error;
@@ -1146,14 +1146,14 @@ int qemuDomainAttachHostUsbDevice(virQEMUDriverPtr driver,
virUSBDeviceFree(usb);
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE))
ret = qemuMonitorAddDevice(priv->mon, devstr);
else
ret = qemuMonitorAddUSBDeviceExact(priv->mon,
hostdev->source.subsys.u.usb.bus,
hostdev->source.subsys.u.usb.device);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditHostdev(vm, hostdev, "attach", ret == 0);
if (ret < 0)
goto error;
@@ -1421,7 +1421,7 @@ int qemuDomainChangeNetLinkState(virQEMUDriverPtr driver,
return -1;
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorSetLink(priv->mon, dev->info.alias, linkstate);
if (ret < 0)
@@ -1431,7 +1431,7 @@ int qemuDomainChangeNetLinkState(virQEMUDriverPtr driver,
dev->linkstate = linkstate;
cleanup:
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
return ret;
}
@@ -2059,17 +2059,17 @@ int qemuDomainDetachPciDiskDevice(virQEMUDriverPtr driver,
goto cleanup;
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
if (qemuMonitorDelDevice(priv->mon, detach->info.alias) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditDisk(vm, detach->src, NULL, "detach", false);
goto cleanup;
}
} else {
if (qemuMonitorRemovePCIDevice(priv->mon,
&detach->info.addr.pci) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditDisk(vm, detach->src, NULL, "detach", false);
goto cleanup;
}
@@ -2078,7 +2078,7 @@ int qemuDomainDetachPciDiskDevice(virQEMUDriverPtr driver,
/* disconnect guest from host device */
qemuMonitorDriveDel(priv->mon, drivestr);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditDisk(vm, detach->src, NULL, "detach", true);
@@ -2165,9 +2165,9 @@ int qemuDomainDetachDiskDevice(virQEMUDriverPtr driver,
goto cleanup;
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
if (qemuMonitorDelDevice(priv->mon, detach->info.alias) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditDisk(vm, detach->src, NULL, "detach", false);
goto cleanup;
}
@@ -2175,7 +2175,7 @@ int qemuDomainDetachDiskDevice(virQEMUDriverPtr driver,
/* disconnect guest from host device */
qemuMonitorDriveDel(priv->mon, drivestr);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditDisk(vm, detach->src, NULL, "detach", true);
@@ -2301,20 +2301,20 @@ int qemuDomainDetachPciControllerDevice(virQEMUDriverPtr driver,
goto cleanup;
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
if (qemuMonitorDelDevice(priv->mon, detach->info.alias)) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
goto cleanup;
}
} else {
if (qemuMonitorRemovePCIDevice(priv->mon,
&detach->info.addr.pci) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
goto cleanup;
}
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainControllerRemove(vm->def, idx);
virDomainControllerDefFree(detach);
@@ -2357,13 +2357,13 @@ qemuDomainDetachHostPciDevice(virQEMUDriverPtr driver,
goto cleanup;
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
rv = qemuMonitorDelDevice(priv->mon, detach->info->alias);
} else {
rv = qemuMonitorRemovePCIDevice(priv->mon, &detach->info->addr.pci);
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditHostdev(vm, detach, "detach", rv == 0);
if (rv < 0)
goto cleanup;
@@ -2427,9 +2427,9 @@ qemuDomainDetachHostUsbDevice(virQEMUDriverPtr driver,
return -1;
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorDelDevice(priv->mon, detach->info->alias);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditHostdev(vm, detach, "detach", ret == 0);
if (ret < 0)
return -1;
@@ -2613,17 +2613,17 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver,
goto cleanup;
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
if (qemuMonitorDelDevice(priv->mon, detach->info.alias) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditNet(vm, detach, NULL, "detach", false);
goto cleanup;
}
} else {
if (qemuMonitorRemovePCIDevice(priv->mon,
&detach->info.addr.pci) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditNet(vm, detach, NULL, "detach", false);
goto cleanup;
}
@@ -2632,18 +2632,18 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver,
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV) &&
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
if (qemuMonitorRemoveNetdev(priv->mon, hostnet_name) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditNet(vm, detach, NULL, "detach", false);
goto cleanup;
}
} else {
if (qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditNet(vm, detach, NULL, "detach", false);
goto cleanup;
}
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virDomainAuditNet(vm, detach, NULL, "detach", true);
@@ -2713,7 +2713,7 @@ qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver,
if (auth->connected)
connected = virDomainGraphicsAuthConnectedTypeToString(auth->connected);
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorSetPassword(priv->mon,
type,
auth->passwd ? auth->passwd : defaultPasswd,
@@ -2756,7 +2756,7 @@ qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver,
}
end_job:
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
cleanup:
virObjectUnref(cfg);
return ret;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 815f7a5..60cd47a 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1188,7 +1188,7 @@ qemuMigrationUpdateJobStatus(virQEMUDriverPtr driver,
ret = qemuMonitorGetSpiceMigrationStatus(priv->mon,
&spice_migrated);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
if (ret < 0 || virTimeMillisNow(&priv->job.info.timeElapsed) < 0) {
priv->job.info.type = VIR_DOMAIN_JOB_FAILED;
@@ -1277,11 +1277,9 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver, virDomainObjPtr vm,
}
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
nanosleep(&ts, NULL);
- qemuDriverLock(driver);
virObjectLock(vm);
}
@@ -1322,7 +1320,7 @@ qemuDomainMigrateGraphicsRelocate(virQEMUDriverPtr driver,
cookie->graphics->port,
cookie->graphics->tlsPort,
cookie->graphics->tlsSubject);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
}
return ret;
@@ -2265,7 +2263,7 @@ qemuMigrationRun(virQEMUDriverPtr driver,
/* explicitly do this *after* we entered the monitor,
* as this is a critical section so we are guaranteed
* priv->job.asyncAbort will not change */
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virReportError(VIR_ERR_OPERATION_ABORTED, _("%s: %s"),
qemuDomainAsyncJobTypeToString(priv->job.asyncJob),
_("canceled by client"));
@@ -2273,7 +2271,7 @@ qemuMigrationRun(virQEMUDriverPtr driver,
}
if (qemuMonitorSetMigrationSpeed(priv->mon, migrate_speed) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
goto cleanup;
}
@@ -2286,7 +2284,7 @@ qemuMigrationRun(virQEMUDriverPtr driver,
/* connect to the destination qemu if needed */
if (spec->destType == MIGRATION_DEST_CONNECT_HOST &&
qemuMigrationConnect(driver, vm, spec) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
goto cleanup;
}
@@ -2323,7 +2321,7 @@ qemuMigrationRun(virQEMUDriverPtr driver,
VIR_FORCE_CLOSE(spec->dest.fd.qemu);
break;
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
if (ret < 0)
goto cleanup;
ret = -1;
@@ -2412,7 +2410,7 @@ cancel:
if (qemuDomainObjEnterMonitorAsync(driver, vm,
QEMU_ASYNC_JOB_MIGRATION_OUT) == 0) {
qemuMonitorMigrateCancel(priv->mon);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
}
}
goto cleanup;
@@ -2615,23 +2613,23 @@ static int doPeer2PeerMigrate2(virQEMUDriverPtr driver,
if (!(st = virStreamNew(dconn, 0)))
goto cleanup;
- qemuDomainObjEnterRemoteWithDriver(driver, vm);
+ qemuDomainObjEnterRemote(vm);
ret = dconn->driver->domainMigratePrepareTunnel
(dconn, st, flags, dname, resource, dom_xml);
- qemuDomainObjExitRemoteWithDriver(driver, vm);
+ qemuDomainObjExitRemote(vm);
} else {
- qemuDomainObjEnterRemoteWithDriver(driver, vm);
+ qemuDomainObjEnterRemote(vm);
ret = dconn->driver->domainMigratePrepare2
(dconn, &cookie, &cookielen, NULL, &uri_out,
flags, dname, resource, dom_xml);
- qemuDomainObjExitRemoteWithDriver(driver, vm);
+ qemuDomainObjExitRemote(vm);
}
VIR_FREE(dom_xml);
if (ret == -1)
goto cleanup;
/* the domain may have shutdown or crashed while we had the locks dropped
- * in qemuDomainObjEnterRemoteWithDriver, so check again
+ * in qemuDomainObjEnterRemote, so check again
*/
if (!virDomainObjIsActive(vm)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -2678,11 +2676,11 @@ finish:
*/
dname = dname ? dname : vm->def->name;
VIR_DEBUG("Finish2 %p ret=%d", dconn, ret);
- qemuDomainObjEnterRemoteWithDriver(driver, vm);
+ qemuDomainObjEnterRemote(vm);
ddomain = dconn->driver->domainMigrateFinish2
(dconn, dname, cookie, cookielen,
uri_out ? uri_out : dconnuri, flags, cancelled);
- qemuDomainObjExitRemoteWithDriver(driver, vm);
+ qemuDomainObjExitRemote(vm);
cleanup:
if (ddomain) {
@@ -2759,18 +2757,18 @@ static int doPeer2PeerMigrate3(virQEMUDriverPtr driver,
if (!(st = virStreamNew(dconn, 0)))
goto cleanup;
- qemuDomainObjEnterRemoteWithDriver(driver, vm);
+ qemuDomainObjEnterRemote(vm);
ret = dconn->driver->domainMigratePrepareTunnel3
(dconn, st, cookiein, cookieinlen,
&cookieout, &cookieoutlen,
flags, dname, resource, dom_xml);
- qemuDomainObjExitRemoteWithDriver(driver, vm);
+ qemuDomainObjExitRemote(vm);
} else {
- qemuDomainObjEnterRemoteWithDriver(driver, vm);
+ qemuDomainObjEnterRemote(vm);
ret = dconn->driver->domainMigratePrepare3
(dconn, cookiein, cookieinlen, &cookieout, &cookieoutlen,
uri, &uri_out, flags, dname, resource, dom_xml);
- qemuDomainObjExitRemoteWithDriver(driver, vm);
+ qemuDomainObjExitRemote(vm);
}
VIR_FREE(dom_xml);
if (ret == -1)
@@ -2842,11 +2840,11 @@ finish:
cookieout = NULL;
cookieoutlen = 0;
dname = dname ? dname : vm->def->name;
- qemuDomainObjEnterRemoteWithDriver(driver, vm);
+ qemuDomainObjEnterRemote(vm);
ddomain = dconn->driver->domainMigrateFinish3
(dconn, dname, cookiein, cookieinlen, &cookieout, &cookieoutlen,
dconnuri, uri_out ? uri_out : uri, flags, cancelled);
- qemuDomainObjExitRemoteWithDriver(driver, vm);
+ qemuDomainObjExitRemote(vm);
/* If ddomain is NULL, then we were unable to start
* the guest on the target, and must restart on the
@@ -2934,9 +2932,9 @@ static int doPeer2PeerMigrate(virQEMUDriverPtr driver,
* destination side is completely setup before we touch the source
*/
- qemuDomainObjEnterRemoteWithDriver(driver, vm);
+ qemuDomainObjEnterRemote(vm);
dconn = virConnectOpen(dconnuri);
- qemuDomainObjExitRemoteWithDriver(driver, vm);
+ qemuDomainObjExitRemote(vm);
if (dconn == NULL) {
virReportError(VIR_ERR_OPERATION_FAILED,
_("Failed to connect to remote libvirt URI %s"), dconnuri);
@@ -2948,7 +2946,7 @@ static int doPeer2PeerMigrate(virQEMUDriverPtr driver,
cfg->keepAliveCount) < 0)
goto cleanup;
- qemuDomainObjEnterRemoteWithDriver(driver, vm);
+ qemuDomainObjEnterRemote(vm);
p2p = VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn,
VIR_DRV_FEATURE_MIGRATION_P2P);
/* v3proto reflects whether the caller used Perform3, but with
@@ -2960,7 +2958,7 @@ static int doPeer2PeerMigrate(virQEMUDriverPtr driver,
if (flags & VIR_MIGRATE_OFFLINE)
offline = VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn,
VIR_DRV_FEATURE_MIGRATION_OFFLINE);
- qemuDomainObjExitRemoteWithDriver(driver, vm);
+ qemuDomainObjExitRemote(vm);
if (!p2p) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
@@ -2998,9 +2996,9 @@ static int doPeer2PeerMigrate(virQEMUDriverPtr driver,
cleanup:
orig_err = virSaveLastError();
- qemuDomainObjEnterRemoteWithDriver(driver, vm);
+ qemuDomainObjEnterRemote(vm);
virConnectClose(dconn);
- qemuDomainObjExitRemoteWithDriver(driver, vm);
+ qemuDomainObjExitRemote(vm);
if (orig_err) {
virSetError(orig_err);
virFreeError(orig_err);
@@ -3646,7 +3644,7 @@ qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm,
qemuMonitorSetMigrationSpeed(priv->mon,
QEMU_DOMAIN_MIG_BANDWIDTH_MAX);
priv->migMaxBandwidth = QEMU_DOMAIN_MIG_BANDWIDTH_MAX;
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
}
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD) &&
@@ -3726,11 +3724,11 @@ qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm,
if (virSetCloseExec(pipeFD[1]) < 0) {
virReportSystemError(errno, "%s",
_("Unable to set cloexec flag"));
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
goto cleanup;
}
if (virCommandRunAsync(cmd, NULL) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
goto cleanup;
}
rc = qemuMonitorMigrateToFd(priv->mon,
@@ -3745,7 +3743,7 @@ qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm,
args, path, offset);
}
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
if (rc < 0)
goto cleanup;
@@ -3765,7 +3763,7 @@ cleanup:
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
qemuMonitorSetMigrationSpeed(priv->mon, saveMigBandwidth);
priv->migMaxBandwidth = saveMigBandwidth;
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
}
VIR_FORCE_CLOSE(pipeFD[0]);
@@ -3799,7 +3797,7 @@ qemuMigrationJobStart(virQEMUDriverPtr driver,
{
qemuDomainObjPrivatePtr priv = vm->privateData;
- if (qemuDomainObjBeginAsyncJobWithDriver(driver, vm, job) < 0)
+ if (qemuDomainObjBeginAsyncJob(driver, vm, job) < 0)
return -1;
if (job == QEMU_ASYNC_JOB_MIGRATION_IN) {
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 12e3544..9c93e47 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -129,12 +129,10 @@ static void
qemuProcessHandleAgentEOF(qemuAgentPtr agent,
virDomainObjPtr vm)
{
- virQEMUDriverPtr driver = qemu_driver;
qemuDomainObjPrivatePtr priv;
VIR_DEBUG("Received EOF from agent on %p '%s'", vm, vm->def->name);
- qemuDriverLock(driver);
virObjectLock(vm);
priv = vm->privateData;
@@ -152,14 +150,12 @@ qemuProcessHandleAgentEOF(qemuAgentPtr agent,
priv->agent = NULL;
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
qemuAgentClose(agent);
return;
unlock:
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
return;
}
@@ -174,12 +170,10 @@ static void
qemuProcessHandleAgentError(qemuAgentPtr agent ATTRIBUTE_UNUSED,
virDomainObjPtr vm)
{
- virQEMUDriverPtr driver = qemu_driver;
qemuDomainObjPrivatePtr priv;
VIR_DEBUG("Received error from agent on %p '%s'", vm, vm->def->name);
- qemuDriverLock(driver);
virObjectLock(vm);
priv = vm->privateData;
@@ -187,7 +181,6 @@ qemuProcessHandleAgentError(qemuAgentPtr agent ATTRIBUTE_UNUSED,
priv->agentError = true;
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
}
static void qemuProcessHandleAgentDestroy(qemuAgentPtr agent,
@@ -250,13 +243,11 @@ qemuConnectAgent(virQEMUDriverPtr driver, virDomainObjPtr vm)
ignore_value(virTimeMillisNow(&priv->agentStart));
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
agent = qemuAgentOpen(vm,
config,
&agentCallbacks);
- qemuDriverLock(driver);
virObjectLock(vm);
priv->agentStart = 0;
@@ -307,7 +298,6 @@ qemuProcessHandleMonitorEOF(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
VIR_DEBUG("Received EOF on %p '%s'", vm, vm->def->name);
- qemuDriverLock(driver);
virObjectLock(vm);
priv = vm->privateData;
@@ -347,7 +337,6 @@ unlock:
cleanup:
if (event)
qemuDomainEventQueue(driver, event);
- qemuDriverUnlock(driver);
}
@@ -366,7 +355,6 @@ qemuProcessHandleMonitorError(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
VIR_DEBUG("Received error on %p '%s'", vm, vm->def->name);
- qemuDriverLock(driver);
virObjectLock(vm);
((qemuDomainObjPrivatePtr) vm->privateData)->monError = true;
@@ -375,7 +363,6 @@ qemuProcessHandleMonitorError(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
qemuDomainEventQueue(driver, event);
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
}
@@ -543,11 +530,8 @@ qemuProcessHandleReset(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virObjectUnlock(vm);
- if (event) {
- qemuDriverLock(driver);
+ if (event)
qemuDomainEventQueue(driver, event);
- qemuDriverUnlock(driver);
- }
return 0;
}
@@ -570,7 +554,6 @@ qemuProcessFakeReboot(void *opaque)
virDomainEventPtr event = NULL;
int ret = -1;
VIR_DEBUG("vm=%p", vm);
- qemuDriverLock(driver);
virObjectLock(vm);
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
@@ -581,12 +564,12 @@ qemuProcessFakeReboot(void *opaque)
goto endjob;
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
if (qemuMonitorSystemReset(priv->mon) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
goto endjob;
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
if (!virDomainObjIsActive(vm)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -616,7 +599,7 @@ endjob:
cleanup:
if (vm) {
if (ret == -1) {
- ignore_value(qemuProcessKill(driver, vm,
+ ignore_value(qemuProcessKill(vm,
VIR_QEMU_PROCESS_KILL_FORCE));
}
if (virObjectUnref(vm))
@@ -624,7 +607,6 @@ cleanup:
}
if (event)
qemuDomainEventQueue(driver, event);
- qemuDriverUnlock(driver);
}
@@ -643,12 +625,13 @@ qemuProcessShutdownOrReboot(virQEMUDriverPtr driver,
qemuProcessFakeReboot,
vm) < 0) {
VIR_ERROR(_("Failed to create reboot thread, killing domain"));
- ignore_value(qemuProcessKill(driver, vm,
+ ignore_value(qemuProcessKill(vm,
VIR_QEMU_PROCESS_KILL_NOWAIT));
virObjectUnref(vm);
}
} else {
- ignore_value(qemuProcessKill(driver, vm, VIR_QEMU_PROCESS_KILL_NOWAIT));
+ ignore_value(qemuProcessKill(vm,
+ VIR_QEMU_PROCESS_KILL_NOWAIT));
}
}
@@ -703,11 +686,8 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
unlock:
virObjectUnlock(vm);
cleanup:
- if (event) {
- qemuDriverLock(driver);
+ if (event)
qemuDomainEventQueue(driver, event);
- qemuDriverUnlock(driver);
- }
virObjectUnref(caps);
virObjectUnref(cfg);
@@ -759,11 +739,8 @@ unlock:
virObjectUnlock(vm);
cleanup:
- if (event) {
- qemuDriverLock(driver);
+ if (event)
qemuDomainEventQueue(driver, event);
- qemuDriverUnlock(driver);
- }
virObjectUnref(caps);
virObjectUnref(cfg);
@@ -821,11 +798,8 @@ qemuProcessHandleResume(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
unlock:
virObjectUnlock(vm);
cleanup:
- if (event) {
- qemuDriverLock(driver);
+ if (event)
qemuDomainEventQueue(driver, event);
- qemuDriverUnlock(driver);
- }
virObjectUnref(caps);
virObjectUnref(cfg);
return 0;
@@ -857,11 +831,8 @@ qemuProcessHandleRTCChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virObjectUnlock(vm);
cleanup:
- if (event) {
- qemuDriverLock(driver);
+ if (event)
qemuDomainEventQueue(driver, event);
- qemuDriverUnlock(driver);
- }
virObjectUnref(caps);
virObjectUnref(cfg);
return 0;
@@ -929,14 +900,10 @@ qemuProcessHandleWatchdog(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virObjectUnlock(vm);
cleanup:
- if (watchdogEvent || lifecycleEvent) {
- qemuDriverLock(driver);
- if (watchdogEvent)
- qemuDomainEventQueue(driver, watchdogEvent);
- if (lifecycleEvent)
- qemuDomainEventQueue(driver, lifecycleEvent);
- qemuDriverUnlock(driver);
- }
+ if (watchdogEvent)
+ qemuDomainEventQueue(driver, watchdogEvent);
+ if (lifecycleEvent)
+ qemuDomainEventQueue(driver, lifecycleEvent);
virObjectUnref(caps);
virObjectUnref(cfg);
@@ -999,16 +966,12 @@ qemuProcessHandleIOError(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virObjectUnlock(vm);
cleanup:
- if (ioErrorEvent || ioErrorEvent2 || lifecycleEvent) {
- qemuDriverLock(driver);
- if (ioErrorEvent)
- qemuDomainEventQueue(driver, ioErrorEvent);
- if (ioErrorEvent2)
- qemuDomainEventQueue(driver, ioErrorEvent2);
- if (lifecycleEvent)
- qemuDomainEventQueue(driver, lifecycleEvent);
- qemuDriverUnlock(driver);
- }
+ if (ioErrorEvent)
+ qemuDomainEventQueue(driver, ioErrorEvent);
+ if (ioErrorEvent2)
+ qemuDomainEventQueue(driver, ioErrorEvent2);
+ if (lifecycleEvent)
+ qemuDomainEventQueue(driver, lifecycleEvent);
virObjectUnref(caps);
virObjectUnref(cfg);
return 0;
@@ -1050,11 +1013,8 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virObjectUnlock(vm);
- if (event) {
- qemuDriverLock(driver);
+ if (event)
qemuDomainEventQueue(driver, event);
- qemuDriverUnlock(driver);
- }
return 0;
}
@@ -1117,11 +1077,8 @@ qemuProcessHandleGraphics(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
event = virDomainEventGraphicsNewFromObj(vm, phase, localAddr, remoteAddr, authScheme, subject);
virObjectUnlock(vm);
- if (event) {
- qemuDriverLock(driver);
+ if (event)
qemuDomainEventQueue(driver, event);
- qemuDriverUnlock(driver);
- }
return 0;
@@ -1192,11 +1149,8 @@ qemuProcessHandleTrayChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virObjectUnlock(vm);
cleanup:
- if (event) {
- qemuDriverLock(driver);
+ if (event)
qemuDomainEventQueue(driver, event);
- qemuDriverUnlock(driver);
- }
virObjectUnref(caps);
virObjectUnref(cfg);
return 0;
@@ -1240,14 +1194,10 @@ qemuProcessHandlePMWakeup(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virObjectUnlock(vm);
cleanup:
- if (event || lifecycleEvent) {
- qemuDriverLock(driver);
- if (event)
- qemuDomainEventQueue(driver, event);
- if (lifecycleEvent)
- qemuDomainEventQueue(driver, lifecycleEvent);
- qemuDriverUnlock(driver);
- }
+ if (event)
+ qemuDomainEventQueue(driver, event);
+ if (lifecycleEvent)
+ qemuDomainEventQueue(driver, lifecycleEvent);
virObjectUnref(caps);
virObjectUnref(cfg);
return 0;
@@ -1293,14 +1243,10 @@ qemuProcessHandlePMSuspend(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virObjectUnlock(vm);
cleanup:
- if (event || lifecycleEvent) {
- qemuDriverLock(driver);
- if (event)
- qemuDomainEventQueue(driver, event);
- if (lifecycleEvent)
- qemuDomainEventQueue(driver, lifecycleEvent);
- qemuDriverUnlock(driver);
- }
+ if (event)
+ qemuDomainEventQueue(driver, event);
+ if (lifecycleEvent)
+ qemuDomainEventQueue(driver, lifecycleEvent);
virObjectUnref(caps);
virObjectUnref(cfg);
return 0;
@@ -1332,11 +1278,8 @@ qemuProcessHandleBalloonChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virObjectUnlock(vm);
cleanup:
- if (event) {
- qemuDriverLock(driver);
+ if (event)
qemuDomainEventQueue(driver, event);
- qemuDriverUnlock(driver);
- }
virObjectUnref(caps);
virObjectUnref(cfg);
return 0;
@@ -1382,14 +1325,10 @@ qemuProcessHandlePMSuspendDisk(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virObjectUnlock(vm);
cleanup:
- if (event || lifecycleEvent) {
- qemuDriverLock(driver);
- if (event)
- qemuDomainEventQueue(driver, event);
- if (lifecycleEvent)
- qemuDomainEventQueue(driver, lifecycleEvent);
- qemuDriverUnlock(driver);
- }
+ if (event)
+ qemuDomainEventQueue(driver, event);
+ if (lifecycleEvent)
+ qemuDomainEventQueue(driver, lifecycleEvent);
virObjectUnref(caps);
virObjectUnref(cfg);
@@ -1438,14 +1377,12 @@ qemuConnectMonitor(virQEMUDriverPtr driver, virDomainObjPtr vm)
ignore_value(virTimeMillisNow(&priv->monStart));
virObjectUnlock(vm);
- qemuDriverUnlock(driver);
mon = qemuMonitorOpen(vm,
priv->monConfig,
priv->monJSON,
&monitorCallbacks);
- qemuDriverLock(driver);
virObjectLock(vm);
priv->monStart = 0;
@@ -1469,12 +1406,12 @@ qemuConnectMonitor(virQEMUDriverPtr driver, virDomainObjPtr vm)
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorSetCapabilities(priv->mon);
if (ret == 0 &&
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MONITOR_JSON))
ret = virQEMUCapsProbeQMP(priv->qemuCaps, priv->mon);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
error:
@@ -1850,9 +1787,9 @@ qemuProcessWaitForMonitor(virQEMUDriverPtr driver,
goto cleanup;
priv = vm->privateData;
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorGetPtyPaths(priv->mon, paths);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
VIR_DEBUG("qemuMonitorGetPtyPaths returned %i", ret);
if (ret == 0)
@@ -1900,12 +1837,12 @@ qemuProcessDetectVcpuPIDs(virQEMUDriverPtr driver,
int ncpupids;
qemuDomainObjPrivatePtr priv = vm->privateData;
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
/* failure to get the VCPU<-> PID mapping or to execute the query
* command will not be treated fatal as some versions of qemu don't
* support this command */
if ((ncpupids = qemuMonitorGetCPUInfo(priv->mon, &cpupids)) <= 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
virResetLastError();
priv->nvcpupids = 1;
@@ -1916,7 +1853,7 @@ qemuProcessDetectVcpuPIDs(virQEMUDriverPtr driver,
priv->vcpupids[0] = vm->pid;
return 0;
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
if (ncpupids != vm->def->vcpus) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -2309,10 +2246,10 @@ qemuProcessInitPasswords(virConnectPtr conn,
goto cleanup;
alias = vm->def->disks[i]->info.alias;
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorSetDrivePassphrase(priv->mon, alias, secret);
VIR_FREE(secret);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
if (ret < 0)
goto cleanup;
}
@@ -2701,10 +2638,10 @@ qemuProcessInitPCIAddresses(virQEMUDriverPtr driver,
int ret;
qemuMonitorPCIAddress *addrs = NULL;
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
naddrs = qemuMonitorGetAllPCIAddresses(priv->mon,
&addrs);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
ret = qemuProcessDetectPCIAddresses(vm, addrs, naddrs);
@@ -2862,7 +2799,7 @@ qemuProcessPrepareMonitorChr(virQEMUDriverConfigPtr cfg,
/*
* Precondition: Both driver and vm must be locked,
* and a job must be active. This method will call
- * {Enter,Exit}MonitorWithDriver
+ * {Enter,Exit}Monitor
*/
int
qemuProcessStartCPUs(virQEMUDriverPtr driver, virDomainObjPtr vm,
@@ -2887,7 +2824,7 @@ qemuProcessStartCPUs(virQEMUDriverPtr driver, virDomainObjPtr vm,
ret = qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob);
if (ret == 0) {
ret = qemuMonitorStartCPUs(priv->mon, conn);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
}
if (ret == 0) {
@@ -2916,7 +2853,7 @@ int qemuProcessStopCPUs(virQEMUDriverPtr driver, virDomainObjPtr vm,
ret = qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob);
if (ret == 0) {
ret = qemuMonitorStopCPUs(priv->mon);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
}
if (ret == 0) {
@@ -2979,9 +2916,9 @@ qemuProcessUpdateState(virQEMUDriverPtr driver, virDomainObjPtr vm)
char *msg = NULL;
int ret;
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorGetStatus(priv->mon, &running, &reason);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
if (ret < 0 || !virDomainObjIsActive(vm))
return -1;
@@ -3264,7 +3201,6 @@ qemuProcessReconnect(void *opaque)
VIR_FREE(data);
- qemuDriverLock(driver);
virObjectLock(obj);
cfg = virQEMUDriverGetConfig(driver);
@@ -3383,8 +3319,6 @@ endjob:
if (obj && virObjectUnref(obj))
virObjectUnlock(obj);
- qemuDriverUnlock(driver);
-
virConnectClose(conn);
virObjectUnref(cfg);
virObjectUnref(caps);
@@ -3399,7 +3333,6 @@ error:
if (!virDomainObjIsActive(obj)) {
if (virObjectUnref(obj))
virObjectUnlock(obj);
- qemuDriverUnlock(driver);
return;
}
@@ -3425,7 +3358,6 @@ error:
virObjectUnlock(obj);
}
}
- qemuDriverUnlock(driver);
virConnectClose(conn);
virObjectUnref(caps);
virObjectUnref(cfg);
@@ -3474,7 +3406,7 @@ qemuProcessReconnectHelper(virDomainObjPtr obj,
qemuDomainObjRestoreJob(obj, &data->oldjob);
- if (qemuDomainObjBeginJobWithDriver(src->driver, obj, QEMU_JOB_MODIFY) < 0)
+ if (qemuDomainObjBeginJob(src->driver, obj, QEMU_JOB_MODIFY) < 0)
goto error;
/* Since we close the connection later on, we have to make sure
@@ -4111,13 +4043,13 @@ int qemuProcessStart(virConnectPtr conn,
/* qemu doesn't support setting this on the command line, so
* enter the monitor */
VIR_DEBUG("Setting network link states");
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
if (qemuProcessSetLinkStates(vm) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
goto cleanup;
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
/* Technically, qemuProcessStart can be called from inside
* QEMU_ASYNC_JOB_MIGRATION_IN, but we are okay treating this like
@@ -4131,12 +4063,12 @@ int qemuProcessStart(virConnectPtr conn,
vm->def->mem.cur_balloon);
goto cleanup;
}
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
if (qemuMonitorSetBalloon(priv->mon, cur_balloon) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
goto cleanup;
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
if (!(flags & VIR_QEMU_PROCESS_START_PAUSED)) {
VIR_DEBUG("Starting domain CPUs");
@@ -4205,8 +4137,7 @@ cleanup:
int
-qemuProcessKill(virQEMUDriverPtr driver,
- virDomainObjPtr vm, unsigned int flags)
+qemuProcessKill(virDomainObjPtr vm, unsigned int flags)
{
int ret;
@@ -4227,20 +4158,9 @@ qemuProcessKill(virQEMUDriverPtr driver,
return 0;
}
- if (driver)
- qemuDriverUnlock(driver);
-
ret = virProcessKillPainfully(vm->pid,
!!(flags & VIR_QEMU_PROCESS_KILL_FORCE));
- if (driver) {
- virObjectRef(vm);
- virObjectUnlock(vm);
- qemuDriverLock(driver);
- virObjectLock(vm);
- virObjectUnref(vm);
- }
-
return ret;
}
@@ -4346,8 +4266,9 @@ void qemuProcessStop(virQEMUDriverPtr driver,
}
/* shut it off for sure */
- ignore_value(qemuProcessKill(driver, vm, VIR_QEMU_PROCESS_KILL_FORCE|
- VIR_QEMU_PROCESS_KILL_NOCHECK));
+ ignore_value(qemuProcessKill(vm,
+ VIR_QEMU_PROCESS_KILL_FORCE|
+ VIR_QEMU_PROCESS_KILL_NOCHECK));
qemuDomainCleanupRun(driver, vm);
@@ -4646,20 +4567,20 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
}
VIR_DEBUG("Getting initial memory amount");
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ qemuDomainObjEnterMonitor(driver, vm);
if (qemuMonitorGetBalloonInfo(priv->mon, &vm->def->mem.cur_balloon) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
goto cleanup;
}
if (qemuMonitorGetStatus(priv->mon, &running, &reason) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
goto cleanup;
}
if (qemuMonitorGetVirtType(priv->mon, &vm->def->virtType) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
goto cleanup;
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
if (!virDomainObjIsActive(vm))
goto cleanup;
@@ -4731,8 +4652,8 @@ qemuProcessAutoDestroy(virQEMUDriverPtr driver,
qemuDomainObjDiscardAsyncJob(driver, dom);
}
- if (qemuDomainObjBeginJobWithDriver(driver, dom,
- QEMU_JOB_DESTROY) < 0)
+ if (qemuDomainObjBeginJob(driver, dom,
+ QEMU_JOB_DESTROY) < 0)
goto cleanup;
VIR_DEBUG("Killing domain");
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index cbdab24..ce44fe5 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -84,8 +84,7 @@ typedef enum {
VIR_QEMU_PROCESS_KILL_NOCHECK = 1 << 2, /* bypass the running vm check */
} virQemuProcessKillMode;
-int qemuProcessKill(virQEMUDriverPtr driver,
- virDomainObjPtr vm, unsigned int flags);
+int qemuProcessKill(virDomainObjPtr vm, unsigned int flags);
int qemuProcessAutoDestroyInit(virQEMUDriverPtr driver);
void qemuProcessAutoDestroyShutdown(virQEMUDriverPtr driver);
--
1.8.1
11 years, 8 months
[libvirt] [PATCH] virCommand: Don't misuse the eventloop for async IO
by Michal Privoznik
Currently, if a command wants to do asynchronous IO, a callback
is registered in the libvirtd eventloop to handle writes and
reads. However, there's a race in virCommandWait. The eventloop
may already be executing the callback, while virCommandWait is
mangling internal state of virCommand. To deal with it, we need
to either introduce locking or spawn a separate thread where we
poll() on stdio from child. The former, however, requires to
unlock all mutexes held, as the event loop may execute other
callbacks which tries to lock one of the mutexes, deadlock and
thus never wake us up. So it's safer to spawn a separate thread.
---
This is an alternative to:
https://www.redhat.com/archives/libvir-list/2013-February/msg00352.html
src/util/vircommand.c | 342 +++++++++++---------------------------------------
1 file changed, 76 insertions(+), 266 deletions(-)
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index db7dbca..160f4c2 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
@@ -80,15 +81,13 @@ struct _virCommand {
char **errbuf;
int infd;
+ int inpipe;
int outfd;
int errfd;
int *outfdptr;
int *errfdptr;
- size_t inbufOffset;
- int inWatch;
- int outWatch;
- int errWatch;
+ virThreadPtr asyncioThread;
bool handshake;
int handshakeWait[2];
@@ -784,8 +783,7 @@ virCommandNewArgs(const char *const*args)
cmd->handshakeNotify[0] = -1;
cmd->handshakeNotify[1] = -1;
- cmd->infd = cmd->outfd = cmd->errfd = -1;
- cmd->inWatch = cmd->outWatch = cmd->errWatch = -1;
+ cmd->infd = cmd->inpipe = cmd->outfd = cmd->errfd = -1;
cmd->pid = -1;
virCommandAddArgSet(cmd, args);
@@ -1703,19 +1701,17 @@ virCommandToString(virCommandPtr cmd)
* Manage input and output to the child process.
*/
static int
-virCommandProcessIO(virCommandPtr cmd, int *inpipe)
+virCommandProcessIO(virCommandPtr cmd)
{
- int infd = -1, outfd = -1, errfd = -1;
+ int outfd = -1, errfd = -1;
size_t inlen = 0, outlen = 0, errlen = 0;
size_t inoff = 0;
int ret = 0;
/* With an input buffer, feed data to child
* via pipe */
- if (cmd->inbuf) {
+ if (cmd->inbuf)
inlen = strlen(cmd->inbuf);
- infd = *inpipe;
- }
/* With out/err buffer, the outfd/errfd have been filled with an
* FD for us. Guarantee an allocated string with partial results
@@ -1744,8 +1740,8 @@ virCommandProcessIO(virCommandPtr cmd, int *inpipe)
struct pollfd fds[3];
int nfds = 0;
- if (infd != -1) {
- fds[nfds].fd = infd;
+ if (cmd->inpipe != -1) {
+ fds[nfds].fd = cmd->inpipe;
fds[nfds].events = POLLOUT;
fds[nfds].revents = 0;
nfds++;
@@ -1817,21 +1813,19 @@ virCommandProcessIO(virCommandPtr cmd, int *inpipe)
}
if (fds[i].revents & (POLLOUT | POLLERR) &&
- fds[i].fd == infd) {
+ fds[i].fd == cmd->inpipe) {
int done;
/* Coverity 5.3.0 can't see that we only get here if
* infd is in the set because it was non-negative. */
sa_assert(infd != -1);
- done = write(infd, cmd->inbuf + inoff,
+ done = write(cmd->inpipe, cmd->inbuf + inoff,
inlen - inoff);
if (done < 0) {
if (errno == EPIPE) {
VIR_DEBUG("child closed stdin early, ignoring EPIPE "
- "on fd %d", infd);
- if (VIR_CLOSE(*inpipe) < 0)
- VIR_DEBUG("ignoring failed close on fd %d", infd);
- infd = -1;
+ "on fd %d", cmd->inpipe);
+ VIR_FORCE_CLOSE(cmd->inpipe);
} else if (errno != EINTR && errno != EAGAIN) {
virReportSystemError(errno, "%s",
_("unable to write to child input"));
@@ -1839,11 +1833,8 @@ virCommandProcessIO(virCommandPtr cmd, int *inpipe)
}
} else {
inoff += done;
- if (inoff == inlen) {
- if (VIR_CLOSE(*inpipe) < 0)
- VIR_DEBUG("ignoring failed close on fd %d", infd);
- infd = -1;
- }
+ if (inoff == inlen)
+ VIR_FORCE_CLOSE(cmd->inpipe);
}
}
}
@@ -1914,7 +1905,6 @@ virCommandRun(virCommandPtr cmd, int *exitstatus)
int ret = 0;
char *outbuf = NULL;
char *errbuf = NULL;
- int infd[2] = { -1, -1 };
struct stat st;
bool string_io;
bool async_io = false;
@@ -1960,18 +1950,6 @@ virCommandRun(virCommandPtr cmd, int *exitstatus)
}
}
- /* If we have an input buffer, we need
- * a pipe to feed the data to the child */
- if (cmd->inbuf) {
- if (pipe2(infd, O_CLOEXEC) < 0) {
- virReportSystemError(errno, "%s",
- _("unable to open pipe"));
- cmd->has_error = -1;
- return -1;
- }
- cmd->infd = infd[0];
- }
-
/* If caller requested the same string for stdout and stderr, then
* merge those into one string. */
if (cmd->outbuf && cmd->outbuf == cmd->errbuf) {
@@ -1999,23 +1977,14 @@ virCommandRun(virCommandPtr cmd, int *exitstatus)
cmd->flags |= VIR_EXEC_RUN_SYNC;
if (virCommandRunAsync(cmd, NULL) < 0) {
- if (cmd->inbuf) {
- tmpfd = infd[0];
- if (VIR_CLOSE(infd[0]) < 0)
- VIR_DEBUG("ignoring failed close on fd %d", tmpfd);
- tmpfd = infd[1];
- if (VIR_CLOSE(infd[1]) < 0)
- VIR_DEBUG("ignoring failed close on fd %d", tmpfd);
- }
cmd->has_error = -1;
return -1;
}
- tmpfd = infd[0];
- if (VIR_CLOSE(infd[0]) < 0)
- VIR_DEBUG("ignoring failed close on fd %d", tmpfd);
- if (string_io)
- ret = virCommandProcessIO(cmd, &infd[1]);
+ if (string_io) {
+ VIR_FORCE_CLOSE(cmd->infd);
+ ret = virCommandProcessIO(cmd);
+ }
if (virCommandWait(cmd, exitstatus) < 0)
ret = -1;
@@ -2031,11 +2000,7 @@ virCommandRun(virCommandPtr cmd, int *exitstatus)
/* Reset any capturing, in case caller runs
* this identical command again */
- if (cmd->inbuf) {
- tmpfd = infd[1];
- if (VIR_CLOSE(infd[1]) < 0)
- VIR_DEBUG("ignoring failed close on fd %d", tmpfd);
- }
+ VIR_FORCE_CLOSE(cmd->inpipe);
if (cmd->outbuf == &outbuf) {
tmpfd = cmd->outfd;
if (VIR_CLOSE(cmd->outfd) < 0)
@@ -2135,177 +2100,13 @@ virCommandHook(void *data)
static void
-virCommandHandleReadWrite(int watch, int fd, int events, void *opaque)
-{
- virCommandPtr cmd = (virCommandPtr) opaque;
- char ***bufptr = NULL;
- char buf[1024];
- ssize_t nread, nwritten;
- size_t len = 0;
- int *watchPtr = NULL;
- bool eof = false;
- int *fdptr = NULL, **fdptrptr = NULL;
-
- VIR_DEBUG("watch=%d fd=%d events=%d", watch, fd, events);
- errno = 0;
-
- if (watch == cmd->inWatch) {
- watchPtr = &cmd->inWatch;
- fdptr = &cmd->infd;
-
- if (events & VIR_EVENT_HANDLE_WRITABLE) {
- len = strlen(cmd->inbuf);
-
- while (true) {
- nwritten = write(fd, cmd->inbuf + cmd->inbufOffset,
- len - cmd->inbufOffset);
- if (nwritten < 0) {
- if (errno != EAGAIN && errno != EINTR) {
- virReportSystemError(errno,
- _("Unable to write command's "
- "input to FD %d"),
- fd);
- eof = true;
- }
- break;
- }
-
- if (nwritten == 0) {
- eof = true;
- break;
- }
-
- cmd->inbufOffset += nwritten;
- if (cmd->inbufOffset == len) {
- VIR_FORCE_CLOSE(cmd->infd);
- eof = true;
- break;
- }
- }
-
- }
- } else {
- if (watch == cmd->outWatch) {
- watchPtr = &cmd->outWatch;
- bufptr = &cmd->outbuf;
- fdptr = &cmd->outfd;
- fdptrptr = &cmd->outfdptr;
- } else {
- watchPtr = &cmd->errWatch;
- bufptr = &cmd->errbuf;
- fdptr = &cmd->errfd;
- fdptrptr = &cmd->errfdptr;
- }
-
- if (events & VIR_EVENT_HANDLE_READABLE) {
- if (**bufptr)
- len = strlen(**bufptr);
-
- while (true) {
- nread = read(fd, buf, sizeof(buf));
- if (nread < 0) {
- if (errno != EAGAIN && errno != EINTR) {
- virReportSystemError(errno,
- _("unable to read command's "
- "output from FD %d"),
- fd);
- eof = true;
- }
- break;
- }
-
- if (nread == 0) {
- eof = true;
- break;
- }
-
- if (VIR_REALLOC_N(**bufptr, len + nread + 1) < 0) {
- virReportOOMError();
- break;
- }
-
- memcpy(**bufptr + len, buf, nread);
- (**bufptr)[len + nread] = '\0';
- }
-
- }
- }
-
- if (eof || (events & VIR_EVENT_HANDLE_HANGUP) ||
- (events & VIR_EVENT_HANDLE_ERROR)) {
- virEventRemoveHandle(watch);
-
- *watchPtr = -1;
- VIR_FORCE_CLOSE(*fdptr);
- if (bufptr)
- *bufptr = NULL;
- if (fdptrptr)
- *fdptrptr = NULL;
- }
-}
-
-
-static int
-virCommandRegisterEventLoop(virCommandPtr cmd)
+virCommandDoAsyncIOHelper(void *opaque)
{
- int ret = -1;
-
- if (cmd->inbuf &&
- (cmd->inWatch = virEventAddHandle(cmd->infd,
- VIR_EVENT_HANDLE_WRITABLE |
- VIR_EVENT_HANDLE_HANGUP |
- VIR_EVENT_HANDLE_ERROR,
- virCommandHandleReadWrite,
- cmd, NULL)) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to register infd %d in the event loop"),
- cmd->infd);
- goto cleanup;
+ virCommandPtr cmd = opaque;
+ if (virCommandProcessIO(cmd) < 0) {
+ /* If something went wrong, save errno or -1*/
+ cmd->has_error = errno ? errno : -1;
}
-
- if (cmd->outbuf && cmd->outfdptr == &cmd->outfd &&
- (cmd->outWatch = virEventAddHandle(cmd->outfd,
- VIR_EVENT_HANDLE_READABLE |
- VIR_EVENT_HANDLE_HANGUP |
- VIR_EVENT_HANDLE_ERROR,
- virCommandHandleReadWrite,
- cmd, NULL)) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to register outfd %d in the event loop"),
- cmd->outfd);
-
- if (cmd->inWatch != -1) {
- virEventRemoveHandle(cmd->inWatch);
- cmd->inWatch = -1;
- }
- goto cleanup;
- }
-
- if (cmd->errbuf && cmd->errfdptr == &cmd->errfd &&
- (cmd->errWatch = virEventAddHandle(cmd->errfd,
- VIR_EVENT_HANDLE_READABLE |
- VIR_EVENT_HANDLE_HANGUP |
- VIR_EVENT_HANDLE_ERROR,
- virCommandHandleReadWrite,
- cmd, NULL)) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to register errfd %d in the event loop"),
- cmd->errfd);
- if (cmd->inWatch != -1) {
- virEventRemoveHandle(cmd->inWatch);
- cmd->inWatch = -1;
- }
- if (cmd->outWatch != -1) {
- virEventRemoveHandle(cmd->outWatch);
- cmd->outWatch = -1;
- }
- goto cleanup;
- }
-
- ret = 0;
-
-cleanup:
- return ret;
}
@@ -2351,23 +2152,21 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid)
synchronous = cmd->flags & VIR_EXEC_RUN_SYNC;
cmd->flags &= ~VIR_EXEC_RUN_SYNC;
- /* Buffer management can only be requested via virCommandRun, unless help
- * from the event loop has been requested via virCommandDoAsyncIO. */
- if (cmd->flags & VIR_EXEC_ASYNC_IO) {
- /* If we have an input buffer, we need
- * a pipe to feed the data to the child */
- if (cmd->inbuf && cmd->infd == -1) {
- if (pipe2(infd, O_CLOEXEC) < 0) {
- virReportSystemError(errno, "%s",
- _("unable to open pipe"));
- cmd->has_error = -1;
- return -1;
- }
- cmd->infd = infd[0];
+ /* Buffer management can only be requested via virCommandRun or
+ * virCommandDoAsyncIO. */
+ if (cmd->inbuf && cmd->infd == -1 &&
+ (synchronous || cmd->flags & VIR_EXEC_ASYNC_IO)) {
+ if (pipe2(infd, O_CLOEXEC) < 0) {
+ virReportSystemError(errno, "%s",
+ _("unable to open pipe"));
+ cmd->has_error = -1;
+ return -1;
}
+ cmd->infd = infd[0];
+ cmd->inpipe = infd[1];
} else if ((cmd->inbuf && cmd->infd == -1) ||
- (cmd->outbuf && cmd->outfdptr != &cmd->outfd) ||
- (cmd->errbuf && cmd->errfdptr != &cmd->errfd)) {
+ (cmd->outbuf && cmd->outfdptr != &cmd->outfd) ||
+ (cmd->errbuf && cmd->errfdptr != &cmd->errfd)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot mix string I/O with asynchronous command"));
return -1;
@@ -2377,24 +2176,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);
@@ -2430,15 +2229,27 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid)
cmd->reap = true;
if (ret == 0 && cmd->flags & VIR_EXEC_ASYNC_IO) {
- cmd->flags &= ~VIR_EXEC_ASYNC_IO;
- if (cmd->inbuf && cmd->infd != -1) {
- /* close the read end of infd and replace it with the write end */
+ if (cmd->inbuf)
VIR_FORCE_CLOSE(cmd->infd);
- cmd->infd = infd[1];
+ /* clear any error so we can catch if the helper thread reports one */
+ cmd->has_error = 0;
+ if (VIR_ALLOC(cmd->asyncioThread) < 0 ||
+ virThreadCreate(cmd->asyncioThread, true,
+ virCommandDoAsyncIOHelper, cmd) < 0) {
+ virReportSystemError(errno, "%s",
+ _("Unable to create thread "
+ "to process command's IO"));
+ VIR_FREE(cmd->asyncioThread);
+ virCommandAbort(cmd);
+ ret = -1;
}
- ret = virCommandRegisterEventLoop(cmd);
}
+cleanup:
+ if (ret < 0) {
+ VIR_FORCE_CLOSE(cmd->infd);
+ VIR_FORCE_CLOSE(cmd->inpipe);
+ }
return ret;
}
@@ -2459,7 +2270,6 @@ 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();
@@ -2484,24 +2294,20 @@ virCommandWait(virCommandPtr cmd, int *exitstatus)
* guarantee that virProcessWait only fails due to failure to wait,
* 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;
+ if (cmd->flags & VIR_EXEC_ASYNC_IO) {
+ cmd->flags &= ~VIR_EXEC_ASYNC_IO;
+ virThreadJoin(cmd->asyncioThread);
+ VIR_FREE(cmd->asyncioThread);
+ VIR_FORCE_CLOSE(cmd->inpipe);
+ if (cmd->has_error) {
+ const char *msg = _("Error while processing command's IO");
+ if (cmd->has_error < 0)
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", msg);
+ else
+ virReportSystemError(cmd->has_error, "%s", msg);
+ ret = -1;
+ }
}
-
if (ret == 0) {
cmd->pid = -1;
cmd->reap = false;
@@ -2719,6 +2525,10 @@ virCommandFree(virCommandPtr cmd)
VIR_FORCE_CLOSE(cmd->transfer[i]);
}
+ if (cmd->asyncioThread) {
+ virThreadJoin(cmd->asyncioThread);
+ VIR_FREE(cmd->asyncioThread);
+ }
VIR_FREE(cmd->inbuf);
VIR_FORCE_CLOSE(cmd->outfd);
VIR_FORCE_CLOSE(cmd->errfd);
--
1.8.0.2
11 years, 8 months
[libvirt] [PATCH 00/13] Yet another c99 struct initialization conversion
by Michal Privoznik
I wonder if there's any syntax-check rule that we could use
to enforce this style.
Michal Privoznik (13):
virsh: Switch to c99 initialization of vshCmdDef
virsh.c: Switch to c99 initialization of vshCmdInfo
virsh-domain-monitor.c: Switch to c99 initialization of vshCmdInfo
virsh-domain.c: Switch to c99 initialization of vshCmdInfo
virsh-host.c: Switch to c99 initialization of vshCmdInfo
virsh-interface.c: Switch to c99 initialization of vshCmdInfo
virsh-network.c: Switch to c99 initialization of vshCmdInfo
virsh-nodedev.c: Switch to c99 initialization of vshCmdInfo
virsh-nwfilter.c: Switch to c99 initialization of vshCmdInfo
virsh-pool.c: Switch to c99 initialization of vshCmdInfo
virsh-secret.c: Switch to c99 initialization of vshCmdInfo
virsh-snapshot.c: Switch to c99 initialization of vshCmdInfo
virsh-volume.c: Switch to c99 initialization of vshCmdInfo
tools/virsh-domain-monitor.c | 198 ++++--
tools/virsh-domain.c | 1409 +++++++++++++++++++++++++++++++-----------
tools/virsh-host.c | 222 +++++--
tools/virsh-interface.c | 256 +++++---
tools/virsh-network.c | 230 +++++--
tools/virsh-nodedev.c | 144 +++--
tools/virsh-nwfilter.c | 92 ++-
tools/virsh-pool.c | 331 +++++++---
tools/virsh-secret.c | 109 +++-
tools/virsh-snapshot.c | 182 ++++--
tools/virsh-volume.c | 276 +++++++--
tools/virsh.c | 97 ++-
12 files changed, 2631 insertions(+), 915 deletions(-)
--
1.8.0.2
11 years, 8 months
[libvirt] [PATCH 0/3] add virendian.h, and use it to kill xen cpumap issue
by Eric Blake
Not only does this solve the compiler warning on 32-bit machines,
but it completely gets rid of what looks like bogus pointer aliasing,
all while reducing the number of lines in xen_hypervisor.c.
Eric Blake (3):
util: add virendian.h macros
util: use new virendian.h macros
xen: clean up the mess with cpumap
.gitignore | 1 +
src/Makefile.am | 1 +
src/cpu/cpu_x86.c | 24 ++++------
src/util/virendian.h | 93 +++++++++++++++++++++++++++++++++++++++
src/util/virstoragefile.c | 109 ++++++++++------------------------------------
src/xen/xen_hypervisor.c | 16 +++----
tests/Makefile.am | 8 +++-
tests/virendiantest.c | 102 +++++++++++++++++++++++++++++++++++++++++++
8 files changed, 239 insertions(+), 115 deletions(-)
create mode 100644 src/util/virendian.h
create mode 100644 tests/virendiantest.c
--
1.8.1.2
11 years, 8 months
[libvirt] [PATCH] build: fix compilation of selinux on RHEL 5
by Eric Blake
On RHEL 5, I got:
security/security_selinux.c: In function 'getContext':
security/security_selinux.c:971: warning: unused parameter 'mgr' [-Wunused-parameter]
* src/security/security_selinux.c (getContext): Mark potentially
unused parameter.
---
Pushing under the build-breaker rule.
src/security/security_selinux.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 2a9333c..8173b20 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2012 Red Hat, Inc.
+ * Copyright (C) 2008-2013 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -968,7 +968,7 @@ virSecuritySELinuxFSetFilecon(int fd, char *tcon)
/* Set fcon to the appropriate label for path and mode, or return -1. */
static int
-getContext(virSecurityManagerPtr mgr,
+getContext(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
const char *newpath, mode_t mode, security_context_t *fcon)
{
#if HAVE_SELINUX_LABEL_H
--
1.8.1.2
11 years, 8 months
[libvirt] [PATCH 00/11] Revisit xen driver Coverity cleanup changes
by John Ferlan
This is a rework of a couple of patches. Initially the changes were to
just remove some Coverity warnings; however, it was pointed out that each
of the xen drivers could use some cleanup since they were duplicating
checks in libvirt.c, see:
https://www.redhat.com/archives/libvir-list/2013-January/msg01038.html
https://www.redhat.com/archives/libvir-list/2013-January/msg01057.html
While I was at it - I cleaned up some of the function headers.
Additionally, a revisit of a change to add Coverity false positive tags
to the v0 & v1 xen_hypervisor cpumap manipulation, see:
https://www.redhat.com/archives/libvir-list/2013-January/msg01527.html
and followups.
John Ferlan (11):
xs: Remove redundant validity checks
xs: Code cleanup
inotify: Code cleanup
xm: Remove redundant validity checks
xm: Clean up
xend: Remove redundant validity checks
xend: Fix a memory leak found by Coverity
xend: Clean up
hypervisor: Remove redundant validity checks
hypervisor: Clean up
hypervisor: Revisit Coverity issues regarding cpumap
src/xen/xen_hypervisor.c | 220 ++++++++--------------------------
src/xen/xen_inotify.c | 48 ++++----
src/xen/xend_internal.c | 303 ++++++++++++++---------------------------------
src/xen/xm_internal.c | 195 ++++++++++++++----------------
src/xen/xs_internal.c | 239 +++++++++++--------------------------
5 files changed, 325 insertions(+), 680 deletions(-)
--
1.7.11.7
11 years, 8 months
[libvirt] [PATCH] build: fix VPATH testsuite
by Eric Blake
'make check' has been failing on VPATH builds since commit
907a39e7. The tests already had magic for munging path names,
but were munging to the wrong location, thus working only on
an in-tree build.
* tests/securityselinuxlabeltest.c (testSELinuxMungePath): Munge
to correct path.
---
Pushing under the build-breaker rule.
tests/securityselinuxlabeltest.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c
index c0bb09b..7445ab6 100644
--- a/tests/securityselinuxlabeltest.c
+++ b/tests/securityselinuxlabeltest.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2012 Red Hat, Inc.
+ * Copyright (C) 2011-2013 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -61,7 +61,7 @@ testSELinuxMungePath(char **path)
char *tmp;
if (virAsprintf(&tmp, "%s/securityselinuxlabeldata%s",
- abs_srcdir, *path) < 0) {
+ abs_builddir, *path) < 0) {
virReportOOMError();
return -1;
}
--
1.7.1
11 years, 8 months
[libvirt] [PATCH] docs: fix 1.0.2 release date
by Eric Blake
* docs/news.html.in: Use correct release year.
---
Pushing under the trivial rule.
docs/news.html.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/news.html.in b/docs/news.html.in
index 48a039a..5f51dac 100644
--- a/docs/news.html.in
+++ b/docs/news.html.in
@@ -8,7 +8,7 @@
<p>Here is the list of official releases, it is also possible to just use the <a href="downloads.html">GIT version or snapshot</a>, contact the mailing list
and check the <a href="http://libvirt.org/git/?p=libvirt.git;a=log">GIT log</a> to gauge progress.</p>
- <h3>1.0.2: Jan 30 2012</h3>
+ <h3>1.0.2: Jan 30 2013</h3>
<ul>
<li> Features:<br/>
LXC improvements (Daniel P. Berrange),<br/>
--
1.8.1.2
11 years, 8 months