Skip to content

Commit a6aec5a

Browse files
committed
Update qvm module for new devices API
QubesOS/qubes-issues#9325
1 parent bce7ccc commit a6aec5a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

_modules/ext_module_qvm.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from nulltype import Null
3838

3939
import qubesadmin
40-
import qubesadmin.devices
40+
import qubesadmin.device_protocol
4141
import qubesadmin.firewall
4242

4343
# Enable logging
@@ -869,7 +869,7 @@ def prefs(vmname, *varargs, **kwargs):
869869
dest = property_map.get(dest, dest)
870870

871871
if dest == 'pcidevs':
872-
value_current = [str(dev.ident).replace('_', ':') for dev
872+
value_current = [str(dev.port_id).replace('_', ':') for dev
873873
in args.vm.devices['pci'].get_assigned_devices(required_only=True)]
874874
elif dest == 'pci_strictreset':
875875
value_current = all(not assignment.options.get('no-strict-reset', False)
@@ -920,7 +920,7 @@ def prefs(vmname, *varargs, **kwargs):
920920
dev_id_api = dev_id.strip().replace(':', '_')
921921
current_assignment = None
922922
for a in args.vm.devices['pci'].get_assigned_devices(required_only=True):
923-
if a.ident == dev_id_api:
923+
if a.port_id == dev_id_api:
924924
current_assignment = a
925925
if current_assignment and \
926926
pci_strictreset is not None and \
@@ -934,11 +934,11 @@ def prefs(vmname, *varargs, **kwargs):
934934
options = {}
935935
if pci_strictreset is not None:
936936
options['no-strict-reset'] = not pci_strictreset
937-
assignment = qubesadmin.devices.DeviceAssignment(
937+
assignment = qubesadmin.device_protocol.DeviceAssignment.new(
938938
args.vm.app.domains['dom0'],
939939
dev_id_api,
940940
devclass='pci',
941-
attach_automatically=True, required=True,
941+
mode="required",
942942
options=options)
943943
args.vm.devices['pci'].assign(assignment)
944944
except qubesadmin.exc.DeviceAlreadyAttached:
@@ -1052,7 +1052,7 @@ def devices(vmname, *varargs, **kwargs):
10521052
for device_type in args.vm.devices:
10531053
for device in args.vm.devices[device_type].get_assigned_devices():
10541054
current_devices.append(
1055-
{'device_type': device_type, 'backend': device.backend_domain.name, 'dev_id': device.ident,
1055+
{'device_type': device_type, 'backend': device.backend_domain.name, 'dev_id': device.port_id,
10561056
'options': device.options})
10571057

10581058
# Return all current devices if a 'list' only was selected
@@ -1100,7 +1100,7 @@ def parse_device(raw_dev):
11001100
device_skip = False
11011101
message_old = None
11021102
for a in args.vm.devices[device_type].get_assigned_devices():
1103-
if a.ident == device['dev_id'] and a.backend_domain == device['backend']:
1103+
if a.port_id == device['dev_id'] and a.backend_domain == device['backend']:
11041104
current_assignment = a
11051105
if current_assignment.options != device['options']:
11061106
# detach and attach again to adjust options
@@ -1115,11 +1115,11 @@ def parse_device(raw_dev):
11151115
msg_options = '(' + ', '.join('{}={}'.format(key, value) for key, value in device['options'].items()) + ')'
11161116
if not device_skip:
11171117
try:
1118-
assignment = qubesadmin.devices.DeviceAssignment(
1118+
assignment = qubesadmin.device_protocol.DeviceAssignment.new(
11191119
backend_domain=args.vm.app.domains[device['backend']],
1120-
ident=device['dev_id'],
1120+
port_id=device['dev_id'],
11211121
devclass=device_type,
1122-
attach_automatically=True, required=True,
1122+
mode="required",
11231123
options=device['options'])
11241124

11251125
args.vm.devices[device_type].assign(assignment)
@@ -1142,7 +1142,7 @@ def parse_device(raw_dev):
11421142
device_type = device['device_type']
11431143

11441144
try:
1145-
assignment = qubesadmin.devices.DeviceAssignment(
1145+
assignment = qubesadmin.device_protocol.DeviceAssignment(
11461146
args.vm.app.domains[device['backend']],
11471147
device['dev_id'],
11481148
devclass=device_type)

0 commit comments

Comments
 (0)