[pve-devel] [PATCH v3 qemu-server 04/11] blockdev: vm_devices_list : fix block-query

DERUMIER, Alexandre alexandre.derumier at groupe-cyllene.com
Mon Jan 13 08:56:03 CET 2025


-------- Message initial --------
De: Fabian Grünbichler <f.gruenbichler at proxmox.com>
À: Proxmox VE development discussion <pve-devel at lists.proxmox.com>
Cc: Alexandre Derumier <alexandre.derumier at groupe-cyllene.com>
Objet: Re: [pve-devel] [PATCH v3 qemu-server 04/11] blockdev:
vm_devices_list : fix block-query
Date: 08/01/2025 15:31:36


> Alexandre Derumier via pve-devel <pve-devel at lists.proxmox.com> hat am
> 16.12.2024 10:12 CET geschrieben:

> Look at qdev value, as cdrom drives can be empty
> without any inserted media


>>is this needed if we don't drive_del the cdrom drive when ejecting
>>the medium?

The original code is buggy for me, because vm_devices_list should list
devices (the media device reder), not (drives/blockdev) -> the media

we can't list an an empty device without media without this.


(We don't drive_del the cdrom drive(device), they are ide devices,
and can't be removed online)

> 
> Signed-off-by: Alexandre Derumier <alexandre.derumier at groupe-
> cyllene.com>
> ---
>  PVE/QemuServer.pm | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index baf78ec0..3b33fd7d 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -4425,10 +4425,9 @@ sub vm_devices_list {
>      }
>  
>      my $resblock = mon_cmd($vmid, 'query-block');
> -    foreach my $block (@$resblock) {
> - if($block->{device} =~ m/^drive-(\S+)/){
> - $devices->{$1} = 1;
> - }
> +    $resblock = { map { $_->{qdev} => $_ } $resblock->@* };
> +    foreach my $blockid (keys %$resblock) {
> + $devices->{$blockid} = 1;
>      }
>  
>      my $resmice = mon_cmd($vmid, 'query-mice');
> -- 
> 2.39.5




More information about the pve-devel mailing list