-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vmm: support starting stratovirt lightweight vm sandbox #93
Conversation
const ROOTFS_KERNEL_PARAMS: &str = " root=/dev/vda ro rootfstype=ext4"; | ||
#[cfg(target_arch = "aarch64")] | ||
const ROOTFS_KERNEL_PARAMS: &str = " root=/dev/vda1 ro rootfstype=ext4"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it different before? and is it unified now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is unified now, i used an unofficial image in arm before, which would divide a vda1 patition, now i use the image provided by stratovirt to start vm, it will not devide vda1.
@@ -85,17 +85,25 @@ impl VMFactory for StratoVirtVMFactory { | |||
// create pcie.0 root bus object | |||
vm.pcie_root_bus = create_pcie_root_bus(); | |||
|
|||
let mut transport = Transport::Pci; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the transport is strongly related to the machine type, maybe we can add a transport()
in Machine to determine the transport by the machine type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
vmm/sandbox/src/stratovirt/mod.rs
Outdated
// set the pcie slot status to Occupied | ||
self.pcie_root_bus.bus.slots[slot_index].status = SlotStatus::Occupied(device.id()); | ||
device.set_device_addr(slot_index); | ||
if !self.config.machine.r#type.contains(MACHINE_TYPE_MICROVM) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this makes the machine type of microvm
a special case, can we just make the pcie_root_bus
of StratoVirtVM
an Option so that we just need to check if it is a None here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
cf51efb
to
74e939c
Compare
@@ -450,11 +458,14 @@ impl StratoVirtVM { | |||
&mut self, | |||
mut device: T, | |||
) -> Result<()> { | |||
// get the empty slot index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now microVM
support a new virtual bus typemmio
, so attatch_to_pcie_rootbus
func name is not accurate, maybe attach_to_bus
is more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
if self.pcie_root_bus.is_some() { | ||
// get the empty slot index | ||
let slot_index = self.get_empty_pcie_slot_index()?; | ||
// set the pcie slot status to Occupied | ||
self.pcie_root_bus.as_mut().unwrap().bus.slots[slot_index].status = | ||
SlotStatus::Occupied(device.id()); | ||
device.set_device_addr(slot_index); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if self.pcie_root_bus.is_some() { | |
// get the empty slot index | |
let slot_index = self.get_empty_pcie_slot_index()?; | |
// set the pcie slot status to Occupied | |
self.pcie_root_bus.as_mut().unwrap().bus.slots[slot_index].status = | |
SlotStatus::Occupied(device.id()); | |
device.set_device_addr(slot_index); | |
} | |
if let Some(&mut pcie_root_bus) = self.pcie_root_bus { | |
... | |
pcie_root_bus.bus.slots[slot_index].status = | |
SlotStatus::Occupied(device.id()); | |
... | |
} |
I am not sure does it work? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried but it did not work well...
move occurs because pcie_root_bus
does not implement the Copy
trait, but self.get_empty_pcie_slot_index
needs to use it next
@@ -147,8 +153,10 @@ impl VMFactory for StratoVirtVMFactory { | |||
share_fs_path.as_str(), | |||
); | |||
|
|||
// set pcie-root-ports for hotplugging | |||
vm.create_pcie_root_ports(PCIE_ROOTPORT_CAPACITY)?; | |||
if vm.config.machine.r#type.split(',').next().unwrap() != MACHINE_TYPE_MICROVM { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be careful with unwrap()
. How about collect()
substrings after split()
, and handle the string array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
b33d300
to
2a70820
Compare
vmm-sandboxer support starting stratovirt lightweight vm sandbox, which uses lightweight microvm mainboard and mmio bus. Signed-off-by: Vanient <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
vmm-sandboxer support starting stratovirt lightweight vm sandbox, which uses lightweight microvm mainboard and mmio bus.