提交 05fe0350 编写于 作者: J John Ferlan

conf: Introduce storage pool functions into capabilities

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: NJohn Ferlan <jferlan@redhat.com>
ACKed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 05fade52
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "cpu_conf.h" #include "cpu_conf.h"
#include "domain_conf.h" #include "domain_conf.h"
#include "physmem.h" #include "physmem.h"
#include "storage_conf.h"
#include "viralloc.h" #include "viralloc.h"
#include "virarch.h" #include "virarch.h"
#include "virbuffer.h" #include "virbuffer.h"
...@@ -181,6 +182,17 @@ virCapabilitiesFreeGuest(virCapsGuestPtr guest) ...@@ -181,6 +182,17 @@ virCapabilitiesFreeGuest(virCapsGuestPtr guest)
VIR_FREE(guest); VIR_FREE(guest);
} }
static void
virCapabilitiesFreeStoragePool(virCapsStoragePoolPtr pool)
{
if (!pool)
return;
VIR_FREE(pool);
}
void void
virCapabilitiesFreeNUMAInfo(virCapsPtr caps) virCapabilitiesFreeNUMAInfo(virCapsPtr caps)
{ {
...@@ -222,6 +234,10 @@ virCapsDispose(void *object) ...@@ -222,6 +234,10 @@ virCapsDispose(void *object)
virCapsPtr caps = object; virCapsPtr caps = object;
size_t i; 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++) for (i = 0; i < caps->nguests; i++)
virCapabilitiesFreeGuest(caps->guests[i]); virCapabilitiesFreeGuest(caps->guests[i]);
VIR_FREE(caps->guests); VIR_FREE(caps->guests);
...@@ -793,6 +809,30 @@ virCapabilitiesDomainDataLookup(virCapsPtr caps, ...@@ -793,6 +809,30 @@ virCapabilitiesDomainDataLookup(virCapsPtr caps,
emulator, machinetype); 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 static int
virCapabilitiesFormatNUMATopology(virBufferPtr buf, virCapabilitiesFormatNUMATopology(virBufferPtr buf,
size_t ncells, size_t ncells,
...@@ -1065,6 +1105,12 @@ virCapabilitiesFormatHostXML(virCapsHostPtr host, ...@@ -1065,6 +1105,12 @@ virCapabilitiesFormatHostXML(virCapsHostPtr host,
size_t i, j; size_t i, j;
char host_uuid[VIR_UUID_STRING_BUFLEN]; 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"); virBufferAddLit(buf, "<host>\n");
virBufferAdjustIndent(buf, 2); virBufferAdjustIndent(buf, 2);
if (virUUIDIsValid(host->host_uuid)) { if (virUUIDIsValid(host->host_uuid)) {
...@@ -1277,6 +1323,32 @@ virCapabilitiesFormatGuestXML(virCapsGuestPtr *guests, ...@@ -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: * virCapabilitiesFormatXML:
* @caps: capabilities to format * @caps: capabilities to format
...@@ -1298,6 +1370,8 @@ virCapabilitiesFormatXML(virCapsPtr caps) ...@@ -1298,6 +1370,8 @@ virCapabilitiesFormatXML(virCapsPtr caps)
virCapabilitiesFormatGuestXML(caps->guests, caps->nguests, &buf); virCapabilitiesFormatGuestXML(caps->guests, caps->nguests, &buf);
virCapabilitiesFormatStoragePoolXML(caps->pools, caps->npools, &buf);
virBufferAdjustIndent(&buf, -2); virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</capabilities>\n"); virBufferAddLit(&buf, "</capabilities>\n");
......
...@@ -211,6 +211,13 @@ struct _virCapsHost { ...@@ -211,6 +211,13 @@ struct _virCapsHost {
bool iommu; bool iommu;
}; };
typedef struct _virCapsStoragePool virCapsStoragePool;
typedef virCapsStoragePool *virCapsStoragePoolPtr;
struct _virCapsStoragePool {
int type;
};
typedef int (*virDomainDefNamespaceParse)(xmlDocPtr, xmlNodePtr, typedef int (*virDomainDefNamespaceParse)(xmlDocPtr, xmlNodePtr,
xmlXPathContextPtr, void **); xmlXPathContextPtr, void **);
typedef void (*virDomainDefNamespaceFree)(void *); typedef void (*virDomainDefNamespaceFree)(void *);
...@@ -235,6 +242,10 @@ struct _virCaps { ...@@ -235,6 +242,10 @@ struct _virCaps {
size_t nguests; size_t nguests;
size_t nguests_max; size_t nguests_max;
virCapsGuestPtr *guests; virCapsGuestPtr *guests;
size_t npools;
size_t npools_max;
virCapsStoragePoolPtr *pools;
}; };
typedef struct _virCapsDomainData virCapsDomainData; typedef struct _virCapsDomainData virCapsDomainData;
...@@ -318,6 +329,10 @@ virCapabilitiesAddGuestFeature(virCapsGuestPtr guest, ...@@ -318,6 +329,10 @@ virCapabilitiesAddGuestFeature(virCapsGuestPtr guest,
bool defaultOn, bool defaultOn,
bool toggle); bool toggle);
int
virCapabilitiesAddStoragePool(virCapsPtr caps,
int poolType);
int int
virCapabilitiesHostSecModelAddBaseLabel(virCapsHostSecModelPtr secmodel, virCapabilitiesHostSecModelAddBaseLabel(virCapsHostSecModelPtr secmodel,
const char *type, const char *type,
......
...@@ -49,6 +49,7 @@ virCapabilitiesAddGuestFeature; ...@@ -49,6 +49,7 @@ virCapabilitiesAddGuestFeature;
virCapabilitiesAddHostFeature; virCapabilitiesAddHostFeature;
virCapabilitiesAddHostMigrateTransport; virCapabilitiesAddHostMigrateTransport;
virCapabilitiesAddHostNUMACell; virCapabilitiesAddHostNUMACell;
virCapabilitiesAddStoragePool;
virCapabilitiesAllocMachines; virCapabilitiesAllocMachines;
virCapabilitiesClearHostNUMACellCPUTopology; virCapabilitiesClearHostNUMACellCPUTopology;
virCapabilitiesDomainDataLookup; virCapabilitiesDomainDataLookup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册