From ca6abacf6b12bb20f23576bcb829f1d934768075 Mon Sep 17 00:00:00 2001 From: Tim Marx Date: Fri, 3 May 2019 14:22:39 +0200 Subject: [PATCH] migrate: log which local resource causes error Signed-off-by: Tim Marx --- PVE/QemuMigrate.pm | 6 +++--- PVE/QemuServer.pm | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm index e915a9a..bc83816 100644 --- a/PVE/QemuMigrate.pm +++ b/PVE/QemuMigrate.pm @@ -218,10 +218,10 @@ sub prepare { $self->{forcemachine} = PVE::QemuServer::qemu_machine_pxe($vmid, $conf); } - - if (my $loc_res = PVE::QemuServer::check_local_resources($conf, 1)) { + my $loc_res = PVE::QemuServer::check_local_resources($conf, 1); + if (scalar @$loc_res) { if ($self->{running} || !$self->{opts}->{force}) { - die "can't migrate VM which uses local devices\n"; + die "can't migrate VM which uses local devices: " . join(", ", @$loc_res) . "\n"; } else { $self->log('info', "migrating VM which uses local devices"); } diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index ee4fbd3..9d560ec 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -2846,23 +2846,23 @@ sub config_list { sub check_local_resources { my ($conf, $noerr) = @_; - my $loc_res = 0; + my @loc_res = (); - $loc_res = 1 if $conf->{hostusb}; # old syntax - $loc_res = 1 if $conf->{hostpci}; # old syntax + push @loc_res, "hostusb" if $conf->{hostusb}; # old syntax + push @loc_res, "hostpci" if $conf->{hostpci}; # old syntax - $loc_res = 1 if $conf->{ivshmem}; + push @loc_res, "ivshmem" if $conf->{ivshmem}; foreach my $k (keys %$conf) { next if $k =~ m/^usb/ && ($conf->{$k} eq 'spice'); # sockets are safe: they will recreated be on the target side post-migrate next if $k =~ m/^serial/ && ($conf->{$k} eq 'socket'); - $loc_res = 1 if $k =~ m/^(usb|hostpci|serial|parallel)\d+$/; + push @loc_res, $k if $k =~ m/^(usb|hostpci|serial|parallel)\d+$/; } - die "VM uses local resources\n" if $loc_res && !$noerr; + die "VM uses local resources\n" if scalar @loc_res && !$noerr; - return $loc_res; + return \@loc_res; } # check if used storages are available on all nodes (use by migrate) -- 2.39.2