]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: rdp: Fix 'qemuRdpAvailable()'
authorPeter Krempa <pkrempa@redhat.com>
Mon, 7 Apr 2025 16:16:15 +0000 (18:16 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 9 Apr 2025 16:05:26 +0000 (18:05 +0200)
qemuRdpAvailable() is called from the capability filing code, thus:
- it must not report spurious errors
- it should not call any extra processes

We can solve the above by just checking existance of 'qemu-rdp' in the
path as:
- at the time of adding of qemuRdpAvailable() there was only one 'qemu-rdp' release
- it supported all the features
- the check can't change as we'd drop the capability

Add comments and gut the check to only check existance of the file.

Fixes: f5e5a9bec9ec3e6c762f5000e3b8a0ba6a3a8c8d
Closes: https://gitlab.com/libvirt/libvirt/-/issues/763
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
src/qemu/qemu_rdp.c

index 984795d59992ba6ae5515cfc155d76d168f6bf43..0c48b87e7bad002a5fd4e4b6268c4ed44c49ff63 100644 (file)
@@ -413,12 +413,25 @@ qemuRdpSetCredentials(virDomainObj *vm,
 }
 
 
+/**
+ * qemuRdpAvailable:
+ * @helper: name (or path to) 'qemu-rdp' binary
+ *
+ * Returns whether 'qemu-rdp' is available.
+ *
+ * Important:
+ * This function is called from 'virQEMUDriverGetDomainCapabilities'. It must
+ * not report any errors and must not add any additional checks.
+ *
+ * This function is mocked from 'tests/testutilsqemu.c'
+ *
+ */
 bool
 qemuRdpAvailable(const char *helper)
 {
-    g_autoptr(qemuRdp) rdp = NULL;
-
-    rdp = qemuRdpNewForHelper(helper);
+    g_autofree char *helperPath = NULL;
 
-    return rdp && qemuRdpHasFeature(rdp, QEMU_RDP_FEATURE_DBUS_ADDRESS);
+    /* This function was added corresponding to the first release of 'qemu-rdp'
+     * thus checking existance of the helper binary is sufficient. */
+    return !!(helperPath = virFindFileInPath(helper));
 }