Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

最近の作業部屋活動履歴

2023-04-12
2022-05-19
2022-01-21

最近のWikiの更新 (Recent Changes)

2022-05-19

Wikiガイド(Guide)

サイドバー (Side Bar)

FreeBSD bhyve keyboard layout specified option patch & support QEMU extended keyevent message patch

Backgroud

When a guest OS is loaded using UEFI and connected with VNC, if the keyboard on the VNC client side is other than the US keyboard, some keys input may not be performed correctly.
For example, if you press the '@' key on a Japanese keyboard, the number '2' will be entered on the guest OS.
The cause is that the '@' key on the US keyboard is assigned to Shift + '2' keys.
In addition, there is a problem that keys that do not exist on the US keyboard cannot be entered. (example, Zenkaku-Hankaku key in the Japanese Keyboard)

In the current bhyve(13.x-RELEASE & 12.x-RELEASE), in the virtual PS2 keyboard driver, there is a conversion table that converts from the key entered from the VNC client side to the virtual keyboard scancode for the Guest OS.
However, since this conversion table is set for US keyboards, the above problem will occur if the client side is not a US keyboard.

Therefore, in order to solve this problem, the following two types of patches were created.

Patches Overview

<Patch 1> Support for QEMU Extended Key Event Message.
By applying a patch that supports QEMU Extended Key Event message to bhyve, this patch bypasses the conversion process to keyboard scancode by the conversion table and sends the Keycode on the VNC client side directly to the guest OS.
If you're using TigerVNC, this method can solve keyboard layout issues without any bhyve boot options or VNC client settings.
However, it has no effect when using VNC clients that do not support QEM messages, such as tightVNC and ssvnc.

<Patch 2> Append Keyboard Layout specified option.
This patch adds the ability to overwrite the keyboard scancode conversion table that is causing the problem from the settings for the US key board to the settings for the language you want to use.
In addition, the content of the setting (conversion table) to be overwritten is an external layout setting file for each language so that the language to be used can be set from the bhyve command option.
This method will work fine with VNC clients that do not support QEMU Extended Key Event Message, such as tightVNC.
However, it is necessary to specify options according to the keyboard layout of the client on the hypervisor side, and it is necessary to prepare an external configuration file that matches the keyboard layout of each language.
(For each keyboard layout available on the FreeBSD console, we have created a layout configuration file that allows you to use the minimum keys, such as alphabets and numbers.)

Patch 1 and 2 are independent. Therefore, it is possible to apply only one or both.

Usage <Patch 1> Support for QEMU Extended Key Event Message.

This patch can be used only by applying the patch according to the following procedure and then building and installing the bhyve command.
VNC clients can only be used with QEMU Extended Key Event Messages, (e.g. tigerVNC)
The patch is stored in the qemu_ext_keyevent_msg directory.

1. cd /usr/src/usr.sbin/bhyve
2. patch -u -p1 < bhyve_qemu_ext_key_event_msg_fbsd131r.patch
3. make
4. make install

If you use the FreeBSD 12.1/2/3-RELEASE, please replace the "fbsd131r" of the above No.2 to the "fbsd123r" or "fbsd122r" or "fbsd121r"


Usage <Patch 2> Append Keyboard Layout specified option.

First, please apply the patch to bhyve by following the steps below.
Then extract the keyboard layout settings files and then build and install it.

1. cd /usr/src/usr.sbin/bhyve
2. patch -u -p1 < bhyve_kbdlayout_option_fbsd131r.patch
3. cd /usr/src/usr.sbin
4. sh bhyve_kbdlayout_layoutfile.shar
5. cd /usr/src/usr.sbin/bhyve
6. make
7. make install

If you use the FreeBSD 12.1/2/3-RELEASE, please replace the "fbsd131r" of the above No.2 to the "fbsd123r" or "fbsd122r" or "fbsd121r".


Second, please apply the patch to vmrun.sh.

8. cd /usr/src/share
9. patch -u < bhyve_kbdlayout_vmrunsh_fbsd131r.patch
Finaly, if you use the bhyve command directly, specify the '-K layout' option for the bhyve command.
You can specify the "layout" in the file name stored in /usr/share/bhyve/kbdlayout dir.
If no '-K' option is specified, the US keyboard (default) is assumed to be selected.

Others, If you use the bhyve via the vm-bhyve package, specify the following lines for the Guest OS configure file.
bhyve_options="-K layout"

CAUTION for <Patch 2>

The layout specified option is changed to uppercase "-K", since the version of 2021/5/5.
Please note that if you are using an earlier patch, it will be INCOMPATIBLE!

Change Log

  * 2022/05/19
     - Add the patches for FreeBSD 13.1-RELEASE.
     - Remove the patches for FreeBSD 13-STABLE(20211223).
     - Fix install operation in this file.
  * 2022/01/21
     - Add to the README (this doc.) that these patches was merged into the FreeBSD-CURRENT source tree.
  * 2022/01/02
     - Add the patches for FreeBSD 12.3-RELEASE.
     - Add the patches for FreeBSD 13-STABLE(20211223).
  * 2021/05/05
     - Update for FreeBSD 13.0-RELEASE.(Along with this, the patch filename was changed)
         >> [Patch 1] & [Patch 2]

     - Change keyboard layout specification option to "-K" (uppercase K).
       (Because "-k" is used for other purposes in FreeBSD current's bhyve)
         >> [Patch 2] - for FreeBSD 13.0-RELEASE & 12.2-RELEASE

     - Fix the following issues on the FreeBSD review site.
         (Corrected the violation of man's notation rule by incorporating the content of the proposal
          on the review side.) (https://reviews.freebsd.org/D29473)
  * 2021/01/24
     - Initial Version as an archive file for osdn.net.

Note

These patches was merged into the FreeBSD-CURRENT source-tree on 2022/1/21.
I really appreciate everyone who cooperated.
THANK YOU VERY MUCH!!

The patches on this page will be updated irregularly until they are merged into the FreeBSD Release version.

Request for Cooperation (The remaining tasks)

Currently, the keyboard layout configuration file is generated from the FreeBSD console layout configuration file. (Excluding layout setting files for Japanese keyboards)
Therefore, there are the following problems.

  • There are no settings for keyboard-specific keys for each language, such as alphabets, number keys, Enter, Space, and Escape, which are not found in US keyboards.
  • The layout setting file has not been tested except for the Japanese keyboard.


Regarding the above, please add to the created layout setting file and cooperate with the test.
If the layout configuration file has been improved or tested, please report the results to the following FreeBSD bugzilla or koinec@users.osdn.me.

Release Files

FilenameTamañoTiempoDownload count
bhyve_keyboard_layout_patch_20220519.tgz24.65 k2022-05-19 21:13:2266
bhyve_keyboard_layout_patch_20220121.tgz24.53 k2022-05-19 21:13:00119
bhyve_keyboard_layout_patch_20210505.tgz22.67 k2022-01-21 21:11:2175
bhyve_keyboard_layout_patch_20210102.tgz22.05 k2021-05-05 13:54:3869

Repository

  • R/O
  • R/O (HTTP)
  • R/W (SSH)
  • R/W (HTTPS)
Fork

Recent Commits

Rev.TiempoAutorMensaje RSS
2ceab8f52023-04-12 21:56:41Koine Yuusuke(koinec)Add support for FreeBSD 12.4-RELEASE.
e1f832032022-05-19 21:03:56Koine Yuusuke(koinec)Fix install operation in the readme.txt.
09c7e3302022-05-19 20:55:14Koine Yuusuke(koinec)Append patch for FreeBSD 13.1-RELEASE. Remove patch for F...
ff980fe42022-01-21 21:05:27Koine Yuusuke(koinec)Add to the readme.txt that these patches was merged into ...
d87c74212022-01-02 13:32:09Koine Yuusuke(koinec)- Add support for FreeBSD 12.3-RELEASE. - Add support for...
540e494f2022-01-02 13:21:32Koine Yuusuke(koinec)Add for the patches for FreeBSD 13-statble (20211223).
3b4b39842022-01-02 10:14:34Koine Yuusuke(koinec)Add for the patches for FreeBSD 12.3-RELEASE.
50074a7c2021-05-30 20:04:05Koine Yuusuke(koinec)Correct "Key" in the delimiter line of the layout configu...
610f43b22021-05-30 14:54:40Koine Yuusuke(koinec)Correct "Create" in the comment section to "Created". (To...
cc1686d32021-05-05 13:42:00Koine Yuusuke(koinec)Update information for FreeBSD 13.0-RELEASE & patch fixes.