[libvirt] [PATCH RFC 0/5] drop nested job concept

Instead I suggest to serialize qemu monitor commands. My original motivation is to prepare job exclusion code to add agent jobs. This job is a special job to operate on guest agent only so first it can be run in parallel with sync, async and nested jobs and second it should not block any qemu monitor job at all. Eventually I want to move from a lot of different types of jobs to just a job with some kind of matrix which describes what jobs can run in a parallel. As a first step I want to drop nested jobs. AFAIU *main* nested job purpuse is to serialize requests to monitor from async jobs and allowed sync jobs as monitor does not do it by himself now. Strictly speaking this assertion is rather rough because nested jobs and sync jobs serialized at job level and thus chunks of code that serialized differ from case when only monitor requests are serialized. Nevertheless IFAIU this part of libvirt is not strict too. We have a lot of query commands and async commands that can execute in parallel and have no definition of what query job or async job are. Thus it is not clear is this code correct or not. So the same argument is applicable to new approach: query jobs are safe to be called during async jobs. (Except that new approach opens situation when async job interrupts query job itself but it generally not clear how this can break query job). On this path job became high level concept which I think it should be. Also we drop boring passing of current async job which we need only for safety check deep down below the stack. We drop driver passing for nested jobs which I guess we really don't need to pass at all as we need it only to check queue size and nested job probably should skip this check. The diff stat looks large but most of code is dumb renaming or dropping unused parameter in patches 4 and 5. To reduce risk of introducing an error on this tedious task I used sed and perl where I can. I ran only a simple test with this series of quering a domain during its migration. Nikolay Shirokovskiy (5): qemu: monitor: serialize send command requests qemu: job: drop nested job qemu: monitor: add closed monitor flag qemu: drop driver parameter on domain enter/exit monitor qemu: drop qemuDomainObjEnterMonitorAsync src/qemu/qemu_domain.c | 154 ++++--------------- src/qemu/qemu_domain.h | 43 ++---- src/qemu/qemu_driver.c | 374 ++++++++++++++++++++-------------------------- src/qemu/qemu_hotplug.c | 282 ++++++++++++++++------------------ src/qemu/qemu_hotplug.h | 21 +-- src/qemu/qemu_migration.c | 292 +++++++++++++----------------------- src/qemu/qemu_migration.h | 7 +- src/qemu/qemu_monitor.c | 93 ++++++++++-- src/qemu/qemu_process.c | 279 +++++++++++++--------------------- src/qemu/qemu_process.h | 20 +-- tests/qemuhotplugtest.c | 2 +- 11 files changed, 636 insertions(+), 931 deletions(-) -- 1.8.3.1

Current libvirt qemu monitor can not handle many send command requests and it does not need to as misc job conditions protect him from this case. As there is an intention to replace nested jobs concept by mere serialization at monitor level let's add serialization to monitor as a preparation step. Let's add job tracking code so that in case of request jams we can get nice info on blockers just as domain job acquiring code does. This patch introduces distinct mutex condition for serializing queries. This way we can still wake up only senders on qemu response and wake up waiters when sender finishes. Typically we wake up only one waiter, in case of error conditions all waiters will wakeup and fail. --- src/qemu/qemu_monitor.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 3f86887..f402300 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -43,6 +43,7 @@ #include "virprobe.h" #include "virstring.h" #include "virtime.h" +#include "virthreadjob.h" #ifdef WITH_DTRACE_PROBES # include "libvirt_qemu_probes.h" @@ -99,6 +100,11 @@ struct _qemuMonitor { qemuMonitorReportDomainLogError logFunc; void *logOpaque; virFreeCallback logDestroy; + + unsigned long long owner; + const char *ownerAPI; + unsigned long long started; + virCond queueCond; }; /** @@ -320,6 +326,7 @@ qemuMonitorDispose(void *obj) virResetError(&mon->lastError); virCondDestroy(&mon->notify); + virCondDestroy(&mon->queueCond); VIR_FREE(mon->buffer); virJSONValueFree(mon->options); VIR_FREE(mon->balloonpath); @@ -813,6 +820,11 @@ qemuMonitorOpenInternal(virDomainObjPtr vm, _("cannot initialize monitor condition")); goto cleanup; } + if (virCondInit(&mon->queueCond) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot initialize monitor queue condition")); + goto cleanup; + } mon->fd = fd; mon->hasSendFD = hasSendFD; mon->vm = virObjectRef(vm); @@ -986,12 +998,52 @@ qemuMonitorNextCommandID(qemuMonitorPtr mon) return id; } +#define QEMU_COMMAND_WAIT_TIME (1000ull * 30) int qemuMonitorSend(qemuMonitorPtr mon, qemuMonitorMessagePtr msg) { int ret = -1; + unsigned long long now; + unsigned long long then; + + if (virTimeMillisNow(&now) < 0) + return -1; + then = now + QEMU_COMMAND_WAIT_TIME; + + while (mon->msg && mon->lastError.code == VIR_ERR_OK) { + VIR_DEBUG("Waiting for monitor lock: mon=%p, msg=%s, fd=%d", + mon, msg->txBuffer, msg->txFD); + + if (virCondWaitUntil(&mon->queueCond, &mon->parent.lock, then) < 0) { + if (errno == ETIMEDOUT) { + if (mon->ownerAPI) { + virReportError(VIR_ERR_OPERATION_TIMEOUT, + _("cannot acquire monitor lock (held by %s)"), + mon->ownerAPI); + } else { + virReportError(VIR_ERR_OPERATION_TIMEOUT, "%s", + _("cannot acquire monitor lock")); + } + } else { + virReportSystemError(errno, "%s", + _("cannot acquire monitor lock")); + } + + now = 0; + ignore_value(virTimeMillisNow(&now)); + VIR_WARN("Cannot send message: mon=%p, msg=%s, fd=%d" + " blocker: msg=%s, fd=%d" + " (thread: %llu, API: %s," " duration: %llu)", + mon, msg->txBuffer, msg->txFD, + mon->msg->txBuffer, mon->msg->txFD, + mon->owner, NULLSTR(mon->ownerAPI), + now && mon->started ? (now - mon->started) / 1000 : 0); + + return -1; + } + } /* Check whether qemu quit unexpectedly */ if (mon->lastError.code != VIR_ERR_OK) { @@ -1001,6 +1053,11 @@ qemuMonitorSend(qemuMonitorPtr mon, return -1; } + now = 0; + ignore_value(virTimeMillisNow(&now)); + mon->ownerAPI = virThreadJobGet(); + mon->owner = virThreadSelfID(); + mon->started = now; mon->msg = msg; qemuMonitorUpdateWatch(mon); @@ -1027,6 +1084,15 @@ qemuMonitorSend(qemuMonitorPtr mon, cleanup: mon->msg = NULL; + mon->ownerAPI = NULL; + mon->owner = 0; + mon->started = 0; + + if (mon->lastError.code == VIR_ERR_OK) + virCondSignal(&mon->queueCond); + else + virCondBroadcast(&mon->queueCond); + qemuMonitorUpdateWatch(mon); return ret; -- 1.8.3.1

After the drop we don't need checks that nested job is requested by the same thread that run async job and that there is async job at all. Or that async job does not try to use monitor without aquiring nested job. Dropping this value from enum does not affect persistent status xml too as nested job is not trackable and serialized/deserialized just as QEMU_JOB_NONE. --- src/qemu/qemu_domain.c | 81 +++++++++---------------------------------------- src/qemu/qemu_domain.h | 7 +---- src/qemu/qemu_process.c | 32 +++++-------------- 3 files changed, 23 insertions(+), 97 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 137d4d5..40d46d6 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -73,7 +73,6 @@ VIR_ENUM_IMPL(qemuDomainJob, QEMU_JOB_LAST, "abort", "migration operation", "none", /* async job is never stored in job.active */ - "async nested", ); VIR_ENUM_IMPL(qemuDomainAsyncJob, QEMU_ASYNC_JOB_LAST, @@ -3199,8 +3198,6 @@ qemuDomainObjDiscardAsyncJob(virQEMUDriverPtr driver, virDomainObjPtr obj) { qemuDomainObjPrivatePtr priv = obj->privateData; - if (priv->job.active == QEMU_JOB_ASYNC_NESTED) - qemuDomainObjResetJob(priv); qemuDomainObjResetAsyncJob(priv); qemuDomainObjSaveJob(driver, obj); } @@ -3248,7 +3245,6 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver, qemuDomainObjPrivatePtr priv = obj->privateData; unsigned long long now; unsigned long long then; - bool nested = job == QEMU_JOB_ASYNC_NESTED; bool async = job == QEMU_JOB_ASYNC; virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); const char *blocker = NULL; @@ -3281,7 +3277,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver, goto error; } - while (!nested && !qemuDomainNestedJobAllowed(priv, job)) { + while (!qemuDomainNestedJobAllowed(priv, job)) { VIR_DEBUG("Waiting for async job (vm=%p name=%s)", obj, obj->def->name); if (virCondWaitUntil(&priv->job.asyncCond, &obj->parent.lock, then) < 0) goto error; @@ -3295,7 +3291,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver, /* No job is active but a new async job could have been started while obj * was unlocked, so we need to recheck it. */ - if (!nested && !qemuDomainNestedJobAllowed(priv, job)) + if (!qemuDomainNestedJobAllowed(priv, job)) goto retry; qemuDomainObjResetJob(priv); @@ -3350,7 +3346,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver, priv->job.asyncOwner, NULLSTR(priv->job.asyncOwnerAPI), duration / 1000, asyncDuration / 1000); - if (nested || qemuDomainNestedJobAllowed(priv, job)) + if (qemuDomainNestedJobAllowed(priv, job)) blocker = priv->job.ownerAPI; else blocker = priv->job.asyncOwnerAPI; @@ -3419,30 +3415,6 @@ int qemuDomainObjBeginAsyncJob(virQEMUDriverPtr driver, return 0; } -int -qemuDomainObjBeginNestedJob(virQEMUDriverPtr driver, - virDomainObjPtr obj, - qemuDomainAsyncJob asyncJob) -{ - qemuDomainObjPrivatePtr priv = obj->privateData; - - if (asyncJob != priv->job.asyncJob) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected async job %d"), asyncJob); - return -1; - } - - if (priv->job.asyncOwner != virThreadSelfID()) { - VIR_WARN("This thread doesn't seem to be the async job owner: %llu", - priv->job.asyncOwner); - } - - return qemuDomainObjBeginJobInternal(driver, obj, - QEMU_JOB_ASYNC_NESTED, - QEMU_ASYNC_JOB_NONE); -} - - /* * obj must be locked and have a reference before calling * @@ -3502,45 +3474,25 @@ qemuDomainObjAbortAsyncJob(virDomainObjPtr obj) * * 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. + * that the VM is still active * * To be followed with qemuDomainObjExitMonitor() once complete */ -static int -qemuDomainObjEnterMonitorInternal(virQEMUDriverPtr driver, - virDomainObjPtr obj, - qemuDomainAsyncJob asyncJob) +static void +qemuDomainObjEnterMonitorInternal(virDomainObjPtr obj) { qemuDomainObjPrivatePtr priv = obj->privateData; - if (asyncJob != QEMU_ASYNC_JOB_NONE) { - int ret; - if ((ret = qemuDomainObjBeginNestedJob(driver, obj, asyncJob)) < 0) - return ret; - if (!virDomainObjIsActive(obj)) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("domain is no longer running")); - qemuDomainObjEndJob(driver, obj); - return -1; - } - } else if (priv->job.asyncOwner == virThreadSelfID()) { - VIR_WARN("This thread seems to be the async job owner; entering" - " monitor without asking for a nested job is dangerous"); - } - VIR_DEBUG("Entering monitor (mon=%p vm=%p name=%s)", priv->mon, obj, obj->def->name); virObjectLock(priv->mon); virObjectRef(priv->mon); ignore_value(virTimeMillisNow(&priv->monStart)); virObjectUnlock(obj); - - return 0; } static void ATTRIBUTE_NONNULL(1) -qemuDomainObjExitMonitorInternal(virQEMUDriverPtr driver, - virDomainObjPtr obj) +qemuDomainObjExitMonitorInternal(virDomainObjPtr obj) { qemuDomainObjPrivatePtr priv = obj->privateData; bool hasRefs; @@ -3557,16 +3509,12 @@ qemuDomainObjExitMonitorInternal(virQEMUDriverPtr driver, priv->monStart = 0; if (!hasRefs) priv->mon = NULL; - - if (priv->job.active == QEMU_JOB_ASYNC_NESTED) - qemuDomainObjEndJob(driver, obj); } -void qemuDomainObjEnterMonitor(virQEMUDriverPtr driver, +void qemuDomainObjEnterMonitor(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, virDomainObjPtr obj) { - ignore_value(qemuDomainObjEnterMonitorInternal(driver, obj, - QEMU_ASYNC_JOB_NONE)); + qemuDomainObjEnterMonitorInternal(obj); } /* obj must NOT be locked before calling @@ -3579,10 +3527,10 @@ void qemuDomainObjEnterMonitor(virQEMUDriverPtr driver, * and replaced by the persistent definition, so pointers stolen * from the live definition could no longer be valid. */ -int qemuDomainObjExitMonitor(virQEMUDriverPtr driver, +int qemuDomainObjExitMonitor(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, virDomainObjPtr obj) { - qemuDomainObjExitMonitorInternal(driver, obj); + qemuDomainObjExitMonitorInternal(obj); if (!virDomainObjIsActive(obj)) { if (!virGetLastError()) virReportError(VIR_ERR_OPERATION_FAILED, "%s", @@ -3607,11 +3555,12 @@ int qemuDomainObjExitMonitor(virQEMUDriverPtr driver, * in the meantime). */ int -qemuDomainObjEnterMonitorAsync(virQEMUDriverPtr driver, +qemuDomainObjEnterMonitorAsync(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, virDomainObjPtr obj, - qemuDomainAsyncJob asyncJob) + qemuDomainAsyncJob asyncJob ATTRIBUTE_UNUSED) { - return qemuDomainObjEnterMonitorInternal(driver, obj, asyncJob); + qemuDomainObjEnterMonitorInternal(obj); + return 0; } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 7650ff3..7fd8cd6 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -73,9 +73,8 @@ typedef enum { QEMU_JOB_ABORT, /* Abort current async job */ QEMU_JOB_MIGRATION_OP, /* Operation influencing outgoing migration */ - /* The following two items must always be the last items before JOB_LAST */ + /* The following item must always be the last item before JOB_LAST */ QEMU_JOB_ASYNC, /* Asynchronous job */ - QEMU_JOB_ASYNC_NESTED, /* Normal job within an async job */ QEMU_JOB_LAST } qemuDomainJob; @@ -413,10 +412,6 @@ int qemuDomainObjBeginAsyncJob(virQEMUDriverPtr driver, virDomainObjPtr obj, qemuDomainAsyncJob asyncJob) ATTRIBUTE_RETURN_CHECK; -int qemuDomainObjBeginNestedJob(virQEMUDriverPtr driver, - virDomainObjPtr obj, - qemuDomainAsyncJob asyncJob) - ATTRIBUTE_RETURN_CHECK; void qemuDomainObjEndJob(virQEMUDriverPtr driver, virDomainObjPtr obj); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f8f379a..d9776c4 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3132,8 +3132,6 @@ qemuProcessRecoverJob(virQEMUDriverPtr driver, case QEMU_JOB_MIGRATION_OP: case QEMU_JOB_ABORT: case QEMU_JOB_ASYNC: - case QEMU_JOB_ASYNC_NESTED: - /* async job was already handled above */ case QEMU_JOB_NONE: case QEMU_JOB_LAST: break; @@ -5916,7 +5914,7 @@ qemuProcessBeginStopJob(virQEMUDriverPtr driver, void qemuProcessStop(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainShutoffReason reason, - qemuDomainAsyncJob asyncJob, + qemuDomainAsyncJob asyncJob ATTRIBUTE_UNUSED, unsigned int flags) { int ret; @@ -5930,32 +5928,21 @@ void qemuProcessStop(virQEMUDriverPtr driver, virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); VIR_DEBUG("Shutting down vm=%p name=%s id=%d pid=%lld, " - "reason=%s, asyncJob=%s, flags=%x", + "reason=%s, flags=%x", vm, vm->def->name, vm->def->id, (long long) vm->pid, virDomainShutoffReasonTypeToString(reason), - qemuDomainAsyncJobTypeToString(asyncJob), flags); + if (!virDomainObjIsActive(vm)) { + VIR_DEBUG("VM '%s' not active", vm->def->name); + return; + } + /* This method is routinely used in clean up paths. Disable error * reporting so we don't squash a legit error. */ orig_err = virSaveLastError(); - if (asyncJob != QEMU_ASYNC_JOB_NONE) { - if (qemuDomainObjBeginNestedJob(driver, vm, asyncJob) < 0) - goto cleanup; - } else if (priv->job.asyncJob != QEMU_ASYNC_JOB_NONE && - priv->job.asyncOwner == virThreadSelfID() && - priv->job.active != QEMU_JOB_ASYNC_NESTED) { - VIR_WARN("qemuProcessStop called without a nested job (async=%s)", - qemuDomainAsyncJobTypeToString(asyncJob)); - } - - if (!virDomainObjIsActive(vm)) { - VIR_DEBUG("VM '%s' not active", vm->def->name); - goto endjob; - } - vm->def->id = -1; if (virAtomicIntDecAndTest(&driver->nactive) && driver->inhibitCallback) @@ -6209,11 +6196,6 @@ void qemuProcessStop(virQEMUDriverPtr driver, virDomainObjRemoveTransientDef(vm); - endjob: - if (asyncJob != QEMU_ASYNC_JOB_NONE) - qemuDomainObjEndJob(driver, vm); - - cleanup: if (orig_err) { virSetError(orig_err); virFreeError(orig_err); -- 1.8.3.1

More precisely this patch reuse existing mon->lastError to mark monitor as closed. Why we need this state? For sure monitor have closed state and attempts to send commands in this state must fail otherwise we hang on waiting command response, AFAIK monitor is never used in this state because of locks structure: first check if domain is active (that is monitor is not closed), then lock monitor, then unlock domain - any code that closes monitor first lock domain so at this moment we have a lock on monitor and it is not closed. So this patch just makes monitor more incapsulated. Just to be sure. --- src/qemu/qemu_monitor.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index f402300..950b371 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -957,23 +957,24 @@ qemuMonitorClose(qemuMonitorPtr mon) VIR_FORCE_CLOSE(mon->fd); } + if (mon->lastError.code == VIR_ERR_OK) { + virErrorPtr err = virSaveLastError(); + + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("Qemu monitor was closed")); + virCopyLastError(&mon->lastError); + if (err) { + virSetError(err); + virFreeError(err); + } else { + virResetLastError(); + } + } + /* In case another thread is waiting for its monitor command to be * processed, we need to wake it up with appropriate error set. */ if (mon->msg) { - if (mon->lastError.code == VIR_ERR_OK) { - virErrorPtr err = virSaveLastError(); - - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("Qemu monitor was closed")); - virCopyLastError(&mon->lastError); - if (err) { - virSetError(err); - virFreeError(err); - } else { - virResetLastError(); - } - } mon->msg->finished = 1; virCondSignal(&mon->notify); } -- 1.8.3.1

