]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: introduce parser feature flags
authorPeter Krempa <pkrempa@redhat.com>
Tue, 23 Feb 2016 09:32:19 +0000 (10:32 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 9 Mar 2016 09:09:16 +0000 (10:09 +0100)
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
src/conf/domain_conf.h
src/vmx/vmx.c

index fc6758c227a57107d6791bad84619ffe441bd9fd..0a6e3e16962ae170f4ec52df9cfde48ca2cd622f 100644 (file)
@@ -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
index 146d90663c4600a367ab9902e0c31b2ac7418c41..9e953a0390ffcc782f3b3c4646dbe10af6aa5911 100644 (file)
@@ -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];
 };
 
index 7ed73a51f541d02647f7112cac514045778e2f21..7263ee57e1560ad83fb6cae589ee5532d0592eb1 100644 (file)
@@ -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