Просмотр исходного кода

vm: expose to VM only features with 'service/' prefix

And place them in /qubes-service/ QubesDB directory. This allows
extensions to easily store some data not exposed to VM, but also have
control what VM will see. And at the same time, it make it compatible
with existing services framework

QubesOS/qubes-issues#1637
Marek Marczykowski-Górecki 7 лет назад
Родитель
Сommit
e54cc11a2c
2 измененных файлов с 9 добавлено и 3 удалено
  1. 3 1
      qubes/ext/r3compatibility.py
  2. 6 2
      qubes/vm/qubesvm.py

+ 3 - 1
qubes/ext/r3compatibility.py

@@ -162,7 +162,9 @@ class R3Compatibility(qubes.ext.Extension):
 
     def write_services(self, vm):
         for feature, value in vm.features.items():
-            service = self.features_to_services.get(feature, feature)
+            service = self.features_to_services.get(feature, None)
+            if service is None:
+                continue
             # forcefully convert to '0' or '1'
             vm.qdb.write('/qubes-service/{}'.format(service),
                 str(int(bool(value))))

+ 6 - 2
qubes/vm/qubesvm.py

@@ -1819,8 +1819,12 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
             self.qdb.write('/qubes-timezone', tzname)
 
         for feature, value in self.features.items():
-            self.qdb.write('/features/{0}'.format(feature),
-                    str(value) if value else '')
+            if not feature.startswith('service/'):
+                continue
+            service = feature[len('service/'):]
+            # forcefully convert to '0' or '1'
+            self.qdb.write('/qubes-service/{}'.format(service),
+                str(int(bool(value))))
 
         self.qdb.write('/qubes-block-devices', '')