public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
	Dominik Csapak <d.csapak@proxmox.com>
Subject: Re: [pve-devel] [PATCH qemu-server v2 7/8] api: qemu machine capabilities: add custom pveX versions too
Date: Fri, 4 Apr 2025 14:02:00 +0200	[thread overview]
Message-ID: <84975b44-08d5-482b-afd1-246261992ca3@proxmox.com> (raw)
In-Reply-To: <20250307144436.122621-8-d.csapak@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


  reply	other threads:[~2025-04-04 12:02 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-07 14:44 [pve-devel] [PATCH qemu-server/docs v2] disable S3/S4 power states by default Dominik Csapak
2025-03-07 14:44 ` [pve-devel] [PATCH qemu-server v2 1/8] tests: cfg2cmd: add test for windows machine pinning from meta info Dominik Csapak
2025-03-07 14:44 ` [pve-devel] [PATCH qemu-server v2 2/8] config to command: get rid of globalFlags Dominik Csapak
2025-03-07 14:44 ` [pve-devel] [PATCH qemu-server v2 3/8] machine: correctly select pve machine version for non pinned windows guests Dominik Csapak
2025-03-07 14:44 ` [pve-devel] [PATCH qemu-server v2 4/8] machine: incorporate pve machine version when pinning " Dominik Csapak
2025-03-07 14:44 ` [pve-devel] [PATCH qemu-server v2 5/8] machine: add S3/S4 power state properties Dominik Csapak
2025-04-04 11:53   ` Fiona Ebner
2025-03-07 14:44 ` [pve-devel] [PATCH qemu-server v2 6/8] machine: bump pve machine version and reverse the s3/s4 defaults Dominik Csapak
2025-04-04 11:54   ` Fiona Ebner
2025-03-07 14:44 ` [pve-devel] [PATCH qemu-server v2 7/8] api: qemu machine capabilities: add custom pveX versions too Dominik Csapak
2025-04-04 12:02   ` Fiona Ebner [this message]
2025-03-07 14:44 ` [pve-devel] [PATCH qemu-server v2 8/8] api: qemu machine capabilities: add description for pveX variants Dominik Csapak
2025-04-04 12:04   ` Fiona Ebner
2025-04-04 12:24   ` Fiona Ebner
2025-03-07 14:44 ` [pve-devel] [PATCH docs v2 1/1] qm: pve machine version: add section to explain +pveX versions Dominik Csapak
2025-04-04 12:20   ` Fiona Ebner
2025-04-01  9:17 ` [pve-devel] [PATCH qemu-server/docs v2] disable S3/S4 power states by default Dominik Csapak
2025-04-04 12:22 ` Fiona Ebner
2025-04-04 13:23 ` Dominik Csapak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=84975b44-08d5-482b-afd1-246261992ca3@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal