Skip to content

Commit

Permalink
runtime: use device serial for storage identification
Browse files Browse the repository at this point in the history
* Assign serial numbers of the form vol-{k} to identify external
  storage.
* Emit command line parameters vol-{k}-path=.. and vol-{k}-errors for
  each of the external drives.
* Split tmpfs specification into vol-{k}-path=.. and vol-{k}-size.
* Assign serial `vol-nvidia` to the nvidia files drive.
* Don't emit command line nvidia=true
  • Loading branch information
kamirr committed Aug 27, 2024
1 parent 9c9513d commit 7ca1a03
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions runtime/src/vmrt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,46 +102,48 @@ pub async fn start_vmrt(
"virtserialport,chardev=manager_cdev,name=manager_port",
"-drive",
format!(
"file={},cache=unsafe,readonly=on,format=raw,if=virtio",
"file={},cache=unsafe,readonly=on,format=raw,id=rootfs,if=none",
deployment.task_package.display()
)
.as_str(),
"-device",
format!("virtio-blk-pci,drive=rootfs,serial=rootfs").as_str(),

Check failure on line 110 in runtime/src/vmrt.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

useless use of `format!`
"-no-reboot",
]);

let mut vol_idx = 0;
let mut dev_idx = 0;
for DeploymentMount {
name,
guest_path,
mount,
} in &deployment.mounts
for (
vol_idx,
DeploymentMount {
name,
guest_path,
mount,
},
) in deployment.mounts.iter().enumerate()
{
match mount {
VolumeMount::Storage { errors, .. } => {
let errors = errors.as_deref().unwrap_or("continue");

let img_path = work_dir.join(name);
cmd.args([
"-drive",
format!(
"file={},format=qcow2,media=disk,if=virtio",
"file={},format=qcow2,media=disk,id=vol-{vol_idx},if=none",
img_path.display()
)
.as_str(),
"-device",
format!("virtio-blk-pci,drive=vol-{vol_idx},serial=vol-{vol_idx}").as_ref(),
]);
kernel_cmdline.push_str(&match errors {
None => format!(" vol-{vol_idx}={guest_path}:{dev_idx}"),
Some(errors) => {
format!(" vol-{vol_idx}={guest_path},errors={errors}:{dev_idx}")
}
});
dev_idx += 1;
kernel_cmdline.push_str(&format!(" vol-{vol_idx}-path={guest_path}"));
kernel_cmdline.push_str(&format!(" vol-{vol_idx}-errors={errors}"));
}
VolumeMount::Ram { size } => {
let size = size.as_u64();
kernel_cmdline.push_str(&format!(" vol-{vol_idx}={guest_path},size={size}"));
kernel_cmdline.push_str(&format!(" vol-{vol_idx}-path={guest_path}"));
kernel_cmdline.push_str(&format!(" vol-{vol_idx}-size={size}"));
}
}
vol_idx += 1;
}

if let Some(pci_device_id) = &data.pci_device_id {
Expand All @@ -155,16 +157,16 @@ pub async fn start_vmrt(
}

if runtime_dir.join(FILE_NVIDIA_FILES).exists() {
cmd.arg("-drive");
cmd.arg(
cmd.args([
"-drive",
format!(
"file={},cache=unsafe,readonly=on,format=raw,if=virtio",
"file={},cache=unsafe,readonly=on,format=raw,id=vol-nvidia,if=none",
runtime_dir.join(FILE_NVIDIA_FILES).display()
)
.as_str(),
);

kernel_cmdline.push_str(&format!(" nvidia=true"));
"-device",
format!("virtio-blk-pci,drive=vol-nvidia,serial=vol-nvidia").as_ref(),

Check failure on line 168 in runtime/src/vmrt.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

useless use of `format!`
]);
}

cmd.args(["-append", &kernel_cmdline]);
Expand Down

0 comments on commit 7ca1a03

Please sign in to comment.