render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
c480ed
From d2ef598bb59e613ce4a8b969ab9836604bd72727 Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <d2ef598bb59e613ce4a8b969ab9836604bd72727@dist-git>
c480ed
From: Jiri Denemark <jdenemar@redhat.com>
c480ed
Date: Fri, 21 Jun 2019 09:25:54 +0200
c480ed
Subject: [PATCH] qemu: Probe host CPU after capabilities
c480ed
MIME-Version: 1.0
c480ed
Content-Type: text/plain; charset=UTF-8
c480ed
Content-Transfer-Encoding: 8bit
c480ed
c480ed
The way we call query-cpu-model-expansion will rely on some capabilities
c480ed
bits. Let's make sure all capabilities are set before probing host CPU.
c480ed
c480ed
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
(cherry picked from commit 6f6401fbae384c66ce6043ced30591050729a4ac)
c480ed
c480ed
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
c480ed
c480ed
Conflicts:
c480ed
	src/qemu/qemu_capabilities.c
c480ed
            - various refactors were not backported
c480ed
c480ed
	tests/qemucapabilitiesdata/caps_2.12.0.x86_64.replies
c480ed
	tests/qemucapabilitiesdata/caps_3.0.0.x86_64.replies
c480ed
            - QMP message IDs are different
c480ed
c480ed
	tests/qemucapabilitiesdata/caps_3.1.0.x86_64.replies
c480ed
	tests/qemucapabilitiesdata/caps_4.0.0.x86_64.replies
c480ed
            - missing
c480ed
c480ed
	tests/qemucapabilitiesdata/caps_4.1.0.x86_64.replies
c480ed
            - QMP message IDs are different
c480ed
c480ed
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c480ed
Message-Id: <cea249ba54be2d9dca6f523a14b0af608163323f.1561068591.git.jdenemar@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
---
c480ed
 src/qemu/qemu_capabilities.c                  |  8 +++-
c480ed
 .../caps_2.12.0.x86_64.replies                | 44 +++++++++----------
c480ed
 .../caps_3.0.0.x86_64.replies                 | 40 ++++++++---------
c480ed
 .../caps_4.1.0.x86_64.replies                 | 40 ++++++++---------
c480ed
 4 files changed, 68 insertions(+), 64 deletions(-)
c480ed
c480ed
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
c480ed
index beec9d1497..fb260eae96 100644
c480ed
--- a/src/qemu/qemu_capabilities.c
c480ed
+++ b/src/qemu/qemu_capabilities.c
c480ed
@@ -4343,8 +4343,6 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
c480ed
     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_QMP_SCHEMA) &&
c480ed
         virQEMUCapsProbeQMPSchemaCapabilities(qemuCaps, mon) < 0)
c480ed
         goto cleanup;
c480ed
-    if (virQEMUCapsProbeQMPHostCPU(qemuCaps, mon, false) < 0)
c480ed
-        goto cleanup;
c480ed
 
c480ed
     /* 'intel-iommu' shows up as a device since 2.2.0, but can
c480ed
      * not be used with -device until 2.7.0. Before that it
c480ed
@@ -4394,6 +4392,12 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
c480ed
             virQEMUCapsClear(qemuCaps, QEMU_CAPS_SEV_GUEST);
c480ed
     }
c480ed
 
c480ed
+    /* The following probes rely on other previously probed capabilities.
c480ed
+     * No capabilities bits should be set below this point. */
c480ed
+
c480ed
+    if (virQEMUCapsProbeQMPHostCPU(qemuCaps, mon, false) < 0)
c480ed
+        goto cleanup;
c480ed
+
c480ed
     ret = 0;
c480ed
  cleanup:
c480ed
     return ret;
c480ed
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.replies b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.replies
c480ed
index 66a5577e5e..ecfe3386c4 100644
c480ed
--- a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.replies
c480ed
+++ b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.replies
c480ed
@@ -19521,6 +19521,21 @@
c480ed
   "id": "libvirt-50"
c480ed
 }
c480ed
 
c480ed
+{
c480ed
+  "execute": "query-sev-capabilities",
c480ed
+  "id": "libvirt-51"
c480ed
+}
c480ed
+
c480ed
+{
c480ed
+  "return": {
c480ed
+    "reduced-phys-bits": 1,
c480ed
+    "cbitpos": 47,
c480ed
+    "cert-chain": "AQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAA",
c480ed
+    "pdh": "AQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAA"
c480ed
+  },
c480ed
+  "id": "libvirt-51"
c480ed
+}
c480ed
+
c480ed
 {
c480ed
   "execute": "query-cpu-model-expansion",
c480ed
   "arguments": {
c480ed
@@ -19529,7 +19544,7 @@
c480ed
       "name": "host"
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-51"
c480ed
+  "id": "libvirt-52"
c480ed
 }
c480ed
 
c480ed
 {
c480ed
@@ -19719,7 +19734,7 @@
c480ed
       }
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-51"
c480ed
+  "id": "libvirt-52"
c480ed
 }
c480ed
 
c480ed
 {
c480ed
@@ -19911,7 +19926,7 @@
c480ed
       }
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-52"
c480ed
+  "id": "libvirt-53"
c480ed
 }
c480ed
 
c480ed
 {
c480ed
@@ -20166,7 +20181,7 @@
c480ed
       }
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-52"
c480ed
+  "id": "libvirt-53"
c480ed
 }
c480ed
 
c480ed
 {
c480ed
@@ -20180,7 +20195,7 @@
c480ed
       }
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-53"
c480ed
+  "id": "libvirt-54"
c480ed
 }
c480ed
 
c480ed
 {
c480ed
@@ -20370,7 +20385,7 @@
c480ed
       }
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-53"
c480ed
+  "id": "libvirt-54"
c480ed
 }
c480ed
 
c480ed
 {
c480ed
@@ -20562,7 +20577,7 @@
c480ed
       }
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-54"
c480ed
+  "id": "libvirt-55"
c480ed
 }
c480ed
 
c480ed
 {
c480ed
@@ -20817,21 +20832,6 @@
c480ed
       }
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-54"
c480ed
-}
c480ed
-
c480ed
-{
c480ed
-  "execute": "query-sev-capabilities",
c480ed
-  "id": "libvirt-55"
c480ed
-}
c480ed
-
c480ed
-{
c480ed
-  "return": {
c480ed
-    "reduced-phys-bits": 1,
c480ed
-    "cbitpos": 47,
c480ed
-    "cert-chain": "AQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAA",
c480ed
-    "pdh": "AQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAAAQAAAAAOAAA"
c480ed
-  },
c480ed
   "id": "libvirt-55"
c480ed
 }
c480ed
 
c480ed
diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.replies b/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.replies
c480ed
index 9f44eb4fae..7fea8587fd 100644
c480ed
--- a/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.replies
c480ed
+++ b/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.replies
c480ed
@@ -20490,6 +20490,19 @@
c480ed
   "id": "libvirt-50"
c480ed
 }
c480ed
 
c480ed
+{
c480ed
+  "execute": "query-sev-capabilities",
c480ed
+  "id": "libvirt-51"
c480ed
+}
c480ed
+
c480ed
+{
c480ed
+  "id": "libvirt-51",
c480ed
+  "error": {
c480ed
+    "class": "GenericError",
c480ed
+    "desc": "SEV feature is not available"
c480ed
+  }
c480ed
+}
c480ed
+
c480ed
 {
c480ed
   "execute": "query-cpu-model-expansion",
c480ed
   "arguments": {
c480ed
@@ -20498,7 +20511,7 @@
c480ed
       "name": "host"
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-51"
c480ed
+  "id": "libvirt-52"
c480ed
 }
c480ed
 
c480ed
 {
c480ed
@@ -20691,7 +20704,7 @@
c480ed
       }
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-51"
c480ed
+  "id": "libvirt-52"
c480ed
 }
c480ed
 
c480ed
 {
c480ed
@@ -20886,7 +20899,7 @@
c480ed
       }
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-52"
c480ed
+  "id": "libvirt-53"
c480ed
 }
c480ed
 
c480ed
 {
c480ed
@@ -21148,7 +21161,7 @@
c480ed
       }
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-52"
c480ed
+  "id": "libvirt-53"
c480ed
 }
c480ed
 
c480ed
 {
c480ed
@@ -21162,7 +21175,7 @@
c480ed
       }
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-53"
c480ed
+  "id": "libvirt-54"
c480ed
 }
