*KVM(+QEMU) and SPICE [#yb80eeff]

RIGHT:更新日 &lastmod();

**インストール [#jf725862]

CentOS6xをインストール時

CentOS6.3をDisktopでインストール時以下のような警告が出、インストールされない

''警告''
 Disk sda contains BIOS RAID metadata,but is not part of any recognized 
 BIOS RAID sets. lgnoring disk sda.

そこでインストール時どのモードでインストールするか選択する画面で「Tab」キーを押し、以下のオプションを入れる

Install Option 

 umlinux ・・・・ boot: linux nodmraid
                 ^^^^^^^^^^^^^^^^^^^^^ この部分

***KVMのインストール [#ydd61f4b]


 # yum -y install qemu-kvm libvirt python-virtinst bridge-utils
 # modprobe kvm
 # modprobe kvm_intel


 # lsmod | grep kvm
 kvm_intel              52890  0
 kvm                   314739  1 kvm_intel

 /etc/rc.d/init.d/libvirtd start
 libvirtd デーモンを起動中:                                 [  OK  ]

/etc/hostsにホスト名の登録がないと

 2012-12-06 06:29:51.611+0000: 9243: warning : virGetHostname:2171 : 
 getaddrinfo failed for 'CentOS6x': 名前またはサービスが不明です

のようなエラーが出る

自動起動登録

 # chkconfig libvirtd on


***ネットワークの設定 [#se849e30]

ゲストOSがブリッジ接続できるようにブリッジネットワークを構成


 # cd /etc/sysconfig/network-scripts
 # cp ifcfg-eth0 ifcfg-br0

''ifcfg-br0''

 DEVICE="br0"  <==変更
 BOOTPROTO=none
 NM_CONTROLLED="yes"
 ONBOOT=yes
 TYPE="Bridge" <=変更
 # UUID="b4c80987-9bb2-4e01-b4a6-fe813aaad5e1" <=削除
 IPADDR=10.99.99.64
 PREFIX=8
 GATEWAY=10.0.0.1
 DNS1=192.244.75.1
 DEFROUTE=yes
 IPV4_FAILURE_FATAL=yes
 IPV6INIT=no
 NAME="System eth0"
 HWADDR=30:85:A9:94:85:82


''ifcfg-eth0''

 DEVICE="eth0"
 BOOTPROTO=none
 NM_CONTROLLED="yes"
 ONBOOT=yes
 TYPE="Ethernet"
 # UUID="b4c80987-9bb2-4e01-b4a6-fe813aaad5e1"  <=削除
 IPADDR=10.99.99.64
 PREFIX=8
 GATEWAY=10.0.0.1
 DNS1=192.244.75.1
 DEFROUTE=yes
 IPV4_FAILURE_FATAL=yes
 IPV6INIT=no
 NAME="System eth0"
 HWADDR=30:85:A9:94:85:82
 BRIDGE=br0   <=追加

 # /etc/rc.d/init.d/network restart 
 インターフェース br0 を終了中:                             [  OK  ]
 インターフェース eth0 を終了中:                            [  OK  ]
 ループバックインターフェースを終了中                       [  OK  ]
 ループバックインターフェイスを呼び込み中                   [  OK  ]
 インターフェース eth0 を活性化中:                          [  OK  ]
 インターフェース br0 を活性化中:                           [  OK  ]

''確認''

 # /sbin/ifconfig
 br0       Link encap:Ethernet  HWaddr 30:85:A9:94:85:82
           inet addr:10.99.99.64  Bcast:10.255.255.255  Mask:255.0.0.0
           inet6 addr: fe80::3285:a9ff:fe94:8582/64 Scope:Link
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:142 errors:0 dropped:0 overruns:0 frame:0
           TX packets:57 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:0
           RX bytes:7957 (7.7 KiB)  TX bytes:8461 (8.2 KiB)
 
 eth0      Link encap:Ethernet  HWaddr 30:85:A9:94:85:82
           inet6 addr: fe80::3285:a9ff:fe94:8582/64 Scope:Link
           UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
           RX packets:21684 errors:0 dropped:0 overruns:0 frame:0
           TX packets:9430 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1000
           RX bytes:21480575 (20.4 MiB)  TX bytes:774531 (756.3 KiB)
           Interrupt:34 Base address:0xe000
 
 lo        Link encap:Local Loopback
           inet addr:127.0.0.1  Mask:255.0.0.0
           inet6 addr: ::1/128 Scope:Host
           UP LOOPBACK RUNNING  MTU:16436  Metric:1
           RX packets:12 errors:0 dropped:0 overruns:0 frame:0
           TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:0
           RX bytes:2408 (2.3 KiB)  TX bytes:2408 (2.3 KiB)
 
 virbr0    Link encap:Ethernet  HWaddr 52:54:00:A5:9F:C3
           inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:27 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:0
           RX bytes:0 (0.0 b)  TX bytes:5153 (5.0 KiB)





**仮想マシン作成 [#h31b1601]

仮想マシンのイメージの保管場所(ストレージプール)の作成

 $ cd ~okada
 $ mkdir -p Images

ISOイメージを入れるフォルダの作成

 $ mkdir ~okada/ISO
 
この中イメージを入れる


***ネットワーク仮想化のオーバーヘッドを減らすことができる vhost-net を有効 [#re7f207f]

 # modprobe vhost_net
 # lsmod | grep vhost
 vhost_net              31320  0
 macvtap                 9948  1 vhost_net
 tun                    17127  2 vhost_net


***仮想マシンインストール [#u3636786]

GUIから仮想マシンを作成するツールをインストール

 # yum install virt-manager

-X-WindowまたはVNCから仮想マシンマネージャを起動

&ref("./kvm1.png");

-事前にインストールするHDDイメージを作成

&ref("./kvm7.png");

&ref("./kvm8.png");

-OSのインストール

&ref("./kvm2.png");

&ref("./kvm3.png");

&ref("./kvm4.png");

-「管理しているストレージ・・・・」で先の作成ストレージをImgesフォルダから選択

&ref("./kvm5.png");

&ref("./kvm6.png");


後は普通にWindowsをインストール

コマンドでOSを起動

 # virsh start WinXP
 ドメイン WinXP が起動されました


 ''Shutdown''

 # virsh shutdown WinXP

**Spice サーバのインストール [#i5dce532]

 #  yum install spice-server 
 

***環境を編集 [#ad646b0c]

 # virsh edit WinXP
 
 <domain type='kvm'>
   <name>WinXP</name>
   <uuid>89f8ac4e-e9cb-f42e-7e9d-97e1a836b4ce</uuid>
   <memory unit='KiB'>1536000</memory>
   <currentMemory unit='KiB'>1536000</currentMemory>
   <vcpu placement='static'>2</vcpu>
   <os>
     <type arch='x86_64' machine='rhel6.3.0'>hvm</type>
     <boot dev='hd'/>
   </os>
   <features>
     <acpi/>
     <apic/>
     <pae/>
   </features>
   <clock offset='localtime'>
     <timer name='rtc' tickpolicy='catchup'/>
   </clock>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
   <devices>
     <emulator>/usr/libexec/qemu-kvm</emulator>
     <disk type='file' device='disk'>
       <driver name='qemu' type='raw' cache='none'/>
       <source file='/var/lib/libvirt/images/WinXP.img'/>
       <target dev='hda' bus='ide'/>
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
     </disk>
     <disk type='file' device='cdrom'>
       <driver name='qemu' type='raw'/>
       <source file='/home/okada/ISO/ja_windows_xp_professional_with_service_pack_3_x86_dvd_x14-80464.iso'/>
       <target dev='hdc' bus='ide'/>
       <readonly/>
       <address type='drive' controller='0' bus='1' target='0' unit='0'/>
     </disk>
     <controller type='usb' index='0'>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
     </controller>
     <controller type='ide' index='0'>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
     </controller>
     <interface type='bridge'>
       <mac address='52:54:00:92:49:16'/>
       <source bridge='br0'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
     </interface>
     <serial type='pty'>
       <target port='0'/>
     </serial>
     <console type='pty'>
       <target type='serial' port='0'/>
     </console>
     <input type='tablet' bus='usb'/>
     <input type='mouse' bus='ps2'/>
     <graphics type='spice' port='5930' autoport='no' listen='0.0.0.0'>
       <listen type='address' address='0.0.0.0'/>
     </graphics>
     <sound model='ich6'>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
     </sound>
     <video>
       <model type='qxl' vram='32768' heads='1'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
     </video>
     <memballoon model='virtio'>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
     </memballoon>
   </devices>
 </domain>


以下を追加を追加する。追加されるとコメントは消える

      <target type='serial' port='0'/>
    </console>
    <input type='tablet' bus='usb'/>
<!-- Edit by JE2ISM -->
    <graphics type='spice' port='5930' autoport='no' listen='0.0.0.0'/>
    <video>
    <model type='qxl' vram='32768' heads='1'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
<!-- End JE2ISM -->
    <input type='mouse' bus='ps2'/>


video,graphics が追加されるので、以前からあるものを削除

以下を削除
    <video>
      <model type='vga' vram='9216' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>


    <graphics type='vnc' port='-1' autoport='yes'/>

''接続ポート指定''

以下のポート変更で複数接続OK

<graphics type='spice' port='5930' autoport='no' listen='0.0.0.0'>
                             ^^^^

''Sound関係''

Windows XP は以下の変更でSoundDriverがOKになった。Windows7(32bit)は変更なし

<sound model='ich6'>

を以下に変更

<sound model='ac97'>


**SPICE CLIENT [#af7305c4]

http://www.spice-space.org/download.html

から

-Old Windows client - spice-client-win32-0.6.3.zip
-Windows libraries - these are runtime dependencies of the old SPICE client, wspice-x86_20110308.zip

をDownload

spice-client-win32-0.6.3.zipを解凍後、「spice.exe」をwspice-x86_20110308.zipを解凍した中のlibフォルダにコピーし、そこでspice.exeを起動

***Client ドライバ [#p6b2367c]

http://www.spice-space.org/download.html

spice-guest-tools-0.2.exe


以下は上のものと同じなようなので、上記のものをインストール
http://www.spice-space.org/download/binaries/

qxl ドライバ (Videoドライバ)
virtio-serial ドライバ


**参考 [#v229377d]

-http://www.server-world.info/query?os=CentOS_6&p=kvm&f=1

-http://webcache.googleusercontent.com/search?q=cache:k9cpxnKezgwJ:toyao.net/xoops/modules/wordpress/archives/4929+kvm+windows+xp+audio&cd=1&hl=ja&ct=clnk&lr=lang_ja&inlang=ja
-http://gihyo.jp/admin/serial/01/linux_kvm/0002?page=2

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS