public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server 5/6] test: migration: mock get_current_qemu_machine
Date: Fri, 10 Nov 2023 14:24:50 +0100	[thread overview]
Message-ID: <20231110132451.67482-7-f.ebner@proxmox.com> (raw)
In-Reply-To: <20231110132451.67482-1-f.ebner@proxmox.com>

by remembering the 'forcemachine' parameter that's passed along when
starting the target instance.

In preparation to introduce a call to get_current_qemu_machine after
starting a VM to check for machine version deprecation.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 test/MigrationTest/QmMock.pm | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/test/MigrationTest/QmMock.pm b/test/MigrationTest/QmMock.pm
index e34686e3..fb94c58b 100644
--- a/test/MigrationTest/QmMock.pm
+++ b/test/MigrationTest/QmMock.pm
@@ -23,6 +23,7 @@ my $migrate_params = decode_json(file_get_contents("${RUN_DIR_PATH}/migrate_para
 my $nodename = $migrate_params->{target};
 
 my $kvm_exectued = 0;
+my $forcemachine;
 
 sub setup_environment {
     my $rpcenv = PVE::RPCEnvironment::init('MigrationTest::QmMock', 'cli');
@@ -56,6 +57,12 @@ $MigrationTest::Shared::qemu_server_module->mock(
     config_to_command => sub {
 	return [ 'mocked_kvm_command' ];
     },
+    vm_start_nolock => sub {
+	my ($storecfg, $vmid, $conf, $params, $migrate_opts) = @_;
+	$forcemachine = $params->{forcemachine}
+	    or die "mocked vm_start_nolock - expected 'forcemachine' parameter\n";
+	$MigrationTest::Shared::qemu_server_module->original('vm_start_nolock')->(@_);
+    },
 );
 
 my $qemu_server_helpers_module = Test::MockModule->new("PVE::QemuServer::Helpers");
@@ -65,6 +72,13 @@ $qemu_server_helpers_module->mock(
     },
 );
 
+our $qemu_server_machine_module = Test::MockModule->new("PVE::QemuServer::Machine");
+$qemu_server_machine_module->mock(
+    get_current_qemu_machine => sub {
+	return wantarray ? ($forcemachine, 0) : $forcemachine;
+    },
+);
+
 # to make sure we get valid and predictable names
 my $disk_counter = 10;
 
-- 
2.39.2





  parent reply	other threads:[~2023-11-10 13:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-10 13:24 [pve-devel] [PATCH-SERIES docs/qemu-server] machine version information Fiona Ebner
2023-11-10 13:24 ` [pve-devel] [PATCH docs 1/1] qm: add section about machine types Fiona Ebner
2023-11-10 13:24 ` [pve-devel] [PATCH qemu-server 1/6] machine: get current: improve naming and style Fiona Ebner
2023-11-10 13:24 ` [pve-devel] [PATCH qemu-server 2/6] machine: get current: make it clear that pve-version only exists for the current machine Fiona Ebner
2023-11-10 13:24 ` [pve-devel] [PATCH qemu-server 3/6] machine: get current: return early from loop if possible Fiona Ebner
2023-11-10 13:24 ` [pve-devel] [PATCH qemu-server 4/6] machine: get current: add flag if current machine is deprecated in list context Fiona Ebner
2023-11-10 13:24 ` Fiona Ebner [this message]
2023-11-10 13:24 ` [pve-devel] [PATCH qemu-server 6/6] vm start: add warning about deprecated machine version Fiona Ebner
2023-11-12 18:11 ` [pve-devel] applied-series: [PATCH-SERIES docs/qemu-server] machine version information Thomas Lamprecht

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=20231110132451.67482-7-f.ebner@proxmox.com \
    --to=f.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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal