Verification done on jammy-proposed. ---
Part 1: comment #2, libvirt starts without errors, and can list and manage the domain. Part 2: comment #5, libvirt restarts without errors 100 times with 10 domains.
Environment: ---
LXD virtual machine
lxc launch --vm ubuntu:jammy lp2059272-jammy lxc exec lp2059272-jammy -- su - ubuntu
Enable -proposed
sudo add-apt-repository -yp proposed
cat <<EOF | sudo tee /etc/apt/preferences.d/proposed Package: * Pin: release a=jammy-proposed Pin-Priority: 400 EOF
Install
sudo apt install -y -t jammy-proposed libvirt-daemon libvirt-daemon-system libvirt-daemon-driver-qemu sudo apt install -y gdb qemu-system-x86
$ apt-cache policy libvirt-daemon libvirt-daemon: Installed: 8.0.0-1ubuntu7.9 Candidate: 8.0.0-1ubuntu7.9 Version table: *** 8.0.0-1ubuntu7.9 400 400 http://security.ubuntu.com/ubuntu jammy-proposed/main amd64 Packages 400 http://archive.ubuntu.com/ubuntu jammy-proposed/main amd64 Packages 100 /var/lib/dpkg/status 8.0.0-1ubuntu7.8 500 500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages 8.0.0-1ubuntu7.5 500 500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages 8.0.0-1ubuntu7 500 500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
Part 1: ---
GDB ...
Check there are 2 threads: cleanup and domain status XML save
(gdb) i th Id Target Id Frame 1 Thread 0x7fe039120ac0 (LWP 3405) "libvirtd" qemuStateCleanup () at ../../src/qemu/qemu_driver.c:1070 18 Thread 0x7fe00ffff640 (LWP 3425) "gmain" (running) 19 Thread 0x7fe00f7fe640 (LWP 3426) "gdbus" (running) 20 Thread 0x7fe00effd640 (LWP 3473) "udev-event" (running) 24 Thread 0x7fe014e07640 (LWP 3600) "vm-test-vm" (running) 25 Thread 0x7fe00dffb640 (LWP 3620) "qemu-event" virDomainObjSave (obj=0x7fe028301a30, xmlopt=0x7fe028040010, statusDir=0x7fe0280373b0 "/run/libvirt/qemu") at ../../src/conf/domain_conf.c:28879
Confirm the qemu driver's domain xml formatter/options is set/referenced:
(gdb) t 25
(gdb) p xmlopt.privateData.format $1 = (virDomainXMLPrivateDataFormatFunc) 0x7fe0176b4da0 <qemuDomainObjPrivateXMLFormat>
(gdb) p xmlopt.parent.parent_instance $2 = {g_type_instance = {g_class = 0x7fe02806cf20}, ref_count = 1, qdata = 0x0}
Let the cleanup function and shutdown path finish
(gdb) t 1 (gdb) c &
Check the formatter/options again; it is *STILL* referenced:
(gdb) p xmlopt.privateData.format $3 = (virDomainXMLPrivateDataFormatFunc) 0x7fe0176b4da0 <qemuDomainObjPrivateXMLFormat>
(gdb) p xmlopt.parent.parent_instance $4 = {g_type_instance = {g_class = 0x7fe02806cf20}, ref_count = 1, qdata = 0x0}
Check the VM status XML *before* the save function finishes:
$ sudo grep -e '<domstatus' -e '<domain' -e 'monitor path' /run/libvirt/qemu/test-vm.xml <domstatus state='running' reason='booted' pid='3597'> <monitor path='/var/lib/libvirt/qemu/domain-1-test-vm/monitor.sock' type='unix'/> <domain type='qemu' id='1'>
Let the save function continue, and libvirt finishes shutting down:
(gdb) c ... [Inferior 1 (process 3405) exited normally]
Check the VM status XML *after*:
It *CONTINUES* to have the 'monitor path' tag/field.
Now, the next time libvirtd starts, it *CORRECTLY* parses that XML:
$ sudo systemctl start libvirtd.service $ journalctl -b -u libvirtd.service | tail | grep error $
And libvirt is now aware of the domain, and can manage it:
$ virsh list Id Name State ------------------------- 1 test-vm running
$ virsh destroy test-vm Domain 'test-vm' destroyed
Part 2: ---
$ for i in {1..100}; do echo restart $i; sudo systemctl restart libvirtd.service; sleep 10; done restart 1 restart 2 restart 3 ... restart 98 restart 99 restart 100
No errors:
$ journalctl -b -u libvirtd.service | grep -v -e 'systemd' -e 'hostname:' | cut -d' ' -f7- | sort | uniq -c | sort -rn 106 /var/lib/libvirt/dnsmasq/default.hostsfile 106 /var/lib/libvirt/dnsmasq/default.addnhosts - 0 names 106 /etc/hosts - 8 names
Verification done on jammy-proposed.
---
Part 1: comment #2, libvirt starts without errors, and can list and manage the domain.
Part 2: comment #5, libvirt restarts without errors 100 times with 10 domains.
Environment:
---
LXD virtual machine
lxc launch --vm ubuntu:jammy lp2059272-jammy
lxc exec lp2059272-jammy -- su - ubuntu
Enable -proposed
sudo add-apt-repository -yp proposed
cat <<EOF | sudo tee /etc/apt/ preferences. d/proposed
Package: *
Pin: release a=jammy-proposed
Pin-Priority: 400
EOF
Install
sudo apt install -y -t jammy-proposed libvirt-daemon libvirt- daemon- system libvirt- daemon- driver- qemu
sudo apt install -y gdb qemu-system-x86
$ apt-cache policy libvirt-daemon security. ubuntu. com/ubuntu jammy-proposed/main amd64 Packages archive. ubuntu. com/ubuntu jammy-proposed/main amd64 Packages dpkg/status 0.0-1ubuntu7. 8 500 archive. ubuntu. com/ubuntu jammy-updates/main amd64 Packages 0.0-1ubuntu7. 5 500 security. ubuntu. com/ubuntu jammy-security/main amd64 Packages 0.0-1ubuntu7 500 archive. ubuntu. com/ubuntu jammy/main amd64 Packages
libvirt-daemon:
Installed: 8.0.0-1ubuntu7.9
Candidate: 8.0.0-1ubuntu7.9
Version table:
*** 8.0.0-1ubuntu7.9 400
400 http://
400 http://
100 /var/lib/
8.
500 http://
8.
500 http://
8.
500 http://
Part 1:
---
GDB
...
Check there are 2 threads: cleanup and domain status XML save
(gdb) i th qemu/qemu_ driver. c:1070 1a30, xmlopt= 0x7fe028040010, statusDir= 0x7fe0280373b0 "/run/libvirt/ qemu") at ../../src/ conf/domain_ conf.c: 28879
Id Target Id Frame
1 Thread 0x7fe039120ac0 (LWP 3405) "libvirtd" qemuStateCleanup () at ../../src/
18 Thread 0x7fe00ffff640 (LWP 3425) "gmain" (running)
19 Thread 0x7fe00f7fe640 (LWP 3426) "gdbus" (running)
20 Thread 0x7fe00effd640 (LWP 3473) "udev-event" (running)
24 Thread 0x7fe014e07640 (LWP 3600) "vm-test-vm" (running)
25 Thread 0x7fe00dffb640 (LWP 3620) "qemu-event" virDomainObjSave (obj=0x7fe02830
Confirm the qemu driver's domain xml formatter/options is set/referenced:
(gdb) t 25
(gdb) p xmlopt. privateData. format ivateDataFormat Func) 0x7fe0176b4da0 <qemuDomainObjP rivateXMLFormat >
$1 = (virDomainXMLPr
(gdb) p xmlopt. parent. parent_ instance
$2 = {g_type_instance = {g_class = 0x7fe02806cf20}, ref_count = 1, qdata = 0x0}
Let the cleanup function and shutdown path finish
(gdb) t 1
(gdb) c &
(gdb) t 25
Check the formatter/options again; it is *STILL* referenced:
(gdb) p xmlopt. privateData. format ivateDataFormat Func) 0x7fe0176b4da0 <qemuDomainObjP rivateXMLFormat >
$3 = (virDomainXMLPr
(gdb) p xmlopt. parent. parent_ instance
$4 = {g_type_instance = {g_class = 0x7fe02806cf20}, ref_count = 1, qdata = 0x0}
Check the VM status XML *before* the save function finishes:
$ sudo grep -e '<domstatus' -e '<domain' -e 'monitor path' /run/libvirt/ qemu/test- vm.xml var/lib/ libvirt/ qemu/domain- 1-test- vm/monitor. sock' type='unix'/>
<domstatus state='running' reason='booted' pid='3597'>
<monitor path='/
<domain type='qemu' id='1'>
Let the save function continue, and libvirt finishes shutting down:
(gdb) c
...
[Inferior 1 (process 3405) exited normally]
Check the VM status XML *after*:
$ sudo grep -e '<domstatus' -e '<domain' -e 'monitor path' /run/libvirt/ qemu/test- vm.xml var/lib/ libvirt/ qemu/domain- 1-test- vm/monitor. sock' type='unix'/>
<domstatus state='running' reason='booted' pid='3597'>
<monitor path='/
<domain type='qemu' id='1'>
It *CONTINUES* to have the 'monitor path' tag/field.
Now, the next time libvirtd starts, it *CORRECTLY* parses that XML:
$ sudo systemctl start libvirtd.service
$ journalctl -b -u libvirtd.service | tail | grep error
$
And libvirt is now aware of the domain, and can manage it:
$ virsh list ------- ------- -----
Id Name State
------
1 test-vm running
$ virsh destroy test-vm
Domain 'test-vm' destroyed
Part 2:
---
$ for i in {1..100}; do echo restart $i; sudo systemctl restart libvirtd.service; sleep 10; done
restart 1
restart 2
restart 3
...
restart 98
restart 99
restart 100
No errors:
$ journalctl -b -u libvirtd.service | grep -v -e 'systemd' -e 'hostname:' | cut -d' ' -f7- | sort | uniq -c | sort -rn libvirt/ dnsmasq/ default. hostsfile libvirt/ dnsmasq/ default. addnhosts - 0 names
106 /var/lib/
106 /var/lib/
106 /etc/hosts - 8 names