* [PATCH v2] input-linux: Add option to not grab a device upon guest startup
@ 2024-03-22 3:43 Justinien Bouron
2024-03-22 5:36 ` Markus Armbruster
2024-04-02 16:18 ` Justinien Bouron
0 siblings, 2 replies; 6+ messages in thread
From: Justinien Bouron @ 2024-03-22 3:43 UTC (permalink / raw)
To: Eric Blake, Markus Armbruster, Paolo Bonzini,
Daniel P. Berrangé, Eduardo Habkost, Gerd Hoffmann,
Marc-André Lureau
Cc: Justinien Bouron, qemu-devel
Depending on your use-case, it might be inconvenient to have qemu grab
the input device from the host immediately upon starting the guest.
Added a new bool option to input-linux: grab-on-startup. If true, the
device is grabbed as soon as the guest is started, otherwise it is not
grabbed until the toggle combination is entered. To avoid breaking
existing setups, the default value of grab-on-startup is true, i.e. same
behaviour as before this change.
Signed-off-by: Justinien Bouron <justinien.bouron@gmail.com>
---
Changes since v1:
- Revised commit message.
- Revised grab-on-startup description in qapi/qom.json to comply with
conventions.
qapi/qom.json | 14 +++++++++++++-
ui/input-linux.c | 20 +++++++++++++++++++-
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/qapi/qom.json b/qapi/qom.json
index baae3a183f..4bcffd265c 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -508,13 +508,25 @@
# @grab-toggle: the key or key combination that toggles device grab
# (default: ctrl-ctrl)
#
+# @grab-on-startup: if true, grab the device immediately upon starting
+# the guest. Otherwise, don't grab the device until the
+# combination is entered. This does not influence other devices
+# even if grab_all is true, i.e. in the unlikely scenario where
+# device1 has grab_all=true + grab-on-startup=true and device2 has
+# grab-on-startup=false, only device1 is grabbed on startup, then,
+# once the grab combination is entered, grabbing is toggled off
+# for both devices (because device1 enforces the grab_all
+# property) until the combination is entered again at which point
+# both devices will be grabbed. (default: true).
+#
# Since: 2.6
##
{ 'struct': 'InputLinuxProperties',
'data': { 'evdev': 'str',
'*grab_all': 'bool',
'*repeat': 'bool',
- '*grab-toggle': 'GrabToggleKeys' } }
+ '*grab-toggle': 'GrabToggleKeys',
+ '*grab-on-startup': 'bool'} }
##
# @EventLoopBaseProperties:
diff --git a/ui/input-linux.c b/ui/input-linux.c
index e572a2e905..68b5c6d485 100644
--- a/ui/input-linux.c
+++ b/ui/input-linux.c
@@ -44,6 +44,7 @@ struct InputLinux {
bool grab_request;
bool grab_active;
bool grab_all;
+ bool grab_on_startup;
bool keydown[KEY_CNT];
int keycount;
int wheel;
@@ -400,7 +401,7 @@ static void input_linux_complete(UserCreatable *uc, Error **errp)
if (il->keycount) {
/* delay grab until all keys are released */
il->grab_request = true;
- } else {
+ } else if (il->grab_on_startup) {
input_linux_toggle_grab(il);
}
QTAILQ_INSERT_TAIL(&inputs, il, next);
@@ -491,6 +492,19 @@ static void input_linux_set_grab_toggle(Object *obj, int value,
il->grab_toggle = value;
}
+static bool input_linux_get_grab_on_startup(Object *obj, Error **errp)
+{
+ InputLinux *il = INPUT_LINUX(obj);
+ return il->grab_on_startup;
+}
+
+static void input_linux_set_grab_on_startup(Object *obj, bool value,
+ Error **errp)
+{
+ InputLinux *il = INPUT_LINUX(obj);
+ il->grab_on_startup = value;
+}
+
static void input_linux_instance_init(Object *obj)
{
}
@@ -498,6 +512,7 @@ static void input_linux_instance_init(Object *obj)
static void input_linux_class_init(ObjectClass *oc, void *data)
{
UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
+ ObjectProperty *grab_on_startup_prop;
ucc->complete = input_linux_complete;
@@ -514,6 +529,9 @@ static void input_linux_class_init(ObjectClass *oc, void *data)
&GrabToggleKeys_lookup,
input_linux_get_grab_toggle,
input_linux_set_grab_toggle);
+ grab_on_startup_prop = object_class_property_add_bool(oc, "grab-on-startup",
+ input_linux_get_grab_on_startup, input_linux_set_grab_on_startup);
+ object_property_set_default_bool(grab_on_startup_prop, true);
}
static const TypeInfo input_linux_info = {
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v2] input-linux: Add option to not grab a device upon guest startup
2024-03-22 3:43 [PATCH v2] input-linux: Add option to not grab a device upon guest startup Justinien Bouron
@ 2024-03-22 5:36 ` Markus Armbruster
2024-04-03 5:30 ` Markus Armbruster
2024-04-02 16:18 ` Justinien Bouron
1 sibling, 1 reply; 6+ messages in thread
From: Markus Armbruster @ 2024-03-22 5:36 UTC (permalink / raw)
To: Justinien Bouron
Cc: Eric Blake, Paolo Bonzini, Daniel P. Berrangé,
Eduardo Habkost, Gerd Hoffmann, Marc-André Lureau,
qemu-devel
Justinien Bouron <justinien.bouron@gmail.com> writes:
> Depending on your use-case, it might be inconvenient to have qemu grab
> the input device from the host immediately upon starting the guest.
>
> Added a new bool option to input-linux: grab-on-startup. If true, the
> device is grabbed as soon as the guest is started, otherwise it is not
> grabbed until the toggle combination is entered. To avoid breaking
> existing setups, the default value of grab-on-startup is true, i.e. same
> behaviour as before this change.
>
> Signed-off-by: Justinien Bouron <justinien.bouron@gmail.com>
QAPI schema
Acked-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] input-linux: Add option to not grab a device upon guest startup
2024-03-22 5:36 ` Markus Armbruster
@ 2024-04-03 5:30 ` Markus Armbruster
2024-04-03 5:55 ` Justinien Bouron
0 siblings, 1 reply; 6+ messages in thread
From: Markus Armbruster @ 2024-04-03 5:30 UTC (permalink / raw)
To: Justinien Bouron
Cc: Eric Blake, Paolo Bonzini, Daniel P. Berrangé,
Eduardo Habkost, Gerd Hoffmann, Marc-André Lureau,
qemu-devel
Markus Armbruster <armbru@redhat.com> writes:
> Justinien Bouron <justinien.bouron@gmail.com> writes:
>
>> Depending on your use-case, it might be inconvenient to have qemu grab
>> the input device from the host immediately upon starting the guest.
>>
>> Added a new bool option to input-linux: grab-on-startup. If true, the
>> device is grabbed as soon as the guest is started, otherwise it is not
>> grabbed until the toggle combination is entered. To avoid breaking
>> existing setups, the default value of grab-on-startup is true, i.e. same
>> behaviour as before this change.
>>
>> Signed-off-by: Justinien Bouron <justinien.bouron@gmail.com>
>
> QAPI schema
> Acked-by: Markus Armbruster <armbru@redhat.com>
Missed one little thing: the doc comment needs a (since 9.1).
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] input-linux: Add option to not grab a device upon guest startup
2024-04-03 5:30 ` Markus Armbruster
@ 2024-04-03 5:55 ` Justinien Bouron
0 siblings, 0 replies; 6+ messages in thread
From: Justinien Bouron @ 2024-04-03 5:55 UTC (permalink / raw)
To: armbru
Cc: berrange, eblake, eduardo, justinien.bouron, kraxel,
marcandre.lureau, pbonzini, qemu-devel
> Missed one little thing: the doc comment needs a (since 9.1).
Thanks for the input, I just submitted a v3 with the missing "(since 9.1)":
https://patchew.org/QEMU/20240403055002.890760-1-justinien.bouron@gmail.com/
Regards,
Justinien Bouron
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] input-linux: Add option to not grab a device upon guest startup
2024-03-22 3:43 [PATCH v2] input-linux: Add option to not grab a device upon guest startup Justinien Bouron
2024-03-22 5:36 ` Markus Armbruster
@ 2024-04-02 16:18 ` Justinien Bouron
2024-04-03 5:30 ` Markus Armbruster
1 sibling, 1 reply; 6+ messages in thread
From: Justinien Bouron @ 2024-04-02 16:18 UTC (permalink / raw)
To: justinien.bouron
Cc: armbru, berrange, eblake, eduardo, kraxel, marcandre.lureau,
pbonzini, qemu-devel
Just a ping to make sure this patch hasn't been lost in the noise.
The relevant patchew page is
https://patchew.org/QEMU/20240322034311.2980970-1-justinien.bouron@gmail.com/.
Any chance to get this merged before the next release?
Regards,
Justinien
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-04-03 5:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-22 3:43 [PATCH v2] input-linux: Add option to not grab a device upon guest startup Justinien Bouron
2024-03-22 5:36 ` Markus Armbruster
2024-04-03 5:30 ` Markus Armbruster
2024-04-03 5:55 ` Justinien Bouron
2024-04-02 16:18 ` Justinien Bouron
2024-04-03 5:30 ` Markus Armbruster
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).