Execute virsh commands in virt-launcher pod

A powerful utility to check and troubleshoot the VM state is virsh and the utility is already installed in the compute container on the virt-launcher pod.

For example, it possible to run any QMP commands.

For a full list of QMP command, please refer to the QEMU documentation.

  1. $ kubectl get po
  2. NAME READY STATUS RESTARTS AGE
  3. virt-launcher-vmi-ephemeral-xg98p 3/3 Running 0 44m
  4. $ kubectl exec -ti virt-launcher-vmi-debug-tools-fk64q -- bash
  5. bash-5.1$ virsh list
  6. Id Name State
  7. -----------------------------------------
  8. 1 default_vmi-debug-tools running
  9. bash-5.1$ virsh qemu-monitor-command default_vmi-debug-tools query-status --pretty
  10. {
  11. "return": {
  12. "status": "running",
  13. "singlestep": false,
  14. "running": true
  15. },
  16. "id": "libvirt-439"
  17. }
  18. $ virsh qemu-monitor-command default_vmi-debug-tools query-kvm --pretty
  19. {
  20. "return": {
  21. "enabled": true,
  22. "present": true
  23. },
  24. "id": "libvirt-438"
  25. }

Another useful virsh command is the qemu-monitor-event. Once invoked, it observes and reports the QEMU events.

The following example shows the events generated for pausing and unpausing the guest.

  1. $ kubectl get po
  2. NAME READY STATUS RESTARTS AGE
  3. virt-launcher-vmi-ephemeral-nqcld 3/3 Running 0 57m
  4. $ kubectl exec -ti virt-launcher-vmi-ephemeral-nqcld -- virsh qemu-monitor-event --pretty --loop

Then, you can, for example, pause and then unpause the guest and check the triggered events:

  1. $ virtctl pause vmi vmi-ephemeral
  2. VMI vmi-ephemeral was scheduled to pause
  3. $ virtctl unpause vmi vmi-ephemeral
  4. VMI vmi-ephemeral was scheduled to unpause

From the monitored events:

  1. $ kubectl exec -ti virt-launcher-vmi-ephemeral-nqcld -- virsh qemu-monitor-event --pretty --loop
  2. event STOP at 1698405797.422823 for domain 'default_vmi-ephemeral': <null>
  3. event RESUME at 1698405823.162458 for domain 'default_vmi-ephemeral': <null>