From nobody Sun May 5 12:46:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 16269371537541021.0058023063478; Wed, 21 Jul 2021 23:59:13 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-587-WdzqDTeeMg2xQI8gQQBDLQ-1; Thu, 22 Jul 2021 02:59:11 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9E212363A8; Thu, 22 Jul 2021 06:59:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F1A175D6D1; Thu, 22 Jul 2021 06:59:00 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8AC984BB7B; Thu, 22 Jul 2021 06:58:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16M6wrKa004372 for ; Thu, 22 Jul 2021 02:58:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id C8D71202863A; Thu, 22 Jul 2021 06:58:53 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C45BD20285BD for ; Thu, 22 Jul 2021 06:58:51 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EC9A2802A5E for ; Thu, 22 Jul 2021 06:58:50 +0000 (UTC) Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-95-_7g_DNKANC-BKGWLkw8bfg-1; Thu, 22 Jul 2021 02:58:48 -0400 Received: by mail-qk1-f173.google.com with SMTP id m68so4512338qke.7; Wed, 21 Jul 2021 23:58:48 -0700 (PDT) Received: from south.. ([2601:182:300:6ce:8858:59ff:fe0c:9c97]) by smtp.gmail.com with ESMTPSA id g4sm8827035qkk.104.2021.07.21.23.58.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jul 2021 23:58:47 -0700 (PDT) X-MC-Unique: WdzqDTeeMg2xQI8gQQBDLQ-1 X-MC-Unique: _7g_DNKANC-BKGWLkw8bfg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NyHEoo5aKwkcGmuDszU2ZbwV0GWLSin9jh52oBxwd9s=; b=FrNMomEX2t+q8giC7D1smCxz5b+k0LKwhO5r3kr2gcJWrqfP3kMadRL7kdVxpe7Lm2 zOruxfsLvVxV5Ohm4zjRZXKkZAN0CfopZqT3ao45vSWqQXcRq2V8YsjAm2/Zvw9TY7OE VtlTLT2cuC9Lrb/Tbuv4oJYORRRwuf1o0XOqrdcxwtO1+YDNl1m8ChPNuTBLcyQao7+P c1frgFTOE5oReUl2kJPFvKH8BpNBOxlb+/3JtqERCgQ0PHvxmjbMDMXXMoI8SqAJlL+1 3o3I0DguHZBdynr/Om5FSSM2QDaxjVtpCTiOLoigfy43LjK0Dr+EmZnG4d4+beFFeTrs Q2DA== X-Gm-Message-State: AOAM5315DIKVFzIpYu66p2LAjmGvhSFbhQJHi9AIvwGwu8YyvoMfi3vy 1N9eZvcyJKimfP3vpHWUceOl0WKN9W7Cvw== X-Google-Smtp-Source: ABdhPJzEkCzNwE1ZA1rIm79c6vu9GHPz39CpmpI75Z08YnEO2tF9mmwwE9Do/1gNC8a1n74zKlOgBA== X-Received: by 2002:a37:4090:: with SMTP id n138mr38535787qka.238.1626937127992; Wed, 21 Jul 2021 23:58:47 -0700 (PDT) From: Justin Gatzen To: libvir-list@redhat.com Subject: [PATCH] conf: Add grabToggle to evdev input Date: Thu, 22 Jul 2021 02:58:45 -0400 Message-Id: <20210722065845.1274528-1-justin.gatzen@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, Justin Gatzen , khanicov@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1626937154335100001 Content-Type: text/plain; charset="utf-8" Add support for customizable grabToggle key combinations with . Signed-off-by: Justin Gatzen Reviewed-by: Michal Privoznik --- docs/formatdomain.rst | 12 +++++++----- docs/schemas/domaincommon.rng | 12 ++++++++++++ src/conf/domain_conf.c | 19 +++++++++++++++++++ src/conf/domain_conf.h | 14 ++++++++++++++ src/libvirt_private.syms | 2 ++ src/qemu/qemu_command.c | 5 +++++ .../input-linux.x86_64-latest.args | 2 +- tests/qemuxml2argvdata/input-linux.xml | 2 +- 8 files changed, 61 insertions(+), 7 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index b621591515..61ccd8895a 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -5747,7 +5747,7 @@ to provide a graphics tablet for absolute cursor move= ment. - + ... @@ -5768,10 +5768,12 @@ On S390, ``address`` can be used to provide a CCW a= ddress for an input device ( sub-element ``source`` must have an ``evdev`` (for ``passthrough``) or ``d= ev`` (for ``evdev``) attribute containing the absolute path to the event device passed through to guests. -For type ``evdev``, ``source`` can have two optional attributes ``grab`` w= ith -value 'all' which when enabled grabs all input devices instead of just one= and -``repeat`` with value 'on'/'off' to enable/disable auto-repeat events ( -:since:`Since 7.4.0`). +For type ``evdev``, ``source`` has three optional attributes ``grab`` with +value 'all' which when enabled grabs all input devices instead of just one, +``repeat`` with value 'on'/'off' to enable/disable auto-repeat events and +``grabToggle`` (:since:`since 7.6.0`) with values ``ctrl-ctrl``, ``alt-alt= ``, +``shift-shift``, ``meta-meta``, ``scrolllock`` or ``ctrl-scrolllock`` to +change the grab key combination. ``input`` type ``evdev`` is currently supported only on linux devices. (KVM only) :since:`Since 5.2.0` , the ``input`` element accepts a ``model`` attribute which has the values 'virtio', 'virtio-transitional' a= nd diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 538581360d..14c5d4ee68 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -5484,6 +5484,18 @@ all + + + + ctrl-ctrl + alt-alt + shift-shift + meta-meta + scrolllock + ctrl-scrolllock + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e05ea9ba88..44d55ede5b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -891,6 +891,17 @@ VIR_ENUM_IMPL(virDomainInputSourceGrab, "all", ); =20 +VIR_ENUM_IMPL(virDomainInputSourceGrabToggle, + VIR_DOMAIN_INPUT_SOURCE_GRAB_TOGGLE_LAST, + "default", + "ctrl-ctrl", + "alt-alt", + "shift-shift", + "meta-meta", + "scrolllock", + "ctrl-scrolllock", +); + VIR_ENUM_IMPL(virDomainGraphics, VIR_DOMAIN_GRAPHICS_TYPE_LAST, "sdl", @@ -12011,6 +12022,11 @@ virDomainInputDefParseXML(virDomainXMLOption *xmlo= pt, VIR_XML_PROP_NONZERO, &def->source.grab) < = 0) goto error; =20 + if (virXMLPropEnum(source, "grabToggle", + virDomainInputSourceGrabToggleTypeFromStrin= g, + VIR_XML_PROP_NONZERO, &def->source.grabTogg= le) < 0) + goto error; + if (virXMLPropTristateSwitch(source, "repeat", VIR_XML_PROP_NONE, &def->source.r= epeat) < 0) goto error; @@ -25998,6 +26014,7 @@ virDomainInputDefFormat(virBuffer *buf, const char *type =3D virDomainInputTypeToString(def->type); const char *bus =3D virDomainInputBusTypeToString(def->bus); const char *grab =3D virDomainInputSourceGrabTypeToString(def->source.= grab); + const char *grabToggle =3D virDomainInputSourceGrabToggleTypeToString(= def->source.grabToggle); const char *repeat =3D virTristateSwitchTypeToString(def->source.repea= t); g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); @@ -26049,6 +26066,8 @@ virDomainInputDefFormat(virBuffer *buf, =20 if (def->source.grab) virBufferAsprintf(&sourceAttrBuf, " grab=3D'%s'", grab); + if (def->source.grabToggle) + virBufferAsprintf(&sourceAttrBuf, " grabToggle=3D'%s'", grabToggle= ); if (def->source.repeat) virBufferAsprintf(&sourceAttrBuf, " repeat=3D'%s'", repeat); =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 5c22f252d0..ca21082624 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1420,6 +1420,18 @@ typedef enum { VIR_DOMAIN_INPUT_SOURCE_GRAB_LAST } virDomainInputSourceGrab; =20 +typedef enum { + VIR_DOMAIN_INPUT_SOURCE_GRAB_TOGGLE_DEFAULT, + VIR_DOMAIN_INPUT_SOURCE_GRAB_TOGGLE_CTRL_CTRL, + VIR_DOMAIN_INPUT_SOURCE_GRAB_TOGGLE_ALT_ALT, + VIR_DOMAIN_INPUT_SOURCE_GRAB_TOGGLE_SHIFT_SHIFT, + VIR_DOMAIN_INPUT_SOURCE_GRAB_TOGGLE_META_META, + VIR_DOMAIN_INPUT_SOURCE_GRAB_TOGGLE_SCROLLLOCK, + VIR_DOMAIN_INPUT_SOURCE_GRAB_TOGGLE_CTRL_SCROLLLOCK, + + VIR_DOMAIN_INPUT_SOURCE_GRAB_TOGGLE_LAST +} virDomainInputSourceGrabToggle; + struct _virDomainInputDef { int type; int bus; @@ -1427,6 +1439,7 @@ struct _virDomainInputDef { struct { char *evdev; virDomainInputSourceGrab grab; + virDomainInputSourceGrabToggle grabToggle; virTristateSwitch repeat; } source; virDomainDeviceInfo info; @@ -3871,6 +3884,7 @@ VIR_ENUM_DECL(virDomainInput); VIR_ENUM_DECL(virDomainInputBus); VIR_ENUM_DECL(virDomainInputModel); VIR_ENUM_DECL(virDomainInputSourceGrab); +VIR_ENUM_DECL(virDomainInputSourceGrabToggle); VIR_ENUM_DECL(virDomainGraphics); VIR_ENUM_DECL(virDomainGraphicsListen); VIR_ENUM_DECL(virDomainGraphicsAuthConnected); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4bc2974e7f..6bbf551f48 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -476,6 +476,8 @@ virDomainInputBusTypeToString; virDomainInputDefFind; virDomainInputDefFree; virDomainInputDefGetPath; +virDomainInputSourceGrabToggleTypeFromString; +virDomainInputSourceGrabToggleTypeToString; virDomainInputSourceGrabTypeFromString; virDomainInputSourceGrabTypeToString; virDomainInputTypeToString; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3c3ecd63e3..156af4caee 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3947,6 +3947,11 @@ qemuBuildObjectInputDevStr(virDomainInputDef *dev, if (dev->source.grab =3D=3D VIR_DOMAIN_INPUT_SOURCE_GRAB_ALL) virJSONValueObjectAdd(props, "b:grab_all", true, NULL); =20 + if (dev->source.grabToggle !=3D VIR_DOMAIN_INPUT_SOURCE_GRAB_TOGGLE_DE= FAULT) + virJSONValueObjectAdd(props, "s:grab-toggle", + virDomainInputSourceGrabToggleTypeToString(d= ev->source.grabToggle), + NULL); + if (qemuBuildObjectCommandlineFromJSON(&buf, props, qemuCaps) < 0) return NULL; =20 diff --git a/tests/qemuxml2argvdata/input-linux.x86_64-latest.args b/tests/= qemuxml2argvdata/input-linux.x86_64-latest.args index 688cf02873..3c7e65a7f0 100644 --- a/tests/qemuxml2argvdata/input-linux.x86_64-latest.args +++ b/tests/qemuxml2argvdata/input-linux.x86_64-latest.args @@ -27,7 +27,7 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -no-acpi \ -boot strict=3Don \ -device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ --object '{"qom-type":"input-linux","id":"input0","evdev":"/dev/input/event= 1234","repeat":true,"grab_all":true}' \ +-object '{"qom-type":"input-linux","id":"input0","evdev":"/dev/input/event= 1234","repeat":true,"grab_all":true,"grab-toggle":"alt-alt"}' \ -audiodev id=3Daudio1,driver=3Dnone \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x2 \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ diff --git a/tests/qemuxml2argvdata/input-linux.xml b/tests/qemuxml2argvdat= a/input-linux.xml index c0702676c1..389ba789a6 100644 --- a/tests/qemuxml2argvdata/input-linux.xml +++ b/tests/qemuxml2argvdata/input-linux.xml @@ -22,7 +22,7 @@
- + --=20 2.32.0