summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2020-06-12 10:11:06 +0000
committerAlyssa Ross <hi@alyssa.is>2020-07-02 12:33:05 +0000
commit544cb6bcda8654747e2de3d67c25182f3850ab2c (patch)
treebf72d04500aa85762c4f1b6b4b80153d17077831
parentf57267d7e998ffec48794723b188b35489acfeec (diff)
downloadcrosvm-544cb6bcda8654747e2de3d67c25182f3850ab2c.tar
crosvm-544cb6bcda8654747e2de3d67c25182f3850ab2c.tar.gz
crosvm-544cb6bcda8654747e2de3d67c25182f3850ab2c.tar.bz2
crosvm-544cb6bcda8654747e2de3d67c25182f3850ab2c.tar.lz
crosvm-544cb6bcda8654747e2de3d67c25182f3850ab2c.tar.xz
crosvm-544cb6bcda8654747e2de3d67c25182f3850ab2c.tar.zst
crosvm-544cb6bcda8654747e2de3d67c25182f3850ab2c.zip
Make lots of things Debug
-rw-r--r--devices/src/proxy.rs2
-rw-r--r--devices/src/virtio/balloon.rs3
-rw-r--r--devices/src/virtio/block.rs1
-rw-r--r--devices/src/virtio/console.rs6
-rw-r--r--devices/src/virtio/controller.rs1
-rw-r--r--devices/src/virtio/fs/mod.rs7
-rw-r--r--devices/src/virtio/fs/multikey.rs1
-rw-r--r--devices/src/virtio/fs/passthrough.rs5
-rw-r--r--devices/src/virtio/input/event_source.rs3
-rw-r--r--devices/src/virtio/input/mod.rs10
-rw-r--r--devices/src/virtio/net.rs3
-rw-r--r--devices/src/virtio/p9.rs1
-rw-r--r--devices/src/virtio/pmem.rs1
-rw-r--r--devices/src/virtio/resource_bridge.rs2
-rw-r--r--devices/src/virtio/rng.rs1
-rw-r--r--devices/src/virtio/vhost/net.rs5
-rw-r--r--devices/src/virtio/vhost/vsock.rs1
-rw-r--r--devices/src/virtio/virtio_device.rs2
-rw-r--r--devices/src/virtio/virtio_pci_common_config.rs1
-rw-r--r--devices/src/virtio/wl.rs1
-rw-r--r--net_util/src/lib.rs1
-rw-r--r--p9/src/server.rs2
-rw-r--r--sys_util/src/guest_memory.rs3
-rw-r--r--vhost/src/net.rs2
-rw-r--r--vhost/src/vsock.rs1
25 files changed, 55 insertions, 11 deletions
diff --git a/devices/src/proxy.rs b/devices/src/proxy.rs
index cc31550..344a789 100644
--- a/devices/src/proxy.rs
+++ b/devices/src/proxy.rs
@@ -30,7 +30,7 @@ pub enum Command {
     Shutdown,
 }
 
