libvirt/libvirtd

From Gentoo Wiki
Jump to:navigation Jump to:search

libvirtd is a daemon for Libvirt management of virtual machines.

The daemon is used to ensure consistent handling of virtual machines, containers, and domains.

Libvirt (and libvirtd) currently supports QEMU, LXC, Xen, KVM, OpenVZ, VirtualBox and VMware ESX.


Installation

See libvirt for installation of libvirtd.

Configuration

Environment variables

A list of optional environment variables that are read and checked by the libvirtd command:

  • XDG_RUNTIME_DIR - Used to find the $XDG_RUNTIME_DIR/libvirt directory.
  • XDG_CONFIG_HOME

A list of optional environment variables that are ead and checked by the libvirt.so library linked by libvirtd:

  • VIR_CRED_AUTHNAME
  • VIR_CRED_PASSPHRASE
  • VIR_CRED_NOECHOPROMPT
  • LC_ALL
  • LD_PRELOAD
  • LD_LIBRARY_PATH
  • DYLD_INSERT_LIBRARIES
  • DYLD_FORCE_FLAT_NAMESPACE
  • USER
  • LOGNAME
  • TMPDIR
  • XDG_DATA_HOME
  • XDG_CACHE_HOME
  • LIBVIRT_AUTOSTART - (test) If set to 0, disables auto-launching the libvirtd, but only if there is any unprivileged hypervisor drivers required.
  • LIBVIRTD_PATH - find the libvirtd executable; colon-separated directory spec(s).
  • DISPLAY - the display X server and screen to which graphical applications should be sent. For virtualbox-only
  • DNSMASQ_CLIENT_ID - Used by libvirt_leaseshelper with dnsmasqd during bridge driver.
  • DNSMASQ_IAID - Used by libvirt_leaseshelper with dnsmasqd during bridge driver.
  • DNSMASQ_INTERFACE - Used by libvirt_leaseshelper with dnsmasqd during bridge driver.
  • DNSMASQ_LEASE_EXPIRES - Used by libvirt_leaseshelper with dnsmasqd during bridge driver.
  • DNSMASQ_OLD_HOSTNAME - Used by libvirt_leaseshelper with dnsmasqd during bridge driver.
  • DNSMASQ_SERVER_DUID - Used by libvirt_leaseshelper with dnsmasqd during bridge driver.
  • DNSMASQ_SUPPLIED_HOSTNAME - Used by libvirt_leaseshelper with dnsmasqd during bridge driver.
  • VIR_BRIDGE_NAME - Used by libvirt_leaseshelper with dnsmasqd during bridge driver.
  • LIBVIRT_ADMIN_DEFAULT_URI - administration, see virt-admin(1) manpage. (Deprecated; use LIBVIRT_DEFAULT_URI)
  • LIBVIRT_AUTH_FILE - authentication, when connecting to libvirtd
  • LIBVIRT_DEBUG - debug level
  • LIBVIRT_DEFAULT_URI - administration, see virt-admin(1) manpage.
  • LIBVIRT_GNUTLS_DEBUG - Enable GNUTLS debug, if defined
  • LIBVIRT_LIBSSH_DEBUG - Enable LIBSSH debug, if defined; use TRACE_LIBSSH=<level> to define debug level.
  • LIBVIRT_LOG_FILTERS - A component:level colon-pair, each separated by commas: levels are , error, warning, info, debug, trace.; Some components are qemu, network, storage, cpu, driver, interface, xml, domain, migration, security, host, api, config, event, util.
  • LIBVIRT_LOG_OUTPUTS - A valid filepath to a debug log file.
  • LISTEN_PID - For systemd only.
  • LISTEN_FDS - For systemd only.
  • NOTIFY_SOCKET - for systemd-only.
  • QEMU_AUDIO_DRV - Valid values are pa, none, alsa, coreaudio, jack, oss, pipewire, sdl, spice or wav.
  • SDL_AUDIODRIVER - Valid values are pulseaudio, esd, alsa or arts.
  • VBOX_APP_HOME - for virtualbox-only
  • VIRSH_DEFAULT_CONNECT_URI - administration, see virsh(1) manpage. (Deprecated; used LIBVIRT_DEFAULT_URI).
  • VIRTD_PATH - find the libvirtd executable; colon-separated directory spec(s).


Files

Files that are read by the host-side OS libvirtd daemon command:

  • /etc/libvirt/libvirtd.conf
  • /etc/libvirt/util.conf
  • /etc/machine-id
  • /etc/pki/CA/cacert.pem
  • /etc/pki/libvirt/servercert.pem
  • /etc/pki/libvirt/private/serverkey.pem
  • /proc/devices
  • /proc/filesystems
  • /proc/mounts
  • /proc/self/cgroup
  • /proc/%lld/cgroup
  • /proc/self/status
  • /proc/sys/kernel/cap_last_cap
  • [/var]/run/libvirt/libvirt-admin-sock
  • [/var]/run/libvirt/libvirt-sock
  • [/var]/run/libvirt/libvirt-sock-ro
  • [/var]/run/pid/libvirt.pid
  • /sys/devices/system/cpu/possible
  • /sys/devices/system/node/node0/meminfo
  • /sys/devices/system/node
  • /usr/lib/locale/locale-archive
  • /var/run/utmp
  • $HOME/.cache
  • $HOME/.local/share
  • $HOME/.pki/libvirt/cacert.pem
  • $HOME/.pki/libvirt/servercert.pem
  • $HOME/.pki/libvirt/serverkey.pem
  • $XDG_DATA_HOME
  • $XDG_CACHE_HOME


User permissions

libvirtd runs in either root (for system mode) or as a non-root user (for session mode).

See libvirt configuration for more setup on enabling a non-root user to use the libvirtd command.

Service

Typically, libvirtd daemon is run in system mode by the system startup script (like ATT SysV, rc.local, systemd). See libvirt service for more commands.

A quick test to see if the libvirtd daemon is up and running from the command line in one of three ways:

libvirtd service - status by CLI

host-root#virsh list --all

virsh list --all
 Id   Name       State
---------------------------
 16   gentoo     running
 -    gentoo2    shut off

libvirtd service - status by explicit channel

host-root#virsh -c qemu:///system list --all

virsh -c qemu:///system list --all
 Id   Name       State
---------------------------
 16   gentoo     running
 -    gentoo2    shut off

libvirtd service - status by environment variable

By environment variable, run:

CODE Use environment variable to define connect type
export VIRSH_DEFAULT_CONNECT_URI=qemu:///system

then run:

host-root#virsh list --all
virsh  list --all
 Id   Name       State
---------------------------
 16   gentoo     running
 -    gentoo2    shut off


libvirtd service - status by config file

The libvirt configuration file is in the following directory order:

1. /etc/libvirt/libvirt.conf

Note
There is no $HOME nor user-specific Libvirt configuration file.
CODE Libvirt configuration settings
#
# This can be used to setup URI aliases for frequently
# used connection URIs. Aliases may contain only the
# characters  a-Z, 0-9, _, -.
#
# Following the '=' may be any valid libvirt connection
# URI, including arbitrary parameters

#uri_aliases = [
#  "hail=qemu+ssh://root@hail.cloud.example.com/system",
#  "sleet=qemu+ssh://root@sleet.cloud.example.com/system",
#]

#
# These can be used in cases when no URI is supplied by the application
# (@uri_default also prevents probing of the hypervisor driver).
#
#uri_default = "qemu:///system"

Use @uri_default if using this configuration file is copied as-is across multiple hosts; no probe for hypervisor driver done here, but if it does exist, use them.


Invocation

host$libvirtd --help
Usage:
  libvirtd [options]

Options:
  -h | --help            Display program help
  -v | --verbose         Verbose messages
  -d | --daemon          Run as a daemon & write PID file
  -l | --listen          Listen for TCP/IP connections
  -t | --timeout <secs>  Exit after timeout period
  -f | --config <file>   Configuration file
  -V | --version         Display version information
  -p | --pid-file <file> Change name of PID file

libvirt management daemon:

  Default paths:

    Configuration file (unless overridden by -f):
      /etc/libvirt/libvirtd.conf

    Sockets:
      /run/libvirt/libvirt-sock
      /run/libvirt/libvirt-sock-ro

    TLS:
      CA certificate: /etc/pki/CA/cacert.pem
      Server certificate: /etc/pki/libvirt/servercert.pem
      Server private key: /etc/pki/libvirt/private/serverkey.pem

    PID file (unless overridden by -p):
      /run/libvirtd.pid

Removal

Removal of libvirt package (toolkit, library, and utilities) can be done by executing:

root #emerge --ask --depclean --verbose app-emulation/libvirt

See also

  • Virtualization — the concept and technique that permits running software in an environment separate from a computer operating system.
  • QEMU — a generic, open-source hardware emulator and virtualization suite.
  • QEMU/Front-ends — facilitate VM management and use
  • Libvirt — a virtualization management toolkit
  • Virt-manager — lightweight GUI application designed for managing virtual machines and containers via the libvirt API.


External resources