[PATCH v3 2/6] qemu_capabilities: Introduce QEMU_CAPS_MACHINE_I8042_OPT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This capability tells us whether given QEMU binary supports the
'-machine xxx,i8042=on/off' toggle used to enable/disable PS/2
controller emulation.

A few facts:
- This option was introduced in QEMU 7.0 and defaults to 'on'
- QEMU versions before 7.0 enabled i8042 controller emulation implicitly
- This option (and i8042 controller emulation itself) is only supported
by descendants of the generic PC machine type (e.g. i440fx, q35, etc.)

Signed-off-by: Kamil Szczęk <kamil@xxxxxxxxxx>
---
 src/qemu/qemu_capabilities.c | 22 ++++++++++++++++++++++
 src/qemu/qemu_capabilities.h |  4 ++++
 2 files changed, 26 insertions(+)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index dd833fb3ff..2d53e87ff3 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -714,6 +714,7 @@ VIR_ENUM_IMPL(virQEMUCaps,
               "netdev.user", /* QEMU_CAPS_NETDEV_USER */
               "acpi-erst", /* QEMU_CAPS_DEVICE_ACPI_ERST */
               "intel-iommu.dma-translation", /* QEMU_CAPS_INTEL_IOMMU_DMA_TRANSLATION */
+              "machine-i8042-opt", /* QEMU_CAPS_MACHINE_I8042_OPT */
     );
 
 
@@ -1747,6 +1748,10 @@ static struct virQEMUCapsStringFlags virQEMUCapsMachinePropsGeneric[] = {
     { "confidential-guest-support", QEMU_CAPS_MACHINE_CONFIDENTAL_GUEST_SUPPORT },
 };
 
+static struct virQEMUCapsStringFlags virQEMUCapsMachinePropsGenericPC[] = {
+    { "i8042", QEMU_CAPS_MACHINE_I8042_OPT },
+};
+
 static virQEMUCapsObjectTypeProps virQEMUCapsMachineProps[] = {
     { "pseries", virQEMUCapsMachinePropsPSeries,
       G_N_ELEMENTS(virQEMUCapsMachinePropsPSeries),
@@ -1757,6 +1762,9 @@ static virQEMUCapsObjectTypeProps virQEMUCapsMachineProps[] = {
     { "none", virQEMUCapsMachinePropsGeneric,
       G_N_ELEMENTS(virQEMUCapsMachinePropsGeneric),
       -1 },
+    { "generic-pc", virQEMUCapsMachinePropsGenericPC,
+      G_N_ELEMENTS(virQEMUCapsMachinePropsGenericPC),
+      -1 },
 };
 
 static void
@@ -2893,6 +2901,7 @@ virQEMUCapsProbeQMPMachineProps(virQEMUCaps *qemuCaps,
         g_auto(GStrv) values = NULL;
 
         if (STRNEQ(canon, "none") &&
+            (!ARCH_IS_X86(qemuCaps->arch) || STRNEQ(canon, "generic-pc")) &&
             !virQEMUCapsIsMachineSupported(qemuCaps, virtType, canon)) {
             continue;
         }
@@ -6021,6 +6030,19 @@ virQEMUCapsSupportsI8042(virQEMUCaps *qemuCaps,
         STREQ(def->os.machine, "isapc");
 }
 
+bool
+virQEMUCapsSupportsI8042Toggle(virQEMUCaps *qemuCaps,
+                               const virDomainDef *def)
+{
+    if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_I8042_OPT))
+        return false;
+
+    return qemuDomainIsI440FX(def) ||
+        qemuDomainIsQ35(def) ||
+        qemuDomainIsXenFV(def) ||
+        STREQ(def->os.machine, "isapc");
+}
+
 
 /*
  * The preferred machine to use if none is listed explicitly
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 659efd9182..9c577c1505 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -693,6 +693,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */
     QEMU_CAPS_NETDEV_USER, /* -netdev user */
     QEMU_CAPS_DEVICE_ACPI_ERST, /* -device acpi-erst */
     QEMU_CAPS_INTEL_IOMMU_DMA_TRANSLATION, /* intel-iommu.dma-translation */
+    QEMU_CAPS_MACHINE_I8042_OPT, /* -machine xxx,i8042=on/off; use virQEMUCapsSupportsI8042Toggle() to query this capability */
 
     QEMU_CAPS_LAST /* this must always be the last item */
 } virQEMUCapsFlags;
@@ -721,6 +722,9 @@ bool virQEMUCapsSupportsVmport(virQEMUCaps *qemuCaps,
 bool virQEMUCapsSupportsI8042(virQEMUCaps *qemuCaps,
                               const virDomainDef *def);
 
+bool virQEMUCapsSupportsI8042Toggle(virQEMUCaps *qemuCaps,
+                                    const virDomainDef *def);
+
 const char *virQEMUCapsGetBinary(virQEMUCaps *qemuCaps);
 virArch virQEMUCapsGetArch(virQEMUCaps *qemuCaps);
 unsigned int virQEMUCapsGetVersion(virQEMUCaps *qemuCaps);
-- 
2.45.0





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux