mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
lxc: use virDomainJob enum instead of virLXCDomainJob
Signed-off-by: Kristina Hanicova <khanicov@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
93d653a9f6
commit
096138851c
@ -21,8 +21,8 @@
|
||||
|
||||
|
||||
/* Only 1 job is allowed at any time
|
||||
* A job includes *all* monitor commands, even those just querying
|
||||
* information, not merely actions */
|
||||
* A job includes *all* monitor commands / hypervisor.so api,
|
||||
* even those just querying information, not merely actions */
|
||||
typedef enum {
|
||||
VIR_JOB_NONE = 0, /* Always set to 0 for easy if (jobActive) conditions */
|
||||
VIR_JOB_QUERY, /* Doesn't change any state */
|
||||
|
@ -31,17 +31,10 @@
|
||||
#include "virsystemd.h"
|
||||
#include "virinitctl.h"
|
||||
#include "domain_driver.h"
|
||||
#include "domain_job.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_LXC
|
||||
|
||||
VIR_ENUM_IMPL(virLXCDomainJob,
|
||||
LXC_JOB_LAST,
|
||||
"none",
|
||||
"query",
|
||||
"destroy",
|
||||
"modify",
|
||||
);
|
||||
|
||||
VIR_LOG_INIT("lxc.lxc_domain");
|
||||
|
||||
static int
|
||||
@ -60,7 +53,7 @@ virLXCDomainObjResetJob(virLXCDomainObjPrivate *priv)
|
||||
{
|
||||
struct virLXCDomainJobObj *job = &priv->job;
|
||||
|
||||
job->active = LXC_JOB_NONE;
|
||||
job->active = VIR_JOB_NONE;
|
||||
job->owner = 0;
|
||||
}
|
||||
|
||||
@ -85,7 +78,7 @@ virLXCDomainObjFreeJob(virLXCDomainObjPrivate *priv)
|
||||
int
|
||||
virLXCDomainObjBeginJob(virLXCDriver *driver G_GNUC_UNUSED,
|
||||
virDomainObj *obj,
|
||||
enum virLXCDomainJob job)
|
||||
virDomainJob job)
|
||||
{
|
||||
virLXCDomainObjPrivate *priv = obj->privateData;
|
||||
unsigned long long now;
|
||||
@ -97,14 +90,14 @@ virLXCDomainObjBeginJob(virLXCDriver *driver G_GNUC_UNUSED,
|
||||
|
||||
while (priv->job.active) {
|
||||
VIR_DEBUG("Wait normal job condition for starting job: %s",
|
||||
virLXCDomainJobTypeToString(job));
|
||||
virDomainJobTypeToString(job));
|
||||
if (virCondWaitUntil(&priv->job.cond, &obj->parent.lock, then) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
virLXCDomainObjResetJob(priv);
|
||||
|
||||
VIR_DEBUG("Starting job: %s", virLXCDomainJobTypeToString(job));
|
||||
VIR_DEBUG("Starting job: %s", virDomainJobTypeToString(job));
|
||||
priv->job.active = job;
|
||||
priv->job.owner = virThreadSelfID();
|
||||
|
||||
@ -113,9 +106,9 @@ virLXCDomainObjBeginJob(virLXCDriver *driver G_GNUC_UNUSED,
|
||||
error:
|
||||
VIR_WARN("Cannot start job (%s) for domain %s;"
|
||||
" current job is (%s) owned by (%d)",
|
||||
virLXCDomainJobTypeToString(job),
|
||||
virDomainJobTypeToString(job),
|
||||
obj->def->name,
|
||||
virLXCDomainJobTypeToString(priv->job.active),
|
||||
virDomainJobTypeToString(priv->job.active),
|
||||
priv->job.owner);
|
||||
|
||||
if (errno == ETIMEDOUT)
|
||||
@ -139,10 +132,10 @@ virLXCDomainObjEndJob(virLXCDriver *driver G_GNUC_UNUSED,
|
||||
virDomainObj *obj)
|
||||
{
|
||||
virLXCDomainObjPrivate *priv = obj->privateData;
|
||||
enum virLXCDomainJob job = priv->job.active;
|
||||
virDomainJob job = priv->job.active;
|
||||
|
||||
VIR_DEBUG("Stopping job: %s",
|
||||
virLXCDomainJobTypeToString(job));
|
||||
virDomainJobTypeToString(job));
|
||||
|
||||
virLXCDomainObjResetJob(priv);
|
||||
virCondSignal(&priv->job.cond);
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "lxc_conf.h"
|
||||
#include "lxc_monitor.h"
|
||||
#include "virenum.h"
|
||||
#include "domain_job.h"
|
||||
|
||||
|
||||
typedef enum {
|
||||
@ -53,23 +54,9 @@ struct _lxcDomainDef {
|
||||
};
|
||||
|
||||
|
||||
/* Only 1 job is allowed at any time
|
||||
* A job includes *all* lxc.so api, even those just querying
|
||||
* information, not merely actions */
|
||||
|
||||
enum virLXCDomainJob {
|
||||
LXC_JOB_NONE = 0, /* Always set to 0 for easy if (jobActive) conditions */
|
||||
LXC_JOB_QUERY, /* Doesn't change any state */
|
||||
LXC_JOB_DESTROY, /* Destroys the domain (cannot be masked out) */
|
||||
LXC_JOB_MODIFY, /* May change state */
|
||||
LXC_JOB_LAST
|
||||
};
|
||||
VIR_ENUM_DECL(virLXCDomainJob);
|
||||
|
||||
|
||||
struct virLXCDomainJobObj {
|
||||
virCond cond; /* Use to coordinate jobs */
|
||||
enum virLXCDomainJob active; /* Currently running job */
|
||||
virDomainJob active; /* Currently running job */
|
||||
int owner; /* Thread which set current job */
|
||||
};
|
||||
|
||||
@ -96,7 +83,7 @@ extern virDomainDefParserConfig virLXCDriverDomainDefParserConfig;
|
||||
int
|
||||
virLXCDomainObjBeginJob(virLXCDriver *driver,
|
||||
virDomainObj *obj,
|
||||
enum virLXCDomainJob job)
|
||||
virDomainJob job)
|
||||
G_GNUC_WARN_UNUSED_RESULT;
|
||||
|
||||
void
|
||||
|
@ -652,7 +652,7 @@ static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
|
||||
if (virDomainSetMemoryFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
|
||||
@ -766,7 +766,7 @@ lxcDomainSetMemoryParameters(virDomainPtr dom,
|
||||
if (virDomainSetMemoryParametersEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
/* QEMU and LXC implementation are identical */
|
||||
@ -983,7 +983,7 @@ static int lxcDomainCreateWithFiles(virDomainPtr dom,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjIsActive(vm)) {
|
||||
@ -1104,7 +1104,7 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn,
|
||||
NULL)))
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0) {
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0) {
|
||||
if (!vm->persistent)
|
||||
virDomainObjListRemove(driver->domains, vm);
|
||||
goto cleanup;
|
||||
@ -1351,7 +1351,7 @@ lxcDomainDestroyFlags(virDomainPtr dom,
|
||||
if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_DESTROY) < 0)
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_DESTROY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -1814,7 +1814,7 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
||||
if (!(caps = virLXCDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
|
||||
@ -2033,7 +2033,7 @@ lxcDomainBlockStats(virDomainPtr dom,
|
||||
if (virDomainBlockStatsEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_QUERY) < 0)
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_QUERY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -2116,7 +2116,7 @@ lxcDomainBlockStatsFlags(virDomainPtr dom,
|
||||
if (virDomainBlockStatsFlagsEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_QUERY) < 0)
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_QUERY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -2252,7 +2252,7 @@ lxcDomainSetBlkioParameters(virDomainPtr dom,
|
||||
if (virDomainSetBlkioParametersEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
|
||||
@ -2394,7 +2394,7 @@ lxcDomainInterfaceStats(virDomainPtr dom,
|
||||
if (virDomainInterfaceStatsEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_QUERY) < 0)
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_QUERY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -2454,7 +2454,7 @@ static int lxcDomainSetAutostart(virDomainPtr dom,
|
||||
if (virDomainSetAutostartEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!vm->persistent) {
|
||||
@ -2605,7 +2605,7 @@ static int lxcDomainSuspend(virDomainPtr dom)
|
||||
if (virDomainSuspendEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -2655,7 +2655,7 @@ static int lxcDomainResume(virDomainPtr dom)
|
||||
if (virDomainResumeEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -2784,7 +2784,7 @@ lxcDomainSendProcessSignal(virDomainPtr dom,
|
||||
if (virDomainSendProcessSignalEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -2869,7 +2869,7 @@ lxcDomainShutdownFlags(virDomainPtr dom,
|
||||
if (virDomainShutdownFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -2945,7 +2945,7 @@ lxcDomainReboot(virDomainPtr dom,
|
||||
if (virDomainRebootEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -4270,7 +4270,7 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr dom,
|
||||
if (virDomainAttachDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjUpdateModificationImpact(vm, &flags) < 0)
|
||||
@ -4375,7 +4375,7 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr dom,
|
||||
if (virDomainUpdateDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjUpdateModificationImpact(vm, &flags) < 0)
|
||||
@ -4438,7 +4438,7 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr dom,
|
||||
if (virDomainDetachDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjUpdateModificationImpact(vm, &flags) < 0)
|
||||
@ -4538,7 +4538,7 @@ static int lxcDomainLxcOpenNamespace(virDomainPtr dom,
|
||||
if (virDomainLxcOpenNamespaceEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_QUERY) < 0)
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_QUERY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -4621,7 +4621,7 @@ lxcDomainMemoryStats(virDomainPtr dom,
|
||||
if (virDomainMemoryStatsEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_QUERY) < 0)
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_QUERY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
@ -4791,7 +4791,7 @@ lxcDomainSetMetadata(virDomainPtr dom,
|
||||
if (virDomainSetMetadataEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = virDomainObjSetMetadata(vm, type, metadata, key, uri,
|
||||
@ -4897,7 +4897,7 @@ lxcDomainGetHostname(virDomainPtr dom,
|
||||
if (virDomainGetHostnameEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_QUERY) < 0)
|
||||
if (virLXCDomainObjBeginJob(driver, vm, VIR_JOB_QUERY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjCheckActive(vm) < 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user