From 767d1f00747050f0139f207dc9e6ef17c1173f5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 2 Jun 2016 02:49:22 +0200 Subject: [PATCH] qvm-usb: implement usb_detach_all QubesOS/qubes-issues#531 --- core/qubesutils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/qubesutils.py b/core/qubesutils.py index 494ca7d4..b05ddbc5 100644 --- a/core/qubesutils.py +++ b/core/qubesutils.py @@ -653,8 +653,11 @@ def usb_detach(qvmc, vm, device): # TODO: sanitize and include stdout raise QubesException('Device detach failed') -def usb_detach_all(vm): - raise NotImplementedError("Detaching all devices from a given VM is not implemented yet") +def usb_detach_all(qvmc, vm): + for dev in usb_list(qvmc).values(): + connected_to = dev['connected-to'] + if connected_to is not None and connected_to.qid == vm.qid: + usb_detach(qvmc, connected_to, dev) ####### QubesWatch ######