From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9])
	by lore.proxmox.com (Postfix) with ESMTPS id 67BFF1FF15E
	for <inbox@lore.proxmox.com>; Tue, 17 Jun 2025 16:44:23 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 51E6330B61;
	Tue, 17 Jun 2025 16:44:50 +0200 (CEST)
Message-ID: <32bb3b1b-f74c-459f-9454-a451ba46059f@proxmox.com>
Date: Tue, 17 Jun 2025 16:44:16 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
From: Fiona Ebner <f.ebner@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
References: <20250603075558.627850-1-alexandre.derumier@groupe-cyllene.com>
 <mailman.205.1748937402.395.pve-devel@lists.proxmox.com>
Content-Language: en-US
In-Reply-To: <mailman.205.1748937402.395.pve-devel@lists.proxmox.com>
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.033 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: Re: [pve-devel] [PATCH qemu-server 03/13] blockdev: vm_devices_list
 : fix block-query
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

Am 03.06.25 um 09:55 schrieb Alexandre Derumier via pve-devel:
> 
> Look at qdev value, as cdrom drives can be empty
> without any inserted media
> 
> Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
> ---
>  PVE/QemuServer.pm | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index a27dcabb..b15b05aa 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -4061,11 +4061,22 @@ sub vm_devices_list {
>  	$devices_to_check = $to_check;
>      }
>  
> +    # block devices need to be queried at qdev level, as a device
> +    # don't always have a blockdev drive media attached (cdrom for example).
> +    # Also top node of the graph could have a different name than the device
> +    # (we still use "drive-$deviceid" for throttle filter, but it's not 100% safe
> +    # if we change that in the future
>      my $resblock = mon_cmd($vmid, 'query-block');
>      foreach my $block (@$resblock) {
> -	if($block->{device} =~ m/^drive-(\S+)/){

But this is already looking at the device ID, not the block node
name. AFAICS, the function does always work for -drive, but never for
-blockdev, regardless of the presence of a media. So I'm a bit confused
by the comment and commit message.

That said, the change itself looks good to me. I slightly adapted it and
will pick it up for v2 of the preparatory series with the following
commit message:

vm devices list: prepare querying block device names for -blockdev

Look at the 'qdev' value, because the 'device' property is not
initialized with '-blockdev'. This can be seen in the QEMU source code
(the device property is the name of the block backend and blk->name is
assigned a value only in a code path reached via drive_new()). This
most likely was done to avoid confusion/clashes, since with
'-blockdev', the node that's inserted for a front-end device can
change and then both the block backend and the node would be named
the same, but not connected.

> -		$devices->{$1} = 1;
> -	}
> +	my $qdev_id = $block->{qdev};
> +	if ($qdev_id =~ m|^/machine/peripheral/(virtio(\d+))/virtio-backend$|) {
> +	    $qdev_id = $1;
> +	} elsif ($qdev_id =~ m|^/machine/system.flash0$|) {
> +	    $qdev_id = 'pflash0';
> +	} elsif ($qdev_id =~ m|^/machine/system.flash1$|) {
> +	    $qdev_id = 'efidisk0';
> +	}
> +	$devices->{$qdev_id} = 1 if $qdev_id;
>      }
>  
>      my $resmice = mon_cmd($vmid, 'query-mice');
> -- 
> 2.39.5
> 
> 



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel