Blame SOURCES/libvirt-virDomainDiskTranslateSourcePool-Fix-check-of-startupPolicy-definition.patch

49d448
From 2ea89fb18aa9d2dac1e651869736fede7a2ec434 Mon Sep 17 00:00:00 2001
49d448
Message-Id: <2ea89fb18aa9d2dac1e651869736fede7a2ec434@dist-git>
49d448
From: Peter Krempa <pkrempa@redhat.com>
49d448
Date: Tue, 14 Jun 2022 14:21:33 +0200
49d448
Subject: [PATCH] virDomainDiskTranslateSourcePool: Fix check of
49d448
 'startupPolicy' definition
49d448
MIME-Version: 1.0
49d448
Content-Type: text/plain; charset=UTF-8
49d448
Content-Transfer-Encoding: 8bit
49d448
49d448
The check was historically done only for _TYPE_VOLUME disks, but
49d448
refactors to allow _TYPE_VOLUME disks in the backing chain caused a
49d448
regression where we'd reject startupPolicy also for _TYPE_BLOCK disks
49d448
which historically worked well.
49d448
49d448
Fix it by using the 'virDomainDiskDefValidateStartupPolicy' helper and
49d448
use it only when the top level image is a _TYPE_VOLUME as in other cases
49d448
it was already validated. This also allows _TYPE_BLOCK volumes to use
49d448
startup policy.
49d448
49d448
Fixes: 37f01262eed9f37dd5eb7de8b83edd2fea741054
49d448
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2095758
49d448
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
49d448
Reviewed-by: Ján Tomko <jtomko@redhat.com>
49d448
(cherry picked from commit ed8984306e1cd44c424fda3ed412a4177dd7b84d)
49d448
---
49d448
 src/conf/domain_conf.c | 12 ++++++------
49d448
 1 file changed, 6 insertions(+), 6 deletions(-)
49d448
49d448
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
49d448
index 805a15848e..92510973e6 100644
49d448
--- a/src/conf/domain_conf.c
49d448
+++ b/src/conf/domain_conf.c
49d448
@@ -31311,13 +31311,13 @@ virDomainDiskTranslateSourcePool(virDomainDiskDef *def)
49d448
 
49d448
         if (virDomainStorageSourceTranslateSourcePool(n, conn) < 0)
49d448
             return -1;
49d448
-    }
49d448
 
49d448
-    if (def->startupPolicy != 0 &&
49d448
-        virStorageSourceGetActualType(def->src) != VIR_STORAGE_TYPE_FILE) {
49d448
-        virReportError(VIR_ERR_XML_ERROR, "%s",
49d448
-                       _("'startupPolicy' is only valid for 'file' type volume"));
49d448
-        return -1;
49d448
+        /* The validity of 'startupPolicy' setting is checked only for the top
49d448
+         * level image. For any other subsequent images we honour it only if
49d448
+         * possible */
49d448
+        if (n == def->src &&
49d448
+            virDomainDiskDefValidateStartupPolicy(def) < 0)
49d448
+            return -1;
49d448
     }
49d448
 
49d448
     return 0;
49d448
-- 
49d448
2.35.1
49d448