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

[libvirt] [PATCH RFC 1/8] add virCapabilitiesDupMachines



Add support to duplicate a virCapsGuestMachine object -- e.g., from
cached emulator information.

---
 src/conf/capabilities.c  |   34 ++++++++++++++++++++++++++++++++++
 src/conf/capabilities.h  |    3 +++
 src/libvirt_private.syms |    1 +
 3 files changed, 38 insertions(+)

Index: libvirt-0.9.10/src/conf/capabilities.h
===================================================================
--- libvirt-0.9.10.orig/src/conf/capabilities.h
+++ libvirt-0.9.10/src/conf/capabilities.h
@@ -208,6 +208,9 @@ virCapabilitiesSetHostCPU(virCapsPtr cap
 extern virCapsGuestMachinePtr *
 virCapabilitiesAllocMachines(const char *const *names,
                              int nnames);
+extern virCapsGuestMachinePtr *
+virCapabilitiesDupMachines(const virCapsGuestMachinePtr *smachines,
+                             int nmachines);
 extern void
 virCapabilitiesFreeMachines(virCapsGuestMachinePtr *machines,
                             int nmachines);
Index: libvirt-0.9.10/src/conf/capabilities.c
===================================================================
--- libvirt-0.9.10.orig/src/conf/capabilities.c
+++ libvirt-0.9.10/src/conf/capabilities.c
@@ -325,6 +325,40 @@ virCapabilitiesAllocMachines(const char
 }
 
 /**
+ * virCapabilitiesDupMachines:
+ * @smachines: table of virCapsGuestMachinePtr
+ * @nmachines: number of machine variants in table
+ *
+ * Allocate a table of virCapsGuestMachinePtr from the supplied table
+ * of virCapsGuestMachinePtr
+ */
+virCapsGuestMachinePtr *
+virCapabilitiesDupMachines(const virCapsGuestMachinePtr *smachines, int nmachines)
+{
+    virCapsGuestMachinePtr *machines;
+    int i;
+
+    if (VIR_ALLOC_N(machines, nmachines) < 0)
+        return NULL;
+
+    for (i = 0; i < nmachines; i++) {
+        if (VIR_ALLOC(machines[i]) < 0 ||
+            !(machines[i]->name = strdup(smachines[i]->name)))
+            goto error;
+        if (smachines[i]->canonical &&
+             !(machines[i]->canonical = strdup(smachines[i]->canonical)))
+             goto error;
+    }
+
+    return machines;
+
+error:
+    virCapabilitiesFreeMachines(machines, nmachines);
+    return NULL;
+
+}
+
+/**
  * virCapabilitiesFreeMachines:
  * @machines: table of vircapsGuestMachinePtr
  *
Index: libvirt-0.9.10/src/libvirt_private.syms
===================================================================
--- libvirt-0.9.10.orig/src/libvirt_private.syms
+++ libvirt-0.9.10/src/libvirt_private.syms
@@ -49,6 +49,7 @@ virCapabilitiesAllocMachines;
 virCapabilitiesDefaultGuestArch;
 virCapabilitiesDefaultGuestEmulator;
 virCapabilitiesDefaultGuestMachine;
+virCapabilitiesDupMachines;
 virCapabilitiesFormatXML;
 virCapabilitiesFree;
 virCapabilitiesFreeMachines;


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