ãœãªã¥ãŒã·ã§ã³ïŒææ°ã®Linuxãã£ã¹ããªãã¥ãŒã·ã§ã³ãããã€ãã£ããKVMä»®æ³åãã¯ãããžãŒãWindows 2003ãããã³ä»¥äžã§èª¬æããèšå®ã
FreeBSDçšã®KVMã³ã³ããã®æ§æã«é¢ããå ¥éèšäºãåç §ããŠãã ããã
ã²ã¹ãOSã®éžæ
Windows XPã¯Linux KVMã§ã¯äžå®å®ã§ãã äž»ãªãšã©ãŒã¯ãcsrs.exeããã»ã¹ã«ããããã»ããµã®100ïŒ ã®æ¶è²»ïŒRDPã»ãã·ã§ã³ã®çµäºãŸã§ïŒãšãHAL.DLLã®IRQL_NOT_LESS_OR_EQUALã³ãŒãã«ããBSODã§ãã å®å®ããåäœãéæã§ããå Žåã¯ãæŽæ°ããã°ã©ã ã®èªåã€ã³ã¹ããŒã«ãç¡å¹ã«ããŠãã ããïŒ ç§ãã¡ã®çµéšã§ã¯ãWinXPãKVMã®äžã§åäœããããã«ããããã¯åé¡ã®äž»èŠãªåå ã«ãªããŸããã
Windows 7ã¯æ£åžžã«åäœããŸãããProxmoxã«ãŠã³ã¿ãŒã«ãããšãåäœã«ã¯3ã®ã¬ãã€ã以äžã®RAMãå¿ èŠã§ãã
æè¯ã®ãªãã·ã§ã³ã¯ãWindows 2003 R2ã®32ãããçã§ãã
- 確å®ã«åäœããŸãã virtioã䜿çšãããšã
- XPãšã®äºææ§ã®åé¡ã¯ãããŸããïŒå€èŠ³ãåãã«ããããšãã§ããŸãïŒ
- 800ã¡ã¬ãã€ãæªæºã®RAMã䜿çšããŸãã
4ã®ã¬ãã€ãã®ã¡ã¢ãªïŒPAEãªãïŒã®äžéã¯ãçºçãããã¹ãŠã®åé¡ã«å¯ŸããŠååã§ããã
æ å ±æäŸã®ç®çã§ãRuTrackerã§å ¬éãããŠãããã¹ãŠã®ãã£ã¹ããªãã¥ãŒã·ã§ã³ãé©ããŠããŸãã
æåã®èµ·åãšvirtio
#!/bin/sh VM_ID="10" MACBASE="00:16:3e:ff:ff" HDA="vm_${VM_ID}.img" HDB="temp.img" HDC="w2k3_r2_ent_rus_x86/ru_win_srv_2003_r2_enterprise_with_sp2_vl_cd1_X13-46484.iso" HDD="virtio-win-0.1-52.iso" sudo kvm \ -enable-kvm \ -boot "menu=on,order=d" \ -m 1024M \ -balloon virtio \ -name "kvm_${VM_ID}" \ -drive "file=$HDA,index=0,media=disk,cache=writeback" \ -drive "file=$HDB,index=1,media=disk,cache=writeback,if=virtio" \ -drive "file=$HDC,index=2,media=cdrom,cache=writeback,readonly" \ -drive "file=$HDD,index=3,media=cdrom,cache=writeback,readonly" \ -net "nic,model=virtio,macaddr=${MACBASE}:${VM_ID}" \ -net "tap,ifname=tap${VM_ID},script=no,downscript=no" \ -vnc "0.0.0.0:${VM_ID}"
-vnc ...ãªãã·ã§ã³ã¯ãGUIã®ãªãââãµãŒããŒã§ã®ã¿æå³ããããŸãã ããã©ã«ãã§ã¯ãKVMã¯SDLãä»ããŠãŠã£ã³ããŠãéããŸãã ã©ã¡ãã®å ŽåããCtrl + Alt + Shift + 1ããã³Ctrl + Alt + Shift + 2ã䜿çšããŠãã²ã¹ããšãŠã£ã³ããŠå ã®ç®¡çã³ã³ãœãŒã«ãåãæ¿ããŸãã
ã
-net nic,model=virtio,...
ã
-net nic,model=virtio,...
ã¯ãVMå ã«äžæãªWindowsã¿ã€ãã®ãããã¯ãŒã¯ã«ãŒããäœæããŸããããã«å¯ŸããŠãããŒããŠã§ã¢ã»ããã¢ãããŠã£ã¶ãŒãããã©ã€ããŒã®éžæãæ±ããŸãã ãã¢ã® "
-net tap,...
"ãã©ã¡ãŒã¿ãŒã¯ãVMãšã®éä¿¡çšã«ãã¹ãOSã«ãããã¯ãŒã¯ã€ã³ã¿ãŒãã§ã€ã¹ãäœæããŸãã IPã¢ãã¬ã¹ã®å²ãåœãŠãDHCPã®æ§æãããã³ProxyARPãNATããŸãã¯Bridgeãä»ããå€éšãžã®ã¢ã¯ã»ã¹ã¯ãWindowsãšçŽæ¥é¢ä¿ããªããããããã§ã¯èæ ®ããŸããã
ãã®æ®µéã§æãéèŠãªããšãã€ãŸã è»èŒªã«ã€ããŠã
HDCã¯ãWindowsãã£ã¹ããªãã¥ãŒã·ã§ã³ãå«ãISOã€ã¡ãŒãžã§ãã ãã¡ã€ã«åã¯ãåã®ã»ã¯ã·ã§ã³ã®ãã¬ã³ãããååŸãããŸãã ãããããVMå ã§ãã·ã¹ãã ã®æåã®ããŒããçºçããŸãïŒ "
-boot order=d
"ïŒã
HDDã¯ãvirtioãã©ã€ããŒãåããISOã€ã¡ãŒãžã§ãã alt.fedoraproject.org/pub/alt/virtio-win/latest/images/binããããŠã³ããŒãããŸã
HDAã¯ãã·ã¹ãã ãã€ã³ã¹ããŒã«ããã空ã®ãã£ã¹ã¯ã€ã¡ãŒãžã§ãã ã³ãã³ãã
kvm-img create -f qcow2 vm_10.img 50G
ãã«ãã£ãŠäœæãã
kvm-img create -f qcow2 vm_10.img 50G
ã
HDBã¯ãã
kvm-img create -f qcow2 temp.img 1G
ãã§äœæããã空ã®ãã£ã¹ã¯ã€ã¡ãŒãžã§ãäžæãªçš®é¡ã®Windowsããã€ã¹ã衚瀺ããããšã®ã¿ãç®çãšããŠããããã©ã€ããŒãå¿ èŠã§ãã äžæãã£ã¹ã¯ã®virtioãã©ã€ããŒãã·ã¹ãã ã«ã€ã³ã¹ããŒã«ãããšãIDEããvirtioã·ã¹ãã ãã£ã¹ã¯ã«åãæ¿ãããŸãã
ã·ã¹ãã ãšãã©ã€ããŒã®ã€ã³ã¹ããŒã«ãå®å šã«å®äºããåŸãstartã³ãã³ãã§ãã-bootããšæåã®è¡ãé€ãã-driveãã®ãã¹ãŠã®è¡ãåé€ããå¿ èŠããããŸãã äžæãã£ã¹ã¯ãšISOã€ã¡ãŒãžã¯å¿ èŠãããŸããïŒè¿œå ãããã
if=virtio
ãã«æ³šæããŠãã ããïŒïŒïŒ
kvm ... -drive "file=$HDA,index=0,media=disk,cache=writeback,if=virtio" ...
virtioããããã¯ãŒã¯æ§æãªãã·ã§ã³ãããã³kvmã³ãã³ãã©ã€ã³ãªãã·ã§ã³ã®å©ç¹ã«ã€ããŠã¯ã habrahabr.ru / post / 167099ãåç §ããŠãã ããã
æšå¥šWindowsèšå®
æåã«ãããã©ã«ãã§ã¯ãWindowsã¯BSODã§å®å šãªã¡ã¢ãªãã³ããäœæããŸãã æè¯ã®å Žåãããã«ããåèµ·åãå€§å¹ ã«é ããªããŸãã ææªã®å Žåãå®å šã«ãã³ã°ã¢ããããŸãã
第äºã«ãèªåæŽæ°ã¯ããã©ã«ãã§æå¹ã«ãªã£ãŠãããèªåæŽæ°ã®1ã€ãKVMã®äžã§äžå®å®ã«ãªãå¯èœæ§ããããŸãã
ãããã£ãŠãæåã®å Žæã§ã€ã³ã¹ããŒã«ãå®äºããåŸïŒãã©ã€ããŒãã€ã³ã¹ããŒã«ããåã«ïŒïŒã³ã³ãããŒã«ããã«=>ã·ã¹ãã ã«ç§»åããããšããå§ãããŸãã
- èªåæŽæ°ïŒç¡å¹ã«ãã
- 詳现èšå®=>ãšã©ãŒã¬ããŒã=>ç¡å¹å
- 詳现=>ããŠã³ããŒããšåŸ©å =>èšå®=>ã·ã¹ãã ã¯ã©ãã·ã¥=>ãããã°æ å ±ã®æžã蟌ã¿=>å°ããªã¡ã¢ãªãã³ãïŒ64KBïŒ
TCP / IPèšå®ã¯ãªãã·ã§ã³ã§ãããããã©ãŒãã³ã¹ããããã«åäžããŸãã ä»®æ³ç°å¢ã§ã¯ãç©çãããã¯ãŒã¯ãä»ããŠéä¿¡ãããšãã«èæ ®ããå¿ èŠã®ããåé¡ã¯ãããŸããã
説æïŒ www.linux-kvm.org/page/WindowsGuestDrivers/kvmnet/registry
æºåãã§ããŠããREGãã¡ã€ã«ïŒ svn1.sytes.net/linuxkvm/tune-guest-tcpip.reg
ãã®åŸããã£ã¹ã¯ïŒvirt-storïŒããã³ãããã¯ãŒã¯ã«ãŒãïŒvirt-netïŒã®ãã©ã€ããŒã®ã€ã³ã¹ããŒã«ã«é²ãããšãã§ããŸãã ããããã€ã³ã¹ããŒã«ãããšããRed Hat VirtIO SCSI ControllerãããRed Hat VirtIO SCSI Disk Deviceããããã³ãRed Hat VirtIO Ethernet AdapterããããŒããŠã§ã¢ãããŒãžã£ãŒã«è¡šç€ºãããŸãã
ãã«ãŒãã³ã°
åŸæ¥ã®ã¢ãããŒãã§ã¯ãä»®æ³ãã·ã³ïŒVMïŒã®éå§æã«ãç¹å®ã®ãµã€ãºïŒããšãã°ã512ã¡ã¬ãã€ãïŒã®RAMãããã¯ãçŽã¡ã«å²ãåœãŠãŸãã ãã®æ¬ ç¹ã¯ãVMã¡ã¢ãªã«æªäœ¿çšã®ã¹ããŒã¹ãããç¬éã«ãããä»ã®VMããã¹ãã·ã¹ãã ã§ã¯èŠéãããå¯èœæ§ããããŸãã
ã¡ã¢ãªããŒã«ãªã³ã°ã¯ãïŒaïŒå¿ èŠã«å¿ããŠVMã«ãã¹ãRAMãå²ãåœãŠãïŒbïŒäœ¿çšå¯èœã«ãªã£ãæªäœ¿çšã®ãããã¯ãè¿ãããã®ã¡ã«ããºã ã§ãã ãã®ãããã§ãæ倧蚱容ããªã¥ãŒã ãäžåºŠã«äœ¿çšããªãéãããã¹ãã·ã¹ãã ã®ç©çRAMã®éãè¶ ããä»®æ³RAMã®åèšéã§ããå€ãã®VMãåæã«èµ·åããããšãå¯èœã«ãªããŸãã ããã«ããããã¹ãã·ã¹ãã ã®ã¡ã¢ãªã¯ãéåžžã®ããã»ã¹éãšåæ§ã«æè»ã«VMéã§åæ£ãããŸãã
ç©çéãè¶ ããä»®æ³ãªãœãŒã¹ã®äœæã¯ãå€ãã®ãã¹ãã£ã³ã°äŒç€Ÿã«æãããŠããããªãŒããŒã³ããããããã³ããªãŒããŒã»ã«ãªã³ã°ããšããçšèªã§ç€ºãããŸãã
ãããã³ã°ã«ã¯ã2ã€ã®ãœãããŠã§ã¢ã³ã³ããŒãã³ãã®å調åäœãå¿ èŠã§ãã
- ãã¹ãã·ã¹ãã ã®MOM ïŒã¡ã¢ãªãªãŒããŒã³ããããããŒãžã£ãŒïŒãVMããã®èŠæ±ã«åºã¥ããŠVMã®RAMã®éãå€æŽããŸãã
- ä»®æ³PCIã³ã³ãããŒã©ãŒãä»ããŠMOMãšå¯Ÿè©±ããã²ã¹ãOSã®VMMïŒä»®æ³ã¡ã¢ãªãããŒãžã£ãŒïŒã
KVMã®ææ°ããŒãžã§ã³ã®MOMã¯èªåçã«æå¹ã«ãªããå€ãããŒãžã§ã³ã§ã¯ã³ãã³ãã©ã€ã³ã§ãkvm ... -balloon virtioãã䜿çšããŠæå¹ã«ããããèŠæ±ãããŸããã
Windowsã¯ãMOMããŒããŠã§ã¢ãããŒãžã£ãŒïŒdevmgmt.mscïŒãšéä¿¡ããããã®ã²ã¹ãããã€ã¹ããæªç¥ã®çš®é¡ã®PCIæšæºRAMã³ã³ãããŒã©ãŒããšããŠèªèããŸãã virt-storãvirt-netãšã¯ç°ãªãããã®ãã©ã€ããŒã¯èªåçã«ã€ã³ã¹ããŒã«ããããã«ã¯æäŸãããŸããã 代ããã«ãããã€ã¹ã®ããããã£ã«ç§»åããããã©ã€ããŒãã¿ãã§æŽæ°ãéžæããVirtIO CDã®balloon.infãžã®ãã¹ãæåã§æå®ããŸãïŒ proof ïŒã ãã®åŸãããã€ã¹ã®ååããVirtIO Balloon Driverãã«å€æŽãããŸãã
ACPI
ããã©ã«ãã§ã¯ãWindows 2003ã§ã¯ããã°ã€ã³ãã¹ã¯ãŒããå ¥åãã[ã¹ã¿ãŒã] => [ã·ã£ããããŠã³]ãéžæããã¡ã¢ãå ¥åããŠ[OK]ãã¯ãªãã¯ãããšããå¯äžã®æ¹æ³ã§èªåèªèº«ããªãã«ããããšãã§ããŸãã ãã¡ããããã®ã¢ãããŒãã¯VDSãã¡ãŒã ã§ã¯åãå ¥ããããŸããã KVMïŒããã³QEMUïŒã¯ACPIããšãã¥ã¬ãŒãã§ããŸãã ãsystem_powerdownãã³ãã³ãã¯ç©çã³ã³ãã¥ãŒã¿ãŒã®é»æºãã¿ã³ãæŒãã®ãšäŒŒãŠããŸãããWindowsã¯ãããç¡èŠããŸãã 次ã®.regãã¡ã€ã«ã§åŠçãããŸãã
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system] "ShutdownWithoutLogon"=dword:00000001 "DisableCAD"=dword:00000001 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows] "ShutdownWarningDialogTimeout"=dword:00000003
å®è¡ããæºåãã§ããŸããïŒ svn1.sytes.net/linuxkvm/win-acpi-kvm.reg
詳现ãªèª¬æãå«ãå ã®ãœãŒã¹ïŒ umgum.com/acpi-windows2003-shutdown
ãã£ãã·ã³ã°
ã²ã¹ããã£ã¹ã¯ã®ã€ã¡ãŒãžãVDSãã¡ãŒã ã«ãã¡ã€ã«ãšããŠä¿åãããŠããå Žåãã²ã¹ããã¡ã€ã«ã®ãã£ãã·ã¥ã¯2åã«ãªãå¯èœæ§ããããŸããã²ã¹ãOSã¯ãä»®æ³ãã£ã¹ã¯ã«ã¢ã¯ã»ã¹ãããšãã«æåã«ã²ã¹ãOSããã£ãã·ã¥ãã次ã«ç©çãã£ã¹ã¯ã«ã¢ã¯ã»ã¹ãããšãã«ãã¡ãŒã OSããã£ãã·ã¥ããŸãã
åèšã§ã 3ã€ã®ã¡ã€ã³ã¢ãŒããå¯èœã§ãã
- none-ãã¹ãã·ã¹ãã ã¯ãèªã¿åããŸãã¯æžã蟌ã¿ã®ããã«ã€ã¡ãŒãžãã¡ã€ã«ããã£ãã·ã¥ããŸãã
- ã©ã€ãããã¯-ããã«æžã蟌ã¿ãèªã¿åãã¯ãã£ãã·ã¥ãããŸã
- ã©ã€ãã¹ã«ãŒ-èªã¿åããšæžã蟌ã¿ã¯ãã£ãã·ã¥ãããŸã
ç°ãªãããŒãžã§ã³ã®qemu / kvmããã³ç°ãªããªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã§ã¯ãããã©ã«ãã§ç°ãªãã¢ãŒãã䜿çšã§ããŸãã ããšãã°ãããŒãžã§ã³1.2ããåã®Qemuã¯ã©ã€ãã¹ã«ãŒã䜿çšãã1.2ã¯ã©ã€ãããã¯ã«åãæ¿ããProxmoxã§ã¯cache = noneãéžæãããŠããŸãã
äŸå€ãªããWebäžã®æ å ±æºã¯ãã©ã€ãã¹ã«ãŒãæãäœéãªãã®ãšããŠäœ¿çšããªãããšãæšå¥šããŠããŸãã 䞻芳çãªè©äŸ¡ã«ãããšãã©ã€ãããã¯ã¯WindowsãæèŒããVMã«æé©ã§ãããLinuxããã³FreeBSDãæèŒããVMã«ã¯æé©ã§ã¯ãããŸããã
ãããã¯ãŒã¯ããã³ã°ãã
KVMãšã©ãŒãæããã«åŒãèµ·ããå¯äžã®æ·±å»ãªåé¡ã¯ããã©ãã£ãã¯ãå€ãå Žåã®ã²ã¹ããããã¯ãŒã¯ã®ããªãŒãºã§ãïŒ bugs.centos.org/view.php?id=5526 ïŒãšã©ãŒã®èª¬æèªäœã®ä»ã«ãä»ã®ãã°ãã©ãã«ãŒãžã®éèŠãªãªã³ã¯ããããŸãïŒã
è°è«ã®åå è ã«ãã£ãŠææ¡ãããæšå¥šäºé ïŒqemu-kvmãšã«ãŒãã«ã®æŽæ°ãvhost-netã䜿çšããã³ãã³ãã©ã€ã³ãã©ã¡ãŒã¿ãŒã®å€æŽïŒã¯ãæ®å¿µãªãããŸã 解決ã§ããŠããŸããã
ããªãŒãºãããã³ã«ãVNCçµç±ã§VMã³ã³ãœãŒã«ã«ç§»åãããããã¯ãŒã¯ã€ã³ã¿ãŒãã§ã€ã¹ããªã»ããããå¿ èŠããããŸãããã®åŸããã©ãã£ãã¯ã¯åã³æ£åžžã«ãªãå§ããŸãã
PingFailed_ResetNic.au3ãã¡ã€ã«ãäœæããã¿ã¹ã¯ãããŒãžã£ãŒã«ãã£ãŠæ°åããšã«åŒã³åºãå ŽåãAutoItã䜿çšããŠWindowsã§ãã®ã¢ã¯ã·ã§ã³ãèªååã§ããŸãã
#include «EventLog.au3» Local $PingHost = "192.168.0.1" Local $Interface = "LAN" Ping($PingHost, 250) If @error = 0 Then Exit Local $hEventLog = _EventLog__Open("", "RestartNicOnPingFailure") Local $aEmpty[1] = [0] _EventLog__Report($hEventLog, 2, 0, 1, "", "Restart NIC " & Interface & " on failed ping to " & PingHost, $aEmpty) _EventLog__Close($hEventLog) RunWait("netsh interface set interface " & $Interface & " DISABLED", "", @SW_HIDE) RunWait("netsh interface set interface " & $Interface & " ENABLED", "", @SW_HIDE)
CMD.EXEã®ãªãã·ã§ã³ïŒ rickosborne.org/blog/2007/02/stupid-windows-tricks-restart-network-adapter-when-it-hangs
ãã®ãããªã解決çãã¯å¿ ãããæºè¶³ã§ãããšã¯éããŸããããå Žåã«ãã£ãŠã¯ããã€ãã¹ã®åœ±é¿ã蚱容å¯èœãªæå°å€ã«æžããã ãã§ååãªå Žåããããããææ¬çãªå¯Ÿçã®ä»£ããã«ä¿®æ£ãçŸããã®ãåŸ ã€ããšãã§ããŸãã