From e32246746b82cd7d5a46f3c42b4e0f34f7da6035 Mon Sep 17 00:00:00 2001 From: Amory Hoste Date: Wed, 24 Nov 2021 20:13:26 +0000 Subject: [PATCH] remove sending transport_reset event on snapshot creation Signed-off-by: Amory Hoste --- src/devices/src/lib.rs | 4 +--- src/devices/src/virtio/vsock/device.rs | 33 +------------------------- src/devices/src/virtio/vsock/mod.rs | 2 -- src/vmm/src/device_manager/persist.rs | 15 +++--------- tools/devtool | 2 +- 5 files changed, 6 insertions(+), 50 deletions(-) diff --git a/src/devices/src/lib.rs b/src/devices/src/lib.rs index 030d210e9b1c..bc53c3f929a3 100644 --- a/src/devices/src/lib.rs +++ b/src/devices/src/lib.rs @@ -14,7 +14,7 @@ pub mod pseudo; pub mod virtio; pub use self::bus::{Bus, BusDevice, Error as BusError}; -use crate::virtio::{QueueError, VsockError}; +use crate::virtio::{QueueError}; use logger::{error, IncMetric, METRICS}; // Function used for reporting error in terms of logging @@ -43,6 +43,4 @@ pub enum Error { MalformedDescriptor, /// Error during queue processing. QueueError(QueueError), - /// Vsock device error. - VsockError(VsockError), } diff --git a/src/devices/src/virtio/vsock/device.rs b/src/devices/src/virtio/vsock/device.rs index be431766738c..b0819690dca9 100644 --- a/src/devices/src/virtio/vsock/device.rs +++ b/src/devices/src/virtio/vsock/device.rs @@ -26,7 +26,7 @@ use std::sync::Arc; use logger::{debug, error, warn, IncMetric, METRICS}; use utils::byte_order; use utils::eventfd::EventFd; -use vm_memory::{Bytes, GuestMemoryMmap}; +use vm_memory::{GuestMemoryMmap}; use super::super::super::Error as DeviceError; use super::super::{ @@ -41,8 +41,6 @@ pub(crate) const RXQ_INDEX: usize = 0; pub(crate) const TXQ_INDEX: usize = 1; pub(crate) const EVQ_INDEX: usize = 2; -pub(crate) const VIRTIO_VSOCK_EVENT_TRANSPORT_RESET: u32 = 0; - /// The virtio features supported by our vsock device: /// - VIRTIO_F_VERSION_1: the device conforms to at least version 1.0 of the VirtIO spec. /// - VIRTIO_F_IN_ORDER: the device returns used buffers in the same order that the driver makes @@ -228,35 +226,6 @@ where have_used } - - // Send TRANSPORT_RESET_EVENT to driver. According to specs, the driver shuts down established - // connections and the guest_cid configuration field is fetched again. Existing listen sockets remain - // but their CID is updated to reflect the current guest_cid. - pub fn send_transport_reset_event(&mut self) -> result::Result<(), DeviceError> { - let mem = match self.device_state { - DeviceState::Activated(ref mem) => mem, - // This should never happen, it's been already validated in the caller function. - DeviceState::Inactive => unreachable!(), - }; - - let head = self.queues[EVQ_INDEX].pop(mem).ok_or_else(|| { - METRICS.vsock.ev_queue_event_fails.inc(); - DeviceError::VsockError(VsockError::EmptyQueue) - })?; - - mem.write_obj::(VIRTIO_VSOCK_EVENT_TRANSPORT_RESET, head.addr) - .unwrap_or_else(|e| error!("Failed to write virtio vsock reset event: {:?}", e)); - - self.queues[EVQ_INDEX] - .add_used(mem, head.index, head.len) - .unwrap_or_else(|e| { - error!("Failed to add used descriptor {}: {}", head.index, e); - }); - - self.signal_used_queue()?; - - Ok(()) - } } impl VirtioDevice for Vsock diff --git a/src/devices/src/virtio/vsock/mod.rs b/src/devices/src/virtio/vsock/mod.rs index a810a49eb37d..47fa59b70e4b 100644 --- a/src/devices/src/virtio/vsock/mod.rs +++ b/src/devices/src/virtio/vsock/mod.rs @@ -99,8 +99,6 @@ pub enum VsockError { BufDescTooSmall, /// The vsock data/buffer virtio descriptor is expected, but missing. BufDescMissing, - /// Empty queue - EmptyQueue, /// EventFd error EventFd(std::io::Error), /// Chained GuestMemoryMmap error. diff --git a/src/vmm/src/device_manager/persist.rs b/src/vmm/src/device_manager/persist.rs index aaa6ee7e5b3d..fd309a014027 100644 --- a/src/vmm/src/device_manager/persist.rs +++ b/src/vmm/src/device_manager/persist.rs @@ -9,7 +9,6 @@ use std::sync::{Arc, Mutex}; use super::mmio::*; use crate::EventManager; -use logger::error; #[cfg(target_arch = "aarch64")] use arch::DeviceType; @@ -188,7 +187,7 @@ impl<'a> Persist<'a> for MMIODeviceManager { let transport_state = mmio_transport.save(); - let mut locked_device = mmio_transport.locked_device(); + let locked_device = mmio_transport.locked_device(); match locked_device.device_type() { TYPE_BALLOON => { let balloon_state = locked_device @@ -227,9 +226,9 @@ impl<'a> Persist<'a> for MMIODeviceManager { } TYPE_VSOCK => { let vsock = locked_device - .as_mut_any() + .as_any() // Currently, VsockUnixBackend is the only implementation of VsockBackend. - .downcast_mut::>() + .downcast_ref::>() .unwrap(); let vsock_state = VsockState { @@ -237,14 +236,6 @@ impl<'a> Persist<'a> for MMIODeviceManager { frontend: vsock.save(), }; - // Send Transport event to reset connections if device - // is activated. - if vsock.is_activated() { - vsock.send_transport_reset_event().unwrap_or_else(|e| { - error!("Failed to send reset transport event: {:?}", e); - }); - } - states.vsock_device = Some(ConnectedVsockState { device_id: devid.clone(), device_state: vsock_state, diff --git a/tools/devtool b/tools/devtool index 7950f5b30b7c..80e77682eb59 100755 --- a/tools/devtool +++ b/tools/devtool @@ -69,7 +69,7 @@ # would help with reproducible builds (in addition to pinning Cargo.lock) # Development container image (without tag) -DEVCTR_IMAGE_NO_TAG="docker.io/amohoste/fcuvm_dev" +DEVCTR_IMAGE_NO_TAG="docker.io/vhiveease/fcuvm_dev" # Development container tag DEVCTR_IMAGE_TAG="v30"