mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-08 22:15:21 +00:00
vz: add validation callbacks
This patch fixes a bug which occurs when we check a bus and unit number for a new attached disk. We should do this check in ValidadionCallback, not in PostParse callback. Because in PostParse we have not initialized disk->info.addr.drive struct yet. Move part of code from domainPostParseCallback to domainValidateCallback and part from devicesPostParseCallback to deviceValidateCallback. PostParse callbacks are for modification data. ValidateCallbacks are only for checks.
This commit is contained in:
parent
b880ff42dd
commit
72abe56448
@ -232,6 +232,7 @@ vzConnectGetCapabilities(virConnectPtr conn)
|
||||
xml = virCapabilitiesFormatXML(privconn->driver->caps);
|
||||
return xml;
|
||||
}
|
||||
|
||||
static int
|
||||
vzDomainDefAddDefaultInputDevices(virDomainDefPtr def)
|
||||
{
|
||||
@ -258,11 +259,19 @@ static int
|
||||
vzDomainDefPostParse(virDomainDefPtr def,
|
||||
virCapsPtr caps ATTRIBUTE_UNUSED,
|
||||
unsigned int parseFlags ATTRIBUTE_UNUSED,
|
||||
void *opaque)
|
||||
void *opaque ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (vzDomainDefAddDefaultInputDevices(def) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
vzDomainDefValidate(const virDomainDef *def,
|
||||
virCapsPtr caps ATTRIBUTE_UNUSED,
|
||||
void *opaque)
|
||||
{
|
||||
if (vzCheckUnsupportedControllers(def, opaque) < 0)
|
||||
return -1;
|
||||
|
||||
@ -284,6 +293,14 @@ vzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
||||
VIR_STRDUP(dev->data.net->model, "e1000") < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
vzDomainDeviceDefValidate(const virDomainDeviceDef *dev,
|
||||
const virDomainDef *def,
|
||||
void *opaque ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (dev->type == VIR_DOMAIN_DEVICE_DISK)
|
||||
return vzCheckUnsupportedDisk(def, dev->data.disk, opaque);
|
||||
else if (dev->type == VIR_DOMAIN_DEVICE_GRAPHICS)
|
||||
@ -299,8 +316,10 @@ static virDomainXMLPrivateDataCallbacks vzDomainXMLPrivateDataCallbacksPtr = {
|
||||
|
||||
static virDomainDefParserConfig vzDomainDefParserConfig = {
|
||||
.macPrefix = {0x42, 0x1C, 0x00},
|
||||
.devicesPostParseCallback = vzDomainDeviceDefPostParse,
|
||||
.domainPostParseCallback = vzDomainDefPostParse,
|
||||
.devicesPostParseCallback = vzDomainDeviceDefPostParse,
|
||||
.domainValidateCallback = vzDomainDefValidate,
|
||||
.deviceValidateCallback = vzDomainDeviceDefValidate,
|
||||
};
|
||||
|
||||
static vzDriverPtr
|
||||
|
@ -463,7 +463,7 @@ vzCheckUnsupportedDisk(const virDomainDef *def,
|
||||
}
|
||||
|
||||
int
|
||||
vzCheckUnsupportedControllers(virDomainDefPtr def, vzCapabilitiesPtr vzCaps)
|
||||
vzCheckUnsupportedControllers(const virDomainDef *def, vzCapabilitiesPtr vzCaps)
|
||||
{
|
||||
size_t i, j;
|
||||
virDomainControllerDefPtr controller;
|
||||
|
@ -137,7 +137,7 @@ vzCheckUnsupportedDisk(const virDomainDef *def,
|
||||
virDomainDiskDefPtr disk,
|
||||
vzCapabilitiesPtr vzCaps);
|
||||
int
|
||||
vzCheckUnsupportedControllers(virDomainDefPtr def,
|
||||
vzCheckUnsupportedControllers(const virDomainDef *def,
|
||||
vzCapabilitiesPtr vzCaps);
|
||||
int
|
||||
vzGetDefaultSCSIModel(vzDriverPtr driver,
|
||||
|
Loading…
Reference in New Issue
Block a user