[PATCH v2 06/22] Pass domain object to private data formatter/parser

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



So that they can format private data (e.g., disk private data) stored
elsewhere in the domain object.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---

Notes:
    Version 2:
    - no changes

 src/conf/domain_conf.c   |  4 ++--
 src/conf/domain_conf.h   |  6 ++++--
 src/libxl/libxl_domain.c | 10 ++++++----
 src/lxc/lxc_domain.c     | 12 ++++++++----
 src/qemu/qemu_domain.c   | 10 ++++++----
 5 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0850b9b..cf0f54b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15900,7 +15900,7 @@ virDomainObjParseXML(xmlDocPtr xml,
     VIR_FREE(nodes);
 
     if (xmlopt->privateData.parse &&
-        ((xmlopt->privateData.parse)(ctxt, obj->privateData)) < 0)
+        xmlopt->privateData.parse(ctxt, obj) < 0)
         goto error;
 
     return obj;
@@ -21828,7 +21828,7 @@ virDomainObjFormat(virDomainXMLOptionPtr xmlopt,
     }
 
     if (xmlopt->privateData.format &&
-        ((xmlopt->privateData.format)(&buf, obj->privateData)) < 0)
+        xmlopt->privateData.format(&buf, obj) < 0)
         goto error;
 
     if (virDomainDefFormatInternal(obj->def, flags, &buf) < 0)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 1039f78..05a8884 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2344,8 +2344,10 @@ typedef virDomainXMLOption *virDomainXMLOptionPtr;
 typedef void *(*virDomainXMLPrivateDataAllocFunc)(void);
 typedef void (*virDomainXMLPrivateDataFreeFunc)(void *);
 typedef virObjectPtr (*virDomainXMLPrivateDataNewFunc)(void);
-typedef int (*virDomainXMLPrivateDataFormatFunc)(virBufferPtr, void *);
-typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr, void *);
+typedef int (*virDomainXMLPrivateDataFormatFunc)(virBufferPtr,
+                                                 virDomainObjPtr);
+typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr,
+                                                virDomainObjPtr);
 
 /* Called once after everything else has been parsed, for adjusting
  * overall domain defaults.  */
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index c7f0ed9..d38ed61 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -223,9 +223,10 @@ libxlDomainObjPrivateFree(void *data)
 }
 
 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);
 
@@ -233,9 +234,10 @@ libxlDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data)
 }
 
 static int
-libxlDomainObjPrivateXMLFormat(virBufferPtr buf, void *data)
+libxlDomainObjPrivateXMLFormat(virBufferPtr buf,
+                               virDomainObjPtr vm)
 {
-    libxlDomainObjPrivatePtr priv = data;
+    libxlDomainObjPrivatePtr priv = vm->privateData;
 
     if (priv->lockState)
         virBufferAsprintf(buf, "<lockstate>%s</lockstate>\n", priv->lockState);
diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c
index c2180cb..70606f3 100644
--- a/src/lxc/lxc_domain.c
+++ b/src/lxc/lxc_domain.c
@@ -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",
                       (unsigned long long)priv->initpid);
@@ -61,9 +63,11 @@ static int virLXCDomainObjPrivateXMLFormat(virBufferPtr buf, void *data)
     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;
 
     if (virXPathULongLong("string(./init[1]/@pid)", ctxt, &thepid) < 0) {
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 144a968..f6c9add 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -511,9 +511,10 @@ qemuDomainObjPrivateFree(void *data)
 
 
 static int
-qemuDomainObjPrivateXMLFormat(virBufferPtr buf, void *data)
+qemuDomainObjPrivateXMLFormat(virBufferPtr buf,
+                              virDomainObjPtr vm)
 {
-    qemuDomainObjPrivatePtr priv = data;
+    qemuDomainObjPrivatePtr priv = vm->privateData;
     const char *monitorpath;
     qemuDomainJob job;
 
@@ -600,9 +601,10 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, void *data)
 }
 
 static int
-qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data)
+qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
+                             virDomainObjPtr vm)
 {
-    qemuDomainObjPrivatePtr priv = data;
+    qemuDomainObjPrivatePtr priv = vm->privateData;
     char *monitorpath;
     char *tmp;
     int n;
-- 
2.4.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]