-
Notifications
You must be signed in to change notification settings - Fork 34
Wire up vsock device to propolis-server #1075
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
Changes from 5 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
|
|
||
| use std::convert::TryInto; | ||
| use std::fs::File; | ||
| use std::net::{IpAddr, Ipv4Addr, SocketAddr}; | ||
| use std::num::{NonZeroU8, NonZeroUsize}; | ||
| use std::os::unix::fs::FileTypeExt; | ||
| use std::sync::Arc; | ||
|
|
@@ -46,6 +47,7 @@ use propolis::hw::uart::LpcUart; | |
| use propolis::hw::{nvme, virtio}; | ||
| use propolis::intr_pins; | ||
| use propolis::vmm::{self, Builder, Machine}; | ||
| use propolis::vsock::GuestCid; | ||
| use propolis_api_types::instance::InstanceProperties; | ||
| use propolis_api_types::instance_spec::components::devices::SerialPortNumber; | ||
| use propolis_api_types::instance_spec::{self, SpecKey}; | ||
|
|
@@ -476,6 +478,44 @@ impl MachineInitializer<'_> { | |
| Ok(()) | ||
| } | ||
|
|
||
| pub fn initialize_vsock( | ||
| &mut self, | ||
| chipset: &RegisteredChipset, | ||
| ) -> Result<(), MachineInitError> { | ||
| use propolis::vsock::proxy::VsockPortMapping; | ||
|
|
||
| // OANA Port 605 - VM Attestation RFD 605 | ||
| const ATTESTATION_PORT: u16 = 605; | ||
| const ATTESTATION_ADDR: SocketAddr = SocketAddr::new( | ||
| IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), | ||
| ATTESTATION_PORT, | ||
| ); | ||
|
|
||
| if let Some(vsock) = &self.spec.vsock { | ||
| let bdf: pci::Bdf = vsock.spec.pci_path.into(); | ||
|
|
||
| let mappings = vec![VsockPortMapping::new( | ||
| ATTESTATION_PORT.into(), | ||
| ATTESTATION_ADDR, | ||
| )]; | ||
|
|
||
| let guest_cid = GuestCid::try_from(vsock.spec.guest_cid) | ||
| .context("guest cid")?; | ||
|
|
||
| let device = virtio::PciVirtioSock::new( | ||
| 256, | ||
| guest_cid, | ||
| self.log.new(slog::o!("dev" => "virtio-socket")), | ||
| mappings, | ||
| ); | ||
|
|
||
| self.devices.insert(vsock.id.clone(), device.clone()); | ||
| chipset.pci_attach(bdf, device); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i wanted to double-check my understanding of how the multi-function device bit would get set and currently it's only if there are multiple functions attached on the same bus/device (managed over in my read of the spec (and seems to agree with at least linux and illumos) is that it'd be legal to report this device as multi-function that happens to only implement a single function right now. but that it's also pretty low-risk for this device to suddenly become multi-function when there's another function here. so i think being not multi-function today while knowing it'll become multi-function in the future is ok?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I understand it from chat, this is okay to leave as is for merging?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, whatever we do with the multifunction-ness of this device we can (should!) do as a separate change. |
||
| } | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| async fn create_storage_backend_from_spec( | ||
| &mut self, | ||
| backend_spec: &StorageBackend, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.