mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
conf: extend xmlopt with job config & add job object into domain object
This patch adds the generalized job object into the domain object so that it can be used by all drivers without the need to extract it from the private data. Because of this, the job object needs to be created and set during the creation of the domain object. This patch also extends xmlopt with possible job config containing virDomainJobObj callbacks, its private data callbacks and one variable (maxQueuedJobs). This patch includes: * addition of virDomainJobObj into virDomainObj (used in the following patches) * extending xmlopt with job config structure * new function for freeing the virDomainJobObj Signed-off-by: Kristina Hanicova <khanicov@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
0c3f023045
commit
84e9fd068c
@ -221,7 +221,7 @@ virBhyveDriverCreateXMLConf(struct _bhyveConn *driver)
|
|||||||
return virDomainXMLOptionNew(&virBhyveDriverDomainDefParserConfig,
|
return virDomainXMLOptionNew(&virBhyveDriverDomainDefParserConfig,
|
||||||
&virBhyveDriverPrivateDataCallbacks,
|
&virBhyveDriverPrivateDataCallbacks,
|
||||||
&virBhyveDriverDomainXMLNamespace,
|
&virBhyveDriverDomainXMLNamespace,
|
||||||
NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ chDomainXMLConfInit(virCHDriver *driver)
|
|||||||
virCHDriverDomainDefParserConfig.priv = driver;
|
virCHDriverDomainDefParserConfig.priv = driver;
|
||||||
return virDomainXMLOptionNew(&virCHDriverDomainDefParserConfig,
|
return virDomainXMLOptionNew(&virCHDriverDomainDefParserConfig,
|
||||||
&virCHDriverPrivateDataCallbacks,
|
&virCHDriverPrivateDataCallbacks,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
virCHDriverConfig *
|
virCHDriverConfig *
|
||||||
|
@ -1605,7 +1605,8 @@ virDomainXMLOptionNew(virDomainDefParserConfig *config,
|
|||||||
virDomainXMLPrivateDataCallbacks *priv,
|
virDomainXMLPrivateDataCallbacks *priv,
|
||||||
virXMLNamespace *xmlns,
|
virXMLNamespace *xmlns,
|
||||||
virDomainABIStability *abi,
|
virDomainABIStability *abi,
|
||||||
virSaveCookieCallbacks *saveCookie)
|
virSaveCookieCallbacks *saveCookie,
|
||||||
|
virDomainJobObjConfig *jobConfig)
|
||||||
{
|
{
|
||||||
virDomainXMLOption *xmlopt;
|
virDomainXMLOption *xmlopt;
|
||||||
|
|
||||||
@ -1630,6 +1631,9 @@ virDomainXMLOptionNew(virDomainDefParserConfig *config,
|
|||||||
if (saveCookie)
|
if (saveCookie)
|
||||||
xmlopt->saveCookie = *saveCookie;
|
xmlopt->saveCookie = *saveCookie;
|
||||||
|
|
||||||
|
if (jobConfig)
|
||||||
|
xmlopt->jobObjConfig = *jobConfig;
|
||||||
|
|
||||||
/* Technically this forbids to use one of Xerox's MAC address prefixes in
|
/* Technically this forbids to use one of Xerox's MAC address prefixes in
|
||||||
* our hypervisor drivers. This shouldn't ever be a problem.
|
* our hypervisor drivers. This shouldn't ever be a problem.
|
||||||
*
|
*
|
||||||
@ -3858,6 +3862,7 @@ static void virDomainObjDispose(void *obj)
|
|||||||
virDomainObjDeprecationFree(dom);
|
virDomainObjDeprecationFree(dom);
|
||||||
virDomainSnapshotObjListFree(dom->snapshots);
|
virDomainSnapshotObjListFree(dom->snapshots);
|
||||||
virDomainCheckpointObjListFree(dom->checkpoints);
|
virDomainCheckpointObjListFree(dom->checkpoints);
|
||||||
|
virDomainJobObjFree(dom->job);
|
||||||
}
|
}
|
||||||
|
|
||||||
virDomainObj *
|
virDomainObj *
|
||||||
@ -3890,6 +3895,12 @@ virDomainObjNew(virDomainXMLOption *xmlopt)
|
|||||||
if (!(domain->checkpoints = virDomainCheckpointObjListNew()))
|
if (!(domain->checkpoints = virDomainCheckpointObjListNew()))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
domain->job = g_new0(virDomainJobObj, 1);
|
||||||
|
if (virDomainObjInitJob(domain->job,
|
||||||
|
&xmlopt->jobObjConfig.cb,
|
||||||
|
&xmlopt->jobObjConfig.jobDataPrivateCb) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
virObjectLock(domain);
|
virObjectLock(domain);
|
||||||
virDomainObjSetState(domain, VIR_DOMAIN_SHUTOFF,
|
virDomainObjSetState(domain, VIR_DOMAIN_SHUTOFF,
|
||||||
VIR_DOMAIN_SHUTOFF_UNKNOWN);
|
VIR_DOMAIN_SHUTOFF_UNKNOWN);
|
||||||
|
@ -56,6 +56,7 @@
|
|||||||
#include "virsavecookie.h"
|
#include "virsavecookie.h"
|
||||||
#include "virresctrl.h"
|
#include "virresctrl.h"
|
||||||
#include "virenum.h"
|
#include "virenum.h"
|
||||||
|
#include "virdomainjob.h"
|
||||||
|
|
||||||
/* Flags for the 'type' field in virDomainDeviceDef */
|
/* Flags for the 'type' field in virDomainDeviceDef */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -3093,6 +3094,8 @@ struct _virDomainObj {
|
|||||||
virObjectLockable parent;
|
virObjectLockable parent;
|
||||||
virCond cond;
|
virCond cond;
|
||||||
|
|
||||||
|
virDomainJobObj *job;
|
||||||
|
|
||||||
pid_t pid; /* 0 for no PID, avoid negative values like -1 */
|
pid_t pid; /* 0 for no PID, avoid negative values like -1 */
|
||||||
virDomainStateReason state;
|
virDomainStateReason state;
|
||||||
|
|
||||||
@ -3277,11 +3280,19 @@ struct _virDomainABIStability {
|
|||||||
virDomainABIStabilityDomain domain;
|
virDomainABIStabilityDomain domain;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct _virDomainJobObjConfig {
|
||||||
|
virDomainObjPrivateJobCallbacks cb;
|
||||||
|
virDomainJobDataPrivateDataCallbacks jobDataPrivateCb;
|
||||||
|
unsigned int maxQueuedJobs;
|
||||||
|
};
|
||||||
|
|
||||||
virDomainXMLOption *virDomainXMLOptionNew(virDomainDefParserConfig *config,
|
virDomainXMLOption *virDomainXMLOptionNew(virDomainDefParserConfig *config,
|
||||||
virDomainXMLPrivateDataCallbacks *priv,
|
virDomainXMLPrivateDataCallbacks *priv,
|
||||||
virXMLNamespace *xmlns,
|
virXMLNamespace *xmlns,
|
||||||
virDomainABIStability *abi,
|
virDomainABIStability *abi,
|
||||||
virSaveCookieCallbacks *saveCookie);
|
virSaveCookieCallbacks *saveCookie,
|
||||||
|
virDomainJobObjConfig *jobConfig);
|
||||||
|
|
||||||
virSaveCookieCallbacks *
|
virSaveCookieCallbacks *
|
||||||
virDomainXMLOptionGetSaveCookie(virDomainXMLOption *xmlopt);
|
virDomainXMLOptionGetSaveCookie(virDomainXMLOption *xmlopt);
|
||||||
@ -3321,6 +3332,9 @@ struct _virDomainXMLOption {
|
|||||||
|
|
||||||
/* Snapshot postparse callbacks */
|
/* Snapshot postparse callbacks */
|
||||||
virDomainMomentPostParseCallback momentPostParse;
|
virDomainMomentPostParseCallback momentPostParse;
|
||||||
|
|
||||||
|
/* virDomainJobObj callbacks, private data callbacks and defaults */
|
||||||
|
virDomainJobObjConfig jobObjConfig;
|
||||||
};
|
};
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainXMLOption, virObjectUnref);
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainXMLOption, virObjectUnref);
|
||||||
|
|
||||||
|
@ -150,6 +150,8 @@ typedef struct _virDomainIdMapEntry virDomainIdMapEntry;
|
|||||||
|
|
||||||
typedef struct _virDomainInputDef virDomainInputDef;
|
typedef struct _virDomainInputDef virDomainInputDef;
|
||||||
|
|
||||||
|
typedef struct _virDomainJobObjConfig virDomainJobObjConfig;
|
||||||
|
|
||||||
typedef struct _virDomainKeyWrapDef virDomainKeyWrapDef;
|
typedef struct _virDomainKeyWrapDef virDomainKeyWrapDef;
|
||||||
|
|
||||||
typedef struct _virDomainLeaseDef virDomainLeaseDef;
|
typedef struct _virDomainLeaseDef virDomainLeaseDef;
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "virthreadjob.h"
|
#include "virthreadjob.h"
|
||||||
#include "virlog.h"
|
#include "virlog.h"
|
||||||
#include "virtime.h"
|
#include "virtime.h"
|
||||||
|
#include "domain_conf.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||||
|
|
||||||
@ -230,6 +231,16 @@ virDomainObjClearJob(virDomainJobObj *job)
|
|||||||
g_clear_pointer(&job->privateData, job->cb->freeJobPrivate);
|
g_clear_pointer(&job->privateData, job->cb->freeJobPrivate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
virDomainJobObjFree(virDomainJobObj *job)
|
||||||
|
{
|
||||||
|
if (!job)
|
||||||
|
return;
|
||||||
|
|
||||||
|
virDomainObjClearJob(job);
|
||||||
|
g_free(job);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
virDomainTrackJob(virDomainJob job)
|
virDomainTrackJob(virDomainJob job)
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
#include "virenum.h"
|
#include "virenum.h"
|
||||||
#include "virthread.h"
|
#include "virthread.h"
|
||||||
#include "virbuffer.h"
|
#include "virbuffer.h"
|
||||||
#include "domain_conf.h"
|
#include "virconftypes.h"
|
||||||
|
#include "virxml.h"
|
||||||
|
|
||||||
#define JOB_MASK(job) (job == 0 ? 0 : 1 << (job - 1))
|
#define JOB_MASK(job) (job == 0 ? 0 : 1 << (job - 1))
|
||||||
#define VIR_JOB_DEFAULT_MASK \
|
#define VIR_JOB_DEFAULT_MASK \
|
||||||
@ -227,6 +228,8 @@ int virDomainObjPreserveJob(virDomainJobObj *currJob,
|
|||||||
void virDomainObjClearJob(virDomainJobObj *job);
|
void virDomainObjClearJob(virDomainJobObj *job);
|
||||||
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virDomainJobObj, virDomainObjClearJob);
|
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virDomainJobObj, virDomainObjClearJob);
|
||||||
|
|
||||||
|
void virDomainJobObjFree(virDomainJobObj *job);
|
||||||
|
|
||||||
bool virDomainTrackJob(virDomainJob job);
|
bool virDomainTrackJob(virDomainJob job);
|
||||||
|
|
||||||
bool virDomainNestedJobAllowed(virDomainJobObj *jobs, virDomainJob newJob);
|
bool virDomainNestedJobAllowed(virDomainJobObj *jobs, virDomainJob newJob);
|
||||||
|
@ -1766,7 +1766,7 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* init xmlopt for domain XML */
|
/* init xmlopt for domain XML */
|
||||||
priv->xmlopt = virDomainXMLOptionNew(&hypervDomainDefParserConfig, NULL, NULL, NULL, NULL);
|
priv->xmlopt = virDomainXMLOptionNew(&hypervDomainDefParserConfig, NULL, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
if (hypervGetOperatingSystem(priv, &os) < 0)
|
if (hypervGetOperatingSystem(priv, &os) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -1182,6 +1182,7 @@ virDomainAsyncJobTypeToString;
|
|||||||
virDomainJobDataCopy;
|
virDomainJobDataCopy;
|
||||||
virDomainJobDataFree;
|
virDomainJobDataFree;
|
||||||
virDomainJobDataInit;
|
virDomainJobDataInit;
|
||||||
|
virDomainJobObjFree;
|
||||||
virDomainJobStatusToType;
|
virDomainJobStatusToType;
|
||||||
virDomainJobTypeFromString;
|
virDomainJobTypeFromString;
|
||||||
virDomainJobTypeToString;
|
virDomainJobTypeToString;
|
||||||
|
@ -2486,5 +2486,5 @@ libxlCreateXMLConf(libxlDriverPrivate *driver)
|
|||||||
return virDomainXMLOptionNew(&libxlDomainDefParserConfig,
|
return virDomainXMLOptionNew(&libxlDomainDefParserConfig,
|
||||||
&libxlDomainXMLPrivateDataCallbacks,
|
&libxlDomainXMLPrivateDataCallbacks,
|
||||||
&libxlDriverDomainXMLNamespace,
|
&libxlDriverDomainXMLNamespace,
|
||||||
NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ lxcDomainXMLConfInit(virLXCDriver *driver, const char *defsecmodel)
|
|||||||
return virDomainXMLOptionNew(&virLXCDriverDomainDefParserConfig,
|
return virDomainXMLOptionNew(&virLXCDriverDomainDefParserConfig,
|
||||||
&virLXCDriverPrivateDataCallbacks,
|
&virLXCDriverPrivateDataCallbacks,
|
||||||
&virLXCDriverDomainXMLNamespace,
|
&virLXCDriverDomainXMLNamespace,
|
||||||
NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1062,5 +1062,5 @@ virDomainXMLOption *openvzXMLOption(struct openvz_driver *driver)
|
|||||||
{
|
{
|
||||||
openvzDomainDefParserConfig.priv = driver;
|
openvzDomainDefParserConfig.priv = driver;
|
||||||
return virDomainXMLOptionNew(&openvzDomainDefParserConfig,
|
return virDomainXMLOptionNew(&openvzDomainDefParserConfig,
|
||||||
NULL, NULL, NULL, NULL);
|
NULL, NULL, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
@ -1278,7 +1278,8 @@ virQEMUDriverCreateXMLConf(virQEMUDriver *driver,
|
|||||||
&virQEMUDriverPrivateDataCallbacks,
|
&virQEMUDriverPrivateDataCallbacks,
|
||||||
&virQEMUDriverDomainXMLNamespace,
|
&virQEMUDriverDomainXMLNamespace,
|
||||||
&virQEMUDriverDomainABIStability,
|
&virQEMUDriverDomainABIStability,
|
||||||
&virQEMUDriverDomainSaveCookie);
|
&virQEMUDriverDomainSaveCookie,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9273,7 +9273,7 @@ qemuProcessQMPConnectMonitor(qemuProcessQMP *proc)
|
|||||||
monConfig.data.nix.path = proc->monpath;
|
monConfig.data.nix.path = proc->monpath;
|
||||||
monConfig.data.nix.listen = false;
|
monConfig.data.nix.listen = false;
|
||||||
|
|
||||||
if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL)) ||
|
if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL, NULL)) ||
|
||||||
!(proc->vm = virDomainObjNew(xmlopt)) ||
|
!(proc->vm = virDomainObjNew(xmlopt)) ||
|
||||||
!(proc->vm->def = virDomainDefNew(xmlopt)))
|
!(proc->vm->def = virDomainDefNew(xmlopt)))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -632,7 +632,7 @@ get_definition(vahControl * ctl, const char *xmlStr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(ctl->xmlopt = virDomainXMLOptionNew(&virAAHelperDomainDefParserConfig,
|
if (!(ctl->xmlopt = virDomainXMLOptionNew(&virAAHelperDomainDefParserConfig,
|
||||||
NULL, NULL, NULL, NULL))) {
|
NULL, NULL, NULL, NULL, NULL))) {
|
||||||
vah_error(ctl, 0, _("Failed to create XML config object"));
|
vah_error(ctl, 0, _("Failed to create XML config object"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -460,7 +460,7 @@ testDriverNew(void)
|
|||||||
if (!(ret = virObjectLockableNew(testDriverClass)))
|
if (!(ret = virObjectLockableNew(testDriverClass)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!(ret->xmlopt = virDomainXMLOptionNew(&config, &privatecb, &ns, NULL, NULL)) ||
|
if (!(ret->xmlopt = virDomainXMLOptionNew(&config, &privatecb, &ns, NULL, NULL, NULL)) ||
|
||||||
!(ret->eventState = virObjectEventStateNew()) ||
|
!(ret->eventState = virObjectEventStateNew()) ||
|
||||||
!(ret->ifaces = virInterfaceObjListNew()) ||
|
!(ret->ifaces = virInterfaceObjListNew()) ||
|
||||||
!(ret->domains = virDomainObjListNew()) ||
|
!(ret->domains = virDomainObjListNew()) ||
|
||||||
|
@ -143,7 +143,7 @@ vboxDriverObjNew(void)
|
|||||||
|
|
||||||
if (!(driver->caps = vboxCapsInit()) ||
|
if (!(driver->caps = vboxCapsInit()) ||
|
||||||
!(driver->xmlopt = virDomainXMLOptionNew(&vboxDomainDefParserConfig,
|
!(driver->xmlopt = virDomainXMLOptionNew(&vboxDomainDefParserConfig,
|
||||||
NULL, NULL, NULL, NULL)))
|
NULL, NULL, NULL, NULL, NULL)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
return driver;
|
return driver;
|
||||||
|
@ -139,7 +139,7 @@ vmwareDomainXMLConfigInit(struct vmware_driver *driver)
|
|||||||
.free = vmwareDataFreeFunc };
|
.free = vmwareDataFreeFunc };
|
||||||
vmwareDomainDefParserConfig.priv = driver;
|
vmwareDomainDefParserConfig.priv = driver;
|
||||||
return virDomainXMLOptionNew(&vmwareDomainDefParserConfig, &priv,
|
return virDomainXMLOptionNew(&vmwareDomainDefParserConfig, &priv,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static virDrvOpenStatus
|
static virDrvOpenStatus
|
||||||
|
@ -696,7 +696,7 @@ virVMXDomainXMLConfInit(virCaps *caps)
|
|||||||
{
|
{
|
||||||
virVMXDomainDefParserConfig.priv = caps;
|
virVMXDomainDefParserConfig.priv = caps;
|
||||||
return virDomainXMLOptionNew(&virVMXDomainDefParserConfig, NULL,
|
return virDomainXMLOptionNew(&virVMXDomainDefParserConfig, NULL,
|
||||||
&virVMXDomainXMLNamespace, NULL, NULL);
|
&virVMXDomainXMLNamespace, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
@ -331,7 +331,7 @@ vzDriverObjNew(void)
|
|||||||
if (!(driver->caps = vzBuildCapabilities()) ||
|
if (!(driver->caps = vzBuildCapabilities()) ||
|
||||||
!(driver->xmlopt = virDomainXMLOptionNew(&vzDomainDefParserConfig,
|
!(driver->xmlopt = virDomainXMLOptionNew(&vzDomainDefParserConfig,
|
||||||
&vzDomainXMLPrivateDataCallbacksPtr,
|
&vzDomainXMLPrivateDataCallbacksPtr,
|
||||||
NULL, NULL, NULL)) ||
|
NULL, NULL, NULL, NULL)) ||
|
||||||
!(driver->domains = virDomainObjListNew()) ||
|
!(driver->domains = virDomainObjListNew()) ||
|
||||||
!(driver->domainEventState = virObjectEventStateNew()) ||
|
!(driver->domainEventState = virObjectEventStateNew()) ||
|
||||||
(vzInitVersion(driver) < 0) ||
|
(vzInitVersion(driver) < 0) ||
|
||||||
|
@ -113,7 +113,7 @@ mymain(void)
|
|||||||
if ((driver.caps = virBhyveCapsBuild()) == NULL)
|
if ((driver.caps = virBhyveCapsBuild()) == NULL)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
if ((driver.xmlopt = virDomainXMLOptionNew(NULL, NULL,
|
if ((driver.xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL)) == NULL)
|
NULL, NULL, NULL)) == NULL)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
@ -989,7 +989,7 @@ static virDomainDefParserConfig virTestGenericDomainDefParserConfig = {
|
|||||||
virDomainXMLOption *virTestGenericDomainXMLConfInit(void)
|
virDomainXMLOption *virTestGenericDomainXMLConfInit(void)
|
||||||
{
|
{
|
||||||
return virDomainXMLOptionNew(&virTestGenericDomainDefParserConfig,
|
return virDomainXMLOptionNew(&virTestGenericDomainDefParserConfig,
|
||||||
NULL, NULL, NULL, NULL);
|
NULL, NULL, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user