From 008cf4a5ae3cb37d944f94027a6c3ea94e22326d Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Thu, 3 Sep 2020 16:48:37 +0100 Subject: [PATCH] virtio-devices: block: Rearrange activate() to match other devices Rearrange the code to match other devices which makes it easier to prep for sharing this between other devices. Signed-off-by: Rob Bradford --- virtio-devices/src/block.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/virtio-devices/src/block.rs b/virtio-devices/src/block.rs index 037293948..2a7f751e1 100644 --- a/virtio-devices/src/block.rs +++ b/virtio-devices/src/block.rs @@ -482,7 +482,9 @@ impl VirtioDevice for Block { })?; self.pause_evt = Some(self_pause_evt); - let disk_image_id = build_disk_image_id(&self.disk_path); + // Save the interrupt EventFD as we need to return it on reset + // but clone it to pass into the thread. + self.interrupt_cb = Some(interrupt_cb.clone()); let mut tmp_queue_evts: Vec = Vec::new(); for queue_evt in queue_evts.iter() { @@ -495,6 +497,7 @@ impl VirtioDevice for Block { } self.queue_evts = Some(tmp_queue_evts); + let disk_image_id = build_disk_image_id(&self.disk_path); let event_idx = self.common.feature_acked(VIRTIO_RING_F_EVENT_IDX.into()); self.update_writeback(); @@ -542,10 +545,6 @@ impl VirtioDevice for Block { })?; } - // Save the interrupt EventFD as we need to return it on reset - // but clone it to pass into the thread. - self.interrupt_cb = Some(interrupt_cb); - self.epoll_threads = Some(epoll_threads); Ok(())