def test_microvm_initrd_with_serial(test_microvm_with_initrd): """ Test that a boot using initrd successfully loads the root filesystem. @type: functional """ vm = test_microvm_with_initrd vm.jailer.daemonize = False vm.spawn() vm.memory_monitor = None vm.basic_config(add_root_device=False, vcpu_count=1, boot_args='console=ttyS0 reboot=k panic=1 pci=off', use_initrd=True) vm.start() serial = Serial(vm) serial.open() serial.rx(token='login: '******'Password: '******'# ') serial.tx("findmnt /") serial.rx(token=f"/ {INITRD_FILESYSTEM} {INITRD_FILESYSTEM}")
def test_microvm_initrd_with_serial( test_microvm_with_initrd): """Check microvm started with an inird has / mounted as rootfs.""" vm = test_microvm_with_initrd vm.jailer.daemonize = False vm.spawn() vm.memory_monitor = None vm.basic_config( add_root_device=False, vcpu_count=1, boot_args='console=ttyS0 reboot=k panic=1 pci=off', use_initrd=True ) vm.start() serial = Serial(vm) serial.open() serial.rx(token='login: '******'Password: '******'# ') serial.tx("findmnt /") serial.rx( token=f"/ {INITRD_FILESYSTEM} {INITRD_FILESYSTEM}")
def test_serial_after_snapshot(bin_cloner_path): """ Serial I/O after restoring from a snapshot. @type: functional """ vm_builder = MicrovmBuilder(bin_cloner_path) vm_instance = vm_builder.build_vm_nano( diff_snapshots=False, daemonize=False, ) microvm = vm_instance.vm root_disk = vm_instance.disks[0] ssh_key = vm_instance.ssh_key microvm.start() serial = Serial(microvm) serial.open() # Image used for tests on aarch64 has autologon if platform.machine() == "x86_64": serial.rx(token="login: "******"root") serial.rx("Password: "******"root") # Make sure that at the time we snapshot the vm, the user is logged in. serial.rx("#") snapshot_builder = SnapshotBuilder(microvm) disks = [root_disk.local_path()] # Create diff snapshot. snapshot = snapshot_builder.create(disks, ssh_key, SnapshotType.FULL) # Kill base microVM. microvm.kill() # Load microVM clone from snapshot. test_microvm, _ = vm_builder.build_from_snapshot(snapshot, resume=True, diff_snapshots=False, daemonize=False) serial = Serial(test_microvm) serial.open() # We need to send a newline to signal the serial to flush # the login content. serial.tx("") serial.rx("#") serial.tx("pwd") res = serial.rx("#") assert "/root" in res