R-Car/Virtualization/Libvirt

From eLinux.org
< R-Car‎ | Virtualization
Revision as of 04:20, 1 February 2018 by Geert (talk | contribs) (Virsh invocation)
Jump to: navigation, search

Libvirt virtualization API

Virsh

'virsh' is a commandline 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

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

Virt-manager

References