mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
conf: Add save cookie callbacks to xmlopt
virDomainXMLOption gains driver specific callbacks for parsing and formatting save cookies. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
e37daa1fb6
commit
25af7e950a
@ -144,7 +144,7 @@ virBhyveDriverCreateXMLConf(bhyveConnPtr driver)
|
||||
virBhyveDriverDomainDefParserConfig.priv = driver;
|
||||
return virDomainXMLOptionNew(&virBhyveDriverDomainDefParserConfig,
|
||||
&virBhyveDriverPrivateDataCallbacks,
|
||||
NULL, NULL);
|
||||
NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
virDomainDefParserConfig virBhyveDriverDomainDefParserConfig = {
|
||||
|
@ -79,6 +79,9 @@ struct _virDomainXMLOption {
|
||||
|
||||
/* ABI stability callbacks */
|
||||
virDomainABIStability abi;
|
||||
|
||||
/* Private data for save image stored in snapshot XML */
|
||||
virSaveCookieCallbacks saveCookie;
|
||||
};
|
||||
|
||||
#define VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS \
|
||||
@ -1054,7 +1057,8 @@ virDomainXMLOptionPtr
|
||||
virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
|
||||
virDomainXMLPrivateDataCallbacksPtr priv,
|
||||
virDomainXMLNamespacePtr xmlns,
|
||||
virDomainABIStabilityPtr abi)
|
||||
virDomainABIStabilityPtr abi,
|
||||
virSaveCookieCallbacksPtr saveCookie)
|
||||
{
|
||||
virDomainXMLOptionPtr xmlopt;
|
||||
|
||||
@ -1076,6 +1080,9 @@ virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
|
||||
if (abi)
|
||||
xmlopt->abi = *abi;
|
||||
|
||||
if (saveCookie)
|
||||
xmlopt->saveCookie = *saveCookie;
|
||||
|
||||
/* Technically this forbids to use one of Xerox's MAC address prefixes in
|
||||
* our hypervisor drivers. This shouldn't ever be a problem.
|
||||
*
|
||||
@ -1106,6 +1113,13 @@ virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt)
|
||||
}
|
||||
|
||||
|
||||
virSaveCookieCallbacksPtr
|
||||
virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt)
|
||||
{
|
||||
return &xmlopt->saveCookie;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
virBlkioDeviceArrayClear(virBlkioDevicePtr devices,
|
||||
int ndevices)
|
||||
|
@ -55,6 +55,7 @@
|
||||
# include "virgic.h"
|
||||
# include "virperf.h"
|
||||
# include "virtypedparam.h"
|
||||
# include "virsavecookie.h"
|
||||
|
||||
/* forward declarations of all device types, required by
|
||||
* virDomainDeviceDef
|
||||
@ -2549,7 +2550,11 @@ struct _virDomainABIStability {
|
||||
virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
|
||||
virDomainXMLPrivateDataCallbacksPtr priv,
|
||||
virDomainXMLNamespacePtr xmlns,
|
||||
virDomainABIStabilityPtr abi);
|
||||
virDomainABIStabilityPtr abi,
|
||||
virSaveCookieCallbacksPtr saveCookie);
|
||||
|
||||
virSaveCookieCallbacksPtr
|
||||
virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt);
|
||||
|
||||
void virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr mac);
|
||||
|
||||
|
@ -102,6 +102,7 @@ void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def)
|
||||
virDomainSnapshotDiskDefClear(&def->disks[i]);
|
||||
VIR_FREE(def->disks);
|
||||
virDomainDefFree(def->dom);
|
||||
virObjectUnref(def->cookie);
|
||||
VIR_FREE(def);
|
||||
}
|
||||
|
||||
@ -214,6 +215,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
||||
char *memorySnapshot = NULL;
|
||||
char *memoryFile = NULL;
|
||||
bool offline = !!(flags & VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE);
|
||||
virSaveCookieCallbacksPtr saveCookie = virDomainXMLOptionGetSaveCookie(xmlopt);
|
||||
|
||||
if (VIR_ALLOC(def) < 0)
|
||||
goto cleanup;
|
||||
@ -365,6 +367,9 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
||||
def->current = active != 0;
|
||||
}
|
||||
|
||||
if (!offline && virSaveCookieParse(ctxt, &def->cookie, saveCookie) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = def;
|
||||
|
||||
cleanup:
|
||||
@ -691,7 +696,7 @@ char *
|
||||
virDomainSnapshotDefFormat(const char *domain_uuid,
|
||||
virDomainSnapshotDefPtr def,
|
||||
virCapsPtr caps,
|
||||
virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED,
|
||||
virDomainXMLOptionPtr xmlopt,
|
||||
unsigned int flags,
|
||||
int internal)
|
||||
{
|
||||
@ -751,6 +756,10 @@ virDomainSnapshotDefFormat(const char *domain_uuid,
|
||||
virBufferAddLit(&buf, "</domain>\n");
|
||||
}
|
||||
|
||||
if (virSaveCookieFormatBuf(&buf, def->cookie,
|
||||
virDomainXMLOptionGetSaveCookie(xmlopt)) < 0)
|
||||
goto error;
|
||||
|
||||
if (internal)
|
||||
virBufferAsprintf(&buf, "<active>%d</active>\n", def->current);
|
||||
|
||||
|
@ -76,6 +76,8 @@ struct _virDomainSnapshotDef {
|
||||
|
||||
virDomainDefPtr dom;
|
||||
|
||||
virObjectPtr cookie;
|
||||
|
||||
/* Internal use. */
|
||||
bool current; /* At most one snapshot in the list should have this set */
|
||||
};
|
||||
|
@ -535,6 +535,7 @@ virDomainWatchdogActionTypeToString;
|
||||
virDomainWatchdogModelTypeFromString;
|
||||
virDomainWatchdogModelTypeToString;
|
||||
virDomainXMLOptionGetNamespace;
|
||||
virDomainXMLOptionGetSaveCookie;
|
||||
virDomainXMLOptionNew;
|
||||
|
||||
|
||||
|
@ -2255,5 +2255,5 @@ libxlCreateXMLConf(void)
|
||||
{
|
||||
return virDomainXMLOptionNew(&libxlDomainDefParserConfig,
|
||||
&libxlDomainXMLPrivateDataCallbacks,
|
||||
NULL, NULL);
|
||||
NULL, NULL, NULL);
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ lxcDomainXMLConfInit(void)
|
||||
return virDomainXMLOptionNew(&virLXCDriverDomainDefParserConfig,
|
||||
&virLXCDriverPrivateDataCallbacks,
|
||||
&virLXCDriverDomainXMLNamespace,
|
||||
NULL);
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1483,7 +1483,7 @@ static virDrvOpenStatus openvzConnectOpen(virConnectPtr conn,
|
||||
goto cleanup;
|
||||
|
||||
if (!(driver->xmlopt = virDomainXMLOptionNew(&openvzDomainDefParserConfig,
|
||||
NULL, NULL, NULL)))
|
||||
NULL, NULL, NULL, NULL)))
|
||||
goto cleanup;
|
||||
|
||||
if (openvzLoadDomains(driver) < 0)
|
||||
|
@ -1202,7 +1202,7 @@ phypConnectOpen(virConnectPtr conn,
|
||||
goto failure;
|
||||
|
||||
if (!(phyp_driver->xmlopt = virDomainXMLOptionNew(&virPhypDriverDomainDefParserConfig,
|
||||
NULL, NULL, NULL)))
|
||||
NULL, NULL, NULL, NULL)))
|
||||
goto failure;
|
||||
|
||||
conn->privateData = phyp_driver;
|
||||
|
@ -5026,7 +5026,7 @@ virQEMUCapsInitQMPCommandRun(virQEMUCapsInitQMPCommandPtr cmd,
|
||||
goto ignore;
|
||||
}
|
||||
|
||||
if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL)) ||
|
||||
if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL)) ||
|
||||
!(cmd->vm = virDomainObjNew(xmlopt)))
|
||||
goto cleanup;
|
||||
|
||||
|
@ -910,7 +910,8 @@ virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver)
|
||||
return virDomainXMLOptionNew(&virQEMUDriverDomainDefParserConfig,
|
||||
&virQEMUDriverPrivateDataCallbacks,
|
||||
&virQEMUDriverDomainXMLNamespace,
|
||||
&virQEMUDriverDomainABIStability);
|
||||
&virQEMUDriverDomainABIStability,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -667,7 +667,7 @@ get_definition(vahControl * ctl, const char *xmlStr)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!(ctl->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL))) {
|
||||
if (!(ctl->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL))) {
|
||||
vah_error(ctl, 0, _("Failed to create XML config object"));
|
||||
goto exit;
|
||||
}
|
||||
|
@ -414,7 +414,7 @@ testDriverNew(void)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!(ret->xmlopt = virDomainXMLOptionNew(NULL, NULL, &ns, NULL)) ||
|
||||
if (!(ret->xmlopt = virDomainXMLOptionNew(NULL, NULL, &ns, NULL, NULL)) ||
|
||||
!(ret->eventState = virObjectEventStateNew()) ||
|
||||
!(ret->ifaces = virInterfaceObjListNew()) ||
|
||||
!(ret->domains = virDomainObjListNew()) ||
|
||||
|
@ -533,7 +533,7 @@ umlStateInitialize(bool privileged,
|
||||
goto out_of_memory;
|
||||
|
||||
if (!(uml_driver->xmlopt = virDomainXMLOptionNew(¨DriverDomainDefParserConfig,
|
||||
&privcb, NULL, NULL)))
|
||||
&privcb, NULL, NULL, NULL)))
|
||||
goto error;
|
||||
|
||||
if ((uml_driver->inotifyFD = inotify_init()) < 0) {
|
||||
|
@ -142,7 +142,7 @@ vboxDriverObjNew(void)
|
||||
|
||||
if (!(driver->caps = vboxCapsInit()) ||
|
||||
!(driver->xmlopt = virDomainXMLOptionNew(&vboxDomainDefParserConfig,
|
||||
NULL, NULL, NULL)))
|
||||
NULL, NULL, NULL, NULL)))
|
||||
goto cleanup;
|
||||
|
||||
return driver;
|
||||
|
@ -114,7 +114,8 @@ vmwareDomainXMLConfigInit(void)
|
||||
virDomainXMLPrivateDataCallbacks priv = { .alloc = vmwareDataAllocFunc,
|
||||
.free = vmwareDataFreeFunc };
|
||||
|
||||
return virDomainXMLOptionNew(&vmwareDomainDefParserConfig, &priv, NULL, NULL);
|
||||
return virDomainXMLOptionNew(&vmwareDomainDefParserConfig, &priv,
|
||||
NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
static virDrvOpenStatus
|
||||
|
@ -591,7 +591,7 @@ virDomainXMLOptionPtr
|
||||
virVMXDomainXMLConfInit(void)
|
||||
{
|
||||
return virDomainXMLOptionNew(&virVMXDomainDefParserConfig, NULL,
|
||||
&virVMXDomainXMLNamespace, NULL);
|
||||
&virVMXDomainXMLNamespace, NULL, NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
|
@ -328,7 +328,7 @@ vzDriverObjNew(void)
|
||||
if (!(driver->caps = vzBuildCapabilities()) ||
|
||||
!(driver->xmlopt = virDomainXMLOptionNew(&vzDomainDefParserConfig,
|
||||
&vzDomainXMLPrivateDataCallbacksPtr,
|
||||
NULL, NULL)) ||
|
||||
NULL, NULL, NULL)) ||
|
||||
!(driver->domains = virDomainObjListNew()) ||
|
||||
!(driver->domainEventState = virObjectEventStateNew()) ||
|
||||
(vzInitVersion(driver) < 0) ||
|
||||
|
@ -401,7 +401,7 @@ virDomainXMLOptionPtr
|
||||
xenDomainXMLConfInit(void)
|
||||
{
|
||||
return virDomainXMLOptionNew(&xenDomainDefParserConfig,
|
||||
NULL, NULL, NULL);
|
||||
NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -200,7 +200,7 @@ xenapiConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
|
||||
}
|
||||
|
||||
if (!(privP->xmlopt = virDomainXMLOptionNew(&xenapiDomainDefParserConfig,
|
||||
NULL, NULL, NULL))) {
|
||||
NULL, NULL, NULL, NULL))) {
|
||||
xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
_("Failed to create XML conf object"));
|
||||
goto error;
|
||||
|
@ -131,7 +131,7 @@ mymain(void)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if ((driver.xmlopt = virDomainXMLOptionNew(NULL, NULL,
|
||||
NULL, NULL)) == NULL)
|
||||
NULL, NULL, NULL)) == NULL)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
# define DO_TEST_FULL(name, flags) \
|
||||
|
@ -1136,7 +1136,7 @@ virDomainXMLOptionPtr virTestGenericDomainXMLConfInit(void)
|
||||
{
|
||||
return virDomainXMLOptionNew(&virTestGenericDomainDefParserConfig,
|
||||
&virTestGenericPrivateDataCallbacks,
|
||||
NULL, NULL);
|
||||
NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user