-#[derive(MsgOnSocket)]
+#[derive(Debug, MsgOnSocket)]
 pub enum CommandResult {
     Ok,
     ReadResult([u8; 8]),
diff --git a/devices/src/virtio/balloon.rs b/devices/src/virtio/balloon.rs
index d115377..dfefcf4 100644
--- a/devices/src/virtio/balloon.rs
+++ b/devices/src/virtio/balloon.rs
@@ -64,7 +64,7 @@ struct virtio_balloon_config {
 unsafe impl DataInit for virtio_balloon_config {}
 
 // BalloonConfig is modified by the worker and read from the device thread.
-#[derive(Default)]
+#[derive(Debug, Default)]
 struct BalloonConfig {
     num_pages: AtomicUsize,
     actual_pages: AtomicUsize,
@@ -323,6 +323,7 @@ impl Worker {
 }
 
 /// Virtio device for memory balloon inflation/deflation.
+#[derive(Debug)]
 pub struct Balloon {
     command_socket: Option<BalloonControlResponseSocket>,
     config: Arc<BalloonConfig>,
diff --git a/devices/src/virtio/block.rs b/devices/src/virtio/block.rs
index 57a243b..73b1f1f 100644
--- a/devices/src/virtio/block.rs
+++ b/devices/src/virtio/block.rs
@@ -459,6 +459,7 @@ impl Worker {
 }
 
 /// Virtio device for exposing block level read/write operations on a host file.
+#[derive(Debug)]
 pub struct Block {
     kill_evt: Option<EventFd>,
     worker_thread: Option<thread::JoinHandle<Worker>>,
diff --git a/devices/src/virtio/console.rs b/devices/src/virtio/console.rs
index e22f91d..10389bd 100644
--- a/devices/src/virtio/console.rs
+++ b/devices/src/virtio/console.rs
@@ -304,6 +304,12 @@ pub struct Console {
     keep_fds: Vec<RawFd>,
 }
 
+impl std::fmt::Debug for Console {
+    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+        write!(f, "Console {{ .. }}")
+    }
+}
+
 impl SerialDevice for Console {
     fn new(
         _evt_fd: EventFd,
diff --git a/devices/src/virtio/controller.rs b/devices/src/virtio/controller.rs
index dbb14e6..42e8a1d 100644
--- a/devices/src/virtio/controller.rs
+++ b/devices/src/virtio/controller.rs
@@ -145,6 +145,7 @@ impl Worker {
     }
 }
 
+#[derive(Debug)]
 pub struct Controller {
     kill_evt: Option<EventFd>,
     worker_thread: Option<thread::JoinHandle<()>>,
diff --git a/devices/src/virtio/fs/mod.rs b/devices/src/virtio/fs/mod.rs
index 63b2a04..21cda40 100644
--- a/devices/src/virtio/fs/mod.rs
+++ b/devices/src/virtio/fs/mod.rs
@@ -47,6 +47,12 @@ struct Config {
     num_queues: Le32,
 }
 
+impl std::fmt::Debug for Config {
+    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+        write!(f, "Config {{ .. }}")
+    }
+}
+
 // Safe because all members are plain old data and any value is valid.
 unsafe impl DataInit for Config {}
 
@@ -129,6 +135,7 @@ impl fmt::Display for Error {
 
 pub type Result<T> = ::std::result::Result<T, Error>;
 
+#[derive(Debug)]
 pub struct Fs {
     cfg: Config,
     fs: Option<PassthroughFs>,
diff --git a/devices/src/virtio/fs/multikey.rs b/devices/src/virtio/fs/multikey.rs
index b1e22f4..9bf355e 100644
--- a/devices/src/virtio/fs/multikey.rs
+++ b/devices/src/virtio/fs/multikey.rs
@@ -9,6 +9,7 @@ use std::collections::BTreeMap;
 /// `std::collections::BTreeMap` also apply to this struct. Additionally, there is a 1:1
 /// relationship between the 2 key types. In other words, for each `K1` in the map, there is exactly
 /// one `K2` in the map and vice versa.
+#[derive(Debug)]
 pub struct MultikeyBTreeMap<K1, K2, V> {
     // We need to keep a copy of the second key in the main map so that we can remove entries using
     // just the main key. Otherwise we would require the caller to provide both keys when calling
diff --git a/devices/src/virtio/fs/passthrough.rs b/devices/src/virtio/fs/passthrough.rs
index 4833bb7..f3d3fd0 100644
--- a/devices/src/virtio/fs/passthrough.rs
+++ b/devices/src/virtio/fs/passthrough.rs
@@ -49,12 +49,13 @@ ioctl_iow_nr!(FS_IOC_GET_ENCRYPTION_POLICY, 0x66, 21, fscrypt_policy_v1);
 type Inode = u64;
 type Handle = u64;
 
-#[derive(Clone, Copy, PartialOrd, Ord, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, PartialOrd, Ord, PartialEq, Eq)]
 struct InodeAltKey {
     ino: libc::ino64_t,
     dev: libc::dev_t,
 }
 
+#[derive(Debug)]
 struct InodeData {
     inode: Inode,
     // Most of these aren't actually files but ¯\_(ツ)_/¯.
@@ -62,6 +63,7 @@ struct InodeData {
     refcount: AtomicU64,
 }
 
+#[derive(Debug)]
 struct HandleData {
     inode: Inode,
     file: Mutex<File>,
@@ -304,6 +306,7 @@ impl Default for Config {
 /// that wish to serve only a specific directory should set up the environment so that that
 /// directory ends up as the root of the file system process. One way to accomplish this is via a
 /// combination of mount namespaces and the pivot_root system call.
+#[derive(Debug)]
 pub struct PassthroughFs {
     // File descriptors for various points in the file system tree. These fds are always opened with
     // the `O_PATH` option so they cannot be used for reading or writing any data. See the
diff --git a/devices/src/virtio/input/event_source.rs b/devices/src/virtio/input/event_source.rs
index 392c121..25e6e74 100644
--- a/devices/src/virtio/input/event_source.rs
+++ b/devices/src/virtio/input/event_source.rs
@@ -42,6 +42,7 @@ pub trait EventSource: AsRawFd {
 }
 
 /// Encapsulates implementation details common to all kinds of event sources.
+#[derive(Debug)]
 pub struct EventSourceImpl<T> {
     source: T,
     queue: VecDeque<virtio_input_event>,
@@ -135,6 +136,7 @@ enum EventType {
 }
 
 /// Encapsulates a (unix) socket as an event source.
+#[derive(Debug)]
 pub struct SocketEventSource<T> {
     evt_source_impl: EventSourceImpl<T>,
 }
@@ -187,6 +189,7 @@ where
 }
 
 /// Encapsulates an event device node as an event source
+#[derive(Debug)]
 pub struct EvdevEventSource<T> {
     evt_source_impl: EventSourceImpl<T>,
 }
diff --git a/devices/src/virtio/input/mod.rs b/devices/src/virtio/input/mod.rs
index 7c9418c..7d5b91a 100644
--- a/devices/src/virtio/input/mod.rs
+++ b/devices/src/virtio/input/mod.rs
@@ -243,6 +243,12 @@ pub struct VirtioInputConfig {
     axis_info: BTreeMap<u16, virtio_input_absinfo>,
 }
 
+impl std::fmt::Debug for VirtioInputConfig {
+    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+        write!(f, "VirtioInputConfig {{ .. }}")
+    }
+}
+
 impl VirtioInputConfig {
     fn new(
         device_ids: virtio_input_device_ids,
@@ -534,7 +540,7 @@ impl<T: EventSource> Worker<T> {
 }
 
 /// Virtio input device
-
+#[derive(Debug)]
 pub struct Input<T: EventSource> {
     kill_evt: Option<EventFd>,
     worker_thread: Option<thread::JoinHandle<Worker<T>>>,
@@ -557,7 +563,7 @@ impl<T: EventSource> Drop for Input<T> {
 
 impl<T> VirtioDevice for Input<T>
 where
-    T: 'static + EventSource + Send,
+    T: 'static + EventSource + Send + std::fmt::Debug,
 {
     fn keep_fds(&self) -> Vec<RawFd> {
         if let Some(source) = &self.source {
diff --git a/devices/src/virtio/net.rs b/devices/src/virtio/net.rs
index c15bd3d..dca2b06 100644
--- a/devices/src/virtio/net.rs
+++ b/devices/src/virtio/net.rs
@@ -418,6 +418,7 @@ where
     }
 }
 
+#[derive(Debug)]
 pub struct Net<T: TapT> {
     queue_sizes: Box<[u16]>,
     workers_kill_evt: Vec<EventFd>,
@@ -575,7 +576,7 @@ where
 
 impl<T> VirtioDevice for Net<T>
 where
-    T: 'static + TapT,
+    T: 'static + TapT + std::fmt::Debug,
 {
     fn keep_fds(&self) -> Vec<RawFd> {
         let mut keep_fds = Vec::new();
diff --git a/devices/src/virtio/p9.rs b/devices/src/virtio/p9.rs
index c139c53..8a4f85e 100644
--- a/devices/src/virtio/p9.rs
+++ b/devices/src/virtio/p9.rs
@@ -147,6 +147,7 @@ impl Worker {
 }
 
 /// Virtio device for sharing specific directories on the host system with the guest VM.
+#[derive(Debug)]
 pub struct P9 {
     config: Vec<u8>,
     server: Option<p9::Server>,
diff --git a/devices/src/virtio/pmem.rs b/devices/src/virtio/pmem.rs
index 72d47c4..296b90c 100644
--- a/devices/src/virtio/pmem.rs
+++ b/devices/src/virtio/pmem.rs
@@ -219,6 +219,7 @@ impl Worker {
     }
 }
 
+#[derive(Debug)]
 pub struct Pmem {
     kill_event: Option<EventFd>,
     worker_thread: Option<thread::JoinHandle<()>>,
diff --git a/devices/src/virtio/resource_bridge.rs b/devices/src/virtio/resource_bridge.rs
index 2a2343f..68491d6 100644
--- a/devices/src/virtio/resource_bridge.rs
+++ b/devices/src/virtio/resource_bridge.rs
@@ -11,7 +11,7 @@ use std::fs::File;
 use msg_on_socket_derive::MsgOnSocket;
 use msg_socket::{MsgError, MsgReceiver, MsgSender, MsgSocket};
 
-#[derive(MsgOnSocket)]
+#[derive(Debug, MsgOnSocket)]
 pub enum ResourceRequest {
     GetResource { id: u32 },
 }
diff --git a/devices/src/virtio/rng.rs b/devices/src/virtio/rng.rs
index ec1eb64..28bda81 100644
--- a/devices/src/virtio/rng.rs
+++ b/devices/src/virtio/rng.rs
@@ -118,6 +118,7 @@ impl Worker {
 }
 
 /// Virtio device for exposing entropy to the guest OS through virtio.
+#[derive(Debug)]
 pub struct Rng {
     kill_evt: Option<EventFd>,
     worker_thread: Option<thread::JoinHandle<Worker>>,
diff --git a/devices/src/virtio/vhost/net.rs b/devices/src/virtio/vhost/net.rs
index 49fe14d..cf6d262 100644
--- a/devices/src/virtio/vhost/net.rs
+++ b/devices/src/virtio/vhost/net.rs
@@ -24,6 +24,7 @@ const QUEUE_SIZE: u16 = 256;
 const NUM_QUEUES: usize = 2;
 const QUEUE_SIZES: &[u16] = &[QUEUE_SIZE; NUM_QUEUES];
 
+#[derive(Debug)]
 pub struct Net<T: TapT, U: VhostNetT<T>> {
     workers_kill_evt: Option<EventFd>,
     kill_evt: EventFd,
@@ -126,8 +127,8 @@ where
 
 impl<T, U> VirtioDevice for Net<T, U>
 where
-    T: TapT + 'static,
-    U: VhostNetT<T> + 'static,
+    T: TapT + 'static + std::fmt::Debug,
+    U: VhostNetT<T> + 'static + std::fmt::Debug,
 {
     fn keep_fds(&self) -> Vec<RawFd> {
         let mut keep_fds = Vec::new();
diff --git a/devices/src/virtio/vhost/vsock.rs b/devices/src/virtio/vhost/vsock.rs
index 70d2f2e..d0b2c0c 100644
--- a/devices/src/virtio/vhost/vsock.rs
+++ b/devices/src/virtio/vhost/vsock.rs
@@ -19,6 +19,7 @@ const QUEUE_SIZE: u16 = 256;
 const NUM_QUEUES: usize = 3;
 const QUEUE_SIZES: &[u16] = &[QUEUE_SIZE; NUM_QUEUES];
 
+#[derive(Debug)]
 pub struct Vsock {
     worker_kill_evt: Option<EventFd>,
     kill_evt: Option<EventFd>,
diff --git a/devices/src/virtio/virtio_device.rs b/devices/src/virtio/virtio_device.rs
index 1d6e4bc..645a59b 100644
--- a/devices/src/virtio/virtio_device.rs
+++ b/devices/src/virtio/virtio_device.rs
@@ -24,7 +24,7 @@ pub trait VirtioDeviceNew: Sized {
 /// and all the events, memory, and queues for device operation will be moved into the device.
 /// Optionally, a virtio device can implement device reset in which it returns said resources and
 /// resets its internal.
-pub trait VirtioDevice: Send {
+pub trait VirtioDevice: Send + Debug {
     /// Returns a label suitable for debug output.
     fn debug_label(&self) -> String {
         match type_to_str(self.device_type()) {
diff --git a/devices/src/virtio/virtio_pci_common_config.rs b/devices/src/virtio/virtio_pci_common_config.rs
index 14aefcb..56266c6 100644
--- a/devices/src/virtio/virtio_pci_common_config.rs
+++ b/devices/src/virtio/virtio_pci_common_config.rs
@@ -245,6 +245,7 @@ mod tests {
     use std::os::unix::io::RawFd;
     use sys_util::{EventFd, GuestMemory};
 
+    #[derive(Debug)]
     struct DummyDevice(u32);
     const QUEUE_SIZE: u16 = 256;
     const QUEUE_SIZES: &'static [u16] = &[QUEUE_SIZE];
diff --git a/devices/src/virtio/wl.rs b/devices/src/virtio/wl.rs
index 0ebb4ef..fd11839 100644
--- a/devices/src/virtio/wl.rs
+++ b/devices/src/virtio/wl.rs
@@ -1576,6 +1576,7 @@ impl Worker {
     }
 }
 
+#[derive(Debug)]
 pub struct Wl {
     kill_evt: Option<EventFd>,
     worker_thread: Option<thread::JoinHandle<()>>,
diff --git a/net_util/src/lib.rs b/net_util/src/lib.rs
index a91a116..8c2ffdb 100644
--- a/net_util/src/lib.rs
+++ b/net_util/src/lib.rs
@@ -527,6 +527,7 @@ pub mod fakes {
 
     const TMP_FILE: &str = "/tmp/crosvm_tap_test_file";
 
+    #[derive(Debug)]
     pub struct FakeTap {
         tap_file: File,
     }
diff --git a/p9/src/server.rs b/p9/src/server.rs
index 957923d..3574619 100644
--- a/p9/src/server.rs
+++ b/p9/src/server.rs
@@ -101,6 +101,7 @@ const MAX_MESSAGE_SIZE: u32 = ::std::u16::MAX as u32;
 // 32-bit number chosen by the client. Most messages sent by clients include a fid on which to
 // operate. The fid in a Tattach message represents the root of the file system tree that the client
 // is allowed to access. A client can create more fids by walking the directory tree from that fid.
+#[derive(Debug)]
 struct Fid {
     path: Box<Path>,
     metadata: fs::Metadata,
@@ -200,6 +201,7 @@ fn join_path<P: AsRef<Path>, R: AsRef<Path>>(
     Ok(buf)
 }
 
+#[derive(Debug)]
 pub struct Server {
     root: Box<Path>,
     msize: u32,
diff --git a/sys_util/src/guest_memory.rs b/sys_util/src/guest_memory.rs
index 0728b77..c47f626 100644
--- a/sys_util/src/guest_memory.rs
+++ b/sys_util/src/guest_memory.rs
@@ -84,6 +84,7 @@ impl Display for Error {
     }
 }
 
+#[derive(Debug)]
 struct MemoryRegion {
     mapping: MemoryMapping,
     guest_base: GuestAddress,
@@ -107,7 +108,7 @@ impl MemoryRegion {
 
 /// Tracks a memory region and where it is mapped in the guest, along with a shm
 /// fd of the underlying memory regions.
-#[derive(Clone)]
+#[derive(Clone, Debug)]
 pub struct GuestMemory {
     regions: Arc<Vec<MemoryRegion>>,
     memfd: Arc<SharedMemory>,
diff --git a/vhost/src/net.rs b/vhost/src/net.rs
index 9b59cf2..0e87056 100644
--- a/vhost/src/net.rs
+++ b/vhost/src/net.rs
@@ -18,6 +18,7 @@ static DEVICE: &str = "/dev/vhost-net";
 ///
 /// This provides a simple wrapper around a VHOST_NET file descriptor and
 /// methods that safely run ioctls on that file descriptor.
+#[derive(Debug)]
 pub struct Net<T> {
     // fd must be dropped first, which will stop and tear down the
     // vhost-net worker before GuestMemory can potentially be unmapped.
@@ -96,6 +97,7 @@ pub mod fakes {
 
     const TMP_FILE: &str = "/tmp/crosvm_vhost_test_file";
 
+    #[derive(Debug)]
     pub struct FakeNet<T> {
         fd: File,
         mem: GuestMemory,
diff --git a/vhost/src/vsock.rs b/vhost/src/vsock.rs
index 8bd27e7..9ac5c77 100644
--- a/vhost/src/vsock.rs
+++ b/vhost/src/vsock.rs
@@ -14,6 +14,7 @@ use super::{ioctl_result, Error, Result, Vhost};
 static DEVICE: &str = "/dev/vhost-vsock";
 
 /// Handle for running VHOST_VSOCK ioctls.
+#[derive(Debug)]
 pub struct Vsock {
     fd: File,
     mem: GuestMemory,