yishen 发表于 2013-7-11 08:57:28

Ubuntu12.10 下搭建基于KVM-QEMU的虚拟机环境(十一)

上一个介绍主要讲了如何virtio驱动对于虚拟机性能改善的重要性以及如何安装针对磁盘的虚拟驱动,接下来我们继续安装其他几个虚拟驱动:QXL虚拟显卡、虚拟网卡、虚拟串口和改善显示和鼠标体验的vdagent程序。在继续之前我们先还是有针对性的修改定义虚拟机的XML定义文件,参阅红色字体部分:
<domain type='kvm'>   <name>XP_VM2</name>   <uuid>91f15b08-e115-4016-a522-b550ff593af8</uuid>   <memory>1024000</memory>   <currentMemory>1024000</currentMemory><vcpu>1</vcpu><os>    <type arch='x86_64'machine='pc'>hvm</type>    <bootdev='cdrom'/>    <boot dev='hd'/>    <bootmenuenable='yes'/></os><features>    <acpi/>    <apic/>    <pae/></features><cpu>    <topology sockets='1'cores='1' threads='1'/></cpu><clockoffset='localtime'/>   <on_poweroff>destroy</on_poweroff>   <on_reboot>restart</on_reboot>   <on_crash>restart</on_crash><devices>    <emulator>/usr/bin/qemu-system-x86_64</emulator>    <disk type='file'device='disk'>      <driver name='qemu'type='raw'/>      <sourcefile='/opt/vm/xpvm_virtio/xp_c.img' lock='exclusive'/>      <target dev='hda'bus='virtio'/>    </disk>    <disk type='file'device='disk'>      <driver name='qemu'type='qcow2'/>      <sourcefile='/opt/vm/xpvm_virtio/xp_d.img' lock='exclusive'/>      <target dev='hdb'bus='virtio'/>    </disk>    <disk type='file'device='cdrom'>      <sourcefile='/opt/vm/windows_xp_professional_sp3_x86.iso'/>      <targetdev='hdc'/>      <readonly/>    </disk>    <disk type='file'device='floppy'>      <sourcefile='/opt/vm/virtio-WinXP-x86.vfd'/>      <target dev='fda'bus='fdc'/>      <readonly/>    </disk>    <interfacetype='bridge'>      <macaddress='52:54:00:7b:a8:d8'/>      <source bridge='virbr0'/>      <targetdev='vnet1'/>      <modeltype='virtio'/>    </interface>    <channeltype='spicevmc'>             <target type='virtio'name='com.redhat.spice.0'/>                   <aliasname='virserial-channel1'/>   </channel>    <input type='tablet'bus='usb'/>    <graphicstype='spice' port='4000' autoport='no' listen='0.0.0.0'>      <listentype='address' address='0.0.0.0'/>      <agent_mousemode='off'/>    </graphics>    <soundmodel='ac97'>      <address type='pci'domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>    </sound>    <video>      <model type='qxl'vram='65536' heads='1'/>    </video>    <memballoonmodel='virtio'>             <alias name='balloon0'/>    </memballoon></devices><qemu:commandline>   <qemu:argvalue="-cpu"/>   <qemu:argvalue="qemu64,model=3"/></qemu:commandline></domain>
挑出来就是下面一段:<channeltype='spicevmc'>       <targettype='virtio' name='com.redhat.spice.0'/>       <aliasname='virserial-channel1'/> </channel>有关spicevmc的说明如下(http://www.libvirt.org/formatdomain.html):Paravirtualized SPICE channel. The domainmust also have a SPICE server as a graphicsdevice, at which point the host piggy-backs messages across the main channel. The target element must be present, withattributetype='virtio'; an optional attribute namecontrols how the guest will have access to the channel, and defaults to name='com.redhat.spice.0'. The optional address element can tie thechannel to a particular type='virtio-serial'controller.简单的说是一个虚拟串口通道,用于优化主机和虚拟机之间的一些通信。 在修改了XML后,需要通过重新执行下面的命令来让其生效:sudo virsh undefined XP_VM2sudo virsh define xp.xml 然后再启动虚拟机:sudo virsh start XP_VM2启动完成后当然还是通过spice连接上去: spicec –h 127.0.0.1 –p 4000:启动完后你会发现在虚拟机的设备管理器上会出现一些未知设备,那是因为在更新了XML定义后系统发现了一些硬件上的改动。为了让系统识别这些设备,我们需要为其装上驱动,下载这些驱动的路径是:http://www.spice-space.org/download/windows/spice-guest-tools/spice-guest-tools-0.59.exe这个exe里面就包含了完整的虚拟显卡驱动、虚拟网卡驱动和虚拟串口驱动,而且针对windows各个版本的都有(也包括32位和64位)。 下载以后执行这个EXE程序:中间会有些警告信息,那是因为没有数字证书,没关系,选择安装就是。安装完以后再看一下设备管理器,发现那些原来带黄色问号的设备纷纷被识别出来了,原来它们就是虚拟网卡、虚拟串口和虚拟显卡,参考下图: 同时在服务列表中可以看到增加了一个叫RHEV Spice Agent的服务: 这个服务就是所谓的vdagent,它主要起到下面几个作用:1. 在虚拟机和本地系统间拷贝、粘贴文本;2. 在全屏模式下让虚拟机自适应本地系统的分辨率;3. 改善在虚拟机里面的鼠标使用体验等。这个vdagent运行的LOG缺省在 C:\windows\temp 目录下,如果有什么问题可以去看看。

zhufeng518 发表于 2013-7-12 18:24:41

吃饭与ml是第一生产力。

青野 发表于 2013-7-14 23:12:58

我的id是假冒的,大家不要相信我是骗子。

q987654 发表于 2013-7-17 21:43:06

商女不知亡国恨、妓女不懂婚外情。

云中漫步 发表于 2013-7-20 02:24:42

爱她,就请为她做无痛人流手术!

小时? 发表于 2013-7-22 08:14:16

老天,你让夏天和冬天同房了吧?生出这鬼天气!

shilang 发表于 2013-7-24 04:01:38

美女未抱身先走,常使色狼泪满襟。。。。。。
页: [1]
查看完整版本: Ubuntu12.10 下搭建基于KVM-QEMU的虚拟机环境(十一)