render / rpms / libvirt

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