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
This commit is contained in:
Marek Marczykowski-Górecki 2017-05-26 05:28:07 +02:00
parent 2c01504a50
commit e54cc11a2c
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 9 additions and 3 deletions

View File

@ -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))))

View File

@ -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', '')