Blame SOURCES/libvirt-virDomainDiskDefValidateStartupPolicy-Validate-disk-type-better.patch

459f93
From 26daf647925213a05509cc302d9151fe4525febb Mon Sep 17 00:00:00 2001
459f93
Message-Id: <26daf647925213a05509cc302d9151fe4525febb@dist-git>
459f93
From: Peter Krempa <pkrempa@redhat.com>
459f93
Date: Tue, 14 Jun 2022 14:07:47 +0200
459f93
Subject: [PATCH] virDomainDiskDefValidateStartupPolicy: Validate disk type
459f93
 better
459f93
MIME-Version: 1.0
459f93
Content-Type: text/plain; charset=UTF-8
459f93
Content-Transfer-Encoding: 8bit
459f93
459f93
Our startup policy checkers work only for local paths, so disk sources
459f93
such as NVMe, or vhost-user can't be used with startup policy.
459f93
459f93
Unfortunately the validation did not catch these cases. Fix it.
459f93
459f93
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
459f93
Reviewed-by: Ján Tomko <jtomko@redhat.com>
459f93
(cherry picked from commit b90d0f0a1e4ee52c828fb683c14c14e241e6fcbb)
459f93
https://bugzilla.redhat.com/show_bug.cgi?id=2095758
459f93
---
459f93
 src/conf/domain_validate.c | 5 ++++-
459f93
 1 file changed, 4 insertions(+), 1 deletion(-)
459f93
459f93
diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
459f93
index bfff7339ef..55759af9f8 100644
459f93
--- a/src/conf/domain_validate.c
459f93
+++ b/src/conf/domain_validate.c
459f93
@@ -604,7 +604,10 @@ virDomainDiskDefValidateStartupPolicy(const virDomainDiskDef *disk)
459f93
     if (disk->startupPolicy == VIR_DOMAIN_STARTUP_POLICY_DEFAULT)
459f93
         return 0;
459f93
 
459f93
-    if (disk->src->type == VIR_STORAGE_TYPE_NETWORK) {
459f93
+    /* We want to allow any startup policy for un-translated _TYPE_VOLUME disks.
459f93
+     * virStorageSourceGetActualType returns _TYPE_VOLUME in such case */
459f93
+    if (virStorageSourceGetActualType(disk->src) != VIR_STORAGE_TYPE_VOLUME &&
459f93
+        !virStorageSourceIsLocalStorage(disk->src)) {
459f93
         virReportError(VIR_ERR_XML_ERROR,
459f93
                        _("disk startupPolicy '%s' is not allowed for disk of '%s' type"),
459f93
                        virDomainStartupPolicyTypeToString(disk->startupPolicy),
459f93
-- 
459f93
2.35.1
459f93