[PATCH v3 2/3] qemu: process: refactor deprecated features code

Collin Walling posted 3 patches 3 months, 2 weeks ago
There is a newer version of this series
[PATCH v3 2/3] qemu: process: refactor deprecated features code
Posted by Collin Walling 3 months, 2 weeks ago
Group up the deprecated features code into a single block to keep things
clean; only check if the deprecated_features attribute is present
once and then do relevent work.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
---
 src/qemu/qemu_process.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index e4f8cb8c01..b4989f7ab8 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -6588,19 +6588,18 @@ qemuProcessUpdateGuestCPU(virDomainDef *def,
                                 &def->os.arch) < 0)
         return -1;
 
-    if (def->cpu->deprecated_feats &&
-        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS)) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("toggling deprecated features for CPU model is unsupported"));
-        return -1;
-    }
-
     if (def->cpu->deprecated_feats) {
 
         virCPUFeaturePolicy policy = VIR_CPU_FEATURE_REQUIRE;
         if (def->cpu->deprecated_feats == VIR_TRISTATE_SWITCH_OFF)
             policy = VIR_CPU_FEATURE_DISABLE;
 
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("toggling deprecated features for CPU model is unsupported"));
+            return -1;
+        }
+
         virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, def->virtType,
                                                def->cpu, policy);
     }
-- 
2.47.1
Re: [PATCH v3 2/3] qemu: process: refactor deprecated features code
Posted by Boris Fiuczynski 3 months, 2 weeks ago
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>

On 5/22/25 08:03, Collin Walling wrote:
> Group up the deprecated features code into a single block to keep things
> clean; only check if the deprecated_features attribute is present
> once and then do relevent work.
> 
> Signed-off-by: Collin Walling <walling@linux.ibm.com>
> ---
>   src/qemu/qemu_process.c | 13 ++++++-------
>   1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
> index e4f8cb8c01..b4989f7ab8 100644
> --- a/src/qemu/qemu_process.c
> +++ b/src/qemu/qemu_process.c
> @@ -6588,19 +6588,18 @@ qemuProcessUpdateGuestCPU(virDomainDef *def,
>                                   &def->os.arch) < 0)
>           return -1;
>   
> -    if (def->cpu->deprecated_feats &&
> -        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS)) {
> -        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> -                       _("toggling deprecated features for CPU model is unsupported"));
> -        return -1;
> -    }
> -
>       if (def->cpu->deprecated_feats) {
>   
>           virCPUFeaturePolicy policy = VIR_CPU_FEATURE_REQUIRE;
>           if (def->cpu->deprecated_feats == VIR_TRISTATE_SWITCH_OFF)
>               policy = VIR_CPU_FEATURE_DISABLE;
>   
> +        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_DEPRECATED_PROPS)) {
> +            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                           _("toggling deprecated features for CPU model is unsupported"));
> +            return -1;
> +        }
> +
>           virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, def->virtType,
>                                                  def->cpu, policy);
>       }


-- 
Mit freundlichen Grüßen/Kind regards
    Boris Fiuczynski

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Wolfgang Wendt
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294