qemu 启动参数修改_第1页
qemu 启动参数修改_第2页
qemu 启动参数修改_第3页
qemu 启动参数修改_第4页
qemu 启动参数修改_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

对于 qemu 的启动参数 qemu 使用了一些基本的框架函数完成相关的解 析 方便后续开发人员增加功能 这部分的代码还是有点复杂 所以自己总结一下 qemu kvm 启动参数的一个例子 使用 libvirt 创建的一个虚拟机 usr libexec qemu kvm name rhel6 5 S M pc 0 15 enable kvm m 1024 realtime mlock off smp 1 sockets 1 cores 1 threads 1 uuid 8f338d83 41c1 9df6 d42f 851f13949359 no user config nodefaults chardev socket id charmonitor path var lib libvirt qemu rhel6 5 monitor server nowait mon chardev charmonitor id monitor mode control rtc base utc no shutdown boot c drive file var lib libvirt images rhel6 5 img if none id drive virtio disk0 format raw cache none device virtio blk pci bus pci 0 addr 0 x5 drive drive virtio disk0 id virtio disk0 drive if none media cdrom id drive ide0 1 0 readonly on format raw device ide drive bus ide 1 unit 0 drive drive ide0 1 0 id ide0 1 0 netdev tap fd 23 id hostnet0 device e1000 netdev hostnet0 id net0 mac 52 54 00 61 00 e7 bus pci 0 addr 0 x3 chardev pty id charserial0 device isa serial chardev charserial0 id serial0 usb device usb tablet id input0 vnc 127 0 0 1 0 vga cirrus device virtio balloon pci id balloon0 bus pci 0 addr 0 x6 qemu 参数代码分析 以 realtime 这个参数为例进行说明 修改点一 qemu add opts 修改点二 static QemuOptsList qemu realtime opts name realtime head QTAILQ HEAD INITIALIZER qemu realtime opts head desc name mlock type QEMU OPT BOOL end of list 修改点三 case QEMU OPTION realtime opts qemu opts parse qemu find opts realtime optarg 0 if opts exit 1 configure realtime opts break 修改点四 static void configure realtime QemuOpts opts bool enable mlock enable mlock qemu opt get bool opts mlock true if enable mlock if os mlock 0 fprintf stderr qemu locking memory failed n exit 1 修改点五 qemu option hx 中增加 DEF realtime HAS ARG QEMU OPTION realtime realtime mlock on off n run qemu with realtime features n mlock on off controls mlock support default on n QEMU ARCH ALL STEXI item realtime mlock on off findex realtime Run qemu with realtime features mlocking qemu and guest memory can be enabled via option mlock on enabled by default ETEXI 下面分析一下这些函数的处理流程 1 qemu add opts qemu add opts 函数在 include qemu config file h 中声明 在 util qemu config c 中定义 在 util qemu config c 中定义静态变量 static QemuOptsList vm config groups 32 static QemuOptsList drive config groups 4 定义了数组 通过 qemu add opts 增加到 vm config groups 数组中 qemu realtime opts 定义如下 static QemuOptsList qemu realtime opts name realtime head QTAILQ HEAD INITIALIZER qemu realtime opts head desc name mlock type QEMU OPT BOOL end of list 2 在 vl c 的 main 函数中 调用 lookup opt 该函数根据 argv 当前执 行的参数 查找 qemu options 变量 返回对应的指针 返回的 optarg 和 optind 参数含义 optarg 执行对应参数后对应的内 容 比如 realtime 后的 mlock off 返回值的类型是 QemuOption 对应的是和 qemu option hx 中名称一致 的变量指针 qemu options 变量在 lv c 中定义 static const QEMUOption qemu options h 0 QEMU OPTION h QEMU ARCH ALL define QEMU OPTIONS GENERATE OPTIONS include qemu options wrapper h NULL typedef struct QEMUOption const char name int flags int index uint32 t arch mask QEMUOption define HAS ARG 0 x0001 include qemu options wrapper h 中通过宏分别处理 QEMU OPTIONS GENERATE ENUM QEMU OPTIONS GENERATE HELP QEMU OPTIONS GENERATE OPTIONS 具体的内容在 include qemu options def 通过宏处理后 qemu options 内容被填充 QEMU OPTIONS GENERATE HELP 在如下场景下使用 static void help int exitcode version printf usage s options disk image n n disk image is a raw hard disk image for IDE hard disk 0 n n error get progname define QEMU OPTIONS GENERATE HELP include qemu options wrapper h printf nDuring emulation the following keys are useful n ctrl alt f toggle full screen n ctrl alt n switch to virtual console n n ctrl alt toggle mouse and keyboard grab n n When using nographic press ctrl a h to get some help n exit exitcode 枚举宏的定义在 qemu options h 中定义 ifndef QEMU OPTIONS H define QEMU OPTIONS H enum define QEMU OPTIONS GENERATE ENUM include qemu options wrapper h endif 3 qemu find opts 代码流程 返回对应名称的 QemuOptsList 变量 QemuOptsList qemu find opts const char group QemuOptsList ret Error local err NULL ret find list vm config groups group if error is set error free local err return ret 调用 qemu opts parse 函数 根据 QemuOptsList 中定义的数据格式 生成 QemuOpts 变量 QemuOpts 变量的格式定义如下 在 include qemu option int h struct QemuOpt const char name const char str const QemuOptDesc desc union bool boolean uint64 t uint value

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论