Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-c誰得cocoaqtpythonrubywindowsphpgameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwitterdombtronvb.nettestarduinodirectxpreviewerゲームエンジン



最近のWikiの更新 (Recent Changes)



サイドバー (Side Bar)

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


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
2. patch -u < bhyve_qemu_ext_key_event_msg_fbsd130r.patch
3. cd /usr/src/usr.sbin/bhyve
4. make
5. make install

If you use the FreeBSD 12.1/2-RELEASE, please replace the "fbsd130r" of the above No.2 to the "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
2. patch -u < bhyve_kbdlayout_option_fbsd130r.patch
3. sh bhyve_kbdlayout_layoutfile.shar
4. cd /usr/src/usr.sbin/bhyve
5. make
6. make install

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

Second, please apply the patch to

7. cd /usr/src/share
8. patch -u < bhyve_kbdlayout_vmrunsh_fbsd130r.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

  * 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.) (
  * 2021/01/24
     - Initial Version as an archive file for


I'm currently posting on FreeBSD bugzilla to have the patches on this page merge into the bhyve src-tree of FreeBSD.
As a result, <Patch 1> has been merged into the latest basesystem. (Thanks to all the members of the FreeBSD / bhyve core team for their cooperation!)
Patch 2 is under review as of May 5, 2021.

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

Release Files

FilenameGrößeZeitAnzahl der Downloads
bhyve_keyboard_layout_patch_20210102.tgz22.05 k2021-05-05 13:54:3812
bhyve_keyboard_layout_patch_20210505.tgz22.67 k2021-05-05 13:54:062


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

Recent Commits

Rev.ZeitAutorNachricht RSS
cc1686d32021-05-05 13:42:00Koine Yuusuke(koinec)Update information for FreeBSD 13.0-RELEASE & patch fixes.
64183a612021-05-03 23:00:42Koine Yuusuke(koinec)* Change keyboard layout specification option to "-K" (up...
0fd314b52021-05-03 22:57:47Koine Yuusuke(koinec)* Update for FreeBSD 13.0-RELEASE.(Along with this, the p...
e5fa1dd32021-05-03 22:45:35Koine Yuusuke(koinec)* Update for FreeBSD 13.0-RELEASE.(Along with this, the p...
b74a2a2e2021-05-03 22:32:34Koine Yuusuke(koinec)* Update for FreeBSD 13.0-RELASE.(Along with this, the pa...
741ffcc82021-01-24 19:51:56Koine Yuusuke(koinec)Fix bugs.
6ef7697d2021-01-24 19:49:31Koine Yuusuke(koinec)Put keyboard layout setting file generation tools from Fr...
bd77d34f2021-01-24 19:43:03Koine Yuusuke(koinec)Put Keyboar Layout file to git repository.
e74b13452021-01-24 13:25:37Koine Yuusuke(koinec)Create readme.txt.
a52e6fbb2021-01-02 13:42:09Koine Yuusuke(koinec)kbdlayout: add patch for FreeBSD 12.2-RELEASE kbdlayout: ...