]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: capabilities: Fix testing of 'TCG' capabilities probing
authorPeter Krempa <pkrempa@redhat.com>
Wed, 8 Mar 2023 17:58:51 +0000 (18:58 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 3 Apr 2023 07:19:06 +0000 (09:19 +0200)
The logic in 'virQEMUCapsInitQMP' invokes a second probe of qemu in case
when acceleration is used and TCG is supported to specifically probe the
CPU and features of non-accelerated guests.

The same logic must then be used in 'qemucapabilitiestest' when
replaying the data for testing otherwise the test would fail.

Export 'virQEMUCapsHaveAccel' for test usage and use the same logic
in 'testQemuCaps'.

Fix the comment in 'virQEMUCapsInitQMP' to outline what's happening.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_capabilities.c
src/qemu/qemu_capspriv.h
tests/qemucapabilitiestest.c

index b2622a056ebb01fce655a14bbf57cef23ec6ff99..c5f144d20afed4e8287cf9a1d7054aaeff5c68de 100644 (file)
@@ -883,7 +883,7 @@ virQEMUCapsTypeIsAccelerated(virDomainVirtType type)
 }
 
 
-static bool
+bool
 virQEMUCapsHaveAccel(virQEMUCaps *qemuCaps)
 {
     return virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) ||
@@ -5748,8 +5748,8 @@ virQEMUCapsInitQMP(virQEMUCaps *qemuCaps,
         return -1;
 
     /*
-     * If KVM was enabled during the first probe, we need to explicitly probe
-     * for TCG capabilities by asking the same binary again and turning KVM
+     * If acceleration was enabled during the first probe, we need to explicitly
+     * probe for TCG capabilities by asking the same binary again and turning KVM
      * off.
      */
     if (virQEMUCapsHaveAccel(qemuCaps) &&
index 60fdf02f06f452000858ac012e319e133dfd833d..be83b13ab54185c6d6aece8129292a85b0f4d74c 100644 (file)
@@ -116,3 +116,6 @@ virQEMUCapsAddMachine(virQEMUCaps *qemuCaps,
                       const char *defaultRAMid,
                       bool deprecated,
                       virTristateBool acpi);
+
+bool
+virQEMUCapsHaveAccel(virQEMUCaps *qemuCaps);
index 081f14a6c387b4a13ba3b04abbb07a9f627da723..7575f9fd440e5859db26e08599fb439ca845cd5b 100644 (file)
@@ -101,7 +101,8 @@ testQemuCaps(const void *opaque)
     if (virQEMUCapsInitQMPMonitor(capsActual, qemuMonitorTestGetMonitor(mon)) < 0)
         return -1;
 
-    if (virQEMUCapsGet(capsActual, QEMU_CAPS_KVM)) {
+    if (virQEMUCapsHaveAccel(capsActual) &&
+        virQEMUCapsGet(capsActual, QEMU_CAPS_TCG)) {
         qemuMonitorResetCommandID(qemuMonitorTestGetMonitor(mon));
 
         if (qemuProcessQMPInitMonitor(qemuMonitorTestGetMonitor(mon)) < 0)