From 96670745a62412ddbb4f66ded1789fc855fbf8c4 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 2 May 2022 13:28:03 +0200 Subject: [PATCH] api: reassign disk: drop moved disk from boot order Reported-by: Matthias Heiserer Signed-off-by: Thomas Lamprecht --- PVE/API2/Qemu.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 06780918..a8246574 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -3879,6 +3879,13 @@ __PACKAGE__->register_method({ $drive->{file} = $new_volid; + my $boot_order = PVE::QemuServer::device_bootorder($source_conf); + if (defined(delete $boot_order->{$disk})) { + print "removing disk '$disk' from boot order config\n"; + my $boot_devs = [ sort { $boot_order->{$a} <=> $boot_order->{$b} } keys %$boot_order ]; + $source_conf->{boot} = PVE::QemuServer::print_bootorder($boot_devs); + } + delete $source_conf->{$disk}; print "removing disk '${disk}' from VM '${vmid}' config\n"; PVE::QemuConfig->write_config($vmid, $source_conf);