Jelajahi Sumber

BaseVM add DeviceAssignment xml serialization

Signed-off-by: Bahtiar `kalkin-` Gadimov <bahtiar@gadimov.de>
Bahtiar `kalkin-` Gadimov 7 tahun lalu
induk
melakukan
2a6266887e
1 mengubah file dengan 13 tambahan dan 4 penghapusan
  1. 13 4
      qubes/vm/__init__.py

+ 13 - 4
qubes/vm/__init__.py

@@ -217,11 +217,17 @@ class BaseVM(qubes.PropertyHolder, metaclass=BaseVMMeta):
         for parent in self.xml.xpath('./devices'):
             devclass = parent.get('class')
             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')],
-                    node.get('id')
+                    node.get('id'),
+                    options,
+                    persistent=True
                 )
-                self.devices[devclass].attach(device)
+                self.devices[devclass].attach(device_assignment)
 
         # tags
         for node in self.xml.xpath('./tags/tag'):
@@ -254,7 +260,10 @@ class BaseVM(qubes.PropertyHolder, metaclass=BaseVMMeta):
                 node = lxml.etree.Element('device')
                 node.set('backend-domain', device.backend_domain.name)
                 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)
             element.append(devices)