采用virtio的目的是提高虚拟机的性能,KVMI/O虚拟化方面,传统的方式是使用QEMU纯软件的方式来模拟I/O设备(模拟的网卡、磁盘、显卡等等),其效率并不非常高。在KVM中,可以在客户机中使用半虚拟化驱动(Paravirtualized DriversPV Drivers)来提高客户机的性能(特别是I/O性能)。目前,KVM中实现半虚拟化驱动的方式是采用了virtio这个Linux上的设备驱动标准框架。

在未采用virtio之前,我们的磁盘是模拟的”ide”格式,XML的定义是:

<disk type='file' device='disk'>

      <driver name='qemu'  type='qcow2'/>

      <source  file='/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>

    <boot  dev='cdrom'/>

    <boot dev='hd'/>

    <bootmenu  enable='yes'/>

  </os>

  <features>

    <acpi/>

    <apic/>

    <pae/>

  </features>

  <cpu>

    <topology sockets='1'  cores='1' threads='1'/>

  </cpu>

  <clock  offset='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'/>

      <source  file='/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'/>

      <source  file='/opt/vm/xpvm_virtio/xp_d.img' lock='exclusive'/>

      <target dev='hdb'  bus='virtio'/>

    </disk>

    <disk type='file'  device='cdrom'>

      <source  file='/opt/vm/windows_xp_professional_sp3_x86.iso'/>

      <target  dev='hdc'/>

      <readonly/>

    </disk>

   <disk  type='file' device='floppy'>

      <source file='/opt/vm/virtio-WinXP-x86.vfd'/>

      <target dev='fda' bus='fdc'/>

      <readonly/>

    </disk>

    <interface  type='bridge'>

      <mac  address='52:54:00:7b:a8:d8'/>

      <source bridge='virbr0'/>

      <target  dev='vnet1'/>

    </interface>

    <input type='tablet'  bus='usb'/>

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

      <listen  type='address' address='0.0.0.0'/>

      <agent_mouse  mode='off'/>

    </graphics>

    <sound  model='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:arg  value="-cpu"/>

     <qemu:arg  value="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磁盘驱动已经装上了!


文章来源 http://blog.csdn.net/hbsong75/article/details/9255573



Logo

更多推荐