summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock21
-rw-r--r--Cargo.toml6
-rw-r--r--README.md3
-rw-r--r--devices/Cargo.toml15
-rw-r--r--devices/src/bus.rs (renamed from src/hw/bus.rs)0
-rw-r--r--devices/src/cmos.rs (renamed from src/hw/cmos.rs)2
-rw-r--r--devices/src/i8042.rs (renamed from src/hw/i8042.rs)2
-rw-r--r--devices/src/lib.rs (renamed from src/hw/mod.rs)21
-rw-r--r--devices/src/proxy.rs (renamed from src/hw/proxy.rs)4
-rw-r--r--devices/src/serial.rs (renamed from src/hw/serial.rs)2
-rw-r--r--devices/src/virtio/block.rs (renamed from src/hw/virtio/block.rs)0
-rw-r--r--devices/src/virtio/mmio.rs (renamed from src/hw/virtio/mmio.rs)6
-rw-r--r--devices/src/virtio/mod.rs (renamed from src/hw/virtio/mod.rs)0
-rw-r--r--devices/src/virtio/net.rs (renamed from src/hw/virtio/net.rs)0
-rw-r--r--devices/src/virtio/queue.rs (renamed from src/hw/virtio/queue.rs)0
-rw-r--r--devices/src/virtio/rng.rs (renamed from src/hw/virtio/rng.rs)0
-rw-r--r--devices/src/virtio/vhost/mod.rs (renamed from src/hw/virtio/vhost/mod.rs)0
-rw-r--r--devices/src/virtio/vhost/net.rs (renamed from src/hw/virtio/vhost/net.rs)0
-rw-r--r--devices/src/virtio/vhost/vsock.rs (renamed from src/hw/virtio/vhost/vsock.rs)0
-rw-r--r--devices/src/virtio/vhost/worker.rs (renamed from src/hw/virtio/vhost/worker.rs)0
-rw-r--r--devices/src/virtio/wl.rs (renamed from src/hw/virtio/wl.rs)0
-rw-r--r--src/device_manager.rs20
-rw-r--r--src/main.rs51
23 files changed, 92 insertions, 61 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 2c2511e..dacbf44 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4,16 +4,12 @@ version = "0.1.0"
 dependencies = [
  "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "data_model 0.1.0",
+ "devices 0.1.0",
  "io_jail 0.1.0",
  "kernel_loader 0.1.0",
  "kvm 0.1.0",
  "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
- "net_sys 0.1.0",
- "net_util 0.1.0",
  "sys_util 0.1.0",
- "syscall_defines 0.1.0",
- "vhost 0.1.0",
- "virtio_sys 0.1.0",
  "vm_control 0.1.0",
  "x86_64 0.1.0",
 ]
@@ -28,6 +24,21 @@ name = "data_model"
 version = "0.1.0"
 
 [[package]]
+name = "devices"
+version = "0.1.0"
+dependencies = [
+ "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "data_model 0.1.0",
+ "libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
+ "net_sys 0.1.0",
+ "net_util 0.1.0",
+ "sys_util 0.1.0",
+ "vhost 0.1.0",
+ "virtio_sys 0.1.0",
+ "vm_control 0.1.0",
+]
+
+[[package]]
 name = "gcc"
 version = "0.3.54"
 source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index a9c3b76..875ce99 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,17 +8,13 @@ lto = true
 panic = 'abort'
 
 [dependencies]
+devices = { path = "devices" }
 io_jail = { path = "io_jail" }
 kvm = { path = "kvm" }
 sys_util = { path = "sys_util" }
 kernel_loader = { path = "kernel_loader" }
 libc = "=0.2.29"
 byteorder = "=1.1.0"
-syscall_defines = { path = "syscall_defines" }
-net_sys = { path = "net_sys" }
-net_util = { path = "net_util" }
-vhost = { path = "vhost" }
-virtio_sys = { path = "virtio_sys" }
 vm_control = { path = "vm_control" }
 data_model = { path = "data_model" }
 
diff --git a/README.md b/README.md
index 580f5ac..0427a7d 100644
--- a/README.md
+++ b/README.md
@@ -162,7 +162,8 @@ v1.20 or later.
 Source code is organized into crates, each with their own unit tests. These
 crates are:
 
