River008

 

命令行方式启动Qemu虚拟机的几个示例

1. 前端使用virtio-net驱动,后端是tap设备,vhost-net方式。这样VM启动后,主机上ifconfig可以查到tap0接口,如果想要VM动态获取IP需要主机上将tap0接口添加到virbr0网桥上,即运行sudo brctl addif virbr0 tap0

sudo qemu-system-x86_64 -enable-kvm  -kernel ./bzImage -hda ./intel-x86-64-rootfs.ext4 -m 2048 -nographic -netdev tap,id=hn2,br=virbr0,vhost=on -device virtio-net,netdev=hn2 \

-append "console=ttyS0,115200 ip=dhcp root=/dev/sda init=/sbin/init clock=pit oprofile.timer=1 UMA=1"

2.#e1000 as front-end connect to backend of type tap, backend with id hn2.

sudo qemu-system-x86_64 -nographic -netdev tap,id=hn2 -device e1000,netdev=hn2 -drive format=raw,file=xx.img

3.#boot from nfs
sudo kvm -kernel ./bzImage -m 2048 -netdev tap,id=hn2 -device e1000,netdev=hn2,mac=11:22:33:44:55:66 -nographic -append "console=ttyS0,115200 root=/dev/nfs nfsroot=127.0.0.1:/home/${USER}/nfs-server-qemu init=/sbin/init"

 

posted on 2022-02-16 22:10  River008  阅读(2180)  评论(0编辑  收藏  举报

导航