diff --git a/core-modules/000QubesVm.py b/core-modules/000QubesVm.py index c49e178e..df0180f8 100644 --- a/core-modules/000QubesVm.py +++ b/core-modules/000QubesVm.py @@ -43,6 +43,7 @@ from qubes.qubes import dry_run,vmm from qubes.qubes import register_qubes_vm_class from qubes.qubes import QubesVmCollection,QubesException,QubesHost,QubesVmLabels from qubes.qubes import defaults,system_path,vm_files,qubes_max_qid + qmemman_present = False try: from qubes.qmemman_client import QMemmanClient @@ -334,6 +335,11 @@ class QubesVm(object): if len(self.pcidevs) > 0: 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 self.storage = defaults["storage_class"](self) if hasattr(self, 'kernels_dir'): diff --git a/core/qubesutils.py b/core/qubesutils.py index b0da7a7c..041a66c8 100644 --- a/core/qubesutils.py +++ b/core/qubesutils.py @@ -844,8 +844,18 @@ class QubesWatch(object): ##### updates check ##### 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): + # 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(): if vm.qid == 0: continue @@ -875,5 +885,16 @@ def updates_dom0_toggle(qvm_collection, value): def updates_dom0_status(qvm_collection): 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: diff --git a/qvm-tools/qubes-set-updates b/qvm-tools/qubes-set-updates index feca2c85..c57a6ccb 100755 --- a/qvm-tools/qubes-set-updates +++ b/qvm-tools/qubes-set-updates @@ -27,15 +27,14 @@ import os import sys from qubes.qubes import QubesVmCollection from qubes.qubesutils import updates_vms_toggle,updates_dom0_toggle,\ - updates_dom0_status + updates_dom0_status,updates_vms_status from qubes.qubes import vmm def main(): usage = "%prog enable|disable|status\n"\ - " Enable or disable globally checking for updates (both dom0 and VM)"\ - " Status option checks only dom0 updates status" + " Enable or disable globally checking for updates (both dom0 and VM)" parser = OptionParser (usage) parser.add_option("--offline-mode", dest="offline_mode", action="store_true", default=False, @@ -67,9 +66,16 @@ def main(): updates_vms_toggle(qvm_collection, False) else: if updates_dom0_status(qvm_collection): - print "enabled" + print "dom0: enabled" 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': qvm_collection.save()