提交 3a0f39bc 编写于 作者: J Jiri Denemark

Pass domain object to private data formatter/parser

So that they can format private data (e.g., disk private data) stored
elsewhere in the domain object.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
上级 b247d47f
...@@ -16185,7 +16185,7 @@ virDomainObjParseXML(xmlDocPtr xml, ...@@ -16185,7 +16185,7 @@ virDomainObjParseXML(xmlDocPtr xml,
VIR_FREE(nodes); VIR_FREE(nodes);
if (xmlopt->privateData.parse && if (xmlopt->privateData.parse &&
((xmlopt->privateData.parse)(ctxt, obj->privateData)) < 0) xmlopt->privateData.parse(ctxt, obj) < 0)
goto error; goto error;
return obj; return obj;
...@@ -22074,7 +22074,7 @@ virDomainObjFormat(virDomainXMLOptionPtr xmlopt, ...@@ -22074,7 +22074,7 @@ virDomainObjFormat(virDomainXMLOptionPtr xmlopt,
} }
if (xmlopt->privateData.format && if (xmlopt->privateData.format &&
((xmlopt->privateData.format)(&buf, obj->privateData)) < 0) xmlopt->privateData.format(&buf, obj) < 0)
goto error; goto error;
if (virDomainDefFormatInternal(obj->def, flags, &buf) < 0) if (virDomainDefFormatInternal(obj->def, flags, &buf) < 0)
......
...@@ -2357,8 +2357,10 @@ typedef virDomainXMLOption *virDomainXMLOptionPtr; ...@@ -2357,8 +2357,10 @@ typedef virDomainXMLOption *virDomainXMLOptionPtr;
typedef void *(*virDomainXMLPrivateDataAllocFunc)(void); typedef void *(*virDomainXMLPrivateDataAllocFunc)(void);
typedef void (*virDomainXMLPrivateDataFreeFunc)(void *); typedef void (*virDomainXMLPrivateDataFreeFunc)(void *);
typedef virObjectPtr (*virDomainXMLPrivateDataNewFunc)(void); typedef virObjectPtr (*virDomainXMLPrivateDataNewFunc)(void);
typedef int (*virDomainXMLPrivateDataFormatFunc)(virBufferPtr, void *); typedef int (*virDomainXMLPrivateDataFormatFunc)(virBufferPtr,
typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr, void *); virDomainObjPtr);
typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr,
virDomainObjPtr);
/* Called once after everything else has been parsed, for adjusting /* Called once after everything else has been parsed, for adjusting
* overall domain defaults. */ * overall domain defaults. */
......
...@@ -223,9 +223,10 @@ libxlDomainObjPrivateFree(void *data) ...@@ -223,9 +223,10 @@ libxlDomainObjPrivateFree(void *data)
} }
static int static int
libxlDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data) libxlDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
virDomainObjPtr vm)
{ {
libxlDomainObjPrivatePtr priv = data; libxlDomainObjPrivatePtr priv = vm->privateData;
priv->lockState = virXPathString("string(./lockstate)", ctxt); priv->lockState = virXPathString("string(./lockstate)", ctxt);
...@@ -233,9 +234,10 @@ libxlDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data) ...@@ -233,9 +234,10 @@ libxlDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data)
} }
static int static int
libxlDomainObjPrivateXMLFormat(virBufferPtr buf, void *data) libxlDomainObjPrivateXMLFormat(virBufferPtr buf,
virDomainObjPtr vm)
{ {
libxlDomainObjPrivatePtr priv = data; libxlDomainObjPrivatePtr priv = vm->privateData;
if (priv->lockState) if (priv->lockState)
virBufferAsprintf(buf, "<lockstate>%s</lockstate>\n", priv->lockState); virBufferAsprintf(buf, "<lockstate>%s</lockstate>\n", priv->lockState);
......
...@@ -51,9 +51,11 @@ static void virLXCDomainObjPrivateFree(void *data) ...@@ -51,9 +51,11 @@ static void virLXCDomainObjPrivateFree(void *data)
} }
static int virLXCDomainObjPrivateXMLFormat(virBufferPtr buf, void *data) static int
virLXCDomainObjPrivateXMLFormat(virBufferPtr buf,
virDomainObjPtr vm)
{ {
virLXCDomainObjPrivatePtr priv = data; virLXCDomainObjPrivatePtr priv = vm->privateData;
virBufferAsprintf(buf, "<init pid='%llu'/>\n", virBufferAsprintf(buf, "<init pid='%llu'/>\n",
(unsigned long long)priv->initpid); (unsigned long long)priv->initpid);
...@@ -61,9 +63,11 @@ static int virLXCDomainObjPrivateXMLFormat(virBufferPtr buf, void *data) ...@@ -61,9 +63,11 @@ static int virLXCDomainObjPrivateXMLFormat(virBufferPtr buf, void *data)
return 0; return 0;
} }
static int virLXCDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data) static int
virLXCDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
virDomainObjPtr vm)
{ {
virLXCDomainObjPrivatePtr priv = data; virLXCDomainObjPrivatePtr priv = vm->privateData;
unsigned long long thepid; unsigned long long thepid;
if (virXPathULongLong("string(./init[1]/@pid)", ctxt, &thepid) < 0) { if (virXPathULongLong("string(./init[1]/@pid)", ctxt, &thepid) < 0) {
......
...@@ -511,9 +511,10 @@ qemuDomainObjPrivateFree(void *data) ...@@ -511,9 +511,10 @@ qemuDomainObjPrivateFree(void *data)
static int static int
qemuDomainObjPrivateXMLFormat(virBufferPtr buf, void *data) qemuDomainObjPrivateXMLFormat(virBufferPtr buf,
virDomainObjPtr vm)
{ {
qemuDomainObjPrivatePtr priv = data; qemuDomainObjPrivatePtr priv = vm->privateData;
const char *monitorpath; const char *monitorpath;
qemuDomainJob job; qemuDomainJob job;
...@@ -600,9 +601,10 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, void *data) ...@@ -600,9 +601,10 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, void *data)
} }
static int static int
qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data) qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
virDomainObjPtr vm)
{ {
qemuDomainObjPrivatePtr priv = data; qemuDomainObjPrivatePtr priv = vm->privateData;
char *monitorpath; char *monitorpath;
char *tmp; char *tmp;
int n; int n;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册