crosvm/tools/examples/example_simple.ps1
Vikram Auradkar fa539725eb tools: add simple windows example script
Makes gpu argument optional

BUG=b:316406247
TEST=ran the script on windows

Change-Id: I08e7961f2477ee56ad162420a99c469e3f4c7b1b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5124591
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
2024-01-27 06:17:57 +00:00

49 lines
1.5 KiB
PowerShell

<#
.Description
Runs an ubuntu image. The image itself needs to be built on linux as per instructions at
https://crosvm.dev/book/running_crosvm/example_usage.html#preparing-the-guest-os-image
The console is a pipe at \\.\pipe\crosvm-debug that you can connect to using apps like
putty.
.PARAMETER IMAGE_DIR
Directory where initrd, rootfs and vmlinuz are located. Defaults to user's tmp directory.
.PARAMETER LOGS_DIR
Directory where logs will be written to. Defaults to user's tmp directory.
#>
param (
[Parameter(
Position = 0
)]
[string]$IMAGE_DIR = $Env:TEMP, ##
[Parameter(
Position = 1
)]
[string]$LOGS_DIR = $Env:TEMP ##
)
$VMLINUZ = Join-Path $IMAGE_DIR "vmlinuz"
$ROOTFS = Join-Path $IMAGE_DIR "rootfs"
$INITRD = Join-Path $IMAGE_DIR "initrd"
$SERIAL = "\\.\pipe\crosvm-debug"
$LOGS_DIR = Join-Path $LOGS_DIR "\"
$PATHS = $IMAGE_DIR, $VMLINUZ, $ROOTFS, $INITRD, $LOGS_DIR
foreach ($path in $PATHS) {
if (!(Test-Path $path)) {
throw (New-Object System.IO.FileNotFoundException("Path not found: $path", $path))
}
}
cargo run --features "all-msvc64,whpx" -- `
--log-level INFO `
run-mp `
--logs-directory $LOGS_DIR `
--cpus 1 `
--mem 4096 `
--serial "hardware=serial,type=namedpipe,path=$SERIAL,num=1,console=true" `
--params "nopat clocksource=jiffies root=/dev/vda5 loglevel=7 console=/dev/ttyS1 console=/dev/ttyS0" `
--host-guid "dontcare" `
--rwdisk $ROOTFS `
--initrd $INITRD `
$VMLINUZ