As it is not used anymore. Most of the work is done by sed: sed -i.bak s/qemuDomainObjEnterMonitor(driver, vm)/qemuDomainObjEnterMonitor(vm)/ src/qemu/* sed -i.bak s/qemuDomainObjExitMonitor(driver, vm)/qemuDomainObjExitMonitor(vm)/ src/qemu/* Then drop driver parameter from the callers until gcc stops giving 'unused parameter' error. --- src/qemu/qemu_domain.c | 24 ++--- src/qemu/qemu_domain.h | 11 +- src/qemu/qemu_driver.c | 224 ++++++++++++++++++++--------------------- src/qemu/qemu_hotplug.c | 248 ++++++++++++++++++++++------------------------ src/qemu/qemu_hotplug.h | 12 +-- src/qemu/qemu_migration.c | 48 ++++----- src/qemu/qemu_process.c | 65 ++++++------ tests/qemuhotplugtest.c | 2 +- 8 files changed, 304 insertions(+), 330 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 40d46d6..0a51fe8 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3511,8 +3511,7 @@ qemuDomainObjExitMonitorInternal(virDomainObjPtr obj) priv->mon = NULL; } -void qemuDomainObjEnterMonitor(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, - virDomainObjPtr obj) +void qemuDomainObjEnterMonitor(virDomainObjPtr obj) { qemuDomainObjEnterMonitorInternal(obj); } @@ -3527,8 +3526,7 @@ void qemuDomainObjEnterMonitor(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, * and replaced by the persistent definition, so pointers stolen * from the live definition could no longer be valid. */ -int qemuDomainObjExitMonitor(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, - virDomainObjPtr obj) +int qemuDomainObjExitMonitor(virDomainObjPtr obj) { qemuDomainObjExitMonitorInternal(obj); if (!virDomainObjIsActive(obj)) { @@ -4435,10 +4433,10 @@ qemuDomainSnapshotDiscard(virQEMUDriverPtr driver, goto cleanup; } else { priv = vm->privateData; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); /* we continue on even in the face of error */ qemuMonitorDeleteSnapshot(priv->mon, snap->def->name); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); } } @@ -5207,7 +5205,7 @@ qemuDomainUpdateDeviceList(virQEMUDriverPtr driver, if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) return -1; rc = qemuMonitorGetDeviceAliases(priv->mon, &aliases); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) return -1; if (rc < 0) return -1; @@ -5236,7 +5234,7 @@ qemuDomainUpdateMemoryDeviceInfo(virQEMUDriverPtr driver, rc = qemuMonitorGetMemoryDeviceInfo(priv->mon, &meminfo); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) return -1; /* if qemu doesn't support the info request, just carry on */ @@ -5847,9 +5845,9 @@ qemuDomainUpdateCurrentMemorySize(virQEMUDriverPtr driver, goto endjob; } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorGetBalloonInfo(priv->mon, &balloon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; endjob: @@ -6194,7 +6192,7 @@ qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver, rc = qemuMonitorGetCPUInfo(qemuDomainGetMonitor(vm), &info, maxvcpus, hotplug); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; if (rc < 0) @@ -6308,7 +6306,7 @@ qemuDomainRefreshVcpuHalted(virQEMUDriverPtr driver, haltedmap = qemuMonitorGetCpuHalted(qemuDomainGetMonitor(vm), maxvcpus); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || !haltedmap) + if (qemuDomainObjExitMonitor(vm) < 0 || !haltedmap) goto cleanup; for (i = 0; i < maxvcpus; i++) { @@ -6585,7 +6583,7 @@ qemuDomainCheckMonitor(virQEMUDriverPtr driver, ret = qemuMonitorCheck(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) return -1; return ret; diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 7fd8cd6..12fef38 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -431,13 +431,10 @@ void qemuDomainObjReleaseAsyncJob(virDomainObjPtr obj); qemuMonitorPtr qemuDomainGetMonitor(virDomainObjPtr vm) ATTRIBUTE_NONNULL(1); -void qemuDomainObjEnterMonitor(virQEMUDriverPtr driver, - virDomainObjPtr obj) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -int qemuDomainObjExitMonitor(virQEMUDriverPtr driver, - virDomainObjPtr obj) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) - ATTRIBUTE_RETURN_CHECK; +void qemuDomainObjEnterMonitor(virDomainObjPtr obj) + ATTRIBUTE_NONNULL(1); +int qemuDomainObjExitMonitor(virDomainObjPtr obj) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK; int qemuDomainObjEnterMonitorAsync(virQEMUDriverPtr driver, virDomainObjPtr obj, qemuDomainAsyncJob asyncJob) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index fdfe912..4b39021 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2034,9 +2034,9 @@ static int qemuDomainShutdownFlags(virDomainPtr dom, unsigned int flags) } qemuDomainSetFakeReboot(driver, vm, isReboot); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorSystemPowerdown(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; } @@ -2136,9 +2136,9 @@ qemuDomainReboot(virDomainPtr dom, unsigned int flags) } #endif qemuDomainSetFakeReboot(driver, vm, isReboot); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorSystemPowerdown(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; } @@ -2178,9 +2178,9 @@ qemuDomainReset(virDomainPtr dom, unsigned int flags) } priv = vm->privateData; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorSystemReset(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; priv->fakeReboot = false; @@ -2396,9 +2396,9 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, if (def) { priv = vm->privateData; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); r = qemuMonitorSetBalloon(priv->mon, newmem); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || r < 0) + if (qemuDomainObjExitMonitor(vm) < 0 || r < 0) goto endjob; /* Lack of balloon support is a fatal error */ @@ -2478,9 +2478,9 @@ static int qemuDomainSetMemoryStatsPeriod(virDomainPtr dom, int period, goto endjob; } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); r = qemuMonitorSetMemoryStatsPeriod(priv->mon, def->memballoon, period); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto endjob; if (r < 0) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -2542,9 +2542,9 @@ static int qemuDomainInjectNMI(virDomainPtr domain, unsigned int flags) goto endjob; } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorInjectNMI(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; endjob: @@ -2605,9 +2605,9 @@ static int qemuDomainSendKey(virDomainPtr domain, goto endjob; } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorSendKey(priv->mon, holdtime, keycodes, nkeycodes); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; endjob: @@ -3571,7 +3571,7 @@ static int qemuDumpToFd(virQEMUDriverPtr driver, virDomainObjPtr vm, ret = qemuMonitorDumpToFd(priv->mon, fd, dumpformat); cleanup: - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); return ret; } @@ -3743,9 +3743,9 @@ qemuDomainCoreDumpWithFormat(virDomainPtr dom, virDomainObjIsActive(vm)) { if ((ret == 0) && (flags & VIR_DUMP_RESET)) { priv = vm->privateData; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorSystemReset(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; } @@ -3840,12 +3840,12 @@ qemuDomainScreenshot(virDomainPtr dom, virSecurityManagerSetSavedStateLabel(driver->securityManager, vm->def, tmp); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (qemuMonitorScreendump(priv->mon, tmp) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); goto endjob; } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto endjob; if (VIR_CLOSE(tmp_fd) < 0) { @@ -4346,9 +4346,9 @@ processNicRxFilterChangedEvent(virQEMUDriverPtr driver, VIR_DEBUG("process NIC_RX_FILTER_CHANGED event for network " "device %s in domain %s", def->info.alias, vm->def->name); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorQueryRxFilter(priv->mon, devAlias, &guestFilter); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; if (ret < 0) goto endjob; @@ -4630,7 +4630,7 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver, goto cleanup; } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (newhotplug) { rc = qemuMonitorAddDeviceArgs(qemuDomainGetMonitor(vm), vcpuprops); @@ -4639,7 +4639,7 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver, rc = qemuMonitorSetCPU(qemuDomainGetMonitor(vm), vcpu, true); } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; virDomainAuditVcpu(vm, oldvcpus, oldvcpus + nvcpus, "update", rc == 0); @@ -5592,9 +5592,9 @@ qemuDomainGetIOThreadsLive(virQEMUDriverPtr driver, goto endjob; } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); niothreads = qemuMonitorGetIOThreads(priv->mon, &iothreads); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto endjob; if (niothreads < 0) goto endjob; @@ -5878,8 +5878,7 @@ qemuDomainPinIOThread(virDomainPtr dom, } static int -qemuDomainHotplugAddIOThread(virQEMUDriverPtr driver, - virDomainObjPtr vm, +qemuDomainHotplugAddIOThread(virDomainObjPtr vm, unsigned int iothread_id) { qemuDomainObjPrivatePtr priv = vm->privateData; @@ -5903,7 +5902,7 @@ qemuDomainHotplugAddIOThread(virQEMUDriverPtr driver, if (virAsprintf(&alias, "iothread%u", iothread_id) < 0) return -1; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorAddObject(priv->mon, "iothread", alias, NULL); exp_niothreads++; @@ -5918,7 +5917,7 @@ qemuDomainHotplugAddIOThread(virQEMUDriverPtr driver, &new_iothreads)) < 0) goto exit_monitor; - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; if (new_niothreads != exp_niothreads) { @@ -5969,13 +5968,12 @@ qemuDomainHotplugAddIOThread(virQEMUDriverPtr driver, return ret; exit_monitor: - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); goto cleanup; } static int -qemuDomainHotplugDelIOThread(virQEMUDriverPtr driver, - virDomainObjPtr vm, +qemuDomainHotplugDelIOThread(virDomainObjPtr vm, unsigned int iothread_id) { qemuDomainObjPrivatePtr priv = vm->privateData; @@ -6006,7 +6004,7 @@ qemuDomainHotplugDelIOThread(virQEMUDriverPtr driver, if (virAsprintf(&alias, "iothread%u", iothread_id) < 0) return -1; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorDelObject(priv->mon, alias); exp_niothreads--; @@ -6017,7 +6015,7 @@ qemuDomainHotplugDelIOThread(virQEMUDriverPtr driver, &new_iothreads)) < 0) goto exit_monitor; - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; if (new_niothreads != exp_niothreads) { @@ -6050,7 +6048,7 @@ qemuDomainHotplugDelIOThread(virQEMUDriverPtr driver, return ret; exit_monitor: - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); goto cleanup; } @@ -6091,10 +6089,10 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver, } if (add) { - if (qemuDomainHotplugAddIOThread(driver, vm, iothread_id) < 0) + if (qemuDomainHotplugAddIOThread(vm, iothread_id) < 0) goto endjob; } else { - if (qemuDomainHotplugDelIOThread(driver, vm, iothread_id) < 0) + if (qemuDomainHotplugDelIOThread(vm, iothread_id) < 0) goto endjob; } @@ -7543,7 +7541,7 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, break; case VIR_DOMAIN_DEVICE_CONTROLLER: - ret = qemuDomainAttachControllerDevice(driver, vm, dev->data.controller); + ret = qemuDomainAttachControllerDevice(vm, dev->data.controller); if (!ret) { alias = dev->data.controller->info.alias; dev->data.controller = NULL; @@ -7612,8 +7610,7 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, break; case VIR_DOMAIN_DEVICE_SHMEM: - ret = qemuDomainAttachShmemDevice(driver, vm, - dev->data.shmem); + ret = qemuDomainAttachShmemDevice(vm, dev->data.shmem); if (!ret) { alias = dev->data.shmem->info.alias; dev->data.shmem = NULL; @@ -7820,7 +7817,7 @@ qemuDomainUpdateDeviceLive(virConnectPtr conn, ret = qemuDomainChangeGraphics(driver, vm, dev->data.graphics); break; case VIR_DOMAIN_DEVICE_NET: - ret = qemuDomainChangeNet(driver, vm, dev); + ret = qemuDomainChangeNet(vm, dev); break; case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: @@ -10718,12 +10715,12 @@ qemuDomainBlockResize(virDomainPtr dom, if (!(device = qemuAliasFromDisk(disk))) goto endjob; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (qemuMonitorBlockResize(priv->mon, device, size) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); goto endjob; } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto endjob; ret = 0; @@ -10775,8 +10772,7 @@ qemuDomainBlockStatsGatherTotals(void *payload, * Returns -1 on error; number of filled block statistics on success. */ static int -qemuDomainBlocksStatsGather(virQEMUDriverPtr driver, - virDomainObjPtr vm, +qemuDomainBlocksStatsGather(virDomainObjPtr vm, const char *path, qemuBlockStatsPtr *retstats) { @@ -10804,9 +10800,9 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driver, goto cleanup; } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); nstats = qemuMonitorGetAllBlockStatsInfo(priv->mon, &blockstats, false); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || nstats < 0) + if (qemuDomainObjExitMonitor(vm) < 0 || nstats < 0) goto cleanup; if (VIR_ALLOC(*retstats) < 0) @@ -10862,7 +10858,7 @@ qemuDomainBlockStats(virDomainPtr dom, goto endjob; } - if (qemuDomainBlocksStatsGather(driver, vm, path, &blockstats) < 0) + if (qemuDomainBlocksStatsGather(vm, path, &blockstats) < 0) goto endjob; stats->rd_req = blockstats->rd_req; @@ -10919,8 +10915,7 @@ qemuDomainBlockStatsFlags(virDomainPtr dom, goto endjob; } - if ((nstats = qemuDomainBlocksStatsGather(driver, vm, path, - &blockstats)) < 0) + if ((nstats = qemuDomainBlocksStatsGather(vm, path, &blockstats)) < 0) goto endjob; /* return count of supported stats */ @@ -11320,8 +11315,7 @@ qemuDomainGetInterfaceParameters(virDomainPtr dom, /* This functions assumes that job QEMU_JOB_QUERY is started by a caller */ static int -qemuDomainMemoryStatsInternal(virQEMUDriverPtr driver, - virDomainObjPtr vm, +qemuDomainMemoryStatsInternal(virDomainObjPtr vm, virDomainMemoryStatPtr stats, unsigned int nr_stats) @@ -11337,10 +11331,10 @@ qemuDomainMemoryStatsInternal(virQEMUDriverPtr driver, if (vm->def->memballoon && vm->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) { - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorGetMemoryStats(qemuDomainGetMonitor(vm), vm->def->memballoon, stats, nr_stats); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; if (ret < 0 || ret >= nr_stats) @@ -11382,7 +11376,7 @@ qemuDomainMemoryStats(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; - ret = qemuDomainMemoryStatsInternal(driver, vm, stats, nr_stats); + ret = qemuDomainMemoryStatsInternal(vm, stats, nr_stats); qemuDomainObjEndJob(driver, vm); @@ -11493,19 +11487,19 @@ qemuDomainMemoryPeek(virDomainPtr dom, virSecurityManagerSetSavedStateLabel(driver->securityManager, vm->def, tmp); priv = vm->privateData; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (flags == VIR_MEMORY_VIRTUAL) { if (qemuMonitorSaveVirtualMemory(priv->mon, offset, size, tmp) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); goto endjob; } } else { if (qemuMonitorSavePhysicalMemory(priv->mon, offset, size, tmp) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); goto endjob; } } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto endjob; /* Read the memory file into buffer. */ @@ -11734,14 +11728,14 @@ qemuDomainGetBlockInfo(virDomainPtr dom, goto endjob; } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorGetAllBlockStatsInfo(qemuDomainGetMonitor(vm), &stats, false); if (rc >= 0) rc = qemuMonitorBlockStatsUpdateCapacity(qemuDomainGetMonitor(vm), stats, false); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + if (qemuDomainObjExitMonitor(vm) < 0 || rc < 0) goto endjob; if (!(entry = virHashLookup(stats, alias))) { @@ -13142,9 +13136,9 @@ static int qemuDomainAbortJob(virDomainPtr dom) VIR_DEBUG("Cancelling job at client request"); qemuDomainObjAbortAsyncJob(vm); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorMigrateCancel(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; endjob: @@ -13186,9 +13180,9 @@ qemuDomainMigrateSetMaxDowntime(virDomainPtr dom, priv = vm->privateData; VIR_DEBUG("Setting migration downtime to %llums", downtime); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorSetMigrationDowntime(priv->mon, downtime); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; endjob: @@ -13228,7 +13222,7 @@ qemuDomainMigrateGetCompressionCache(virDomainPtr dom, priv = vm->privateData; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorGetMigrationCapability( priv->mon, @@ -13242,7 +13236,7 @@ qemuDomainMigrateGetCompressionCache(virDomainPtr dom, ret = qemuMonitorGetMigrationCacheSize(priv->mon, cacheSize); } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; endjob: @@ -13282,7 +13276,7 @@ qemuDomainMigrateSetCompressionCache(virDomainPtr dom, priv = vm->privateData; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorGetMigrationCapability( priv->mon, @@ -13297,7 +13291,7 @@ qemuDomainMigrateSetCompressionCache(virDomainPtr dom, ret = qemuMonitorSetMigrationCacheSize(priv->mon, cacheSize); } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; endjob: @@ -13346,9 +13340,9 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom, } VIR_DEBUG("Setting migration bandwidth to %luMbs", bandwidth); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorSetMigrationSpeed(priv->mon, bandwidth); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; if (ret == 0) @@ -13437,9 +13431,9 @@ qemuDomainMigrateStartPostCopy(virDomainPtr dom, } VIR_DEBUG("Starting post-copy"); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorMigrateStartPostCopy(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; endjob: @@ -13665,7 +13659,7 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr conn, } ret = qemuMonitorCreateSnapshot(priv->mon, snap->def->name); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; if (ret < 0) goto cleanup; @@ -14187,7 +14181,7 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver, ret = rc = qemuMonitorDiskSnapshot(priv->mon, actions, device, source, formatStr, reuse); if (!actions) { - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; } @@ -14325,7 +14319,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver, if (ret == 0 && do_transaction) { if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) { ret = qemuMonitorTransaction(priv->mon, actions); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; } else { /* failed to enter monitor, clean stuff up and quit */ @@ -15403,7 +15397,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, QEMU_ASYNC_JOB_START) < 0) goto endjob; rc = qemuMonitorLoadSnapshot(priv->mon, snap->def->name); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto endjob; if (rc < 0) { /* XXX resume domain if it was running before the @@ -15773,9 +15767,9 @@ static int qemuDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd, hmp = !!(flags & VIR_DOMAIN_QEMU_MONITOR_COMMAND_HMP); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorArbitraryCommand(priv->mon, cmd, result, hmp); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; endjob: @@ -16061,9 +16055,9 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver, /* Probe the status, if needed. */ if (!disk->mirrorState) { - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorGetBlockJobInfo(priv->mon, disk->info.alias, &info); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; if (rc < 0) goto cleanup; @@ -16122,9 +16116,9 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver, * that pivot failed, we need to reflect that failure into the * overall return value. */ disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_PIVOT; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorDrivePivot(priv->mon, device); - if (qemuDomainObjExitMonitor(driver, vm) < 0) { + if (qemuDomainObjExitMonitor(vm) < 0) { ret = -1; goto cleanup; } @@ -16248,14 +16242,14 @@ qemuDomainBlockPullCommon(virQEMUDriverPtr driver, speed <<= 20; } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (baseSource) basePath = qemuMonitorDiskNameLookup(priv->mon, device, disk->src, baseSource); if (!baseSource || basePath) ret = qemuMonitorBlockStream(priv->mon, device, basePath, backingPath, speed, modern); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; if (ret < 0) @@ -16338,9 +16332,9 @@ qemuDomainBlockJobAbort(virDomainPtr dom, save = true; } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorBlockJobCancel(qemuDomainGetMonitor(vm), device, modern); - if (qemuDomainObjExitMonitor(driver, vm) < 0) { + if (qemuDomainObjExitMonitor(vm) < 0) { ret = -1; goto endjob; } @@ -16479,10 +16473,10 @@ qemuDomainGetBlockJobInfo(virDomainPtr dom, goto endjob; } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorGetBlockJobInfo(qemuDomainGetMonitor(vm), disk->info.alias, &rawInfo); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; if (ret <= 0) goto endjob; @@ -16567,12 +16561,12 @@ qemuDomainBlockJobSetSpeed(virDomainPtr dom, if (!(device = qemuAliasFromDisk(disk))) goto endjob; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorBlockJobSetSpeed(qemuDomainGetMonitor(vm), device, speed, modern); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; endjob: @@ -16745,11 +16739,11 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, } /* Actually start the mirroring */ - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorDriveMirror(priv->mon, device, mirror->path, format, bandwidth, granularity, buf_size, flags); virDomainAuditDisk(vm, NULL, mirror, "mirror", ret >= 0); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; if (ret < 0) { qemuDomainDiskChainElementRevoke(driver, vm, mirror); @@ -17138,7 +17132,7 @@ qemuDomainBlockCommit(virDomainPtr dom, disk->mirror = mirror; disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT; } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); basePath = qemuMonitorDiskNameLookup(priv->mon, device, disk->src, baseSource); topPath = qemuMonitorDiskNameLookup(priv->mon, device, disk->src, @@ -17147,7 +17141,7 @@ qemuDomainBlockCommit(virDomainPtr dom, ret = qemuMonitorBlockCommit(priv->mon, device, topPath, basePath, backingPath, speed); - if (qemuDomainObjExitMonitor(driver, vm) < 0) { + if (qemuDomainObjExitMonitor(vm) < 0) { ret = -1; goto endjob; } @@ -17243,10 +17237,10 @@ qemuDomainOpenGraphics(virDomainPtr dom, fd) < 0) goto endjob; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorOpenGraphics(priv->mon, protocol, fd, "graphicsfd", (flags & VIR_DOMAIN_OPEN_GRAPHICS_SKIPAUTH) != 0); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; endjob: @@ -17315,10 +17309,10 @@ qemuDomainOpenGraphicsFD(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorOpenGraphics(priv->mon, protocol, pair[1], "graphicsfd", (flags & VIR_DOMAIN_OPEN_GRAPHICS_SKIPAUTH)); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; qemuDomainObjEndJob(driver, vm); if (ret < 0) @@ -17650,11 +17644,11 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, /* NB: Let's let QEMU decide how to handle issues with _length * via the JSON error code from the block_set_io_throttle call */ - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorSetBlockIoThrottle(priv->mon, device, &info, supportMaxOptions, supportMaxLengthOptions); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; if (ret < 0) goto endjob; @@ -17775,9 +17769,9 @@ qemuDomainGetBlockIoTune(virDomainPtr dom, if (!(device = qemuAliasFromDisk(disk))) goto endjob; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorGetBlockIoThrottle(priv->mon, device, &reply); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto endjob; if (ret < 0) goto endjob; @@ -17878,9 +17872,9 @@ qemuDomainGetDiskErrors(virDomainPtr dom, goto endjob; } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); table = qemuMonitorGetBlockInfo(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto endjob; if (!table) goto endjob; @@ -18156,9 +18150,9 @@ qemuDomainPMWakeup(virDomainPtr dom, goto endjob; } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorSystemWakeup(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; endjob: @@ -18587,9 +18581,9 @@ qemuDomainSetTime(virDomainPtr dom, /* Don't try to call rtc-reset-reinjection if it's not available */ if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_RTC_RESET_REINJECTION)) { - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); rv = qemuMonitorRTCResetReinjection(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto endjob; if (rv < 0) @@ -18898,7 +18892,7 @@ qemuDomainGetStatsCpu(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, } static int -qemuDomainGetStatsBalloon(virQEMUDriverPtr driver, +qemuDomainGetStatsBalloon(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, virDomainObjPtr dom, virDomainStatsRecordPtr record, int *maxparams, @@ -18936,7 +18930,7 @@ qemuDomainGetStatsBalloon(virQEMUDriverPtr driver, if (!HAVE_JOB(privflags) || !virDomainObjIsActive(dom)) return 0; - nr_stats = qemuDomainMemoryStatsInternal(driver, dom, stats, + nr_stats = qemuDomainMemoryStatsInternal(dom, stats, VIR_DOMAIN_MEMORY_STAT_NR); if (nr_stats < 0) return 0; @@ -19342,13 +19336,13 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver, bool visitBacking = !!(privflags & QEMU_DOMAIN_STATS_BACKING); if (HAVE_JOB(privflags) && virDomainObjIsActive(dom)) { - qemuDomainObjEnterMonitor(driver, dom); + qemuDomainObjEnterMonitor(dom); rc = qemuMonitorGetAllBlockStatsInfo(priv->mon, &stats, visitBacking); if (rc >= 0) ignore_value(qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats, visitBacking)); - if (qemuDomainObjExitMonitor(driver, dom) < 0) + if (qemuDomainObjExitMonitor(dom) < 0) goto cleanup; /* failure to retrieve stats is fine at this point */ diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 5038ce1..ed08313 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -146,8 +146,7 @@ qemuDomainPrepareDisk(virQEMUDriverPtr driver, static int -qemuHotplugWaitForTrayEject(virQEMUDriverPtr driver, - virDomainObjPtr vm, +qemuHotplugWaitForTrayEject(virDomainObjPtr vm, virDomainDiskDefPtr disk, const char *driveAlias) { @@ -173,9 +172,9 @@ qemuHotplugWaitForTrayEject(virQEMUDriverPtr driver, } /* re-issue ejection command to pop out the media */ - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorEjectMedia(qemuDomainGetMonitor(vm), driveAlias, false); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + if (qemuDomainObjExitMonitor(vm) < 0 || rc < 0) return -1; return 0; @@ -231,15 +230,15 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver, if (!(driveAlias = qemuAliasFromDisk(disk))) goto error; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorEjectMedia(priv->mon, driveAlias, force); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; /* If the tray is present and tray change event is supported wait for it to open. */ if (!force && diskPriv->tray && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_TRAY_MOVED)) { - rc = qemuHotplugWaitForTrayEject(driver, vm, disk, driveAlias); + rc = qemuHotplugWaitForTrayEject(vm, disk, driveAlias); if (rc < 0) goto error; } else { @@ -260,12 +259,12 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver, format = virStorageFileFormatTypeToString(disk->src->format); } } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorChangeMedia(priv->mon, driveAlias, sourcestr, format); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; } @@ -378,7 +377,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn, if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0) goto error; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (secobjProps) { rv = qemuMonitorAddObject(priv->mon, "secret", secinfo->s.aes.alias, @@ -405,7 +404,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn, if (qemuMonitorAddDevice(priv->mon, devstr) < 0) goto exit_monitor; - if (qemuDomainObjExitMonitor(driver, vm) < 0) { + if (qemuDomainObjExitMonitor(vm) < 0) { releaseaddr = false; goto error; } @@ -441,7 +440,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn, virFreeError(orig_err); } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) releaseaddr = false; virDomainAuditDisk(vm, NULL, disk->src, "attach", false); @@ -455,8 +454,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn, } -int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, - virDomainObjPtr vm, +int qemuDomainAttachControllerDevice(virDomainObjPtr vm, virDomainControllerDefPtr controller) { int ret = -1; @@ -523,9 +521,9 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, if (VIR_REALLOC_N(vm->def->controllers, vm->def->ncontrollers+1) < 0) goto cleanup; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorAddDevice(priv->mon, devstr); - if (qemuDomainObjExitMonitor(driver, vm) < 0) { + if (qemuDomainObjExitMonitor(vm) < 0) { releaseaddr = false; ret = -1; goto cleanup; @@ -547,8 +545,7 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, } static virDomainControllerDefPtr -qemuDomainFindOrCreateSCSIDiskController(virQEMUDriverPtr driver, - virDomainObjPtr vm, +qemuDomainFindOrCreateSCSIDiskController(virDomainObjPtr vm, int controller) { size_t i; @@ -573,8 +570,7 @@ qemuDomainFindOrCreateSCSIDiskController(virQEMUDriverPtr driver, cont->model = -1; VIR_INFO("No SCSI controller present, hotplugging one"); - if (qemuDomainAttachControllerDevice(driver, - vm, cont) < 0) { + if (qemuDomainAttachControllerDevice(vm, cont) < 0) { VIR_FREE(cont); return NULL; } @@ -634,7 +630,7 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn, * exist; there must not be any missing index in between. */ for (i = 0; i <= disk->info.addr.drive.controller; i++) { - if (!qemuDomainFindOrCreateSCSIDiskController(driver, vm, i)) + if (!qemuDomainFindOrCreateSCSIDiskController(vm, i)) goto error; } @@ -667,7 +663,7 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn, if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0) goto error; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (secobjProps) { rv = qemuMonitorAddObject(priv->mon, "secret", secinfo->s.aes.alias, @@ -694,7 +690,7 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn, if (qemuMonitorAddDevice(priv->mon, devstr) < 0) goto exit_monitor; - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto error; virDomainAuditDisk(vm, NULL, disk->src, "attach", true); @@ -727,7 +723,7 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn, virFreeError(orig_err); } - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); virDomainAuditDisk(vm, NULL, disk->src, "attach", false); @@ -784,7 +780,7 @@ qemuDomainAttachUSBMassStorageDevice(virQEMUDriverPtr driver, if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0) goto error; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (qemuMonitorAddDrive(priv->mon, drivestr) < 0) goto exit_monitor; @@ -793,7 +789,7 @@ qemuDomainAttachUSBMassStorageDevice(virQEMUDriverPtr driver, if (qemuMonitorAddDevice(priv->mon, devstr) < 0) goto exit_monitor; - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto error; virDomainAuditDisk(vm, NULL, disk->src, "attach", true); @@ -821,7 +817,7 @@ qemuDomainAttachUSBMassStorageDevice(virQEMUDriverPtr driver, virFreeError(orig_err); } - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); virDomainAuditDisk(vm, NULL, disk->src, "attach", false); error: @@ -1183,11 +1179,11 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, goto cleanup; } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER) { if (qemuMonitorAttachCharDev(priv->mon, charDevAlias, net->data.vhostuser) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); virDomainAuditNet(vm, NULL, net, "attach", false); goto cleanup; } @@ -1198,7 +1194,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, if (qemuMonitorAddNetdev(priv->mon, netstr, tapfd, tapfdName, tapfdSize, vhostfd, vhostfdName, vhostfdSize) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); virDomainAuditNet(vm, NULL, net, "attach", false); goto try_remove; } @@ -1207,14 +1203,14 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, if (qemuMonitorAddHostNetwork(priv->mon, netstr, tapfd, tapfdName, tapfdSize, vhostfd, vhostfdName, vhostfdSize) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); virDomainAuditNet(vm, NULL, net, "attach", false); goto try_remove; } hostPlugged = true; } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; for (i = 0; i < tapfdSize; i++) @@ -1226,13 +1222,13 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, vhostfdSize, priv->qemuCaps))) goto try_remove; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (qemuMonitorAddDevice(priv->mon, nicstr) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); virDomainAuditNet(vm, NULL, net, "attach", false); goto try_remove; } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; /* set link state */ @@ -1241,11 +1237,11 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("device alias not found: cannot set link state to down")); } else { - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) { if (qemuMonitorSetLink(priv->mon, net->info.alias, VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); virDomainAuditNet(vm, NULL, net, "attach", false); goto try_remove; } @@ -1254,7 +1250,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, _("setting of link state not supported: Link is up")); } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; } /* link set to down */ @@ -1331,7 +1327,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) { char *netdev_name; if (virAsprintf(&netdev_name, "host%s", net->info.alias) >= 0) { - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (charDevPlugged && qemuMonitorDetachCharDev(priv->mon, charDevAlias) < 0) VIR_WARN("Failed to remove associated chardev %s", charDevAlias); @@ -1339,7 +1335,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, qemuMonitorRemoveNetdev(priv->mon, netdev_name) < 0) VIR_WARN("Failed to remove network backend for netdev %s", netdev_name); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); VIR_FREE(netdev_name); } } else { @@ -1348,12 +1344,12 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, } else { char *hostnet_name; if (virAsprintf(&hostnet_name, "host%s", net->info.alias) >= 0) { - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (hostPlugged && qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0) VIR_WARN("Failed to remove network backend for vlan %d, net %s", vlan, hostnet_name); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); VIR_FREE(hostnet_name); } } @@ -1464,10 +1460,10 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, configfd_name, priv->qemuCaps))) goto error; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorAddDeviceWithFd(priv->mon, devstr, configfd, configfd_name); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto error; virDomainAuditHostdev(vm, hostdev, "attach", ret == 0); @@ -1593,7 +1589,7 @@ int qemuDomainAttachRedirdevDevice(virConnectPtr conn, &secProps, &secAlias) < 0) goto cleanup; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (secAlias) { rc = qemuMonitorAddObject(priv->mon, "secret", @@ -1622,7 +1618,7 @@ int qemuDomainAttachRedirdevDevice(virConnectPtr conn, if (qemuMonitorAddDevice(priv->mon, devstr) < 0) goto exit_monitor; - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto audit; def->redirdevs[def->nredirdevs++] = redirdev; @@ -1652,7 +1648,7 @@ int qemuDomainAttachRedirdevDevice(virConnectPtr conn, virSetError(orig_err); virFreeError(orig_err); } - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); goto audit; } @@ -1874,7 +1870,7 @@ int qemuDomainAttachChrDevice(virConnectPtr conn, &secProps, &secAlias) < 0) goto cleanup; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (secAlias) { rc = qemuMonitorAddObject(priv->mon, "secret", secAlias, secProps); @@ -1900,7 +1896,7 @@ int qemuDomainAttachChrDevice(virConnectPtr conn, if (qemuMonitorAddDevice(priv->mon, devstr) < 0) goto exit_monitor; - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto audit; qemuDomainChrInsertPreAlloced(vmdef, chr); @@ -1939,7 +1935,7 @@ int qemuDomainAttachChrDevice(virConnectPtr conn, virFreeError(orig_err); } - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); goto audit; } @@ -2037,7 +2033,7 @@ qemuDomainAttachRNGDevice(virConnectPtr conn, goto cleanup; } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (secAlias) { rv = qemuMonitorAddObject(priv->mon, "secret", @@ -2072,7 +2068,7 @@ qemuDomainAttachRNGDevice(virConnectPtr conn, if (qemuMonitorAddDevice(priv->mon, devstr) < 0) goto exit_monitor; - if (qemuDomainObjExitMonitor(driver, vm) < 0) { + if (qemuDomainObjExitMonitor(vm) < 0) { releaseaddr = false; goto cleanup; } @@ -2118,7 +2114,7 @@ qemuDomainAttachRNGDevice(virConnectPtr conn, virFreeError(orig_err); } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) releaseaddr = false; goto audit; } @@ -2189,7 +2185,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver, goto removedef; } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); rv = qemuMonitorAddObject(priv->mon, backendType, objalias, props); props = NULL; /* qemuMonitorAddObject consumes */ if (rv < 0) @@ -2199,7 +2195,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver, if (qemuMonitorAddDevice(priv->mon, devstr) < 0) goto exit_monitor; - if (qemuDomainObjExitMonitor(driver, vm) < 0) { + if (qemuDomainObjExitMonitor(vm) < 0) { /* we shouldn't touch mem now, as the def might be freed */ mem = NULL; goto audit; @@ -2237,7 +2233,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver, virSetError(orig_err); virFreeError(orig_err); } - if (qemuDomainObjExitMonitor(driver, vm) < 0) { + if (qemuDomainObjExitMonitor(vm) < 0) { mem = NULL; goto audit; } @@ -2299,9 +2295,9 @@ qemuDomainAttachHostUSBDevice(virQEMUDriverPtr driver, if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1) < 0) goto cleanup; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorAddDevice(priv->mon, devstr); - if (qemuDomainObjExitMonitor(driver, vm) < 0) { + if (qemuDomainObjExitMonitor(vm) < 0) { ret = -1; goto cleanup; } @@ -2361,7 +2357,7 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn, * exist; there must not be any missing index in between. */ for (i = 0; i <= hostdev->info->addr.drive.controller; i++) { - if (!qemuDomainFindOrCreateSCSIDiskController(driver, vm, i)) + if (!qemuDomainFindOrCreateSCSIDiskController(vm, i)) return -1; } @@ -2410,7 +2406,7 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn, if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0) goto cleanup; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (qemuMonitorAddDrive(priv->mon, drvstr) < 0) goto exit_monitor; @@ -2419,7 +2415,7 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn, if (qemuMonitorAddDevice(priv->mon, devstr) < 0) goto exit_monitor; - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; virDomainAuditHostdev(vm, hostdev, "attach", true); @@ -2456,7 +2452,7 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn, virFreeError(orig_err); } - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); virDomainAuditHostdev(vm, hostdev, "attach", false); goto cleanup; @@ -2510,8 +2506,7 @@ qemuDomainAttachHostDevice(virConnectPtr conn, int -qemuDomainAttachShmemDevice(virQEMUDriverPtr driver, - virDomainObjPtr vm, +qemuDomainAttachShmemDevice(virDomainObjPtr vm, virDomainShmemDefPtr shmem) { int ret = -1; @@ -2567,7 +2562,7 @@ qemuDomainAttachShmemDevice(virQEMUDriverPtr driver, goto cleanup; } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (shmem->server.enabled) { if (qemuMonitorAttachCharDev(priv->mon, charAlias, @@ -2587,7 +2582,7 @@ qemuDomainAttachShmemDevice(virQEMUDriverPtr driver, if (qemuMonitorAddDevice(priv->mon, shmstr) < 0) goto exit_monitor; - if (qemuDomainObjExitMonitor(driver, vm) < 0) { + if (qemuDomainObjExitMonitor(vm) < 0) { release_address = false; goto cleanup; } @@ -2627,7 +2622,7 @@ qemuDomainAttachShmemDevice(virQEMUDriverPtr driver, virFreeError(orig_err); } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) release_address = false; goto audit; @@ -2725,8 +2720,7 @@ qemuDomainChangeNetFilter(virDomainObjPtr vm, return 0; } -int qemuDomainChangeNetLinkState(virQEMUDriverPtr driver, - virDomainObjPtr vm, +int qemuDomainChangeNetLinkState(virDomainObjPtr vm, virDomainNetDefPtr dev, int linkstate) { @@ -2741,7 +2735,7 @@ int qemuDomainChangeNetLinkState(virQEMUDriverPtr driver, VIR_DEBUG("dev: %s, state: %d", dev->info.alias, linkstate); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorSetLink(priv->mon, dev->info.alias, linkstate); if (ret < 0) @@ -2751,15 +2745,14 @@ int qemuDomainChangeNetLinkState(virQEMUDriverPtr driver, dev->linkstate = linkstate; cleanup: - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) return -1; return ret; } int -qemuDomainChangeNet(virQEMUDriverPtr driver, - virDomainObjPtr vm, +qemuDomainChangeNet(virDomainObjPtr vm, virDomainDeviceDefPtr dev) { virDomainNetDefPtr newdev = dev->data.net; @@ -3096,7 +3089,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, } if (needLinkStateChange && - qemuDomainChangeNetLinkState(driver, vm, olddev, newdev->linkstate) < 0) { + qemuDomainChangeNetLinkState(vm, olddev, newdev->linkstate) < 0) { goto cleanup; } @@ -3433,7 +3426,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, } } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); qemuMonitorDriveDel(priv->mon, drivestr); VIR_FREE(drivestr); @@ -3448,7 +3441,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, ignore_value(qemuMonitorDelObject(priv->mon, encAlias)); VIR_FREE(encAlias); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) return -1; virDomainAuditDisk(vm, disk->src, NULL, "detach", true); @@ -3535,9 +3528,9 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver, if (virAsprintf(&backendAlias, "mem%s", mem->info.alias) < 0) return -1; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorDelObject(priv->mon, backendAlias); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) rc = -1; VIR_FREE(backendAlias); @@ -3613,9 +3606,9 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver, if (!(drivealias = qemuAliasFromHostdev(hostdev))) goto cleanup; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); qemuMonitorDriveDel(priv->mon, drivealias); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; } @@ -3714,10 +3707,10 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver, goto cleanup; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) { if (qemuMonitorRemoveNetdev(priv->mon, hostnet_name) < 0) { - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; virDomainAuditNet(vm, net, NULL, "detach", false); goto cleanup; @@ -3730,7 +3723,7 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver, virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("unable to determine original VLAN")); } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; virDomainAuditNet(vm, net, NULL, "detach", false); goto cleanup; @@ -3747,7 +3740,7 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver, } } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; virDomainAuditNet(vm, net, NULL, "detach", true); @@ -3838,7 +3831,7 @@ qemuDomainRemoveChrDevice(virQEMUDriverPtr driver, goto cleanup; } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorDetachCharDev(priv->mon, charAlias); if (rc == 0) { @@ -3848,7 +3841,7 @@ qemuDomainRemoveChrDevice(virQEMUDriverPtr driver, ignore_value(qemuMonitorDelObject(priv->mon, secAlias)); } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; virDomainAuditChardev(vm, chr, NULL, "detach", rc == 0); @@ -3914,7 +3907,7 @@ qemuDomainRemoveRNGDevice(virQEMUDriverPtr driver, goto cleanup; } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorDelObject(priv->mon, objAlias); @@ -3926,7 +3919,7 @@ qemuDomainRemoveRNGDevice(virQEMUDriverPtr driver, ignore_value(qemuMonitorDelObject(priv->mon, secAlias)); } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; virDomainAuditRNG(vm, rng, NULL, "detach", rc == 0); @@ -3980,14 +3973,14 @@ qemuDomainRemoveShmemDevice(virQEMUDriverPtr driver, return -1; } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (shmem->server.enabled) rc = qemuMonitorDetachCharDev(priv->mon, charAlias); else rc = qemuMonitorDelObject(priv->mon, memAlias); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; virDomainAuditShmem(vm, shmem, "detach", rc == 0); @@ -4211,14 +4204,14 @@ qemuDomainDetachVirtioDiskDevice(virQEMUDriverPtr driver, qemuDomainMarkDeviceForRemoval(vm, &detach->info); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (qemuMonitorDelDevice(priv->mon, detach->info.alias) < 0) { - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; virDomainAuditDisk(vm, detach->src, NULL, "detach", false); goto cleanup; } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1) @@ -4242,14 +4235,14 @@ qemuDomainDetachDiskDevice(virQEMUDriverPtr driver, qemuDomainMarkDeviceForRemoval(vm, &detach->info); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (qemuMonitorDelDevice(priv->mon, detach->info.alias) < 0) { - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; virDomainAuditDisk(vm, detach->src, NULL, "detach", false); goto cleanup; } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1) @@ -4419,12 +4412,12 @@ int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver, qemuDomainMarkDeviceForRemoval(vm, &detach->info); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (qemuMonitorDelDevice(priv->mon, detach->info.alias)) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); goto cleanup; } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1) @@ -4436,8 +4429,7 @@ int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver, } static int -qemuDomainDetachHostPCIDevice(virQEMUDriverPtr driver, - virDomainObjPtr vm, +qemuDomainDetachHostPCIDevice(virDomainObjPtr vm, virDomainHostdevDefPtr detach) { qemuDomainObjPrivatePtr priv = vm->privateData; @@ -4461,17 +4453,16 @@ qemuDomainDetachHostPCIDevice(virQEMUDriverPtr driver, qemuDomainMarkDeviceForRemoval(vm, detach->info); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorDelDevice(priv->mon, detach->info->alias); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; return ret; } static int -qemuDomainDetachHostUSBDevice(virQEMUDriverPtr driver, - virDomainObjPtr vm, +qemuDomainDetachHostUSBDevice(virDomainObjPtr vm, virDomainHostdevDefPtr detach) { qemuDomainObjPrivatePtr priv = vm->privateData; @@ -4485,17 +4476,16 @@ qemuDomainDetachHostUSBDevice(virQEMUDriverPtr driver, qemuDomainMarkDeviceForRemoval(vm, detach->info); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorDelDevice(priv->mon, detach->info->alias); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; return ret; } static int -qemuDomainDetachHostSCSIDevice(virQEMUDriverPtr driver, - virDomainObjPtr vm, +qemuDomainDetachHostSCSIDevice(virDomainObjPtr vm, virDomainHostdevDefPtr detach) { qemuDomainObjPrivatePtr priv = vm->privateData; @@ -4509,10 +4499,10 @@ qemuDomainDetachHostSCSIDevice(virQEMUDriverPtr driver, qemuDomainMarkDeviceForRemoval(vm, detach->info); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorDelDevice(priv->mon, detach->info->alias); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) return -1; return ret; @@ -4532,13 +4522,13 @@ qemuDomainDetachThisHostDevice(virQEMUDriverPtr driver, switch (detach->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: - ret = qemuDomainDetachHostPCIDevice(driver, vm, detach); + ret = qemuDomainDetachHostPCIDevice(vm, detach); break; case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: - ret = qemuDomainDetachHostUSBDevice(driver, vm, detach); + ret = qemuDomainDetachHostUSBDevice(vm, detach); break; case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: - ret = qemuDomainDetachHostSCSIDevice(driver, vm, detach); + ret = qemuDomainDetachHostSCSIDevice(vm, detach); break; default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -4668,11 +4658,11 @@ qemuDomainDetachShmemDevice(virQEMUDriverPtr driver, } qemuDomainMarkDeviceForRemoval(vm, &shmem->info); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorDelDevice(priv->mon, shmem->info.alias); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; if (ret == 0) { @@ -4750,14 +4740,14 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver, qemuDomainMarkDeviceForRemoval(vm, &detach->info); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (qemuMonitorDelDevice(priv->mon, detach->info.alias) < 0) { - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; virDomainAuditNet(vm, detach, NULL, "detach", false); goto cleanup; } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1) @@ -4835,7 +4825,7 @@ qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver, } end_job: - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; cleanup: VIR_FREE(validTo); @@ -4915,12 +4905,12 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver, qemuDomainMarkDeviceForRemoval(vm, &tmpChr->info); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (devstr && qemuMonitorDelDevice(priv->mon, tmpChr->info.alias) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); goto cleanup; } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1) { @@ -4962,9 +4952,9 @@ qemuDomainDetachRNGDevice(virQEMUDriverPtr driver, qemuDomainMarkDeviceForRemoval(vm, &tmpRNG->info); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorDelDevice(priv->mon, tmpRNG->info.alias); - if (qemuDomainObjExitMonitor(driver, vm) || rc < 0) + if (qemuDomainObjExitMonitor(vm) || rc < 0) goto cleanup; if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1) @@ -5005,9 +4995,9 @@ qemuDomainDetachMemoryDevice(virQEMUDriverPtr driver, qemuDomainMarkDeviceForRemoval(vm, &mem->info); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorDelDevice(priv->mon, mem->info.alias); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + if (qemuDomainObjExitMonitor(vm) < 0 || rc < 0) goto cleanup; if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1) @@ -5103,11 +5093,11 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver, qemuDomainMarkDeviceAliasForRemoval(vm, vcpupriv->alias); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorDelDevice(qemuDomainGetMonitor(vm), vcpupriv->alias); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) return -1; if (rc < 0) { diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index 85ec724..7f0bca7 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -33,8 +33,7 @@ int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver, virDomainDiskDefPtr disk, virStorageSourcePtr newsrc, bool force); -int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, - virDomainObjPtr vm, +int qemuDomainAttachControllerDevice(virDomainObjPtr vm, virDomainControllerDefPtr controller); int qemuDomainAttachDeviceDiskLive(virConnectPtr conn, virQEMUDriverPtr driver, @@ -51,8 +50,7 @@ int qemuDomainAttachHostDevice(virConnectPtr conn, virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainHostdevDefPtr hostdev); -int qemuDomainAttachShmemDevice(virQEMUDriverPtr driver, - virDomainObjPtr vm, +int qemuDomainAttachShmemDevice(virDomainObjPtr vm, virDomainShmemDefPtr shmem); int qemuDomainFindGraphicsIndex(virDomainDefPtr def, virDomainGraphicsDefPtr dev); @@ -71,11 +69,9 @@ int qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver, virDomainGraphicsAuthDefPtr auth, const char *defaultPasswd, int asyncJob); -int qemuDomainChangeNet(virQEMUDriverPtr driver, - virDomainObjPtr vm, +int qemuDomainChangeNet(virDomainObjPtr vm, virDomainDeviceDefPtr dev); -int qemuDomainChangeNetLinkState(virQEMUDriverPtr driver, - virDomainObjPtr vm, +int qemuDomainChangeNetLinkState(virDomainObjPtr vm, virDomainNetDefPtr dev, int linkstate); int qemuDomainDetachDeviceDiskLive(virQEMUDriverPtr driver, diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index b029319..36ddfa0 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -615,7 +615,7 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig, priv->job.asyncJob) < 0) goto cleanup; rc = qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats, false); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; if (rc < 0) goto cleanup; @@ -1791,7 +1791,7 @@ qemuMigrationStartNBDServer(virQEMUDriverPtr driver, if (qemuMonitorNBDServerAdd(priv->mon, diskAlias, true) < 0) goto exit_monitor; - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; } @@ -1805,7 +1805,7 @@ qemuMigrationStartNBDServer(virQEMUDriverPtr driver, return ret; exit_monitor: - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); goto cleanup; } @@ -1826,7 +1826,7 @@ qemuMigrationStopNBDServer(virQEMUDriverPtr driver, if (qemuMonitorNBDServerStop(priv->mon) < 0) VIR_WARN("Unable to stop NBD server"); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) return -1; virPortAllocatorRelease(driver->migrationPorts, priv->nbdPort); @@ -1996,7 +1996,7 @@ qemuMigrationCancelOneDriveMirror(virQEMUDriverPtr driver, rv = qemuMonitorBlockJobCancel(priv->mon, diskAlias, true); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rv < 0) + if (qemuDomainObjExitMonitor(vm) < 0 || rv < 0) goto cleanup; ret = 0; @@ -2179,7 +2179,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver, VIR_FREE(diskAlias); VIR_FREE(nbd_dest); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || mon_ret < 0) { + if (qemuDomainObjExitMonitor(vm) < 0 || mon_ret < 0) { qemuBlockJobSyncEnd(driver, vm, disk); goto cleanup; } @@ -2508,7 +2508,7 @@ qemuMigrationSetOption(virQEMUDriverPtr driver, ret = qemuMonitorSetMigrationCapability(priv->mon, capability, state); cleanup: - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; return ret; } @@ -2595,7 +2595,7 @@ qemuMigrationFetchJobStatus(virQEMUDriverPtr driver, memset(&jobInfo->stats, 0, sizeof(jobInfo->stats)); rv = qemuMonitorGetMigrationStats(priv->mon, &jobInfo->stats); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rv < 0) + if (qemuDomainObjExitMonitor(vm) < 0 || rv < 0) return -1; qemuMigrationUpdateJobType(jobInfo); @@ -2929,7 +2929,7 @@ qemuDomainMigrateGraphicsRelocate(virQEMUDriverPtr driver, ret = qemuMonitorGraphicsRelocate(priv->mon, type, listenAddress, port, tlsPort, tlsSubject); priv->job.spiceMigration = !ret; - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; } @@ -3033,7 +3033,7 @@ qemuMigrationRunIncoming(virQEMUDriverPtr driver, rv = qemuMonitorMigrateIncoming(priv->mon, uri); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rv < 0) + if (qemuDomainObjExitMonitor(vm) < 0 || rv < 0) goto cleanup; if (asyncJob == QEMU_ASYNC_JOB_MIGRATION_IN) { @@ -3494,7 +3494,7 @@ qemuMigrationSetCompression(virQEMUDriverPtr driver, ret = 0; cleanup: - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; return ret; @@ -3565,7 +3565,7 @@ qemuMigrationSetParams(virQEMUDriverPtr driver, ret = 0; cleanup: - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; return ret; @@ -4765,7 +4765,7 @@ qemuMigrationRun(virQEMUDriverPtr driver, /* explicitly do this *after* we entered the monitor, * as this is a critical section so we are guaranteed * priv->job.abortJob will not change */ - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); priv->job.current->type = VIR_DOMAIN_JOB_CANCELLED; virReportError(VIR_ERR_OPERATION_ABORTED, _("%s: %s"), qemuDomainAsyncJobTypeToString(priv->job.asyncJob), @@ -4819,7 +4819,7 @@ qemuMigrationRun(virQEMUDriverPtr driver, VIR_FORCE_CLOSE(spec->dest.fd.qemu); break; } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; if (ret < 0) goto cleanup; @@ -4948,7 +4948,7 @@ qemuMigrationRun(virQEMUDriverPtr driver, return ret; exit_monitor: - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); goto cleanup; cancel: @@ -4958,7 +4958,7 @@ qemuMigrationRun(virQEMUDriverPtr driver, if (qemuDomainObjEnterMonitorAsync(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT) == 0) { qemuMonitorMigrateCancel(priv->mon); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); } } goto cleanup; @@ -6466,7 +6466,7 @@ qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm, qemuMonitorSetMigrationSpeed(priv->mon, QEMU_DOMAIN_MIG_BANDWIDTH_MAX); priv->migMaxBandwidth = QEMU_DOMAIN_MIG_BANDWIDTH_MAX; - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) return -1; } @@ -6514,11 +6514,11 @@ qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm, if (virSetCloseExec(pipeFD[1]) < 0) { virReportSystemError(errno, "%s", _("Unable to set cloexec flag")); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); goto cleanup; } if (virCommandRunAsync(cmd, NULL) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); goto cleanup; } rc = qemuMonitorMigrateToFd(priv->mon, @@ -6528,7 +6528,7 @@ qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm, VIR_CLOSE(pipeFD[1]) < 0) VIR_WARN("failed to close intermediate pipe"); } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; if (rc < 0) goto cleanup; @@ -6542,7 +6542,7 @@ qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm, if (virDomainObjIsActive(vm) && qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) { qemuMonitorMigrateCancel(priv->mon); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); } } goto cleanup; @@ -6563,7 +6563,7 @@ qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm, qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) { qemuMonitorSetMigrationSpeed(priv->mon, saveMigBandwidth); priv->migMaxBandwidth = saveMigBandwidth; - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); } VIR_FORCE_CLOSE(pipeFD[0]); @@ -6604,13 +6604,13 @@ qemuMigrationCancel(virQEMUDriverPtr driver, } } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ignore_value(qemuMonitorMigrateCancel(priv->mon)); if (storage) blockJobs = qemuMonitorGetAllBlockJobInfo(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || (storage && !blockJobs)) + if (qemuDomainObjExitMonitor(vm) < 0 || (storage && !blockJobs)) goto endsyncjob; if (!storage) { diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index d9776c4..2bf69d5 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -533,10 +533,10 @@ qemuProcessFakeReboot(void *opaque) goto endjob; } - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorSystemReset(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto endjob; if (rc < 0) @@ -1738,7 +1738,7 @@ qemuConnectMonitor(virQEMUDriverPtr driver, virDomainObjPtr vm, int asyncJob, ret = 0; cleanup: - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; return ret; } @@ -1976,7 +1976,7 @@ qemuRefreshVirtioChannelState(virQEMUDriverPtr driver, goto cleanup; ret = qemuMonitorGetChardevInfo(priv->mon, &info); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; if (ret < 0) @@ -1990,8 +1990,7 @@ qemuRefreshVirtioChannelState(virQEMUDriverPtr driver, } static void -qemuRefreshRTC(virQEMUDriverPtr driver, - virDomainObjPtr vm) +qemuRefreshRTC(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv = vm->privateData; time_t now, then; @@ -2003,10 +2002,10 @@ qemuRefreshRTC(virQEMUDriverPtr driver, return; memset(&thenbits, 0, sizeof(thenbits)); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); now = time(NULL); rv = qemuMonitorGetRTCTime(priv->mon, &thenbits); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) rv = -1; if (rv < 0) @@ -2045,7 +2044,7 @@ qemuProcessRefreshBalloonState(virQEMUDriverPtr driver, return -1; rc = qemuMonitorGetBalloonInfo(qemuDomainGetMonitor(vm), &balloon); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + if (qemuDomainObjExitMonitor(vm) < 0 || rc < 0) return -1; vm->def->mem.cur_balloon = balloon; @@ -2078,7 +2077,7 @@ qemuProcessWaitForMonitor(virQEMUDriverPtr driver, goto cleanup; ret = qemuMonitorGetChardevInfo(priv->mon, &info); VIR_DEBUG("qemuMonitorGetChardevInfo returned %i", ret); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; if (ret == 0) { @@ -2146,7 +2145,7 @@ qemuProcessDetectIOThreadPIDs(virQEMUDriverPtr driver, if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) goto cleanup; niothreads = qemuMonitorGetIOThreads(priv->mon, &iothreads); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; if (niothreads < 0) goto cleanup; @@ -2294,7 +2293,7 @@ qemuProcessSetLinkStates(virQEMUDriverPtr driver, ret = 0; cleanup: - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; return ret; } @@ -2477,7 +2476,7 @@ qemuProcessInitPasswords(virConnectPtr conn, if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) goto cleanup; ret = qemuMonitorSetDrivePassphrase(priv->mon, alias, secret); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; if (ret < 0) goto cleanup; @@ -2601,7 +2600,7 @@ qemuProcessUpdateVideoRamSize(virQEMUDriverPtr driver, } - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) return -1; cfg = virQEMUDriverGetConfig(driver); @@ -2611,7 +2610,7 @@ qemuProcessUpdateVideoRamSize(virQEMUDriverPtr driver, return ret; error: - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); return -1; } @@ -2732,7 +2731,7 @@ qemuProcessStartCPUs(virQEMUDriverPtr driver, virDomainObjPtr vm, goto release; ret = qemuMonitorStartCPUs(priv->mon, conn); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; if (ret < 0) @@ -2766,7 +2765,7 @@ int qemuProcessStopCPUs(virQEMUDriverPtr driver, goto cleanup; ret = qemuMonitorStopCPUs(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; if (ret < 0) @@ -2827,7 +2826,7 @@ qemuProcessFiltersInstantiate(virDomainDefPtr def) } static int -qemuProcessUpdateState(virQEMUDriverPtr driver, virDomainObjPtr vm) +qemuProcessUpdateState(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv = vm->privateData; virDomainState state; @@ -2839,9 +2838,9 @@ qemuProcessUpdateState(virQEMUDriverPtr driver, virDomainObjPtr vm) char *msg = NULL; int ret; - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorGetStatus(priv->mon, &running, &reason); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) return -1; if (ret < 0) @@ -3068,9 +3067,9 @@ qemuProcessRecoverJob(virQEMUDriverPtr driver, case QEMU_ASYNC_JOB_SAVE: case QEMU_ASYNC_JOB_DUMP: case QEMU_ASYNC_JOB_SNAPSHOT: - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); ignore_value(qemuMonitorMigrateCancel(priv->mon)); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) return -1; /* resume the domain but only if it was paused as a result of * running a migration-to-file operation. Although we are @@ -3332,7 +3331,7 @@ qemuProcessReconnect(void *opaque) goto error; } - if (qemuProcessUpdateState(driver, obj) < 0) + if (qemuProcessUpdateState(obj) < 0) goto error; state = virDomainObjGetState(obj, &reason); @@ -3395,7 +3394,7 @@ qemuProcessReconnect(void *opaque) goto error; /* If querying of guest's RTC failed, report error, but do not kill the domain. */ - qemuRefreshRTC(driver, obj); + qemuRefreshRTC(obj); if (qemuProcessRefreshBalloonState(driver, obj, QEMU_ASYNC_JOB_NONE) < 0) goto error; @@ -3702,7 +3701,7 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) return false; rc = qemuMonitorGetGuestCPU(priv->mon, arch, &guestcpu); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) return false; if (rc < 0) { @@ -4351,7 +4350,7 @@ qemuProcessSetupBalloon(virQEMUDriverPtr driver, ret = 0; cleanup: - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; return ret; } @@ -4995,7 +4994,7 @@ qemuProcessSetupHotpluggableVcpus(virQEMUDriverPtr driver, rc = qemuMonitorAddDeviceArgs(qemuDomainGetMonitor(vm), vcpuprops); vcpuprops = NULL; - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; if (rc < 0) @@ -6367,14 +6366,14 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED, goto error; VIR_DEBUG("Getting initial memory amount"); - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); if (qemuMonitorGetBalloonInfo(priv->mon, &vm->def->mem.cur_balloon) < 0) goto exit_monitor; if (qemuMonitorGetStatus(priv->mon, &running, &reason) < 0) goto exit_monitor; if (qemuMonitorGetVirtType(priv->mon, &vm->def->virtType) < 0) goto exit_monitor; - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto error; if (running) { @@ -6383,10 +6382,10 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED, if (vm->def->memballoon && vm->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO && vm->def->memballoon->period) { - qemuDomainObjEnterMonitor(driver, vm); + qemuDomainObjEnterMonitor(vm); qemuMonitorSetMemoryStatsPeriod(priv->mon, vm->def->memballoon, vm->def->memballoon->period); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto error; } } else { @@ -6423,7 +6422,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED, return 0; exit_monitor: - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + ignore_value(qemuDomainObjExitMonitor(vm)); error: /* We jump here if we failed to attach to the VM for any reason. * Leave the domain running, but pretend we never attempted to @@ -6534,7 +6533,7 @@ qemuProcessRefreshDisks(virQEMUDriverPtr driver, if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) { table = qemuMonitorGetBlockInfo(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; } diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 89e870c..61d942c 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -123,7 +123,7 @@ testQemuHotplugAttach(virDomainObjPtr vm, ret = qemuDomainAttachChrDevice(NULL, &driver, vm, dev->data.chr); break; case VIR_DOMAIN_DEVICE_SHMEM: - ret = qemuDomainAttachShmemDevice(&driver, vm, dev->data.shmem); + ret = qemuDomainAttachShmemDevice(vm, dev->data.shmem); break; default: VIR_TEST_VERBOSE("device type '%s' cannot be attached\n", -- 1.8.3.1

