mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
libxl: use virDomainJob enum instead of libxlDomainJob
Signed-off-by: Kristina Hanicova <khanicov@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
096138851c
commit
44f0b63dbc
@ -44,14 +44,6 @@
|
||||
|
||||
VIR_LOG_INIT("libxl.libxl_domain");
|
||||
|
||||
VIR_ENUM_IMPL(libxlDomainJob,
|
||||
LIBXL_JOB_LAST,
|
||||
"none",
|
||||
"query",
|
||||
"destroy",
|
||||
"modify",
|
||||
);
|
||||
|
||||
|
||||
static int
|
||||
libxlDomainObjInitJob(libxlDomainObjPrivate *priv)
|
||||
@ -71,7 +63,7 @@ libxlDomainObjResetJob(libxlDomainObjPrivate *priv)
|
||||
{
|
||||
struct libxlDomainJobObj *job = &priv->job;
|
||||
|
||||
job->active = LIBXL_JOB_NONE;
|
||||
job->active = VIR_JOB_NONE;
|
||||
job->owner = 0;
|
||||
}
|
||||
|
||||
@ -97,7 +89,7 @@ libxlDomainObjFreeJob(libxlDomainObjPrivate *priv)
|
||||
int
|
||||
libxlDomainObjBeginJob(libxlDriverPrivate *driver G_GNUC_UNUSED,
|
||||
virDomainObj *obj,
|
||||
enum libxlDomainJob job)
|
||||
virDomainJob job)
|
||||
{
|
||||
libxlDomainObjPrivate *priv = obj->privateData;
|
||||
unsigned long long now;
|
||||
@ -109,14 +101,14 @@ libxlDomainObjBeginJob(libxlDriverPrivate *driver G_GNUC_UNUSED,
|
||||
|
||||
while (priv->job.active) {
|
||||
VIR_DEBUG("Wait normal job condition for starting job: %s",
|
||||
libxlDomainJobTypeToString(job));
|
||||
virDomainJobTypeToString(job));
|
||||
if (virCondWaitUntil(&priv->job.cond, &obj->parent.lock, then) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
libxlDomainObjResetJob(priv);
|
||||
|
||||
VIR_DEBUG("Starting job: %s", libxlDomainJobTypeToString(job));
|
||||
VIR_DEBUG("Starting job: %s", virDomainJobTypeToString(job));
|
||||
priv->job.active = job;
|
||||
priv->job.owner = virThreadSelfID();
|
||||
priv->job.current->started = now;
|
||||
@ -127,9 +119,9 @@ libxlDomainObjBeginJob(libxlDriverPrivate *driver G_GNUC_UNUSED,
|
||||
error:
|
||||
VIR_WARN("Cannot start job (%s) for domain %s;"
|
||||
" current job is (%s) owned by (%d)",
|
||||
libxlDomainJobTypeToString(job),
|
||||
virDomainJobTypeToString(job),
|
||||
obj->def->name,
|
||||
libxlDomainJobTypeToString(priv->job.active),
|
||||
virDomainJobTypeToString(priv->job.active),
|
||||
priv->job.owner);
|
||||
|
||||
if (errno == ETIMEDOUT)
|
||||
@ -157,10 +149,10 @@ libxlDomainObjEndJob(libxlDriverPrivate *driver G_GNUC_UNUSED,
|
||||
virDomainObj *obj)
|
||||
{
|
||||
libxlDomainObjPrivate *priv = obj->privateData;
|
||||
enum libxlDomainJob job = priv->job.active;
|
||||
virDomainJob job = priv->job.active;
|
||||
|
||||
VIR_DEBUG("Stopping job: %s",
|
||||
libxlDomainJobTypeToString(job));
|
||||
virDomainJobTypeToString(job));
|
||||
|
||||
libxlDomainObjResetJob(priv);
|
||||
virCondSignal(&priv->job.cond);
|
||||
@ -510,7 +502,7 @@ libxlDomainShutdownThread(void *opaque)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (xl_reason == LIBXL_SHUTDOWN_REASON_POWEROFF) {
|
||||
@ -639,7 +631,7 @@ libxlDomainDeathThread(void *opaque)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, VIR_DOMAIN_SHUTOFF_DESTROYED);
|
||||
|
@ -28,23 +28,10 @@
|
||||
#include "virenum.h"
|
||||
#include "domain_job.h"
|
||||
|
||||
/* Only 1 job is allowed at any time
|
||||
* A job includes *all* libxl.so api, even those just querying
|
||||
* information, not merely actions */
|
||||
enum libxlDomainJob {
|
||||
LIBXL_JOB_NONE = 0, /* Always set to 0 for easy if (jobActive) conditions */
|
||||
LIBXL_JOB_QUERY, /* Doesn't change any state */
|
||||
LIBXL_JOB_DESTROY, /* Destroys the domain (cannot be masked out) */
|
||||
LIBXL_JOB_MODIFY, /* May change state */
|
||||
|
||||
LIBXL_JOB_LAST
|
||||
};
|
||||
VIR_ENUM_DECL(libxlDomainJob);
|
||||
|
||||
|
||||
struct libxlDomainJobObj {
|
||||
virCond cond; /* Use to coordinate jobs */
|
||||
enum libxlDomainJob active; /* Currently running job */
|
||||
virDomainJob active; /* Currently running job */
|
||||
int owner; /* Thread which set current job */
|
||||
virDomainJobData *current; /* Statistics for the current job */
|
||||
};
|
||||
@ -76,7 +63,7 @@ libxlDomainObjPrivateInitCtx(virDomainObj *vm);
|
||||
int
|
||||
libxlDomainObjBeginJob(libxlDriverPrivate *driver,
|
||||
virDomainObj *obj,
|
||||
enum libxlDomainJob job)
|
||||
virDomainJob job)
|
||||
G_GNUC_WARN_UNUSED_RESULT;
|
||||
|
||||
void
|
||||
|
@ -329,7 +329,7 @@ libxlAutostartDomain(virDomainObj *vm,
|
||||
virObjectLock(vm);
|
||||
virResetLastError();
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (vm->autostart && !virDomainObjIsActive(vm) &&
|
||||
@ -1056,7 +1056,7 @@ libxlDomainCreateXML(virConnectPtr conn, const char *xml,
|
||||
NULL)))
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) {
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) {
|
||||
if (!vm->persistent)
|
||||
virDomainObjListRemove(driver->domains, vm);
|
||||
goto cleanup;
|
||||
@ -1166,7 +1166,7 @@ libxlDomainSuspend(virDomainPtr dom)
|
||||
if (virDomainSuspendEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -1219,7 +1219,7 @@ libxlDomainResume(virDomainPtr dom)
|
||||
if (virDomainResumeEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -1380,7 +1380,7 @@ libxlDomainDestroyFlags(virDomainPtr dom,
|
||||
if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -1453,7 +1453,7 @@ libxlDomainPMSuspendForDuration(virDomainPtr dom,
|
||||
if (virDomainPMSuspendForDurationEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -1506,7 +1506,7 @@ libxlDomainPMWakeup(virDomainPtr dom, unsigned int flags)
|
||||
if (virDomainPMWakeupEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_PMSUSPENDED) {
|
||||
@ -1640,7 +1640,7 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
|
||||
if (virDomainSetMemoryFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(cfg->caps, driver->xmlopt, vm, &flags,
|
||||
@ -1909,7 +1909,7 @@ libxlDomainSaveFlags(virDomainPtr dom, const char *to, const char *dxml,
|
||||
if (virDomainSaveFlagsEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -1974,7 +1974,7 @@ libxlDomainRestoreFlags(virConnectPtr conn, const char *from,
|
||||
NULL)))
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) {
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) {
|
||||
if (!vm->persistent)
|
||||
virDomainObjListRemove(driver->domains, vm);
|
||||
goto cleanup;
|
||||
@ -2021,7 +2021,7 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
|
||||
if (virDomainCoreDumpEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -2110,7 +2110,7 @@ libxlDomainManagedSave(virDomainPtr dom, unsigned int flags)
|
||||
if (virDomainManagedSaveEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -2255,7 +2255,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
||||
if (virDomainSetVcpusFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!virDomainObjIsActive(vm) && (flags & VIR_DOMAIN_VCPU_LIVE)) {
|
||||
@ -2453,7 +2453,7 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int vcpu,
|
||||
if (virDomainPinVcpuFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(cfg->caps, driver->xmlopt, vm,
|
||||
@ -2784,7 +2784,7 @@ libxlDomainCreateWithFlags(virDomainPtr dom,
|
||||
if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjIsActive(vm)) {
|
||||
@ -4102,7 +4102,7 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
|
||||
if (virDomainAttachDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjUpdateModificationImpact(vm, &flags) < 0)
|
||||
@ -4196,7 +4196,7 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
|
||||
if (virDomainDetachDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjUpdateModificationImpact(vm, &flags) < 0)
|
||||
@ -4484,7 +4484,7 @@ libxlDomainSetAutostart(virDomainPtr dom, int autostart)
|
||||
if (virDomainSetAutostartEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!vm->persistent) {
|
||||
@ -4690,7 +4690,7 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
||||
if (virDomainSetSchedulerParametersFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -5007,7 +5007,7 @@ libxlDomainInterfaceStats(virDomainPtr dom,
|
||||
if (virDomainInterfaceStatsEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_QUERY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -5175,7 +5175,7 @@ libxlDomainMemoryStats(virDomainPtr dom,
|
||||
if (virDomainMemoryStatsEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_QUERY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -5533,7 +5533,7 @@ libxlDomainBlockStats(virDomainPtr dom,
|
||||
if (virDomainBlockStatsEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_QUERY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -5583,7 +5583,7 @@ libxlDomainBlockStatsFlags(virDomainPtr dom,
|
||||
if (virDomainBlockStatsFlagsEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_QUERY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -6375,7 +6375,7 @@ libxlDomainSetMetadata(virDomainPtr dom,
|
||||
if (virDomainSetMetadataEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = virDomainObjSetMetadata(vm, type, metadata, key, uri,
|
||||
|
@ -386,7 +386,7 @@ libxlDomainMigrationSrcBegin(virConnectPtr conn,
|
||||
* terminated in the confirm phase. Errors in the begin or perform
|
||||
* phase will also terminate the job.
|
||||
*/
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(mig = libxlMigrationCookieNew(vm)))
|
||||
@ -556,7 +556,7 @@ libxlDomainMigrationDstPrepareTunnel3(virConnectPtr dconn,
|
||||
* Unless an error is encountered in this function, the job will
|
||||
* be terminated in the finish phase.
|
||||
*/
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto error;
|
||||
|
||||
priv = vm->privateData;
|
||||
@ -665,7 +665,7 @@ libxlDomainMigrationDstPrepare(virConnectPtr dconn,
|
||||
* Unless an error is encountered in this function, the job will
|
||||
* be terminated in the finish phase.
|
||||
*/
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||
if (libxlDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto error;
|
||||
|
||||
priv = vm->privateData;
|
||||
|
Loading…
Reference in New Issue
Block a user