From 23eb382128427cb32f844e131fa35db16106f2ce Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 23 Feb 2016 10:32:19 +0100 Subject: [PATCH] conf: introduce parser feature flags 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 fc6758c227..0a6e3e1696 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4038,18 +4038,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; @@ -5861,7 +5864,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 146d90663c..9e953a0390 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2407,6 +2407,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; @@ -2438,7 +2443,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 7ed73a51f5..7263ee57e1 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.47.2