====== FreeBSD 12でQEMUゲストエージェントを使う ====== ===== 試した環境 ===== * FreeBSD 12.2-RELEASE * Proxmox VE 6.3-2 ===== 手順 ===== FreeBSD用のQEMUゲストエージェントの[[https://github.com/aborche/qemu-guest-agent|GitHub]]に書いてある通りに進めるだけ。 ==== ビルド ==== 現状、Portsは存在しないようなので、zipを取ってきて展開する。 (2021-05-02 追記) 2021年3月16日に[[https://www.freshports.org/emulators/qemu-guest-agent/|emulators/qemu-gueat-agent]]としてports化された。 $ fetch https://github.com/aborche/qemu-guest-agent/archive/master.zip $ tar -xvf master.zip PortsのQEMUのMakefileにパッチを充てる。上記のゲストエージェントは、portsに対するパッチ集となっており、portsを間借りする形で作られるようだ。 $ cd /usr/ports/emulators/qemu # echo '--- Makefile.orig 2018-10-27 17:23:47.760934000 +0300 +++ Makefile 2018-10-27 17:10:31.140104000 +0300 @@ -23,7 +23,7 @@ USES?= cpe gmake pkgconfig bison perl5 python:2.7,build tar:bzip2 USE_PERL5= build MAKE_ENV+= BSD_MAKE="${MAKE}" V=1 -.if !defined(PKGNAMESUFFIX) || ${PKGNAMESUFFIX} != "-utils" +.if !defined(PKGNAMESUFFIX) || (${PKGNAMESUFFIX} != "-utils" && ${PKGNAMESUFFIX} != "-guest-agent") USE_XORG= pixman USE_GNOME+= cairo glib20 libxml2 ONLY_FOR_ARCHS= amd64 i386 powerpc powerpc64' | patch ゲストエージェントの展開場所に戻ってmakeする。 $ cd /path/to/qemu-guest-agent # make && make install (略) ===> Installing for qemu-guest-agent-5.0.1 ===> Checking if qemu-guest-agent is already installed ===> Registering installation for qemu-guest-agent-5.0.1 Installing qemu-guest-agent-5.0.1... ======================================================= Modify your `/etc/rc.conf` by adding these settings qemu_guest_agent_enable="YES" qemu_guest_agent_flags="-d -v -l /var/log/qemu-ga.log" and run # service qemu-guest-agent start For detailed help use `qemu-ga -h` ======================================================= ===> SECURITY REPORT: This port has installed the following files which may act as network servers and may therefore pose a remote security risk to the system. /usr/local/bin/qemu-ga If there are vulnerabilities in these programs there may be a security risk to the system. FreeBSD makes no guarantee about the security of ports included in the Ports Collection. Please type 'make deinstall' to deinstall the port if this is a concern. For more information, and contact details about the security status of this software, see the following webpage: http://wiki.qemu.org/Main_Page インストールはPackagesの作法に則った形で行われるっぽい。 ==== 設定 ==== 動作にはvirtio_consoleが必要なので設定する。 # echo 'virtio_console_load="YES"' >> /boot/loader.conf # kldload virtio_console カーネルモジュールを読み込むと/dev/vtcon/が生えてくるはずだが、もしなければ、VMホスト側のQEMUエージェントタイプがvirtioになっているか確認する。 {{ :freebsd:pve_check_qemu_agent_type.png |}} 続いてゲストエージェントの設定&実行。 以下の2行を/etc/rc.confに追加。 qemu_guest_agent_enable="YES" qemu_guest_agent_flags="-d -v -l /var/log/qemu-ga.log" からのゲストエージェントを起動。 # service qemu-guest-agent start Proxmox VEの仮想マシンのサマリーで、VMのIPアドレスが表示されればゲストエージェントが問題なく動いていると分かる。 {{ :freebsd:pve_qemu_guest_agent_status.png |}} 素のKVM環境ならvirshとか使えばいいんじゃないかな? ===== 参考サイト ===== * [[https://github.com/aborche/qemu-guest-agent|GitHub - aborche/qemu-guest-agent: QEMU Guest Agent patched for FreeBSD]]