summary refs log tree commit diff
path: root/devices/src/virtio/rng.rs
diff options
context:
space:
mode:
Diffstat (limited to 'devices/src/virtio/rng.rs')
-rw-r--r--devices/src/virtio/rng.rs29
1 files changed, 18 insertions, 11 deletions
diff --git a/devices/src/virtio/rng.rs b/devices/src/virtio/rng.rs
index 292d3f1..da5d40b 100644
--- a/devices/src/virtio/rng.rs
+++ b/devices/src/virtio/rng.rs
@@ -8,7 +8,7 @@ use std::io;
 use std::os::unix::io::{AsRawFd, RawFd};
 use std::sync::Arc;
 use std::sync::atomic::{AtomicUsize, Ordering};
-use std::thread::spawn;
+use std::thread;
 
 use sys_util::{EventFd, GuestMemory, Poller};
 
@@ -172,16 +172,23 @@ impl VirtioDevice for Rng {
         let queue = queues.remove(0);
 
         if let Some(random_file) = self.random_file.take() {
-            spawn(move || {
-                let mut worker = Worker {
-                    queue: queue,
-                    mem: mem,
-                    random_file: random_file,
-                    interrupt_status: status,
-                    interrupt_evt: interrupt_evt,
-                };
-                worker.run(queue_evts.remove(0), kill_evt);
-            });
+            let worker_result = thread::Builder::new()
+                .name("virtio_rng".to_string())
+                .spawn(move || {
+                    let mut worker = Worker {
+                        queue: queue,
+                        mem: mem,
+                        random_file: random_file,
+                        interrupt_status: status,
+                        interrupt_evt: interrupt_evt,
+                    };
+                    worker.run(queue_evts.remove(0), kill_evt);
+                });
+
+            if let Err(e) = worker_result {
+                error!("failed to spawn virtio_rng worker: {}", e);
+                return;
+            }
         }
     }
 }