ext/r3compatibility: features/services

QubesOS/qubes-issues#1812
This commit is contained in:
Marek Marczykowski-Górecki 2016-03-07 03:22:59 +01:00 committed by Wojtek Porczyk
parent 0f03b257ce
commit b6d8c7fb81

View File

@ -37,6 +37,14 @@ class R3Compatibility(qubes.ext.Extension):
'''Maintain VM interface compatibility with R3.0 and R3.1. '''Maintain VM interface compatibility with R3.0 and R3.1.
At lease where possible. At lease where possible.
''' '''
features_to_services = {
'services/ntpd': 'ntpd',
'check-updates': 'qubes-update-check',
'dvm': 'qubes-dvm',
}
# noinspection PyUnusedLocal # noinspection PyUnusedLocal
@qubes.ext.handler('qdb-created') @qubes.ext.handler('qdb-created')
def on_qdb_created(self, vm, event): def on_qdb_created(self, vm, event):
@ -107,6 +115,8 @@ class R3Compatibility(qubes.ext.Extension):
vm.qdb.write("/qubes-iptables-error", '') vm.qdb.write("/qubes-iptables-error", '')
self.write_iptables_qubesdb_entry(vm) self.write_iptables_qubesdb_entry(vm)
self.write_services(vm)
# FIXME use event after creating Xen domain object, but before "resume" # FIXME use event after creating Xen domain object, but before "resume"
@qubes.ext.handler('domain-started') @qubes.ext.handler('domain-started')
def on_domain_started(self, vm, event, **kwargs): def on_domain_started(self, vm, event, **kwargs):
@ -212,3 +222,10 @@ class R3Compatibility(qubes.ext.Extension):
# no need for ending -A FORWARD -j DROP, cause default action is DROP # no need for ending -A FORWARD -j DROP, cause default action is DROP
firewallvm.qdb.write("/qubes-iptables", 'reload') firewallvm.qdb.write("/qubes-iptables", 'reload')
def write_services(self, vm):
for feature, value in vm.features.items():
service = self.features_to_services.get(feature, feature)
# forcefully convert to '0' or '1'
vm.qdb.write('/qubes-service/{}'.format(service),
str(int(bool(value))))