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>
This commit is contained in:
Vikram Auradkar 2023-12-14 13:53:54 -08:00 committed by crosvm LUCI
parent b7cb5c3573
commit fa539725eb
4 changed files with 88 additions and 26 deletions

View file

@ -701,31 +701,35 @@ fn run_internal(mut cfg: Config, log_args: LogArgs) -> Result<()> {
)?;
#[cfg(feature = "gpu")]
let _gpu_child = if !cfg
.vhost_user
.iter()
.any(|opt| opt.type_ == DeviceType::Gpu)
{
// Pass both backend and frontend configs to main process.
cfg.gpu_backend_config = Some(gpu_cfg.0);
cfg.gpu_vmm_config = Some(gpu_cfg.1);
None
let _gpu_child = if let Some(gpu_cfg) = gpu_cfg {
if !cfg
.vhost_user
.iter()
.any(|opt| opt.type_ == DeviceType::Gpu)
{
// Pass both backend and frontend configs to main process.
cfg.gpu_backend_config = Some(gpu_cfg.0);
cfg.gpu_vmm_config = Some(gpu_cfg.1);
None
} else {
Some(start_up_gpu(
&mut cfg,
&log_args,
gpu_cfg,
&mut input_event_split_config,
&mut main_child,
&mut children,
&mut wait_ctx,
&mut metric_tubes,
window_procedure_thread_builder
.take()
.ok_or_else(|| anyhow!("window_procedure_thread_builder is missing."))?,
#[cfg(feature = "process-invariants")]
&process_invariants,
)?)
}
} else {
Some(start_up_gpu(
&mut cfg,
&log_args,
gpu_cfg,
&mut input_event_split_config,
&mut main_child,
&mut children,
&mut wait_ctx,
&mut metric_tubes,
window_procedure_thread_builder
.take()
.ok_or_else(|| anyhow!("window_procedure_thread_builder is missing."))?,
#[cfg(feature = "process-invariants")]
&process_invariants,
)?)
None
};
#[cfg(feature = "gpu")]
@ -1740,7 +1744,10 @@ fn platform_create_gpu(
exit_evt_wrtube: SendTube,
gpu_control_host_tube: Tube,
gpu_control_device_tube: Tube,
) -> Result<(GpuBackendConfig, GpuVmmConfig)> {
) -> Result<Option<(GpuBackendConfig, GpuVmmConfig)>> {
if cfg.gpu_parameters.is_none() {
return Ok(None);
}
let exit_event = Event::new().exit_context(Exit::CreateEvent, "failed to create exit event")?;
exit_events.push(
exit_event
@ -1770,7 +1777,7 @@ fn platform_create_gpu(
product_config: vmm_config_product,
};
Ok((backend_config, vmm_config))
Ok(Some((backend_config, vmm_config)))
}
#[cfg(feature = "gpu")]

View file

@ -2252,6 +2252,7 @@ pub fn run_config_for_broker(raw_tube_transporter: RawDescriptor) -> Result<Exit
.recv::<Event>()
.exit_context(Exit::TubeFailure, "failed to read bootstrap tube")?,
);
#[cfg(feature = "crash-report")]
let crash_tube_map = bootstrap_tube
.recv::<HashMap<ProcessType, Vec<SendTube>>>()
.exit_context(Exit::TubeFailure, "failed to read bootstrap tube")?;

View file

@ -3,13 +3,16 @@
// found in the LICENSE file.
use std::collections::BTreeMap;
use std::thread;
use std::thread::JoinHandle;
use std::time::Duration;
use anyhow::Result;
use arch::RunnableLinuxVm;
use arch::VcpuArch;
use arch::VirtioDeviceStub;
use arch::VmArch;
use base::info;
use base::AsRawDescriptor;
use base::CloseNotifier;
use base::Event;
@ -296,6 +299,8 @@ pub(super) fn virtio_sound_enabled() -> bool {
}
pub(crate) fn run_metrics(_args: RunMetricsCommand) -> Result<()> {
info!("sleep forever. We will get killed by broker");
thread::sleep(Duration::MAX);
Ok(())
}

View file

@ -0,0 +1,49 @@
<#
.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