fix #5440: hmp helpers: drive{add, del}: increase timeout

The default timeout for HMP commands is 5 seconds.

While it should be rather fast to attach a new drive to QEMU, a busy
system might take longer, so future-proof and increase to 60 seconds.

On the other hand, detaching a drive needs to complete any pending IO
on it, so use the same 10 minutes timeout that's used for
drive-related QMP commands.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fiona Ebner 2024-05-03 13:19:54 +02:00 committed by Fabian Grünbichler
parent 990e32ff1b
commit daf64a27b9

View File

@ -4380,7 +4380,7 @@ sub qemu_driveadd {
my $io_uring = min_version($kvmver, 6, 0); my $io_uring = min_version($kvmver, 6, 0);
my $drive = print_drive_commandline_full($storecfg, $vmid, $device, undef, $io_uring); my $drive = print_drive_commandline_full($storecfg, $vmid, $device, undef, $io_uring);
$drive =~ s/\\/\\\\/g; $drive =~ s/\\/\\\\/g;
my $ret = PVE::QemuServer::Monitor::hmp_cmd($vmid, "drive_add auto \"$drive\""); my $ret = PVE::QemuServer::Monitor::hmp_cmd($vmid, "drive_add auto \"$drive\"", 60);
# If the command succeeds qemu prints: "OK" # If the command succeeds qemu prints: "OK"
return 1 if $ret =~ m/OK/s; return 1 if $ret =~ m/OK/s;
@ -4391,7 +4391,7 @@ sub qemu_driveadd {
sub qemu_drivedel { sub qemu_drivedel {
my ($vmid, $deviceid) = @_; my ($vmid, $deviceid) = @_;
my $ret = PVE::QemuServer::Monitor::hmp_cmd($vmid, "drive_del drive-$deviceid"); my $ret = PVE::QemuServer::Monitor::hmp_cmd($vmid, "drive_del drive-$deviceid", 10 * 60);
$ret =~ s/^\s+//; $ret =~ s/^\s+//;
return 1 if $ret eq ""; return 1 if $ret eq "";