[pve-devel] [PATCH v3 qemu-server 05/11] blockdev: convert cdrom media eject/insert

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Jan 8 15:34:07 CET 2025


> Alexandre Derumier via pve-devel <pve-devel at lists.proxmox.com> hat am 16.12.2024 10:12 CET geschrieben:
> Signed-off-by: Alexandre Derumier <alexandre.derumier at groupe-cyllene.com>
> ---
>  PVE/QemuServer.pm | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 3b33fd7d..758c8240 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -5694,7 +5694,10 @@ sub vmconfig_update_disk {
>  	} else { # cdrom
>  
>  	    if ($drive->{file} eq 'none') {
> -		mon_cmd($vmid, "eject", force => JSON::true, id => "$opt");
> +		mon_cmd($vmid, "blockdev-open-tray", force => JSON::true, id => $opt);
> +		mon_cmd($vmid, "blockdev-remove-medium", id => $opt);
> +		qemu_drivedel($vmid, $opt);

the drivedel here

> +
>  		if (drive_is_cloudinit($old_drive)) {
>  		    vmconfig_register_unused_drive($storecfg, $vmid, $conf, $old_drive);
>  		}
> @@ -5702,14 +5705,16 @@ sub vmconfig_update_disk {
>  		my $path = get_iso_path($storecfg, $vmid, $drive->{file});
>  
>  		# force eject if locked
> -		mon_cmd($vmid, "eject", force => JSON::true, id => "$opt");
> +		mon_cmd($vmid, "blockdev-open-tray", force => JSON::true, id => $opt);
> +		mon_cmd($vmid, "blockdev-remove-medium", id => $opt);
> +		eval { qemu_drivedel($vmid, $opt) };

and here

>  
>  		if ($path) {
> -		    mon_cmd($vmid, "blockdev-change-medium",
> -			id => "$opt", filename => "$path");
> +		    qemu_driveadd($storecfg, $vmid, $drive);

and the driveadd here seem kind of weird..

are they really needed (also see comments on other patches)?

> +		    mon_cmd($vmid, "blockdev-insert-medium", id => $opt, 'node-name' => "drive-$opt");
> +		    mon_cmd($vmid, "blockdev-close-tray", id => $opt);
>  		}
>  	    }
> -
>  	    return 1;
>  	}
>      }
> -- 
> 2.39.5




More information about the pve-devel mailing list