-* `crosvm` - The top-level binary front-end for using crosvm, along with all devices.
+* `crosvm` - The top-level binary front-end for using crosvm.
+* `devices` - Virtual devices exposed to the guest OS.
 * `io_jail` - Creates jailed process using `libminijail`.
 * `kernel_loader` - Loads elf64 kernel files to a slice of memory.
 * `kvm_sys` - Low-level (mostly) auto-generated structures and constants for using KVM.
diff --git a/devices/Cargo.toml b/devices/Cargo.toml
new file mode 100644
index 0000000..1c1eeb9
--- /dev/null
+++ b/devices/Cargo.toml
@@ -0,0 +1,15 @@
+[package]
+name = "devices"
+version = "0.1.0"
+authors = ["The Chromium OS Authors"]
+
+[dependencies]
+byteorder = "*"
+data_model = { path = "../data_model" }
+libc = "*"
+net_sys = { path = "../net_sys" }
+net_util = { path = "../net_util" }
+sys_util = { path = "../sys_util" }
+vhost = { path = "../vhost" }
+virtio_sys = { path = "../virtio_sys" }
+vm_control = { path = "../vm_control" }
diff --git a/src/hw/bus.rs b/devices/src/bus.rs
index 030694a..030694a 100644
--- a/src/hw/bus.rs
+++ b/devices/src/bus.rs
diff --git a/src/hw/cmos.rs b/devices/src/cmos.rs
index 5efebe1..70caff7 100644
--- a/src/hw/cmos.rs
+++ b/devices/src/cmos.rs
@@ -5,7 +5,7 @@
 use std::mem;
 use libc::{tm, time_t, time, gmtime_r};
 
-use hw::BusDevice;
+use BusDevice;
 
 const INDEX_MASK: u8 = 0x7f;
 const INDEX_OFFSET: u64 = 0x0;
diff --git a/src/hw/i8042.rs b/devices/src/i8042.rs
index 33e94d6..b046184 100644
--- a/src/hw/i8042.rs
+++ b/devices/src/i8042.rs
@@ -4,7 +4,7 @@
 
 use sys_util::EventFd;
 
-use hw::BusDevice;
+use BusDevice;
 
 /// A i8042 PS/2 controller that emulates just enough to shutdown the machine.
 pub struct I8042Device {
diff --git a/src/hw/mod.rs b/devices/src/lib.rs
index d6d80fe..4b1a6a5 100644
--- a/src/hw/mod.rs
+++ b/devices/src/lib.rs
@@ -4,15 +4,26 @@
 
 //! Emulates virtual and hardware devices.
 
+extern crate byteorder;
+extern crate data_model;
+extern crate libc;
+extern crate net_sys;
+extern crate net_util;
+#[macro_use]
+extern crate sys_util;
+extern crate vhost;
+extern crate virtio_sys;
+extern crate vm_control;
+
+mod bus;
 mod cmos;
-mod serial;
 mod i8042;
-mod bus;
 mod proxy;
+mod serial;
 pub mod virtio;
 
+pub use self::bus::{Bus, BusDevice};
 pub use self::cmos::Cmos;
-pub use self::serial::Serial;
 pub use self::i8042::I8042Device;
-pub use self::bus::{Bus, BusDevice};
-pub use self::proxy::ProxyDevice;
\ No newline at end of file
+pub use self::proxy::ProxyDevice;
+pub use self::serial::Serial;
diff --git a/src/hw/proxy.rs b/devices/src/proxy.rs
index e313a2c..c55f5a3 100644
--- a/src/hw/proxy.rs
+++ b/devices/src/proxy.rs
@@ -12,7 +12,7 @@ use std::time::Duration;
 
 use byteorder::{NativeEndian, ByteOrder};
 
-use hw::BusDevice;
+use BusDevice;
 use sys_util::{clone_process, CloneNamespace};
 
 const SOCKET_TIMEOUT_MS: u64 = 2000;
@@ -68,7 +68,7 @@ fn child_proc(sock: UnixDatagram, device: &mut BusDevice) {
     }
 }
 
-/// Wraps an inner `hw::BusDevice` that is run inside a child process via fork.
+/// Wraps an inner `BusDevice` that is run inside a child process via fork.
 ///
 /// Because forks are very unfriendly to destructors and all memory mappings and file descriptors
 /// are inherited, this should be used as early as possible in the main process.
diff --git a/src/hw/serial.rs b/devices/src/serial.rs
index 0e1b017..6d7512f 100644
--- a/src/hw/serial.rs
+++ b/devices/src/serial.rs
@@ -7,7 +7,7 @@ use std::collections::VecDeque;
 
 use sys_util::{EventFd, Result};
 
