virtio-devices: Derive thread names from device ids

In order to make the thread naming more useful derive their name from
the device id (which can be supplied by the user) and a device specific
suffix that has details of the individual queue (or queue pair.)

e.g.

rob@artemis:~$ pstree -p -c -l -t `pidof cloud-hypervisor`
cloud-hyperviso(27501)─┬─{_console}(27525)
                       ├─{_disk0_q0}(27529)
                       ├─{_disk0_q1}(27532)
                       ├─{_net1_ctrl}(27533)
                       ├─{_net1_qp0}(27534)
                       ├─{_net1_qp1}(27535)
                       ├─{_rng}(27526)
                       ├─{http-server}(27504)
                       ├─{seccomp_signal_}(27502)
                       ├─{signal_handler}(27523)
                       ├─{vcpu0}(27520)
                       ├─{vcpu1}(27522)
                       └─{vmm}(27503)

Fixes: #2077

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford
2021-01-13 13:10:36 +00:00
committed by Sebastien Boeuf
parent 3b43551d98
commit 23afe89089
14 changed files with 20 additions and 20 deletions

View File

@@ -216,7 +216,7 @@ impl VirtioDevice for Blk {
.map_err(ActivateError::VhostUserBlkSetup)?;
let mut epoll_threads = Vec::new();
for _ in 0..vu_interrupt_list.len() {
for i in 0..vu_interrupt_list.len() {
let mut interrupt_list_sub: Vec<(Option<EventFd>, Queue)> = Vec::with_capacity(1);
interrupt_list_sub.push(vu_interrupt_list.remove(0));
@@ -255,7 +255,7 @@ impl VirtioDevice for Blk {
get_seccomp_filter(&self.seccomp_action, Thread::VirtioVhostBlk)
.map_err(ActivateError::CreateSeccompFilter)?;
thread::Builder::new()
.name("vhost_blk".to_string())
.name(format!("{}_q{}", self.id.clone(), i))
.spawn(move || {
if let Err(e) = SeccompFilter::apply(virtio_vhost_blk_seccomp_filter) {
error!("Error applying seccomp filter: {:?}", e);

View File

@@ -475,7 +475,7 @@ impl VirtioDevice for Fs {
get_seccomp_filter(&self.seccomp_action, Thread::VirtioVhostFs)
.map_err(ActivateError::CreateSeccompFilter)?;
thread::Builder::new()
.name("vhost_fs".to_string())
.name(self.id.clone())
.spawn(move || {
if let Err(e) = SeccompFilter::apply(virtio_vhost_fs_seccomp_filter) {
error!("Error applying seccomp filter: {:?}", e);

View File

@@ -244,7 +244,7 @@ impl VirtioDevice for Net {
get_seccomp_filter(&self.seccomp_action, Thread::VirtioVhostNetCtl)
.map_err(ActivateError::CreateSeccompFilter)?;
thread::Builder::new()
.name("vhost_net_ctl".to_string())
.name(format!("{}_ctrl", self.id))
.spawn(move || {
if let Err(e) = SeccompFilter::apply(virtio_vhost_net_ctl_seccomp_filter) {
error!("Error applying seccomp filter: {:?}", e);
@@ -270,7 +270,7 @@ impl VirtioDevice for Net {
.map_err(ActivateError::VhostUserNetSetup)?;
let mut epoll_threads = Vec::new();
for _ in 0..vu_interrupt_list.len() / 2 {
for i in 0..vu_interrupt_list.len() / 2 {
let mut interrupt_list_sub: Vec<(Option<EventFd>, Queue)> = Vec::with_capacity(2);
interrupt_list_sub.push(vu_interrupt_list.remove(0));
interrupt_list_sub.push(vu_interrupt_list.remove(0));
@@ -310,7 +310,7 @@ impl VirtioDevice for Net {
get_seccomp_filter(&self.seccomp_action, Thread::VirtioVhostNet)
.map_err(ActivateError::CreateSeccompFilter)?;
thread::Builder::new()
.name("vhost_net".to_string())
.name(format!("{}_qp{}", self.id.clone(), i))
.spawn(move || {
if let Err(e) = SeccompFilter::apply(virtio_vhost_net_seccomp_filter) {
error!("Error applying seccomp filter: {:?}", e);