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

[libvirt] [PATCH 1/2] Rename qemudShrinkDisks to virDomainDiskRemove and move to domain_conf.c



From: Soren Hansen <soren linux2go dk>

Other drivers will need this same functionality, so move it to up to
conf/domain_conf.c and give it a more general name.

Signed-off-by: Soren Hansen <soren linux2go dk>
---
 src/conf/domain_conf.c   |   18 ++++++++++++++++++
 src/conf/domain_conf.h   |    2 ++
 src/libvirt_private.syms |    1 +
 src/qemu/qemu_driver.c   |   20 ++------------------
 4 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ee99cd1..e05d5d7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4064,6 +4064,24 @@ void virDomainDiskInsertPreAlloced(virDomainDefPtr def,
 }
 
 
+void virDomainDiskRemove(virDomainDefPtr def, size_t i)
+{
+    if (def->ndisks > 1) {
+        memmove(def->disks + i,
+                def->disks + i + 1,
+                sizeof(*def->disks) *
+                (def->ndisks - (i + 1)));
+        def->ndisks--;
+        if (VIR_REALLOC_N(def->disks, def->ndisks) < 0) {
+            /* ignore, harmless */
+        }
+    } else {
+        VIR_FREE(def->disks);
+        def->ndisks = 0;
+    }
+}
+
+
 int virDomainControllerInsert(virDomainDefPtr def,
                               virDomainControllerDefPtr controller)
 {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 92f98bc..7195c04 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1067,6 +1067,8 @@ void virDomainDiskInsertPreAlloced(virDomainDefPtr def,
                                    virDomainDiskDefPtr disk);
 int virDomainDiskDefAssignAddress(virCapsPtr caps, virDomainDiskDefPtr def);
 
+void virDomainDiskRemove(virDomainDefPtr def, size_t i);
+
 int virDomainControllerInsert(virDomainDefPtr def,
                               virDomainControllerDefPtr controller);
 void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index d5a7a73..c2905ba 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -144,6 +144,7 @@ virDomainDiskDefFree;
 virDomainDiskDeviceTypeToString;
 virDomainDiskInsert;
 virDomainDiskInsertPreAlloced;
+virDomainDiskRemove;
 virDomainDiskDefAssignAddress;
 virDomainControllerInsert;
 virDomainControllerInsertPreAlloced;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 656a1e4..25695df 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8583,22 +8583,6 @@ static inline int qemudFindDisk(virDomainDefPtr def, const char *dst)
     return -1;
 }
 
-static inline void qemudShrinkDisks(virDomainDefPtr def, size_t i)
-{
-    if (def->ndisks > 1) {
-        memmove(def->disks + i,
-                def->disks + i + 1,
-                sizeof(*def->disks) *
-                (def->ndisks - (i + 1)));
-        def->ndisks--;
-        if (VIR_REALLOC_N(def->disks, def->ndisks) < 0) {
-            /* ignore, harmless */
-        }
-    } else {
-        VIR_FREE(def->disks);
-        def->ndisks = 0;
-    }
-}
 
 static int qemudDomainDetachPciDiskDevice(struct qemud_driver *driver,
                                           virDomainObjPtr vm,
@@ -8655,7 +8639,7 @@ static int qemudDomainDetachPciDiskDevice(struct qemud_driver *driver,
         qemuDomainPCIAddressReleaseAddr(priv->pciaddrs, &detach->info) < 0)
         VIR_WARN("Unable to release PCI address on %s", dev->data.disk->src);
 
-    qemudShrinkDisks(vm->def, i);
+    virDomainDiskRemove(vm->def, i);
 
     virDomainDiskDefFree(detach);
 
@@ -8719,7 +8703,7 @@ static int qemudDomainDetachSCSIDiskDevice(struct qemud_driver *driver,
     }
     qemuDomainObjExitMonitorWithDriver(driver, vm);
 
-    qemudShrinkDisks(vm->def, i);
+    virDomainDiskRemove(vm->def, i);
 
     virDomainDiskDefFree(detach);
 
-- 
1.7.0.4


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