inline create_test_machine again
This commit is contained in:
@@ -175,7 +175,29 @@
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
from nixos_test_lib.ssh import setup_test_environment # type: ignore[import-untyped]
|
from nixos_test_lib.ssh import setup_test_environment # type: ignore[import-untyped]
|
||||||
from nixos_test_lib.machine import create_test_machine # type: ignore[import-untyped]
|
|
||||||
|
def create_test_machine(oldmachine, qemu_test_bin: str, **kwargs):
|
||||||
|
"""Create a new test machine from an installed disk image"""
|
||||||
|
start_command = [
|
||||||
|
f"{qemu_test_bin}/bin/qemu-kvm",
|
||||||
|
"-cpu",
|
||||||
|
"max",
|
||||||
|
"-m",
|
||||||
|
"3048",
|
||||||
|
"-virtfs",
|
||||||
|
"local,path=/nix/store,security_model=none,mount_tag=nix-store",
|
||||||
|
"-drive",
|
||||||
|
f"file={oldmachine.state_dir}/target.qcow2,id=drive1,if=none,index=1,werror=report",
|
||||||
|
"-device",
|
||||||
|
"virtio-blk-pci,drive=drive1",
|
||||||
|
"-netdev",
|
||||||
|
"user,id=net0",
|
||||||
|
"-device",
|
||||||
|
"virtio-net-pci,netdev=net0",
|
||||||
|
]
|
||||||
|
machine = create_machine(start_command=" ".join(start_command), **kwargs)
|
||||||
|
driver.machines.append(machine)
|
||||||
|
return machine
|
||||||
|
|
||||||
target.start()
|
target.start()
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
"""VM machine management utilities"""
|
|
||||||
|
|
||||||
|
|
||||||
def create_test_machine(oldmachine, qemu_test_bin: str, **kwargs):
|
|
||||||
"""Create a new test machine from an installed disk image"""
|
|
||||||
start_command = [
|
|
||||||
f"{qemu_test_bin}/bin/qemu-kvm",
|
|
||||||
"-cpu",
|
|
||||||
"max",
|
|
||||||
"-m",
|
|
||||||
"3048",
|
|
||||||
"-virtfs",
|
|
||||||
"local,path=/nix/store,security_model=none,mount_tag=nix-store",
|
|
||||||
"-drive",
|
|
||||||
f"file={oldmachine.state_dir}/target.qcow2,id=drive1,if=none,index=1,werror=report",
|
|
||||||
"-device",
|
|
||||||
"virtio-blk-pci,drive=drive1",
|
|
||||||
"-netdev",
|
|
||||||
"user,id=net0",
|
|
||||||
"-device",
|
|
||||||
"virtio-net-pci,netdev=net0",
|
|
||||||
]
|
|
||||||
machine = create_machine(start_command=" ".join(start_command), **kwargs)
|
|
||||||
driver.machines.append(machine)
|
|
||||||
return machine
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
"""VM machine management utilities"""
|
|
||||||
|
|
||||||
|
|
||||||
def create_test_machine(oldmachine, qemu_test_bin: str, **kwargs):
|
|
||||||
"""Create a new test machine from an installed disk image"""
|
|
||||||
start_command = [
|
|
||||||
f"{qemu_test_bin}/bin/qemu-kvm",
|
|
||||||
"-cpu",
|
|
||||||
"max",
|
|
||||||
"-m",
|
|
||||||
"3048",
|
|
||||||
"-virtfs",
|
|
||||||
"local,path=/nix/store,security_model=none,mount_tag=nix-store",
|
|
||||||
"-drive",
|
|
||||||
f"file={oldmachine.state_dir}/target.qcow2,id=drive1,if=none,index=1,werror=report",
|
|
||||||
"-device",
|
|
||||||
"virtio-blk-pci,drive=drive1",
|
|
||||||
"-netdev",
|
|
||||||
"user,id=net0",
|
|
||||||
"-device",
|
|
||||||
"virtio-net-pci,netdev=net0",
|
|
||||||
]
|
|
||||||
machine = create_machine(start_command=" ".join(start_command), **kwargs)
|
|
||||||
driver.machines.append(machine)
|
|
||||||
return machine
|
|
||||||
Reference in New Issue
Block a user