From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH qemu-server v3 2/3] move get_running_qemu_version to QMPHelpers
Date: Tue, 30 Jun 2026 13:04:38 +0200 [thread overview]
Message-ID: <20260630110446.314299-3-m.sandoval@proxmox.com> (raw)
In-Reply-To: <20260630110446.314299-1-m.sandoval@proxmox.com>
We will add a new helper for retrieving the package version in the next
commit and it makes sense to keep them together.
Since the fn is in a different module now one also needs to add it to
the mock modules. This will be relevant in the next commit when
query-version is called as part of VM startup.
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
src/PVE/QemuServer.pm | 9 ++-------
src/PVE/QemuServer/QMPHelpers.pm | 6 ++++++
src/test/MigrationTest/QmMock.pm | 5 +++++
3 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index cdf66e89..12ac5d2d 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -89,7 +89,8 @@ use PVE::QemuServer::OVMF;
use PVE::QemuServer::PCI qw(print_pci_addr print_pcie_addr print_pcie_root_port parse_hostpci);
use PVE::QemuServer::PCI::Mdev;
use PVE::QemuServer::QemuImage;
-use PVE::QemuServer::QMPHelpers qw(qemu_deviceadd qemu_devicedel qemu_objectadd qemu_objectdel);
+use PVE::QemuServer::QMPHelpers
+ qw(get_running_qemu_version qemu_deviceadd qemu_devicedel qemu_objectadd qemu_objectdel);
use PVE::QemuServer::QSD;
use PVE::QemuServer::RNG qw(parse_rng print_rng_device_commandline print_rng_object_commandline);
use PVE::QemuServer::RunState;
@@ -8062,12 +8063,6 @@ no_data_clone:
return $disk;
}
-sub get_running_qemu_version {
- my ($vmid) = @_;
- my $res = mon_cmd($vmid, "query-version");
- return "$res->{qemu}->{major}.$res->{qemu}->{minor}";
-}
-
sub qemu_use_old_bios_files {
my ($machine_type) = @_;
diff --git a/src/PVE/QemuServer/QMPHelpers.pm b/src/PVE/QemuServer/QMPHelpers.pm
index b4c6d1e7..4275ebb2 100644
--- a/src/PVE/QemuServer/QMPHelpers.pm
+++ b/src/PVE/QemuServer/QMPHelpers.pm
@@ -8,6 +8,7 @@ use PVE::QemuServer::Monitor qw(mon_cmd);
use base 'Exporter';
our @EXPORT_OK = qw(
+ get_running_qemu_version
qemu_deviceadd
qemu_devicedel
qemu_objectadd
@@ -18,6 +19,11 @@ sub nbd_stop($vmid) {
mon_cmd($vmid, 'nbd-server-stop', timeout => 25);
}
+sub get_running_qemu_version($vmid) {
+ my $res = mon_cmd($vmid, 'query-version');
+ return "$res->{qemu}->{major}.$res->{qemu}->{minor}";
+}
+
sub qemu_deviceadd($vmid, $devicefull) {
$devicefull = "driver=" . $devicefull;
diff --git a/src/test/MigrationTest/QmMock.pm b/src/test/MigrationTest/QmMock.pm
index c6fc1f50..8f8899dc 100644
--- a/src/test/MigrationTest/QmMock.pm
+++ b/src/test/MigrationTest/QmMock.pm
@@ -82,6 +82,11 @@ $qemu_server_helpers_module->mock(
},
);
+my $qemu_server_qmp_helpers_module = Test::MockModule->new("PVE::QemuServer::QMPHelpers");
+$qemu_server_qmp_helpers_module->mock(
+ mon_cmd => \&mocked_mon_cmd,
+);
+
my $qemu_server_runstate_module = Test::MockModule->new("PVE::QemuServer::RunState");
$qemu_server_runstate_module->mock(
get_cleanup_flag_path => sub {
--
2.47.3
next prev parent reply other threads:[~2026-06-30 11:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 11:04 [PATCH qemu-server v3 0/3] vm start: log qemu version when starting a VM Maximiliano Sandoval
2026-06-30 11:04 ` [PATCH qemu-server v3 1/3] test: mock query-version qmp command Maximiliano Sandoval
2026-06-30 11:04 ` Maximiliano Sandoval [this message]
2026-06-30 11:04 ` [PATCH qemu-server v3 3/3] vm start: log qemu version when starting a VM Maximiliano Sandoval
2026-07-03 13:17 ` applied: [PATCH qemu-server v3 0/3] " Fiona 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=20260630110446.314299-3-m.sandoval@proxmox.com \
--to=m.sandoval@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