[PATCH 1/2] Move virtio *Free() functions from domain_addr to domain_conf

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

 



More hypervisors may implement the possibility of specifying device
addresses, so it makes sense to make QEMU-specific code more generic
to be prepared for it.

The first step is to move data from obj->privateData to domainDef.
Two functions and a few struct definitions have to be in domain_addr
because virDomainDefFree() has to execute them when freeing
the domainDef structure.
---
 src/conf/domain_addr.c   | 22 ----------------------
 src/conf/domain_addr.h   | 17 -----------------
 src/conf/domain_conf.c   | 21 +++++++++++++++++++++
 src/conf/domain_conf.h   | 17 +++++++++++++++++
 src/libvirt_private.syms |  3 ++-
 5 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 794270d..e482328 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -856,15 +856,6 @@ virDomainVirtioSerialAddrSetCreate(void)
     return ret;
 }
 
-static void
-virDomainVirtioSerialControllerFree(virDomainVirtioSerialControllerPtr cont)
-{
-    if (cont) {
-        virBitmapFree(cont->ports);
-        VIR_FREE(cont);
-    }
-}
-
 static ssize_t
 virDomainVirtioSerialAddrPlaceController(virDomainVirtioSerialAddrSetPtr addrs,
                                          virDomainVirtioSerialControllerPtr cont)
@@ -962,19 +953,6 @@ virDomainVirtioSerialAddrSetAddControllers(virDomainVirtioSerialAddrSetPtr addrs
     return 0;
 }
 
-
-void
-virDomainVirtioSerialAddrSetFree(virDomainVirtioSerialAddrSetPtr addrs)
-{
-    size_t i;
-    if (addrs) {
-        for (i = 0; i < addrs->ncontrollers; i++)
-            virDomainVirtioSerialControllerFree(addrs->controllers[i]);
-        VIR_FREE(addrs->controllers);
-        VIR_FREE(addrs);
-    }
-}
-
 static int
 virDomainVirtioSerialAddrSetAutoaddController(virDomainDefPtr def,
                                               virDomainVirtioSerialAddrSetPtr addrs,
diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
index f3eda89..0fb5f85 100644
--- a/src/conf/domain_addr.h
+++ b/src/conf/domain_addr.h
@@ -185,29 +185,12 @@ int virDomainCCWAddressReleaseAddr(virDomainCCWAddressSetPtr addrs,
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
 virDomainCCWAddressSetPtr virDomainCCWAddressSetCreate(void);
 
-struct _virDomainVirtioSerialController {
-    unsigned int idx;
-    virBitmapPtr ports;
-};
-
-typedef struct _virDomainVirtioSerialController virDomainVirtioSerialController;
-typedef virDomainVirtioSerialController *virDomainVirtioSerialControllerPtr;
-
-struct _virDomainVirtioSerialAddrSet {
-    virDomainVirtioSerialControllerPtr *controllers;
-    size_t ncontrollers;
-};
-typedef struct _virDomainVirtioSerialAddrSet virDomainVirtioSerialAddrSet;
-typedef virDomainVirtioSerialAddrSet *virDomainVirtioSerialAddrSetPtr;
-
 virDomainVirtioSerialAddrSetPtr
 virDomainVirtioSerialAddrSetCreate(void);
 int
 virDomainVirtioSerialAddrSetAddControllers(virDomainVirtioSerialAddrSetPtr addrs,
                                            virDomainDefPtr def)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
-void
-virDomainVirtioSerialAddrSetFree(virDomainVirtioSerialAddrSetPtr addrs);
 bool
 virDomainVirtioSerialAddrIsComplete(virDomainDeviceInfoPtr info);
 int
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4196537..6900eb9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2514,6 +2514,27 @@ virDomainLoaderDefFree(virDomainLoaderDefPtr loader)
     VIR_FREE(loader);
 }
 
+void
+virDomainVirtioSerialControllerFree(virDomainVirtioSerialControllerPtr cont)
+{
+    if (cont) {
+        virBitmapFree(cont->ports);
+        VIR_FREE(cont);
+    }
+}
+
+void
+virDomainVirtioSerialAddrSetFree(virDomainVirtioSerialAddrSetPtr addrs)
+{
+    size_t i;
+    if (addrs) {
+        for (i = 0; i < addrs->ncontrollers; i++)
+            virDomainVirtioSerialControllerFree(addrs->controllers[i]);
+        VIR_FREE(addrs->controllers);
+        VIR_FREE(addrs);
+    }
+}
+
 void virDomainDefFree(virDomainDefPtr def)
 {
     size_t i;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 6e81e52..7dcecdc 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2089,6 +2089,21 @@ struct _virDomainMemtune {
     unsigned long long swap_hard_limit; /* in kibibytes, limit at off_t bytes */
 };
 
+struct _virDomainVirtioSerialController {
+    unsigned int idx;
+    virBitmapPtr ports;
+};
+
+typedef struct _virDomainVirtioSerialController virDomainVirtioSerialController;
+typedef virDomainVirtioSerialController *virDomainVirtioSerialControllerPtr;
+
+struct _virDomainVirtioSerialAddrSet {
+    virDomainVirtioSerialControllerPtr *controllers;
+    size_t ncontrollers;
+};
+typedef struct _virDomainVirtioSerialAddrSet virDomainVirtioSerialAddrSet;
+typedef virDomainVirtioSerialAddrSet *virDomainVirtioSerialAddrSetPtr;
+
 typedef struct _virDomainPowerManagement virDomainPowerManagement;
 typedef virDomainPowerManagement *virDomainPowerManagementPtr;
 
@@ -2526,6 +2541,8 @@ void virDomainDefClearPCIAddresses(virDomainDefPtr def);
 void virDomainDefClearCCWAddresses(virDomainDefPtr def);
 void virDomainDefClearDeviceAliases(virDomainDefPtr def);
 void virDomainTPMDefFree(virDomainTPMDefPtr def);
+void virDomainVirtioSerialControllerFree(virDomainVirtioSerialControllerPtr cont);
+void virDomainVirtioSerialAddrSetFree(virDomainVirtioSerialAddrSetPtr addrs);
 
 typedef int (*virDomainDeviceInfoCallback)(virDomainDefPtr def,
                                            virDomainDeviceDefPtr dev,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index f62dd70..d29eb07 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -116,7 +116,6 @@ virDomainVirtioSerialAddrRelease;
 virDomainVirtioSerialAddrReserve;
 virDomainVirtioSerialAddrSetAddControllers;
 virDomainVirtioSerialAddrSetCreate;
-virDomainVirtioSerialAddrSetFree;
 
 
 # conf/domain_audit.h
@@ -479,6 +478,8 @@ virDomainVideoDefaultType;
 virDomainVideoDefFree;
 virDomainVideoTypeFromString;
 virDomainVideoTypeToString;
+virDomainVirtioSerialAddrSetFree;
+virDomainVirtioSerialControllerFree;
 virDomainVirtTypeFromString;
 virDomainVirtTypeToString;
 virDomainWatchdogActionTypeFromString;
-- 
2.7.4 (Apple Git-66)

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