[PATCH 5/7] conf: Introduce storage pool functions into capabilities

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

 



https://bugzilla.redhat.com/show_bug.cgi?id=1581670

Introduce the bare bones functions to processing capability
data for the storage driver. Currently just looking to store
and format the storage pool types in output, such as:

  <pool>
    <type>dir</pool>

  <pool>
    <type>fs</pool>
  </pool>

...

  <pool>
    <type>iscsi-direct</pool>
  </pool>

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/conf/capabilities.c  | 60 ++++++++++++++++++++++++++++++++++++++++
 src/conf/capabilities.h  | 15 ++++++++++
 src/libvirt_private.syms |  1 +
 3 files changed, 76 insertions(+)

diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 1269a4c739..c60743a38d 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -28,6 +28,7 @@
 #include "cpu_conf.h"
 #include "domain_conf.h"
 #include "physmem.h"
+#include "storage_conf.h"
 #include "viralloc.h"
 #include "virarch.h"
 #include "virbuffer.h"
@@ -180,6 +181,17 @@ virCapabilitiesFreeGuest(virCapsGuestPtr guest)
     VIR_FREE(guest);
 }
 
+
+static void
+virCapabilitiesFreeStoragePool(virCapsStoragePoolPtr pool)
+{
+    if (!pool)
+        return;
+
+    VIR_FREE(pool);
+}
+
+
 void
 virCapabilitiesFreeNUMAInfo(virCapsPtr caps)
 {
@@ -221,6 +233,10 @@ virCapsDispose(void *object)
     virCapsPtr caps = object;
     size_t i;
 
+    for (i = 0; i < caps->npools; i++)
+        virCapabilitiesFreeStoragePool(caps->pools[i]);
+    VIR_FREE(caps->pools);
+
     for (i = 0; i < caps->nguests; i++)
         virCapabilitiesFreeGuest(caps->guests[i]);
     VIR_FREE(caps->guests);
@@ -792,6 +808,30 @@ virCapabilitiesDomainDataLookup(virCapsPtr caps,
                                                    emulator, machinetype);
 }
 
+
+int
+virCapabilitiesAddStoragePool(virCapsPtr caps,
+                              int poolType)
+{
+    virCapsStoragePoolPtr pool;
+
+    if (VIR_ALLOC(pool) < 0)
+        goto error;
+
+    pool->type = poolType;
+
+    if (VIR_RESIZE_N(caps->pools, caps->npools_max, caps->npools, 1) < 0)
+        goto error;
+    caps->pools[caps->npools++] = pool;
+
+    return 0;
+
+ error:
+    virCapabilitiesFreeStoragePool(pool);
+    return -1;
+}
+
+
 static int
 virCapabilitiesFormatNUMATopology(virBufferPtr buf,
                                   size_t ncells,
@@ -1276,6 +1316,24 @@ virCapabilitiesFormatGuestXML(virCapsGuestPtr *guests,
 }
 
 
+static void
+virCapabilitiesFormatStoragePoolXML(virCapsStoragePoolPtr *pools,
+                                    size_t npools,
+                                    virBufferPtr buf)
+{
+    size_t i;
+
+    for (i = 0; i < npools; i++) {
+        virBufferAddLit(buf, "<pool>\n");
+        virBufferAdjustIndent(buf, 2);
+        virBufferAsprintf(buf, "<type>%s</pool>\n",
+                          virStoragePoolTypeToString(pools[i]->type));
+        virBufferAdjustIndent(buf, -2);
+        virBufferAddLit(buf, "</pool>\n\n");
+    }
+}
+
+
 /**
  * virCapabilitiesFormatXML:
  * @caps: capabilities to format
@@ -1297,6 +1355,8 @@ virCapabilitiesFormatXML(virCapsPtr caps)
 
     virCapabilitiesFormatGuestXML(caps->guests, caps->nguests, &buf);
 
+    virCapabilitiesFormatStoragePoolXML(caps->pools, caps->npools, &buf);
+
     virBufferAdjustIndent(&buf, -2);
     virBufferAddLit(&buf, "</capabilities>\n");
 
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index 31c2a07a9b..cca1a20949 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -211,6 +211,13 @@ struct _virCapsHost {
     bool iommu;
 };
 
+typedef struct _virCapsStoragePool virCapsStoragePool;
+typedef virCapsStoragePool *virCapsStoragePoolPtr;
+struct _virCapsStoragePool {
+    int type;
+};
+
+
 typedef int (*virDomainDefNamespaceParse)(xmlDocPtr, xmlNodePtr,
                                           xmlXPathContextPtr, void **);
 typedef void (*virDomainDefNamespaceFree)(void *);
@@ -235,6 +242,10 @@ struct _virCaps {
     size_t nguests;
     size_t nguests_max;
     virCapsGuestPtr *guests;
+
+    size_t npools;
+    size_t npools_max;
+    virCapsStoragePoolPtr *pools;
 };
 
 typedef struct _virCapsDomainData virCapsDomainData;
@@ -318,6 +329,10 @@ virCapabilitiesAddGuestFeature(virCapsGuestPtr guest,
                                bool defaultOn,
                                bool toggle);
 
+int
+virCapabilitiesAddStoragePool(virCapsPtr caps,
+                              int poolType);
+
 int
 virCapabilitiesHostSecModelAddBaseLabel(virCapsHostSecModelPtr secmodel,
                                         const char *type,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index c3d6306809..9aaa8830e4 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -49,6 +49,7 @@ virCapabilitiesAddGuestFeature;
 virCapabilitiesAddHostFeature;
 virCapabilitiesAddHostMigrateTransport;
 virCapabilitiesAddHostNUMACell;
+virCapabilitiesAddStoragePool;
 virCapabilitiesAllocMachines;
 virCapabilitiesClearHostNUMACellCPUTopology;
 virCapabilitiesDomainDataLookup;
-- 
2.20.1

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

  Powered by Linux