[PATCH 1/9] conf: Introduce virDomainDefPostParseOpaque

[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     | 13 ++++++++++++-
 src/conf/domain_conf.h     | 14 ++++++++++++--
 src/libvirt_private.syms   |  1 +
 src/libxl/libxl_domain.c   |  3 ++-
 src/lxc/lxc_domain.c       |  3 ++-
 src/openvz/openvz_driver.c |  3 ++-
 src/phyp/phyp_driver.c     |  3 ++-
 src/qemu/qemu_domain.c     |  3 ++-
 src/uml/uml_driver.c       |  3 ++-
 src/vbox/vbox_common.c     |  3 ++-
 src/vmware/vmware_driver.c |  3 ++-
 src/vmx/vmx.c              |  3 ++-
 src/vz/vz_driver.c         |  3 ++-
 src/xen/xen_driver.c       |  3 ++-
 src/xenapi/xenapi_driver.c |  3 ++-
 16 files changed, 51 insertions(+), 16 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 b4a3e92..e8c8465 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4532,6 +4532,16 @@ virDomainDefPostParse(virDomainDefPtr def,
                       unsigned int parseFlags,
                       virDomainXMLOptionPtr xmlopt)
 {
+    return virDomainDefPostParseOpaque(def, caps, parseFlags, xmlopt, NULL);
+}
+
+int
+virDomainDefPostParseOpaque(virDomainDefPtr def,
+                            virCapsPtr caps,
+                            unsigned int parseFlags,
+                            virDomainXMLOptionPtr xmlopt,
+                            void *parseOpaque)
+{
     int ret;
     struct virDomainDefPostParseDeviceIteratorData data = {
         .caps = caps,
@@ -4547,7 +4557,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;
     }
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index c14a39c..6056aa7 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,
@@ -2453,6 +2457,12 @@ virDomainDefPostParse(virDomainDefPtr def,
                       unsigned int parseFlags,
                       virDomainXMLOptionPtr xmlopt);
 
+int virDomainDefPostParseOpaque(virDomainDefPtr def,
+                                virCapsPtr caps,
+                                unsigned int parseFlags,
+                                virDomainXMLOptionPtr xmlopt,
+                                void *parseOpaque);
+
 int virDomainDefValidate(virDomainDefPtr def,
                          virCapsPtr caps,
                          unsigned int parseFlags,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 9610e0c..5fd1178 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -250,6 +250,7 @@ virDomainDefParseFile;
 virDomainDefParseNode;
 virDomainDefParseString;
 virDomainDefPostParse;
+virDomainDefPostParseOpaque;
 virDomainDefSetMemoryTotal;
 virDomainDefSetVcpus;
 virDomainDefSetVcpusMax;
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/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 3f16dbe..c26da14 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/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..ce0b155 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;
 }
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)
-- 
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]