You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In general we refer to potential assignment as assignment
24
79
and real assignment as attachment. To check whether the device is currently
25
80
attached, we check :py:meth:`qubes.device_protocol.DeviceAssignment.attached`,
@@ -28,17 +83,35 @@ we check :py:meth:`qubes.device_protocol.DeviceAssignment.attach_automatically`.
28
83
Potential and real connections may coexist at the same time,
29
84
in which case both values will be true.
30
85
86
+
Understanding Device Identity
87
+
-----------------------------
88
+
89
+
It is important to understand that :py:class:`qubes.device_protocol.Port` does not
90
+
correspond to the device itself, but rather to the *port* to which the device
91
+
is connected. Therefore, when assigning a device to a VM, such as
92
+
`sys-usb:1-1.1`, the port `1-1.1` is actually assigned, and thus
93
+
*every* devices connected to it will be automatically attached.
94
+
Similarly, when assigning `vm:sda`, every block device with the name `sda`
95
+
will be automatically attached. We can limit this using
96
+
:py:meth:`qubes.device_protocol.DeviceInfo.device_id`, which returns a string
97
+
containing information presented by the device, such as for example
98
+
`vendor_id`, `product_id`, `serial_number`, and encoded interfaces.
99
+
In the case of block devices, `device_id` consists of the parent's `device_id`
100
+
to which the device is connected (if any) and the interface/partition number.
101
+
In practice, this means that, a partition on a USB drive will only
102
+
be automatically attached to a frontend domain if the parent presents
103
+
the correct serial number etc.
31
104
32
105
Actions
33
106
-------
34
107
35
-
The `assign` action signifies that a device will be assigned to the frontend VM
108
+
The `assign` action means that a device will be assigned to the frontend VM
36
109
in a potential form (this does not change the current system state).
37
110
This will result in an attempt to automatically attach the device
38
-
upon the next VM startup. If `required=True`, and the device cannot be attached,
111
+
upon the next VM startup. If `mode=required`, and the device cannot be attached,
39
112
the VM startup will fail. Additionally, upon device detection (`device-added`),
40
113
an attempt will be made to attach the device. However, at any time
41
-
(unless `required=True`), the user can manually modify this state by performing
114
+
(unless `mode=required`), the user can manually modify this state by performing
42
115
`attach` or `detach` on the device, changing the current system state.
43
116
This will not alter the assignment, and automatic attachment attempts
44
117
will still be made in the future. To remove the assignment the user
@@ -48,23 +121,23 @@ Assignment Management
48
121
---------------------
49
122
50
123
Assignments can be edited at any time: regardless of whether the VM is running
51
-
or the device is currently attached. An exception is `required=True`,
52
-
in which case the VM must be shut down. Removing the assignment does not change the real system state, so if the device is currently attached
53
-
and the user remove the assignment, it will not be detached,
54
-
but it will not be automatically attached in the future.
55
-
Similarly, it works the other way around with `assign`.
124
+
or the device is currently attached. Removing the assignment does not change
125
+
the real system state, so if the device is currently attached and the user
126
+
remove the assignment, it will not be detached, but it will not be
127
+
automatically attached in the future. Similarly, it works the other way
128
+
around with `assign`.
56
129
57
130
Proper Assignment States
58
131
------------------------
59
132
60
133
In short, we can think of device assignment in terms of three flags:
61
134
#. `attached` - indicating whether the device is currently assigned,
62
-
#. `attach_automatically` - indicating whether the device will be
135
+
#. `attach_automatically` - indicating whether the device will be
63
136
automatically attached by the system daemon,
64
137
#. `required` - determining whether the failure of automatic attachment should
65
138
result in the domain startup being interrupted.
66
139
67
-
Then the proper states of assignment
140
+
Then the possible states of assignment
68
141
(`attached`, `automatically_attached`, `required`) are as follow:
69
142
#. `(True, False, False)` -> domain is running, device is manually attached
70
143
and could be manually detach any time.
@@ -79,51 +152,52 @@ because either (i) domain is halted, device (ii) manually detached or
79
152
#. `(False, True, True)` -> domain is halted, device assigned to domain
80
153
and required to start domain.
81
154
155
+
Note that if `required=True` then `automatically_attached=True`.
156
+
157
+
Conflicted Assignments
158
+
----------------------
159
+
160
+
If a connected device has multiple assignments to different `frontend_domain`
161
+
instances, the user will be asked to choose which domain connect the device to.
162
+
If no GUI client is available, the device will not be connected to any domain.
163
+
If multiple assignments exist for a connected device with different options but
164
+
to the same `frontend_domain`, the most specific assignment will take
165
+
precedence, according to the following order (from highest to lowest priority):
166
+
#. Assignment specifies both `port` and `device_id`.
167
+
#. Assignment specifies only the `port`.
168
+
#. Assignment specifies only the `device_id`.
169
+
170
+
It is important to note that only one matching assignment can exist within
171
+
each of the categories listed above.
172
+
173
+
Port Assignment
174
+
---------------
175
+
176
+
It is possible to not assign a specific device but rather a port,
177
+
(e.g., we can use the `--port` flag in the client). In this case,
178
+
the value `*` will appear in the `identity` field of the `qubes.xml` file.
179
+
This indicates that the identity presented by the devices will be ignored,
180
+
and all connected devices will be automatically attached.
181
+
82
182
83
183
PCI Devices
84
184
-----------
85
185
86
186
PCI devices cannot be manually attached to a VM at any time.
87
187
We must first create an assignment (`assign`) as required
88
-
(in client we can use `--required` flag) while the VM is turned off.
89
-
Then, it will be automatically attached upon each VM startup.
90
-
However, if a PCI device is currently in use by another VM,
91
-
the startup of the second VM will fail.
92
-
PCI devices can only be assigned with the `required=True`, which does not
93
-
allow for manual modification of the state during VM operation (attach/detach).
188
+
(in client we can use `--required` flag). Then, it will be automatically
189
+
attached upon each VM startup. However, if a PCI device is currently in use
190
+
by another VM, the startup of the second VM will fail.
94
191
95
192
Microphone
96
193
----------
97
194
98
-
The microphone cannot be assigned (potentially) to any VM (attempting to attach the microphone during VM startup fails).
195
+
The microphone cannot be assigned with the `mode=required` to any VM.
99
196
100
-
Understanding Device Self Identity
101
-
----------------------------------
102
-
103
-
It is important to understand that :py:class:`qubes.device_protocol.Port` does not
104
-
correspond to the device itself, but rather to the *port* to which the device
105
-
is connected. Therefore, when assigning a device to a VM, such as
106
-
`sys-usb:1-1.1`, the port `1-1.1` is actually assigned, and thus
107
-
*every* devices connected to it will be automatically attached.
108
-
Similarly, when assigning `vm:sda`, every block device with the name `sda`
109
-
will be automatically attached. We can limit this using :py:meth:`qubes.device_protocol.DeviceInfo.device_id`, which returns a string containing information
110
-
presented by the device, such as, `vendor_id`, `product_id`, `serial_number`,
111
-
and encoded interfaces. In the case of block devices, `device_id`
112
-
consists of the parent port to which the device is connected (if any),
113
-
the parent's `device_id`, and the interface/partition number.
114
-
In practice, this means that, a partition on a USB drive will only be
115
-
automatically attached to a frontend domain if the parent presents
116
-
the correct serial number etc., and is connected to a specific port.
117
-
118
-
Port Assignment
119
-
---------------
197
+
USB Devices
198
+
-----------
120
199
121
-
It is possible to not assign a specific device but rather a port,
122
-
(e.g., we can use the `--port` flag in the client). In this case,
123
-
the value `any` will appear in the `identity` field of the `qubes.xml` file.
124
-
This indicates that the identity presented by the devices will be ignored,
125
-
and all connected devices will be automatically attached. Note that to create
126
-
an assignment, *any* device must currently be connected to the port.
200
+
The USB devices cannot be assigned with the `mode=required` to any VM.
0 commit comments