[PATCH] qemu: softfail for TCG capabilities probe

Tobin Feldman-Fitzthum posted 1 patch 4 years, 1 month ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20200323144235.34614-1-tobin@linux.vnet.ibm.com
src/qemu/qemu_capabilities.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
[PATCH] qemu: softfail for TCG capabilities probe
Posted by Tobin Feldman-Fitzthum 4 years, 1 month ago
As of version 2.10, QEMU can be built without the TCG. When libvirt determines that capabilities of a QEMU binary using QMP, it launches a QEMU process with KVM acceleration and TCG as a fallback. If QEMU supports KVM, a second probe is performed, forcing QEMU to use only TCG. This causes an error if the QEMU binary was built without TCG. This patch allows execution to continue when the second probe fails. Thus libvirt can be used with QEMU built without TCG. First patch. Feedback appreciated. If better solution, please advise.

Signed-off-by: Tobin Feldman-Fitzthum <tobin@linux.vnet.ibm.com>
---
 src/qemu/qemu_capabilities.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index a95a60c36a..f303171cc4 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -5100,9 +5100,6 @@ virQEMUCapsInitQMPSingle(virQEMUCapsPtr qemuCaps,
         ret = virQEMUCapsInitQMPMonitor(qemuCaps, proc->mon);
 
  cleanup:
-    if (ret < 0)
-        virQEMUCapsLogProbeFailure(qemuCaps->binary);
-
     qemuProcessQMPFree(proc);
     return ret;
 }
@@ -5114,17 +5111,18 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps,
                    uid_t runUid,
                    gid_t runGid)
 {
-    if (virQEMUCapsInitQMPSingle(qemuCaps, libDir, runUid, runGid, false) < 0)
+    if (virQEMUCapsInitQMPSingle(qemuCaps, libDir, runUid, runGid, false) < 0) {
+        virQEMUCapsLogProbeFailure(qemuCaps->binary);
         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
      * off.
      */
-    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) &&
-        virQEMUCapsInitQMPSingle(qemuCaps, libDir, runUid, runGid, true) < 0)
-        return -1;
+    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
+        virQEMUCapsInitQMPSingle(qemuCaps, libDir, runUid, runGid, true);
 
     return 0;
 }
-- 
2.20.1 (Apple Git-117)


Re: [PATCH] qemu: softfail for TCG capabilities probe
Posted by Ján Tomko 4 years, 1 month ago
[please wrap the lines to something sensible like 72 columns,
especially in the commit message]

On a Monday in 2020, Tobin Feldman-Fitzthum wrote:
>As of version 2.10, QEMU can be built without the TCG. When libvirt
>determines that capabilities of a QEMU binary using QMP, it launches a
>QEMU process with KVM acceleration and TCG as a fallback. If QEMU
>supports KVM, a second probe is performed, forcing QEMU to use only
>TCG. This causes an error if the QEMU binary was built without TCG.

>This patch allows execution to continue when the second probe fails.
>Thus libvirt can be used with QEMU built without TCG.

The second probe can fail for other reasons so ideally we would not even
call it if we know TCG is unsupported.

grep'ing through collected capabilitiesdata replies shows that since
2.10.0 the "qom-list-types" command shows two new 'types':
kvm-accel and tcg-accel

So we could introduce QEMU_CAPS_TCG, that would be set to true if
tcg-accel is present, or none of them are (to account for QEMU's earlier
than 2.10 - libvirt currently supports QEMUs back to 1.5.0)

>First patch.
>Feedback appreciated. If better solution, please advise.
>

Messages like this should not be in the git history, you can put them
under the three dashes below:

>Signed-off-by: Tobin Feldman-Fitzthum <tobin@linux.vnet.ibm.com>
>---
> src/qemu/qemu_capabilities.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>

Jano