]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
libxl: capsInitCPU: fail if we can't initialize host features
authorJán Tomko <jtomko@redhat.com>
Sun, 5 Sep 2021 18:59:27 +0000 (20:59 +0200)
committerJán Tomko <jtomko@redhat.com>
Wed, 8 Sep 2021 14:19:55 +0000 (16:19 +0200)
Introduced by:
  commit 17322e551861a5bc4dd464a7c5399204dc8c7caa
      libxl: describe host cpu features based on hwcaps
with the justification that libxl_hwcaps does not have a stable
format across all version.

Even though the code would return '0' in the case of such failure,
it frees the 'cpu' pointer, while keeping it in caps->host.
Based on that, assume it does not happen in current usage.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
src/libxl/libxl_capabilities.c

index d98109ea86d99bf2d87e694c9597549e2c0f3cf7..9d0ed921bd62ec47404422ba3db9a0b1a1170b92 100644 (file)
@@ -166,16 +166,17 @@ libxlCapsInitCPU(virCaps *caps, libxl_physinfo *phy_info)
     cpu->threads = phy_info->threads_per_core;
     cpu->dies = 1;
     cpu->sockets = phy_info->nr_cpus / (cpu->cores * cpu->threads);
-    caps->host.cpu = cpu;
-
-    ret = 0;
 
     if (!(data = libxlCapsNodeData(cpu, phy_info->hw_cap)) ||
         cpuDecode(cpu, data, NULL) < 0) {
-        VIR_WARN("Failed to initialize host cpu features");
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Failed to initialize host cpu features"));
         goto error;
     }
 
+    caps->host.cpu = cpu;
+    ret = 0;
+
  cleanup:
     virCPUDataFree(data);