[pve-devel] [PATCH qemu-server 5/6] test: migration: mock get_current_qemu_machine
Fiona Ebner
f.ebner at proxmox.com
Fri Nov 10 14:24:50 CET 2023
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 at 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
More information about the pve-devel
mailing list