]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Introduce the 'ps2' feature
authorKamil Szczęk <kamil@szczek.dev>
Mon, 19 Aug 2024 01:19:21 +0000 (01:19 +0000)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 21 Aug 2024 15:10:51 +0000 (17:10 +0200)
This introduces a new 'ps2' feature which, when disabled, results in
no implicit PS/2 bus input devices being automatically added to the
domain and addition of the 'i8042=off' machine option to the QEMU
command-line.

A notable side effect of disabling the i8042 controller in QEMU is that
the vmport device won't be created. For this reason we will not allow
setting the vmport feature if the ps2 feature is explicitly disabled.

Signed-off-by: Kamil Szczęk <kamil@szczek.dev>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
docs/formatdomain.rst
src/conf/domain_conf.c
src/conf/domain_conf.h
src/conf/domain_validate.c
src/conf/schemas/domaincommon.rng
src/qemu/qemu_command.c
src/qemu/qemu_domain.c
src/qemu/qemu_validate.c

index e1e219bcb5c51a1161273eb19ace3443f3fc2964..741405ec1207447bd4c02364fe62c1a51c3e901c 100644 (file)
@@ -2022,6 +2022,7 @@ Hypervisors may allow certain CPU / machine features to be toggled on/off.
      </tcg>
      <async-teardown enabled='yes'/>
      <ras state='on'/>
+     <ps2 state='on'/>
    </features>
    ...
 
@@ -2262,6 +2263,11 @@ are:
    exceptions when enabled (``on``). If the attribute is not defined, the
    hypervisor default will be used.
    :since:`Since 10.4.0` (QEMU/KVM and ARM virt guests only)
+``ps2``
+   Depending on the ``state`` attribute (values ``on``, ``off``) enable or
+   disable the emulation of a PS/2 controller used by ``ps2`` bus input devices.
+   If the attribute is not defined, the hypervisor default will be used.
+   :since:`Since 10.7.0` (QEMU only)
 
 Time keeping
 ------------
