summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2020-06-12 10:12:32 +0000
committerAlyssa Ross <hi@alyssa.is>2020-07-02 12:33:06 +0000
commitca7331a0fcbf476f782014ff81d06ba5ca08e2a3 (patch)
tree3bbf1560626f74b0fc0b242a1a2bfcc50138d76d
parent544cb6bcda8654747e2de3d67c25182f3850ab2c (diff)
downloadcrosvm-ca7331a0fcbf476f782014ff81d06ba5ca08e2a3.tar
crosvm-ca7331a0fcbf476f782014ff81d06ba5ca08e2a3.tar.gz
crosvm-ca7331a0fcbf476f782014ff81d06ba5ca08e2a3.tar.bz2
crosvm-ca7331a0fcbf476f782014ff81d06ba5ca08e2a3.tar.lz
crosvm-ca7331a0fcbf476f782014ff81d06ba5ca08e2a3.tar.xz
crosvm-ca7331a0fcbf476f782014ff81d06ba5ca08e2a3.tar.zst
crosvm-ca7331a0fcbf476f782014ff81d06ba5ca08e2a3.zip
debug
-rw-r--r--devices/src/virtio/virtio_pci_device.rs11
-rw-r--r--devices/src/virtio/wl.rs8
-rw-r--r--src/linux.rs11
3 files changed, 24 insertions, 6 deletions
diff --git a/devices/src/virtio/virtio_pci_device.rs b/devices/src/virtio/virtio_pci_device.rs
index 7453e4c..b3288d4 100644
--- a/devices/src/virtio/virtio_pci_device.rs
+++ b/devices/src/virtio/virtio_pci_device.rs
@@ -295,6 +295,7 @@ impl VirtioPciDevice {
     fn is_driver_ready(&self) -> bool {
         let ready_bits =
             (DEVICE_ACKNOWLEDGE | DEVICE_DRIVER | DEVICE_DRIVER_OK | DEVICE_FEATURES_OK) as u8;
+        eprintln!("driver_status: {:b}", self.common_config.driver_status);
         self.common_config.driver_status == ready_bits
             && self.common_config.driver_status & DEVICE_FAILED as u8 == 0
     }
@@ -608,6 +609,7 @@ impl PciDevice for VirtioPciDevice {
 
     #[allow(clippy::absurd_extreme_comparisons)]
     fn write_bar(&mut self, addr: u64, data: &[u8]) {
+        eprintln!("Writing VirtioPciDevice bar for {:?}", self.device);
         let bar0 = self.config_regs.get_bar_addr(self.settings_bar as usize);
         let offset = addr - bar0;
         match offset {
@@ -653,7 +655,12 @@ impl PciDevice for VirtioPciDevice {
             _ => (),
         };
 
-        if !self.device_activated && self.is_driver_ready() && self.are_queues_valid() {
+        if !dbg!(self.device_activated)
+            && dbg!(self.is_driver_ready())
+            && dbg!(self.are_queues_valid())
+        {
+            eprintln!("Device needs activating: {:?}", self.device);
+
             if let Some(interrupt_evt) = self.interrupt_evt.take() {
                 self.interrupt_evt = match interrupt_evt.try_clone() {
                     Ok(evt) => Some(evt),
@@ -688,6 +695,8 @@ impl PciDevice for VirtioPciDevice {
                             self.common_config.msix_config,
                         ));
 
+                        eprintln!("Activating {:?}", self.device);
+
                         match self.clone_queue_evts() {
                             Ok(queue_evts) => {
                                 self.device.activate(
diff --git a/devices/src/virtio/wl.rs b/devices/src/virtio/wl.rs
index fd11839..13471f4 100644
--- a/devices/src/virtio/wl.rs
+++ b/devices/src/virtio/wl.rs
@@ -1437,7 +1437,7 @@ impl Worker {
             };
 
             for event in &events {
-                match event.token() {
+                match dbg!(event.token()) {
                     Token::InQueue => {
                         let _ = in_queue_evt.read();
                         // Used to buffer descriptor indexes that are invalid for our uses.
@@ -1503,7 +1503,7 @@ impl Worker {
                         }
                     }
                     Token::CommandSocket => {
-                        let resp = match self.control_socket.recv() {
+                        let resp = match dbg!(self.control_socket.recv()) {
                             Ok(WlControlCommand::AddSocket { name, path }) => {
                                 self.state.add_path(name, path).into()
                             }
@@ -1516,7 +1516,7 @@ impl Worker {
                             }
                         };
 
-                        if let Err(e) = self.control_socket.send(&resp) {
+                        if let Err(e) = self.control_socket.send(dbg!(&resp)) {
                             error!("control socket failed send: {}", e);
                             break 'poll;
                         }
@@ -1764,6 +1764,8 @@ impl VirtioDevice for Wl {
         mut queues: Vec<Queue>,
         queue_evts: Vec<EventFd>,
     ) {
+        eprintln!("+++++++ Activating Wl device");
+
         if queues.len() != QUEUE_SIZES.len() || queue_evts.len() != QUEUE_SIZES.len() {
             return;
         }
diff --git a/src/linux.rs b/src/linux.rs
index 3ef323e..e9ee659 100644
--- a/src/linux.rs
+++ b/src/linux.rs
@@ -1826,6 +1826,12 @@ pub fn run_config(cfg: Config) -> Result<()> {
     let (wayland_host_socket, wayland_device_control_socket) =
         msg_socket::pair::<VmMemoryResponse, VmMemoryRequest>().map_err(Error::CreateSocket)?;
     control_sockets.push(TaggedControlSocket::VmMemory(wayland_host_socket));
+
+    eprintln!(
+        "Wayland control socket at index {}",
+        control_sockets.len() - 1
+    );
+
     // Balloon gets a special socket so balloon requests can be forwarded from the main process.
     let (balloon_host_socket, balloon_device_control_socket) =
         msg_socket::pair::<BalloonControlCommand, BalloonControlResult>()
@@ -2107,7 +2113,7 @@ fn run_control(
 
         let mut vm_control_indices_to_remove = Vec::new();
         for event in events.iter_readable() {
-            match event.token() {
+            match dbg!(event.token()) {
                 Token::Exit => {
                     info!("vcpu requested shutdown");
                     break 'poll;
@@ -2267,9 +2273,10 @@ fn run_control(
                     }
                 }
                 Token::VmControl { index } => {
+                    eprintln!("Received VM control message: {{ index: {:?} }}", index);
                     if let Some(socket) = control_sockets.get(index) {
                         match socket {
-                            TaggedControlSocket::Vm(socket) => match socket.recv() {
+                            TaggedControlSocket::Vm(socket) => match dbg!(socket.recv()) {
                                 Ok(request) => {
                                     let device_socket = request.socket(
                                         &balloon_host_socket,