BaseVM add DeviceAssignment xml serialization
Signed-off-by: Bahtiar `kalkin-` Gadimov <bahtiar@gadimov.de>
This commit is contained in:
parent
990cfd8ab9
commit
2a6266887e
@ -217,11 +217,17 @@ class BaseVM(qubes.PropertyHolder, metaclass=BaseVMMeta):
|
|||||||
for parent in self.xml.xpath('./devices'):
|
for parent in self.xml.xpath('./devices'):
|
||||||
devclass = parent.get('class')
|
devclass = parent.get('class')
|
||||||
for node in parent.xpath('./device'):
|
for node in parent.xpath('./device'):
|
||||||
device = self.devices[devclass].devclass(
|
options = {}
|
||||||
|
if node.get('options'):
|
||||||
|
options = node.get('options').attribs(),
|
||||||
|
|
||||||
|
device_assignment = qubes.devices.DeviceAssignment(
|
||||||
self.app.domains[node.get('backend-domain')],
|
self.app.domains[node.get('backend-domain')],
|
||||||
node.get('id')
|
node.get('id'),
|
||||||
|
options,
|
||||||
|
persistent=True
|
||||||
)
|
)
|
||||||
self.devices[devclass].attach(device)
|
self.devices[devclass].attach(device_assignment)
|
||||||
|
|
||||||
# tags
|
# tags
|
||||||
for node in self.xml.xpath('./tags/tag'):
|
for node in self.xml.xpath('./tags/tag'):
|
||||||
@ -254,7 +260,10 @@ class BaseVM(qubes.PropertyHolder, metaclass=BaseVMMeta):
|
|||||||
node = lxml.etree.Element('device')
|
node = lxml.etree.Element('device')
|
||||||
node.set('backend-domain', device.backend_domain.name)
|
node.set('backend-domain', device.backend_domain.name)
|
||||||
node.set('id', device.ident)
|
node.set('id', device.ident)
|
||||||
node.set('options', device.options)
|
options_node = lxml.etree.Element('options')
|
||||||
|
for key, val in device.options:
|
||||||
|
options_node.set(key, val)
|
||||||
|
node.append(options_node)
|
||||||
devices.append(node)
|
devices.append(node)
|
||||||
element.append(devices)
|
element.append(devices)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user