* [Qemu-devel] [RFC PATCH 0/2] Support to change VNC keyboard layout dynamically @ 2014-11-29 10:39 arei.gonglei 2014-11-29 10:39 ` [Qemu-devel] [RFC PATCH 1/2] vnc: introduce vnc_display_kbd_layout function arei.gonglei ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: arei.gonglei @ 2014-11-29 10:39 UTC (permalink / raw) To: qemu-devel; +Cc: Gonglei, weidong.huang, kraxel, peter.huangpeng From: Gonglei <arei.gonglei@huawei.com> A bonus of this feature is that supporting different people (in different countries) using defferent keyboard to connect the same guest but not need to configure command line or libivrt xml file then restart guest. Using the existing qmp command: -> { "execute": "change", "arguments": { "device": "vnc", "target": "keymap", "arg": "de" } } <- { "return": {} } I knew sdl and curses are using keyboard layout, but I don't know whether they both need to support this feature and add some new qmp command for them? If you have some ideas, please let me know. Thanks! NOTE: The patch series based on Gerd's vnc-next tree: https://www.kraxel.org/cgit/qemu/log/?h=rebase/ui-vnc-next Cc: Gerd Hoffmann <kraxel@redhat.com> Gonglei (2): vnc: introduce vnc_display_kbd_layout function vnc: add change keyboard layout interface include/ui/console.h | 5 +++++ qapi-schema.json | 8 +++++--- qmp.c | 17 +++++++++++++++++ ui/vnc.c | 21 +++++++++++++++++++++ 4 files changed, 48 insertions(+), 3 deletions(-) -- 1.7.12.4 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [RFC PATCH 1/2] vnc: introduce vnc_display_kbd_layout function 2014-11-29 10:39 [Qemu-devel] [RFC PATCH 0/2] Support to change VNC keyboard layout dynamically arei.gonglei @ 2014-11-29 10:39 ` arei.gonglei 2014-11-29 10:39 ` [Qemu-devel] [RFC PATCH 2/2] vnc: add change keyboard layout interface arei.gonglei 2014-12-01 16:37 ` [Qemu-devel] [RFC PATCH 0/2] Support to change VNC keyboard layout dynamically Eric Blake 2 siblings, 0 replies; 6+ messages in thread From: arei.gonglei @ 2014-11-29 10:39 UTC (permalink / raw) To: qemu-devel; +Cc: Gonglei, weidong.huang, kraxel, peter.huangpeng From: Gonglei <arei.gonglei@huawei.com> In order to support changing vnc keyboard layout dynamically. Signed-off-by: Gonglei <arei.gonglei@huawei.com> --- include/ui/console.h | 5 +++++ ui/vnc.c | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/ui/console.h b/include/ui/console.h index 887ed91..4645dc3 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -333,6 +333,7 @@ void vnc_display_add_client(const char *id, int csock, bool skipauth); char *vnc_display_local_addr(const char *id); #ifdef CONFIG_VNC int vnc_display_password(const char *id, const char *password); +int vnc_display_kbd_layout(const char *id, const char *kbd_layout); int vnc_display_pw_expire(const char *id, time_t expires); QemuOpts *vnc_parse_func(const char *str); int vnc_init_func(QemuOpts *opts, void *opaque); @@ -341,6 +342,10 @@ static inline int vnc_display_password(const char *id, const char *password) { return -ENODEV; } +int vnc_display_kbd_layout(const char *id, const char *kbd_layout) +{ + return -ENODEV; +} static inline int vnc_display_pw_expire(const char *id, time_t expires) { return -ENODEV; diff --git a/ui/vnc.c b/ui/vnc.c index 8d189e7..5a2c60d 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3090,6 +3090,27 @@ int vnc_display_password(const char *id, const char *password) return 0; } +int vnc_display_kbd_layout(const char *id, const char *kbd_layout) +{ + VncDisplay *vs = vnc_display_find(id); + kbd_layout_t *k = NULL; + + if (!vs) { + return -EINVAL; + } + + k = init_keyboard_layout(name2keysym, kbd_layout); + if (!k) { + return -EINVAL; + } + + trace_vnc_key_map_init(kbd_layout); + g_free(vs->kbd_layout); + vs->kbd_layout = k; + + return 0; +} + int vnc_display_pw_expire(const char *id, time_t expires) { VncDisplay *vs = vnc_display_find(id); -- 1.7.12.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [RFC PATCH 2/2] vnc: add change keyboard layout interface 2014-11-29 10:39 [Qemu-devel] [RFC PATCH 0/2] Support to change VNC keyboard layout dynamically arei.gonglei 2014-11-29 10:39 ` [Qemu-devel] [RFC PATCH 1/2] vnc: introduce vnc_display_kbd_layout function arei.gonglei @ 2014-11-29 10:39 ` arei.gonglei 2014-12-01 16:40 ` Eric Blake 2014-12-01 16:37 ` [Qemu-devel] [RFC PATCH 0/2] Support to change VNC keyboard layout dynamically Eric Blake 2 siblings, 1 reply; 6+ messages in thread From: arei.gonglei @ 2014-11-29 10:39 UTC (permalink / raw) To: qemu-devel; +Cc: Gonglei, weidong.huang, kraxel, peter.huangpeng From: Gonglei <arei.gonglei@huawei.com> Example QMP command of Change VNC keyboard layout: -> { "execute": "change", "arguments": { "device": "vnc", "target": "keymap", "arg": "de" } } <- { "return": {} } Signed-off-by: Gonglei <arei.gonglei@huawei.com> --- qapi-schema.json | 8 +++++--- qmp.c | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 9ffdcf8..8c02a9f 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1552,13 +1552,15 @@ # # @target: If @device is a block device, then this is the new filename. # If @device is 'vnc', then if the value 'password' selects the vnc -# change password command. Otherwise, this specifies a new server URI +# change password command, if the value 'keymap'selects the vnc change +# keyboard layout command. Otherwise, this specifies a new server URI # address to listen to for VNC connections. # # @arg: If @device is a block device, then this is an optional format to open # the device with. -# If @device is 'vnc' and @target is 'password', this is the new VNC -# password to set. If this argument is an empty string, then no future +# If @device is 'vnc' and if @target is 'password', this is the new VNC +# password to set; if @target is 'keymap', this is the new VNC keyboard +# layout to set. If this argument is an empty string, then no future # logins will be allowed. # # Returns: Nothing on success. diff --git a/qmp.c b/qmp.c index 3fda973..044cd34 100644 --- a/qmp.c +++ b/qmp.c @@ -366,6 +366,13 @@ void qmp_change_vnc_password(const char *password, Error **errp) } } +static void qmp_change_vnc_kbd_layout(const char *kbd_layout, Error **errp) +{ + if (vnc_display_kbd_layout(NULL, kbd_layout) < 0) { + error_setg(errp, "keyboard layout '%s' set failed", kbd_layout); + } +} + static void qmp_change_vnc_listen(const char *target, Error **errp) { QemuOptsList *olist = qemu_find_opts("vnc"); @@ -393,6 +400,12 @@ static void qmp_change_vnc(const char *target, bool has_arg, const char *arg, } else { qmp_change_vnc_password(arg, errp); } + } else if (strcmp(target, "keymap") == 0) { + if (!has_arg) { + error_set(errp, QERR_MISSING_PARAMETER, "keymap"); + } else { + qmp_change_vnc_kbd_layout(arg, errp); + } } else { qmp_change_vnc_listen(target, errp); } @@ -402,6 +415,10 @@ void qmp_change_vnc_password(const char *password, Error **errp) { error_set(errp, QERR_FEATURE_DISABLED, "vnc"); } +static void qmp_change_vnc_kbd_layout(const char *kbd_layout, Error **errp) +{ + error_set(errp, QERR_FEATURE_DISABLED, "vnc"); +} static void qmp_change_vnc(const char *target, bool has_arg, const char *arg, Error **errp) { -- 1.7.12.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 2/2] vnc: add change keyboard layout interface 2014-11-29 10:39 ` [Qemu-devel] [RFC PATCH 2/2] vnc: add change keyboard layout interface arei.gonglei @ 2014-12-01 16:40 ` Eric Blake 2014-12-02 1:48 ` Gonglei 0 siblings, 1 reply; 6+ messages in thread From: Eric Blake @ 2014-12-01 16:40 UTC (permalink / raw) To: arei.gonglei, qemu-devel; +Cc: weidong.huang, kraxel, peter.huangpeng [-- Attachment #1: Type: text/plain, Size: 2309 bytes --] On 11/29/2014 03:39 AM, arei.gonglei@huawei.com wrote: > From: Gonglei <arei.gonglei@huawei.com> > > Example QMP command of Change VNC keyboard layout: > > -> { "execute": "change", > "arguments": { "device": "vnc", "target": "keymap", > "arg": "de" } } > <- { "return": {} } As I said in the cover letter, we should NOT be adding stuff to the broken 'change' command, but should instead add a new command. > > Signed-off-by: Gonglei <arei.gonglei@huawei.com> > --- > qapi-schema.json | 8 +++++--- > qmp.c | 17 +++++++++++++++++ > 2 files changed, 22 insertions(+), 3 deletions(-) > > diff --git a/qapi-schema.json b/qapi-schema.json > index 9ffdcf8..8c02a9f 100644 > --- a/qapi-schema.json > +++ b/qapi-schema.json > @@ -1552,13 +1552,15 @@ > # > # @target: If @device is a block device, then this is the new filename. > # If @device is 'vnc', then if the value 'password' selects the vnc > -# change password command. Otherwise, this specifies a new server URI > +# change password command, if the value 'keymap'selects the vnc change s/'keymap'selects/'keymap' selects/ > +# keyboard layout command. Otherwise, this specifies a new server URI > # address to listen to for VNC connections. > # > # @arg: If @device is a block device, then this is an optional format to open > # the device with. > -# If @device is 'vnc' and @target is 'password', this is the new VNC > -# password to set. If this argument is an empty string, then no future > +# If @device is 'vnc' and if @target is 'password', this is the new VNC > +# password to set; if @target is 'keymap', this is the new VNC keyboard > +# layout to set. If this argument is an empty string, then no future > # logins will be allowed. Not discoverable. As proposed, libvirt has no way of knowing if qemu is new enough to support this horrible hack. A new command has multiple benefits: it would be discoverable ('query-commands') and type-safe (none of this horrid overloading of special text values). -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 539 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 2/2] vnc: add change keyboard layout interface 2014-12-01 16:40 ` Eric Blake @ 2014-12-02 1:48 ` Gonglei 0 siblings, 0 replies; 6+ messages in thread From: Gonglei @ 2014-12-02 1:48 UTC (permalink / raw) To: Eric Blake Cc: Huangpeng (Peter), Huangweidong (C), qemu-devel@nongnu.org, kraxel@redhat.com On 2014/12/2 0:40, Eric Blake wrote: > On 11/29/2014 03:39 AM, arei.gonglei@huawei.com wrote: >> From: Gonglei <arei.gonglei@huawei.com> >> >> Example QMP command of Change VNC keyboard layout: >> >> -> { "execute": "change", >> "arguments": { "device": "vnc", "target": "keymap", >> "arg": "de" } } >> <- { "return": {} } > > As I said in the cover letter, we should NOT be adding stuff to the > broken 'change' command, but should instead add a new command. > OK. >> >> Signed-off-by: Gonglei <arei.gonglei@huawei.com> >> --- >> qapi-schema.json | 8 +++++--- >> qmp.c | 17 +++++++++++++++++ >> 2 files changed, 22 insertions(+), 3 deletions(-) >> >> diff --git a/qapi-schema.json b/qapi-schema.json >> index 9ffdcf8..8c02a9f 100644 >> --- a/qapi-schema.json >> +++ b/qapi-schema.json >> @@ -1552,13 +1552,15 @@ >> # >> # @target: If @device is a block device, then this is the new filename. >> # If @device is 'vnc', then if the value 'password' selects the vnc >> -# change password command. Otherwise, this specifies a new server URI >> +# change password command, if the value 'keymap'selects the vnc change > > s/'keymap'selects/'keymap' selects/ > >> +# keyboard layout command. Otherwise, this specifies a new server URI >> # address to listen to for VNC connections. >> # >> # @arg: If @device is a block device, then this is an optional format to open >> # the device with. >> -# If @device is 'vnc' and @target is 'password', this is the new VNC >> -# password to set. If this argument is an empty string, then no future >> +# If @device is 'vnc' and if @target is 'password', this is the new VNC >> +# password to set; if @target is 'keymap', this is the new VNC keyboard >> +# layout to set. If this argument is an empty string, then no future >> # logins will be allowed. > > Not discoverable. As proposed, libvirt has no way of knowing if qemu is > new enough to support this horrible hack. A new command has multiple > benefits: it would be discoverable ('query-commands') and type-safe > (none of this horrid overloading of special text values). > Great! Thank you so much for your comments, Eric. I will add a new QMP command for this. Regards, -Gonglei ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 0/2] Support to change VNC keyboard layout dynamically 2014-11-29 10:39 [Qemu-devel] [RFC PATCH 0/2] Support to change VNC keyboard layout dynamically arei.gonglei 2014-11-29 10:39 ` [Qemu-devel] [RFC PATCH 1/2] vnc: introduce vnc_display_kbd_layout function arei.gonglei 2014-11-29 10:39 ` [Qemu-devel] [RFC PATCH 2/2] vnc: add change keyboard layout interface arei.gonglei @ 2014-12-01 16:37 ` Eric Blake 2 siblings, 0 replies; 6+ messages in thread From: Eric Blake @ 2014-12-01 16:37 UTC (permalink / raw) To: arei.gonglei, qemu-devel; +Cc: weidong.huang, kraxel, peter.huangpeng [-- Attachment #1: Type: text/plain, Size: 863 bytes --] On 11/29/2014 03:39 AM, arei.gonglei@huawei.com wrote: > From: Gonglei <arei.gonglei@huawei.com> > > A bonus of this feature is that supporting different > people (in different countries) using defferent keyboard s/defferent/different/ > to connect the same guest but not need to configure > command line or libivrt xml file then restart guest. > > Using the existing qmp command: > > -> { "execute": "change", > "arguments": { "device": "vnc", "target": "keymap", > "arg": "de" } } > <- { "return": {} } Please add a new QMP command. The existing 'change' command is not type-safe and therefore difficult to introspect; we should not be adding more band-aids to it. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 539 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-12-02 1:49 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-11-29 10:39 [Qemu-devel] [RFC PATCH 0/2] Support to change VNC keyboard layout dynamically arei.gonglei 2014-11-29 10:39 ` [Qemu-devel] [RFC PATCH 1/2] vnc: introduce vnc_display_kbd_layout function arei.gonglei 2014-11-29 10:39 ` [Qemu-devel] [RFC PATCH 2/2] vnc: add change keyboard layout interface arei.gonglei 2014-12-01 16:40 ` Eric Blake 2014-12-02 1:48 ` Gonglei 2014-12-01 16:37 ` [Qemu-devel] [RFC PATCH 0/2] Support to change VNC keyboard layout dynamically Eric Blake
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).