免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4993 | 回复: 0
打印 上一主题 下一主题

Using kvm/qemu with virtio [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-01-27 14:39 |只看该作者 |倒序浏览
Using kvm/qemu with virtio
Since kernel 2.6.25, linux kernel have virtio support, virtio is
different
with full device virtualization, it doesn't have to behave as the
realhardware,
the guest driver actually knows it is running under a virtual
environment, thus
in theory it's should be faster and more efficient than the
full virtualized
hardware.
Newer qemu (svn version, not 0.9.1) have virtio support, recent kvm also
have
virtio support.
In order to utilize virtio, you will need a recent kernel (> 2.6.25)
with
virtio (variants) support, and a recent qemu/kvm.
How to use Virtio
* Get kvm version >= 60 (or recent svn verstion qemu)
* Get Linux
kernel with virtio drivers for the guest
Get Kernel >= 2.6.25 and activate (modules should also work, but take care
of initramdisk)
+
CONFIG_VIRTIO_PCI=y (Virtualization -> PCI driver for virtio devices)
+
CONFIG_VIRTIO_BALLOON=y (Virtualization -> Virtio balloon driver)
+
CONFIG_VIRTIO_BLK=y (Device Drivers -> Block -> Virtio block
driver)
+
CONFIG_VIRTIO_NET=y (Device Drivers -> Network device support -> Virtio
network driver)
+ CONFIG_VIRTIO=y (automatically selected)
+
CONFIG_VIRTIO_RING=y (automatically selected)
+ you can safely disable
SATA/SCSI and also all other nic drivers if you only use VIRTIO (disk/nic)
As an alternative one can use a standard guest kernel for the guest >
2.6.18 and make use sync backward compatibility option
Backport and instructions can be found in kvm-guest-drivers-linux.git
*
Use model=virtio for the network devices and if=virtio for disk
Example
qemu/x86_64-softmmu/qemu-system-x86_64 -boot c -drive
file=/images/xpbase.qcow2,if=virtio,boot=on -m 384 -net nic,model=virtio -net
tap,script=/etc/kvm/qemu-ifup
Another Example of using virtio:
I use qemu/kvm to install a distro like arch linux, I can't use virtio at
the
begining because the official arch linux kernel (archlinux 2009.2,
kernel
2.6.28.5-2) can not boot via virtio devices. so:
qemu-img create -f qcow2 arch-x86.img 1G
sudo kvm -cdrom
archlinux-2009.02-core-x86_64.iso -hda arch-x86.img -boot 'd' -net
nic,model=e1000 -net tap
NOTE: root partition mount point in /etc/fstab should be UUID or LABEL
based
because later the device interface (sda->vda) might be changed. ie:
LABEL=/arch / ext4 noatime 0 0
after finishing archlinux installation, we could use our own kernel to
utilize
virtio, ie:
cd ~/linux/linux-2.6
build a kernel with VIRTIO support.
sudo kvm -kernel arch/i386/boot/bzImage -append 'root=/dev/vd1 ro
console=ttyS0,115200' -drive file=~/arch-x86.img,if=virtio,boot=on -m 256 -net
nic,model=virtio -net tap
refs:
http://kvm.qumranet.com/kvmwiki/Virtio
http://wiki.libvirt.org/page/Virtio
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/98727/showart_2162141.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP