From: Christian Ebner <c.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH v2 qemu-server 2/5] helpers: optionally get package version for kvm_user_version()
Date: Wed, 19 Aug 2026 16:46:39 +0200 [thread overview]
Message-ID: <20260819144642.453513-3-c.ebner@proxmox.com> (raw)
In-Reply-To: <20260819144642.453513-1-c.ebner@proxmox.com>
Allows to specify whether to return the binary version or the package
version by adding a flag to kvm_user_version(). This will allow
comparing the package version including it's revision when the binary
version is not enough.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
changes:
- new in version 2
src/PVE/QemuServer/Helpers.pm | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/src/PVE/QemuServer/Helpers.pm b/src/PVE/QemuServer/Helpers.pm
index dd17eef5..658400f2 100644
--- a/src/PVE/QemuServer/Helpers.pm
+++ b/src/PVE/QemuServer/Helpers.pm
@@ -53,30 +53,40 @@ my $kvm_user_version = {};
my $kvm_mtime = {};
sub kvm_user_version {
- my ($binary) = @_;
+ my ($binary, $query_package_version) = @_;
$binary //= get_command_for_arch(get_host_arch()); # get the native arch by default
my $st = stat($binary);
my $cachedmtime = $kvm_mtime->{$binary} // -1;
- return $kvm_user_version->{$binary}
- if $kvm_user_version->{$binary}
- && $cachedmtime == $st->mtime;
+ my $version_type = $query_package_version ? 'package' : 'version';
+ if ($kvm_user_version->{$binary}->{$version_type} && $cachedmtime == $st->mtime) {
+ return $kvm_user_version->{$binary}->{$version_type};
+ }
- $kvm_user_version->{$binary} = 'unknown';
+ $kvm_user_version->{$binary} = {
+ version => 'unknown',
+ package => 'unknown',
+ };
$kvm_mtime->{$binary} = $st->mtime;
+ my $version_regex = '(\d+\.\d+(\.\d+)?)(\.\d+)?';
my $code = sub {
my $line = shift;
- if ($line =~ m/^QEMU( PC)? emulator version (\d+\.\d+(\.\d+)?)(\.\d+)?[,\s]/) {
- $kvm_user_version->{$binary} = $2;
+ if ($line =~
+ m/^QEMU( PC)? emulator version $version_regex[,\s]\(pve-qemu-kvm_($version_regex-\d+)\)/
+ ) {
+ $kvm_user_version->{$binary} = {
+ version => $2,
+ package => $5,
+ };
}
};
eval { PVE::Tools::run_command([$binary, '--version'], outfunc => $code); };
warn $@ if $@;
- return $kvm_user_version->{$binary};
+ return $kvm_user_version->{$binary}->{$version_type};
}
# Paths and directories
--
2.47.3
next prev parent reply other threads:[~2026-08-19 14:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 14:46 [PATCH v2 qemu-server 0/5] bypass host page cache for restore on zvol Christian Ebner
2026-08-19 14:46 ` [PATCH v2 pve-qemu 1/5] add optional no-cache flag to bypass host page cache on pbs-restore Christian Ebner
2026-08-19 16:44 ` Fiona Ebner
2026-08-19 14:46 ` Christian Ebner [this message]
2026-08-19 16:37 ` [PATCH v2 qemu-server 2/5] helpers: optionally get package version for kvm_user_version() Fiona Ebner
2026-08-19 14:46 ` [PATCH v2 qemu-server 3/5] helpers: add helper for min package version comparison Christian Ebner
2026-08-19 16:37 ` Fiona Ebner
2026-08-19 14:46 ` [PATCH v2 qemu-server 4/5] pbs-restore: set 'no-cache' on block devices backed by zfspool Christian Ebner
2026-08-19 14:46 ` [PATCH v2 qemu-server 5/5] vma restore: skip page cache " Christian Ebner
2026-08-19 16:44 ` [PATCH v2 qemu-server 0/5] bypass host page cache for restore on zvol Jonas Theisen
2026-08-20 9:06 ` Christian Ebner
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=20260819144642.453513-3-c.ebner@proxmox.com \
--to=c.ebner@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