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

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