summary refs log tree commit diff
path: root/vm_control/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vm_control/src/lib.rs')
-rw-r--r--vm_control/src/lib.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/vm_control/src/lib.rs b/vm_control/src/lib.rs
index ee24b61..c6115ad 100644
--- a/vm_control/src/lib.rs
+++ b/vm_control/src/lib.rs
@@ -220,6 +220,7 @@ impl VmRequest {
         run_mode: &mut Option<VmRunMode>,
         balloon_host_socket: &UnixSeqpacket,
         disk_host_sockets: &[MsgSocket<VmRequest, VmResponse>],
+        usb_control_socket: &UsbControlSocket,
     ) -> VmResponse {
         match *self {
             VmRequest::Exit => {
@@ -316,8 +317,18 @@ impl VmRequest {
                 }
             }
             VmRequest::UsbCommand(ref cmd) => {
-                error!("not implemented yet");
-                VmResponse::Ok
+                let res = usb_control_socket.send(cmd);
+                if let Err(e) = res {
+                    error!("fail to send command to usb control socket: {}", e);
+                    return VmResponse::Err(SysError::new(EIO));
+                }
+                match usb_control_socket.recv() {
+                    Ok(response) => VmResponse::UsbResponse(response),
+                    Err(e) => {
+                        error!("fail to recv command from usb control socket: {}", e);
+                        return VmResponse::Err(SysError::new(EIO));
+                    }
+                }
             }
         }
     }