* [pve-devel] [PATCH-SERIES qemu-server 0/2] fix #6648: api: machine versions: fix ordering
@ 2025-08-11 10:47 Fiona Ebner
2025-08-11 10:47 ` [pve-devel] [PATCH qemu-server 1/2] machine: add extract_version_parts helper Fiona Ebner
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Fiona Ebner @ 2025-08-11 10:47 UTC (permalink / raw)
To: pve-devel
It's necessary to numerically compare versions in machine types.
Fiona Ebner (2):
machine: add extract_version_parts helper
fix #6648: api: machine versions: fix ordering
src/PVE/API2/Qemu/Machine.pm | 6 +++-
src/PVE/QemuServer/Machine.pm | 56 ++++++++++++++++++++++++++++++-----
2 files changed, 54 insertions(+), 8 deletions(-)
--
2.47.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] [PATCH qemu-server 1/2] machine: add extract_version_parts helper
2025-08-11 10:47 [pve-devel] [PATCH-SERIES qemu-server 0/2] fix #6648: api: machine versions: fix ordering Fiona Ebner
@ 2025-08-11 10:47 ` Fiona Ebner
2025-08-11 10:47 ` [pve-devel] [PATCH qemu-server 2/2] fix #6648: api: machine versions: fix ordering Fiona Ebner
2025-08-11 13:03 ` [pve-devel] applied-series: [PATCH-SERIES qemu-server 0/2] " Fabian Grünbichler
2 siblings, 0 replies; 4+ messages in thread
From: Fiona Ebner @ 2025-08-11 10:47 UTC (permalink / raw)
To: pve-devel
Note that the regex is changed to not include the '+pve' part. No
functional change intended.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
src/PVE/QemuServer/Machine.pm | 32 +++++++++++++++++++++++++-------
1 file changed, 25 insertions(+), 7 deletions(-)
diff --git a/src/PVE/QemuServer/Machine.pm b/src/PVE/QemuServer/Machine.pm
index b2bac932..3d98ee0b 100644
--- a/src/PVE/QemuServer/Machine.pm
+++ b/src/PVE/QemuServer/Machine.pm
@@ -156,19 +156,37 @@ sub get_current_qemu_machine {
return current_from_query_machines($res);
}
+=head3 extract_version_parts
+
+ my ($major, $minor, $pve) = extract_version_parts($machine_type);
+
+Returns the major, minor and pve versions from the given C<$machine_type> string. Returns nothing if
+the string did not contain any version or if parsing failed.
+
+=cut
+
+my sub extract_version_parts {
+ my ($machine_type) = @_;
+
+ if ($machine_type =~
+ m/^(?:pc(?:-i440fx|-q35)?|virt)-(\d+)\.(\d+)(?:\.(\d+))?(?:\+pve(\d+))?(?:\.pxe)?/
+ ) {
+ return ($1, $2, $4);
+ }
+ return;
+}
+
# returns a string with major.minor+pve<VERSION>, patch version-part is ignored
# as it's seldom resembling a real QEMU machine type, so it would be '0' 99% of
# the time anyway.. This explicitly separates pveversion from the machine.
sub extract_version {
my ($machine_type, $kvmversion) = @_;
- if (
- defined($machine_type)
- && $machine_type =~
- m/^(?:pc(?:-i440fx|-q35)?|virt)-(\d+)\.(\d+)(?:\.(\d+))?(\+pve\d+)?(?:\.pxe)?/
- ) {
- my $versionstr = "$1.$2";
- $versionstr .= $4 if $4;
+ my ($major, $minor, $pve);
+ ($major, $minor, $pve) = extract_version_parts($machine_type) if defined($machine_type);
+ if (defined($major) && defined($minor)) {
+ my $versionstr = "${major}.${minor}";
+ $versionstr .= "+pve${pve}" if $pve;
return $versionstr;
} elsif (defined($kvmversion)) {
if ($kvmversion =~ m/^(\d+)\.(\d+)/) {
--
2.47.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] [PATCH qemu-server 2/2] fix #6648: api: machine versions: fix ordering
2025-08-11 10:47 [pve-devel] [PATCH-SERIES qemu-server 0/2] fix #6648: api: machine versions: fix ordering Fiona Ebner
2025-08-11 10:47 ` [pve-devel] [PATCH qemu-server 1/2] machine: add extract_version_parts helper Fiona Ebner
@ 2025-08-11 10:47 ` Fiona Ebner
2025-08-11 13:03 ` [pve-devel] applied-series: [PATCH-SERIES qemu-server 0/2] " Fabian Grünbichler
2 siblings, 0 replies; 4+ messages in thread
From: Fiona Ebner @ 2025-08-11 10:47 UTC (permalink / raw)
To: pve-devel
It's necessary to numerically compare versions in machine types, so
introduce a new helper which does that.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
src/PVE/API2/Qemu/Machine.pm | 6 +++++-
src/PVE/QemuServer/Machine.pm | 24 ++++++++++++++++++++++++
2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/src/PVE/API2/Qemu/Machine.pm b/src/PVE/API2/Qemu/Machine.pm
index 41281af2..0fc1ea6c 100644
--- a/src/PVE/API2/Qemu/Machine.pm
+++ b/src/PVE/API2/Qemu/Machine.pm
@@ -81,7 +81,11 @@ __PACKAGE__->register_method({
}
}
- return [sort { $b->{id} cmp $a->{id} } ($machines->@*, $pve_machines->@*)]; # merge & sort
+ return [
+ sort {
+ PVE::QemuServer::Machine::machine_version_cmp($b->{id}, $a->{id})
+ } ($machines->@*, $pve_machines->@*)
+ ]; # merge & sort
};
die "could not load supported machine versions - $@\n" if $@;
return $supported_machine_list;
diff --git a/src/PVE/QemuServer/Machine.pm b/src/PVE/QemuServer/Machine.pm
index 3d98ee0b..9d17344a 100644
--- a/src/PVE/QemuServer/Machine.pm
+++ b/src/PVE/QemuServer/Machine.pm
@@ -198,6 +198,30 @@ sub extract_version {
return;
}
+=head3 machine_version_cmp
+
+ sort { machine_version_cmp($a, $b) } @machine_types
+
+Comparision function for sorting machine types by version.
+
+=cut
+
+sub machine_version_cmp {
+ my ($machine_type_a, $machine_type_b) = @_;
+
+ my ($major_a, $minor_a, $pve_a) = extract_version_parts($machine_type_a);
+ my ($major_b, $minor_b, $pve_b) = extract_version_parts($machine_type_b);
+
+ return PVE::QemuServer::Helpers::version_cmp(
+ $major_a,
+ $major_b,
+ $minor_a,
+ $minor_b,
+ $pve_a,
+ $pve_b,
+ );
+}
+
sub is_machine_version_at_least {
my ($machine_type, $major, $minor, $pve) = @_;
--
2.47.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] applied-series: [PATCH-SERIES qemu-server 0/2] fix #6648: api: machine versions: fix ordering
2025-08-11 10:47 [pve-devel] [PATCH-SERIES qemu-server 0/2] fix #6648: api: machine versions: fix ordering Fiona Ebner
2025-08-11 10:47 ` [pve-devel] [PATCH qemu-server 1/2] machine: add extract_version_parts helper Fiona Ebner
2025-08-11 10:47 ` [pve-devel] [PATCH qemu-server 2/2] fix #6648: api: machine versions: fix ordering Fiona Ebner
@ 2025-08-11 13:03 ` Fabian Grünbichler
2 siblings, 0 replies; 4+ messages in thread
From: Fabian Grünbichler @ 2025-08-11 13:03 UTC (permalink / raw)
To: pve-devel, Fiona Ebner
On Mon, 11 Aug 2025 12:47:11 +0200, Fiona Ebner wrote:
> It's necessary to numerically compare versions in machine types.
>
> Fiona Ebner (2):
> machine: add extract_version_parts helper
> fix #6648: api: machine versions: fix ordering
>
> src/PVE/API2/Qemu/Machine.pm | 6 +++-
> src/PVE/QemuServer/Machine.pm | 56 ++++++++++++++++++++++++++++++-----
> 2 files changed, 54 insertions(+), 8 deletions(-)
>
> [...]
Applied, thanks!
[1/2] machine: add extract_version_parts helper
commit: 9e4210a025d56f90045fd4115c7f436303ee778b
[2/2] fix #6648: api: machine versions: fix ordering
commit: 240f44a369fb6efeb6b8599896f87baf5be6274c
Best regards,
--
Fabian Grünbichler <f.gruenbichler@proxmox.com>
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-08-11 13:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-11 10:47 [pve-devel] [PATCH-SERIES qemu-server 0/2] fix #6648: api: machine versions: fix ordering Fiona Ebner
2025-08-11 10:47 ` [pve-devel] [PATCH qemu-server 1/2] machine: add extract_version_parts helper Fiona Ebner
2025-08-11 10:47 ` [pve-devel] [PATCH qemu-server 2/2] fix #6648: api: machine versions: fix ordering Fiona Ebner
2025-08-11 13:03 ` [pve-devel] applied-series: [PATCH-SERIES qemu-server 0/2] " Fabian Grünbichler
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.