qubes/vm: make VM QubesDB interface as much compatible as possible
All the base keys can be kept easily the same, so do it. QubesOS/qubes-issues#1812
This commit is contained in:
parent
d5a41e838f
commit
aa0674e8bb
@ -21,7 +21,6 @@
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
import base64
|
||||
import datetime
|
||||
import qubes.ext
|
||||
import qubes.vm.qubesvm
|
||||
@ -63,55 +62,6 @@ class R3Compatibility(qubes.ext.Extension):
|
||||
vmtype = 'AppVM'
|
||||
vm.qdb.write('/qubes-vm-type', vmtype)
|
||||
|
||||
# /qubes-vm-updateable
|
||||
vm.qdb.write('/qubes-vm-updateable', str(vm.updateable))
|
||||
|
||||
# /qubes-base-template
|
||||
try:
|
||||
if vm.template:
|
||||
vm.qdb.write('/qubes-base-template', str(vm.template))
|
||||
else:
|
||||
vm.qdb.write('/qubes-base-template', '')
|
||||
except AttributeError:
|
||||
vm.qdb.write('/qubes-base-template', '')
|
||||
|
||||
# /qubes-debug-mode: 0, 1
|
||||
vm.qdb.write('/qubes-debug-mode', str(int(vm.debug)))
|
||||
|
||||
# /qubes-timezone
|
||||
timezone = vm.qdb.read('/timezone')
|
||||
if timezone:
|
||||
vm.qdb.write('/qubes-timezone', timezone)
|
||||
|
||||
# /qubes-vm-persistence
|
||||
persistence = vm.qdb.read('/persistence')
|
||||
if persistence:
|
||||
vm.qdb.write('/qubes-vm-persistence', persistence)
|
||||
|
||||
# /qubes-random-seed
|
||||
# write a new one, to make sure it wouldn't be reused/leaked
|
||||
vm.qdb.write('/qubes-random-seed',
|
||||
base64.b64encode(qubes.utils.urandom(64)))
|
||||
|
||||
# /qubes-keyboard
|
||||
# not needed for now - the old one is still present
|
||||
|
||||
# Networking
|
||||
if vm.provides_network:
|
||||
# '/qubes-netvm-network' value is only checked for being non empty
|
||||
vm.qdb.write('/qubes-netvm-network', vm.gateway)
|
||||
vm.qdb.write('/qubes-netvm-netmask', vm.netmask)
|
||||
vm.qdb.write('/qubes-netvm-gateway', vm.gateway)
|
||||
vm.qdb.write('/qubes-netvm-primary-dns', vm.dns[0])
|
||||
vm.qdb.write('/qubes-netvm-secondary-dns', vm.dns[1])
|
||||
|
||||
if vm.netvm is not None:
|
||||
vm.qdb.write('/qubes-ip', vm.ip)
|
||||
vm.qdb.write('/qubes-netmask', vm.netvm.netmask)
|
||||
vm.qdb.write('/qubes-gateway', vm.netvm.gateway)
|
||||
vm.qdb.write('/qubes-primary-dns', vm.dns[0])
|
||||
vm.qdb.write('/qubes-secondary-dns', vm.dns[1])
|
||||
|
||||
vm.qdb.write("/qubes-iptables-error", '')
|
||||
self.write_iptables_qubesdb_entry(vm)
|
||||
|
||||
|
@ -28,7 +28,6 @@ from __future__ import absolute_import
|
||||
import copy
|
||||
import base64
|
||||
import datetime
|
||||
import itertools
|
||||
import os
|
||||
import os.path
|
||||
import re
|
||||
@ -1456,7 +1455,7 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
|
||||
# pylint: disable=no-member
|
||||
|
||||
self.qdb.write('/name', self.name)
|
||||
self.qdb.write('/qubes-vm-type', self.__class__.__name__)
|
||||
self.qdb.write('/type', self.__class__.__name__)
|
||||
self.qdb.write('/qubes-vm-updateable', str(self.updateable))
|
||||
self.qdb.write('/qubes-vm-persistence',
|
||||
'full' if self.updateable else 'rw-only')
|
||||
@ -1470,19 +1469,21 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
|
||||
base64.b64encode(qubes.utils.urandom(64)))
|
||||
|
||||
if self.provides_network:
|
||||
self.qdb.write('/network-provider/gateway', self.gateway)
|
||||
self.qdb.write('/network-provider/netmask', self.netmask)
|
||||
# '/qubes-netvm-network' value is only checked for being non empty
|
||||
self.qdb.write('/qubes-netvm-network', self.gateway)
|
||||
self.qdb.write('/qubes-netvm-gateway', self.gateway)
|
||||
self.qdb.write('/qubes-netvm-netmask', self.netmask)
|
||||
|
||||
for i, addr in zip(itertools.count(start=1), self.dns):
|
||||
self.qdb.write('/network-provider/dns-{}'.format(i), addr)
|
||||
for i, addr in zip(('primary', 'secondary'), self.dns):
|
||||
self.qdb.write('/qubes-netvm-{}-dns'.format(i), addr)
|
||||
|
||||
if self.netvm is not None:
|
||||
self.qdb.write('/network/ip', self.ip)
|
||||
self.qdb.write('/network/netmask', self.netvm.netmask)
|
||||
self.qdb.write('/network/gateway', self.netvm.gateway)
|
||||
self.qdb.write('/qubes-ip', self.ip)
|
||||
self.qdb.write('/qubes-netmask', self.netvm.netmask)
|
||||
self.qdb.write('/qubes-gateway', self.netvm.gateway)
|
||||
|
||||
for i, addr in zip(itertools.count(start=1), self.dns):
|
||||
self.qdb.write('/network/dns-{}'.format(i), addr)
|
||||
for i, addr in zip(('primary', 'secondary'), self.dns):
|
||||
self.qdb.write('/qubes-{}-dns'.format(i), addr)
|
||||
|
||||
|
||||
tzname = qubes.utils.get_timezone()
|
||||
|
Loading…
Reference in New Issue
Block a user