git clone git://git.infradead.org/users/kbusch/qemu-nvme.git
cd qemu-nvme
./configure --python=/usr/bin/python2 --enable-kvm --target-list=x86_64-softmmu --enable-linux-aio --prefix=/home/clzhou/qemu-nvme-setup
make
make install
创建image
qemu-img create -f qcow2 /home/clzhou/qemu-img-disk 20G
安装 ubuntu
./x86_64-softmmu/qemu-system-x86_64 -m 1024 -cdrom ../ubuntu-15.10-server-amd64.iso -hda ../qemu-img-disk
创建一个空的image,用于放NVME device
dd if=/dev/zero of=blknvme bs=1M count=1024
试着启动虚拟机,下面命令行参数逗号前后不能有空格,否则提示 drive with bus=0, unit=0 (index=0) exists
./x86_64-softmmu/qemu-system-x86_64 -m 1024 -hda ../qemu-img-disk -drive file=blknvme,if=none,id=mynvme -device nvme,drive=mynvme,serial=foo --enable-kvm
进入虚拟机后查看/dev/nvme0n1是否存在
配置tap网络,使虚拟机能访问外网
安装bridge和tun/tap工具
yum install bridge-utils.noarch yum install tunctl
brctl show
tunctl -b
新建/etc/qemu-ifup /etc/qemu-ifdown
[root@deralab1 qemu-nvme]# vi /etc/qemu-ifup #!/bin/sh /usr/sbin/tunctl -t tap0 -u root ETH0ADDR=10.0.1.30 /sbin/ifdown eth0 /sbin/ifconfig eth0 0.0.0.0 promisc up /sbin/ifconfig $1 10.0.1.123 promisc up /usr/sbin/brctl addbr br0 /usr/sbin/brctl addif br0 eth0 /usr/sbin/brctl addif br0 $1 /usr/sbin/brctl stp br0 off /sbin/ifconfig br0 /sbin/ifconfig br0 $ETH0ADDR netmask 255.255.255.0 [root@deralab1 qemu-nvme]# vi /etc/qemu-ifdown #!/bin/sh /sbin/ifdown eth0 /sbin/ifdown br0 /sbin/ifconfig br0 down /usr/sbin/brctl delbr br0 /sbin/ifconfig eth0 -promisc /sbin/ifup eth0 #/sbin/dhclient eth0 [root@deralab1 qemu-nvme]# chmod 777 /etc/qemu-ifdown [root@deralab1 qemu-nvme]# chmod 777 /etc/qemu-ifup
启动带网络接口的虚拟机
./x86_64-softmmu/qemu-system-x86_64 -m 1024 -hda ../qemu-img-disk -net nic,vlan=0 -net tap,vlan=0,ifname=tap0 -drive file=blknvme,if=none,id=mynvme -device nvme,drive=mynvme,serial=foo --enable-kvm
参考 http://blog.csdn.net/xinying0424/article/details/8156892
http://git.infradead.org/users/kbusch/ users/kbusch/linux-nvme/*
http://qemu.weilnetz.de/qemu-doc.html Qemu user document
http://openchannelssd.readthedocs.org/en/latest/gettingstarted/ 一个openchannual 官方帮助文档
http://www.cnblogs.com/huqingyu/archive/2005/04/03/131102.html qemu如何上网