From 95a75d7ef67c26c6c456a0535d864c11fe642046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Fri, 18 Jul 2025 19:26:07 +0200 Subject: [PATCH 1/2] Fix exception class --- qubesusbproxy/core3ext.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qubesusbproxy/core3ext.py b/qubesusbproxy/core3ext.py index 665fcce..97e5a60 100644 --- a/qubesusbproxy/core3ext.py +++ b/qubesusbproxy/core3ext.py @@ -35,6 +35,7 @@ import tempfile from typing import List, Optional, Dict, Tuple, Any +import qubes.exc from qubes.utils import sanitize_stderr_for_log try: @@ -652,7 +653,7 @@ async def on_device_attach_usb(self, vm, event, device, options): return if device.attachment: - raise qubes.devices.DeviceAlreadyAttached( + raise qubes.exc.DeviceAlreadyAttached( f"Device {device} already attached to {device.attachment}" ) From dbe1cb0041570cfed5165709adc4483a2bf58ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Fri, 18 Jul 2025 19:26:21 +0200 Subject: [PATCH 2/2] Fix clearing available devices cache on domain shutdown Call utils.device_list_change() on domain shutdown, for two reasons: - generate relevant device-removed events for all devices provided by this VM - do not swallow device-added events on startup (if they were cached as present before) QubesOS/qubes-issues#8537 --- qubesusbproxy/core3ext.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qubesusbproxy/core3ext.py b/qubesusbproxy/core3ext.py index 97e5a60..950c3f8 100644 --- a/qubesusbproxy/core3ext.py +++ b/qubesusbproxy/core3ext.py @@ -776,6 +776,7 @@ async def on_domain_start(self, vm, _event, **_kwargs): async def on_domain_shutdown(self, vm, _event, **_kwargs): # pylint: disable=unused-argument vm.fire_event("device-list-change:usb") + utils.device_list_change(self, {}, vm, None, USBDevice) @qubes.ext.handler("qubes-close", system=True) def on_qubes_close(self, app, event):