Skip to content

Commit

Permalink
q-dev: virtual device
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrbartman committed Oct 14, 2024
1 parent 8ead9c2 commit 070406c
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions qui/devices/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import qubesadmin.devices
import qubesadmin.vm
from qubesadmin.utils import size_to_human
from qubesadmin.device_protocol import (Port, VirtualDevice, DeviceInfo,
DeviceAssignment)

import gi
gi.require_version('Gtk', '3.0') # isort:skip
Expand Down Expand Up @@ -232,12 +234,9 @@ def attach_to_vm(self, vm: VM):
Perform attachment to provided VM.
"""
try:
assignment = qubesadmin.device_protocol.DeviceAssignment(
qubesadmin.device_protocol.Device(
qubesadmin.device_protocol.Port(
self.backend_domain, self.id_string, self.device_class),
device_id=self._device_id,
))
assignment = DeviceAssignment(VirtualDevice(Port(
self.backend_domain, self.id_string, self.device_class),
device_id=self._device_id))

vm.vm_object.devices[self.device_class].attach(assignment)
self.gtk_app.emit_notification(
Expand Down Expand Up @@ -267,11 +266,8 @@ def detach_from_vm(self, vm: VM):
Gio.NotificationPriority.NORMAL,
notification_id=self.notification_id)
try:
assignment = qubesadmin.device_protocol.DeviceAssignment(
qubesadmin.device_protocol.Device(
qubesadmin.device_protocol.Port(
self.backend_domain, self._ident, self.device_class)
))
assignment = DeviceAssignment(VirtualDevice(Port(
self.backend_domain, self._ident, self.device_class)))
vm.vm_object.devices[self.device_class].detach(assignment)
except qubesadmin.exc.QubesException as ex:
self.gtk_app.emit_notification(
Expand Down

0 comments on commit 070406c

Please sign in to comment.