-use hw::BusDevice;
+use BusDevice;
 
 const LOOP_SIZE: usize = 0x40;
 
diff --git a/src/hw/virtio/block.rs b/devices/src/virtio/block.rs
index 1af2693..1af2693 100644
--- a/src/hw/virtio/block.rs
+++ b/devices/src/virtio/block.rs
diff --git a/src/hw/virtio/mmio.rs b/devices/src/virtio/mmio.rs
index 2afdb05..1548f40 100644
--- a/src/hw/virtio/mmio.rs
+++ b/devices/src/virtio/mmio.rs
@@ -9,7 +9,7 @@ use std::sync::atomic::{AtomicUsize, Ordering};
 use byteorder::{ByteOrder, LittleEndian};
 
 use super::*;
-use hw::BusDevice;
+use BusDevice;
 use sys_util::{Result, EventFd, GuestAddress, GuestMemory};
 
 const VENDOR_ID: u32 = 0;
@@ -81,7 +81,7 @@ pub trait VirtioDevice: Send {
 /// This requires 3 points of installation to work with a VM:
 ///
 /// 1. Mmio reads and writes must be sent to this device at what is referred to here as MMIO base.
-/// 1. `Mmio::queue_evts` must be installed at `hw::virtio::NOITFY_REG_OFFSET` offset from the MMIO
+/// 1. `Mmio::queue_evts` must be installed at `virtio::NOITFY_REG_OFFSET` offset from the MMIO
 /// base. Each event in the array must be signaled if the index is written at that offset.
 /// 1. `Mmio::interrupt_evt` must signal an interrupt that the guest driver is listening to when it
 /// is written to.
@@ -133,7 +133,7 @@ impl MmioDevice {
     }
 
     /// Gets the list of queue events that must be triggered whenever the VM writes to
-    /// `hw::virtio::NOITFY_REG_OFFSET` past the MMIO base. Each event must be triggered when the
+    /// `virtio::NOITFY_REG_OFFSET` past the MMIO base. Each event must be triggered when the
     /// value being written equals the index of the event in this list.
     pub fn queue_evts(&self) -> &[EventFd] {
         self.queue_evts.as_slice()
diff --git a/src/hw/virtio/mod.rs b/devices/src/virtio/mod.rs
index 7c1bf1c..7c1bf1c 100644
--- a/src/hw/virtio/mod.rs
+++ b/devices/src/virtio/mod.rs
diff --git a/src/hw/virtio/net.rs b/devices/src/virtio/net.rs
index d632dd6..d632dd6 100644
--- a/src/hw/virtio/net.rs
+++ b/devices/src/virtio/net.rs
diff --git a/src/hw/virtio/queue.rs b/devices/src/virtio/queue.rs
index 955f117..955f117 100644
--- a/src/hw/virtio/queue.rs
+++ b/devices/src/virtio/queue.rs
diff --git a/src/hw/virtio/rng.rs b/devices/src/virtio/rng.rs
index 292d3f1..292d3f1 100644
--- a/src/hw/virtio/rng.rs
+++ b/devices/src/virtio/rng.rs
diff --git a/src/hw/virtio/vhost/mod.rs b/devices/src/virtio/vhost/mod.rs
index 1a45c5b..1a45c5b 100644
--- a/src/hw/virtio/vhost/mod.rs
+++ b/devices/src/virtio/vhost/mod.rs
diff --git a/src/hw/virtio/vhost/net.rs b/devices/src/virtio/vhost/net.rs
index 6fc978e..6fc978e 100644
--- a/src/hw/virtio/vhost/net.rs
+++ b/devices/src/virtio/vhost/net.rs
diff --git a/src/hw/virtio/vhost/vsock.rs b/devices/src/virtio/vhost/vsock.rs
index a3c24aa..a3c24aa 100644
--- a/src/hw/virtio/vhost/vsock.rs
+++ b/devices/src/virtio/vhost/vsock.rs
diff --git a/src/hw/virtio/vhost/worker.rs b/devices/src/virtio/vhost/worker.rs
index 12d879a..12d879a 100644
--- a/src/hw/virtio/vhost/worker.rs
+++ b/devices/src/virtio/vhost/worker.rs
diff --git a/src/hw/virtio/wl.rs b/devices/src/virtio/wl.rs
index 1ea384c..1ea384c 100644
--- a/src/hw/virtio/wl.rs
+++ b/devices/src/virtio/wl.rs
diff --git a/src/device_manager.rs b/src/device_manager.rs
index 642bb7c..6fb2836 100644
--- a/src/device_manager.rs
+++ b/src/device_manager.rs
@@ -18,7 +18,7 @@ use kvm::IoeventAddress;
 use sys_util::{EventFd, GuestMemory, syslog};
 use sys_util;
 
-use hw;
+use devices;
 use kernel_cmdline;
 use vm_control::VmRequest;
 
@@ -74,7 +74,7 @@ const MAX_IRQ: u32 = 15;
 
 /// Manages the complexities of adding a device.
 pub struct DeviceManager {
-    pub bus: hw::Bus,
+    pub bus: devices::Bus,
     pub vm_requests: Vec<VmRequest>,
     guest_mem: GuestMemory,
     mmio_len: u64,
@@ -91,13 +91,13 @@ impl DeviceManager {
             mmio_len: mmio_len,
             mmio_base: mmio_base,
             irq: irq_base,
-            bus: hw::Bus::new(),
+            bus: devices::Bus::new(),
         }
     }
 
     /// Register a device to be used via MMIO transport.
     pub fn register_mmio(&mut self,
-                         device: Box<hw::virtio::VirtioDevice>,
+                         device: Box<devices::virtio::VirtioDevice>,
                          jail: Option<Minijail>,
                          cmdline: &mut kernel_cmdline::Cmdline)
                          -> Result<()> {
@@ -110,11 +110,11 @@ impl DeviceManager {
         keep_fds.push(STDERR_FILENO);
         syslog::push_fds(&mut keep_fds);
 
-        let mmio_device = hw::virtio::MmioDevice::new(self.guest_mem.clone(), device)
+        let mmio_device = devices::virtio::MmioDevice::new(self.guest_mem.clone(), device)
             .map_err(Error::CreateMmioDevice)?;
         for (i, queue_evt) in mmio_device.queue_evts().iter().enumerate() {
             let io_addr = IoeventAddress::Mmio(self.mmio_base +
-                                               hw::virtio::NOITFY_REG_OFFSET as u64);
+                                               devices::virtio::NOITFY_REG_OFFSET as u64);
             self.vm_requests.push(VmRequest::RegisterIoevent(queue_evt
                                                                  .try_clone()
                                                                  .map_err(Error::CloneIoeventFd)?,
@@ -150,7 +150,7 @@ impl DeviceManager {
                 };
             };
 
-            let proxy_dev = hw::ProxyDevice::new(mmio_device, |keep_pipe| {
+            let proxy_dev = devices::ProxyDevice::new(mmio_device, |keep_pipe| {
                 // The setresuid/setresgid calls will not work until the maps have been set, so we
                 // wait for a signal indicating the uid/gid maps have been set by the parent.
                 if let Some(evt) = id_map_done_evt.take() {
@@ -230,7 +230,7 @@ mod tests {
     use sys_util::{EventFd, GuestAddress, GuestMemory};
     use device_manager;
     use kernel_cmdline;
-    use hw;
+    use devices;
 
     const QUEUE_SIZES: &'static [u16] = &[64];
 
@@ -239,7 +239,7 @@ mod tests {
         dummy: u32,
     }
 
-    impl hw::virtio::VirtioDevice for DummyDevice {
+    impl devices::virtio::VirtioDevice for DummyDevice {
         fn keep_fds(&self) -> Vec<RawFd> {
             Vec::new()
         }
@@ -258,7 +258,7 @@ mod tests {
                     mem: GuestMemory,
                     interrupt_evt: EventFd,
                     status: Arc<AtomicUsize>,
-                    queues: Vec<hw::virtio::Queue>,
+                    queues: Vec<devices::virtio::Queue>,
                     mut queue_evts: Vec<EventFd>) {
         }
     }
diff --git a/src/main.rs b/src/main.rs
index a9ac82f..8d4a899 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -4,6 +4,7 @@
 
 //! Runs a virtual machine under KVM
 
+extern crate devices;
 extern crate libc;
 extern crate io_jail;
 extern crate kvm;
@@ -13,15 +14,10 @@ extern crate kernel_loader;
 extern crate byteorder;
 #[macro_use]
 extern crate sys_util;
-extern crate net_sys;
-extern crate net_util;
-extern crate vhost;
-extern crate virtio_sys;
 extern crate vm_control;
 extern crate data_model;
 
 pub mod argument;
-pub mod hw;
 pub mod kernel_cmdline;
 pub mod device_manager;
 
@@ -57,10 +53,10 @@ enum Error {
     Disk(std::io::Error),
     BlockDeviceNew(sys_util::Error),
     BlockDeviceRootSetup(sys_util::Error),
-    VhostNetDeviceNew(hw::virtio::vhost::Error),
-    NetDeviceNew(hw::virtio::NetError),
+    VhostNetDeviceNew(devices::virtio::vhost::Error),
+    NetDeviceNew(devices::virtio::NetError),
     NetDeviceRootSetup(sys_util::Error),
-    VhostVsockDeviceNew(hw::virtio::vhost::Error),
+    VhostVsockDeviceNew(devices::virtio::vhost::Error),
     VsockDeviceRootSetup(sys_util::Error),
     DeviceJail(io_jail::Error),
     DevicePivotRoot(io_jail::Error),
@@ -72,7 +68,7 @@ enum Error {
     MissingWayland(PathBuf),
     RegisterIrqfd(sys_util::Error),
     RegisterRng(device_manager::Error),
-    RngDeviceNew(hw::virtio::RngError),
+    RngDeviceNew(devices::virtio::RngError),
     RngDeviceRootSetup(sys_util::Error),
     KernelLoader(kernel_loader::Error),
     #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
@@ -318,7 +314,7 @@ fn run_config(cfg: Config) -> Result<()> {
                             .open(disk.path)
                             .map_err(|e| Error::Disk(e))?;
 
-        let block_box = Box::new(hw::virtio::Block::new(disk_image)
+        let block_box = Box::new(devices::virtio::Block::new(disk_image)
                     .map_err(|e| Error::BlockDeviceNew(e))?);
         let jail = if cfg.multiprocess {
             let block_root_path = block_root.as_path().unwrap(); // Won't fail if new succeeded.
@@ -335,7 +331,7 @@ fn run_config(cfg: Config) -> Result<()> {
 
     let rng_root = TempDir::new(&PathBuf::from("/tmp/rng_root"))
         .map_err(Error::RngDeviceRootSetup)?;
-    let rng_box = Box::new(hw::virtio::Rng::new().map_err(Error::RngDeviceNew)?);
+    let rng_box = Box::new(devices::virtio::Rng::new().map_err(Error::RngDeviceNew)?);
     let rng_jail = if cfg.multiprocess {
         let rng_root_path = rng_root.as_path().unwrap(); // Won't fail if new succeeded.
         let policy_path: PathBuf = cfg.seccomp_policy_dir.join("rng_device.policy");
@@ -351,11 +347,11 @@ fn run_config(cfg: Config) -> Result<()> {
         .map_err(Error::NetDeviceRootSetup)?;
     if let Some(host_ip) = cfg.host_ip {
         if let Some(netmask) = cfg.netmask {
-            let net_box: Box<hw::virtio::VirtioDevice> = if cfg.vhost_net {
-                Box::new(hw::virtio::vhost::Net::new(host_ip, netmask, &guest_mem)
+            let net_box: Box<devices::virtio::VirtioDevice> = if cfg.vhost_net {
+                Box::new(devices::virtio::vhost::Net::new(host_ip, netmask, &guest_mem)
                                    .map_err(|e| Error::VhostNetDeviceNew(e))?)
             } else {
-                Box::new(hw::virtio::Net::new(host_ip, netmask)
+                Box::new(devices::virtio::Net::new(host_ip, netmask)
                                    .map_err(|e| Error::NetDeviceNew(e))?)
             };
 
@@ -390,7 +386,7 @@ fn run_config(cfg: Config) -> Result<()> {
 
                 let (host_socket, device_socket) = UnixDatagram::pair().map_err(Error::Socket)?;
                 control_sockets.push(UnlinkUnixDatagram(host_socket));
-                let wl_box = Box::new(hw::virtio::Wl::new(if cfg.multiprocess {
+                let wl_box = Box::new(devices::virtio::Wl::new(if cfg.multiprocess {
                         &jailed_wayland_path
                     } else {
                         wayland_path.as_path()
@@ -420,7 +416,7 @@ fn run_config(cfg: Config) -> Result<()> {
     let vsock_root = TempDir::new(&PathBuf::from("/tmp/vsock_root"))
         .map_err(Error::VsockDeviceRootSetup)?;
     if let Some(cid) = cfg.cid {
-        let vsock_box = Box::new(hw::virtio::vhost::Vsock::new(cid, &guest_mem)
+        let vsock_box = Box::new(devices::virtio::vhost::Vsock::new(cid, &guest_mem)
             .map_err(|e| Error::VhostVsockDeviceNew(e))?);
 
         let jail = if cfg.multiprocess {
@@ -455,7 +451,7 @@ fn run_kvm(requests: Vec<VmRequest>,
            cmdline: &CStr,
            vcpu_count: u32,
            guest_mem: GuestMemory,
-           mmio_bus: &hw::Bus,
+           mmio_bus: &devices::Bus,
            control_sockets: Vec<UnlinkUnixDatagram>)
            -> Result<()> {
     let kvm = Kvm::new().map_err(Error::Kvm)?;
@@ -492,7 +488,7 @@ fn run_kvm(requests: Vec<VmRequest>,
                              cmdline.to_bytes().len() + 1,
                              vcpu_count as u8)?;
 
-    let mut io_bus = hw::Bus::new();
+    let mut io_bus = devices::Bus::new();
 
     let exit_evt = EventFd::new().expect("failed to create exit eventfd");
 
@@ -503,41 +499,42 @@ fn run_kvm(requests: Vec<VmRequest>,
         .expect("failed to create child signalfd");
 
     struct NoDevice;
-    impl hw::BusDevice for NoDevice {}
+    impl devices::BusDevice for NoDevice {}
 
     let com_evt_1_3 = EventFd::new().map_err(Error::EventFd)?;
     let com_evt_2_4 = EventFd::new().map_err(Error::EventFd)?;
     let stdio_serial =
-        Arc::new(Mutex::new(hw::Serial::new_out(com_evt_1_3.try_clone().map_err(Error::EventFd)?,
-                                                Box::new(stdout()))));
+        Arc::new(Mutex::new(
+                    devices::Serial::new_out(com_evt_1_3.try_clone().map_err(Error::EventFd)?,
+                Box::new(stdout()))));
     let nul_device = Arc::new(Mutex::new(NoDevice));
     io_bus.insert(stdio_serial.clone(), 0x3f8, 0x8).unwrap();
     io_bus
-        .insert(Arc::new(Mutex::new(hw::Serial::new_sink(com_evt_2_4
+        .insert(Arc::new(Mutex::new(devices::Serial::new_sink(com_evt_2_4
                                                              .try_clone()
                                                              .map_err(Error::EventFd)?))),
                 0x2f8,
                 0x8)
         .unwrap();
     io_bus
-        .insert(Arc::new(Mutex::new(hw::Serial::new_sink(com_evt_1_3
+        .insert(Arc::new(Mutex::new(devices::Serial::new_sink(com_evt_1_3
                                                              .try_clone()
                                                              .map_err(Error::EventFd)?))),
                 0x3e8,
                 0x8)
         .unwrap();
     io_bus
-        .insert(Arc::new(Mutex::new(hw::Serial::new_sink(com_evt_2_4
+        .insert(Arc::new(Mutex::new(devices::Serial::new_sink(com_evt_2_4
                                                              .try_clone()
                                                              .map_err(Error::EventFd)?))),
                 0x2e8,
                 0x8)
         .unwrap();
     io_bus
-        .insert(Arc::new(Mutex::new(hw::Cmos::new())), 0x70, 0x2)
+        .insert(Arc::new(Mutex::new(devices::Cmos::new())), 0x70, 0x2)
         .unwrap();
     io_bus
-        .insert(Arc::new(Mutex::new(hw::I8042Device::new(exit_evt
+        .insert(Arc::new(Mutex::new(devices::I8042Device::new(exit_evt
                                                              .try_clone()
                                                              .map_err(Error::EventFd)?))),
                 0x061,
@@ -632,7 +629,7 @@ fn run_kvm(requests: Vec<VmRequest>,
 fn run_control(mut vm: Vm,
                control_sockets: Vec<UnlinkUnixDatagram>,
                mut next_dev_pfn: u64,
-               stdio_serial: Arc<Mutex<hw::Serial>>,
+               stdio_serial: Arc<Mutex<devices::Serial>>,
                exit_evt: EventFd,
                sigchld_fd: SignalFd,
                kill_signaled: Arc<AtomicBool>,