index d950921667a2afca4d6a13a36f4f2ee195361c0e..a897b0b7271e4be0c785a88d31daee128e081de8 100644 (file)
@@ -185,6 +185,7 @@ VIR_ENUM_IMPL(virDomainFeature,
               "tcg",
               "async-teardown",
               "ras",
+              "ps2",
 );
 
 VIR_ENUM_IMPL(virDomainCapabilitiesPolicy,
@@ -17019,7 +17020,8 @@ virDomainFeaturesDefParse(virDomainDef *def,
         case VIR_DOMAIN_FEATURE_HTM:
         case VIR_DOMAIN_FEATURE_NESTED_HV:
         case VIR_DOMAIN_FEATURE_CCF_ASSIST:
-        case VIR_DOMAIN_FEATURE_RAS: {
+        case VIR_DOMAIN_FEATURE_RAS:
+        case VIR_DOMAIN_FEATURE_PS2: {
             virTristateSwitch state;
 
             if (virXMLPropTristateSwitch(nodes[i], "state",
@@ -20883,6 +20885,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDef *src,
         case VIR_DOMAIN_FEATURE_NESTED_HV:
         case VIR_DOMAIN_FEATURE_CCF_ASSIST:
         case VIR_DOMAIN_FEATURE_RAS:
+        case VIR_DOMAIN_FEATURE_PS2:
             if (src->features[i] != dst->features[i]) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                _("State of feature '%1$s' differs: source: '%2$s', destination: '%3$s'"),
@@ -27685,6 +27688,7 @@ virDomainDefFormatFeatures(virBuffer *buf,
         case VIR_DOMAIN_FEATURE_NESTED_HV:
         case VIR_DOMAIN_FEATURE_CCF_ASSIST:
         case VIR_DOMAIN_FEATURE_RAS:
+        case VIR_DOMAIN_FEATURE_PS2:
             switch ((virTristateSwitch) def->features[i]) {
             case VIR_TRISTATE_SWITCH_LAST:
             case VIR_TRISTATE_SWITCH_ABSENT:
index eae621f900b98f86d4c0c34e6f751aa5a7e8ca16..f65cdd87b603f6e1717d5d120c8b380bc361fd79 100644 (file)
@@ -2181,6 +2181,7 @@ typedef enum {
     VIR_DOMAIN_FEATURE_TCG,
     VIR_DOMAIN_FEATURE_ASYNC_TEARDOWN,
     VIR_DOMAIN_FEATURE_RAS,
+    VIR_DOMAIN_FEATURE_PS2,
 
     VIR_DOMAIN_FEATURE_LAST
 } virDomainFeature;
index ab1caadc7af8e93342f6ce1fae7dbb7bce65aa04..eddb4a5e74a1c51615ce7c0a1720cfb1bb3c61bf 100644 (file)
@@ -2753,6 +2753,29 @@ virDomainInputDefValidate(const virDomainInputDef *input,
         return -1;
     }
 
+    switch ((virDomainInputBus) input->bus) {
+    case VIR_DOMAIN_INPUT_BUS_PS2:
+        if (def->features[VIR_DOMAIN_FEATURE_PS2] == VIR_TRISTATE_SWITCH_OFF) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("ps2 bus inputs require the ps2 feature not to be disabled"));
+            return -1;
+        }
+        break;
+
+    case VIR_DOMAIN_INPUT_BUS_DEFAULT:
+    case VIR_DOMAIN_INPUT_BUS_USB:
+    case VIR_DOMAIN_INPUT_BUS_XEN:
+    case VIR_DOMAIN_INPUT_BUS_PARALLELS:
+    case VIR_DOMAIN_INPUT_BUS_VIRTIO:
+    case VIR_DOMAIN_INPUT_BUS_NONE:
+        break;
+
+    case VIR_DOMAIN_INPUT_BUS_LAST:
+    default:
+        virReportEnumRangeError(virDomainInputBus, input->bus);
+        return -1;
+    }
+
     return 0;
 }
 
index 05ba697924701ee5d2ed8bee4293daac477e2f35..a71f1d97b913f8576663529b97e93ae58f15ca97 100644 (file)
               <ref name="featurestate"/>
             </element>
           </optional>
+          <optional>
+            <element name="ps2">
+              <ref name="featurestate"/>
+            </element>
+          </optional>
         </interleave>
       </element>
     </optional>
index 28914c9c346a3ffe1fa30924540ae27ab696eb76..bb6fee4bfdfdcd941a9ebb69d8a9bfffab40914e 100644 (file)
@@ -6888,6 +6888,11 @@ qemuAppendDomainFeaturesMachineParam(virBuffer *buf,
         virBufferAsprintf(buf, ",ras=%s", str);
     }
 
+    if (def->features[VIR_DOMAIN_FEATURE_PS2] != VIR_TRISTATE_SWITCH_ABSENT) {
+        const char *str = virTristateSwitchTypeToString(def->features[VIR_DOMAIN_FEATURE_PS2]);
+        virBufferAsprintf(buf, ",i8042=%s", str);
+    }
+
     return 0;
 }
 
index 2b4bb54efc521927bd6a6f43c915489d5cd13a3e..d1767c326d5821aeca1ca808372be6e56af27d83 100644 (file)
@@ -3928,7 +3928,8 @@ static int
 qemuDomainDefAddImplicitInputDevice(virDomainDef *def,
                                     virQEMUCaps *qemuCaps)
 {
-    if (virQEMUCapsSupportsI8042(qemuCaps, def)) {
+    if (virQEMUCapsSupportsI8042(qemuCaps, def) &&
+        def->features[VIR_DOMAIN_FEATURE_PS2] != VIR_TRISTATE_SWITCH_OFF) {
         if (virDomainDefMaybeAddInput(def,
                                       VIR_DOMAIN_INPUT_TYPE_MOUSE,
                                       VIR_DOMAIN_INPUT_BUS_PS2) < 0)
index bcb2803130557db42e52c87a2267ce80e28264c7..f74c538efe248605bdf81970a3fafe9e53358494 100644 (file)
@@ -143,6 +143,13 @@ qemuValidateDomainDefFeatures(const virDomainDef *def,
                                _("vmport is not available with this QEMU binary"));
                 return -1;
             }
+
+            if (def->features[i] == VIR_TRISTATE_SWITCH_ON &&
+                def->features[VIR_DOMAIN_FEATURE_PS2] == VIR_TRISTATE_SWITCH_OFF) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("vmport feature requires the ps2 feature not to be disabled"));
+                return -1;
+            }
             break;
 
         case VIR_DOMAIN_FEATURE_VMCOREINFO:
@@ -242,6 +249,22 @@ qemuValidateDomainDefFeatures(const virDomainDef *def,
             }
             break;
 
+        case VIR_DOMAIN_FEATURE_PS2:
+            if (def->features[i] != VIR_TRISTATE_SWITCH_ABSENT &&
+                !virQEMUCapsSupportsI8042(qemuCaps, def)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("ps2 feature is not available with this QEMU binary"));
+                return -1;
+            }
+
+            if (def->features[i] != VIR_TRISTATE_SWITCH_ABSENT &&
+                !virQEMUCapsSupportsI8042Toggle(qemuCaps, def)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("ps2 feature state cannot be controlled with this QEMU binary"));
+                return -1;
+            }
+            break;
+
         case VIR_DOMAIN_FEATURE_SMM:
         case VIR_DOMAIN_FEATURE_KVM:
         case VIR_DOMAIN_FEATURE_XEN: