virtio-devices: Use Default::default() for transitioning to VirtioCommon

In order to simplify the transition to VirtioCommon and to avoid needing
to set empty fields derive Default for VirtioCommon.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2020-09-03 16:56:32 +01:00
parent 008cf4a5ae
commit a9a138460b
14 changed files with 14 additions and 10 deletions

View File

@ -333,7 +333,7 @@ impl Balloon {
Ok(Balloon {
common: VirtioCommon {
avail_features,
acked_features: 0u64,
..Default::default()
},
id,
resize: VirtioBalloonResize::new()?,

View File

@ -339,7 +339,7 @@ impl<T: DiskFile> Block<T> {
Ok(Block {
common: VirtioCommon {
avail_features,
acked_features: 0u64,
..Default::default()
},
id,
kill_evt: None,

View File

@ -374,7 +374,7 @@ impl BlockIoUring {
Ok(BlockIoUring {
common: VirtioCommon {
avail_features,
acked_features: 0u64,
..Default::default()
},
id,
kill_evt: None,

View File

@ -352,7 +352,7 @@ impl Console {
Console {
common: VirtioCommon {
avail_features,
acked_features: 0u64,
..Default::default()
},
id,
kill_evt: None,

View File

@ -183,6 +183,7 @@ pub trait DmaRemapping: Send + Sync {
}
/// Structure to handle device state common to all devices
#[derive(Default)]
pub struct VirtioCommon {
pub avail_features: u64,
pub acked_features: u64,

View File

@ -782,7 +782,7 @@ impl Iommu {
avail_features: 1u64 << VIRTIO_F_VERSION_1
| 1u64 << VIRTIO_IOMMU_F_MAP_UNMAP
| 1u64 << VIRTIO_IOMMU_F_PROBE,
acked_features: 0u64,
..Default::default()
},
config,
config_topo_pci_ranges: Vec::new(),

View File

@ -738,7 +738,7 @@ impl Mem {
Ok(Mem {
common: VirtioCommon {
avail_features,
acked_features: 0u64,
..Default::default()
},
id,
resize,

View File

@ -259,7 +259,7 @@ impl Net {
Ok(Net {
common: VirtioCommon {
avail_features,
acked_features: 0u64,
..Default::default()
},
id,
kill_evt: None,

View File

@ -331,7 +331,7 @@ impl Pmem {
Ok(Pmem {
common: VirtioCommon {
avail_features,
acked_features: 0u64,
..Default::default()
},
id,
kill_evt: None,

View File

@ -165,7 +165,7 @@ impl Rng {
Ok(Rng {
common: VirtioCommon {
avail_features,
acked_features: 0u64,
..Default::default()
},
id,
kill_evt: None,

View File

@ -142,6 +142,7 @@ impl Blk {
common: VirtioCommon {
avail_features,
acked_features,
..Default::default()
},
id,
vhost_user_blk,

View File

@ -358,6 +358,7 @@ impl Fs {
common: VirtioCommon {
avail_features,
acked_features,
..Default::default()
},
id,
vu: master,

View File

@ -151,6 +151,7 @@ impl Net {
common: VirtioCommon {
avail_features,
acked_features,
..Default::default()
},
vhost_user_net,
kill_evt: None,

View File

@ -338,7 +338,7 @@ where
Ok(Vsock {
common: VirtioCommon {
avail_features,
acked_features: 0u64,
..Default::default()
},
id,
cid,