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

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

      在Ubuntu12.10下搭建基于KVM-QEMU的虚拟机环境(九)中我们用libvirt定义创建、启动和使用了基本的虚拟机过程。今天开始我们通过对XML的更多tag的改变来尝试更多新的功能。      今天要实验的是virtio 的功能,有关virtio的介绍参阅:http://www.linux-kvm.org/page/Virtio 和http://www.ibm.com/developerworks/cn/linux/l-virtio/采用virtio的目的是提高虚拟机的性能,KVM在I/O虚拟化方面,传统的方式是使用QEMU纯软件的方式来模拟I/O设备(模拟的网卡、磁盘、显卡等等),其效率并不非常高。在KVM中,可以在客户机中使用半虚拟化驱动(Paravirtualized Drivers,PV Drivers)来提高客户机的性能(特别是I/O性能)。目前,KVM中实现半虚拟化驱动的方式是采用了virtio这个Linux上的设备驱动标准框架。在未采用virtio之前,我们的磁盘是模拟的”ide”格式,XML的定义是:
<disk type='file' device='disk'>      <driver name='qemu'type='qcow2'/>      <sourcefile='/opt/vm/xp_c.img' lock='exclusive'/>      <target dev='hda'bus='ide'/></disk>
在装完系统以后,如下图红色字体所示,是“QEMU HARDDISK” 现在我们对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>   <disktype='file' device='floppy'>      <source file='/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'/>    </interface>    <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></devices><qemu:commandline>   <qemu:argvalue="-cpu"/>   <qemu:argvalue="qemu64,model=3"/></qemu:commandline></domain>
也就是对磁盘、网络和内存等主要有关IO的设备采用virtio的方式。在重新安装虚拟机系统之前,从https://www.linuxwind.org/virtio下载最新的virtio的软盘文件(virtio-WinXP-x86.vfd),在装系统的时候就会弹出提示需要安装上这些虚拟磁盘驱动,默认选上就可以了。做好准备以后重新安装操作系统后,再查看这时候发现磁盘驱动器已经变成了“Red Hat VirtIO SCSI Disk Device”,这意味着virtio磁盘驱动已经装上了!下一篇将介绍如何安装虚拟网卡驱动和虚拟显卡驱动等内容。

残缺极品 发表于 2013-7-12 17:10:12

谢谢楼主,共同发展

jonvi 发表于 2013-7-14 21:26:57

这是什么东东啊

刘伟 发表于 2013-7-17 06:29:29

流氓不可怕,就怕流氓有文化。

dopost 发表于 2013-7-20 00:49:38

有事秘书干,没事干秘书!

boss44 发表于 2013-7-22 05:44:41

我不在江湖,但江湖中有我的传说。

yaomint 发表于 2013-7-24 01:22:12

我真想亲口管你爷爷叫声:爹!
页: [1]
查看完整版本: Ubuntu12.10 下搭建基于KVM-QEMU的虚拟机环境(十)