example_simple.ps1 1.5 KB

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