summary refs log tree commit diff
path: root/usb_util
diff options
context:
space:
mode:
authorJingkui Wang <jkwang@google.com>2019-03-20 11:16:26 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-05-01 01:50:22 -0700
commite23231ccffb149108bb9f80d0b467b24153fcbfa (patch)
treef3fbc6f32dfef4dbdd7b8c99f6e5815722379d0f /usb_util
parentd5f6608f3eb79fa9d058704252f7b91d69954490 (diff)
downloadcrosvm-e23231ccffb149108bb9f80d0b467b24153fcbfa.tar
crosvm-e23231ccffb149108bb9f80d0b467b24153fcbfa.tar.gz
crosvm-e23231ccffb149108bb9f80d0b467b24153fcbfa.tar.bz2
crosvm-e23231ccffb149108bb9f80d0b467b24153fcbfa.tar.lz
crosvm-e23231ccffb149108bb9f80d0b467b24153fcbfa.tar.xz
crosvm-e23231ccffb149108bb9f80d0b467b24153fcbfa.tar.zst
crosvm-e23231ccffb149108bb9f80d0b467b24153fcbfa.zip
usb: fix serial devices by removing device context verification
1. Removed for device slot reset and evaluate context. The verification was
   unnecessary and may cause some guest kernel operations to fail.
2. The context was updated after dequeue pointer set
3. Reset device when it's attached.
4. Add seccomp rules to allow the above reset.

The verification was copied from another implementation which works for
adb, but does not work with serial devices. The verification is also not
part of the spec, so we removed it here.

BUG=b:131336977
TEST=local build and test

Change-Id: Ifd7994ff5512346d1bab27654e60c97a602da8a6
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Signed-off-by: Zach Reizner <zachr@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1558934
Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'usb_util')
-rw-r--r--usb_util/src/device_handle.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/usb_util/src/device_handle.rs b/usb_util/src/device_handle.rs
index 72ee178..32a963f 100644
--- a/usb_util/src/device_handle.rs
+++ b/usb_util/src/device_handle.rs
@@ -39,6 +39,12 @@ impl DeviceHandle {
         }
     }
 
+    /// Reset this usb device.
+    pub fn reset(&self) -> Result<()> {
+        // Safe because 'self.handle' is a valid pointer to device handle.
+        try_libusb!(unsafe { bindings::libusb_reset_device(self.handle) });
+        Ok(())
+    }
     /// Get bConfigurationValue of the currently active configuration.
     pub fn get_active_configuration(&self) -> Result<i32> {
         let mut config: c_int = 0;