diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 320a35c6ee3a3654087d40e6973200cb41d8c438..d3ad192064e5ffe9b2d3d0e77b2dbd1807e86866 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -696,11 +696,17 @@ qemuDomainObjDiscardAsyncJob(struct qemud_driver *driver, virDomainObjPtr obj) } static bool -qemuDomainJobAllowed(qemuDomainObjPrivatePtr priv, enum qemuDomainJob job) +qemuDomainNestedJobAllowed(qemuDomainObjPrivatePtr priv, enum qemuDomainJob job) { return !priv->job.asyncJob || (priv->job.mask & JOB_MASK(job)) != 0; } +bool +qemuDomainJobAllowed(qemuDomainObjPrivatePtr priv, enum qemuDomainJob job) +{ + return !priv->job.active && qemuDomainNestedJobAllowed(priv, job); +} + /* Give up waiting for mutex after 30 seconds */ #define QEMU_JOB_WAIT_TIME (1000ull * 30) @@ -736,7 +742,7 @@ retry: goto error; } - while (!nested && !qemuDomainJobAllowed(priv, job)) { + while (!nested && !qemuDomainNestedJobAllowed(priv, job)) { if (virCondWaitUntil(&priv->job.asyncCond, &obj->lock, then) < 0) goto error; } @@ -748,7 +754,7 @@ retry: /* 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 && !qemuDomainJobAllowed(priv, job)) + if (!nested && !qemuDomainNestedJobAllowed(priv, job)) goto retry; qemuDomainObjResetJob(priv); diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 3b09419f99556ae4d85838e48d64da42e44aa669..cdf1375d40f5bb01f6d20053b7cad558fbab77bf 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -277,4 +277,6 @@ void qemuDomainSetFakeReboot(struct qemud_driver *driver, virDomainObjPtr vm, bool value); +bool qemuDomainJobAllowed(qemuDomainObjPrivatePtr priv, + enum qemuDomainJob job); #endif /* __QEMU_DOMAIN_H__ */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0f18983220bd99736208f9a9038924242ec456e5..dc34e1d422fa6f80da9dd61767c1f43a200dc74b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2068,7 +2068,7 @@ static int qemudDomainGetInfo(virDomainPtr dom, if ((vm->def->memballoon != NULL) && (vm->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE)) { info->memory = vm->def->mem.max_balloon; - } else if (!priv->job.active) { + } else if (qemuDomainJobAllowed(priv, QEMU_JOB_QUERY)) { if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; if (!virDomainObjIsActive(vm)) @@ -4400,7 +4400,7 @@ static char *qemuDomainGetXMLDesc(virDomainPtr dom, qemuDomainObjPrivatePtr priv = vm->privateData; /* Don't delay if someone's using the monitor, just use * existing most recent data instead */ - if (!priv->job.active) { + if (qemuDomainJobAllowed(priv, QEMU_JOB_QUERY)) { if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup;