Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6d80734

Browse files
committed
vmm: Reset device queues and TX/RX buffers
1 parent a396042 commit 6d80734

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

‎resources/seccomp/x86_64-unknown-linux-musl.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,12 @@
799799
"syscall": "sigaltstack",
800800
"comment": "sigaltstack is used by Rust stdlib to remove alternative signal stack during thread teardown."
801801
},
802+
{
803+
"syscall": "fcntl"
804+
},
805+
{
806+
"syscall": "ftruncate"
807+
},
802808
{
803809
"syscall": "futex",
804810
"comment": "Used for synchronization (during thread teardown when joining multiple vcpu threads at once)",
@@ -890,6 +896,56 @@
890896
}
891897
]
892898
},
899+
{
900+
"syscall": "memfd_create"
901+
},
902+
{
903+
"syscall": "mmap",
904+
"comment": "Used to recreate TX/RX queues in VirtIO net device",
905+
"args": [
906+
{
907+
"index": 3,
908+
"type": "dword",
909+
"op": "eq",
910+
"val": 34,
911+
"comment": "libc::MAP_ANONYMOUS|libc::MAP_PRIVATE"
912+
},
913+
{
914+
"index": 2,
915+
"type": "dword",
916+
"op": "eq",
917+
"val": 0,
918+
"comment": "libc::PROT_NONE"
919+
}
920+
]
921+
},
922+
{
923+
"syscall": "mmap",
924+
"comment": "Used to recreate TX/RX queues in VirtIO net device",
925+
"args": [
926+
{
927+
"index": 4,
928+
"type": "dword",
929+
"op": "eq",
930+
"val": 5,
931+
"comment": "file descriptor"
932+
},
933+
{
934+
"index": 3,
935+
"type": "dword",
936+
"op": "eq",
937+
"val": 17,
938+
"comment": "libc::MAP_SHARED|libc::MAP_FIXED"
939+
},
940+
{
941+
"index": 2,
942+
"type": "dword",
943+
"op": "eq",
944+
"val": 3,
945+
"comment": "libc::PROT_READ|libc::PROT_WRITE"
946+
}
947+
]
948+
},
893949
{
894950
"syscall": "mmap",
895951
"comment": "Used for reading the timezone in LocalTime::now()",

‎src/vmm/src/devices/virtio/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ pub enum ActivateError {
7979
// Errors triggered when resetting a VirtioDevice.
8080
#[derive(Debug, thiserror::Error, displaydoc::Display)]
8181
pub enum ResetError {
82+
/// Error when creating RX buffers
83+
RxBuffer,
8284
/// Reset is not implemented for the device.
8385
NotImplemented,
8486
}

‎src/vmm/src/devices/virtio/net/device.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,18 @@ impl VirtioDevice for Net {
10361036
self.rx_frame_buf = [0u8; MAX_BUFFER_SIZE];
10371037
self.acked_features = 0;
10381038
self.metrics.device_resets.inc();
1039+
let mut queues = Vec::new();
1040+
for size in NET_QUEUE_SIZES {
1041+
queues.push(Queue::new(size));
1042+
}
1043+
self.tx_buffer = Default::default();
1044+
self.rx_buffer = match RxBuffers::new() {
1045+
Ok(rx_buffer) => rx_buffer,
1046+
Err(err) => {
1047+
error!("Failed to reset RX buffers: {:?}", err);
1048+
return Err(ResetError::RxBuffer);
1049+
}
1050+
};
10391051
Ok(())
10401052
}
10411053
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /