1 <# 2 .Description 3 Runs an ubuntu image. The image itself needs to be built on linux as per instructions at 4 https://crosvm.dev/book/running_crosvm/example_usage.html#preparing-the-guest-os-image 5 6 The console is a pipe at \\.\pipe\crosvm-debug that you can connect to using apps like 7 putty. 8 .PARAMETER IMAGE_DIR 9 Directory where initrd, rootfs and vmlinuz are located. Defaults to user's tmp directory. 10 .PARAMETER LOGS_DIR 11 Directory where logs will be written to. Defaults to user's tmp directory. 12 #> 13 param ( 14 [Parameter( 15 Position = 0 16 )] 17 [string]$IMAGE_DIR = $Env:TEMP, ## 18 [Parameter( 19 Position = 1 20 )] 21 [string]$LOGS_DIR = $Env:TEMP ## 22 ) 23 24 $VMLINUZ = Join-Path $IMAGE_DIR "vmlinuz" 25 $ROOTFS = Join-Path $IMAGE_DIR "rootfs" 26 $INITRD = Join-Path $IMAGE_DIR "initrd" 27 $SERIAL = "\\.\pipe\crosvm-debug" 28 $LOGS_DIR = Join-Path $LOGS_DIR "\" 29 30 $PATHS = $IMAGE_DIR, $VMLINUZ, $ROOTFS, $INITRD, $LOGS_DIR 31 32 foreach ($path in $PATHS) { 33 if (!(Test-Path $path)) { 34 throw (New-Object System.IO.FileNotFoundException("Path not found: $path", $path)) 35 } 36 } 37 38 cargo run --features "all-msvc64,whpx" -- ` 39 --log-level INFO ` 40 run-mp ` 41 --logs-directory $LOGS_DIR ` 42 --cpus 1 ` 43 --mem 4096 ` 44 --serial "hardware=serial,type=namedpipe,path=$SERIAL,num=1,console=true" ` 45 --params "nopat clocksource=jiffies root=/dev/vda5 loglevel=7 console=/dev/ttyS1 console=/dev/ttyS0" ` 46 --host-guid "dontcare" ` 47 --rwdisk $ROOTFS ` 48 --initrd $INITRD ` 49 $VMLINUZ 50