File tree Expand file tree Collapse file tree
src/vmm/src/device_manager Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,22 +20,22 @@ pub enum ACPIDeviceError {
2020 NotifyGuest ( #[ from] std:: io:: Error ) ,
2121}
2222
23- #[ derive( Debug ) ]
23+ // Although both VMGenID and VMClock devices are always present, they should be instantiated when
24+ // they are attached to preserve the existing ordering of GSI allocation.
25+ #[ derive( Debug , Default ) ]
2426pub struct ACPIDeviceManager {
2527 /// VMGenID device
26- pub vmgenid : Option < VmGenId > ,
28+ vmgenid : Option < VmGenId > ,
2729 /// VMclock device
28- pub vmclock : Option < VmClock > ,
30+ vmclock : Option < VmClock > ,
2931}
3032
3133impl ACPIDeviceManager {
3234 /// Create a new ACPIDeviceManager object
33- pub fn new ( ) -> Self {
34- // Although both VMGenID and VMClock devices are always present, they should be instantiated
35- // when they are attached to preserve the existing ordering of GSI allocation.
35+ pub fn new ( vmgenid : VmGenId , vmclock : VmClock ) -> Self {
3636 ACPIDeviceManager {
37- vmgenid : None ,
38- vmclock : None ,
37+ vmgenid : Some ( vmgenid ) ,
38+ vmclock : Some ( vmclock ) ,
3939 }
4040 }
4141
Original file line number Diff line number Diff line change @@ -174,7 +174,7 @@ impl DeviceManager {
174174 mmio_devices : MMIODeviceManager :: new ( ) ,
175175 #[ cfg( target_arch = "x86_64" ) ]
176176 legacy_devices,
177- acpi_devices : ACPIDeviceManager :: new ( ) ,
177+ acpi_devices : ACPIDeviceManager :: default ( ) ,
178178 pci_devices : PciDevices :: new ( ) ,
179179 } )
180180 }
@@ -559,10 +559,10 @@ pub(crate) mod tests {
559559 pub ( crate ) fn default_device_manager ( ) -> DeviceManager {
560560 let mut resource_allocator = ResourceAllocator :: new ( ) ;
561561 let mmio_devices = MMIODeviceManager :: new ( ) ;
562- let acpi_devices = ACPIDeviceManager {
563- vmgenid : Some ( VmGenId :: new ( & mut resource_allocator) ) ,
564- vmclock : Some ( VmClock :: new ( & mut resource_allocator) ) ,
565- } ;
562+ let acpi_devices = ACPIDeviceManager :: new (
563+ VmGenId :: new ( & mut resource_allocator) ,
564+ VmClock :: new ( & mut resource_allocator) ,
565+ ) ;
566566 let pci_devices = PciDevices :: new ( ) ;
567567
568568 #[ cfg( target_arch = "x86_64" ) ]
Original file line number Diff line number Diff line change @@ -183,12 +183,12 @@ impl<'a> Persist<'a> for ACPIDeviceManager {
183183 }
184184
185185 fn restore ( vm : Self :: ConstructorArgs , state : & Self :: State ) -> Result < Self , Self :: Error > {
186- let mut acpi_devices = ACPIDeviceManager {
186+ let mut acpi_devices = ACPIDeviceManager :: new (
187187 // Safe to unwrap() here, this will never return an error.
188- vmgenid : Some ( VmGenId :: restore ( ( ) , & state. vmgenid ) . unwrap ( ) ) ,
188+ VmGenId :: restore ( ( ) , & state. vmgenid ) . unwrap ( ) ,
189189 // Safe to unwrap() here, this will never return an error.
190- vmclock : Some ( VmClock :: restore ( ( ) , & state. vmclock ) . unwrap ( ) ) ,
191- } ;
190+ VmClock :: restore ( ( ) , & state. vmclock ) . unwrap ( ) ,
191+ ) ;
192192
193193 acpi_devices. activate_vmgenid ( vm) ?;
194194 acpi_devices. do_post_restore_vmgenid ( ) ?;
You can’t perform that action at this time.
0 commit comments