From a993c9f05f780e3149feedeede83492d88856343 Mon Sep 17 00:00:00 2001 From: Wei-chung Hsu Date: Fri, 28 Mar 2025 14:41:37 -0700 Subject: [PATCH] Added function get_enabled to export vring enable status. The vring is disabled and RX/TX queue is set to not-ready during snapshot. But vhost-device process keeps access vring and queue after snapshot which caused system hang. We need to export vring enabled and disabled status for snapshot feature so that the vhost-device would skip vring/queue access aftr snapshot to avoid hang. Signed-off-by: Wei-Chung Hsu --- vhost-user-backend/src/vring.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/vhost-user-backend/src/vring.rs b/vhost-user-backend/src/vring.rs index 948f6878..dc4eeb8e 100644 --- a/vhost-user-backend/src/vring.rs +++ b/vhost-user-backend/src/vring.rs @@ -61,6 +61,9 @@ pub trait VringT: /// Set vring enabled state. fn set_enabled(&self, enabled: bool); + /// Get vring enabled state. + fn get_enabled(&self) -> bool; + /// Set queue addresses for descriptor table, available ring and used ring. fn set_queue_info( &self, @@ -174,6 +177,10 @@ impl VringState { self.enabled = enabled; } + pub fn get_enabled(&self) -> bool { + self.enabled + } + /// Set queue addresses for descriptor table, available ring and used ring. pub fn set_queue_info( &mut self, @@ -327,6 +334,10 @@ impl VringT for VringMutex { self.lock().set_enabled(enabled) } + fn get_enabled(&self) -> bool { + self.get_ref().enabled + } + fn set_queue_info( &self, desc_table: u64, @@ -442,6 +453,10 @@ impl VringT for VringRwLock { self.write_lock().set_enabled(enabled) } + fn get_enabled(&self) -> bool { + self.get_ref().enabled + } + fn set_queue_info( &self, desc_table: u64,