wiki:TipAndDoc/VM/KVM

Version 32 (modified by mitty, 12 years ago) (diff)

--

KVM

  • KVM自体にはIntel-VT or AMD-V が必須
    egrep '(vmx|svm)' --color=always /proc/cpuinfo
    
  • QEMUはVT/AMD-vが無くても動く(ただし非常に遅い)

Client

Windows Guest

drivers

  • デバイスマネージャ

block device

  • virtio-win-1.1.16.vfdを用いてVirtIO diskでセットアップ後、virtio-win-0.1-30.isoによってドライバを更新するとBSODを出して起動しなくなる。
    • OSセットアップ直後
    • ドライバ更新
    • BSOD

virbr0

  • libvirtdによって自動で作られる「default」のNAT
    • ps aux | grep dns
      nobody    2684  0.0  0.0  21264   792 ?        S    Feb07   0:01 dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/libvirt/network/default.pid --conf-file=  --listen-address 192.168.122.1 --except-interface lo --dhcp-range 192.168.122.2,192.168.122.254 --dhcp-lease-max=253
      
    • lease file => /var/lib/misc/dnsmasq.leases

iptables

  • sudo iptables-save
    # Generated by iptables-save v1.4.8 on Thu Feb 16 10:31:29 2012
    *nat
    :PREROUTING ACCEPT [743892:129452770]
    :POSTROUTING ACCEPT [1179:112796]
    :OUTPUT ACCEPT [1215:115607]
    -A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -p tcp -j MASQUERADE --to-ports 1024-65535 
    -A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -p udp -j MASQUERADE --to-ports 1024-65535 
    -A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -j MASQUERADE 
    COMMIT
    # Completed on Thu Feb 16 10:31:29 2012
    # Generated by iptables-save v1.4.8 on Thu Feb 16 10:31:29 2012
    *filter
    :INPUT ACCEPT [4957020:3457557240]
    :FORWARD ACCEPT [0:0]
    :OUTPUT ACCEPT [3323525:4327643495]
    -A INPUT -i virbr0 -p udp -m udp --dport 53 -j ACCEPT 
    -A INPUT -i virbr0 -p tcp -m tcp --dport 53 -j ACCEPT 
    -A INPUT -i virbr0 -p udp -m udp --dport 67 -j ACCEPT 
    -A INPUT -i virbr0 -p tcp -m tcp --dport 67 -j ACCEPT 
    -A FORWARD -d 192.168.122.0/24 -o virbr0 -m state --state RELATED,ESTABLISHED -j ACCEPT 
    -A FORWARD -s 192.168.122.0/24 -i virbr0 -j ACCEPT 
    -A FORWARD -i virbr0 -o virbr0 -j ACCEPT 
    -A FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable 
    -A FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable 
    COMMIT
    # Completed on Thu Feb 16 10:31:29 2012
    

port forwarding

Live Migration

kvm-spice

  • Ubuntu 12.04でqemu-kvm-spiceをインストールすると、デフォルトのemulatorが/usr/bin/kvm-spiceになって以下の様な問題が起きる
  • kern.logにAppArmorからDENIEDとエラーが出る
    Oct 13 22:45:08 HOSTNAME kernel: [507466.445098] type=1400 audit(1350135908.372:69): apparmor="DENIED" operation="open" parent=1 profile="libvirt-52d08545-a490-c890-654a-260caf35d27d" name="/proc/17685/auxv" pid=17685 comm="kvm-spice" requested_mask="r" denied_mask="r" fsuid=104 ouid=104
    
  • Video modelをcirrus以外にすると、画面が表示されなくなる(真っ黒のまま)

start/shutdown log for VM

  • Ubuntu 12.04
  • /var/log/libvirt/qemu 以下に、VMごとのログが残される
    -rw------- 1 root root  3940 Oct  8 00:24 quantal.log
    -rw------- 1 root root 12394 Oct 13 23:13 test.log
    
  • /var/log/libvirt/qemu/xp-vm01.log
    2012-10-28 12:46:55.328+0000: starting up
    LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin QEMU_AUDIO_DRV=none /usr/bin/kvm -S -M pc-1.0 -enable-kvm -m 1024 -smp 1,sockets=1,cores=1,threads=1 -name xp-vm01 -uuid XXXXXXXX-YYYY-ZZZZ-WWWW-VVVVVVVVVVVV -nodefconfig -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/xp-vm01.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime -no-shutdown -drive file=/var/lib/libvirt/images/xp-vm01.img,if=none,id=drive-ide0-0-0,format=raw -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=2 -drive file=/home/mitty/virtio-win-0.1-30.iso,if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,bootindex=1 -netdev tap,fd=16,id=hostnet0 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:a8:d0:1d,bus=pci.0,addr=0x3 -usb -device usb-tablet,id=input0 -vnc 127.0.0.1:1 -vga vmware -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
    vmsvga_value_read: Bad register 2b
    vmsvga_value_read: Bad register 2c
    qemu: terminating on signal 15 from pid 1803
    2012-10-28 12:51:56.141+0000: shutting down
    

autoshutdown

  • /var/log/libvirt/shutdownlog.log で確認できる
    libvirt: libvirt-bin: entering pre-stop at Fri Oct 19 23:22:33 JST 2012
    libvirt: libvirt-bin: attempting clean shutdown of xp-vm02 at Fri Oct 19 23:22:33 JST 2012
    libvirt: destroying xp-vm02
    libvirt: libvirt-bin: exiting pre-stop at Fri Oct 19 23:23:06 JST 2012
    libvirt: libvirt-bin: entering pre-stop at Fri Oct 26 23:37:35 JST 2012
    libvirt: libvirt-bin: exiting pre-stop at Fri Oct 26 23:37:35 JST 2012
    libvirt: libvirt-bin: entering pre-stop at Sun Oct 28 21:45:17 JST 2012
    libvirt: libvirt-bin: attempting clean shutdown of xp-vm02 at Sun Oct 28 21:45:17 JST 2012
    libvirt: libvirt-bin: attempting clean shutdown of xp-vm01 at Sun Oct 28 21:45:17 JST 2012
    libvirt: libvirt-bin: exiting pre-stop at Sun Oct 28 21:45:45 JST 2012
    
  • /etc/init/libvirt-bin.conf で制御されている模様

Attachments (17)

Download all attachments as: .zip