c480ed
 
c480ed
 {
c480ed
@@ -21355,7 +21368,7 @@
c480ed
       }
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-53"
c480ed
+  "id": "libvirt-54"
c480ed
 }
c480ed
 
c480ed
 {
c480ed
@@ -21550,7 +21563,7 @@
c480ed
       }
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-54"
c480ed
+  "id": "libvirt-55"
c480ed
 }
c480ed
 
c480ed
 {
c480ed
@@ -21812,22 +21825,9 @@
c480ed
       }
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-54"
c480ed
-}
c480ed
-
c480ed
-{
c480ed
-  "execute": "query-sev-capabilities",
c480ed
   "id": "libvirt-55"
c480ed
 }
c480ed
 
c480ed
-{
c480ed
-  "id": "libvirt-55",
c480ed
-  "error": {
c480ed
-    "class": "GenericError",
c480ed
-    "desc": "SEV feature is not available"
c480ed
-  }
c480ed
-}
c480ed
-
c480ed
 {
c480ed
   "execute": "qmp_capabilities",
c480ed
   "id": "libvirt-1"
c480ed
diff --git a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.replies b/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.replies
c480ed
index 82b320b1d0..5b4d7a8484 100644
c480ed
--- a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.replies
c480ed
+++ b/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.replies
c480ed
@@ -21315,6 +21315,19 @@
c480ed
   "id": "libvirt-50"
c480ed
 }
c480ed
 
c480ed
+{
c480ed
+  "execute": "query-sev-capabilities",
c480ed
+  "id": "libvirt-51"
c480ed
+}
c480ed
+
c480ed
+{
c480ed
+  "id": "libvirt-51",
c480ed
+  "error": {
c480ed
+    "class": "GenericError",
c480ed
+    "desc": "SEV feature is not available"
c480ed
+  }
c480ed
+}
c480ed
+
c480ed
 {
c480ed
   "execute": "query-cpu-model-expansion",
c480ed
   "arguments": {
c480ed
@@ -21323,7 +21336,7 @@
c480ed
       "name": "host"
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-51"
c480ed
+  "id": "libvirt-52"
c480ed
 }
c480ed
 
c480ed
 {
c480ed
@@ -21529,7 +21542,7 @@
c480ed
       }
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-51"
c480ed
+  "id": "libvirt-52"
c480ed
 }
c480ed
 
c480ed
 {
c480ed
@@ -21737,7 +21750,7 @@
c480ed
       }
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-52"
c480ed
+  "id": "libvirt-53"
c480ed
 }
c480ed
 
c480ed
 {
c480ed
@@ -22018,7 +22031,7 @@
c480ed
       }
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-52"
c480ed
+  "id": "libvirt-53"
c480ed
 }
c480ed
 
c480ed
 {
c480ed
@@ -22032,7 +22045,7 @@
c480ed
       }
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-53"
c480ed
+  "id": "libvirt-54"
c480ed
 }
c480ed
 
c480ed
 {
c480ed
@@ -22238,7 +22251,7 @@
c480ed
       }
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-53"
c480ed
+  "id": "libvirt-54"
c480ed
 }
c480ed
 
c480ed
 {
c480ed
@@ -22446,7 +22459,7 @@
c480ed
       }
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-54"
c480ed
+  "id": "libvirt-55"
c480ed
 }
c480ed
 
c480ed
 {
c480ed
@@ -22727,22 +22740,9 @@
c480ed
       }
c480ed
     }
c480ed
   },
c480ed
-  "id": "libvirt-54"
c480ed
-}
c480ed
-
c480ed
-{
c480ed
-  "execute": "query-sev-capabilities",
c480ed
   "id": "libvirt-55"
c480ed
 }
c480ed
 
c480ed
-{
c480ed
-  "id": "libvirt-55",
c480ed
-  "error": {
c480ed
-    "class": "GenericError",
c480ed
-    "desc": "SEV feature is not available"
c480ed
-  }
c480ed
-}
c480ed
-
c480ed
 {
c480ed
   "execute": "qmp_capabilities",
c480ed
   "id": "libvirt-1"
c480ed
-- 
c480ed
2.22.0
c480ed