Signed-off-by: Fiona Ebner <f.eb...@proxmox.com> --- PVE/QemuServer.pm | 10 +--------- PVE/QemuServer/Drive.pm | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index a2e51849..b9705367 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -1492,15 +1492,7 @@ sub print_drive_commandline_full { if !defined($drive->{media}) && defined($vtype) && $vtype eq 'iso'; if (!drive_is_cdrom($drive)) { - my $detectzeroes; - if (defined($drive->{detect_zeroes}) && !$drive->{detect_zeroes}) { - $detectzeroes = 'off'; - } elsif ($drive->{discard}) { - $detectzeroes = $drive->{discard} eq 'on' ? 'unmap' : 'on'; - } else { - # This used to be our default with discard not being specified: - $detectzeroes = 'on'; - } + my $detectzeroes = PVE::QemuServer::Drive::detect_zeroes_cmdline_option($drive); # note: 'detect-zeroes' works per blockdev and we want it to persist # after the alloc-track is removed, so put it on 'file' directly diff --git a/PVE/QemuServer/Drive.pm b/PVE/QemuServer/Drive.pm index f7611662..aaa0ef0b 100644 --- a/PVE/QemuServer/Drive.pm +++ b/PVE/QemuServer/Drive.pm @@ -1034,4 +1034,20 @@ sub aio_cmdline_option { } } +# must not be called for CD-ROMs +sub detect_zeroes_cmdline_option { + my ($drive) = @_; + + die "cannot use detect-zeroes for CD-ROM\n" if drive_is_cdrom($drive); + + if (defined($drive->{detect_zeroes}) && !$drive->{detect_zeroes}) { + return 'off'; + } elsif ($drive->{discard}) { + return $drive->{discard} eq 'on' ? 'unmap' : 'on'; + } + + # This used to be our default with discard not being specified: + return 'on'; +} + 1; -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel