abbbi / virtnbdbackup

Backup utility for Libvirt / qemu / kvm supporting incremental and differential backups + instant recovery (agentless).
http://libvirtbackup.grinser.de/
GNU General Public License v3.0
330 stars 46 forks source link

libvirtError('virDomainGetAutostart() failed') #198

Closed Unclezz closed 2 months ago

Unclezz commented 2 months ago

Hello I am trying to use the script on a Debian 12.6. All the VMs were created/managed using Cockpit.

I launched the backup with folliwing command:

$ sudo virtnbdbackup -d -l auto -o /Backup/VM1

At the end of the process I got the following error:


[2024-08-03 12:33:45] INFO root metadata - backupDiskInfo [main]:  Saved qcow image config to: [/DEBSER2_BACKUP/DEBSER2_BACKUP/Home_Assistant//vda.virtnbdbackup.0.qcow.json]
Traceback (most recent call last):
  File "/usr/bin/virtnbdbackup", line 493, in <module>
    main()
  File "/usr/bin/virtnbdbackup", line 471, in main
    if domObj.autostart() == 1:
       ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/libvirt.py", line 741, in autostart
    raise libvirtError('virDomainGetAutostart() failed')
libvirt.libvirtError: Cannot write data: Broken pipe

If I check the directory, it seems that all backup files are there. To mention that I am creating the backup on a NFS mounted directory.

Is the above an error I should care about? The Guest saved is Home Assistant and it should be also coming with qemu-guest embedded.

Thanks!

abbbi commented 2 months ago

This Looks very Strange. It fails to get the Information wether if domain autostart setting is configured and the libvirt daemon resets the connection because the api call fails

Please Check your libvirt logs and try to get this setting via virsh.. there is something wrong on libvirt side

while it would be possible to submit Code to catch this error i would First like to know what causes it bcs ive Never Seen this issue Happening before

Unclezz commented 2 months ago

Checked libvirt logs and I do not see anything wrong. I am thinking if this is caused by some weird configuration of the restart behavior set by Cockpit...

abbbi commented 2 months ago

The autostart setting is ususally stored in /etc/libvirt/qemu/autostart/

Afairc its just a file named like the vm

Could be Cockpit machines does something wrong here, the api call shouldnt fail this way

Unclezz commented 2 months ago

I am checking on a different VM while tail -f logs. Will also check the autostart stuff. Will keep you posted.

abbbi commented 2 months ago

Details of the Cockpit implementation

https://bugzilla.redhat.com/show_bug.cgi?id=1670491

abbbi commented 2 months ago

this is what it looks like if i use cockpit-machines to set the autostart setting (debian 12)

root@radiohead ~/virtnbdbackup (master)$ ls -alh /etc/libvirt/qemu/autostart/
lrwxrwxrwx 1 root root   31 Aug  3 14:04 archlinux.xml -> /etc/libvirt/qemu/archlinux.xml
root@radiohead ~/virtnbdbackup (master)$ 

Its basically just a symlink to the vm configuration.

 virsh dominfo archlinux | grep ^Autostart
Autostart:      enable
 virsh autostart archlinux
Domain 'archlinux' marked as autostarted

and the backup works w/o issues:

[2024-08-03 14:04:58] INFO root metadata - backupAutoStart [main]:  Autostart setting configured for virtual machine.
[..]
[2024-08-03 14:04:58] INFO root virtnbdbackup - main [main]:  Finished successfully
Unclezz commented 2 months ago

I think there was a glitch. Because I am arranging backups without issues as well. Now everything is finishing w/o errors.

Weird!

But thanks a lot for looking into this one in real time :)