qemu guest automation

前端 未结 8 781
生来不讨喜
生来不讨喜 2021-02-09 02:39

I\'ve not been able to find any documentation stating the existence of an API that can be used to automate things inside of a qemu guest.

For example, I would like to la

8条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-09 03:28

    I use python with pexpect to interact with spawned VMs using their serial consoles. I generally automate scenarios that have up to 128VMs this way, its reasonably swift. I generally use virt-install to instantiate guests, and use "virsh console (domainname)" using pexpect to get a "handle" to each console, so I can send commands to configure networking, startup tools/utilities/scripts, monitor operation, etc. Pretty sweet in terms of simplicity, and since the scripts are just issuing shell commands, you aren't exposed to APIs that change from version to version, e.g. the serial console will always be there. Sometimes I use qemu directly, (lately I am working with a QEMU that libvirt doesn't support since its too new), in that case I will have the guest console use a telnet port so I can "telnet localhost portnumber" to make a console connection instead of "virsh console (domainname)". Either way, python scripts with the pexpect module for interacting with VMs is great.

提交回复
热议问题