A.19. Common libvirt Errors and Troubleshooting
Solutionfor detailed troubleshooting information.
Table A.1. Common libvirt errors
|Error||Description of problem||Solution|
| || The libvirt daemon failed to start. However, there is no information about this error in ||Section A.19.1, “libvirtd failed to start”|
| ||This is one of several errors that occur when the URI fails to connect to the hypervisor.||Section A.19.2, “The URI Failed to Connect to the Hypervisor”|
|Other connectivity errors||These are other errors that occur when the URI fails to connect to the hypervisor.||Section A.19.2, “The URI Failed to Connect to the Hypervisor”|
| ||The guest virtual machine (or domain) starting fails and returns this error or similar.|| Section A.19.3, “Guest Starting Fails with Error: |
| ||This error can occur when attempting to connect a guest's console. It reports that there is no serial console configured for the guest virtual machine.|| Section A.19.4, “|
| || After building a guest virtual machine from an existing disk image, the guest booting stalls. However, the guest can start successfully using the || Section A.19.5, “Guest Virtual Machine Booting Stalls with Error: |
| || |
If the default network (or other locally-created network) is unable to start, any virtual machine configured to use that network for its connectivity will also fail to start.
|Section A.19.6, “Virtual network default has not been started”|
|PXE boot (or DHCP) on guest failed||A guest virtual machine starts successfully, but is unable to acquire an IP address from DHCP, boot using the PXE protocol, or both. This is often a result of a long forward delay time set for the bridge, or when the iptables package and kernel do not support checksum mangling rules.||Section A.19.7, “PXE Boot (or DHCP) on Guest Failed”|
|Guest can reach outside network, but cannot reach host when using macvtap interface|| |
A guest can communicate with other guests, but cannot connect to the host machine after being configured to use a macvtap (or
This is actually not an error — it is the defined behavior of macvtap.
|Section A.19.8, “Guest Can Reach Outside Network, but Cannot Reach Host When Using macvtap interface”|
| ||This warning message is almost always harmless, but is often mistakenly seen as evidence of a problem.||Section A.19.9, “Could not add rule to fixup DHCP response checksums on network 'default'”|
| || This error message or the similar ||Section A.19.10, “Unable to add bridge br0 port vnet0: No such device”|
| || The guest virtual machine does not start after configuring a || Section A.19.11, “Guest is Unable to Start with Error: |
| ||QEMU guest migration fails and this error message appears with an unfamiliar host name.|| Section A.19.12, “Migration Fails with |
| ||A guest virtual machine cannot be migrated because libvirt cannot access the disk image(s).|| Section A.19.13, “Migration Fails with |
|No guest virtual machines are present when libvirtd is started|| The libvirt daemon is successfully started, but no guest virtual machines appear to be present when running ||Section A.19.14, “No Guest Virtual Machines are Present when libvirtd is Started”|
|Common XML errors||libvirt uses XML documents to store structured data. Several common errors occur with XML documents when they are passed to libvirt through the API. This entry provides instructions for editing guest XML definitions, and details common errors in XML syntax and configuration.||Section A.19.16, “Common XML Errors”|
A.19.1. libvirtd failed to start
- The libvirt daemon does not start automatically. Starting the libvirt daemon manually fails as well:
systemctl start libvirtd.service* Caching service dependencies ... [ ok ] * Starting libvirtd ... /usr/sbin/libvirtd: error: Unable to initialize network sockets. Check /var/log/messages or run without --daemon for more info. * start-stop-daemon: failed to start `/usr/sbin/libvirtd' [ !! ] * ERROR: libvirtd failed to startMoreover, there is not
'more info'about this error in
- Change libvirt's logging in
/etc/libvirt/libvirtd.confby enabling the line below. To enable the setting the line, open the
/etc/libvirt/libvirtd.conffile in a text editor, remove the hash (or
#) symbol from the beginning of the following line, and save the change:
NoteThis line is commented out by default to prevent libvirt from producing excessive log messages. After diagnosing the problem, it is recommended to comment this line again in the
/etc/libvirt/libvirtd.conffile.Restart libvirt to determine if this has solved the problem.If
libvirtdstill does not start successfully, an error similar to the following will be printed:
systemctl restart libvirtdJob for libvirtd.service failed because the control process exited with error code. See "systemctl status libvirtd.service" and "journalctl -xe" for details. Sep 19 16:06:02 jsrh libvirtd: 2017-09-19 14:06:02.097+0000: 30708: info : libvirt version: 3.7.0, package: 1.el7 (Unknown, 2017-09-06-09:01:55, js Sep 19 16:06:02 jsrh libvirtd: 2017-09-19 14:06:02.097+0000: 30708: info : hostname: jsrh Sep 19 16:06:02 jsrh libvirtd: 2017-09-19 14:06:02.097+0000: 30708: error : daemonSetupNetworking:502 : unsupported configuration: No server certif Sep 19 16:06:02 jsrh systemd: libvirtd.service: main process exited, code=exited, status=6/NOTCONFIGURED Sep 19 16:06:02 jsrh systemd: Failed to start Virtualization daemon. -- Subject: Unit libvirtd.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit libvirtd.service has failed. -- -- The result is failed.The libvirtd man page shows that the missing
cacert.pemfile is used as TLS authority when libvirt is run in
Listen for TCP/IP connectionsmode. This means the
--listenparameter is being passed.
- Configure the libvirt daemon's settings with one of the following methods:
- Install a CA certificate.
NoteFor more information on CA certificates and configuring system authentication, refer to the Configuring Authentication chapter in the Red Hat Enterprise Linux 7 Domain Identity, Authentication, and Policy Guide.
- Do not use TLS; use bare TCP instead. In
listen_tls = 0and
listen_tcp = 1. The default values are
listen_tls = 1and
listen_tcp = 0.
- Do not pass the
A.19.2. The URI Failed to Connect to the Hypervisor
A.19.2.1. Cannot read CA certificate
- When running a command, the following error (or similar) appears:
virsh -c qemu://$hostname/system_listerror: failed to connect to the hypervisor error: Cannot read CA certificate '/etc/pki/CA/cacert.pem': No such file or directory
- The error message is misleading about the actual cause. This error can be caused by a variety of factors, such as an incorrectly specified URI, or a connection that is not configured.
- Incorrectly specified URI
- When specifying
qemu://sessionas a connection URI,
virshattempts to connect to host names'
sessionrespectively. This is because
virshrecognizes the text after the second forward slash as the host.Use three forward slashes to connect to the local host. For example, specifying
virshconnect to the
systeminstance of libvirtd on the local host.When a host name is specified, the QEMU transport defaults to
TLS. This results in certificates.
- Connection is not configured
- The URI is correct (for example,
qemu[+tls]://server/system) but the certificates are not set up properly on your machine. For information on configuring TLS, see the upstream libvirt website.
A.19.2.2. Other Connectivity Errors
- Unable to connect to server at
server:port: Connection refused
- The daemon is not running on the server or is configured not to listen, using configuration option
- End of file while reading data: nc: using stream socket: Input/output error
- If you specified
sshtransport, the daemon is likely not running on the server. Solve this error by verifying that the daemon is running on the server.
A.19.3. Guest Starting Fails with Error:
monitor socket did not show up
- The guest virtual machine (or domain) starting fails with this error (or similar):
# virsh -c qemu:///system create name_of_guest.xml error: Failed to create domain from name_of_guest.xml error: monitor socket did not show up.: Connection refused
- This error message shows:
To understand the error details, examine the guest log:
- libvirt is working;
- The QEMU process failed to start up; and
- libvirt quits when trying to connect QEMU or the QEMU agent monitor socket.
cat /var/log/libvirt/qemu/name_of_guest.logLC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin QEMU_AUDIO_DRV=none /usr/bin/qemu-kvm -S -M pc -enable-kvm -m 768 -smp 1,sockets=1,cores=1,threads=1 -name name_of_guest -uuid ebfaadbe-e908-ba92-fdb8-3fa2db557a42 -nodefaults -chardev socket,id=monitor,path=/var/lib/libvirt/qemu/name_of_guest.monitor,server,nowait -mon chardev=monitor,mode=readline -no-reboot -boot c -kernel /var/lib/libvirt/boot/vmlinuz -initrd /var/lib/libvirt/boot/initrd.img -append method=http://www.example.com/pub/product/release/version/x86_64/os/ -drive file=/var/lib/libvirt/images/name_of_guest.img,if=none,id=drive-ide0-0-0,boot=on -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -device virtio-net-pci,vlan=0,id=net0,mac=52:40:00:f4:f1:0a,bus=pci.0,addr=0x4 -net tap,fd=42,vlan=0,name=hostnet0 -chardev pty,id=serial0 -device isa-serial,chardev=serial0 -usb -vnc 127.0.0.1:0 -k en-gb -vga cirrus -device virtio-balloon-pci,id=balloon0,bus=pci.0, addr=0x3 char device redirected to /dev/pts/1 qemu: could not load kernel '/var/lib/libvirt/boot/vmlinuz': Permission denied
- The guest log contains the details needed to fix the error.If a host physical machine is shut down while the guest is still running a libvirt version prior to 0.9.5, the libvirt-guest's init script attempts to perform a managed save of the guest. If the managed save was incomplete (for example, due to loss of power before the managed save image was flushed to disk), the save image is corrupted and will not be loaded by QEMU. The older version of libvirt does not recognize the corruption, making the problem perpetual. In this case, the guest log shows an attempt to use
-incomingas one of its arguments, meaning that libvirt is trying to start QEMU by migrating in the saved state file.This problem can be fixed by running
virsh managedsave-remove name_of_guestto remove the corrupted managed save image. Newer versions of libvirt take steps to avoid the corruption in the first place, as well as adding
virsh start --force-boot name_of_guestto bypass any managed save image.
internal error cannot find character device (null)
- This error message appears when attempting to connect to a guest virtual machine's console:
virsh console test2Connected to domain test2 Escape character is ^] error: internal error cannot find character device (null)
- This error message shows that there is no serial console configured for the guest virtual machine.
- Set up a serial console in the guest's XML file.
Procedure A.8. Setting up a serial console in the guest's XML
- Add the following XML to the guest virtual machine's XML using virsh edit:
<serial type='pty'> <target port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> </console>
- Set up the console in the guest kernel command line.To do this, either log in to the guest virtual machine to edit the
/boot/grub2/grub.cfgfile directly, or use the virt-edit command-line tool. Add the following to the guest kernel command line:
- Run the followings command:
# virsh start vm && virsh console vm
A.19.5. Guest Virtual Machine Booting Stalls with Error:
No boot device
- After building a guest virtual machine from an existing disk image, the guest booting stalls with the error message
No boot device. However, the guest virtual machine can start successfully using the
- The disk's bus type is not specified in the command for importing the existing disk image:
# virt-install \ --connect qemu:///system \ --ram 2048 -n rhel_64 \ --os-type=linux --os-variant=rhel5 \ --disk path=/root/RHEL-Server-5.8-64-virtio.qcow2,device=disk,format=qcow2 \ --vcpus=2 --graphics spice --noautoconsole --importHowever, the command line used to boot up the guest virtual machine using QEMU directly shows that it uses
virtiofor its bus type:
ps -ef | grep qemu/usr/libexec/qemu-kvm -monitor stdio -drive file=/root/RHEL-Server-5.8-32-virtio.qcow2,index=0,if=virtio,media=disk,cache=none,format=qcow2 -net nic,vlan=0,model=rtl8139,macaddr=00:30:91:aa:04:74 -net tap,vlan=0,script=/etc/qemu-ifup,downscript=no -m 2048 -smp 2,cores=1,threads=1,sockets=2 -cpu qemu64,+sse2 -soundhw ac97 -rtc-td-hack -M rhel5.6.0 -usbdevice tablet -vnc :10 -boot c -no-kvm-pit-reinjectionNote the
bus=in the guest's XML generated by libvirt for the imported guest:
<domain type='qemu'> <name>rhel_64</name> <uuid>6cd34d52-59e3-5a42-29e4-1d173759f3e7</uuid> <memory>2097152</memory> <currentMemory>2097152</currentMemory> <vcpu>2</vcpu> <os> <type arch='x86_64' machine='rhel5.4.0'>hvm</type> <boot dev='hd'/> </os> <features> <acpi/> <apic/> <pae/> </features> <clock offset='utc'> <timer name='pit' tickpolicy='delay'/> </clock> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/libexec/qemu-kvm</emulator> <disk type='file' device='disk'> <driver name='qemu' type='qcow2' cache='none'/> <source file='/root/RHEL-Server-5.8-64-virtio.qcow2'/> <emphasis role="bold"><target dev='hda' bus='ide'/></emphasis> <address type='drive' controller='0' bus='0' unit='0'/> </disk> <controller type='ide' index='0'/> <interface type='bridge'> <mac address='54:52:00:08:3e:8c'/> <source bridge='br0'/> </interface> <serial type='pty'> <target port='0'/> </serial> <console type='pty'> <target port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' keymap='en-us'/> <video> <model type='cirrus' vram='9216' heads='1'/> </video> </devices> </domain>The bus type for the disk is set as
ide, which is the default value set by libvirt. This is the incorrect bus type, and has caused the unsuccessful boot for the imported guest.
Procedure A.9. Correcting the disk bus type
- Undefine the imported guest virtual machine, then re-import it with
bus=virtioand the following:
# virsh destroy rhel_64 # virsh undefine rhel_64 # virt-install \ --connect qemu:///system \ --ram 1024 -n rhel_64 -r 2048 \ --os-type=linux --os-variant=rhel5 \ --disk path=/root/RHEL-Server-5.8-64-virtio.qcow2,device=disk,bus=virtio,format=qcow2 \ --vcpus=2 --graphics spice --noautoconsole --import
- Edit the imported guest's XML using
virsh editand correct the disk bus type.
A.19.6. Virtual network default has not been started
- Normally, the configuration for a virtual network named default is installed as part of the libvirt package, and is configured to autostart when libvirtd is started.If the default network (or any other locally-created network) is unable to start, any virtual machine configured to use that network for its connectivity will also fail to start, resulting in this error message:
Virtual network default has not been started
- One of the most common reasons for a libvirt virtual network's failure to start is that the dnsmasq instance required to serve DHCP and DNS requests from clients on that network has failed to start.To determine if this is the cause, run
virsh net-start defaultfrom a root shell to start the default virtual network.If this action does not successfully start the virtual network, open
/var/log/libvirt/libvirtd.logto view the complete error log message.If a message similar to the following appears, the problem is likely a system-wide dnsmasq instance that is already listening on libvirt's bridge, and is preventing libvirt's own dnsmasq instance from doing so. The most important parts to note in the error message are
exit status 2:
Could not start virtual network default: internal error Child process (/usr/sbin/dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/libvirt/network/default.pid --conf-file= --except-interface lo --listen-address 192.168.122.1 --dhcp-range 192.168.122.2,192.168.122.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases --dhcp-lease-max=253 --dhcp-no-override) status unexpected: exit status 2
- If the machine is not using dnsmasq to serve DHCP for the physical network, disable dnsmasq completely.If it is necessary to run dnsmasq to serve DHCP for the physical network, edit the
/etc/dnsmasq.conffile. Add or remove the comment mark the first line, as well as one of the two lines following that line. Do not add or remove the comment from all three lines:
bind-interfaces interface=name_of_physical_interface listen-address=chosen_IP_addressAfter making this change and saving the file, restart the system wide dnsmasq service.Next, start the default network with the
virsh net-start defaultcommand.Start the virtual machines.
A.19.7. PXE Boot (or DHCP) on Guest Failed
- A guest virtual machine starts successfully, but is then either unable to acquire an IP address from DHCP or boot using the PXE protocol, or both. There are two common causes of this error: having a long forward delay time set for the bridge, and when the iptables package and kernel do not support checksum mangling rules.
- Long forward delay time on bridge
- This is the most common cause of this error. If the guest network interface is connecting to a bridge device that has STP (Spanning Tree Protocol) enabled, as well as a long forward delay set, the bridge will not forward network packets from the guest virtual machine onto the bridge until at least that number of forward delay seconds have elapsed since the guest connected to the bridge. This delay allows the bridge time to watch traffic from the interface and determine the MAC addresses behind it, and prevent forwarding loops in the network topology.If the forward delay is longer than the timeout of the guest's PXE or DHCP client, the client's operation will fail, and the guest will either fail to boot (in the case of PXE) or fail to acquire an IP address (in the case of DHCP).
- If this is the case, change the forward delay on the bridge to 0, disable STP on the bridge, or both.
NoteThis solution applies only if the bridge is not used to connect multiple networks, but just to connect multiple endpoints to a single network (the most common use case for bridges used by libvirt).If the guest has interfaces connecting to a libvirt-managed virtual network, edit the definition for the network, and restart it. For example, edit the default network with the following command:
virsh net-edit defaultAdd the following attributes to the
stp='on'are the default settings for virtual networks, so this step is only necessary if the configuration has been modified from the default.If the guest interface is connected to a host bridge that was configured outside of libvirt, change the delay setting.Add or edit the following lines in the
/etc/sysconfig/network-scripts/ifcfg-name_of_bridgefile to turn STP on with a 0 second delay:
STP=on DELAY=0After changing the configuration file, restart the bridge device:
/usr/sbin/ifdown name_of_bridge /usr/sbin/ifup name_of_bridge
NoteIf name_of_bridge is not the root bridge in the network, that bridge's delay will be eventually reset to the delay time configured for the root bridge. To prevent this from occurring, disable STP on name_of_bridge.
- The iptables package and kernel do not support checksum mangling rules
- This message is only a problem if all four of the following conditions are true:
When these conditions occur, UDP packets sent from the host to the guest have uncomputed checksums. This makes the host's UDP packets seem invalid to the guest's network stack.
- The guest is using virtio network devices.If so, the configuration file will contain
- The host has the
vhost-netmodule loaded.This is true if
does not return an empty result.
- The guest is attempting to get an IP address from a DHCP server that is running directly on the host.
- The iptables version on the host is older than 1.4.10.iptables 1.4.10 was the first version to add the
libxt_CHECKSUMextension. This is the case if the following message appears in the libvirtd logs:
warning: Could not add rule to fixup DHCP response checksums on network default warning: May need to update iptables package and kernel to support CHECKSUM rule.
ImportantUnless all of the other three conditions in this list are also true, the above warning message can be disregarded, and is not an indicator of any other problems.
- To solve this problem, invalidate any of the four points above. The best solution is to update the host iptables and kernel to iptables-1.4.10 or newer where possible. Otherwise, the most specific fix is to disable the
vhost-netdriver for this particular guest. To do this, edit the guest configuration with this command:
virsh edit name_of_guestChange or add a
<driver>line to the
<interface type='network'> <model type='virtio'/> <driver name='qemu'/> ... </interface>Save the changes, shut down the guest, and then restart it.If this problem is still not resolved, the issue may be due to a conflict between firewalld and the default libvirt network.To fix this, stop firewalld with the
service firewalld stopcommand, then restart libvirt with the
service libvirtd restartcommand.
A.19.8. Guest Can Reach Outside Network, but Cannot Reach Host When Using macvtap interface
- A guest virtual machine can communicate with other guests, but cannot connect to the host machine after being configured to use a macvtap (also known as
type='direct') network interface.
- Even when not connecting to a Virtual Ethernet Port Aggregator (VEPA) or VN-Link capable switch, macvtap interfaces can be useful. Setting the mode of such an interface to
bridgeallows the guest to be directly connected to the physical network in a very simple manner without the setup issues (or NetworkManager incompatibility) that can accompany the use of a traditional host bridge device.However, when a guest virtual machine is configured to use a
type='direct'network interface such as macvtap, despite having the ability to communicate with other guests and other external hosts on the network, the guest cannot communicate with its own host.This situation is actually not an error — it is the defined behavior of macvtap. Due to the way in which the host's physical Ethernet is attached to the macvtap bridge, traffic into that bridge from the guests that is forwarded to the physical interface cannot be bounced back up to the host's IP stack. Additionally, traffic from the host's IP stack that is sent to the physical interface cannot be bounced back up to the macvtap bridge for forwarding to the guests.
- Use libvirt to create an isolated network, and create a second interface for each guest virtual machine that is connected to this network. The host and guests can then directly communicate over this isolated network, while also maintaining compatibility with NetworkManager.
Procedure A.10. Creating an isolated network with libvirt
The guests are now able to reach the host at the address 192.168.254.1, and the host will be able to reach the guests at the IP address they acquired from DHCP (alternatively, you can manually configure the IP addresses for the guests). Since this new network is isolated to only the host and guests, all other communication from the guests will use the macvtap interface. For more information, refer to Section 24.18.9, “Network Interfaces”.
- Add and save the following XML in the
/tmp/isolated.xmlfile. If the 192.168.254.0/24 network is already in use elsewhere on your network, you can choose a different network.
... <network> <name>isolated</name> <ip address='192.168.254.1' netmask='255.255.255.0'> <dhcp> <range start='192.168.254.2' end='192.168.254.254'/> </dhcp> </ip> </network> ...
Figure A.3. Isolated Network XML
- Create the network with this command:
virsh net-define /tmp/isolated.xml
- Set the network to autostart with the
virsh net-autostart isolatedcommand.
- Start the network with the
virsh net-start isolatedcommand.
virsh edit name_of_guest, edit the configuration of each guest that uses macvtap for its network connection and add a new
<devices>section similar to the following (note the
<model type='virtio'/>line is optional to include):
... <interface type='network' trustGuestRxFilters='yes'> <source network='isolated'/> <model type='virtio'/> </interface>
Figure A.4. Interface Device XML
- Shut down, then restart each of these guests.
A.19.9. Could not add rule to fixup DHCP response checksums on network 'default'
- This message appears:
Could not add rule to fixup DHCP response checksums on network 'default'
- Although this message appears to be evidence of an error, it is almost always harmless.
- Unless the problem you are experiencing is that the guest virtual machines are unable to acquire IP addresses through DHCP, this message can be ignored.If this is the case, refer to Section A.19.7, “PXE Boot (or DHCP) on Guest Failed” for further details on this situation.
A.19.10. Unable to add bridge br0 port vnet0: No such device
- The following error message appears:
Unable to add bridge name_of_bridge port vnet0: No such deviceFor example, if the bridge name is br0, the error message appears as:
Unable to add bridge br0 port vnet0: No such deviceIn libvirt versions 0.9.6 and earlier, the same error appears as:
Failed to add tap interface to bridge name_of_bridge: No such deviceOr for example, if the bridge is named br0:
Failed to add tap interface to bridge 'br0': No such device
- Both error messages reveal that the bridge device specified in the guest's (or domain's)
<interface>definition does not exist.To verify the bridge device listed in the error message does not exist, use the shell command
ip addr show br0.A message similar to this confirms the host has no bridge by that name:
br0: error fetching interface information: Device not foundIf this is the case, continue to the solution.However, if the resulting message is similar to the following, the issue exists elsewhere:
br0 Link encap:Ethernet HWaddr 00:00:5A:11:70:48 inet addr:10.22.1.5 Bcast:10.255.255.255 Mask:255.0.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:249841 errors:0 dropped:0 overruns:0 frame:0 TX packets:281948 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:106327234 (101.4 MiB) TX bytes:21182634 (20.2 MiB)
- Edit the existing bridge or create a new bridge with
virshto either edit the settings of an existing bridge or network, or to add the bridge device to the host system configuration.
- Edit the existing bridge settings using
virsh edit name_of_guestto change the
<interface>definition to use a bridge or network that already exists.For example, change
- Create a host bridge using
- For libvirt version 0.9.8 and later, a bridge device can be created with the
virsh iface-bridgecommand. This creates a bridge device br0 with
eth0, the physical network interface that is set as part of a bridge, attached:
virsh iface-bridge eth0 br0Optional: If needed, remove this bridge and restore the original
eth0configuration with this command:
virsh iface-unbridge br0
- Edit the existing bridge settings using
- Create a host bridge manually
- For older versions of libvirt, it is possible to manually create a bridge device on the host. For instructions, refer to Section 6.4.3, “Bridged Networking with libvirt”.
- Edit the existing bridge or create a new bridge with
A.19.11. Guest is Unable to Start with Error:
warning: could not open /dev/net/tun
- The guest virtual machine does not start after configuring a
type='ethernet'(also known as 'generic ethernet') interface in the host system. An error appears either in
/var/log/libvirt/qemu/name_of_guest.log, or in both, similar to the below message:
warning: could not open /dev/net/tun: no virtual network emulation qemu-kvm: -netdev tap,script=/etc/my-qemu-ifup,id=hostnet0: Device 'tap' could not be initialized
- Use of the generic ethernet interface type (
<interface type='ethernet'>) is discouraged, because using it requires lowering the level of host protection against potential security flaws in QEMU and its guests. However, it is sometimes necessary to use this type of interface to take advantage of some other facility that is not yet supported directly in libvirt. For example, openvswitch was not supported in libvirt until version 0.9.11, so in prior versions of libvirt,
<interface type='ethernet'>was the only way to connect a guest to an openvswitch bridge.However, if you configure a
<interface type='ethernet'>interface without making any other changes to the host system, the guest virtual machine does not start successfully.The reason for this failure is that for this type of interface, a script called by QEMU needs to manipulate the tap device. However, with
type='ethernet'configured, in an attempt to lock down QEMU, libvirt and SELinux have put in place several checks to prevent this. (Normally, libvirt performs all of the tap device creation and manipulation, and passes an open file descriptor for the tap device to QEMU.)
- Reconfigure the host system to be compatible with the generic ethernet interface.
Procedure A.11. Reconfiguring the host system to use the generic ethernet interface
- Set SELinux to permissive by configuring
# This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=permissive # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted
- From a root shell, run the command
/etc/libvirt/qemu.confadd or edit the following lines:
clear_emulator_capabilities = 0
user = "root"
group = "root"
cgroup_device_acl = [ "/dev/null", "/dev/full", "/dev/zero", "/dev/random", "/dev/urandom", "/dev/ptmx", "/dev/kvm", "/dev/kqemu", "/dev/rtc", "/dev/hpet", "/dev/net/tun",
ImportantSince each of these steps significantly decreases the host's security protections against QEMU guest domains, this configuration should only be used if there is no alternative to using
A.19.12. Migration Fails with
error: unable to resolve address
- QEMU guest migration fails and this error message appears:
virsh migrate qemu qemu+tcp://192.168.122.12/systemerror: Unable to resolve address name_of_host service '49155': Name or service not knownFor example, if the destination host name is
newyork, the error message appears as:
virsh migrate qemu qemu+tcp://192.168.122.12/systemerror: Unable to resolve address 'newyork' service '49155': Name or service not knownHowever, this error looks strange as we did not use
newyorkhost name anywhere.
- During migration, libvirtd running on the destination host creates a URI from an address and port where it expects to receive migration data and sends it back to libvirtd running on the source host.In this case, the destination host (
192.168.122.12) has its name set to 'newyork'. For some reason, libvirtd running on that host is unable to resolve the name to an IP address that could be sent back and still be useful. For this reason, it returned the 'newyork' host name hoping the source libvirtd would be more successful with resolving the name. This can happen if DNS is not properly configured or
/etc/hostshas the host name associated with local loopback address (
127.0.0.1).Note that the address used for migration data cannot be automatically determined from the address used for connecting to destination libvirtd (for example, from
qemu+tcp://192.168.122.12/system). This is because to communicate with the destination libvirtd, the source libvirtd may need to use network infrastructure different from the type that virsh (possibly running on a separate machine) requires.
- The best solution is to configure DNS correctly so that all hosts involved in migration are able to resolve all host names.If DNS cannot be configured to do this, a list of every host used for migration can be added manually to the
/etc/hostsfile on each of the hosts. However, it is difficult to keep such lists consistent in a dynamic environment.If the host names cannot be made resolvable by any means,
virsh migratesupports specifying the migration host:
virsh migrate qemu qemu+tcp://192.168.122.12/system tcp://192.168.122.12Destination libvirtd will take the
tcp://192.168.122.12URI and append an automatically generated port number. If this is not desirable (because of firewall configuration, for example), the port number can be specified in this command:
virsh migrate qemu qemu+tcp://192.168.122.12/system tcp://192.168.122.12:12345Another option is to use tunneled migration. Tunneled migration does not create a separate connection for migration data, but instead tunnels the data through the connection used for communication with destination libvirtd (for example,
virsh migrate qemu qemu+tcp://192.168.122.12/system --p2p --tunnelled
A.19.13. Migration Fails with
Unable to allow access for disk path: No such file or directory
- A guest virtual machine (or domain) cannot be migrated because libvirt cannot access the disk image(s):
virsh migrate qemu qemu+tcp://name_of_host/systemerror: Unable to allow access for disk path /var/lib/libvirt/images/qemu.img: No such file or directoryFor example, if the destination host name is
newyork, the error message appears as:
virsh migrate qemu qemu+tcp://newyork/systemerror: Unable to allow access for disk path /var/lib/libvirt/images/qemu.img: No such file or directory
- By default, migration only transfers the in-memory state of a running guest (such as memory or CPU state). Although disk images are not transferred during migration, they need to remain accessible at the same path by both hosts.
- Set up and mount shared storage at the same location on both hosts. The simplest way to do this is to use NFS:
Procedure A.12. Setting up shared storage
- Set up an NFS server on a host serving as shared storage. The NFS server can be one of the hosts involved in the migration, as long as all hosts involved are accessing the shared storage through NFS.
mkdir -p /exports/images#
cat >>/etc/exports <<EOF/exports/images 192.168.122.0/24(rw,no_root_squash) EOF
- Mount the exported directory at a common location on all hosts running libvirt. For example, if the IP address of the NFS server is 192.168.122.1, mount the directory with the following commands:
cat >>/etc/fstab <<EOF192.168.122.1:/exports/images /var/lib/libvirt/images nfs auto 0 0 EOF #
NoteIt is not possible to export a local directory from one host using NFS and mount it at the same path on another host — the directory used for storing disk images must be mounted from shared storage on both hosts. If this is not configured correctly, the guest virtual machine may lose access to its disk images during migration, because the source host's libvirt daemon may change the owner, permissions, and SELinux labels on the disk images after it successfully migrates the guest to its destination.If libvirt detects that the disk images are mounted from a shared storage location, it will not make these changes.
A.19.14. No Guest Virtual Machines are Present when libvirtd is Started
- The libvirt daemon is successfully started, but no guest virtual machines appear to be present.
virsh list --allId Name State ----------------------------------------------------
- There are various possible causes of this problem. Performing these tests will help to determine the cause of this situation:
- Verify KVM kernel modules
- Verify that KVM kernel modules are inserted in the kernel:
lsmod | grep kvmkvm_intel 121346 0 kvm 328927 1 kvm_intelIf you are using an AMD machine, verify the
kvm_amdkernel modules are inserted in the kernel instead, using the similar command
lsmod | grep kvm_amdin the root shell.If the modules are not present, insert them using the
NoteAlthough it is uncommon, KVM virtualization support may be compiled into the kernel. In this case, modules are not needed.
- Verify virtualization extensions
- Verify that virtualization extensions are supported and enabled on the host:
egrep "(vmx|svm)" /proc/cpuinfoflags : fpu vme de pse tsc ... svm ... skinit wdt npt lbrv svm_lock nrip_save flags : fpu vme de pse tsc ... svm ... skinit wdt npt lbrv svm_lock nrip_saveEnable virtualization extensions in your hardware's firmware configuration within the BIOS setup. Refer to your hardware documentation for further details on this.
- Verify client URI configuration
- Verify that the URI of the client is configured as intended:
virsh urivbox:///systemFor example, this message shows the URI is connected to the VirtualBox hypervisor, not QEMU, and reveals a configuration error for a URI that is otherwise set to connect to a QEMU hypervisor. If the URI was correctly connecting to QEMU, the same message would appear instead as:
virsh uriqemu:///systemThis situation occurs when there are other hypervisors present, which libvirt may speak to by default.
- After performing these tests, use the following command to view a list of guest virtual machines:
virsh list --all
A.19.15. unable to connect to server at 'host:16509': Connection refused ... error: failed to connect to the hypervisor
- While libvirtd should listen on TCP ports for connections, the connections fail:
virsh -c qemu+tcp://host/systemerror: failed to connect to the hypervisor error: unable to connect to server at 'host:16509': Connection refusedThe libvirt daemon is not listening on TCP ports even after changing configuration in
grep listen_ /etc/libvirt/libvirtd.conflisten_tls = 1 listen_tcp = 1 listen_addr = "0.0.0.0"However, the TCP ports for libvirt are still not open after changing configuration:
netstat -lntp | grep libvirtd#
- The libvirt daemon was started without the
--listenoption. Verify this by running this command:
ps aux | grep libvirtdroot 10749 0.1 0.2 558276 18280 ? Ssl 23:21 0:00 /usr/sbin/libvirtdThe output does not contain the
- Start the daemon with the
--listenoption.To do this, modify the
/etc/sysconfig/libvirtdfile and uncomment the following line:
# LIBVIRTD_ARGS="--listen"Then, restart the libvirtd service with this command:
/bin/systemctl restart libvirtd.service
A.19.16. Common XML Errors
A.19.16.1. Editing domain definition
virsh edit name_of_guest.xml
virsh edit name_of_guest.xmlDomain name_of_guest.xml XML configuration edited.
editcommand in virsh to edit an XML document, save all changes before exiting the editor.
xmllintcommand to validate that the XML is well-formed, or the
virt-xml-validatecommand to check for usage problems:
xmllint --noout config.xml
- XML documents stored by libvirt
- These documents contain definitions of states and configurations for the guests. These documents are automatically generated and should not be edited manually. Errors in these documents contain the file name of the broken document. The file name is valid only on the host machine defined by the URI, which may refer to the machine the command was run on.Errors in files created by libvirt are rare. However, one possible source of these errors is a downgrade of libvirt — while newer versions of libvirt can always read XML generated by older versions, older versions of libvirt may be confused by XML elements added in a newer version.
A.19.16.2. XML syntax errors
error: (name_of_guest.xml):6: StartTag: invalid element name <vcpu>2</vcpu>< -----------------^
- Information contained in this message:
- This is the file name of the document that contains the error. File names in parentheses are symbolic names to describe XML documents parsed from memory, and do not directly correspond to files on disk. File names that are not contained in parentheses are local files that reside on the target of the connection.
- This is the line number in the XML file that contains the error.
- StartTag: invalid element name
- This is the error message from the libxml2 parser, which describes the specific XML error.
< in the document
- The following error occurs:
error: (name_of_guest.xml):6: StartTag: invalid element name <vcpu>2</vcpu>< -----------------^
- This error message shows that the parser expects a new element name after the
<symbol on line 6 of a guest's XML file.Ensure line number display is enabled in your text editor. Open the XML file, and locate the text on line 6:
<domain type='kvm'> <name>name_of_guest</name> <memory>524288</memory> <vcpu>2</vcpu><This snippet of a guest's XML file contains an extra
<in the document:
- Remove the extra
<or finish the new element.
A.184.108.40.206. Unterminated attribute
- The following error occurs:
error: (name_of_guest.xml):2: Unescaped '<' not allowed in attributes values <name>name_of_guest</name> --^
- This snippet of a guest's XML file contains an unterminated element attribute value:
<domain type='kvm> <name>name_of_guest</name>In this case,
'kvm'is missing a second quotation mark. Strings of attribute values, such as quotation marks and apostrophes, must be opened and closed, similar to XML start and end tags.
- Correctly open and close all attribute value strings.
A.220.127.116.11. Opening and ending tag mismatch
- The following error occurs:
error: (name_of_guest.xml):61: Opening and ending tag mismatch: clock line 16 and domain </domain> ---------^
- The error message above contains three clues to identify the offending tag:The message following the last colon,
clock line 16 and domain, reveals that
<clock>contains a mismatched tag on line 16 of the document. The last hint is the pointer in the context part of the message, which identifies the second offending tag.Unpaired tags must be closed with
/>. The following snippet does not follow this rule and has produced the error message shown above:
<domain type='kvm'> ... <clock offset='utc'>This error is caused by mismatched XML tags in the file. Every XML tag must have a matching start and end tag.
- The following examples produce similar error messages and show variations of mismatched XML tags.This snippet contains an mismatch error for
<features>because there is no end tag (
<domain type='kvm'> ... <features> <acpi/> <pae/> ... </domain>This snippet contains an end tag (
</name>) without a corresponding start tag:
<domain type='kvm'> </name> ... </domain>
- Ensure all XML tags start and end correctly.
A.19.16.3. Logic and configuration errors
A.18.104.22.168. Vanishing parts
- Parts of the change you have made do not show up and have no effect after editing or defining the domain. The
editcommand works, but when dumping the XML once again, the change disappears.
- This error likely results from a broken construct or syntax that libvirt does not parse. The libvirt tool will generally only look for constructs it knows but ignore everything else, resulting in some of the XML changes vanishing after libvirt parses the input.
- Validate the XML input before passing it to the
definecommands. The libvirt developers maintain a set of XML schemas bundled with libvirt that define the majority of the constructs allowed in XML documents used by libvirt.Validate libvirt XML files using the following command:
virt-xml-validate libvirt.xmlIf this command passes, libvirt will likely understand all constructs from your XML, except if the schemas cannot detect options that are valid only for a given hypervisor. For example, any XML generated by libvirt as a result of a
virsh dumpcommand should validate without error.
A.22.214.171.124. Incorrect drive device type
- The definition of the source image for the CD-ROM virtual drive is not present, despite being added:
virsh dumpxml domain<domain type='kvm'> ... <disk type='block' device='cdrom'> <driver name='qemu' type='raw'/> <target dev='hdc' bus='ide'/> <readonly/> </disk> ... </domain>
- Correct the XML by adding the missing
<source>parameter as follows:
<disk type='block' device='cdrom'> <driver name='qemu' type='raw'/> <source file='/path/to/image.iso'/> <target dev='hdc' bus='ide'/> <readonly/> </disk>A
type='block'disk device expects that the source is a physical device. To use the disk with an image file, use