[Rust-VMM] Device implementation in rust-vmm

Peng, Chao P chao.p.peng at intel.com
Thu Nov 21 01:25:02 UTC 2019



From: Florescu, Andreea [mailto:fandree at amazon.com]
Sent: Tuesday, November 19, 2019 6:47 PM
To: rust-vmm ML <rust-vmm at lists.opendev.org>
Subject: [Rust-VMM] Device implementation in rust-vmm


Hey everyone,



A couple of weeks ago we merged a trait for DeviceIo. This is very similar to what we have in CrosVM/Firecracker under the name IoBus and serves the same purpose. You can check the commit that introduced the trait for more context [1].



With this trait merged we can now implement simple legacy devices such as the serial console. I added a PR [2] for this, but it is still very much work in progress. This PR started another conversation regarding where to place the device emulation.



As far as I know we have two options:

- each device in its own crate/repository

- all commonly used devices in vm-device



We touched on this topic during the Bucharest rust-vmm meetup as well. Each of these options come with disadvantages. The one that I was mostly concerned about is bloating the vm-device with lots of devices that are not needed by all the VMMs using rust-vmm. There are ways to work around this problem, so during the meetup we agreed on adding device emulation in vm-device for now. If we get to the point where vm-device becomes unmanageable ( too many devices making the code hard to audit), we can move the device emulation out of the crate.



For people that didn't attend the meetup, what do you think about having the device emulation in vm-device?



If you read my original proposal for vm-device(https://github.com/rust-vmm/community/issues/33) I was not going to mix those together in one crate instead I'm going to separate the common part from concrete devices. I believe it's still true for most of the devices we concerned: Virtio/PCI/vfio all have(or will have) their own crates, it's nature to put the concrete devices there or in new crates if new layers are desirable for them. Putting the concrete device in vm-device, for example, putting a concrete PCI device in vm-device, can result circular reference:  vm-device(concreate PCI device) -> vm-pci -> vm-device(base device). I'm not strongly opposing you doing this for legacy and very simple device emulations like serial-console(not virtio-console),  since we should have very limited number of them and no circular reference  it's OK to put them in vm-device temporarily, though I tend to have a separate crate to hold those legacy ones.



Besides the two options you mentioned, there is third option that putting all the concrete devices in one new crate, with rust features to select specific devices.



Thanks,

Chao





Andreea



[1] https://github.com/rust-vmm/vm-device/commit/21910a148a290fcebec98bf11df4410ef35662d1

[2] https://github.com/rust-vmm/vm-device/pull/15

Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in Romania. Registration number J22/2621/2005.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opendev.org/pipermail/rust-vmm/attachments/20191121/cbdb1157/attachment.html>


More information about the Rust-vmm mailing list