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

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