mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: virtio-devices: make disk_nsectors a shared atomic
This change is a prerequisite for live disk resizing. Before this commit, the epoll-handler threads just got a copy of the sector size which we cannot update during runtime. On-behalf-of: SAP thomas.prescher@sap.com Signed-off-by: Thomas Prescher <thomas.prescher@cyberus-technology.de>
This commit is contained in:
committed by
Rob Bradford
parent
d75bd1675c
commit
8e52bf251b
@@ -137,7 +137,7 @@ struct BlockEpollHandler {
|
|||||||
queue: Queue,
|
queue: Queue,
|
||||||
mem: GuestMemoryAtomic<GuestMemoryMmap>,
|
mem: GuestMemoryAtomic<GuestMemoryMmap>,
|
||||||
disk_image: Box<dyn AsyncIo>,
|
disk_image: Box<dyn AsyncIo>,
|
||||||
disk_nsectors: u64,
|
disk_nsectors: Arc<AtomicU64>,
|
||||||
interrupt_cb: Arc<dyn VirtioInterrupt>,
|
interrupt_cb: Arc<dyn VirtioInterrupt>,
|
||||||
serial: Vec<u8>,
|
serial: Vec<u8>,
|
||||||
kill_evt: EventFd,
|
kill_evt: EventFd,
|
||||||
@@ -234,7 +234,7 @@ impl BlockEpollHandler {
|
|||||||
|
|
||||||
let result = request.execute_async(
|
let result = request.execute_async(
|
||||||
desc_chain.memory(),
|
desc_chain.memory(),
|
||||||
self.disk_nsectors,
|
self.disk_nsectors.load(Ordering::SeqCst),
|
||||||
self.disk_image.as_mut(),
|
self.disk_image.as_mut(),
|
||||||
&self.serial,
|
&self.serial,
|
||||||
desc_chain.head_index() as u64,
|
desc_chain.head_index() as u64,
|
||||||
@@ -625,7 +625,7 @@ pub struct Block {
|
|||||||
id: String,
|
id: String,
|
||||||
disk_image: Box<dyn DiskFile>,
|
disk_image: Box<dyn DiskFile>,
|
||||||
disk_path: PathBuf,
|
disk_path: PathBuf,
|
||||||
disk_nsectors: u64,
|
disk_nsectors: Arc<AtomicU64>,
|
||||||
config: VirtioBlockConfig,
|
config: VirtioBlockConfig,
|
||||||
writeback: Arc<AtomicBool>,
|
writeback: Arc<AtomicBool>,
|
||||||
counters: BlockCounters,
|
counters: BlockCounters,
|
||||||
@@ -753,7 +753,7 @@ impl Block {
|
|||||||
id,
|
id,
|
||||||
disk_image,
|
disk_image,
|
||||||
disk_path,
|
disk_path,
|
||||||
disk_nsectors,
|
disk_nsectors: Arc::new(AtomicU64::new(disk_nsectors)),
|
||||||
config,
|
config,
|
||||||
writeback: Arc::new(AtomicBool::new(true)),
|
writeback: Arc::new(AtomicBool::new(true)),
|
||||||
counters: BlockCounters::default(),
|
counters: BlockCounters::default(),
|
||||||
@@ -843,7 +843,7 @@ impl Block {
|
|||||||
fn state(&self) -> BlockState {
|
fn state(&self) -> BlockState {
|
||||||
BlockState {
|
BlockState {
|
||||||
disk_path: self.disk_path.to_str().unwrap().to_owned(),
|
disk_path: self.disk_path.to_str().unwrap().to_owned(),
|
||||||
disk_nsectors: self.disk_nsectors,
|
disk_nsectors: self.disk_nsectors.load(Ordering::SeqCst),
|
||||||
avail_features: self.common.avail_features,
|
avail_features: self.common.avail_features,
|
||||||
acked_features: self.common.acked_features,
|
acked_features: self.common.acked_features,
|
||||||
config: self.config,
|
config: self.config,
|
||||||
@@ -957,7 +957,7 @@ impl VirtioDevice for Block {
|
|||||||
error!("failed to create new AsyncIo: {e}");
|
error!("failed to create new AsyncIo: {e}");
|
||||||
ActivateError::BadActivate
|
ActivateError::BadActivate
|
||||||
})?,
|
})?,
|
||||||
disk_nsectors: self.disk_nsectors,
|
disk_nsectors: self.disk_nsectors.clone(),
|
||||||
interrupt_cb: interrupt_cb.clone(),
|
interrupt_cb: interrupt_cb.clone(),
|
||||||
serial: self.serial.clone(),
|
serial: self.serial.clone(),
|
||||||
kill_evt,
|
kill_evt,
|
||||||
|
|||||||
Reference in New Issue
Block a user