mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
ch: use virDomainJob enum instead of virCHDomainJob
Signed-off-by: Kristina Hanicova <khanicov@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
44f0b63dbc
commit
48dc020a55
@ -31,14 +31,6 @@
|
|||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_CH
|
#define VIR_FROM_THIS VIR_FROM_CH
|
||||||
|
|
||||||
VIR_ENUM_IMPL(virCHDomainJob,
|
|
||||||
CH_JOB_LAST,
|
|
||||||
"none",
|
|
||||||
"query",
|
|
||||||
"destroy",
|
|
||||||
"modify",
|
|
||||||
);
|
|
||||||
|
|
||||||
VIR_LOG_INIT("ch.ch_domain");
|
VIR_LOG_INIT("ch.ch_domain");
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -57,7 +49,7 @@ virCHDomainObjResetJob(virCHDomainObjPrivate *priv)
|
|||||||
{
|
{
|
||||||
struct virCHDomainJobObj *job = &priv->job;
|
struct virCHDomainJobObj *job = &priv->job;
|
||||||
|
|
||||||
job->active = CH_JOB_NONE;
|
job->active = VIR_JOB_NONE;
|
||||||
job->owner = 0;
|
job->owner = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +69,7 @@ virCHDomainObjFreeJob(virCHDomainObjPrivate *priv)
|
|||||||
* Successful calls must be followed by EndJob eventually.
|
* Successful calls must be followed by EndJob eventually.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virCHDomainObjBeginJob(virDomainObj *obj, enum virCHDomainJob job)
|
virCHDomainObjBeginJob(virDomainObj *obj, virDomainJob job)
|
||||||
{
|
{
|
||||||
virCHDomainObjPrivate *priv = obj->privateData;
|
virCHDomainObjPrivate *priv = obj->privateData;
|
||||||
unsigned long long now;
|
unsigned long long now;
|
||||||
@ -89,13 +81,13 @@ virCHDomainObjBeginJob(virDomainObj *obj, enum virCHDomainJob job)
|
|||||||
|
|
||||||
while (priv->job.active) {
|
while (priv->job.active) {
|
||||||
VIR_DEBUG("Wait normal job condition for starting job: %s",
|
VIR_DEBUG("Wait normal job condition for starting job: %s",
|
||||||
virCHDomainJobTypeToString(job));
|
virDomainJobTypeToString(job));
|
||||||
if (virCondWaitUntil(&priv->job.cond, &obj->parent.lock, then) < 0) {
|
if (virCondWaitUntil(&priv->job.cond, &obj->parent.lock, then) < 0) {
|
||||||
VIR_WARN("Cannot start job (%s) for domain %s;"
|
VIR_WARN("Cannot start job (%s) for domain %s;"
|
||||||
" current job is (%s) owned by (%d)",
|
" current job is (%s) owned by (%d)",
|
||||||
virCHDomainJobTypeToString(job),
|
virDomainJobTypeToString(job),
|
||||||
obj->def->name,
|
obj->def->name,
|
||||||
virCHDomainJobTypeToString(priv->job.active),
|
virDomainJobTypeToString(priv->job.active),
|
||||||
priv->job.owner);
|
priv->job.owner);
|
||||||
|
|
||||||
if (errno == ETIMEDOUT)
|
if (errno == ETIMEDOUT)
|
||||||
@ -110,7 +102,7 @@ virCHDomainObjBeginJob(virDomainObj *obj, enum virCHDomainJob job)
|
|||||||
|
|
||||||
virCHDomainObjResetJob(priv);
|
virCHDomainObjResetJob(priv);
|
||||||
|
|
||||||
VIR_DEBUG("Starting job: %s", virCHDomainJobTypeToString(job));
|
VIR_DEBUG("Starting job: %s", virDomainJobTypeToString(job));
|
||||||
priv->job.active = job;
|
priv->job.active = job;
|
||||||
priv->job.owner = virThreadSelfID();
|
priv->job.owner = virThreadSelfID();
|
||||||
|
|
||||||
@ -127,10 +119,10 @@ void
|
|||||||
virCHDomainObjEndJob(virDomainObj *obj)
|
virCHDomainObjEndJob(virDomainObj *obj)
|
||||||
{
|
{
|
||||||
virCHDomainObjPrivate *priv = obj->privateData;
|
virCHDomainObjPrivate *priv = obj->privateData;
|
||||||
enum virCHDomainJob job = priv->job.active;
|
virDomainJob job = priv->job.active;
|
||||||
|
|
||||||
VIR_DEBUG("Stopping job: %s",
|
VIR_DEBUG("Stopping job: %s",
|
||||||
virCHDomainJobTypeToString(job));
|
virDomainJobTypeToString(job));
|
||||||
|
|
||||||
virCHDomainObjResetJob(priv);
|
virCHDomainObjResetJob(priv);
|
||||||
virCondSignal(&priv->job.cond);
|
virCondSignal(&priv->job.cond);
|
||||||
|
@ -24,27 +24,15 @@
|
|||||||
#include "ch_monitor.h"
|
#include "ch_monitor.h"
|
||||||
#include "virchrdev.h"
|
#include "virchrdev.h"
|
||||||
#include "vircgroup.h"
|
#include "vircgroup.h"
|
||||||
|
#include "domain_job.h"
|
||||||
|
|
||||||
/* Give up waiting for mutex after 30 seconds */
|
/* Give up waiting for mutex after 30 seconds */
|
||||||
#define CH_JOB_WAIT_TIME (1000ull * 30)
|
#define CH_JOB_WAIT_TIME (1000ull * 30)
|
||||||
|
|
||||||
/* Only 1 job is allowed at any time
|
|
||||||
* A job includes *all* ch.so api, even those just querying
|
|
||||||
* information, not merely actions */
|
|
||||||
|
|
||||||
enum virCHDomainJob {
|
|
||||||
CH_JOB_NONE = 0, /* Always set to 0 for easy if (jobActive) conditions */
|
|
||||||
CH_JOB_QUERY, /* Doesn't change any state */
|
|
||||||
CH_JOB_DESTROY, /* Destroys the domain (cannot be masked out) */
|
|
||||||
CH_JOB_MODIFY, /* May change state */
|
|
||||||
CH_JOB_LAST
|
|
||||||
};
|
|
||||||
VIR_ENUM_DECL(virCHDomainJob);
|
|
||||||
|
|
||||||
|
|
||||||
struct virCHDomainJobObj {
|
struct virCHDomainJobObj {
|
||||||
virCond cond; /* Use to coordinate jobs */
|
virCond cond; /* Use to coordinate jobs */
|
||||||
enum virCHDomainJob active; /* Currently running job */
|
virDomainJob active; /* Currently running job */
|
||||||
int owner; /* Thread which set current job */
|
int owner; /* Thread which set current job */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -82,7 +70,7 @@ extern virDomainXMLPrivateDataCallbacks virCHDriverPrivateDataCallbacks;
|
|||||||
extern virDomainDefParserConfig virCHDriverDomainDefParserConfig;
|
extern virDomainDefParserConfig virCHDriverDomainDefParserConfig;
|
||||||
|
|
||||||
int
|
int
|
||||||
virCHDomainObjBeginJob(virDomainObj *obj, enum virCHDomainJob job)
|
virCHDomainObjBeginJob(virDomainObj *obj, virDomainJob job)
|
||||||
G_GNUC_WARN_UNUSED_RESULT;
|
G_GNUC_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -224,7 +224,7 @@ chDomainCreateXML(virConnectPtr conn,
|
|||||||
NULL)))
|
NULL)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virCHDomainObjBeginJob(vm, CH_JOB_MODIFY) < 0)
|
if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virCHProcessStart(driver, vm, VIR_DOMAIN_RUNNING_BOOTED) < 0)
|
if (virCHProcessStart(driver, vm, VIR_DOMAIN_RUNNING_BOOTED) < 0)
|
||||||
@ -258,7 +258,7 @@ chDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
|
|||||||
if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virCHDomainObjBeginJob(vm, CH_JOB_MODIFY) < 0)
|
if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = virCHProcessStart(driver, vm, VIR_DOMAIN_RUNNING_BOOTED);
|
ret = virCHProcessStart(driver, vm, VIR_DOMAIN_RUNNING_BOOTED);
|
||||||
@ -397,7 +397,7 @@ chDomainShutdownFlags(virDomainPtr dom,
|
|||||||
if (virDomainShutdownFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainShutdownFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virCHDomainObjBeginJob(vm, CH_JOB_MODIFY) < 0)
|
if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainObjCheckActive(vm) < 0)
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
@ -453,7 +453,7 @@ chDomainReboot(virDomainPtr dom, unsigned int flags)
|
|||||||
if (virDomainRebootEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainRebootEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virCHDomainObjBeginJob(vm, CH_JOB_MODIFY) < 0)
|
if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainObjCheckActive(vm) < 0)
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
@ -502,7 +502,7 @@ chDomainSuspend(virDomainPtr dom)
|
|||||||
if (virDomainSuspendEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainSuspendEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virCHDomainObjBeginJob(vm, CH_JOB_MODIFY) < 0)
|
if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainObjCheckActive(vm) < 0)
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
@ -547,7 +547,7 @@ chDomainResume(virDomainPtr dom)
|
|||||||
if (virDomainResumeEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainResumeEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virCHDomainObjBeginJob(vm, CH_JOB_MODIFY) < 0)
|
if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainObjCheckActive(vm) < 0)
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
@ -601,7 +601,7 @@ chDomainDestroyFlags(virDomainPtr dom, unsigned int flags)
|
|||||||
if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virCHDomainObjBeginJob(vm, CH_JOB_DESTROY) < 0)
|
if (virCHDomainObjBeginJob(vm, VIR_JOB_DESTROY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainObjCheckActive(vm) < 0)
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
@ -1221,7 +1221,7 @@ chDomainPinVcpuFlags(virDomainPtr dom,
|
|||||||
if (virDomainPinVcpuFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainPinVcpuFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virCHDomainObjBeginJob(vm, CH_JOB_MODIFY) < 0)
|
if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
|
if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
|
||||||
@ -1358,7 +1358,7 @@ chDomainPinEmulator(virDomainPtr dom,
|
|||||||
if (virDomainPinEmulatorEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainPinEmulatorEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virCHDomainObjBeginJob(vm, CH_JOB_MODIFY) < 0)
|
if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
|
if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
|
||||||
@ -1629,7 +1629,7 @@ chDomainSetNumaParameters(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virCHDomainObjBeginJob(vm, CH_JOB_MODIFY) < 0)
|
if (virCHDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
|
if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user