@@ -11,7 +11,7 @@ use propolis_client::{
1111 Board , BootOrderEntry , BootSettings , Chipset , Component , Cpuid ,
1212 CpuidEntry , CpuidVendor , GuestHypervisorInterface , InstanceMetadata ,
1313 InstanceSpec , MigrationFailureInjector , NvmeDisk , PciPath , SerialPort ,
14- SerialPortNumber , SpecKey , VirtioDisk ,
14+ SerialPortNumber , SpecKey , VirtioDisk , VirtioSocket ,
1515 } ,
1616 support:: nvme_serial_from_str,
1717} ;
@@ -56,6 +56,7 @@ pub struct VmConfig<'dr> {
5656 disks : Vec < DiskRequest < ' dr > > ,
5757 migration_failure : Option < MigrationFailureInjector > ,
5858 guest_hv_interface : Option < GuestHypervisorInterface > ,
59+ vsock : Option < VirtioSocket > ,
5960}
6061
6162impl < ' dr > VmConfig < ' dr > {
@@ -76,6 +77,7 @@ impl<'dr> VmConfig<'dr> {
7677 disks : Vec :: new ( ) ,
7778 migration_failure : None ,
7879 guest_hv_interface : None ,
80+ vsock : None ,
7981 } ;
8082
8183 config. boot_disk (
@@ -121,6 +123,12 @@ impl<'dr> VmConfig<'dr> {
121123 self
122124 }
123125
126+ pub fn vsock ( & mut self , guest_cid : u64 , pci_device_num : u8 ) -> & mut Self {
127+ let pci_path = PciPath :: new ( 0 , pci_device_num, 0 ) . unwrap ( ) ;
128+ self . vsock = Some ( VirtioSocket { guest_cid, pci_path } ) ;
129+ self
130+ }
131+
124132 pub fn fail_migration_exports ( & mut self , exports : u32 ) -> & mut Self {
125133 let injector =
126134 self . migration_failure . get_or_insert ( MigrationFailureInjector {
@@ -218,6 +226,7 @@ impl<'dr> VmConfig<'dr> {
218226 disks,
219227 migration_failure,
220228 guest_hv_interface,
229+ vsock,
221230 } = self ;
222231 let framework = & ctx. framework ;
223232 let bootrom_path = framework
@@ -369,6 +378,13 @@ impl<'dr> VmConfig<'dr> {
369378 assert ! ( _old. is_none( ) ) ;
370379 }
371380
381+ if let Some ( vsock) = vsock {
382+ let _old = spec
383+ . components
384+ . insert ( "vsock" . into ( ) , Component :: VirtioSocket ( * vsock) ) ;
385+ assert ! ( _old. is_none( ) ) ;
386+ }
387+
372388 if let Some ( mig) = migration_failure. as_ref ( ) {
373389 let _old = spec. components . insert (
374390 "migration-failure" . into ( ) ,
0 commit comments