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 00DAB1FF189
	for <inbox@lore.proxmox.com>; Fri,  4 Apr 2025 14:02:18 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id B5F591D9AC;
	Fri,  4 Apr 2025 14:02:03 +0200 (CEST)
Message-ID: <84975b44-08d5-482b-afd1-246261992ca3@proxmox.com>
Date: Fri, 4 Apr 2025 14:02:00 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
 Dominik Csapak <d.csapak@proxmox.com>
References: <20250307144436.122621-1-d.csapak@proxmox.com>
 <20250307144436.122621-8-d.csapak@proxmox.com>
Content-Language: en-US
From: Fiona Ebner <f.ebner@proxmox.com>
In-Reply-To: <20250307144436.122621-8-d.csapak@proxmox.com>
X-SPAM-LEVEL: Spam detection results:  0
 AWL -1.037 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
 KAM_MAILER                  2 Automated Mailer Tag Left in Email
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [machine.pm]
Subject: Re: [pve-devel] [PATCH qemu-server v2 7/8] api: qemu machine
 capabilities: add custom pveX versions too
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 07.03.25 um 15:44 schrieb Dominik Csapak:
> Add the pveX variants (where X > 0) to the list too, so one knows they
> exits. Also this allows them to be shown and chosen in the UI.
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> new in v2
>  PVE/API2/Qemu/Machine.pm | 24 +++++++++++++++++++++++-
>  1 file changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/PVE/API2/Qemu/Machine.pm b/PVE/API2/Qemu/Machine.pm
> index afb535c2..11eba34b 100644
> --- a/PVE/API2/Qemu/Machine.pm
> +++ b/PVE/API2/Qemu/Machine.pm
> @@ -6,6 +6,7 @@ use warnings;
>  use JSON;
>  
>  use PVE::JSONSchema qw(get_standard_option);
> +use PVE::QemuServer::Machine;
>  use PVE::RESTHandler;
>  use PVE::Tools qw(file_get_contents);
>  
> @@ -51,7 +52,28 @@ __PACKAGE__->register_method({
>      code => sub {
>  	my $machines = eval {

I'd rename the outer variable to $result to avoid the name re-use.

>  	    my $raw = file_get_contents('/usr/share/kvm/machine-versions-x86_64.json');
> -	    return from_json($raw, { utf8 => 1 });
> +	    my $machines = from_json($raw, { utf8 => 1 });
> +
> +	    my $to_add = [];
> +
> +	    for my $machine ($machines->@*) {
> +		my $base_version = $machine->{version};
> +		my $pvever = PVE::QemuServer::Machine::get_pve_version($base_version);
> +		for (my $i = 1; $i <= $pvever; $i++) {
> +		    my $version = $base_version . "+pve$i";
> +		    my $entry = {
> +			id => $machine->{id} . "+pve$i",
> +			type => $machine->{type},
> +			version => $version,
> +		    };
> +
> +		    push $to_add->@*, $entry;
> +		}
> +	    }
> +
> +	    push $machines->@*, $to_add->@*;
> +
> +	    return [sort { $b->{id} cmp $a->{id} } $machines->@*];

Orthogonal to the series, but if you find the time: we should sort
numerically here. It's already broken for 2.10, 2.11, 2.12 and while
those will be gone soon, QEMU 10 will be here soon ;)

>  	};
>  	die "could not load supported machine versions - $@\n" if $@;
>  	return $machines;



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