KVM - virsh autostart has stopped working

Hi All,

Currently running Clear Linux 39920.
Seems like somethings happened to virtual machine autostart? Worked in previous 38xxx version.

I tried disabling and removing files from /etc/libvirt/qemu/autostart but have had no luck? anyone able to test this see if they get the same result. I have two systems running this version with the same problem. Rebooting server does not bring the VMs back online.

Kind Regards

Hi Again,
I removed ClearLinux from my NUC a while back because of this issue. Today I decided to retry with the latest version. Still not working?

Output as shown autostart is enabled but the VM just does not come up after reboot? any ideas?

kvmadm@kvm03~ $ virsh list --all
 Id   Name   State
-----------------------
 -    gns3   shut off

kvmadm@kvm03~ $ virsh dominfo gns3
Id:             -
Name:           gns3
UUID:           12951fde-072e-48b4-90e1-b7eda544ce0d
OS Type:        hvm
State:          shut off
CPU(s):         2
Max memory:     16777216 KiB
Used memory:    16777216 KiB
Persistent:     yes
Autostart:      enable
Managed save:   no
Security model: none
Security DOI:   0

Hi All,

Been reading through many forums & posts without much luck but I’ve tracked it down to an error with Openvswitch. Seems like the bridge is not available at the time of boot.

Oct 28 20:45:14 dkvm03 libvirtd[451]: internal error: Failed to autostart VM 'gns3': Cannot get interface MTU on 'ovs-br0': No such device

The bridge is definitely there and working, as the vm runs if manually started. I could not find a way to delay the VM autostart which is weird for a hypervisor.

5: ovs-br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether 38:14:28:31:a6:be brd ff:ff:ff:ff:ff:ff

Still seeing if there is a resolution - any ideas would be welcome!

If possible, you can try to add a delay to the VM autostart process.

In the VM’s XML configuration file, you can add:


<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<boot dev='hd'/>
<bootdelay>10</bootdelay>

Hi Businux,

I searched all over for something like this, and got directed down all sorts of rabbit holes. Thanks will give that a go!

Cheers!

Hi Businux,

Nah, that element does not exist.

root@dkvm03/ # virsh edit gns3
error: XML document failed to validate against schema: Unable to validate doc against /usr/share/libvirt/schemas/domain.rng
Element domain has extra content: bootdelay

I do know there is a daemon called libvirt-guests.service that helps suspend and startup VMs on host shutdown… but I’ve never needed to use this before to get autostart to work? If I try enable it on ClearLinux the service just fails - maybe because it can’t locate the configuration.

libvirt-guests.service config is located on some systems under /etc/sysconfig/libvirt-guests but under ClearLinux I have no idea where it would look to check the config.

Under this file there is a START_DELAY option?

Thanks

sudo swupd bundle-add containers-basic kvm-host
sudo systemctl enable libvirtd libvirt-guests

I used to do this for lxc without any configuration files

if you’re looking for default configs, you can try looking under /usr/share/defaults/etc/
but any of the files there are overridden if you introduce a config to /etc/

Hi Kingfisher,
when I check the libvirt-guest service status I get the following error.

Oct 30 13:12:07 clrkvm01 systemd[1]: Starting libvirt-guests.service...
Oct 30 13:12:07 clrkvm01 libvirt-guests.sh[22299]: touch: cannot touch '/var/lock/subsys/libvirt-guests': No such file or directory
Oct 30 13:12:07 clrkvm01 systemd[1]: Finished libvirt-guests.service.

Regards

Ok resolved that issue by creating the missing folder.

sudo mkdir -p /var/lock/subsys

Cheers

No luck. Seems not to like it :frowning:

Oct 30 14:29:50 clrkvm01 systemd-machined[400]: New machine qemu-1-gns3.
░░ The virtual machine qemu-1-gns3 with its leader PID 1352 has been
Oct 30 14:29:50 clrkvm01 systemd[1]: Started machine-qemu\x2d1\x2dgns3.scope.
░░ Subject: A start job for unit machine-qemu\x2d1\x2dgns3.scope has finished successfully
░░ A start job for unit machine-qemu\x2d1\x2dgns3.scope has finished successfully.
Oct 30 14:30:40 clrkvm01 libvirt-guests.sh[1565]: gns3
Oct 30 14:30:40 clrkvm01 libvirt-guests.sh[1565]: Suspending gns3: ...
Oct 30 14:30:42 clrkvm01 systemd[1]: machine-qemu\x2d1\x2dgns3.scope: Deactivated successfully.
░░ The unit machine-qemu\x2d1\x2dgns3.scope has successfully entered the 'dead' state.
Oct 30 14:30:42 clrkvm01 systemd[1]: Stopped machine-qemu\x2d1\x2dgns3.scope.
░░ Subject: A stop job for unit machine-qemu\x2d1\x2dgns3.scope has finished
░░ A stop job for unit machine-qemu\x2d1\x2dgns3.scope has finished.
Oct 30 14:30:42 clrkvm01 systemd[1]: machine-qemu\x2d1\x2dgns3.scope: Consumed 14.743s CPU time.
░░ The unit machine-qemu\x2d1\x2dgns3.scope completed and consumed the indicated resources.
Oct 30 14:31:00 clrkvm01 libvirtd[435]: Unable to restore from managed state /var/lib/libvirt/qemu/save/gns3.save. Maybe the file is corrupted?
Oct 30 14:31:00 clrkvm01 libvirt-guests.sh[660]: Resuming guest gns3:
Oct 30 14:31:00 clrkvm01 libvirt-guests.sh[665]: error: Failed to start domain 'gns3'

Cheers

If I reboot the folder above disappears and kills the process? how does one make this persistent in CL

So I to get around the folder disappearing I hacked the libvirt-guest.service

modified

VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/subsys/libvirt-guests

to

VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/libvirt-guests

Although when rebooting and have a VM running I get this issue…

kvmadm@clrkvm01~ $ systemctl status libvirt-guests.service
× libvirt-guests.service - libvirt guests suspend/resume service
     Loaded: loaded (/usr/lib/systemd/system/libvirt-guests.service; enabled; preset: disabled)
     Active: failed (Result: exit-code) since Wed 2024-10-30 15:07:04 AEDT; 28s ago
       Docs: man:libvirt-guests(8)
             https://libvirt.org/
    Process: 394 ExecStart=/usr/libexec/libvirt-guests.sh start (code=exited, status=1/FAILURE)
   Main PID: 394 (code=exited, status=1/FAILURE)
        CPU: 66ms

Oct 30 15:07:03 clrkvm01 systemd[1]: Starting libvirt-guests.service...
Oct 30 15:07:03 clrkvm01 libvirt-guests.sh[667]: Resuming guests on default URI...
Oct 30 15:07:04 clrkvm01 libvirt-guests.sh[678]: Resuming guest gns3:
Oct 30 15:07:04 clrkvm01 libvirt-guests.sh[683]: error: Failed to start domain 'gns3'
Oct 30 15:07:04 clrkvm01 libvirt-guests.sh[683]: error: internal error: process exited while connecting to monitor: 2024-10-30T04:07:04.023930Z qemu-system-x86_64: warning: Spice: reds>
Oct 30 15:07:04 clrkvm01 libvirt-guests.sh[683]: 2024-10-30T04:07:04.023950Z qemu-system-x86_64: warning: Spice: reds.c:3512:do_spice_init: Failed to open SPICE sockets
Oct 30 15:07:04 clrkvm01 libvirt-guests.sh[683]: 2024-10-30T04:07:04.023956Z qemu-system-x86_64: failed to initialize spice server
Oct 30 15:07:04 clrkvm01 systemd[1]: libvirt-guests.service: Main process exited, code=exited, status=1/FAILURE
Oct 30 15:07:04 clrkvm01 systemd[1]: libvirt-guests.service: Failed with result 'exit-code'.
Oct 30 15:07:04 clrkvm01 systemd[1]: Failed to start libvirt-guests.service.

Kind Regards

So I fixed the next issue found that this is a ancient bug.
Found Reddit - Dive into anything

virsh edit gns3

<graphics type='spice' autoport='yes' listen='0.0.0.0'>
      <listen type='address' address='0.0.0.0'/>
      <image compression='off'/>
    </graphics>

To

<graphics type='spice' autoport='yes' listen='::1'>
      <listen type='address' address='::1'/>
      <image compression='off'/>
    </graphics>

Why is this a problem in ClearLinux and not Debian am I missing some package?

I just can’t win - now getting the following issue :frowning:

kvmadm@clrkvm01~ $ systemctl status libvirt-guests.service
× libvirt-guests.service - libvirt guests suspend/resume service
     Loaded: loaded (/usr/lib/systemd/system/libvirt-guests.service; enabled; preset: disabled)
     Active: failed (Result: exit-code) since Wed 2024-10-30 15:31:12 AEDT; 1min 19s ago
       Docs: man:libvirt-guests(8)
             https://libvirt.org/
    Process: 395 ExecStart=/usr/libexec/libvirt-guests.sh start (code=exited, status=1/FAILURE)
   Main PID: 395 (code=exited, status=1/FAILURE)
        CPU: 62ms

Oct 30 15:31:12 clrkvm01 systemd[1]: Starting libvirt-guests.service...
Oct 30 15:31:12 clrkvm01 libvirt-guests.sh[672]: Resuming guests on default URI...
Oct 30 15:31:12 clrkvm01 libvirt-guests.sh[691]: Resuming guest gns3:
Oct 30 15:31:12 clrkvm01 libvirt-guests.sh[699]: error: Failed to start domain 'gns3'
Oct 30 15:31:12 clrkvm01 libvirt-guests.sh[699]: error: Cannot get interface MTU on 'ovs-br0': No such device
Oct 30 15:31:12 clrkvm01 systemd[1]: libvirt-guests.service: Main process exited, code=exited, status=1/FAILURE
Oct 30 15:31:12 clrkvm01 systemd[1]: libvirt-guests.service: Failed with result 'exit-code'.
Oct 30 15:31:12 clrkvm01 systemd[1]: Failed to start libvirt-guests.service.

I have no idea why, but somehow I have it working, yet I still have errors!!

So I created the folder /etc/sysconfig and create file libvirt-guests with the following configuration

I uncommented START_DELAY=20 and SHUTDOWN_TIMEOUT=300 which is default.

# Customizations for the libvirt-guests.service systemd unit

# URIs to check for running guests
# example: URIS='default xen:///system vbox+tcp://host/system lxc:///system'
#URIS=default

# action taken on host boot
# - start   all guests which were running on shutdown are started on boot
#           regardless on their autostart settings
# - ignore  libvirt-guests init script won't start any guest on boot, however,
#           guests marked as autostart will still be automatically started by
#           libvirtd
#ON_BOOT=ignore

# Number of seconds to wait between each guest start. Set to 0 to allow
# parallel startup.
START_DELAY=20

# action taken on host shutdown
# - suspend   all running guests are suspended using virsh managedsave
# - shutdown  all running guests are asked to shutdown. Please be careful with
#             this settings since there is no way to distinguish between a
#             guest which is stuck or ignores shutdown requests and a guest
#             which just needs a long time to shutdown. When setting
#             ON_SHUTDOWN=shutdown, you must also set SHUTDOWN_TIMEOUT to a
#             value suitable for your guests.
#ON_SHUTDOWN=shutdown

# Number of guests will be shutdown concurrently, taking effect when
# "ON_SHUTDOWN" is set to "shutdown". If Set to 0, guests will be shutdown one
# after another. Number of guests on shutdown at any time will not exceed number
# set in this variable.
#PARALLEL_SHUTDOWN=0

# Number of seconds we're willing to wait for a guest to shut down. If parallel
# shutdown is enabled, this timeout applies as a timeout for shutting down all
# guests on a single URI defined in the variable URIS. If this is 0, then there
# is no time out (use with caution, as guests might not respond to a shutdown
# request). The default value is 300 seconds (5 minutes).
SHUTDOWN_TIMEOUT=300

# If non-zero, try to bypass the file system cache when saving and
# restoring guests, even though this may give slower operation for
# some file systems.
#BYPASS_CACHE=0

# If non-zero, try to sync guest time on domain resume. Be aware, that
# this requires guest agent with support for time synchronization
# running in the guest. By default, this functionality is turned off.
#SYNC_TIME=1

Somehow my VM is now starting after a reboot, which is great, but I still have weird errors about corrupt save file, tainted CPU, and missing openvswitch bridge?

Oct 30 16:57:29 clrkvm01 libvirt-guests.sh[1518]: gns3
Oct 30 16:57:29 clrkvm01 libvirt-guests.sh[1518]: Suspending gns3: ...
Oct 30 16:57:31 clrkvm01 systemd[1]: machine-qemu\x2d2\x2dgns3.scope: Deactivated successfully.
░░ The unit machine-qemu\x2d2\x2dgns3.scope has successfully entered the 'dead' state.
Oct 30 16:57:31 clrkvm01 systemd[1]: Stopped machine-qemu\x2d2\x2dgns3.scope.
░░ Subject: A stop job for unit machine-qemu\x2d2\x2dgns3.scope has finished
░░ A stop job for unit machine-qemu\x2d2\x2dgns3.scope has finished.
Oct 30 16:57:31 clrkvm01 systemd[1]: machine-qemu\x2d2\x2dgns3.scope: Consumed 19.475s CPU time.
░░ The unit machine-qemu\x2d2\x2dgns3.scope completed and consumed the indicated resources.
Oct 30 16:57:47 clrkvm01 libvirtd[484]: Unable to restore from managed state /var/lib/libvirt/qemu/save/gns3.save. Maybe the file is corrupted?
Oct 30 16:57:47 clrkvm01 libvirtd[484]: internal error: Failed to autostart VM 'gns3': Cannot get interface MTU on 'ovs-br0': No such device
Oct 30 16:57:47 clrkvm01 libvirtd[484]: Domain id=2 name='gns3' uuid=647bb888-2786-4ae6-a031-ad8c3bf624af is tainted: host-cpu
Oct 30 16:57:47 clrkvm01 systemd-machined[400]: New machine qemu-2-gns3.
░░ The virtual machine qemu-2-gns3 with its leader PID 789 has been
Oct 30 16:57:47 clrkvm01 systemd[1]: Started machine-qemu\x2d2\x2dgns3.scope.
░░ Subject: A start job for unit machine-qemu\x2d2\x2dgns3.scope has finished successfully
░░ A start job for unit machine-qemu\x2d2\x2dgns3.scope has finished successfully.
Oct 30 16:57:49 clrkvm01 libvirt-guests.sh[749]: Resuming guest gns3:

Well I think I solved my issue - for me anyway… not sure about saving and resuming VMs but all I need is for the VM to start. I got rid of the errors by disabling vm saving.

Answer was to do the following.

 virsh managedsave-remove --domain gns3

Thanks