virDomainDiskDefValidateStartupPolicy: Validate disk type better

Our startup policy checkers work only for local paths, so disk sources
such as NVMe, or vhost-user can't be used with startup policy.

Unfortunately the validation did not catch these cases. Fix it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-06-14 14:07:47 +02:00
parent 3603a18bce
commit b90d0f0a1e

View File

@ -638,7 +638,10 @@ virDomainDiskDefValidateStartupPolicy(const virDomainDiskDef *disk)
if (disk->startupPolicy == VIR_DOMAIN_STARTUP_POLICY_DEFAULT)
return 0;
if (disk->src->type == VIR_STORAGE_TYPE_NETWORK) {
/* We want to allow any startup policy for un-translated _TYPE_VOLUME disks.
* virStorageSourceGetActualType returns _TYPE_VOLUME in such case */
if (virStorageSourceGetActualType(disk->src) != VIR_STORAGE_TYPE_VOLUME &&
!virStorageSourceIsLocalStorage(disk->src)) {
virReportError(VIR_ERR_XML_ERROR,
_("disk startupPolicy '%s' is not allowed for disk of '%s' type"),
virDomainStartupPolicyTypeToString(disk->startupPolicy),