Part of work can be done by perl: perl -0777 -i.bak -pe 's/if \(qemuDomainObjEnterMonitorAsync\(driver, vm,\n? .*\) < 0\)\n \ +return -1;/qemuDomainObjEnterMonitor(vm);/g' src/qemu/* perl -0777 -i.bak -pe 's/if \(qemuDomainObjEnterMonitorAsync\(driver, vm,\n? .*\) < 0\)\n \ +goto .+;/qemuDomainObjEnterMonitor(vm);/g' src/qemu/* Part should be done by hand. Then drop asyncJob and driver parameters from the callers until gcc stops giving 'unused parameter' error. --- src/qemu/qemu_domain.c | 69 +++---------- src/qemu/qemu_domain.h | 25 +---- src/qemu/qemu_driver.c | 152 ++++++++++------------------ src/qemu/qemu_hotplug.c | 34 +++---- src/qemu/qemu_hotplug.h | 9 +- src/qemu/qemu_migration.c | 250 +++++++++++++++------------------------------- src/qemu/qemu_migration.h | 7 +- src/qemu/qemu_process.c | 186 +++++++++++++--------------------- src/qemu/qemu_process.h | 20 +--- 9 files changed, 245 insertions(+), 507 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0a51fe8..f426805 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3478,8 +3478,8 @@ qemuDomainObjAbortAsyncJob(virDomainObjPtr obj) * * To be followed with qemuDomainObjExitMonitor() once complete */ -static void -qemuDomainObjEnterMonitorInternal(virDomainObjPtr obj) +void +qemuDomainObjEnterMonitor(virDomainObjPtr obj) { qemuDomainObjPrivatePtr priv = obj->privateData; @@ -3511,11 +3511,6 @@ qemuDomainObjExitMonitorInternal(virDomainObjPtr obj) priv->mon = NULL; } -void qemuDomainObjEnterMonitor(virDomainObjPtr obj) -{ - qemuDomainObjEnterMonitorInternal(obj); -} - /* obj must NOT be locked before calling * * Should be paired with an earlier qemuDomainObjEnterMonitor() call @@ -3541,30 +3536,6 @@ int qemuDomainObjExitMonitor(virDomainObjPtr obj) /* * 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, 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 - * qemuDomainObjExitMonitor(); -2 if waiting for the nested job times out; - * or -1 if the job could not be started (probably because the vm exited - * in the meantime). - */ -int -qemuDomainObjEnterMonitorAsync(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, - virDomainObjPtr obj, - qemuDomainAsyncJob asyncJob ATTRIBUTE_UNUSED) -{ - qemuDomainObjEnterMonitorInternal(obj); - return 0; -} - - -/* - * 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. @@ -5191,9 +5162,7 @@ qemuDomainHasBlockjob(virDomainObjPtr vm, int -qemuDomainUpdateDeviceList(virQEMUDriverPtr driver, - virDomainObjPtr vm, - int asyncJob) +qemuDomainUpdateDeviceList(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv = vm->privateData; char **aliases; @@ -5202,8 +5171,7 @@ qemuDomainUpdateDeviceList(virQEMUDriverPtr driver, if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_DEL_EVENT)) return 0; - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - return -1; + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorGetDeviceAliases(priv->mon, &aliases); if (qemuDomainObjExitMonitor(vm) < 0) return -1; @@ -5217,9 +5185,7 @@ qemuDomainUpdateDeviceList(virQEMUDriverPtr driver, int -qemuDomainUpdateMemoryDeviceInfo(virQEMUDriverPtr driver, - virDomainObjPtr vm, - int asyncJob) +qemuDomainUpdateMemoryDeviceInfo(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv = vm->privateData; virHashTablePtr meminfo = NULL; @@ -5229,8 +5195,7 @@ qemuDomainUpdateMemoryDeviceInfo(virQEMUDriverPtr driver, if (vm->def->nmems == 0) return 0; - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - return -1; + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorGetMemoryDeviceInfo(priv->mon, &meminfo); @@ -6171,10 +6136,7 @@ qemuDomainSupportsNewVcpuHotplug(virDomainObjPtr vm) * Returns 0 on success and -1 on fatal error. */ int -qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver, - virDomainObjPtr vm, - int asyncJob, - bool state) +qemuDomainRefreshVcpuInfo(virDomainObjPtr vm, bool state) { virDomainVcpuDefPtr vcpu; qemuDomainVcpuPrivatePtr vcpupriv; @@ -6187,8 +6149,7 @@ qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver, hotplug = qemuDomainSupportsNewVcpuHotplug(vm); - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - return -1; + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorGetCPUInfo(qemuDomainGetMonitor(vm), &info, maxvcpus, hotplug); @@ -6286,9 +6247,7 @@ qemuDomainGetVcpuHalted(virDomainObjPtr vm, * Returns 0 on success and -1 on error */ int -qemuDomainRefreshVcpuHalted(virQEMUDriverPtr driver, - virDomainObjPtr vm, - int asyncJob) +qemuDomainRefreshVcpuHalted(virDomainObjPtr vm) { virDomainVcpuDefPtr vcpu; qemuDomainVcpuPrivatePtr vcpupriv; @@ -6301,8 +6260,7 @@ qemuDomainRefreshVcpuHalted(virQEMUDriverPtr driver, if (vm->def->virtType == VIR_DOMAIN_VIRT_QEMU) return 0; - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - return -1; + qemuDomainObjEnterMonitor(vm); haltedmap = qemuMonitorGetCpuHalted(qemuDomainGetMonitor(vm), maxvcpus); @@ -6571,15 +6529,12 @@ qemuDomainVcpuPersistOrder(virDomainDefPtr def) int -qemuDomainCheckMonitor(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainAsyncJob asyncJob) +qemuDomainCheckMonitor(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv = vm->privateData; int ret; - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - return -1; + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorCheck(priv->mon); diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 12fef38..aff6270 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -435,11 +435,6 @@ void qemuDomainObjEnterMonitor(virDomainObjPtr obj) ATTRIBUTE_NONNULL(1); int qemuDomainObjExitMonitor(virDomainObjPtr obj) ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK; -int qemuDomainObjEnterMonitorAsync(virQEMUDriverPtr driver, - virDomainObjPtr obj, - qemuDomainAsyncJob asyncJob) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; - qemuAgentPtr qemuDomainObjEnterAgent(virDomainObjPtr obj) ATTRIBUTE_NONNULL(1); @@ -607,12 +602,9 @@ extern virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks; extern virDomainXMLNamespace virQEMUDriverDomainXMLNamespace; extern virDomainDefParserConfig virQEMUDriverDomainDefParserConfig; -int qemuDomainUpdateDeviceList(virQEMUDriverPtr driver, - virDomainObjPtr vm, int asyncJob); +int qemuDomainUpdateDeviceList(virDomainObjPtr vm); -int qemuDomainUpdateMemoryDeviceInfo(virQEMUDriverPtr driver, - virDomainObjPtr vm, - int asyncJob); +int qemuDomainUpdateMemoryDeviceInfo(virDomainObjPtr vm); bool qemuDomainDefCheckABIStability(virQEMUDriverPtr driver, virDomainDefPtr src, @@ -672,14 +664,9 @@ bool qemuDomainSupportsNewVcpuHotplug(virDomainObjPtr vm); bool qemuDomainHasVcpuPids(virDomainObjPtr vm); pid_t qemuDomainGetVcpuPid(virDomainObjPtr vm, unsigned int vcpuid); int qemuDomainValidateVcpuInfo(virDomainObjPtr vm); -int qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver, - virDomainObjPtr vm, - int asyncJob, - bool state); +int qemuDomainRefreshVcpuInfo(virDomainObjPtr vm, bool state); bool qemuDomainGetVcpuHalted(virDomainObjPtr vm, unsigned int vcpu); -int qemuDomainRefreshVcpuHalted(virQEMUDriverPtr driver, - virDomainObjPtr vm, - int asyncJob); +int qemuDomainRefreshVcpuHalted(virDomainObjPtr vm); bool qemuDomainSupportsNicdev(virDomainDefPtr def, virDomainNetDefPtr net); @@ -770,9 +757,7 @@ bool qemuDomainVcpuHotplugIsInOrder(virDomainDefPtr def) void qemuDomainVcpuPersistOrder(virDomainDefPtr def) ATTRIBUTE_NONNULL(1); -int qemuDomainCheckMonitor(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainAsyncJob asyncJob); +int qemuDomainCheckMonitor(virDomainObjPtr vm); bool qemuDomainSupportsVideoVga(virDomainVideoDefPtr video, virQEMUCapsPtr qemuCaps); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4b39021..46b89a4 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1870,7 +1870,7 @@ static int qemuDomainSuspend(virDomainPtr dom) "%s", _("domain is pmsuspended")); goto endjob; } else if (state != VIR_DOMAIN_PAUSED) { - if (qemuProcessStopCPUs(driver, vm, reason, QEMU_ASYNC_JOB_NONE) < 0) + if (qemuProcessStopCPUs(driver, vm, reason) < 0) goto endjob; if (eventDetail >= 0) { @@ -1935,8 +1935,7 @@ static int qemuDomainResume(virDomainPtr dom) reason == VIR_DOMAIN_CRASHED_PANICKED) || state == VIR_DOMAIN_PAUSED) { if (qemuProcessStartCPUs(driver, vm, dom->conn, - VIR_DOMAIN_RUNNING_UNPAUSED, - QEMU_ASYNC_JOB_NONE) < 0) { + VIR_DOMAIN_RUNNING_UNPAUSED) < 0) { if (virGetLastError() == NULL) virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("resume operation failed")); @@ -2248,8 +2247,7 @@ qemuDomainDestroyFlags(virDomainPtr dom, if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_IN) stopFlags |= VIR_QEMU_PROCESS_STOP_MIGRATED; - qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED, - QEMU_ASYNC_JOB_NONE, stopFlags); + qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED, stopFlags); event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_DESTROYED); @@ -3048,8 +3046,7 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver, int compressed, const char *compressedpath, bool was_running, - unsigned int flags, - qemuDomainAsyncJob asyncJob) + unsigned int flags) { virQEMUSaveHeader header; bool bypassSecurityDriver = false; @@ -3094,7 +3091,7 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver, goto cleanup; /* Perform the migration */ - if (qemuMigrationToFile(driver, vm, fd, compressedpath, asyncJob) < 0) + if (qemuMigrationToFile(driver, vm, fd, compressedpath) < 0) goto cleanup; /* Touch up file header to mark image complete. */ @@ -3176,8 +3173,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom, /* Pause */ if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) { was_running = true; - if (qemuProcessStopCPUs(driver, vm, VIR_DOMAIN_PAUSED_SAVE, - QEMU_ASYNC_JOB_SAVE) < 0) + if (qemuProcessStopCPUs(driver, vm, VIR_DOMAIN_PAUSED_SAVE) < 0) goto endjob; if (!virDomainObjIsActive(vm)) { @@ -3220,14 +3216,12 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom, } ret = qemuDomainSaveMemory(driver, vm, path, xml, compressed, - compressedpath, was_running, flags, - QEMU_ASYNC_JOB_SAVE); + compressedpath, was_running, flags); if (ret < 0) goto endjob; /* Shut it down */ - qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SAVED, - QEMU_ASYNC_JOB_SAVE, 0); + qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SAVED, 0); virDomainAuditStop(vm, "saved"); event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_SAVED); @@ -3236,8 +3230,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom, if (was_running && virDomainObjIsActive(vm)) { virErrorPtr save_err = virSaveLastError(); if (qemuProcessStartCPUs(driver, vm, dom->conn, - VIR_DOMAIN_RUNNING_SAVE_CANCELED, - QEMU_ASYNC_JOB_SAVE) < 0) { + VIR_DOMAIN_RUNNING_SAVE_CANCELED) < 0) { VIR_WARN("Unable to resume guest CPUs after save failure"); qemuDomainEventQueue(driver, virDomainEventLifecycleNewFromObj(vm, @@ -3533,8 +3526,7 @@ qemuDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags) } static int qemuDumpToFd(virQEMUDriverPtr driver, virDomainObjPtr vm, - int fd, qemuDomainAsyncJob asyncJob, - const char *dumpformat) + int fd, const char *dumpformat) { qemuDomainObjPrivatePtr priv = vm->privateData; int ret = -1; @@ -3552,8 +3544,7 @@ static int qemuDumpToFd(virQEMUDriverPtr driver, virDomainObjPtr vm, VIR_FREE(priv->job.current); priv->job.dump_memory_only = true; - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - return -1; + qemuDomainObjEnterMonitor(vm); if (dumpformat) { ret = qemuMonitorGetDumpGuestMemoryCapability(priv->mon, dumpformat); @@ -3632,8 +3623,7 @@ doCoreDump(virQEMUDriverPtr driver, if (STREQ(memory_dump_format, "elf")) memory_dump_format = NULL; - ret = qemuDumpToFd(driver, vm, fd, QEMU_ASYNC_JOB_DUMP, - memory_dump_format); + ret = qemuDumpToFd(driver, vm, fd, memory_dump_format); } else { if (dumpformat != VIR_DOMAIN_CORE_DUMP_FORMAT_RAW) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", @@ -3645,8 +3635,7 @@ doCoreDump(virQEMUDriverPtr driver, if (!qemuMigrationIsAllowed(driver, vm, false, 0)) goto cleanup; - ret = qemuMigrationToFile(driver, vm, fd, compressedpath, - QEMU_ASYNC_JOB_DUMP); + ret = qemuMigrationToFile(driver, vm, fd, compressedpath); } if (ret < 0) @@ -3714,8 +3703,7 @@ qemuDomainCoreDumpWithFormat(virDomainPtr dom, /* Pause domain for non-live dump */ if (!(flags & VIR_DUMP_LIVE) && virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) { - if (qemuProcessStopCPUs(driver, vm, VIR_DOMAIN_PAUSED_DUMP, - QEMU_ASYNC_JOB_DUMP) < 0) + if (qemuProcessStopCPUs(driver, vm, VIR_DOMAIN_PAUSED_DUMP) < 0) goto endjob; paused = true; @@ -3733,8 +3721,7 @@ qemuDomainCoreDumpWithFormat(virDomainPtr dom, endjob: if ((ret == 0) && (flags & VIR_DUMP_CRASH)) { - qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_CRASHED, - QEMU_ASYNC_JOB_DUMP, 0); + qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_CRASHED, 0); virDomainAuditStop(vm, "crashed"); event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, @@ -3751,8 +3738,7 @@ qemuDomainCoreDumpWithFormat(virDomainPtr dom, if (resume && virDomainObjIsActive(vm)) { if (qemuProcessStartCPUs(driver, vm, dom->conn, - VIR_DOMAIN_RUNNING_UNPAUSED, - QEMU_ASYNC_JOB_DUMP) < 0) { + VIR_DOMAIN_RUNNING_UNPAUSED) < 0) { event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_SUSPENDED, VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR); @@ -3937,8 +3923,7 @@ processWatchdogEvent(virQEMUDriverPtr driver, "%s", _("Dump failed")); ret = qemuProcessStartCPUs(driver, vm, NULL, - VIR_DOMAIN_RUNNING_UNPAUSED, - QEMU_ASYNC_JOB_DUMP); + VIR_DOMAIN_RUNNING_UNPAUSED); if (ret < 0) virReportError(VIR_ERR_OPERATION_FAILED, @@ -4024,8 +4009,7 @@ processGuestPanicEvent(virQEMUDriverPtr driver, /* fall through */ case VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY: - qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_CRASHED, - QEMU_ASYNC_JOB_DUMP, 0); + qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_CRASHED, 0); event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_CRASHED); @@ -4082,7 +4066,7 @@ processDeviceDeletedEvent(virQEMUDriverPtr driver, } if (STRPREFIX(devAlias, "vcpu")) { - qemuDomainRemoveVcpuAlias(driver, vm, devAlias); + qemuDomainRemoveVcpuAlias(vm, devAlias); } else { if (virDomainDefFindDevice(vm->def, devAlias, &dev, true) < 0) goto endjob; @@ -4552,7 +4536,7 @@ processMonitorEOFEvent(virQEMUDriverPtr driver, event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, eventReason); - qemuProcessStop(driver, vm, stopReason, QEMU_ASYNC_JOB_NONE, stopFlags); + qemuProcessStop(driver, vm, stopReason, stopFlags); virDomainAuditStop(vm, auditReason); qemuDomainEventQueue(driver, event); @@ -4608,8 +4592,7 @@ static void qemuProcessEventHandler(void *data, void *opaque) static int -qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver, - virDomainObjPtr vm, +qemuDomainHotplugAddVcpu(virDomainObjPtr vm, unsigned int vcpu) { virJSONValuePtr vcpuprops = NULL; @@ -4651,7 +4634,7 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver, if (newhotplug) vm->def->individualvcpus = true; - if (qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE, false) < 0) + if (qemuDomainRefreshVcpuInfo(vm, false) < 0) goto cleanup; /* validation requires us to set the expected state prior to calling it */ @@ -4882,7 +4865,7 @@ qemuDomainSetVcpusLive(virQEMUDriverPtr driver, if (nvcpus > virDomainDefGetVcpus(vm->def)) { while ((nextvcpu = virBitmapNextSetBit(vcpumap, nextvcpu)) != -1) { - if ((rc = qemuDomainHotplugAddVcpu(driver, vm, nextvcpu)) < 0) + if ((rc = qemuDomainHotplugAddVcpu(vm, nextvcpu)) < 0) break; } } else { @@ -4890,7 +4873,7 @@ qemuDomainSetVcpusLive(virQEMUDriverPtr driver, if (!virBitmapIsBitSet(vcpumap, nextvcpu)) continue; - if ((rc = qemuDomainHotplugDelVcpu(driver, vm, nextvcpu)) < 0) + if ((rc = qemuDomainHotplugDelVcpu(vm, nextvcpu)) < 0) break; } } @@ -6621,7 +6604,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, } if (virCommandWait(cmd, NULL) < 0) { - qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, asyncJob, 0); + qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, 0); restored = false; } VIR_DEBUG("Decompression binary stderr: %s", NULLSTR(errbuf)); @@ -6651,8 +6634,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, /* If it was running before, resume it now unless caller requested pause. */ if (header->was_running && !start_paused) { if (qemuProcessStartCPUs(driver, vm, conn, - VIR_DOMAIN_RUNNING_RESTORED, - asyncJob) < 0) { + VIR_DOMAIN_RUNNING_RESTORED) < 0) { if (virGetLastError() == NULL) virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("failed to resume domain")); @@ -7648,7 +7630,7 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, } if (ret == 0) - ret = qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE); + ret = qemuDomainUpdateDeviceList(vm); return ret; } @@ -7732,7 +7714,7 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm, } if (ret == 0) - ret = qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE); + ret = qemuDomainUpdateDeviceList(vm); return ret; } @@ -12994,8 +12976,7 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver, if (jobInfo->type == VIR_DOMAIN_JOB_BOUNDED || jobInfo->type == VIR_DOMAIN_JOB_UNBOUNDED) { if (fetch) - ret = qemuMigrationFetchJobStatus(driver, vm, QEMU_ASYNC_JOB_NONE, - jobInfo); + ret = qemuMigrationFetchJobStatus(vm, jobInfo); else ret = qemuDomainJobInfoUpdateTime(jobInfo); } else { @@ -13640,8 +13621,7 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr conn, * confuses libvirt since it's not notified when qemu resumes the * domain. Thus we stop and start CPUs ourselves. */ - if (qemuProcessStopCPUs(driver, vm, VIR_DOMAIN_PAUSED_SAVE, - QEMU_ASYNC_JOB_SNAPSHOT) < 0) + if (qemuProcessStopCPUs(driver, vm, VIR_DOMAIN_PAUSED_SAVE) < 0) goto cleanup; resume = true; @@ -13652,12 +13632,7 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr conn, } } - if (qemuDomainObjEnterMonitorAsync(driver, vm, - QEMU_ASYNC_JOB_SNAPSHOT) < 0) { - resume = false; - goto cleanup; - } - + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorCreateSnapshot(priv->mon, snap->def->name); if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; @@ -13667,8 +13642,7 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr conn, if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_HALT) { event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT); - qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT, - QEMU_ASYNC_JOB_SNAPSHOT, 0); + qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT, 0); virDomainAuditStop(vm, "from-snapshot"); resume = false; } @@ -13676,8 +13650,7 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr conn, cleanup: if (resume && virDomainObjIsActive(vm) && qemuProcessStartCPUs(driver, vm, conn, - VIR_DOMAIN_RUNNING_UNPAUSED, - QEMU_ASYNC_JOB_SNAPSHOT) < 0) { + VIR_DOMAIN_RUNNING_UNPAUSED) < 0) { event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_SUSPENDED, VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR); @@ -14109,8 +14082,7 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver, virDomainDiskDefPtr disk, virDomainDiskDefPtr persistDisk, virJSONValuePtr actions, - bool reuse, - qemuDomainAsyncJob asyncJob) + bool reuse) { qemuDomainObjPrivatePtr priv = vm->privateData; virStorageSourcePtr newDiskSrc = NULL; @@ -14174,9 +14146,8 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver, /* The monitor is only accessed if qemu doesn't support transactions. * Otherwise the following monitor command only constructs the command. */ - if (!actions && - qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - goto cleanup; + if (!actions) + qemuDomainObjEnterMonitor(vm); ret = rc = qemuMonitorDiskSnapshot(priv->mon, actions, device, source, formatStr, reuse); @@ -14258,8 +14229,7 @@ static int qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainSnapshotObjPtr snap, - unsigned int flags, - qemuDomainAsyncJob asyncJob) + unsigned int flags) { qemuDomainObjPrivatePtr priv = vm->privateData; virJSONValuePtr actions = NULL; @@ -14309,7 +14279,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver, &snap->def->disks[i], vm->def->disks[i], persistDisk, actions, - reuse, asyncJob); + reuse); if (ret < 0) break; @@ -14317,14 +14287,10 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver, } if (actions) { if (ret == 0 && do_transaction) { - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) { - ret = qemuMonitorTransaction(priv->mon, actions); - if (qemuDomainObjExitMonitor(vm) < 0) - ret = -1; - } else { - /* failed to enter monitor, clean stuff up and quit */ + qemuDomainObjEnterMonitor(vm); + ret = qemuMonitorTransaction(priv->mon, actions); + if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; - } } else { VIR_DEBUG("no disks to snapshot, skipping 'transaction' command"); } @@ -14436,8 +14402,7 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn, */ if ((memory && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_LIVE)) || (!memory && atomic && !transaction)) { - if (qemuProcessStopCPUs(driver, vm, VIR_DOMAIN_PAUSED_SNAPSHOT, - QEMU_ASYNC_JOB_SNAPSHOT) < 0) + if (qemuProcessStopCPUs(driver, vm, VIR_DOMAIN_PAUSED_SNAPSHOT) < 0) goto cleanup; if (!virDomainObjIsActive(vm)) { @@ -14470,7 +14435,7 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn, if ((ret = qemuDomainSaveMemory(driver, vm, snap->def->file, xml, compressed, compressedpath, resume, - 0, QEMU_ASYNC_JOB_SNAPSHOT)) < 0) + 0)) < 0) goto cleanup; /* the memory image was created, remove it on errors */ @@ -14487,16 +14452,14 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn, * * Next we snapshot the disks. */ - if ((ret = qemuDomainSnapshotCreateDiskActive(driver, vm, snap, flags, - QEMU_ASYNC_JOB_SNAPSHOT)) < 0) + if ((ret = qemuDomainSnapshotCreateDiskActive(driver, vm, snap, flags)) < 0) goto cleanup; /* the snapshot is complete now */ if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_HALT) { event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT); - qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT, - QEMU_ASYNC_JOB_SNAPSHOT, 0); + qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT, 0); virDomainAuditStop(vm, "from-snapshot"); resume = false; thaw = 0; @@ -14517,8 +14480,7 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn, cleanup: if (resume && virDomainObjIsActive(vm) && qemuProcessStartCPUs(driver, vm, conn, - VIR_DOMAIN_RUNNING_UNPAUSED, - QEMU_ASYNC_JOB_SNAPSHOT) < 0) { + VIR_DOMAIN_RUNNING_UNPAUSED) < 0) { event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_SUSPENDED, VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR); @@ -15359,9 +15321,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, goto endjob; } virResetError(err); - qemuProcessStop(driver, vm, - VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT, - QEMU_ASYNC_JOB_START, 0); + qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT, 0); virDomainAuditStop(vm, "from-snapshot"); detail = VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT; event = virDomainEventLifecycleNewFromObj(vm, @@ -15376,8 +15336,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, /* Transitions 5, 6 */ was_running = true; if (qemuProcessStopCPUs(driver, vm, - VIR_DOMAIN_PAUSED_FROM_SNAPSHOT, - QEMU_ASYNC_JOB_START) < 0) + VIR_DOMAIN_PAUSED_FROM_SNAPSHOT) < 0) goto endjob; /* Create an event now in case the restore fails, so * that user will be alerted that they are now paused. @@ -15393,9 +15352,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, } } - if (qemuDomainObjEnterMonitorAsync(driver, vm, - QEMU_ASYNC_JOB_START) < 0) - goto endjob; + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorLoadSnapshot(priv->mon, snap->def->name); if (qemuDomainObjExitMonitor(vm) < 0) goto endjob; @@ -15448,8 +15405,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, goto endjob; } rc = qemuProcessStartCPUs(driver, vm, snapshot->domain->conn, - VIR_DOMAIN_RUNNING_FROM_SNAPSHOT, - QEMU_ASYNC_JOB_START); + VIR_DOMAIN_RUNNING_FROM_SNAPSHOT); if (rc < 0) goto endjob; virObjectUnref(event); @@ -15481,8 +15437,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, if (virDomainObjIsActive(vm)) { /* Transitions 4, 7 */ - qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT, - QEMU_ASYNC_JOB_START, 0); + qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT, 0); virDomainAuditStop(vm, "from-snapshot"); detail = VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT; event = virDomainEventLifecycleNewFromObj(vm, @@ -18963,7 +18918,7 @@ qemuDomainGetStatsBalloon(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, static int -qemuDomainGetStatsVcpu(virQEMUDriverPtr driver, +qemuDomainGetStatsVcpu(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, virDomainObjPtr dom, virDomainStatsRecordPtr record, int *maxparams, @@ -18995,8 +18950,7 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver, goto cleanup; if (HAVE_JOB(privflags) && virDomainObjIsActive(dom)) { - if (qemuDomainRefreshVcpuHalted(driver, dom, - QEMU_ASYNC_JOB_NONE) < 0) { + if (qemuDomainRefreshVcpuHalted(dom) < 0) { /* it's ok to be silent and go ahead, because halted vcpu info * wasn't here from the beginning */ virResetLastError(); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index ed08313..9f9ae4d 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2205,14 +2205,13 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver, qemuDomainEventQueue(driver, event); /* fix the balloon size */ - ignore_value(qemuProcessRefreshBalloonState(driver, vm, QEMU_ASYNC_JOB_NONE)); + ignore_value(qemuProcessRefreshBalloonState(vm)); /* mem is consumed by vm->def */ mem = NULL; /* this step is best effort, removing the device would be so much trouble */ - ignore_value(qemuDomainUpdateMemoryDeviceInfo(driver, vm, - QEMU_ASYNC_JOB_NONE)); + ignore_value(qemuDomainUpdateMemoryDeviceInfo(vm)); ret = 0; @@ -3265,8 +3264,7 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver, ret = qemuDomainChangeGraphicsPasswords(driver, vm, VIR_DOMAIN_GRAPHICS_TYPE_VNC, &dev->data.vnc.auth, - cfg->vncPassword, - QEMU_ASYNC_JOB_NONE); + cfg->vncPassword); if (ret < 0) goto cleanup; @@ -3316,8 +3314,7 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver, ret = qemuDomainChangeGraphicsPasswords(driver, vm, VIR_DOMAIN_GRAPHICS_TYPE_SPICE, &dev->data.spice.auth, - cfg->spicePassword, - QEMU_ASYNC_JOB_NONE); + cfg->spicePassword); if (ret < 0) goto cleanup; @@ -3545,7 +3542,7 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver, virDomainMemoryDefFree(mem); /* fix the balloon size */ - ignore_value(qemuProcessRefreshBalloonState(driver, vm, QEMU_ASYNC_JOB_NONE)); + ignore_value(qemuProcessRefreshBalloonState(vm)); /* decrease the mlock limit after memory unplug if necessary */ ignore_value(qemuDomainAdjustMaxMemLock(vm)); @@ -4763,8 +4760,7 @@ qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver, virDomainObjPtr vm, int type, virDomainGraphicsAuthDefPtr auth, - const char *defaultPasswd, - int asyncJob) + const char *defaultPasswd) { qemuDomainObjPrivatePtr priv = vm->privateData; time_t now = time(NULL); @@ -4784,8 +4780,7 @@ qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver, if (auth->connected) connected = virDomainGraphicsAuthConnectedTypeToString(auth->connected); - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - goto cleanup; + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorSetPassword(priv->mon, type, password, connected); if (ret == -2) { @@ -5010,8 +5005,7 @@ qemuDomainDetachMemoryDevice(virQEMUDriverPtr driver, static int -qemuDomainRemoveVcpu(virQEMUDriverPtr driver, - virDomainObjPtr vm, +qemuDomainRemoveVcpu(virDomainObjPtr vm, unsigned int vcpu) { qemuDomainObjPrivatePtr priv = vm->privateData; @@ -5021,7 +5015,7 @@ qemuDomainRemoveVcpu(virQEMUDriverPtr driver, unsigned int nvcpus = vcpupriv->vcpus; size_t i; - if (qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE, false) < 0) + if (qemuDomainRefreshVcpuInfo(vm, false) < 0) return -1; /* validation requires us to set the expected state prior to calling it */ @@ -5054,8 +5048,7 @@ qemuDomainRemoveVcpu(virQEMUDriverPtr driver, void -qemuDomainRemoveVcpuAlias(virQEMUDriverPtr driver, - virDomainObjPtr vm, +qemuDomainRemoveVcpuAlias(virDomainObjPtr vm, const char *alias) { virDomainVcpuDefPtr vcpu; @@ -5067,7 +5060,7 @@ qemuDomainRemoveVcpuAlias(virQEMUDriverPtr driver, vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpu); if (STREQ_NULLABLE(alias, vcpupriv->alias)) { - qemuDomainRemoveVcpu(driver, vm, i); + qemuDomainRemoveVcpu(vm, i); return; } } @@ -5075,8 +5068,7 @@ qemuDomainRemoveVcpuAlias(virQEMUDriverPtr driver, int -qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver, - virDomainObjPtr vm, +qemuDomainHotplugDelVcpu(virDomainObjPtr vm, unsigned int vcpu) { virDomainVcpuDefPtr vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu); @@ -5113,5 +5105,5 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver, return -1; } - return qemuDomainRemoveVcpu(driver, vm, vcpu); + return qemuDomainRemoveVcpu(vm, vcpu); } diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index 7f0bca7..9fbc55a 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -67,8 +67,7 @@ int qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver, virDomainObjPtr vm, int type, virDomainGraphicsAuthDefPtr auth, - const char *defaultPasswd, - int asyncJob); + const char *defaultPasswd); int qemuDomainChangeNet(virDomainObjPtr vm, virDomainDeviceDefPtr dev); int qemuDomainChangeNetLinkState(virDomainObjPtr vm, @@ -110,11 +109,9 @@ int qemuDomainDetachRNGDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainRNGDefPtr rng); -int qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver, - virDomainObjPtr vm, +int qemuDomainHotplugDelVcpu(virDomainObjPtr vm, unsigned int vcpu); -void qemuDomainRemoveVcpuAlias(virQEMUDriverPtr driver, - virDomainObjPtr vm, +void qemuDomainRemoveVcpuAlias(virDomainObjPtr vm, const char *alias); int diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 36ddfa0..83f9eb8 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -584,7 +584,6 @@ qemuMigrationCookieAddNetwork(qemuMigrationCookiePtr mig, static int qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig, - virQEMUDriverPtr driver, virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv = vm->privateData; @@ -611,9 +610,7 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig, if (!(stats = virHashCreate(10, virHashValueFree))) goto cleanup; - if (qemuDomainObjEnterMonitorAsync(driver, vm, - priv->job.asyncJob) < 0) - goto cleanup; + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats, false); if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; @@ -1401,7 +1398,7 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig, } if ((flags & QEMU_MIGRATION_COOKIE_NBD) && - qemuMigrationCookieAddNBD(mig, driver, dom) < 0) + qemuMigrationCookieAddNBD(mig, dom) < 0) return -1; if (flags & QEMU_MIGRATION_COOKIE_STATS && @@ -1525,8 +1522,7 @@ qemuMigrationRestoreDomainState(virConnectPtr conn, virDomainObjPtr vm) /* we got here through some sort of failure; start the domain again */ if (qemuProcessStartCPUs(driver, vm, conn, - VIR_DOMAIN_RUNNING_MIGRATION_CANCELED, - QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) { + VIR_DOMAIN_RUNNING_MIGRATION_CANCELED) < 0) { /* Hm, we already know we are in error here. We don't want to * overwrite the previous error, though, so we just throw something * to the logs and hope for the best */ @@ -1775,9 +1771,7 @@ qemuMigrationStartNBDServer(virQEMUDriverPtr driver, if (!(diskAlias = qemuAliasFromDisk(disk))) goto cleanup; - if (qemuDomainObjEnterMonitorAsync(driver, vm, - QEMU_ASYNC_JOB_MIGRATION_IN) < 0) - goto cleanup; + qemuDomainObjEnterMonitor(vm); if (port == 0) { if (nbdPort) @@ -1820,9 +1814,7 @@ qemuMigrationStopNBDServer(virQEMUDriverPtr driver, if (!mig->nbd) return 0; - if (qemuDomainObjEnterMonitorAsync(driver, vm, - QEMU_ASYNC_JOB_MIGRATION_IN) < 0) - return -1; + qemuDomainObjEnterMonitor(vm); if (qemuMonitorNBDServerStop(priv->mon) < 0) VIR_WARN("Unable to stop NBD server"); @@ -1963,8 +1955,7 @@ static int qemuMigrationCancelOneDriveMirror(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainDiskDefPtr disk, - bool failNoJob, - qemuDomainAsyncJob asyncJob) + bool failNoJob) { qemuDomainObjPrivatePtr priv = vm->privateData; char *diskAlias = NULL; @@ -1991,8 +1982,7 @@ qemuMigrationCancelOneDriveMirror(virQEMUDriverPtr driver, if (!(diskAlias = qemuAliasFromDisk(disk))) return -1; - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - goto cleanup; + qemuDomainObjEnterMonitor(vm); rv = qemuMonitorBlockJobCancel(priv->mon, diskAlias, true); @@ -2023,7 +2013,6 @@ static int qemuMigrationCancelDriveMirror(virQEMUDriverPtr driver, virDomainObjPtr vm, bool check, - qemuDomainAsyncJob asyncJob, virConnectPtr dconn) { virErrorPtr err = NULL; @@ -2041,8 +2030,7 @@ qemuMigrationCancelDriveMirror(virQEMUDriverPtr driver, if (!diskPriv->migrating) continue; - rv = qemuMigrationCancelOneDriveMirror(driver, vm, disk, - check, asyncJob); + rv = qemuMigrationCancelOneDriveMirror(driver, vm, disk, check); if (rv != 0) { if (rv < 0) { if (!err) @@ -2168,9 +2156,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver, hoststr, port, diskAlias) < 0)) goto cleanup; - if (qemuDomainObjEnterMonitorAsync(driver, vm, - QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) - goto cleanup; + qemuDomainObjEnterMonitor(vm); qemuBlockJobSyncBegin(disk); /* Force "raw" format for NBD export */ @@ -2413,8 +2399,7 @@ qemuMigrationSetOffline(virQEMUDriverPtr driver, { int ret; VIR_DEBUG("driver=%p vm=%p", driver, vm); - ret = qemuProcessStopCPUs(driver, vm, VIR_DOMAIN_PAUSED_MIGRATION, - QEMU_ASYNC_JOB_MIGRATION_OUT); + ret = qemuProcessStopCPUs(driver, vm, VIR_DOMAIN_PAUSED_MIGRATION); if (ret == 0) { virObjectEventPtr event; @@ -2452,8 +2437,7 @@ qemuMigrationPostcopyFailed(virQEMUDriverPtr driver, virObjectEventPtr event; if (qemuProcessStopCPUs(driver, vm, - VIR_DOMAIN_PAUSED_POSTCOPY_FAILED, - QEMU_ASYNC_JOB_MIGRATION_IN) < 0) { + VIR_DOMAIN_PAUSED_POSTCOPY_FAILED) < 0) { VIR_WARN("Unable to pause guest CPUs for %s", vm->def->name); return; } @@ -2470,8 +2454,7 @@ qemuMigrationPostcopyFailed(virQEMUDriverPtr driver, static int -qemuMigrationSetOption(virQEMUDriverPtr driver, - virDomainObjPtr vm, +qemuMigrationSetOption(virDomainObjPtr vm, qemuMonitorMigrationCaps capability, bool state, qemuDomainAsyncJob job) @@ -2479,8 +2462,7 @@ qemuMigrationSetOption(virQEMUDriverPtr driver, qemuDomainObjPrivatePtr priv = vm->privateData; int ret; - if (qemuDomainObjEnterMonitorAsync(driver, vm, job) < 0) - return -1; + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorGetMigrationCapability(priv->mon, capability); @@ -2515,15 +2497,13 @@ qemuMigrationSetOption(virQEMUDriverPtr driver, static int -qemuMigrationSetPostCopy(virQEMUDriverPtr driver, - virDomainObjPtr vm, +qemuMigrationSetPostCopy(virDomainObjPtr vm, bool state, qemuDomainAsyncJob job) { qemuDomainObjPrivatePtr priv = vm->privateData; - if (qemuMigrationSetOption(driver, vm, - QEMU_MONITOR_MIGRATION_CAPS_POSTCOPY, + if (qemuMigrationSetOption(vm, QEMU_MONITOR_MIGRATION_CAPS_POSTCOPY, state, job) < 0) return -1; @@ -2581,16 +2561,12 @@ qemuMigrationUpdateJobType(qemuDomainJobInfoPtr jobInfo) int -qemuMigrationFetchJobStatus(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainAsyncJob asyncJob, - qemuDomainJobInfoPtr jobInfo) +qemuMigrationFetchJobStatus(virDomainObjPtr vm, qemuDomainJobInfoPtr jobInfo) { qemuDomainObjPrivatePtr priv = vm->privateData; int rv; - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - return -1; + qemuDomainObjEnterMonitor(vm); memset(&jobInfo->stats, 0, sizeof(jobInfo->stats)); rv = qemuMonitorGetMigrationStats(priv->mon, &jobInfo->stats); @@ -2622,15 +2598,13 @@ qemuMigrationJobName(virDomainObjPtr vm) static int -qemuMigrationUpdateJobStatus(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainAsyncJob asyncJob) +qemuMigrationUpdateJobStatus(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainJobInfoPtr jobInfo = priv->job.current; qemuDomainJobInfo newInfo = *jobInfo; - if (qemuMigrationFetchJobStatus(driver, vm, asyncJob, &newInfo) < 0) + if (qemuMigrationFetchJobStatus(vm, &newInfo) < 0) return -1; *jobInfo = newInfo; @@ -2639,10 +2613,7 @@ qemuMigrationUpdateJobStatus(virQEMUDriverPtr driver, static int -qemuMigrationCheckJobStatus(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainAsyncJob asyncJob, - bool updateJobStats) +qemuMigrationCheckJobStatus(virDomainObjPtr vm, bool updateJobStats) { qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainJobInfoPtr jobInfo = priv->job.current; @@ -2651,7 +2622,7 @@ qemuMigrationCheckJobStatus(virQEMUDriverPtr driver, if (events) qemuMigrationUpdateJobType(jobInfo); - else if (qemuMigrationUpdateJobStatus(driver, vm, asyncJob) < 0) + else if (qemuMigrationUpdateJobStatus(vm) < 0) return -1; switch (jobInfo->type) { @@ -2673,7 +2644,7 @@ qemuMigrationCheckJobStatus(virQEMUDriverPtr driver, case VIR_DOMAIN_JOB_COMPLETED: /* Fetch statistics of a completed migration */ if (events && updateJobStats && - qemuMigrationUpdateJobStatus(driver, vm, asyncJob) < 0) + qemuMigrationUpdateJobStatus(vm) < 0) return -1; break; @@ -2702,7 +2673,6 @@ enum qemuMigrationCompletedFlags { static int qemuMigrationCompleted(virQEMUDriverPtr driver, virDomainObjPtr vm, - qemuDomainAsyncJob asyncJob, virConnectPtr dconn, unsigned int flags) { @@ -2711,7 +2681,7 @@ qemuMigrationCompleted(virQEMUDriverPtr driver, int pauseReason; bool updateStats = !!(flags & QEMU_MIGRATION_COMPLETED_UPDATE_STATS); - if (qemuMigrationCheckJobStatus(driver, vm, asyncJob, updateStats) < 0) + if (qemuMigrationCheckJobStatus(vm, updateStats) < 0) goto error; if (flags & QEMU_MIGRATION_COMPLETED_CHECK_STORAGE && @@ -2741,7 +2711,7 @@ qemuMigrationCompleted(virQEMUDriverPtr driver, jobInfo->stats.status == QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY) { VIR_DEBUG("Migration switched to post-copy"); if (updateStats && - qemuMigrationUpdateJobStatus(driver, vm, asyncJob) < 0) + qemuMigrationUpdateJobStatus(vm) < 0) goto error; return 1; } @@ -2771,7 +2741,6 @@ qemuMigrationCompleted(virQEMUDriverPtr driver, static int qemuMigrationWaitForCompletion(virQEMUDriverPtr driver, virDomainObjPtr vm, - qemuDomainAsyncJob asyncJob, virConnectPtr dconn, unsigned int flags) { @@ -2783,8 +2752,7 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver, flags |= QEMU_MIGRATION_COMPLETED_UPDATE_STATS; jobInfo->type = VIR_DOMAIN_JOB_UNBOUNDED; - while ((rv = qemuMigrationCompleted(driver, vm, asyncJob, - dconn, flags)) != 1) { + while ((rv = qemuMigrationCompleted(driver, vm, dconn, flags)) != 1) { if (rv < 0) return rv; @@ -2815,7 +2783,6 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver, static int qemuMigrationWaitForDestCompletion(virQEMUDriverPtr driver, virDomainObjPtr vm, - qemuDomainAsyncJob asyncJob, bool postcopy) { qemuDomainObjPrivatePtr priv = vm->privateData; @@ -2830,8 +2797,7 @@ qemuMigrationWaitForDestCompletion(virQEMUDriverPtr driver, if (postcopy) flags = QEMU_MIGRATION_COMPLETED_POSTCOPY; - while ((rv = qemuMigrationCompleted(driver, vm, asyncJob, - NULL, flags)) != 1) { + while ((rv = qemuMigrationCompleted(driver, vm, NULL, flags)) != 1) { if (rv < 0 || virDomainObjWait(vm) < 0) return -1; } @@ -2841,8 +2807,7 @@ qemuMigrationWaitForDestCompletion(virQEMUDriverPtr driver, static int -qemuDomainMigrateGraphicsRelocate(virQEMUDriverPtr driver, - virDomainObjPtr vm, +qemuDomainMigrateGraphicsRelocate(virDomainObjPtr vm, qemuMigrationCookiePtr cookie, const char *graphicsuri) { @@ -2924,14 +2889,12 @@ qemuDomainMigrateGraphicsRelocate(virQEMUDriverPtr driver, goto cleanup; } - if (qemuDomainObjEnterMonitorAsync(driver, vm, - QEMU_ASYNC_JOB_MIGRATION_OUT) == 0) { - ret = qemuMonitorGraphicsRelocate(priv->mon, type, listenAddress, - port, tlsPort, tlsSubject); - priv->job.spiceMigration = !ret; - if (qemuDomainObjExitMonitor(vm) < 0) - ret = -1; - } + qemuDomainObjEnterMonitor(vm); + ret = qemuMonitorGraphicsRelocate(priv->mon, type, listenAddress, + port, tlsPort, tlsSubject); + priv->job.spiceMigration = !ret; + if (qemuDomainObjExitMonitor(vm) < 0) + ret = -1; cleanup: virURIFree(uri); @@ -3028,8 +2991,7 @@ qemuMigrationRunIncoming(virQEMUDriverPtr driver, VIR_DEBUG("Setting up incoming migration with URI %s", uri); - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - return -1; + qemuDomainObjEnterMonitor(vm); rv = qemuMonitorMigrateIncoming(priv->mon, uri); @@ -3042,7 +3004,7 @@ qemuMigrationRunIncoming(virQEMUDriverPtr driver, goto cleanup; } - if (qemuMigrationWaitForDestCompletion(driver, vm, asyncJob, false) < 0) + if (qemuMigrationWaitForDestCompletion(driver, vm, false) < 0) goto cleanup; ret = 0; @@ -3287,16 +3249,13 @@ qemuMigrationBegin(virConnectPtr conn, { virQEMUDriverPtr driver = conn->privateData; char *xml = NULL; - qemuDomainAsyncJob asyncJob; if ((flags & VIR_MIGRATE_CHANGE_PROTECTION)) { if (qemuMigrationJobStart(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) goto cleanup; - asyncJob = QEMU_ASYNC_JOB_MIGRATION_OUT; } else { if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - asyncJob = QEMU_ASYNC_JOB_NONE; } qemuMigrationStoreDomainState(vm); @@ -3311,7 +3270,7 @@ qemuMigrationBegin(virConnectPtr conn, * We don't want to require them on the destination. */ if (!(flags & VIR_MIGRATE_OFFLINE) && - qemuProcessRefreshDisks(driver, vm, asyncJob) < 0) + qemuProcessRefreshDisks(vm) < 0) goto endjob; if (!(xml = qemuMigrationBeginPhase(driver, vm, xmlin, dname, @@ -3451,8 +3410,7 @@ qemuMigrationPrepareIncoming(virDomainObjPtr vm, } static int -qemuMigrationSetCompression(virQEMUDriverPtr driver, - virDomainObjPtr vm, +qemuMigrationSetCompression(virDomainObjPtr vm, qemuDomainAsyncJob job, qemuMigrationCompressionPtr compression, qemuMonitorMigrationParamsPtr migParams) @@ -3460,22 +3418,19 @@ qemuMigrationSetCompression(virQEMUDriverPtr driver, int ret = -1; qemuDomainObjPrivatePtr priv = vm->privateData; - if (qemuMigrationSetOption(driver, vm, - QEMU_MONITOR_MIGRATION_CAPS_XBZRLE, + if (qemuMigrationSetOption(vm, QEMU_MONITOR_MIGRATION_CAPS_XBZRLE, compression->methods & (1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE), job) < 0) return -1; - if (qemuMigrationSetOption(driver, vm, - QEMU_MONITOR_MIGRATION_CAPS_COMPRESS, + if (qemuMigrationSetOption(vm, QEMU_MONITOR_MIGRATION_CAPS_COMPRESS, compression->methods & (1ULL << QEMU_MIGRATION_COMPRESS_MT), job) < 0) return -1; - if (qemuDomainObjEnterMonitorAsync(driver, vm, job) < 0) - return -1; + qemuDomainObjEnterMonitor(vm); migParams->compressLevel_set = compression->level_set; migParams->compressLevel = compression->level; @@ -3548,16 +3503,13 @@ qemuMigrationParams(virTypedParameterPtr params, static int -qemuMigrationSetParams(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainAsyncJob job, +qemuMigrationSetParams(virDomainObjPtr vm, qemuMonitorMigrationParamsPtr migParams) { qemuDomainObjPrivatePtr priv = vm->privateData; int ret = -1; - if (qemuDomainObjEnterMonitorAsync(driver, vm, job) < 0) - return -1; + qemuDomainObjEnterMonitor(vm); if (qemuMonitorSetMigrationParams(priv->mon, migParams) < 0) goto cleanup; @@ -3752,7 +3704,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, goto stopjob; } - if (qemuProcessInit(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN, + if (qemuProcessInit(driver, vm, true, VIR_QEMU_PROCESS_START_AUTODESTROY) < 0) goto stopjob; stopProcess = true; @@ -3790,7 +3742,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, dataFD[1] = -1; /* 'st' owns the FD now & will close it */ } - if (qemuMigrationSetCompression(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN, + if (qemuMigrationSetCompression(vm, QEMU_ASYNC_JOB_MIGRATION_IN, compression, &migParams) < 0) goto stopjob; @@ -3799,19 +3751,16 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, goto stopjob; } - if (qemuMigrationSetOption(driver, vm, - QEMU_MONITOR_MIGRATION_CAPS_RDMA_PIN_ALL, + if (qemuMigrationSetOption(vm, QEMU_MONITOR_MIGRATION_CAPS_RDMA_PIN_ALL, flags & VIR_MIGRATE_RDMA_PIN_ALL, QEMU_ASYNC_JOB_MIGRATION_IN) < 0) goto stopjob; - if (qemuMigrationSetPostCopy(driver, vm, - flags & VIR_MIGRATE_POSTCOPY, + if (qemuMigrationSetPostCopy(vm, flags & VIR_MIGRATE_POSTCOPY, QEMU_ASYNC_JOB_MIGRATION_IN) < 0) goto stopjob; - if (qemuMigrationSetParams(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN, - &migParams) < 0) + if (qemuMigrationSetParams(vm, &migParams) < 0) goto stopjob; if (mig->nbd && @@ -3839,7 +3788,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, QEMU_ASYNC_JOB_MIGRATION_IN) < 0) goto stopjob; - if (qemuProcessFinishStartup(dconn, driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN, + if (qemuProcessFinishStartup(dconn, driver, vm, false, VIR_DOMAIN_PAUSED_MIGRATION) < 0) goto stopjob; @@ -3909,8 +3858,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, if (!relabel) stopFlags |= VIR_QEMU_PROCESS_STOP_NO_RELABEL; virDomainAuditStart(vm, "migrated", false); - qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, - QEMU_ASYNC_JOB_MIGRATION_IN, stopFlags); + qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, stopFlags); } qemuMigrationJobFinish(driver, vm); @@ -4226,9 +4174,7 @@ qemuMigrationConfirmPhase(virQEMUDriverPtr driver, */ if (virDomainObjGetState(vm, &reason) == VIR_DOMAIN_PAUSED && reason == VIR_DOMAIN_PAUSED_POSTCOPY && - qemuMigrationFetchJobStatus(driver, vm, - QEMU_ASYNC_JOB_MIGRATION_OUT, - jobInfo) < 0) + qemuMigrationFetchJobStatus(vm, jobInfo) < 0) VIR_WARN("Could not refresh migration statistics"); qemuDomainJobInfoUpdateTime(jobInfo); @@ -4250,7 +4196,6 @@ qemuMigrationConfirmPhase(virQEMUDriverPtr driver, qemuMigrationWaitForSpice(vm); qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_MIGRATED, - QEMU_ASYNC_JOB_MIGRATION_OUT, VIR_QEMU_PROCESS_STOP_MIGRATED); virDomainAuditStop(vm, "migrated"); @@ -4264,8 +4209,7 @@ qemuMigrationConfirmPhase(virQEMUDriverPtr driver, int reason; /* cancel any outstanding NBD jobs */ - qemuMigrationCancelDriveMirror(driver, vm, false, - QEMU_ASYNC_JOB_MIGRATION_OUT, NULL); + qemuMigrationCancelDriveMirror(driver, vm, false, NULL); virSetError(orig_err); virFreeError(orig_err); @@ -4701,7 +4645,7 @@ qemuMigrationRun(virQEMUDriverPtr driver, if (!mig) goto cleanup; - if (qemuDomainMigrateGraphicsRelocate(driver, vm, mig, graphicsuri) < 0) + if (qemuDomainMigrateGraphicsRelocate(vm, mig, graphicsuri) < 0) VIR_WARN("unable to provide data for graphics client relocation"); if (migrate_flags & (QEMU_MONITOR_MIGRATE_NON_SHARED_DISK | @@ -4732,34 +4676,28 @@ qemuMigrationRun(virQEMUDriverPtr driver, goto cleanup; } - if (qemuMigrationSetCompression(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT, + if (qemuMigrationSetCompression(vm, QEMU_ASYNC_JOB_MIGRATION_OUT, compression, migParams) < 0) goto cleanup; - if (qemuMigrationSetOption(driver, vm, - QEMU_MONITOR_MIGRATION_CAPS_AUTO_CONVERGE, + if (qemuMigrationSetOption(vm, QEMU_MONITOR_MIGRATION_CAPS_AUTO_CONVERGE, flags & VIR_MIGRATE_AUTO_CONVERGE, QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) goto cleanup; - if (qemuMigrationSetOption(driver, vm, - QEMU_MONITOR_MIGRATION_CAPS_RDMA_PIN_ALL, + if (qemuMigrationSetOption(vm, QEMU_MONITOR_MIGRATION_CAPS_RDMA_PIN_ALL, flags & VIR_MIGRATE_RDMA_PIN_ALL, QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) goto cleanup; - if (qemuMigrationSetPostCopy(driver, vm, - flags & VIR_MIGRATE_POSTCOPY, + if (qemuMigrationSetPostCopy(vm, flags & VIR_MIGRATE_POSTCOPY, QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) goto cleanup; - if (qemuMigrationSetParams(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT, - migParams) < 0) + if (qemuMigrationSetParams(vm, migParams) < 0) goto cleanup; - if (qemuDomainObjEnterMonitorAsync(driver, vm, - QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) - goto cleanup; + qemuDomainObjEnterMonitor(vm); if (priv->job.abortJob) { /* explicitly do this *after* we entered the monitor, @@ -4833,9 +4771,7 @@ qemuMigrationRun(virQEMUDriverPtr driver, * rather failed later on. Check its status before waiting for a * connection from qemu which may never be initiated. */ - if (qemuMigrationCheckJobStatus(driver, vm, - QEMU_ASYNC_JOB_MIGRATION_OUT, - false) < 0) + if (qemuMigrationCheckJobStatus(vm, false) < 0) goto cancel; while ((fd = accept(spec->dest.unix_socket.sock, NULL, NULL)) < 0) { @@ -4864,9 +4800,7 @@ qemuMigrationRun(virQEMUDriverPtr driver, if (flags & VIR_MIGRATE_POSTCOPY) waitFlags |= QEMU_MIGRATION_COMPLETED_POSTCOPY; - rc = qemuMigrationWaitForCompletion(driver, vm, - QEMU_ASYNC_JOB_MIGRATION_OUT, - dconn, waitFlags); + rc = qemuMigrationWaitForCompletion(driver, vm, dconn, waitFlags); if (rc == -2) goto cancel; else if (rc == -1) @@ -4902,9 +4836,7 @@ qemuMigrationRun(virQEMUDriverPtr driver, /* cancel any outstanding NBD jobs */ if (mig && mig->nbd) { - if (qemuMigrationCancelDriveMirror(driver, vm, ret == 0, - QEMU_ASYNC_JOB_MIGRATION_OUT, - dconn) < 0) + if (qemuMigrationCancelDriveMirror(driver, vm, ret == 0, dconn) < 0) ret = -1; } @@ -4955,11 +4887,9 @@ qemuMigrationRun(virQEMUDriverPtr driver, orig_err = virSaveLastError(); if (virDomainObjIsActive(vm)) { - if (qemuDomainObjEnterMonitorAsync(driver, vm, - QEMU_ASYNC_JOB_MIGRATION_OUT) == 0) { - qemuMonitorMigrateCancel(priv->mon); - ignore_value(qemuDomainObjExitMonitor(vm)); - } + qemuDomainObjEnterMonitor(vm); + qemuMonitorMigrateCancel(priv->mon); + ignore_value(qemuDomainObjExitMonitor(vm)); } goto cleanup; @@ -5873,7 +5803,6 @@ qemuMigrationPerformJob(virQEMUDriverPtr driver, */ if (!v3proto) { qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_MIGRATED, - QEMU_ASYNC_JOB_MIGRATION_OUT, VIR_QEMU_PROCESS_STOP_MIGRATED); virDomainAuditStop(vm, "migrated"); event = virDomainEventLifecycleNewFromObj(vm, @@ -6231,7 +6160,7 @@ qemuMigrationFinish(virQEMUDriverPtr driver, /* Check for a possible error on the monitor in case Finish was called * earlier than monitor EOF handler got a chance to process the error */ - qemuDomainCheckMonitor(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN); + qemuDomainCheckMonitor(vm); goto endjob; } @@ -6251,8 +6180,7 @@ qemuMigrationFinish(virQEMUDriverPtr driver, if (qemuMigrationStopNBDServer(driver, vm, mig) < 0) goto endjob; - if (qemuRefreshVirtioChannelState(driver, vm, - QEMU_ASYNC_JOB_MIGRATION_IN) < 0) + if (qemuRefreshVirtioChannelState(driver, vm) < 0) goto endjob; if (qemuConnectAgent(driver, vm) < 0) @@ -6281,7 +6209,6 @@ qemuMigrationFinish(virQEMUDriverPtr driver, * before starting guest CPUs. */ if (qemuMigrationWaitForDestCompletion(driver, vm, - QEMU_ASYNC_JOB_MIGRATION_IN, !!(flags & VIR_MIGRATE_POSTCOPY)) < 0) { /* There's not much we can do for v2 protocol since the * original domain on the source host is already gone. @@ -6300,8 +6227,7 @@ qemuMigrationFinish(virQEMUDriverPtr driver, */ if (qemuProcessStartCPUs(driver, vm, dconn, inPostCopy ? VIR_DOMAIN_RUNNING_POSTCOPY - : VIR_DOMAIN_RUNNING_MIGRATED, - QEMU_ASYNC_JOB_MIGRATION_IN) < 0) { + : VIR_DOMAIN_RUNNING_MIGRATED) < 0) { if (virGetLastError() == NULL) virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("resume operation failed")); @@ -6345,11 +6271,9 @@ qemuMigrationFinish(virQEMUDriverPtr driver, } if (inPostCopy) { - if (qemuMigrationWaitForDestCompletion(driver, vm, - QEMU_ASYNC_JOB_MIGRATION_IN, - false) < 0) { + if (qemuMigrationWaitForDestCompletion(driver, vm, false) < 0) goto endjob; - } + if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) { virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, @@ -6385,7 +6309,6 @@ qemuMigrationFinish(virQEMUDriverPtr driver, virDomainObjIsActive(vm)) { if (doKill) { qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, - QEMU_ASYNC_JOB_MIGRATION_IN, VIR_QEMU_PROCESS_STOP_MIGRATED); virDomainAuditStop(vm, "failed"); event = virDomainEventLifecycleNewFromObj(vm, @@ -6410,8 +6333,7 @@ qemuMigrationFinish(virQEMUDriverPtr driver, if (inPostCopy) VIR_FREE(priv->job.completed); - qemuMigrationSetPostCopy(driver, vm, false, - QEMU_ASYNC_JOB_MIGRATION_IN); + qemuMigrationSetPostCopy(vm, false, QEMU_ASYNC_JOB_MIGRATION_IN); } qemuMigrationJobFinish(driver, vm); @@ -6447,9 +6369,7 @@ qemuMigrationFinish(virQEMUDriverPtr driver, /* Helper function called while vm is active. */ int qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm, - int fd, - const char *compressor, - qemuDomainAsyncJob asyncJob) + int fd, const char *compressor) { qemuDomainObjPrivatePtr priv = vm->privateData; int rc; @@ -6462,13 +6382,11 @@ qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm, /* Increase migration bandwidth to unlimited since target is a file. * Failure to change migration speed is not fatal. */ - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) { - qemuMonitorSetMigrationSpeed(priv->mon, - QEMU_DOMAIN_MIG_BANDWIDTH_MAX); - priv->migMaxBandwidth = QEMU_DOMAIN_MIG_BANDWIDTH_MAX; - if (qemuDomainObjExitMonitor(vm) < 0) - return -1; - } + qemuDomainObjEnterMonitor(vm); + qemuMonitorSetMigrationSpeed(priv->mon, QEMU_DOMAIN_MIG_BANDWIDTH_MAX); + priv->migMaxBandwidth = QEMU_DOMAIN_MIG_BANDWIDTH_MAX; + if (qemuDomainObjExitMonitor(vm) < 0) + return -1; if (!virDomainObjIsActive(vm)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -6491,8 +6409,7 @@ qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm, compressor ? pipeFD[1] : fd) < 0) goto cleanup; - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - goto cleanup; + qemuDomainObjEnterMonitor(vm); if (!compressor) { rc = qemuMonitorMigrateToFd(priv->mon, @@ -6533,14 +6450,14 @@ qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm, if (rc < 0) goto cleanup; - rc = qemuMigrationWaitForCompletion(driver, vm, asyncJob, NULL, 0); + rc = qemuMigrationWaitForCompletion(driver, vm, NULL, 0); if (rc < 0) { if (rc == -2) { orig_err = virSaveLastError(); virCommandAbort(cmd); - if (virDomainObjIsActive(vm) && - qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) { + if (virDomainObjIsActive(vm)) { + qemuDomainObjEnterMonitor(vm); qemuMonitorMigrateCancel(priv->mon); ignore_value(qemuDomainObjExitMonitor(vm)); } @@ -6559,8 +6476,8 @@ qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm, orig_err = virSaveLastError(); /* Restore max migration bandwidth */ - if (virDomainObjIsActive(vm) && - qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) { + if (virDomainObjIsActive(vm)) { + qemuDomainObjEnterMonitor(vm); qemuMonitorSetMigrationSpeed(priv->mon, saveMigBandwidth); priv->migMaxBandwidth = saveMigBandwidth; ignore_value(qemuDomainObjExitMonitor(vm)); @@ -6634,8 +6551,7 @@ qemuMigrationCancel(virQEMUDriverPtr driver, } } - if (qemuMigrationCancelDriveMirror(driver, vm, false, - QEMU_ASYNC_JOB_NONE, NULL) < 0) + if (qemuMigrationCancelDriveMirror(driver, vm, false, NULL) < 0) goto endsyncjob; ret = 0; diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index 14c6178..36b79f5 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -238,16 +238,13 @@ bool qemuMigrationIsAllowed(virQEMUDriverPtr driver, virDomainObjPtr vm, int qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm, int fd, - const char *compressor, - qemuDomainAsyncJob asyncJob) + const char *compressor) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; int qemuMigrationCancel(virQEMUDriverPtr driver, virDomainObjPtr vm); -int qemuMigrationFetchJobStatus(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainAsyncJob asyncJob, +int qemuMigrationFetchJobStatus(virDomainObjPtr vm, qemuDomainJobInfoPtr jobInfo); int qemuMigrationErrorInit(virQEMUDriverPtr driver); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 2bf69d5..68a964e 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -545,9 +545,7 @@ qemuProcessFakeReboot(void *opaque) if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_CRASHED) reason = VIR_DOMAIN_RUNNING_CRASHED; - if (qemuProcessStartCPUs(driver, vm, NULL, - reason, - QEMU_ASYNC_JOB_NONE) < 0) { + if (qemuProcessStartCPUs(driver, vm, NULL, reason) < 0) { if (virGetLastError() == NULL) virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("resume operation failed")); @@ -1660,7 +1658,7 @@ qemuProcessMonitorLogFree(void *opaque) } static int -qemuConnectMonitor(virQEMUDriverPtr driver, virDomainObjPtr vm, int asyncJob, +qemuConnectMonitor(virQEMUDriverPtr driver, virDomainObjPtr vm, qemuDomainLogContextPtr logCtxt) { qemuDomainObjPrivatePtr priv = vm->privateData; @@ -1717,8 +1715,7 @@ qemuConnectMonitor(virQEMUDriverPtr driver, virDomainObjPtr vm, int asyncJob, } - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - return -1; + qemuDomainObjEnterMonitor(vm); if (qemuMonitorSetCapabilities(priv->mon) < 0) goto cleanup; @@ -1965,15 +1962,13 @@ qemuProcessRefreshChannelVirtioState(virQEMUDriverPtr driver, int qemuRefreshVirtioChannelState(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainAsyncJob asyncJob) + virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv = vm->privateData; virHashTablePtr info = NULL; int ret = -1; - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - goto cleanup; + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorGetChardevInfo(priv->mon, &info); if (qemuDomainObjExitMonitor(vm) < 0) @@ -2026,9 +2021,7 @@ qemuRefreshRTC(virDomainObjPtr vm) } int -qemuProcessRefreshBalloonState(virQEMUDriverPtr driver, - virDomainObjPtr vm, - int asyncJob) +qemuProcessRefreshBalloonState(virDomainObjPtr vm) { unsigned long long balloon; int rc; @@ -2040,8 +2033,7 @@ qemuProcessRefreshBalloonState(virQEMUDriverPtr driver, return 0; } - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - return -1; + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorGetBalloonInfo(qemuDomainGetMonitor(vm), &balloon); if (qemuDomainObjExitMonitor(vm) < 0 || rc < 0) @@ -2056,7 +2048,6 @@ qemuProcessRefreshBalloonState(virQEMUDriverPtr driver, static int qemuProcessWaitForMonitor(virQEMUDriverPtr driver, virDomainObjPtr vm, - int asyncJob, virQEMUCapsPtr qemuCaps, qemuDomainLogContextPtr logCtxt) { @@ -2065,7 +2056,7 @@ qemuProcessWaitForMonitor(virQEMUDriverPtr driver, qemuDomainObjPrivatePtr priv; VIR_DEBUG("Connect monitor to %p '%s'", vm, vm->def->name); - if (qemuConnectMonitor(driver, vm, asyncJob, logCtxt) < 0) + if (qemuConnectMonitor(driver, vm, logCtxt) < 0) goto cleanup; /* Try to get the pty path mappings again via the monitor. This is much more @@ -2073,8 +2064,7 @@ qemuProcessWaitForMonitor(virQEMUDriverPtr driver, * Note that the monitor itself can be on a pty, so we still need to try the * log output method. */ priv = vm->privateData; - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - goto cleanup; + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorGetChardevInfo(priv->mon, &info); VIR_DEBUG("qemuMonitorGetChardevInfo returned %i", ret); if (qemuDomainObjExitMonitor(vm) < 0) @@ -2104,9 +2094,7 @@ qemuProcessWaitForMonitor(virQEMUDriverPtr driver, static int -qemuProcessDetectIOThreadPIDs(virQEMUDriverPtr driver, - virDomainObjPtr vm, - int asyncJob) +qemuProcessDetectIOThreadPIDs(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv = vm->privateData; qemuMonitorIOThreadInfoPtr *iothreads = NULL; @@ -2142,8 +2130,7 @@ qemuProcessDetectIOThreadPIDs(virQEMUDriverPtr driver, } /* Get the list of IOThreads from qemu */ - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - goto cleanup; + qemuDomainObjEnterMonitor(vm); niothreads = qemuMonitorGetIOThreads(priv->mon, &iothreads); if (qemuDomainObjExitMonitor(vm) < 0) goto cleanup; @@ -2249,9 +2236,7 @@ qemuProcessInitCpuAffinity(virDomainObjPtr vm) /* set link states to down on interfaces at qemu start */ static int -qemuProcessSetLinkStates(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainAsyncJob asyncJob) +qemuProcessSetLinkStates(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv = vm->privateData; virDomainDefPtr def = vm->def; @@ -2259,8 +2244,7 @@ qemuProcessSetLinkStates(virQEMUDriverPtr driver, int ret = -1; int rv; - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - return -1; + qemuDomainObjEnterMonitor(vm); for (i = 0; i < def->nnets; i++) { if (def->nets[i]->linkstate == VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN) { @@ -2421,8 +2405,7 @@ qemuProcessSetupEmulator(virDomainObjPtr vm) static int qemuProcessInitPasswords(virConnectPtr conn, virQEMUDriverPtr driver, - virDomainObjPtr vm, - int asyncJob) + virDomainObjPtr vm) { int ret = 0; qemuDomainObjPrivatePtr priv = vm->privateData; @@ -2437,14 +2420,12 @@ qemuProcessInitPasswords(virConnectPtr conn, ret = qemuDomainChangeGraphicsPasswords(driver, vm, VIR_DOMAIN_GRAPHICS_TYPE_VNC, &graphics->data.vnc.auth, - cfg->vncPassword, - asyncJob); + cfg->vncPassword); } else if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { ret = qemuDomainChangeGraphicsPasswords(driver, vm, VIR_DOMAIN_GRAPHICS_TYPE_SPICE, &graphics->data.spice.auth, - cfg->spicePassword, - asyncJob); + cfg->spicePassword); } if (ret < 0) @@ -2473,8 +2454,7 @@ qemuProcessInitPasswords(virConnectPtr conn, VIR_FREE(alias); if (!(alias = qemuAliasFromDisk(vm->def->disks[i]))) goto cleanup; - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - goto cleanup; + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorSetDrivePassphrase(priv->mon, alias, secret); if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; @@ -2539,8 +2519,7 @@ qemuProcessCleanupChardevDevice(virDomainDefPtr def ATTRIBUTE_UNUSED, */ static int qemuProcessUpdateVideoRamSize(virQEMUDriverPtr driver, - virDomainObjPtr vm, - int asyncJob) + virDomainObjPtr vm) { int ret = -1; ssize_t i; @@ -2548,8 +2527,7 @@ qemuProcessUpdateVideoRamSize(virQEMUDriverPtr driver, virDomainVideoDefPtr video = NULL; virQEMUDriverConfigPtr cfg = NULL; - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - return -1; + qemuDomainObjEnterMonitor(vm); for (i = 0; i < vm->def->nvideos; i++) { video = vm->def->videos[i]; @@ -2705,8 +2683,7 @@ qemuProcessPrepareMonitorChr(virDomainChrSourceDefPtr monConfig, */ int qemuProcessStartCPUs(virQEMUDriverPtr driver, virDomainObjPtr vm, - virConnectPtr conn, virDomainRunningReason reason, - qemuDomainAsyncJob asyncJob) + virConnectPtr conn, virDomainRunningReason reason) { int ret = -1; qemuDomainObjPrivatePtr priv = vm->privateData; @@ -2727,8 +2704,7 @@ qemuProcessStartCPUs(virQEMUDriverPtr driver, virDomainObjPtr vm, } VIR_FREE(priv->lockState); - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - goto release; + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorStartCPUs(priv->mon, conn); if (qemuDomainObjExitMonitor(vm) < 0) @@ -2753,16 +2729,14 @@ qemuProcessStartCPUs(virQEMUDriverPtr driver, virDomainObjPtr vm, int qemuProcessStopCPUs(virQEMUDriverPtr driver, virDomainObjPtr vm, - virDomainPausedReason reason, - qemuDomainAsyncJob asyncJob) + virDomainPausedReason reason) { int ret = -1; qemuDomainObjPrivatePtr priv = vm->privateData; VIR_FREE(priv->lockState); - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - goto cleanup; + qemuDomainObjEnterMonitor(vm); ret = qemuMonitorStopCPUs(priv->mon); if (qemuDomainObjExitMonitor(vm) < 0) @@ -2926,8 +2900,7 @@ qemuProcessRecoverMigrationIn(virQEMUDriverPtr driver, VIR_DEBUG("Incoming migration finished, resuming domain %s", vm->def->name); if (qemuProcessStartCPUs(driver, vm, conn, - VIR_DOMAIN_RUNNING_UNPAUSED, - QEMU_ASYNC_JOB_NONE) < 0) { + VIR_DOMAIN_RUNNING_UNPAUSED) < 0) { VIR_WARN("Could not resume domain %s", vm->def->name); } break; @@ -3031,8 +3004,7 @@ qemuProcessRecoverMigrationOut(virQEMUDriverPtr driver, (reason == VIR_DOMAIN_PAUSED_MIGRATION || reason == VIR_DOMAIN_PAUSED_UNKNOWN)) { if (qemuProcessStartCPUs(driver, vm, conn, - VIR_DOMAIN_RUNNING_UNPAUSED, - QEMU_ASYNC_JOB_NONE) < 0) { + VIR_DOMAIN_RUNNING_UNPAUSED) < 0) { VIR_WARN("Could not resume domain %s", vm->def->name); } } @@ -3084,8 +3056,7 @@ qemuProcessRecoverJob(virQEMUDriverPtr driver, reason == VIR_DOMAIN_PAUSED_SNAPSHOT) || reason == VIR_DOMAIN_PAUSED_UNKNOWN)) { if (qemuProcessStartCPUs(driver, vm, conn, - VIR_DOMAIN_RUNNING_UNPAUSED, - QEMU_ASYNC_JOB_NONE) < 0) { + VIR_DOMAIN_RUNNING_UNPAUSED) < 0) { VIR_WARN("Could not resume domain '%s' after migration to file", vm->def->name); } @@ -3155,7 +3126,7 @@ qemuProcessUpdateDevices(virQEMUDriverPtr driver, old = priv->qemuDevices; priv->qemuDevices = NULL; - if (qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE) < 0) + if (qemuDomainUpdateDeviceList(vm) < 0) goto cleanup; qemuDevices = (const char **) priv->qemuDevices; @@ -3296,7 +3267,7 @@ qemuProcessReconnect(void *opaque) VIR_DEBUG("Reconnect monitor to %p '%s'", obj, obj->def->name); /* XXX check PID liveliness & EXE path */ - if (qemuConnectMonitor(driver, obj, QEMU_ASYNC_JOB_NONE, NULL) < 0) + if (qemuConnectMonitor(driver, obj, NULL) < 0) goto error; if (qemuHostdevUpdateActiveDomainDevices(driver, obj->def) < 0) @@ -3375,7 +3346,7 @@ qemuProcessReconnect(void *opaque) ignore_value(virSecurityManagerCheckAllLabel(driver->securityManager, obj->def)); - if (qemuDomainRefreshVcpuInfo(driver, obj, QEMU_ASYNC_JOB_NONE, true) < 0) + if (qemuDomainRefreshVcpuInfo(obj, true) < 0) goto error; if (virSecurityManagerReserveLabel(driver->securityManager, obj->def, obj->pid) < 0) @@ -3387,16 +3358,16 @@ qemuProcessReconnect(void *opaque) if (qemuProcessFiltersInstantiate(obj->def)) goto error; - if (qemuProcessRefreshDisks(driver, obj, QEMU_ASYNC_JOB_NONE) < 0) + if (qemuProcessRefreshDisks(obj) < 0) goto error; - if (qemuRefreshVirtioChannelState(driver, obj, QEMU_ASYNC_JOB_NONE) < 0) + if (qemuRefreshVirtioChannelState(driver, obj) < 0) goto error; /* If querying of guest's RTC failed, report error, but do not kill the domain. */ qemuRefreshRTC(obj); - if (qemuProcessRefreshBalloonState(driver, obj, QEMU_ASYNC_JOB_NONE) < 0) + if (qemuProcessRefreshBalloonState(obj) < 0) goto error; if (qemuProcessRecoverJob(driver, obj, conn, &oldjob) < 0) @@ -3466,7 +3437,7 @@ qemuProcessReconnect(void *opaque) * thread didn't have a chance to start playing with the domain yet * (it's all we can do anyway). */ - qemuProcessStop(driver, obj, state, QEMU_ASYNC_JOB_NONE, stopFlags); + qemuProcessStop(driver, obj, state, stopFlags); } goto cleanup; } @@ -3509,8 +3480,7 @@ qemuProcessReconnectHelper(virDomainObjPtr obj, * is no thread that could be doing anything else with the same domain * object. */ - qemuProcessStop(src->driver, obj, VIR_DOMAIN_SHUTOFF_FAILED, - QEMU_ASYNC_JOB_NONE, 0); + qemuProcessStop(src->driver, obj, VIR_DOMAIN_SHUTOFF_FAILED, 0); qemuDomainRemoveInactive(src->driver, obj); virDomainObjEndAPI(&obj); @@ -3683,9 +3653,7 @@ qemuValidateCpuCount(virDomainDefPtr def, static bool -qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, - virDomainObjPtr vm, - int asyncJob) +qemuProcessVerifyGuestCPU(virDomainObjPtr vm) { virDomainDefPtr def = vm->def; virArch arch = def->os.arch; @@ -3698,8 +3666,7 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, switch (arch) { case VIR_ARCH_I686: case VIR_ARCH_X86_64: - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - return false; + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorGetGuestCPU(priv->mon, arch, &guestcpu); if (qemuDomainObjExitMonitor(vm) < 0) return false; @@ -4327,9 +4294,7 @@ qemuProcessSetupRawIO(virQEMUDriverPtr driver, static int -qemuProcessSetupBalloon(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainAsyncJob asyncJob) +qemuProcessSetupBalloon(virDomainObjPtr vm) { unsigned long long balloon = vm->def->mem.cur_balloon; qemuDomainObjPrivatePtr priv = vm->privateData; @@ -4338,8 +4303,7 @@ qemuProcessSetupBalloon(virQEMUDriverPtr driver, if (!virDomainDefHasMemballoon(vm->def)) return 0; - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - goto cleanup; + qemuDomainObjEnterMonitor(vm); if (vm->def->memballoon->period) qemuMonitorSetMemoryStatsPeriod(priv->mon, vm->def->memballoon, @@ -4601,7 +4565,6 @@ qemuProcessStartValidate(virQEMUDriverPtr driver, int qemuProcessInit(virQEMUDriverPtr driver, virDomainObjPtr vm, - qemuDomainAsyncJob asyncJob, bool migration, unsigned int flags) { @@ -4673,7 +4636,7 @@ qemuProcessInit(virQEMUDriverPtr driver, stopFlags = VIR_QEMU_PROCESS_STOP_NO_RELABEL; if (migration) stopFlags |= VIR_QEMU_PROCESS_STOP_MIGRATED; - qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, asyncJob, stopFlags); + qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, stopFlags); goto cleanup; } @@ -4940,9 +4903,7 @@ qemuProcessVcpusSortOrder(const void *a, static int -qemuProcessSetupHotpluggableVcpus(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainAsyncJob asyncJob) +qemuProcessSetupHotpluggableVcpus(virDomainObjPtr vm) { unsigned int maxvcpus = virDomainDefGetVcpusMax(vm->def); qemuDomainObjPrivatePtr priv = vm->privateData; @@ -4988,8 +4949,7 @@ qemuProcessSetupHotpluggableVcpus(virQEMUDriverPtr driver, if (!(vcpuprops = qemuBuildHotpluggableCPUProps(vcpu))) goto cleanup; - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - goto cleanup; + qemuDomainObjEnterMonitor(vm); rc = qemuMonitorAddDeviceArgs(qemuDomainGetMonitor(vm), vcpuprops); vcpuprops = NULL; @@ -5547,14 +5507,14 @@ qemuProcessLaunch(virConnectPtr conn, goto cleanup; VIR_DEBUG("Waiting for monitor to show up"); - if (qemuProcessWaitForMonitor(driver, vm, asyncJob, priv->qemuCaps, logCtxt) < 0) + if (qemuProcessWaitForMonitor(driver, vm, priv->qemuCaps, logCtxt) < 0) goto cleanup; if (qemuConnectAgent(driver, vm) < 0) goto cleanup; VIR_DEBUG("Detecting if required emulator features are present"); - if (!qemuProcessVerifyGuestCPU(driver, vm, asyncJob)) + if (!qemuProcessVerifyGuestCPU(vm)) goto cleanup; VIR_DEBUG("Setting up post-init cgroup restrictions"); @@ -5563,18 +5523,18 @@ qemuProcessLaunch(virConnectPtr conn, VIR_DEBUG("setting up hotpluggable cpus"); if (qemuDomainHasHotpluggableStartupVcpus(vm->def)) { - if (qemuDomainRefreshVcpuInfo(driver, vm, asyncJob, false) < 0) + if (qemuDomainRefreshVcpuInfo(vm, false) < 0) goto cleanup; if (qemuProcessValidateHotpluggableVcpus(vm->def) < 0) goto cleanup; - if (qemuProcessSetupHotpluggableVcpus(driver, vm, asyncJob) < 0) + if (qemuProcessSetupHotpluggableVcpus(vm) < 0) goto cleanup; } VIR_DEBUG("Refreshing VCPU info"); - if (qemuDomainRefreshVcpuInfo(driver, vm, asyncJob, false) < 0) + if (qemuDomainRefreshVcpuInfo(vm, false) < 0) goto cleanup; if (qemuDomainValidateVcpuInfo(vm) < 0) @@ -5583,7 +5543,7 @@ qemuProcessLaunch(virConnectPtr conn, qemuDomainVcpuPersistOrder(vm->def); VIR_DEBUG("Detecting IOThread PIDs"); - if (qemuProcessDetectIOThreadPIDs(driver, vm, asyncJob) < 0) + if (qemuProcessDetectIOThreadPIDs(vm) < 0) goto cleanup; VIR_DEBUG("Setting global CPU cgroup (if required)"); @@ -5599,41 +5559,40 @@ qemuProcessLaunch(virConnectPtr conn, goto cleanup; VIR_DEBUG("Setting any required VM passwords"); - if (qemuProcessInitPasswords(conn, driver, vm, asyncJob) < 0) + if (qemuProcessInitPasswords(conn, driver, vm) < 0) goto cleanup; /* set default link states */ /* qemu doesn't support setting this on the command line, so * enter the monitor */ VIR_DEBUG("Setting network link states"); - if (qemuProcessSetLinkStates(driver, vm, asyncJob) < 0) + if (qemuProcessSetLinkStates(vm) < 0) goto cleanup; VIR_DEBUG("Fetching list of active devices"); - if (qemuDomainUpdateDeviceList(driver, vm, asyncJob) < 0) + if (qemuDomainUpdateDeviceList(vm) < 0) goto cleanup; VIR_DEBUG("Updating info of memory devices"); - if (qemuDomainUpdateMemoryDeviceInfo(driver, vm, asyncJob) < 0) + if (qemuDomainUpdateMemoryDeviceInfo(vm) < 0) goto cleanup; VIR_DEBUG("Setting initial memory amount"); - if (qemuProcessSetupBalloon(driver, vm, asyncJob) < 0) + if (qemuProcessSetupBalloon(vm) < 0) goto cleanup; /* Since CPUs were not started yet, the balloon could not return the memory * to the host and thus cur_balloon needs to be updated so that GetXMLdesc * and friends return the correct size in case they can't grab the job */ - if (!incoming && !snapshot && - qemuProcessRefreshBalloonState(driver, vm, asyncJob) < 0) + if (!incoming && !snapshot && qemuProcessRefreshBalloonState(vm) < 0) goto cleanup; VIR_DEBUG("Detecting actual memory size for video device"); - if (qemuProcessUpdateVideoRamSize(driver, vm, asyncJob) < 0) + if (qemuProcessUpdateVideoRamSize(driver, vm) < 0) goto cleanup; VIR_DEBUG("Updating disk data"); - if (qemuProcessRefreshDisks(driver, vm, asyncJob) < 0) + if (qemuProcessRefreshDisks(vm) < 0) goto cleanup; if (flags & VIR_QEMU_PROCESS_START_AUTODESTROY && @@ -5662,7 +5621,6 @@ int qemuProcessFinishStartup(virConnectPtr conn, virQEMUDriverPtr driver, virDomainObjPtr vm, - qemuDomainAsyncJob asyncJob, bool startCPUs, virDomainPausedReason pausedReason) { @@ -5672,8 +5630,7 @@ qemuProcessFinishStartup(virConnectPtr conn, if (startCPUs) { VIR_DEBUG("Starting domain CPUs"); if (qemuProcessStartCPUs(driver, vm, conn, - VIR_DOMAIN_RUNNING_BOOTED, - asyncJob) < 0) { + VIR_DOMAIN_RUNNING_BOOTED) < 0) { if (!virGetLastError()) virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("resume operation failed")); @@ -5734,7 +5691,7 @@ qemuProcessStart(virConnectPtr conn, if (!migrateFrom && !snapshot) flags |= VIR_QEMU_PROCESS_START_NEW; - if (qemuProcessInit(driver, vm, asyncJob, !!migrateFrom, flags) < 0) + if (qemuProcessInit(driver, vm, !!migrateFrom, flags) < 0) goto cleanup; if (migrateFrom) { @@ -5763,7 +5720,7 @@ qemuProcessStart(virConnectPtr conn, qemuMigrationRunIncoming(driver, vm, incoming->deferredURI, asyncJob) < 0) goto stop; - if (qemuProcessFinishStartup(conn, driver, vm, asyncJob, + if (qemuProcessFinishStartup(conn, driver, vm, !(flags & VIR_QEMU_PROCESS_START_PAUSED), incoming ? VIR_DOMAIN_PAUSED_MIGRATION : @@ -5789,7 +5746,7 @@ qemuProcessStart(virConnectPtr conn, stopFlags |= VIR_QEMU_PROCESS_STOP_MIGRATED; if (priv->mon) qemuMonitorSetDomainLog(priv->mon, NULL, NULL, NULL); - qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, asyncJob, stopFlags); + qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, stopFlags); goto cleanup; } @@ -5813,7 +5770,7 @@ qemuProcessCreatePretendCmd(virConnectPtr conn, flags |= VIR_QEMU_PROCESS_START_PRETEND; flags |= VIR_QEMU_PROCESS_START_NEW; - if (qemuProcessInit(driver, vm, QEMU_ASYNC_JOB_NONE, !!migrateURI, flags) < 0) + if (qemuProcessInit(driver, vm, !!migrateURI, flags) < 0) goto cleanup; if (qemuProcessPrepareDomain(conn, driver, vm, flags) < 0) @@ -5913,7 +5870,6 @@ qemuProcessBeginStopJob(virQEMUDriverPtr driver, void qemuProcessStop(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainShutoffReason reason, - qemuDomainAsyncJob asyncJob ATTRIBUTE_UNUSED, unsigned int flags) { int ret; @@ -6348,21 +6304,21 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED, qemuDomainObjTaint(driver, vm, VIR_DOMAIN_TAINT_EXTERNAL_LAUNCH, logCtxt); VIR_DEBUG("Waiting for monitor to show up"); - if (qemuProcessWaitForMonitor(driver, vm, QEMU_ASYNC_JOB_NONE, priv->qemuCaps, NULL) < 0) + if (qemuProcessWaitForMonitor(driver, vm, priv->qemuCaps, NULL) < 0) goto error; if (qemuConnectAgent(driver, vm) < 0) goto error; VIR_DEBUG("Detecting VCPU PIDs"); - if (qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE, false) < 0) + if (qemuDomainRefreshVcpuInfo(vm, false) < 0) goto error; if (qemuDomainValidateVcpuInfo(vm) < 0) goto error; VIR_DEBUG("Detecting IOThread PIDs"); - if (qemuProcessDetectIOThreadPIDs(driver, vm, QEMU_ASYNC_JOB_NONE) < 0) + if (qemuProcessDetectIOThreadPIDs(vm) < 0) goto error; VIR_DEBUG("Getting initial memory amount"); @@ -6473,8 +6429,7 @@ qemuProcessAutoDestroy(virDomainObjPtr dom, if (qemuProcessBeginStopJob(driver, dom, QEMU_JOB_DESTROY, true) < 0) goto cleanup; - qemuProcessStop(driver, dom, VIR_DOMAIN_SHUTOFF_DESTROYED, - QEMU_ASYNC_JOB_NONE, stopFlags); + qemuProcessStop(driver, dom, VIR_DOMAIN_SHUTOFF_DESTROYED, stopFlags); virDomainAuditStop(dom, "destroyed"); event = virDomainEventLifecycleNewFromObj(dom, @@ -6522,20 +6477,17 @@ bool qemuProcessAutoDestroyActive(virQEMUDriverPtr driver, int -qemuProcessRefreshDisks(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainAsyncJob asyncJob) +qemuProcessRefreshDisks(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv = vm->privateData; virHashTablePtr table = NULL; int ret = -1; size_t i; - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) { - table = qemuMonitorGetBlockInfo(priv->mon); - if (qemuDomainObjExitMonitor(vm) < 0) - goto cleanup; - } + qemuDomainObjEnterMonitor(vm); + table = qemuMonitorGetBlockInfo(priv->mon); + if (qemuDomainObjExitMonitor(vm) < 0) + goto cleanup; if (!table) goto cleanup; diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 21f3b0c..5f10d6e 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -31,12 +31,10 @@ int qemuProcessPrepareMonitorChr(virDomainChrSourceDefPtr monConfig, int qemuProcessStartCPUs(virQEMUDriverPtr driver, virDomainObjPtr vm, virConnectPtr conn, - virDomainRunningReason reason, - qemuDomainAsyncJob asyncJob); + virDomainRunningReason reason); int qemuProcessStopCPUs(virQEMUDriverPtr driver, virDomainObjPtr vm, - virDomainPausedReason reason, - qemuDomainAsyncJob asyncJob); + virDomainPausedReason reason); void qemuProcessAutostartAll(virQEMUDriverPtr driver); void qemuProcessReconnectAll(virConnectPtr conn, virQEMUDriverPtr driver); @@ -92,7 +90,6 @@ virCommandPtr qemuProcessCreatePretendCmd(virConnectPtr conn, int qemuProcessInit(virQEMUDriverPtr driver, virDomainObjPtr vm, - qemuDomainAsyncJob asyncJob, bool migration, unsigned int flags); @@ -117,7 +114,6 @@ int qemuProcessLaunch(virConnectPtr conn, int qemuProcessFinishStartup(virConnectPtr conn, virQEMUDriverPtr driver, virDomainObjPtr vm, - qemuDomainAsyncJob asyncJob, bool startCPUs, virDomainPausedReason pausedReason); @@ -133,7 +129,6 @@ int qemuProcessBeginStopJob(virQEMUDriverPtr driver, void qemuProcessStop(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainShutoffReason reason, - qemuDomainAsyncJob asyncJob, unsigned int flags); int qemuProcessAttach(virConnectPtr conn, @@ -180,15 +175,10 @@ int qemuProcessSetupIOThread(virDomainObjPtr vm, virDomainIOThreadIDDefPtr iothread); int qemuRefreshVirtioChannelState(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainAsyncJob asyncJob); + virDomainObjPtr vm); -int qemuProcessRefreshBalloonState(virQEMUDriverPtr driver, - virDomainObjPtr vm, - int asyncJob); +int qemuProcessRefreshBalloonState(virDomainObjPtr vm); -int qemuProcessRefreshDisks(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainAsyncJob asyncJob); +int qemuProcessRefreshDisks(virDomainObjPtr vm); #endif /* __QEMU_PROCESS_H__ */ -- 1.8.3.1

On Mon, Nov 28, 2016 at 11:15:41 +0300, Nikolay Shirokovskiy wrote:
Instead I suggest to serialize qemu monitor commands.
That won't be possible. There are a few APIs that call multiple commands and expect the VM not to change in between. Thus they rely on nested jobs. See migration and snapshot code (btw, the two most complex parts of libvirt).
My original motivation is to prepare job exclusion code to add agent jobs. This job is a special job to operate on guest agent only so first it can be run in parallel with sync, async and nested jobs and second it should not block any
That is possible. The async jobs allow for query jobs to be run while they are executed you need to properly configure them.
qemu monitor job at all. Eventually I want to move from a lot of different types of jobs to just a job with some kind of matrix which describes what jobs can run in a parallel. As a first step I want to drop nested jobs.
I don't think you will be able to do this in steps. Nested jobs have a vital functions and unless you replace the mechanism or overhaul all the code that is doing nested jobs you won't be able to guarantee that the state of the objects are as the code expects. Doin a ful N*N matrix of possible parallel operations will be very hard to maintain. You will need to group them together in a way so that we don't have to deal with the quadratic complexity. How are you expecting to do this?
AFAIU *main* nested job purpuse is to serialize requests to monitor from async jobs and allowed sync jobs as monitor does not do it by himself now. Strictly
No, the main purpose is to allow to call multiple monitor commands while you are guaranteed that something did not change the VM state and thus invalidate the complex operation you are trying to execute.
speaking this assertion is rather rough because nested jobs and sync jobs serialized at job level and thus chunks of code that serialized differ from case when only monitor requests are serialized. Nevertheless IFAIU this part of libvirt is not strict too. We have a lot of query commands and async commands that can execute in parallel and have no definition of what query job or async job are. Thus it is not clear is this code correct or not. So the same argument
Certainly it's more correct this way than dropping it without replacement.
is applicable to new approach: query jobs are safe to be called during async jobs. (Except that new approach opens situation when async job interrupts
Some of qemu monitor commands block on execution. The job mechanism prevents the second query call to get stuck waiting forever for the job to finish by doing a timed wait.
query job itself but it generally not clear how this can break query job). On this path job became high level concept which I think it should be. Also we drop boring passing of current async job which we need only for safety check deep down below the stack. We drop driver passing for nested jobs which I guess we really don't need to pass at all as we need it only to check queue size and nested job probably should skip this check.
I did not get what you wanted to say here.
The diff stat looks large but most of code is dumb renaming or dropping unused parameter in patches 4 and 5. To reduce risk of introducing an error on this tedious task I used sed and perl where I can.
I ran only a simple test with this series of quering a domain during its migration.
That is a weak test for doing such a complex change. I'd suggest you run parallel migrations and snapshot to see if it works. You need to run operations that change the VM configuration. I don't think we can do this with a complete overhaul of snapshots, migration and a few others that actually have an expectation of the VM object not changing while we are in an async job. Peter

On 28.11.2016 11:56, Peter Krempa wrote:
On Mon, Nov 28, 2016 at 11:15:41 +0300, Nikolay Shirokovskiy wrote:
Instead I suggest to serialize qemu monitor commands.
That won't be possible. There are a few APIs that call multiple commands and expect the VM not to change in between. Thus they rely on nested jobs. See migration and snapshot code (btw, the two most complex parts of libvirt).
But I suggest to drop only nested jobs and use other means to accomplish the same goal. The jobs in general stays as they are after this series. Sync jobs are mutually exclusive, async jobs are mutually exclusive, query (and some other "safe") sync jobs can run in parallel with async etc. The only thing is change how the last are executed in parallels. Probably I'd better use 'replace' instead of 'drop'.
My original motivation is to prepare job exclusion code to add agent jobs. This job is a special job to operate on guest agent only so first it can be run in parallel with sync, async and nested jobs and second it should not block any
That is possible. The async jobs allow for query jobs to be run while they are executed you need to properly configure them.
This is not enough. I don't want agent jobs to block any current async or sync jobs from executing. This is not possible with current code.
qemu monitor job at all. Eventually I want to move from a lot of different types of jobs to just a job with some kind of matrix which describes what jobs can run in a parallel. As a first step I want to drop nested jobs.
I don't think you will be able to do this in steps. Nested jobs have a vital functions and unless you replace the mechanism or overhaul all the code that is doing nested jobs you won't be able to guarantee that the state of the objects are as the code expects.
Gosh, why i used 'drop', it is 'replace'. I replace serializing thru nested jobs and sync jobs with just serializing at monitor level.
Doin a ful N*N matrix of possible parallel operations will be very hard to maintain. You will need to group them together in a way so that we don't have to deal with the quadratic complexity. How are you expecting to do this?
This matrix exists already and it based of job types not every individual job itsel. It is just not apparent in code. Here it's sample: Q M A Q x x o M x x x A x x x Q - query job M - modify job A - async job x - inpossible o - possible This matrix shows can jobs run in parallel. It is assymetrical now, you can run query while async job is executing but can not start async job while in query. This assymetric is probably current implementation restrictment.
AFAIU *main* nested job purpuse is to serialize requests to monitor from async jobs and allowed sync jobs as monitor does not do it by himself now. Strictly
No, the main purpose is to allow to call multiple monitor commands while you are guaranteed that something did not change the VM state and thus invalidate the complex operation you are trying to execute.
For this reason in matrix above AM, AX are impossible. AQ are possible and it is decided by matrix not nested jobs.
speaking this assertion is rather rough because nested jobs and sync jobs serialized at job level and thus chunks of code that serialized differ from case when only monitor requests are serialized. Nevertheless IFAIU this part of libvirt is not strict too. We have a lot of query commands and async commands that can execute in parallel and have no definition of what query job or async job are. Thus it is not clear is this code correct or not. So the same argument
Certainly it's more correct this way than dropping it without replacement.
is applicable to new approach: query jobs are safe to be called during async jobs. (Except that new approach opens situation when async job interrupts
Some of qemu monitor commands block on execution. The job mechanism prevents the second query call to get stuck waiting forever for the job to finish by doing a timed wait.
This will not change. Monitor serialization has timeout too.
query job itself but it generally not clear how this can break query job).
On this path job became high level concept which I think it should be. Also we drop boring passing of current async job which we need only for safety check deep down below the stack. We drop driver passing for nested jobs which I guess we really don't need to pass at all as we need it only to check queue size and nested job probably should skip this check.
I did not get what you wanted to say here.
Code becomes more simple and clear.
The diff stat looks large but most of code is dumb renaming or dropping unused parameter in patches 4 and 5. To reduce risk of introducing an error on this tedious task I used sed and perl where I can.
I ran only a simple test with this series of quering a domain during its migration.
That is a weak test for doing such a complex change. I'd suggest you run parallel migrations and snapshot to see if it works. You need to run operations that change the VM configuration.
I don't need event test it as I don't touch code that make them mutually exclusive.
I don't think we can do this with a complete overhaul of snapshots, migration and a few others that actually have an expectation of the VM object not changing while we are in an async job.
Please, reevalute this series, I don't unrerstand how you see this series that radical. Thing stay the same, async jobs are still mutually exclusive with everything except queries basically. I don't change this. Nikolay
participants (2)
-
Nikolay Shirokovskiy
-
Peter Krempa