summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2020-03-13 23:55:09 +0000
committerAlyssa Ross <hi@alyssa.is>2020-06-15 09:36:50 +0000
commit4ccaa638e7e068e885ac2d9fedf7161ea8970514 (patch)
treec94c0410751214204559c3c290a06ce8484de521
parentc11d38c9d7101de4b2bf8421fb9242f929debf70 (diff)
downloadcrosvm-4ccaa638e7e068e885ac2d9fedf7161ea8970514.tar
crosvm-4ccaa638e7e068e885ac2d9fedf7161ea8970514.tar.gz
crosvm-4ccaa638e7e068e885ac2d9fedf7161ea8970514.tar.bz2
crosvm-4ccaa638e7e068e885ac2d9fedf7161ea8970514.tar.lz
crosvm-4ccaa638e7e068e885ac2d9fedf7161ea8970514.tar.xz
crosvm-4ccaa638e7e068e885ac2d9fedf7161ea8970514.tar.zst
crosvm-4ccaa638e7e068e885ac2d9fedf7161ea8970514.zip
be more panicky
-rw-r--r--devices/src/virtio/controller.rs37
1 files changed, 16 insertions, 21 deletions
diff --git a/devices/src/virtio/controller.rs b/devices/src/virtio/controller.rs
index 2fe8488..7a5ab71 100644
--- a/devices/src/virtio/controller.rs
+++ b/devices/src/virtio/controller.rs
@@ -159,7 +159,7 @@ impl Worker {
             }
 
             Err(e) => {
-                error!("recv failed: {:?}", e);
+                panic!("recv failed: {:?}", e);
             }
         }
     }
@@ -171,10 +171,7 @@ impl Worker {
             Ok(SignalConfigChanged) => self.interrupt.signal_config_changed().unwrap(),
             Ok(InterruptResample) => self.interrupt.interrupt_resample().unwrap(),
 
-            Err(e) => {
-                eprintln!("recv error: {}", e);
-                panic!("recv error: {}", e)
-            }
+            Err(e) => panic!("recv failed: {}", e),
         }
     }
 
@@ -182,7 +179,7 @@ impl Worker {
         if let Err(e) = self.device_socket.send(poly_msg_socket::Value::MsgOnSocket(
             MsgOnSocketRequest::Kill,
         )) {
-            error!("failed to send Kill message: {}", e);
+            error!("failed to send Kill: {}", e);
         }
     }
 
@@ -201,8 +198,7 @@ impl Worker {
         ]) {
             Ok(pc) => pc,
             Err(e) => {
-                error!("failed creating PollContext: {}", e);
-                return;
+                panic!("failed creating PollContext: {}", e);
             }
         };
 
@@ -210,8 +206,7 @@ impl Worker {
             let events = match poll_ctx.wait() {
                 Ok(v) => v,
                 Err(e) => {
-                    error!("failed polling for events: {}", e);
-                    break;
+                    panic!("failed polling for events: {}", e);
                 }
             };
 
@@ -295,7 +290,7 @@ impl VirtioDevice for Controller {
 
     fn ack_features(&mut self, value: u64) {
         if let Err(e) = self.socket.send(MsgOnSocketRequest::AckFeatures(value)) {
-            error!("failed to send AckFeatures: {}", e);
+            panic!("failed to send AckFeatures: {}", e);
         }
     }
 
@@ -303,15 +298,14 @@ impl VirtioDevice for Controller {
         let len = data.len();
 
         if let Err(e) = self.socket.send(BincodeRequest::ReadConfig { offset, len }) {
-            error!("failed to send ReadConfig: {}", e);
-            return;
+            panic!("failed to send ReadConfig: {}", e);
         }
 
         match self.socket.recv_bincode() {
             Ok(BincodeResponse::ReadConfig(response)) => {
                 data.copy_from_slice(&response[..len]); // TODO: test no panic
             }
-            response => error!("bad response to ReadConfig: {:?}", response),
+            response => panic!("bad response to ReadConfig: {:?}", response),
         }
     }
 
@@ -332,14 +326,17 @@ impl VirtioDevice for Controller {
         queue_evts: Vec<EventFd>,
     ) {
         if queues.len() != QUEUE_SIZES.len() || queue_evts.len() != QUEUE_SIZES.len() {
-            return;
+            panic!(
+                "queues ({}) or queue_evts ({}) wrong size",
+                queues.len(),
+                queue_evts.len()
+            );
         }
 
         let (self_kill_evt, kill_evt) = match EventFd::new().and_then(|e| Ok((e.try_clone()?, e))) {
             Ok(v) => v,
             Err(e) => {
-                error!("failed creating kill EventFd pair: {}", e);
-                return;
+                panic!("failed creating kill EventFd pair: {}", e);
             }
         };
         self.kill_evt = Some(self_kill_evt);
@@ -355,8 +352,7 @@ impl VirtioDevice for Controller {
             in_queue_evt: MaybeOwnedFd::new_borrowed(&queue_evts[0]),
             out_queue_evt: MaybeOwnedFd::new_borrowed(&queue_evts[1]),
         }) {
-            error!("failed to send Activate: {}", e);
-            return;
+            panic!("failed to send Activate: {}", e);
         }
 
         let socket = Arc::clone(&self.socket);
@@ -368,8 +364,7 @@ impl VirtioDevice for Controller {
 
         match worker_result {
             Err(e) => {
-                error!("failed to spawn virtio_wl worker: {}", e);
-                return;
+                panic!("failed to spawn virtio_wl worker: {}", e);
             }
             Ok(join_handle) => {
                 self.worker_thread = Some(join_handle);