mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 13:05:27 +00:00
domain_validate: Split out validation of disk startup policy
Move the code into 'virDomainDiskDefValidateStartupPolicy' which will be later reused in the qemu driver. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
9a480737c8
commit
3603a18bce
@ -632,6 +632,32 @@ virDomainDiskDefSourceLUNValidate(const virStorageSource *src)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
virDomainDiskDefValidateStartupPolicy(const virDomainDiskDef *disk)
|
||||||
|
{
|
||||||
|
if (disk->startupPolicy == VIR_DOMAIN_STARTUP_POLICY_DEFAULT)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (disk->src->type == VIR_STORAGE_TYPE_NETWORK) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
|
_("disk startupPolicy '%s' is not allowed for disk of '%s' type"),
|
||||||
|
virDomainStartupPolicyTypeToString(disk->startupPolicy),
|
||||||
|
virStorageTypeToString(disk->src->type));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (disk->device != VIR_DOMAIN_DISK_DEVICE_CDROM &&
|
||||||
|
disk->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
|
||||||
|
disk->startupPolicy == VIR_DOMAIN_STARTUP_POLICY_REQUISITE) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
|
_("disk startupPolicy 'requisite' is allowed only for cdrom or floppy"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virDomainDiskDefValidate(const virDomainDef *def,
|
virDomainDiskDefValidate(const virDomainDef *def,
|
||||||
const virDomainDiskDef *disk)
|
const virDomainDiskDef *disk)
|
||||||
@ -852,23 +878,8 @@ virDomainDiskDefValidate(const virDomainDef *def,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (disk->startupPolicy != VIR_DOMAIN_STARTUP_POLICY_DEFAULT) {
|
if (virDomainDiskDefValidateStartupPolicy(disk) < 0)
|
||||||
if (disk->src->type == VIR_STORAGE_TYPE_NETWORK) {
|
return -1;
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("disk startupPolicy '%s' is not allowed for disk of '%s' type"),
|
|
||||||
virDomainStartupPolicyTypeToString(disk->startupPolicy),
|
|
||||||
virStorageTypeToString(disk->src->type));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (disk->device != VIR_DOMAIN_DISK_DEVICE_CDROM &&
|
|
||||||
disk->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
|
|
||||||
disk->startupPolicy == VIR_DOMAIN_STARTUP_POLICY_REQUISITE) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
||||||
_("disk startupPolicy 'requisite' is allowed only for cdrom or floppy"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (disk->wwn && !virValidateWWN(disk->wwn))
|
if (disk->wwn && !virValidateWWN(disk->wwn))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -41,4 +41,6 @@ int virDomainDeviceDefValidate(const virDomainDeviceDef *dev,
|
|||||||
|
|
||||||
int virDomainDiskDefValidateSource(const virStorageSource *src);
|
int virDomainDiskDefValidateSource(const virStorageSource *src);
|
||||||
|
|
||||||
|
int virDomainDiskDefValidateStartupPolicy(const virDomainDiskDef *disk);
|
||||||
|
|
||||||
int virDomainDiskDefSourceLUNValidate(const virStorageSource *src);
|
int virDomainDiskDefSourceLUNValidate(const virStorageSource *src);
|
||||||
|
@ -779,6 +779,7 @@ virDomainActualNetDefValidate;
|
|||||||
virDomainDefValidate;
|
virDomainDefValidate;
|
||||||
virDomainDeviceValidateAliasForHotplug;
|
virDomainDeviceValidateAliasForHotplug;
|
||||||
virDomainDiskDefSourceLUNValidate;
|
virDomainDiskDefSourceLUNValidate;
|
||||||
|
virDomainDiskDefValidateStartupPolicy;
|
||||||
|
|
||||||
|
|
||||||
# conf/interface_conf.h
|
# conf/interface_conf.h
|
||||||
|
Loading…
x
Reference in New Issue
Block a user