mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-08 16:54:49 +00:00
vz: leverage disks parameters check on disks updates too
This is as easy as moving disks checks from domain post parse callback to device post parse callback. Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
This commit is contained in:
parent
307eb644ed
commit
511f6ab5ba
@ -263,9 +263,6 @@ vzDomainDefPostParse(virDomainDefPtr def,
|
||||
if (vzDomainDefAddDefaultInputDevices(def) < 0)
|
||||
return -1;
|
||||
|
||||
if (vzCheckUnsupportedDisks(def, opaque) < 0)
|
||||
return -1;
|
||||
|
||||
if (vzCheckUnsupportedControllers(def, opaque) < 0)
|
||||
return -1;
|
||||
|
||||
@ -279,19 +276,18 @@ vzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
||||
unsigned int parseFlags ATTRIBUTE_UNUSED,
|
||||
void *opaque ATTRIBUTE_UNUSED)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (dev->type == VIR_DOMAIN_DEVICE_NET &&
|
||||
(dev->data.net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
|
||||
dev->data.net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) &&
|
||||
!dev->data.net->model &&
|
||||
def->os.type == VIR_DOMAIN_OSTYPE_HVM &&
|
||||
VIR_STRDUP(dev->data.net->model, "e1000") < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
if (dev->type == VIR_DOMAIN_DEVICE_DISK)
|
||||
return vzCheckUnsupportedDisk(def, dev->data.disk, opaque);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -379,51 +379,49 @@ vzCheckDiskUnsupportedParams(virDomainDiskDefPtr disk)
|
||||
}
|
||||
|
||||
int
|
||||
vzCheckUnsupportedDisks(virDomainDefPtr def, vzCapabilitiesPtr vzCaps)
|
||||
vzCheckUnsupportedDisk(const virDomainDef *def,
|
||||
virDomainDiskDefPtr disk,
|
||||
vzCapabilitiesPtr vzCaps)
|
||||
{
|
||||
size_t i, j;
|
||||
virDomainDiskDefPtr disk;
|
||||
size_t i;
|
||||
virStorageFileFormat diskFormat;
|
||||
|
||||
for (i = 0; i < def->ndisks; i++) {
|
||||
disk = def->disks[i];
|
||||
if (vzCheckDiskUnsupportedParams(disk) < 0)
|
||||
return -1;
|
||||
|
||||
if (vzCheckDiskUnsupportedParams(disk) < 0)
|
||||
return -1;
|
||||
|
||||
if (disk->src->type == VIR_STORAGE_TYPE_FILE) {
|
||||
if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
|
||||
if (IS_CT(def))
|
||||
diskFormat = vzCaps->ctDiskFormat;
|
||||
else
|
||||
diskFormat = vzCaps->vmDiskFormat;
|
||||
} else {
|
||||
diskFormat = VIR_STORAGE_FILE_RAW;
|
||||
}
|
||||
if (disk->src->type == VIR_STORAGE_TYPE_FILE) {
|
||||
if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
|
||||
if (IS_CT(def))
|
||||
diskFormat = vzCaps->ctDiskFormat;
|
||||
else
|
||||
diskFormat = vzCaps->vmDiskFormat;
|
||||
} else {
|
||||
diskFormat = VIR_STORAGE_FILE_RAW;
|
||||
}
|
||||
|
||||
if (virDomainDiskGetFormat(disk) != VIR_STORAGE_FILE_NONE &&
|
||||
virDomainDiskGetFormat(disk) != diskFormat) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Unsupported format of disk %s"),
|
||||
disk->src->path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (j = 0; vzCaps->diskBuses[j] != VIR_DOMAIN_DISK_BUS_LAST; j++) {
|
||||
if (disk->bus == vzCaps->diskBuses[j])
|
||||
break;
|
||||
}
|
||||
|
||||
if (vzCaps->diskBuses[j] == VIR_DOMAIN_DISK_BUS_LAST) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Unsupported disk bus type %s"),
|
||||
virDomainDiskBusTypeToString(disk->bus));
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
diskFormat = VIR_STORAGE_FILE_RAW;
|
||||
}
|
||||
|
||||
if (virDomainDiskGetFormat(disk) != VIR_STORAGE_FILE_NONE &&
|
||||
virDomainDiskGetFormat(disk) != diskFormat) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Unsupported format of disk %s"),
|
||||
disk->src->path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; vzCaps->diskBuses[i] != VIR_DOMAIN_DISK_BUS_LAST; i++) {
|
||||
if (disk->bus == vzCaps->diskBuses[i])
|
||||
break;
|
||||
}
|
||||
|
||||
if (vzCaps->diskBuses[i] == VIR_DOMAIN_DISK_BUS_LAST) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Unsupported disk bus type %s"),
|
||||
virDomainDiskBusTypeToString(disk->bus));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -121,8 +121,9 @@ vzNewDomain(vzDriverPtr driver,
|
||||
int
|
||||
vzInitVersion(vzDriverPtr driver);
|
||||
int
|
||||
vzCheckUnsupportedDisks(virDomainDefPtr def,
|
||||
vzCapabilitiesPtr vzCaps);
|
||||
vzCheckUnsupportedDisk(const virDomainDef *def,
|
||||
virDomainDiskDefPtr disk,
|
||||
vzCapabilitiesPtr vzCaps);
|
||||
int
|
||||
vzCheckUnsupportedControllers(virDomainDefPtr def,
|
||||
vzCapabilitiesPtr vzCaps);
|
||||
|
Loading…
Reference in New Issue
Block a user