kvm virtualization
qcow2 イメージ
作成。
qemu-img create -f qcow2 image.qcow2 xxG
シュリンク。仮想マシンを止めて実行する。
mv image.qcow2 image.qcow2.bak
qemu-img convert -O qcow2 image.qcow2.bak image.qcow2
qemu-kvm コマンドのよく使うオプション
cdイメージから起動
-cdrom image.iso -boot d
cpuとメモリの指定
-smp 2 -m 2048
kvmでwindows10を使用する時、私の環境(Core i5 650)だと下記のように指定することで、cpu負荷が落ち着いた。
-cpu core2duo,+lahf_lm
その後、試行錯誤し、現在は下記の通り指定している。
-cpu host,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time
(仮想)ストレージの指定。準仮想化ドライバを利用すると、スループットが上がるらしい。 (Windows等で利用する場合は、仮想マシン上でドライバを入れる必要がある。)
-drive if=virtio,file=image.qcow2
ネットワークインターフェースの指定(従来方式)
-net nic,macaddr=xx:xx:xx:xx:xx:xx,model=virtio
-net tap,ifname=vnet0
vncコンソールとキーマップの指定。
-vnc 192.168.xx.xx:xx -k ja
コンソールのマウスカーソルの位置がずれるときは以下を指定 (WindowsではCPU負荷が高くなるらしい)
-usbdevice tablet
デーモンとして起動
-daemonize
物理デバイスのパススルー
example
boot ultra lite linux distribution microcore linux for network configure test
kvm -drive if=virtio,file=linux-microcore-6.4.img -netdev tap,id=tap0 -device e1000,netdev=tap0,mac=52:54:00:12:34:56