mirror of
				https://github.com/kata-containers/kata-containers.git
				synced 2025-10-30 17:03:57 +00:00 
			
		
		
		
	dragonball: update for review
update for review Fixes: #3785 Signed-off-by: Quanwei Zhou <quanweiZhou@linux.alibaba.com>
This commit is contained in:
		
				
					committed by
					
						 quanwei.zqw
						quanwei.zqw
					
				
			
			
				
	
			
			
			
						parent
						
							274598ae56
						
					
				
				
					commit
					3c989521b1
				
			| @@ -5,7 +5,7 @@ | |||||||
| use serde_derive::{Deserialize, Serialize}; | use serde_derive::{Deserialize, Serialize}; | ||||||
|  |  | ||||||
| /// Default guest kernel command line: | /// Default guest kernel command line: | ||||||
| /// - `reboot=k` shut down the guest on reboot, instead of well... rebooting; | /// - `reboot=k` shutdown the guest on reboot, instead of well... rebooting; | ||||||
| /// - `panic=1` on panic, reboot after 1 second; | /// - `panic=1` on panic, reboot after 1 second; | ||||||
| /// - `pci=off` do not scan for PCI devices (ser boot time); | /// - `pci=off` do not scan for PCI devices (ser boot time); | ||||||
| /// - `nomodules` disable loadable kernel module support; | /// - `nomodules` disable loadable kernel module support; | ||||||
|   | |||||||
| @@ -332,7 +332,7 @@ impl VmmService { | |||||||
|         Ok(VmmData::Empty) |         Ok(VmmData::Empty) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// Set virtual machine configuration configurations. |     /// Set virtual machine configuration. | ||||||
|     pub fn set_vm_configuration( |     pub fn set_vm_configuration( | ||||||
|         &mut self, |         &mut self, | ||||||
|         vmm: &mut Vmm, |         vmm: &mut Vmm, | ||||||
| @@ -498,8 +498,7 @@ impl VmmService { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     #[cfg(feature = "virtio-blk")] |     #[cfg(feature = "virtio-blk")] | ||||||
|     // Only call this function as part of the API. |     // Remove the device | ||||||
|     // If the drive_id does not exist, a new Block Device Config is added to the list. |  | ||||||
|     fn remove_block_device( |     fn remove_block_device( | ||||||
|         &mut self, |         &mut self, | ||||||
|         vmm: &mut Vmm, |         vmm: &mut Vmm, | ||||||
|   | |||||||
| @@ -372,8 +372,7 @@ impl BlockDeviceMgr { | |||||||
|                 for info in mgr.info_list.iter() { |                 for info in mgr.info_list.iter() { | ||||||
|                     info.config.check_conflicts(&config)?; |                     info.config.check_conflicts(&config)?; | ||||||
|                 } |                 } | ||||||
|                 let config2 = config.clone(); |                 let index = mgr.create(config.clone())?; | ||||||
|                 let index = mgr.create(config2)?; |  | ||||||
|                 if !ctx.is_hotplug { |                 if !ctx.is_hotplug { | ||||||
|                     return Ok(()); |                     return Ok(()); | ||||||
|                 } |                 } | ||||||
| @@ -497,8 +496,6 @@ impl BlockDeviceMgr { | |||||||
|     ) -> std::result::Result<Box<Block<GuestAddressSpaceImpl>>, virtio::Error> { |     ) -> std::result::Result<Box<Block<GuestAddressSpaceImpl>>, virtio::Error> { | ||||||
|         let epoll_mgr = ctx.epoll_mgr.clone().ok_or(virtio::Error::InvalidInput)?; |         let epoll_mgr = ctx.epoll_mgr.clone().ok_or(virtio::Error::InvalidInput)?; | ||||||
|  |  | ||||||
|         // Safe to unwrap() because we have verified it when parsing device type. |  | ||||||
|         //let path = cfg.path_on_host.to_str().unwrap(); |  | ||||||
|         let mut block_files: Vec<Box<dyn Ufile>> = vec![]; |         let mut block_files: Vec<Box<dyn Ufile>> = vec![]; | ||||||
|  |  | ||||||
|         match cfg.device_type { |         match cfg.device_type { | ||||||
| @@ -762,7 +759,7 @@ impl BlockDeviceMgr { | |||||||
| } | } | ||||||
|  |  | ||||||
| impl Default for BlockDeviceMgr { | impl Default for BlockDeviceMgr { | ||||||
|     /// Constructor for the BlockDeviceConfigs. It initializes an empty LinkedList. |     /// Constructor for the BlockDeviceMgr. It initializes an empty LinkedList. | ||||||
|     fn default() -> BlockDeviceMgr { |     fn default() -> BlockDeviceMgr { | ||||||
|         BlockDeviceMgr { |         BlockDeviceMgr { | ||||||
|             info_list: VecDeque::<BlockDeviceInfo>::new(), |             info_list: VecDeque::<BlockDeviceInfo>::new(), | ||||||
|   | |||||||
| @@ -12,9 +12,9 @@ use std::io; | |||||||
| use std::sync::{Arc, Mutex}; | use std::sync::{Arc, Mutex}; | ||||||
|  |  | ||||||
| use dbs_device::device_manager::Error as IoManagerError; | use dbs_device::device_manager::Error as IoManagerError; | ||||||
| use dbs_legacy_devices::SerialDevice; |  | ||||||
| #[cfg(target_arch = "aarch64")] | #[cfg(target_arch = "aarch64")] | ||||||
| use dbs_legacy_devices::RTCDevice; | use dbs_legacy_devices::RTCDevice; | ||||||
|  | use dbs_legacy_devices::SerialDevice; | ||||||
| use vmm_sys_util::eventfd::EventFd; | use vmm_sys_util::eventfd::EventFd; | ||||||
|  |  | ||||||
| // The I8042 Data Port (IO Port 0x60) is used for reading data that was received from a I8042 device or from the I8042 controller itself and writing data to a I8042 device or to the I8042 controller itself. | // The I8042 Data Port (IO Port 0x60) is used for reading data that was received from a I8042 device or from the I8042 controller itself and writing data to a I8042 device or to the I8042 controller itself. | ||||||
| @@ -149,10 +149,10 @@ pub(crate) mod x86_64 { | |||||||
| #[cfg(target_arch = "aarch64")] | #[cfg(target_arch = "aarch64")] | ||||||
| pub(crate) mod aarch64 { | pub(crate) mod aarch64 { | ||||||
|     use super::*; |     use super::*; | ||||||
|     use dbs_device::device_manager::{IoManager}; |     use dbs_device::device_manager::IoManager; | ||||||
|     use dbs_device::resources::DeviceResources; |     use dbs_device::resources::DeviceResources; | ||||||
|     use std::collections::HashMap; |  | ||||||
|     use kvm_ioctls::VmFd; |     use kvm_ioctls::VmFd; | ||||||
|  |     use std::collections::HashMap; | ||||||
|  |  | ||||||
|     type Result<T> = ::std::result::Result<T, Error>; |     type Result<T> = ::std::result::Result<T, Error>; | ||||||
|  |  | ||||||
| @@ -194,7 +194,7 @@ pub(crate) mod aarch64 { | |||||||
|         ) -> Result<(Arc<Mutex<SerialDevice>>, EventFd)> { |         ) -> Result<(Arc<Mutex<SerialDevice>>, EventFd)> { | ||||||
|             let eventfd = EventFd::new(libc::EFD_NONBLOCK).map_err(Error::EventFd)?; |             let eventfd = EventFd::new(libc::EFD_NONBLOCK).map_err(Error::EventFd)?; | ||||||
|             let device = Arc::new(Mutex::new(SerialDevice::new( |             let device = Arc::new(Mutex::new(SerialDevice::new( | ||||||
|                 eventfd.try_clone().map_err(Error::EventFd)? |                 eventfd.try_clone().map_err(Error::EventFd)?, | ||||||
|             ))); |             ))); | ||||||
|  |  | ||||||
|             bus.register_device_io(device.clone(), resources.get_all_resources()) |             bus.register_device_io(device.clone(), resources.get_all_resources()) | ||||||
|   | |||||||
| @@ -3,18 +3,20 @@ | |||||||
|  |  | ||||||
| //! Device manager to manage IO devices for a virtual machine. | //! Device manager to manage IO devices for a virtual machine. | ||||||
|  |  | ||||||
|  | #[cfg(target_arch = "aarch64")] | ||||||
|  | use std::collections::HashMap; | ||||||
|  |  | ||||||
| use std::io; | use std::io; | ||||||
| use std::sync::{Arc, Mutex, MutexGuard}; | use std::sync::{Arc, Mutex, MutexGuard}; | ||||||
| use std::collections::HashMap; |  | ||||||
|  |  | ||||||
| use arc_swap::ArcSwap; | use arc_swap::ArcSwap; | ||||||
| use dbs_address_space::AddressSpace; | use dbs_address_space::AddressSpace; | ||||||
| #[cfg(target_arch = "aarch64")] | #[cfg(target_arch = "aarch64")] | ||||||
| use dbs_arch::{DeviceType, MMIODeviceInfo}; | use dbs_arch::{DeviceType, MMIODeviceInfo}; | ||||||
| use dbs_device::device_manager::{Error as IoManagerError, IoManager, IoManagerContext}; | use dbs_device::device_manager::{Error as IoManagerError, IoManager, IoManagerContext}; | ||||||
| use dbs_device::resources::Resource; |  | ||||||
| #[cfg(target_arch = "aarch64")] | #[cfg(target_arch = "aarch64")] | ||||||
| use dbs_device::resources::DeviceResources; | use dbs_device::resources::DeviceResources; | ||||||
|  | use dbs_device::resources::Resource; | ||||||
| use dbs_device::DeviceIo; | use dbs_device::DeviceIo; | ||||||
| use dbs_interrupt::KvmIrqManager; | use dbs_interrupt::KvmIrqManager; | ||||||
| use dbs_legacy_devices::ConsoleHandler; | use dbs_legacy_devices::ConsoleHandler; | ||||||
| @@ -54,7 +56,10 @@ pub mod console_manager; | |||||||
| pub use self::console_manager::ConsoleManager; | pub use self::console_manager::ConsoleManager; | ||||||
|  |  | ||||||
| mod legacy; | mod legacy; | ||||||
| pub use self::legacy::{Error as LegacyDeviceError, LegacyDeviceManager, aarch64::{COM1, COM2, RTC}}; | pub use self::legacy::{Error as LegacyDeviceError, LegacyDeviceManager}; | ||||||
|  |  | ||||||
|  | #[cfg(target_arch = "aarch64")] | ||||||
|  | pub use self::legacy::aarch64::{COM1, COM2, RTC}; | ||||||
|  |  | ||||||
| #[cfg(feature = "virtio-vsock")] | #[cfg(feature = "virtio-vsock")] | ||||||
| /// Device manager for user-space vsock devices. | /// Device manager for user-space vsock devices. | ||||||
| @@ -333,9 +338,7 @@ impl DeviceOpContext { | |||||||
|             let (mmio_base, mmio_size, irq) = DeviceManager::get_virtio_mmio_device_info(device)?; |             let (mmio_base, mmio_size, irq) = DeviceManager::get_virtio_mmio_device_info(device)?; | ||||||
|             let dev_type; |             let dev_type; | ||||||
|             let device_id; |             let device_id; | ||||||
|             if let Some(mmiov2_device) = |             if let Some(mmiov2_device) = device.as_any().downcast_ref::<DbsMmioV2Device>() { | ||||||
|                 device.as_any().downcast_ref::<DbsMmioV2Device>() |  | ||||||
|             { |  | ||||||
|                 dev_type = mmiov2_device.get_device_type(); |                 dev_type = mmiov2_device.get_device_type(); | ||||||
|                 device_id = None; |                 device_id = None; | ||||||
|             } else { |             } else { | ||||||
| @@ -534,19 +537,20 @@ impl DeviceManager { | |||||||
|         &mut self, |         &mut self, | ||||||
|         ctx: &mut DeviceOpContext, |         ctx: &mut DeviceOpContext, | ||||||
|     ) -> std::result::Result<(), StartMicroVmError> { |     ) -> std::result::Result<(), StartMicroVmError> { | ||||||
|         #[cfg( |         #[cfg(any( | ||||||
|             any(target_arch = "x86_64", |             target_arch = "x86_64", | ||||||
|                 all(target_arch = "aarch64", feature = "dbs-virtio-devices") |             all(target_arch = "aarch64", feature = "dbs-virtio-devices") | ||||||
|             ) |         ))] | ||||||
|         )] |  | ||||||
|         { |         { | ||||||
|             let mut tx = ctx.io_context.begin_tx(); |             let mut tx = ctx.io_context.begin_tx(); | ||||||
|             let legacy_manager; |             let legacy_manager; | ||||||
|  |  | ||||||
|             #[cfg(target_arch = "x86_64")] |             #[cfg(target_arch = "x86_64")] | ||||||
|             { |             { | ||||||
|                 let legacy_manager = |                 legacy_manager = LegacyDeviceManager::create_manager( | ||||||
|                     LegacyDeviceManager::create_manager(&mut tx.io_manager, Some(self.vm_fd.clone())); |                     &mut tx.io_manager, | ||||||
|  |                     Some(self.vm_fd.clone()), | ||||||
|  |                 ); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             #[cfg(target_arch = "aarch64")] |             #[cfg(target_arch = "aarch64")] | ||||||
| @@ -817,10 +821,7 @@ impl DeviceManager { | |||||||
|             .get_legacy_irq() |             .get_legacy_irq() | ||||||
|             .ok_or(DeviceMgrError::GetDeviceResource)?; |             .ok_or(DeviceMgrError::GetDeviceResource)?; | ||||||
|  |  | ||||||
|         if let Some(mmio_dev) = device |         if let Some(mmio_dev) = device.as_any().downcast_ref::<DbsMmioV2Device>() { | ||||||
|             .as_any() |  | ||||||
|             .downcast_ref::<DbsMmioV2Device>() |  | ||||||
|         { |  | ||||||
|             if let Resource::MmioAddressRange { base, size } = mmio_dev.get_mmio_cfg_res() { |             if let Resource::MmioAddressRange { base, size } = mmio_dev.get_mmio_cfg_res() { | ||||||
|                 return Ok((base, size, irq)); |                 return Ok((base, size, irq)); | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -12,7 +12,7 @@ | |||||||
| #[cfg(feature = "dbs-virtio-devices")] | #[cfg(feature = "dbs-virtio-devices")] | ||||||
| use dbs_virtio_devices::Error as VirtIoError; | use dbs_virtio_devices::Error as VirtIoError; | ||||||
|  |  | ||||||
| use crate::{address_space_manager, device_manager, vcpu, vm, resource_manager}; | use crate::{address_space_manager, device_manager, resource_manager, vcpu, vm}; | ||||||
|  |  | ||||||
| /// Shorthand result type for internal VMM commands. | /// Shorthand result type for internal VMM commands. | ||||||
| pub type Result<T> = std::result::Result<T, Error>; | pub type Result<T> = std::result::Result<T, Error>; | ||||||
|   | |||||||
| @@ -64,7 +64,7 @@ impl TryFrom<AddressMessage> for Address { | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| pub(crate) fn parse_ip(ip: &Vec<u8>, family: u8) -> Result<IpAddr> { | pub(crate) fn parse_ip(ip: &[u8], family: u8) -> Result<IpAddr> { | ||||||
|     let support_len = if family as u16 == AF_INET { 4 } else { 16 }; |     let support_len = if family as u16 == AF_INET { 4 } else { 16 }; | ||||||
|     if ip.len() != support_len { |     if ip.len() != support_len { | ||||||
|         return Err(anyhow!( |         return Err(anyhow!( | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user