R-Car/Virtualization/Libvirt

Libvirt Virtualization API

= Virsh =

'virsh' is a command line interface to libvirt.

It can be used interactively: $ virsh Welcome to virsh, the virtualization interactive terminal.

Type: 'help' for help with commands 'quit' to quit or by passing a subcommand directly: $ virsh list --all Id   Name                           State

-    demo                           shut off

Note that you can run virsh locally, and let it connect to the machine hosting the guests: $ virsh --connect qemu+ssh://my-virtual-host/system

Preparation
Before you can instantiate a guest, you have to create an XML file describing the guest. Fortunately virsh provides a way to convert your QEMU command line invocation into an XML file. E.g. $ virsh domxml-from-native qemu-argv <(echo /usr/bin/qemu-system-aarch64 -m 1024 -cpu cortex-a57 -M virt \       -nographic -serial pty -kernel /path/to/linux-arm64-virt/arch/arm64/boot/Image) | \ sed -e 's/unnamed/demo/' > demo.xml

Caveats:
 * Use an absolute path when referring to the QEMU binary,
 * As libvirt's console doesn't connect to QEMU's stdout, but to a pty, your QEMU command line must include '-serial pty',
 * Make sure 'libvirt-qemu' has permissions to access the kernel Image (and write access to the directory containing it?).

Virsh subcommands
Create (define) a guest (domain) from an existing XML file: $ virsh define demo.xml Domain demo defined from demo.xml

Start a created guest: $ virsh start demo Domain demo started

Connect to the console of a running guest: $ virsh console demo Connected to domain demo Escape character is ^]

BusyBox v1.24.2 built-in shell (ash)

_______                    ________        __ |       |.-.-.-.|  |  |  |..|  |_ |   -   ||  _  |  -__|     ||  |  |  ||   _||   _| |_______||   __|_____|__|__||________||__|  |____|          |__| W I R E L E S S   F R E E D O M - DESIGNATED DRIVER (Bleeding Edge, 50072) - * 2 oz. Orange Juice         Combine all juices in a  * 2 oz. Pineapple Juice      tall glass filled with * 2 oz. Grapefruit Juice    ice, stir well. * 2 oz. Cranberry Juice -

Stop (destroy) a running guest: $ virsh destroy demo Domain demo destroyed

Delete (undefine) a created guest: $ virsh undefine demo Domain demo has been undefined

List all running guests (use '--all' for all defined guests): $ virsh list Id   Name                           State

5    demo                           running

Dump the XML describing a guest: $ virsh dumpxml demo  demo ff9c71e0-53d4-4222-b0b9-70fd00a8f840 ...

= Virt-manager =

Virt-manager is a GUI for libvirt. You can use it to manage guests created with virsh.

You can run it either on the machine hosting the guests: $ virt-manager or run it locally, and let it connect to the machine hosting the guests: $ virt-manager -c qemu+ssh://my-virtual-host/system

Note that just running 'virt-manager' over ssh with X forwarding doesn't seem to work.

= References =


 * https://libvirt.org/