From e54cc11a2ca0e602cde4e404c131cb272c5acb64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Fri, 26 May 2017 05:28:07 +0200 Subject: [PATCH] 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 --- qubes/ext/r3compatibility.py | 4 +++- qubes/vm/qubesvm.py | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/qubes/ext/r3compatibility.py b/qubes/ext/r3compatibility.py index 919493db..728ac9f6 100644 --- a/qubes/ext/r3compatibility.py +++ b/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)))) diff --git a/qubes/vm/qubesvm.py b/qubes/vm/qubesvm.py index 226cc4fc..83763c54 100644 --- a/qubes/vm/qubesvm.py +++ b/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', '')