Make qubes-set-updates
set also default state for new VMs
This makes possible to also check if the "updates check enabled" state is consistent across VMs. Fixes qubesos/qubes-issues#892
This commit is contained in:
parent
fbfaa98b80
commit
46b94b6682
@ -43,6 +43,7 @@ from qubes.qubes import dry_run,vmm
|
|||||||
from qubes.qubes import register_qubes_vm_class
|
from qubes.qubes import register_qubes_vm_class
|
||||||
from qubes.qubes import QubesVmCollection,QubesException,QubesHost,QubesVmLabels
|
from qubes.qubes import QubesVmCollection,QubesException,QubesHost,QubesVmLabels
|
||||||
from qubes.qubes import defaults,system_path,vm_files,qubes_max_qid
|
from qubes.qubes import defaults,system_path,vm_files,qubes_max_qid
|
||||||
|
|
||||||
qmemman_present = False
|
qmemman_present = False
|
||||||
try:
|
try:
|
||||||
from qubes.qmemman_client import QMemmanClient
|
from qubes.qmemman_client import QMemmanClient
|
||||||
@ -334,6 +335,11 @@ class QubesVm(object):
|
|||||||
if len(self.pcidevs) > 0:
|
if len(self.pcidevs) > 0:
|
||||||
self.services['meminfo-writer'] = False
|
self.services['meminfo-writer'] = False
|
||||||
|
|
||||||
|
if 'xml_element' not in kwargs:
|
||||||
|
# New VM, disable updates check if requested for new VMs
|
||||||
|
if os.path.exists(qubes.qubesutils.UPDATES_DEFAULT_VM_DISABLE_FLAG):
|
||||||
|
self.services['qubes-update-check'] = False
|
||||||
|
|
||||||
# Initialize VM image storage class
|
# Initialize VM image storage class
|
||||||
self.storage = defaults["storage_class"](self)
|
self.storage = defaults["storage_class"](self)
|
||||||
if hasattr(self, 'kernels_dir'):
|
if hasattr(self, 'kernels_dir'):
|
||||||
|
@ -844,8 +844,18 @@ class QubesWatch(object):
|
|||||||
##### updates check #####
|
##### updates check #####
|
||||||
|
|
||||||
UPDATES_DOM0_DISABLE_FLAG='/var/lib/qubes/updates/disable-updates'
|
UPDATES_DOM0_DISABLE_FLAG='/var/lib/qubes/updates/disable-updates'
|
||||||
|
UPDATES_DEFAULT_VM_DISABLE_FLAG=\
|
||||||
|
'/var/lib/qubes/updates/vm-default-disable-updates'
|
||||||
|
|
||||||
def updates_vms_toggle(qvm_collection, value):
|
def updates_vms_toggle(qvm_collection, value):
|
||||||
|
# Flag for new VMs
|
||||||
|
if value:
|
||||||
|
if os.path.exists(UPDATES_DEFAULT_VM_DISABLE_FLAG):
|
||||||
|
os.unlink(UPDATES_DEFAULT_VM_DISABLE_FLAG)
|
||||||
|
else:
|
||||||
|
open(UPDATES_DEFAULT_VM_DISABLE_FLAG, "w").close()
|
||||||
|
|
||||||
|
# Change for existing VMs
|
||||||
for vm in qvm_collection.values():
|
for vm in qvm_collection.values():
|
||||||
if vm.qid == 0:
|
if vm.qid == 0:
|
||||||
continue
|
continue
|
||||||
@ -875,5 +885,16 @@ def updates_dom0_toggle(qvm_collection, value):
|
|||||||
def updates_dom0_status(qvm_collection):
|
def updates_dom0_status(qvm_collection):
|
||||||
return not os.path.exists(UPDATES_DOM0_DISABLE_FLAG)
|
return not os.path.exists(UPDATES_DOM0_DISABLE_FLAG)
|
||||||
|
|
||||||
|
def updates_vms_status(qvm_collection):
|
||||||
|
# default value:
|
||||||
|
status = not os.path.exists(UPDATES_DEFAULT_VM_DISABLE_FLAG)
|
||||||
|
# check if all the VMs uses the default value
|
||||||
|
for vm in qvm_collection.values():
|
||||||
|
if vm.qid == 0:
|
||||||
|
continue
|
||||||
|
if vm.services.get('qubes-update-check', True) != status:
|
||||||
|
# "mixed"
|
||||||
|
return None
|
||||||
|
return status
|
||||||
|
|
||||||
# vim:sw=4:et:
|
# vim:sw=4:et:
|
||||||
|
@ -27,15 +27,14 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
from qubes.qubes import QubesVmCollection
|
from qubes.qubes import QubesVmCollection
|
||||||
from qubes.qubesutils import updates_vms_toggle,updates_dom0_toggle,\
|
from qubes.qubesutils import updates_vms_toggle,updates_dom0_toggle,\
|
||||||
updates_dom0_status
|
updates_dom0_status,updates_vms_status
|
||||||
from qubes.qubes import vmm
|
from qubes.qubes import vmm
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
usage = "%prog enable|disable|status\n"\
|
usage = "%prog enable|disable|status\n"\
|
||||||
" Enable or disable globally checking for updates (both dom0 and VM)"\
|
" Enable or disable globally checking for updates (both dom0 and VM)"
|
||||||
" Status option checks only dom0 updates status"
|
|
||||||
parser = OptionParser (usage)
|
parser = OptionParser (usage)
|
||||||
parser.add_option("--offline-mode", dest="offline_mode",
|
parser.add_option("--offline-mode", dest="offline_mode",
|
||||||
action="store_true", default=False,
|
action="store_true", default=False,
|
||||||
@ -67,9 +66,16 @@ def main():
|
|||||||
updates_vms_toggle(qvm_collection, False)
|
updates_vms_toggle(qvm_collection, False)
|
||||||
else:
|
else:
|
||||||
if updates_dom0_status(qvm_collection):
|
if updates_dom0_status(qvm_collection):
|
||||||
print "enabled"
|
print "dom0: enabled"
|
||||||
else:
|
else:
|
||||||
print "disabled"
|
print "dom0: disabled"
|
||||||
|
status_vms = updates_vms_status(qvm_collection)
|
||||||
|
if status_vms is None:
|
||||||
|
print "vms: mixed"
|
||||||
|
elif status_vms:
|
||||||
|
print "vms: enabled"
|
||||||
|
else:
|
||||||
|
print "vms: disabled"
|
||||||
|
|
||||||
if action != 'status':
|
if action != 'status':
|
||||||
qvm_collection.save()
|
qvm_collection.save()
|
||||||
|
Loading…
Reference in New Issue
Block a user