mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
devices: Add support for i8042 reset device
Introduce emulation of i8042 device to allow the guest to stop the VM by issuing a reset event. The device has been copied over from the Crosvm code base, relying on the commit 0268e26e1ac9e09aa51d733482c5df139cd8d588. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
committed by
Samuel Ortiz
parent
29b90a8aee
commit
342bdc3619
@@ -213,6 +213,9 @@ struct DeviceManager {
|
||||
// Serial port on 0x3f8
|
||||
serial: Arc<Mutex<devices::legacy::Serial>>,
|
||||
serial_evt: EventFd,
|
||||
|
||||
// i8042 device for exit
|
||||
i8042: Arc<Mutex<devices::legacy::I8042Device>>,
|
||||
exit_evt: EventFd,
|
||||
}
|
||||
|
||||
@@ -226,20 +229,31 @@ impl DeviceManager {
|
||||
)));
|
||||
|
||||
let exit_evt = EventFd::new(EFD_NONBLOCK).map_err(Error::EventFd)?;
|
||||
let i8042 = Arc::new(Mutex::new(devices::legacy::I8042Device::new(
|
||||
exit_evt.try_clone().map_err(Error::EventFd)?,
|
||||
)));
|
||||
|
||||
Ok(DeviceManager {
|
||||
io_bus,
|
||||
serial,
|
||||
serial_evt,
|
||||
i8042,
|
||||
exit_evt,
|
||||
})
|
||||
}
|
||||
|
||||
/// Register legacy devices.
|
||||
pub fn register_devices(&mut self) -> Result<()> {
|
||||
// Insert serial device
|
||||
self.io_bus
|
||||
.insert(self.serial.clone(), 0x3f8, 0x8)
|
||||
.map_err(Error::BusError)?;
|
||||
|
||||
// Insert i8042 device
|
||||
self.io_bus
|
||||
.insert(self.i8042.clone(), 0x61, 0x4)
|
||||
.map_err(Error::BusError)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user