mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
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.
This commit is contained in:
parent
0fe41f1a8a
commit
23eb382128
@ -4038,18 +4038,21 @@ virDomainHostdevAssignAddress(virDomainXMLOptionPtr xmlopt,
|
|||||||
{
|
{
|
||||||
int next_unit = 0;
|
int next_unit = 0;
|
||||||
unsigned controller = 0;
|
unsigned controller = 0;
|
||||||
|
unsigned int max_unit;
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret;
|
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++) {
|
for (i = 0; i < def->ncontrollers; i++) {
|
||||||
if (def->controllers[i]->type != VIR_DOMAIN_CONTROLLER_TYPE_SCSI)
|
if (def->controllers[i]->type != VIR_DOMAIN_CONTROLLER_TYPE_SCSI)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
controller++;
|
controller++;
|
||||||
ret = virDomainControllerSCSINextUnit(def,
|
ret = virDomainControllerSCSINextUnit(def, max_unit,
|
||||||
xmlopt->config.hasWideSCSIBus ?
|
|
||||||
SCSI_WIDE_BUS_MAX_CONT_UNIT :
|
|
||||||
SCSI_NARROW_BUS_MAX_CONT_UNIT,
|
|
||||||
def->controllers[i]->idx);
|
def->controllers[i]->idx);
|
||||||
if (ret >= 0) {
|
if (ret >= 0) {
|
||||||
next_unit = ret;
|
next_unit = ret;
|
||||||
@ -5861,7 +5864,7 @@ virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt,
|
|||||||
|
|
||||||
def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE;
|
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
|
/* For a wide SCSI bus we define the default mapping to be
|
||||||
* 16 units per bus, 1 bus per controller, many controllers.
|
* 16 units per bus, 1 bus per controller, many controllers.
|
||||||
* Unit 7 is the SCSI controller itself. Therefore unit 7
|
* Unit 7 is the SCSI controller itself. Therefore unit 7
|
||||||
|
@ -2407,6 +2407,11 @@ typedef bool (*virDomainObjListACLFilter)(virConnectPtr conn,
|
|||||||
virDomainDefPtr def);
|
virDomainDefPtr def);
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
VIR_DOMAIN_DEF_FEATURE_WIDE_SCSI = (1 << 0),
|
||||||
|
} virDomainDefFeatures;
|
||||||
|
|
||||||
|
|
||||||
/* This structure holds various callbacks and data needed
|
/* This structure holds various callbacks and data needed
|
||||||
* while parsing and creating domain XMLs */
|
* while parsing and creating domain XMLs */
|
||||||
typedef struct _virDomainXMLOption virDomainXMLOption;
|
typedef struct _virDomainXMLOption virDomainXMLOption;
|
||||||
@ -2438,7 +2443,7 @@ struct _virDomainDefParserConfig {
|
|||||||
virFreeCallback privFree;
|
virFreeCallback privFree;
|
||||||
|
|
||||||
/* data */
|
/* data */
|
||||||
bool hasWideSCSIBus;
|
unsigned int features; /* virDomainDefFeatures */
|
||||||
unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
|
unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -548,10 +548,10 @@ virVMXDomainDevicesDefPostParse(virDomainDeviceDefPtr dev ATTRIBUTE_UNUSED,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static virDomainDefParserConfig virVMXDomainDefParserConfig = {
|
static virDomainDefParserConfig virVMXDomainDefParserConfig = {
|
||||||
.hasWideSCSIBus = true,
|
|
||||||
.macPrefix = {0x00, 0x0c, 0x29},
|
.macPrefix = {0x00, 0x0c, 0x29},
|
||||||
.devicesPostParseCallback = virVMXDomainDevicesDefPostParse,
|
.devicesPostParseCallback = virVMXDomainDevicesDefPostParse,
|
||||||
.domainPostParseCallback = virVMXDomainDefPostParse,
|
.domainPostParseCallback = virVMXDomainDefPostParse,
|
||||||
|
.features = VIR_DOMAIN_DEF_FEATURE_WIDE_SCSI,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user