1. 虚拟机配置
- <domain type='kvm' id='1'>
- <name>winxp</name>
- <uuid>883d614a-30e9-474d-b81e-c131e4a06249</uuid>
- <memory unit='KiB'>1048576</memory>
- <currentMemory unit='KiB'>1048576</currentMemory>
- <vcpu>2</vcpu>
- <cpu mode='host-passthrough'/>
- <os>
- <type arch='x86_64'>hvm</type>
- <boot dev='hd'/>
- </os>
- <!-- Enable Transparent Huge Page
- <memoryBacking>
- <hugepages/>
- </memoryBacking>
- -->
- <features>
- <acpi/>
- <apic/>
- <pae/>
- <hap/>
- </features>
- <clock offset='localtime'/>
- <on_poweroff>destroy</on_poweroff>
- <on_reboot>restart</on_reboot>
- <on_crash>restart</on_crash>
- <devices>
- <emulator>/usr/bin/qemu-kvm</emulator>
- <disk type='file' device='disk'>
- <driver name='qemu' type='qcow2' cache='none' io='native'/>
- <source file='/home/vm/winxp/winxp.img'/>
- <target dev='vda' bus='virtio'/>
- </disk>
- <disk type='file' device='cdrom'>
- <source file='/home/imgs/virtio-win-0.1-30.iso'/>
- <target dev='hdc' bus='ide'/>
- <readonly/>
- </disk>
- <interface type='bridge'>
-
- <source bridge='virbr0'/>
-
- <model type='virtio' />
- <driver name='vhost'/>
- </interface>
- <!-- USB tablet emulation will consume a considerable amount of CPU
- <input type='tablet' bus='usb'/>
- -->
- <input type='mouse' bus='ps2'/>
- <channel type='spicevmc'>
- <target type='virtio' name='com.redhat.spice.0'/>
- </channel>
- <graphics type='spice' port='5900' autoport='yes'>
- <mouse mode='server'/>
- </graphics>
- <video>
- <model type='qxl' vram='65536' heads='1'/>
- </video>
- <sound model='ac97'/>
- <!-- Ballooning is enabled by default
- <memballoon model='none'/>
- -->
- <channel type='pty'>
- <target type='virtio' name='arbitrary.virtio.serial.port.name'/>
- </channel>
- <memballoon model='virtio'/>
- </devices>
- </domain>
2. 因为使用了virtio的虚拟磁盘,所以在windows虚拟机安装的时候,需要提供驱动,否则xp的安装会报告找不到硬盘。
在安装windows的时候,需要用下面的代码把驱动盘放进去。
- <disk type='file' device='floppy'>
- <source file='/usr/share/images/virtio-win-1.1.16.vfd'/>
- <target dev='fda'/>
- </disk>
3. 系统安装完毕以后,因为网卡是用的半虚拟化的vhost virtio, 所以也需要专门安装驱动。在google上搜索virtio-win-0.1-30.iso,
也可以找到很多下载,比如:
http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/virtio-win-0.1-30.iso
把这个iso文件装入虚拟光驱就可以了:
- <disk type='file' device='cdrom'>
- <source file='/usr/share/images/virtio-win-0.1-30.iso'/>
- <target dev='hdc' bus='ide'/>
- <readonly/>
- </disk>
4. 客户机还需要安装spice的agent和相关驱动,。登陆到客户机,在spice的网站下载这些驱动:
该命令会在windows服务里面添加vdagent服务,并且默认是开机启动的。
重启虚拟机以后,就可以用spice的客户端连接虚拟机了,比如spicec,如果没有安装,可以用yum安装:
yum install spice-client
5. As for sound device, if it is es1370, then qemu will crash if spice client is disconnected. So ac97 is more preferred.
6. 虚拟磁盘选用的是qcow2, 有两个,一个是C, 一个是D, 并且在客户机系统第一次安装成功后,对C盘做了ROW快照。
创建瘦分配的qcow2:
qemu-img create -f qcow2 10G winxp.qcow2
做ROW快照:
qemu-img create -f qcow2 -b winxp.qcow2 winxp.snapshot.qcow2
阅读(2766) | 评论(0) | 转发(0) |