Skip to content

Commit

Permalink
remove sending transport_reset event on snapshot creation
Browse files Browse the repository at this point in the history
Signed-off-by: Amory Hoste <[email protected]>
  • Loading branch information
amohoste committed Nov 24, 2021
1 parent 53ba44f commit e322467
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 50 deletions.
4 changes: 1 addition & 3 deletions src/devices/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -43,6 +43,4 @@ pub enum Error {
MalformedDescriptor,
/// Error during queue processing.
QueueError(QueueError),
/// Vsock device error.
VsockError(VsockError),
}
33 changes: 1 addition & 32 deletions src/devices/src/virtio/vsock/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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
Expand Down Expand Up @@ -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::<u32>(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<B> VirtioDevice for Vsock<B>
Expand Down
2 changes: 0 additions & 2 deletions src/devices/src/virtio/vsock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 3 additions & 12 deletions src/vmm/src/device_manager/persist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -227,24 +226,16 @@ 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::<Vsock<VsockUnixBackend>>()
.downcast_ref::<Vsock<VsockUnixBackend>>()
.unwrap();

let vsock_state = VsockState {
backend: vsock.backend().save(),
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,
Expand Down
2 changes: 1 addition & 1 deletion tools/devtool
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit e322467

Please sign in to comment.