To avoid having to forbid new features added to domain XML in post parse
callbacks for individual hypervisor drivers the feature flag mechanism
will allow to add a central check that will be disabled for the drivers
that will add support.
As a first example flag, the 'hasWideSCSIBus' is converted to the new
bitmap.
---
src/conf/domain_conf.c | 13 ++++++++-----
src/conf/domain_conf.h | 7 ++++++-
src/vmx/vmx.c | 2 +-
3 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5bb0616..705a796 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4040,18 +4040,21 @@ virDomainHostdevAssignAddress(virDomainXMLOptionPtr xmlopt,
{
int next_unit = 0;
unsigned controller = 0;
+ unsigned int max_unit;
size_t i;
int ret;
+ if (xmlopt->config.features & VIR_DOMAIN_DEF_FEATURE_WIDE_SCSI)
+ max_unit = SCSI_WIDE_BUS_MAX_CONT_UNIT;
+ else
+ max_unit = SCSI_NARROW_BUS_MAX_CONT_UNIT;
+
for (i = 0; i < def->ncontrollers; i++) {
if (def->controllers[i]->type != VIR_DOMAIN_CONTROLLER_TYPE_SCSI)
continue;
controller++;
- ret = virDomainControllerSCSINextUnit(def,
- xmlopt->config.hasWideSCSIBus ?
- SCSI_WIDE_BUS_MAX_CONT_UNIT :
- SCSI_NARROW_BUS_MAX_CONT_UNIT,
+ ret = virDomainControllerSCSINextUnit(def, max_unit,
def->controllers[i]->idx);
if (ret >= 0) {
next_unit = ret;
@@ -5863,7 +5866,7 @@ virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt,
def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE;
- if (xmlopt->config.hasWideSCSIBus) {
+ if (xmlopt->config.features & VIR_DOMAIN_DEF_FEATURE_WIDE_SCSI) {
/* For a wide SCSI bus we define the default mapping to be
* 16 units per bus, 1 bus per controller, many controllers.
* Unit 7 is the SCSI controller itself. Therefore unit 7
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index c1e63e4..223ce2d 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2403,6 +2403,11 @@ typedef bool (*virDomainObjListACLFilter)(virConnectPtr conn,
virDomainDefPtr def);
+typedef enum {
+ VIR_DOMAIN_DEF_FEATURE_WIDE_SCSI = (1 << 0),
+} virDomainDefFeatures;
+
+
/* This structure holds various callbacks and data needed
* while parsing and creating domain XMLs */
typedef struct _virDomainXMLOption virDomainXMLOption;
@@ -2434,7 +2439,7 @@ struct _virDomainDefParserConfig {
virFreeCallback privFree;
/* data */
- bool hasWideSCSIBus;
+ unsigned int features; /* virDomainDefFeatures */
unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
};
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 4fd0a1d..cbd6633 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -548,10 +548,10 @@ virVMXDomainDevicesDefPostParse(virDomainDeviceDefPtr dev
ATTRIBUTE_UNUSED,
}
static virDomainDefParserConfig virVMXDomainDefParserConfig = {
- .hasWideSCSIBus = true,
.macPrefix = {0x00, 0x0c, 0x29},
.devicesPostParseCallback = virVMXDomainDevicesDefPostParse,
.domainPostParseCallback = virVMXDomainDefPostParse,
+ .features = VIR_DOMAIN_DEF_FEATURE_WIDE_SCSI,
};
static void
--
2.6.2