]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Introduce storage pool functions into capabilities
authorJohn Ferlan <jferlan@redhat.com>
Thu, 10 Jan 2019 12:19:35 +0000 (07:19 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 6 Mar 2019 16:12:48 +0000 (11:12 -0500)
Introduce the bare bones functions to processing capability
data for the storage driver.

Since there will be no need for the <host> output, we need
to filter that data.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/capabilities.c
src/conf/capabilities.h
src/libvirt_private.syms

index 716ac6e2e7ecbdb62804a1b53725ccf3eb6782ba..47308700bb8604fad691b419a27ed7d53d7c8f2f 100644 (file)
@@ -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"
@@ -181,6 +182,17 @@ virCapabilitiesFreeGuest(virCapsGuestPtr guest)
     VIR_FREE(guest);
 }
 
+
+static void
+virCapabilitiesFreeStoragePool(virCapsStoragePoolPtr pool)
+{
+    if (!pool)
+        return;
+
+    VIR_FREE(pool);
+}
+
+
 void
 virCapabilitiesFreeNUMAInfo(virCapsPtr caps)
 {
@@ -222,6 +234,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);
@@ -793,6 +809,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,
@@ -1065,6 +1105,12 @@ virCapabilitiesFormatHostXML(virCapsHostPtr host,
     size_t i, j;
     char host_uuid[VIR_UUID_STRING_BUFLEN];
 
+    /* The lack of some data means we have nothing
+     * minimally to format, so just return. */
+    if (!virUUIDIsValid(host->host_uuid) &&
+        !host->arch && !host->powerMgmt && !host->iommu)
+        return 0;
+
     virBufferAddLit(buf, "<host>\n");
     virBufferAdjustIndent(buf, 2);
     if (virUUIDIsValid(host->host_uuid)) {
@@ -1277,6 +1323,32 @@ virCapabilitiesFormatGuestXML(virCapsGuestPtr *guests,
 }
 
 
+static void
+virCapabilitiesFormatStoragePoolXML(virCapsStoragePoolPtr *pools,
+                                    size_t npools,
+                                    virBufferPtr buf)
+{
+    size_t i;
+
+    if (npools == 0)
+        return;
+
+    virBufferAddLit(buf, "<pool>\n");
+    virBufferAdjustIndent(buf, 2);
+
+    virBufferAddLit(buf, "<enum name='type'>\n");
+    virBufferAdjustIndent(buf, 2);
+    for (i = 0; i < npools; i++)
+        virBufferAsprintf(buf, "<value>%s</value>\n",
+                          virStoragePoolTypeToString(pools[i]->type));
+    virBufferAdjustIndent(buf, -2);
+    virBufferAddLit(buf, "</enum>\n");
+
+    virBufferAdjustIndent(buf, -2);
+    virBufferAddLit(buf, "</pool>\n\n");
+}
+
+
 /**
  * virCapabilitiesFormatXML:
  * @caps: capabilities to format
@@ -1298,6 +1370,8 @@ virCapabilitiesFormatXML(virCapsPtr caps)
 
     virCapabilitiesFormatGuestXML(caps->guests, caps->nguests, &buf);
 
+    virCapabilitiesFormatStoragePoolXML(caps->pools, caps->npools, &buf);
+
     virBufferAdjustIndent(&buf, -2);
     virBufferAddLit(&buf, "</capabilities>\n");
 
index 31c2a07a9bdbabfe5a785e82697a999935185e50..cca1a2094949e0653a01580caa9e3df966e56bef 100644 (file)
@@ -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,
index 69643732e03e36950d361de8bf5db66cfe7d1bf1..6d78db2b942343d98e75146af06afdda122aeb42 100644 (file)
@@ -49,6 +49,7 @@ virCapabilitiesAddGuestFeature;
 virCapabilitiesAddHostFeature;
 virCapabilitiesAddHostMigrateTransport;
 virCapabilitiesAddHostNUMACell;
+virCapabilitiesAddStoragePool;
 virCapabilitiesAllocMachines;
 virCapabilitiesClearHostNUMACellCPUTopology;
 virCapabilitiesDomainDataLookup;