vmstate: improve cleaning up dbus-vmstate and avoid spurious warning

First, moving to vm_stop_cleanup(), which is a better fit for this.
It gets called by the cleanup API method in case of unclean shutdown or
from inside the guest.

In every case, the dbus-vmstate daemon should _never_ be running at this
point, as it is started only before migration and stopped directly after
migration, before vm_stop_cleanup() is even called. So it should only be
left running in case of a crash during migration.

Calling it anyway here ensures that the daemon is always (cleanly) shut
down. As the dbus-vmstate is part of the VM scope unit, that would it
tear it down too as a last resort.

Fixes the following spurious warning when a VM was shutdown from inside
the guest:

  `failed to retrieve org.qemu.VMState1 owners: org.freedesktop.DBus.Error.NameHasNoOwner: Could not get owners of name 'org.qemu.VMState1': no such name`

Reported-by: Hannes Duerr <h.duerr@proxmox.com>
Reported-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Link: https://lore.proxmox.com/20250804133002.1625925-1-c.heiss@proxmox.com
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Christoph Heiss 2025-08-04 15:29:56 +02:00 committed by Thomas Lamprecht
parent 43513e14ac
commit 067a0f55bb
2 changed files with 2 additions and 3 deletions

View File

@ -1056,9 +1056,6 @@ __PACKAGE__->register_method({
PVE::QemuServer::vm_stop_cleanup($storecfg, $vmid, $conf, 0, 0, 1);
}
# ensure that no dbus-vmstate helper is left running in any case
PVE::QemuServer::DBusVMState::qemu_del_dbus_vmstate($vmid);
PVE::GuestHelpers::exec_hookscript($conf, $vmid, 'post-stop');
$restart = eval { PVE::QemuServer::clear_reboot_request($vmid) };

View File

@ -6102,6 +6102,8 @@ sub vm_stop_cleanup {
my ($storecfg, $vmid, $conf, $keepActive, $apply_pending_changes, $noerr) = @_;
eval {
# ensure that no dbus-vmstate helper is left running in any case
PVE::QemuServer::DBusVMState::qemu_del_dbus_vmstate($vmid, quiet => $noerr);
if (!$keepActive) {
my $vollist = get_vm_volumes($conf);