[PATCH v2 01/11] virDomainDefPostParse: Introduce @parseOpaque argument

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

 



Some callers might want to pass yet another pointer to opaque
data to post parse callbacks. The driver generic one is not
enough because two threads executing post parse callback might
want see different data (e.g. domain object pointer that domain
def belongs to).

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/bhyve/bhyve_domain.c      |  3 ++-
 src/conf/domain_conf.c        |  8 +++++---
 src/conf/domain_conf.h        | 18 +++++++++++-------
 src/libxl/libxl_domain.c      |  3 ++-
 src/lxc/lxc_domain.c          |  3 ++-
 src/lxc/lxc_native.c          |  2 +-
 src/openvz/openvz_driver.c    |  3 ++-
 src/phyp/phyp_driver.c        |  3 ++-
 src/qemu/qemu_domain.c        |  3 ++-
 src/qemu/qemu_driver.c        |  6 +++---
 src/qemu/qemu_parse_command.c |  2 +-
 src/uml/uml_driver.c          |  3 ++-
 src/vbox/vbox_common.c        |  3 ++-
 src/vmware/vmware_driver.c    |  3 ++-
 src/vmx/vmx.c                 |  5 +++--
 src/vz/vz_driver.c            |  3 ++-
 src/xen/xen_driver.c          |  3 ++-
 src/xenapi/xenapi_driver.c    |  3 ++-
 src/xenconfig/xen_sxpr.c      |  2 +-
 src/xenconfig/xen_xl.c        |  2 +-
 src/xenconfig/xen_xm.c        |  2 +-
 21 files changed, 51 insertions(+), 32 deletions(-)

diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c
index 89cb171..3273462 100644
--- a/src/bhyve/bhyve_domain.c
+++ b/src/bhyve/bhyve_domain.c
@@ -61,7 +61,8 @@ static int
 bhyveDomainDefPostParse(virDomainDefPtr def,
                         virCapsPtr caps ATTRIBUTE_UNUSED,
                         unsigned int parseFlags ATTRIBUTE_UNUSED,
-                        void *opaque ATTRIBUTE_UNUSED)
+                        void *opaque ATTRIBUTE_UNUSED,
+                        void *parseOpaque ATTRIBUTE_UNUSED)
 {
     /* Add an implicit PCI root controller */
     if (virDomainDefMaybeAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0,
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index dd34cec..c8cb68f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4562,7 +4562,8 @@ int
 virDomainDefPostParse(virDomainDefPtr def,
                       virCapsPtr caps,
                       unsigned int parseFlags,
-                      virDomainXMLOptionPtr xmlopt)
+                      virDomainXMLOptionPtr xmlopt,
+                      void *parseOpaque)
 {
     int ret;
     struct virDomainDefPostParseDeviceIteratorData data = {
@@ -4579,7 +4580,8 @@ virDomainDefPostParse(virDomainDefPtr def,
     /* call the domain config callback */
     if (xmlopt->config.domainPostParseCallback) {
         ret = xmlopt->config.domainPostParseCallback(def, caps, parseFlags,
-                                                     xmlopt->config.priv);
+                                                     xmlopt->config.priv,
+                                                     parseOpaque);
         if (ret < 0)
             return ret;
     }
@@ -17626,7 +17628,7 @@ virDomainDefParseXML(xmlDocPtr xml,
         goto error;
 
     /* callback to fill driver specific domain aspects */
-    if (virDomainDefPostParse(def, caps, flags, xmlopt) < 0)
+    if (virDomainDefPostParse(def, caps, flags, xmlopt, NULL) < 0)
         goto error;
 
     /* valdiate configuration */
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ce90c27..c61b364 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2361,11 +2361,15 @@ typedef struct _virDomainXMLOption virDomainXMLOption;
 typedef virDomainXMLOption *virDomainXMLOptionPtr;
 
 /* Called once after everything else has been parsed, for adjusting
- * overall domain defaults.  */
+ * overall domain defaults.
+ * @parseOpaque is opaque data passed by virDomainDefParse* caller,
+ * @opqaue is opaque data set by driver (usually pointer to driver
+ * private data). */
 typedef int (*virDomainDefPostParseCallback)(virDomainDefPtr def,
                                              virCapsPtr caps,
                                              unsigned int parseFlags,
-                                             void *opaque);
+                                             void *opaque,
+                                             void *parseOpaque);
 /* Called once per device, for adjusting per-device settings while
  * leaving the overall domain otherwise unchanged.  */
 typedef int (*virDomainDeviceDefPostParseCallback)(virDomainDeviceDefPtr dev,
@@ -2447,11 +2451,11 @@ virDomainXMLNamespacePtr
 virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt)
     ATTRIBUTE_NONNULL(1);
 
-int
-virDomainDefPostParse(virDomainDefPtr def,
-                      virCapsPtr caps,
-                      unsigned int parseFlags,
-                      virDomainXMLOptionPtr xmlopt);
+int virDomainDefPostParse(virDomainDefPtr def,
+                          virCapsPtr caps,
+                          unsigned int parseFlags,
+                          virDomainXMLOptionPtr xmlopt,
+                          void *parseOpaque);
 
 int virDomainDefValidate(virDomainDefPtr def,
                          virCapsPtr caps,
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 43f4a7f..a53b977 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -380,7 +380,8 @@ static int
 libxlDomainDefPostParse(virDomainDefPtr def,
                         virCapsPtr caps ATTRIBUTE_UNUSED,
                         unsigned int parseFlags ATTRIBUTE_UNUSED,
-                        void *opaque ATTRIBUTE_UNUSED)
+                        void *opaque ATTRIBUTE_UNUSED,
+                        void *parseOpaque ATTRIBUTE_UNUSED)
 {
     /* Xen PV domains always have a PV console, so add one to the domain config
      * via post-parse callback if not explicitly specified in the XML. */
diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c
index 60db229..c2e362a 100644
--- a/src/lxc/lxc_domain.c
+++ b/src/lxc/lxc_domain.c
@@ -364,7 +364,8 @@ static int
 virLXCDomainDefPostParse(virDomainDefPtr def,
                          virCapsPtr caps,
                          unsigned int parseFlags ATTRIBUTE_UNUSED,
-                         void *opaque ATTRIBUTE_UNUSED)
+                         void *opaque ATTRIBUTE_UNUSED,
+                         void *parseOpaque ATTRIBUTE_UNUSED)
 {
     /* check for emulator and create a default one if needed */
     if (!def->emulator &&
diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
index 94fb659..76b7922 100644
--- a/src/lxc/lxc_native.c
+++ b/src/lxc/lxc_native.c
@@ -1095,7 +1095,7 @@ lxcParseConfigString(const char *config,
     lxcSetCapDrop(vmdef, properties);
 
     if (virDomainDefPostParse(vmdef, caps, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE,
-                              xmlopt) < 0)
+                              xmlopt, NULL) < 0)
         goto cleanup;
 
     goto cleanup;
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 6c3edc9..e1c008c 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -92,7 +92,8 @@ static int
 openvzDomainDefPostParse(virDomainDefPtr def,
                          virCapsPtr caps ATTRIBUTE_UNUSED,
                          unsigned int parseFlags ATTRIBUTE_UNUSED,
-                         void *opaque ATTRIBUTE_UNUSED)
+                         void *opaque ATTRIBUTE_UNUSED,
+                         void *parseOpaque ATTRIBUTE_UNUSED)
 {
     /* fill the init path */
     if (def->os.type == VIR_DOMAIN_OSTYPE_EXE && !def->os.init) {
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 3dd8927..2c1a854 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -1097,7 +1097,8 @@ static int
 phypDomainDefPostParse(virDomainDefPtr def ATTRIBUTE_UNUSED,
                        virCapsPtr caps ATTRIBUTE_UNUSED,
                        unsigned int parseFlags ATTRIBUTE_UNUSED,
-                       void *opaque ATTRIBUTE_UNUSED)
+                       void *opaque ATTRIBUTE_UNUSED,
+                       void *parseOpaque ATTRIBUTE_UNUSED)
 {
     return 0;
 }
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 1fbad91..b33e018 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2326,7 +2326,8 @@ static int
 qemuDomainDefPostParse(virDomainDefPtr def,
                        virCapsPtr caps,
                        unsigned int parseFlags,
-                       void *opaque)
+                       void *opaque,
+                       void *parseOpaque ATTRIBUTE_UNUSED)
 {
     virQEMUDriverPtr driver = opaque;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ee16cb5..50d62bb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7917,7 +7917,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
          return -1;
     }
 
-    if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt) < 0)
+    if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0)
         return -1;
 
     return 0;
@@ -8074,7 +8074,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
         return -1;
     }
 
-    if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt) < 0)
+    if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0)
         return -1;
 
     return 0;
@@ -8173,7 +8173,7 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
         return -1;
     }
 
-    if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt) < 0)
+    if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0)
         return -1;
 
     return 0;
diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index e3a6a34..279f3da 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -2628,7 +2628,7 @@ qemuParseCommandLine(virCapsPtr caps,
 
     VIR_FREE(nics);
 
-    if (virDomainDefPostParse(def, caps, 0, xmlopt) < 0)
+    if (virDomainDefPostParse(def, caps, 0, xmlopt, NULL) < 0)
         goto error;
 
     if (cmd->num_args || cmd->num_env) {
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 4f25f76..90d2eae 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -435,7 +435,8 @@ static int
 umlDomainDefPostParse(virDomainDefPtr def ATTRIBUTE_UNUSED,
                       virCapsPtr caps ATTRIBUTE_UNUSED,
                       unsigned int parseFlags ATTRIBUTE_UNUSED,
-                      void *opaque ATTRIBUTE_UNUSED)
+                      void *opaque ATTRIBUTE_UNUSED,
+                      void *parseOpaque ATTRIBUTE_UNUSED)
 {
     return 0;
 }
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 3624a5e..dfade01 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -255,7 +255,8 @@ static int
 vboxDomainDefPostParse(virDomainDefPtr def ATTRIBUTE_UNUSED,
                        virCapsPtr caps ATTRIBUTE_UNUSED,
                        unsigned int parseFlags ATTRIBUTE_UNUSED,
-                       void *opaque ATTRIBUTE_UNUSED)
+                       void *opaque ATTRIBUTE_UNUSED,
+                       void *parseOpaque ATTRIBUTE_UNUSED)
 {
     return 0;
 }
diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index eea2d1b..d44b8a3 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -86,7 +86,8 @@ static int
 vmwareDomainDefPostParse(virDomainDefPtr def ATTRIBUTE_UNUSED,
                          virCapsPtr caps ATTRIBUTE_UNUSED,
                          unsigned int parseFlags ATTRIBUTE_UNUSED,
-                         void *opaque ATTRIBUTE_UNUSED)
+                         void *opaque ATTRIBUTE_UNUSED,
+                         void *parseOpaque ATTRIBUTE_UNUSED)
 {
     return 0;
 }
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 4a08b0f..3ae4b73 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -528,7 +528,8 @@ static int
 virVMXDomainDefPostParse(virDomainDefPtr def ATTRIBUTE_UNUSED,
                          virCapsPtr caps ATTRIBUTE_UNUSED,
                          unsigned int parseFlags ATTRIBUTE_UNUSED,
-                         void *opaque ATTRIBUTE_UNUSED)
+                         void *opaque ATTRIBUTE_UNUSED,
+                         void *parseOpaque ATTRIBUTE_UNUSED)
 {
     return 0;
 }
@@ -1817,7 +1818,7 @@ virVMXParseConfig(virVMXContext *ctx,
     }
 
     if (virDomainDefPostParse(def, caps, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE,
-                              xmlopt) < 0)
+                              xmlopt, NULL) < 0)
         goto cleanup;
 
     success = true;
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 819dad7..2f2be122 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -263,7 +263,8 @@ static int
 vzDomainDefPostParse(virDomainDefPtr def,
                      virCapsPtr caps ATTRIBUTE_UNUSED,
                      unsigned int parseFlags ATTRIBUTE_UNUSED,
-                     void *opaque ATTRIBUTE_UNUSED)
+                     void *opaque ATTRIBUTE_UNUSED,
+                     void *parseOpaque ATTRIBUTE_UNUSED)
 {
     if (vzDomainDefAddDefaultInputDevices(def) < 0)
         return -1;
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index 2bab61e..5c38bdf 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -370,7 +370,8 @@ static int
 xenDomainDefPostParse(virDomainDefPtr def,
                       virCapsPtr caps ATTRIBUTE_UNUSED,
                       unsigned int parseFlags ATTRIBUTE_UNUSED,
-                      void *opaque ATTRIBUTE_UNUSED)
+                      void *opaque ATTRIBUTE_UNUSED,
+                      void *parseOpaque ATTRIBUTE_UNUSED)
 {
     if (!def->memballoon) {
         virDomainMemballoonDefPtr memballoon;
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 9a861c1..a58c10e 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -75,7 +75,8 @@ static int
 xenapiDomainDefPostParse(virDomainDefPtr def,
                          virCapsPtr caps ATTRIBUTE_UNUSED,
                          unsigned int parseFlags ATTRIBUTE_UNUSED,
-                         void *opaque ATTRIBUTE_UNUSED)
+                         void *opaque ATTRIBUTE_UNUSED,
+                         void *parseOpaque ATTRIBUTE_UNUSED)
 {
     /* add implicit input device */
     if (xenDomainDefAddImplicitInputDevice(def) < 0)
diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c
index 40dc53c..0b04fc8 100644
--- a/src/xenconfig/xen_sxpr.c
+++ b/src/xenconfig/xen_sxpr.c
@@ -1458,7 +1458,7 @@ xenParseSxpr(const struct sexpr *root,
     }
 
     if (virDomainDefPostParse(def, caps, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE,
-                              xmlopt) < 0)
+                              xmlopt, NULL) < 0)
         goto error;
 
     return def;
diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
index 7774dfc..4615bfd 100644
--- a/src/xenconfig/xen_xl.c
+++ b/src/xenconfig/xen_xl.c
@@ -721,7 +721,7 @@ xenParseXL(virConfPtr conf,
         goto cleanup;
 
     if (virDomainDefPostParse(def, caps, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE,
-                              xmlopt) < 0)
+                              xmlopt, NULL) < 0)
         goto cleanup;
 
     return def;
diff --git a/src/xenconfig/xen_xm.c b/src/xenconfig/xen_xm.c
index 124c94a..8ef68bb 100644
--- a/src/xenconfig/xen_xm.c
+++ b/src/xenconfig/xen_xm.c
@@ -461,7 +461,7 @@ xenParseXM(virConfPtr conf,
          goto cleanup;
 
     if (virDomainDefPostParse(def, caps, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE,
-                              xmlopt) < 0)
+                              xmlopt, NULL) < 0)
         goto cleanup;
 
     return def;
-- 
2.8.4

--
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]