资源描述:
《qemu 启动参数修改.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、对于qemu的启动参数,qemu使用了一些基本的框架函数完成相关的解析,方便后续开发人员增加功能。这部分的代码还是有点复杂,所以自己总结一下。qemu-kvm启动参数的一个例子,使用libvirt创建的一个虚拟机。/usr/libexec/qemu-kvm-namerhel6.5-S-Mpc-0.15-enable-kvm-m1024-realtimemlock=off-smp1,sockets=1,cores=1,threads=1-uuid8f338d83-41c1-9df6-d42f-851f13949359-no-user-config-nodefaults-chardevsoc
2、ket,id=charmonitor,path=/var/lib/libvirt/qemu/rhel6.5.monitor,server,nowait-monchardev=charmonitor,id=monitor,mode=control-rtcbase=utc-no-shutdown-bootc-drivefile=/var/lib/libvirt/images/rhel6.5.img,if=none,id=drive-virtio-disk0,format=raw,cache=none-devicevirtio-blk-pci,bus=pci.0,addr=0x5,drive=
3、drive-virtio-disk0,id=virtio-disk0-driveif=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw-deviceide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0-netdevtap,fd=23,id=hostnet0-devicee1000,netdev=hostnet0,id=net0,mac=52:54:00:61:00:e7,bus=pci.0,addr=0x3-chardevpty,id=charserial0
4、-deviceisa-serial,chardev=charserial0,id=serial0-usb-deviceusb-tablet,id=input0-vnc127.0.0.1:0-vgacirrus-devicevirtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6qemu参数代码分析,以realtime这个参数为例进行说明:修改点一:qemu_add_opts(&qemu_realtime_opts);修改点二:staticQemuOptsListqemu_realtime_opts={ .name="realtime",
5、.head=QTAILQ_HEAD_INITIALIZER(qemu_realtime_opts.head), .desc={ { .name="mlock", .type=QEMU_OPT_BOOL, }, {/*endoflist*/} },};修改点三: caseQEMU_OPTION_realtime: opts=qemu_opts_parse(qemu_find_opts("realtime"),optarg,0); i
6、f(!opts){ exit(1); } configure_realtime(opts); break;修改点四:staticvoidconfigure_realtime(QemuOpts*opts){ boolenable_mlock; enable_mlock=qemu_opt_get_bool(opts,"mlock",true); if(enable_mlock){ if(os_mlock()<0){ fprintf
7、(stderr,"qemu:lockingmemoryfailed"); exit(1); } }}修改点五:qemu-option.hx中增加DEF("realtime",HAS_ARG,QEMU_OPTION_realtime, "-realtime[mlock=on
8、off]" " runqemuwithrealtimefeatures"