]> git.proxmox.com Git - qemu-server.git/commitdiff
fix #4372: fix vm_resume migration callback
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Tue, 29 Nov 2022 12:09:26 +0000 (13:09 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 30 Nov 2022 15:21:39 +0000 (16:21 +0100)
the fix for the recently introduced requirement of loading the VM config while
migrating was incomplete, since the vmlist node value could already be out of
date by the time load_config is called.

extend the fallback behaviour even further, by doing the following sequence:
- try regular load_config (likely case, rename already fully processed)
- if it fails, get node from vmlist, and load_config using that
- it that fails, invalidate the PVE::Cluster cache, retry regular load_config

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
PVE/QemuServer.pm

index a746b3ddaf4fd1c0253303eaf4e953ff225572e4..a52a883eb29d3744deb7c68e37844013c1d2761b 100644 (file)
@@ -6377,12 +6377,18 @@ sub vm_resume {
        my $reset = 0;
        my $conf;
        if ($nocheck) {
-           my $vmlist = PVE::Cluster::get_vmlist();
-           my $node;
-           if (exists($vmlist->{ids}->{$vmid})) {
-               $node = $vmlist->{ids}->{$vmid}->{node};
+           $conf = eval { PVE::QemuConfig->load_config($vmid) }; # try on target node
+           if ($@) {
+               my $vmlist = PVE::Cluster::get_vmlist();
+               if (exists($vmlist->{ids}->{$vmid})) {
+                   my $node = $vmlist->{ids}->{$vmid}->{node};
+                   $conf = eval { PVE::QemuConfig->load_config($vmid, $node) }; # try on source node
+               }
+               if (!$conf) {
+                   PVE::Cluster::cfs_update(); # vmlist was wrong, invalidate cache
+                   $conf = PVE::QemuConfig->load_config($vmid); # last try on target node again
+               }
            }
-           $conf = PVE::QemuConfig->load_config($vmid, $node);
        } else {
            $conf = PVE::QemuConfig->load_config($vmid);
        }