add some definitions for pci-bridge device, and
parse elements for pci-bridge, here we bear in
mind that pci-bridge is pci bus, so mostly
we treat ADDRESS_TYPE_PCIBRIDGE as ADDRESS_TYPE_PCI
Signed-off-by: liguang <lig.fnst(a)cn.fujitsu.com>
---
src/conf/domain_conf.c | 88 +++++++++++++++++++++++++++++++++++++++++++++---
src/conf/domain_conf.h | 22 ++++++++++++
2 files changed, 105 insertions(+), 5 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6a7646e..4e7fcca 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -167,11 +167,13 @@ VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST,
"redirdev",
"smartcard",
"chr",
- "memballoon")
+ "memballoon",
+ "pci-bridge")
VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST,
"none",
"pci",
+ "pci-bridge",
"drive",
"virtio-serial",
"ccid",
@@ -680,6 +682,13 @@ VIR_ENUM_IMPL(virDomainNumatuneMemPlacementMode,
"static",
"auto");
+VIR_ENUM_IMPL(virDomainPCIbridge,
+ VIR_DOMAIN_PCIBRIDGE_TYPE_LAST,
+ "root",
+ "subordinate",
+ "secondary");
+
+
#define VIR_DOMAIN_XML_WRITE_FLAGS VIR_DOMAIN_XML_SECURE
#define VIR_DOMAIN_XML_READ_FLAGS VIR_DOMAIN_XML_INACTIVE
@@ -1029,6 +1038,16 @@ void virDomainControllerDefFree(virDomainControllerDefPtr def)
VIR_FREE(def);
}
+void virDomainPCIbridgeDefFree(virDomainPCIbridgeDefPtr def)
+{
+ if (!def)
+ return;
+
+ virDomainDeviceInfoClear(&def->info);
+
+ VIR_FREE(def);
+}
+
void virDomainFSDefFree(virDomainFSDefPtr def)
{
if (!def)
@@ -2256,6 +2275,7 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
virDomainDeviceAddressTypeToString(info->type));
switch (info->type) {
+ case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCIBRIDGE:
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI:
virBufferAsprintf(buf, " domain='0x%.4x' bus='0x%.2x'
slot='0x%.2x' function='0x%.1x'",
info->addr.pci.domain,
@@ -2671,6 +2691,7 @@ virDomainDeviceInfoParseXML(xmlNodePtr node,
}
switch (info->type) {
+ case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCIBRIDGE:
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI:
if (virDevicePCIAddressParseXML(address, &info->addr.pci) < 0)
goto cleanup;
@@ -4541,9 +4562,11 @@ virDomainControllerDefParseXML(xmlNodePtr node,
if (def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO &&
def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390 &&
- def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
+ def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
+ def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCIBRIDGE) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Controllers must use the 'pci' address
type"));
+ _("Controllers must use the"
+ "'pci or pci-bridge' address type"));
goto error;
}
@@ -5138,9 +5161,11 @@ virDomainNetDefParseXML(virCapsPtr caps,
if (def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO &&
def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390 &&
- def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
+ def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
+ def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCIBRIDGE) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Network interfaces must use 'pci' address
type"));
+ _("Network interfaces must use "
+ "'pci or pci-bridge' address type"));
goto error;
}
@@ -6176,6 +6201,42 @@ error:
goto cleanup;
}
+static virDomainPCIbridgeDefPtr
+virDomainPCIbridgeDefParseXML(const xmlNodePtr node,
+ unsigned int flags)
+{
+ char *type;
+ virDomainPCIbridgeDefPtr def;
+
+ if (VIR_ALLOC(def) < 0) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ type = virXMLPropString(node, "type");
+ if (type == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("strongly suggest to have a type for pci-bridge"));
+ goto error;
+ }
+ if ((def->type = virDomainPCIbridgeTypeFromString(type)) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unknown type for pci-bridge '%s'"), type);
+ goto error;
+ }
+
+ if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
+ goto error;
+
+out:
+ return def;
+
+error:
+ virDomainPCIbridgeDefFree(def);
+ def = NULL;
+ goto out;
+}
+
/* Parse the XML definition for a hub device */
static virDomainHubDefPtr
@@ -10197,6 +10258,23 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
}
VIR_FREE(nodes);
+ /* analysis of pci-bridge devices */
+ def->pcibridges = NULL;
+ if ((n = virXPathNodeSet("./devices/pci-bridge", ctxt, &nodes)) < 0)
{
+ goto error;
+ }
+ if (n && VIR_REALLOC_N(def->pcibridges, def->npcibridges) < 0)
+ goto no_memory;
+ for (i = 0 ; i < n ; i++) {
+ virDomainPCIbridgeDefPtr pbg;
+
+ pbg = virDomainPCIbridgeDefParseXML(nodes[i], flags);
+ if (!pbg)
+ goto error;
+ def->pcibridges[def->npcibridges++] = pbg;
+ }
+ VIR_FREE(nodes);
+
/* analysis of the watchdog devices */
def->watchdog = NULL;
if ((n = virXPathNodeSet("./devices/watchdog", ctxt, &nodes)) < 0)
{
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 5062e07..b3ff85b 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -109,6 +109,9 @@ typedef virDomainChrDef *virDomainChrDefPtr;
typedef struct _virDomainMemballoonDef virDomainMemballoonDef;
typedef virDomainMemballoonDef *virDomainMemballoonDefPtr;
+typedef struct _virDomainPCIbridgeDef virDomainPCIbridgeDef;
+typedef virDomainPCIbridgeDef *virDomainPCIbridgeDefPtr;
+
typedef struct _virDomainSnapshotObj virDomainSnapshotObj;
typedef virDomainSnapshotObj *virDomainSnapshotObjPtr;
@@ -134,6 +137,7 @@ typedef enum {
VIR_DOMAIN_DEVICE_SMARTCARD,
VIR_DOMAIN_DEVICE_CHR,
VIR_DOMAIN_DEVICE_MEMBALLOON,
+ VIR_DOMAIN_DEVICE_PCIBRIDGE,
VIR_DOMAIN_DEVICE_LAST
} virDomainDeviceType;
@@ -159,6 +163,7 @@ struct _virDomainDeviceDef {
virDomainSmartcardDefPtr smartcard;
virDomainChrDefPtr chr;
virDomainMemballoonDefPtr memballoon;
+ virDomainPCIbridgeDefPtr pcibridge;
} data;
};
@@ -185,6 +190,7 @@ enum virDomainVirtType {
enum virDomainDeviceAddressType {
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI,
+ VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCIBRIDGE,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID,
@@ -1034,6 +1040,19 @@ struct _virDomainSmartcardDef {
virDomainDeviceInfo info;
};
+enum {
+ VIR_DOMAIN_PCIBRIDGE_TYPE_ROOT,
+ VIR_DOMAIN_PCIBRIDGE_TYPE_SUBORDINATE,
+ VIR_DOMAIN_PCIBRIDGE_TYPE_SECONDARY,
+
+ VIR_DOMAIN_PCIBRIDGE_TYPE_LAST
+};
+
+struct _virDomainPCIbridgeDef {
+ int type;
+ virDomainDeviceInfo info;
+};
+
struct _virDomainHubDef {
int type;
virDomainDeviceInfo info;
@@ -1811,6 +1830,9 @@ struct _virDomainDef {
size_t nseclabels;
virSecurityLabelDefPtr *seclabels;
+ size_t npcibridges;
+ virDomainPCIbridgeDefPtr *pcibridges;
+
/* Only 1 */
virDomainWatchdogDefPtr watchdog;
virDomainMemballoonDefPtr memballoon;
--
1.7.2.5