From 07314a5db00862c220adfe5d8adb18a36ff115d0 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Sun, 22 Apr 2012 23:56:04 +0200 Subject: [PATCH 01/17] dom0/qvm-start: fix --cdrom support. --- dom0/qvm-tools/qvm-start | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom0/qvm-tools/qvm-start b/dom0/qvm-tools/qvm-start index fd1bf67e..493e09f9 100755 --- a/dom0/qvm-tools/qvm-start +++ b/dom0/qvm-tools/qvm-start @@ -71,7 +71,7 @@ def main(): options.drive = 'hd:' + options.drive_hd if options.drive_cdrom: - options.drive = 'cdrom:' + options.drive_hd + options.drive = 'cdrom:' + options.drive_cdrom if options.drive: if hasattr(vm, 'drive'): From c93744d762542d9cb32e084a88e190d04c9650ce Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Mon, 23 Apr 2012 12:15:50 +0200 Subject: [PATCH 02/17] dom0/qvm-prefs: typo fix --- dom0/qvm-tools/qvm-prefs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom0/qvm-tools/qvm-prefs b/dom0/qvm-tools/qvm-prefs index 4d17a3d8..b4e7d075 100755 --- a/dom0/qvm-tools/qvm-prefs +++ b/dom0/qvm-tools/qvm-prefs @@ -127,7 +127,7 @@ def set_maxmem(vms, vm, args): return False if new_maxmem < vm.memory: - print >> sys.stderr, "WARNING: new maxmem smaller than memory property - VM will be able to use only 'maxmem' memory amount". + print >> sys.stderr, "WARNING: new maxmem smaller than memory property - VM will be able to use only 'maxmem' memory amount" vm.maxmem = new_maxmem From f84f2fd762a3d0679adad14d1db863245524a831 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Mon, 23 Apr 2012 12:17:28 +0200 Subject: [PATCH 03/17] dom0/qvm-prefs: remove duplicated set_include_in_backups --- dom0/qvm-tools/qvm-prefs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/dom0/qvm-tools/qvm-prefs b/dom0/qvm-tools/qvm-prefs index b4e7d075..7ceefb2a 100755 --- a/dom0/qvm-tools/qvm-prefs +++ b/dom0/qvm-tools/qvm-prefs @@ -289,14 +289,6 @@ def set_include_in_backups(vms, vm, args): vm.include_in_backups = bool(eval(args[0].capitalize())) return True -def set_include_in_backups(vms, vm, args): - if len (args) != 1: - print >> sys.stderr, "Missing value (True/False)!" - return False - - vm.include_in_backups = bool(eval(args[0].capitalize())) - return True - properties = { "include_in_backups": set_include_in_backups, "pcidevs": set_pcidevs, From c76d2fd864ba820a8e055b566fd2ae05f524457b Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Mon, 23 Apr 2012 12:18:44 +0200 Subject: [PATCH 04/17] dom0/qvm-start: remove obsolete --console switch --- dom0/qvm-tools/qvm-start | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dom0/qvm-tools/qvm-start b/dom0/qvm-tools/qvm-start index 493e09f9..c8c8031f 100755 --- a/dom0/qvm-tools/qvm-start +++ b/dom0/qvm-tools/qvm-start @@ -35,8 +35,6 @@ def main(): parser.add_option ("-q", "--quiet", action="store_false", dest="verbose", default=True) parser.add_option ("--no-guid", action="store_true", dest="noguid", default=False, help="Do not start the GUId (ignored)") - parser.add_option ("--console", action="store_true", dest="debug_console", default=False, - help="Attach debugging console to the newly started VM") parser.add_option ("--drive", dest="drive", default=None, help="Temporarily attach specified drive as CD/DVD or hard disk (can be specified with prefix 'hd:' or 'cdrom:', default is cdrom)") parser.add_option ("--hddisk", dest="drive_hd", default=None, @@ -85,7 +83,7 @@ def main(): try: vm.verify_files() - xid = vm.start(debug_console=options.debug_console, verbose=options.verbose, preparing_dvm=options.preparing_dvm, start_guid=not options.noguid) + xid = vm.start(verbose=options.verbose, preparing_dvm=options.preparing_dvm, start_guid=not options.noguid) except (IOError, OSError, QubesException) as err: print >> sys.stderr, "ERROR: {0}".format(err) exit (1) From a38f1b4284aeb3ccb21d8a06f5ee3b6432ffc482 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Mon, 23 Apr 2012 12:19:54 +0200 Subject: [PATCH 05/17] dom0/core: add 'debug' VM property (#537) --- dom0/qvm-core/qubes.py | 16 +++++++++++++--- dom0/qvm-tools/qvm-prefs | 16 ++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/dom0/qvm-core/qubes.py b/dom0/qvm-core/qubes.py index ce88d74d..98997838 100755 --- a/dom0/qvm-core/qubes.py +++ b/dom0/qvm-core/qubes.py @@ -256,6 +256,7 @@ class QubesVm(object): "mac": { "attr": "_mac", "default": None }, "include_in_backups": { "default": True }, "services": { "default": {}, "eval": "eval(str(value))" }, + "debug": { "default": False }, ##### Internal attributes - will be overriden in __init__ regardless of args "appmenus_templates_dir": { "eval": \ 'self.dir_path + "/" + default_appmenus_templates_subdir if self.updateable else ' + \ @@ -272,7 +273,7 @@ class QubesVm(object): for prop in ['qid', 'name', 'dir_path', 'memory', 'maxmem', 'pcidevs', 'vcpus', 'internal',\ 'uses_default_kernel', 'kernel', 'uses_default_kernelopts',\ 'kernelopts', 'services', 'installed_by_rpm',\ - 'uses_default_netvm', 'include_in_backups' ]: + 'uses_default_netvm', 'include_in_backups', 'debug' ]: attrs[prop]['save'] = 'str(self.%s)' % prop # Simple paths for prop in ['conf_file', 'root_img', 'volatile_img', 'private_img']: @@ -899,6 +900,9 @@ class QubesVm(object): args['otherdevs'] = "'script:file:{dir}/modules.img,xvdd,{mode}',".format(dir=self.kernels_dir, mode=modulesmode) if hasattr(self, 'kernelopts'): args['kernelopts'] = self.kernelopts + if self.debug: + print >> sys.stderr, "--> Debug mode: adding 'earlyprintk=xen' to kernel opts" + args['kernelopts'] += ' earlyprintk=xen' return args @@ -1332,7 +1336,10 @@ class QubesVm(object): print >> sys.stderr, "--> Starting Qubes GUId..." xid = self.get_xid() - retcode = subprocess.call ([qubes_guid_path, "-d", str(xid), "-c", self.label.color, "-i", self.label.icon, "-l", str(self.label.index)]) + guid_cmd = [qubes_guid_path, "-d", str(xid), "-c", self.label.color, "-i", self.label.icon, "-l", str(self.label.index)] + if self.debug: + guid_cmd += ['-v', '-v'] + retcode = subprocess.call (guid_cmd) if (retcode != 0) : raise QubesException("Cannot start qubes_guid!") @@ -2724,7 +2731,7 @@ class QubesVmCollection(dict): "installed_by_rpm", "internal", "uses_default_netvm", "label", "memory", "vcpus", "pcidevs", "maxmem", "kernel", "uses_default_kernel", "kernelopts", "uses_default_kernelopts", - "mac", "services", "include_in_backups" ) + "mac", "services", "include_in_backups", "debug" ) for attribute in common_attr_list: kwargs[attribute] = element.get(attribute) @@ -2783,6 +2790,9 @@ class QubesVmCollection(dict): if "kernelopts" not in kwargs: kwargs["uses_default_kernelopts"] = True + if "debug" in kwargs: + kwargs["debug"] = True if kwargs["debug"] == "True" else False + return kwargs def set_netvm_dependency(self, element): diff --git a/dom0/qvm-tools/qvm-prefs b/dom0/qvm-tools/qvm-prefs index 7ceefb2a..f2707d48 100755 --- a/dom0/qvm-tools/qvm-prefs +++ b/dom0/qvm-tools/qvm-prefs @@ -75,6 +75,8 @@ def do_list(vm): print fmt.format ("kernelopts", "%s (default)" % vm.kernelopts) else: print fmt.format ("kernelopts", vm.kernelopts) + if hasattr(vm, 'debug'): + print fmt.format("debug", "on" if vm.debug else "off") if hasattr(vm, 'drive'): print fmt.format("drive", str(vm.drive)) @@ -289,6 +291,19 @@ def set_include_in_backups(vms, vm, args): vm.include_in_backups = bool(eval(args[0].capitalize())) return True +def set_debug(vms, vm, args): + if len (args) != 1: + print >> sys.stderr, "Missing value (True/False or on/off)!" + return False + + if args[0].lower() == "on": + vm.debug = True + elif args[0].lower() == "off": + vm.debug = False + else: + vm.debug = bool(eval(args[0].capitalize())) + return True + properties = { "include_in_backups": set_include_in_backups, "pcidevs": set_pcidevs, @@ -303,6 +318,7 @@ properties = { "name": set_name, "drive": set_drive, "mac": set_mac, + "debug": set_debug, } From 90845484566b97fc09ee009483c2d59fba3f6f21 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Mon, 23 Apr 2012 12:38:55 +0200 Subject: [PATCH 06/17] dom0/qvm-start: allow temporally enable debug mode (#537) --- dom0/qvm-tools/qvm-start | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dom0/qvm-tools/qvm-start b/dom0/qvm-tools/qvm-start index c8c8031f..17d80fc6 100755 --- a/dom0/qvm-tools/qvm-start +++ b/dom0/qvm-tools/qvm-start @@ -45,6 +45,8 @@ def main(): help="Do actions necessary when preparing DVM image") parser.add_option ("--custom-config", action="store", dest="custom_config", default=None, help="Use custom Xen config instead of Qubes-generated one") + parser.add_option ("--debug", action="store_true", dest="debug", default=False, + help="Enable debug mode for this VM (until its shutdown)") (options, args) = parser.parse_args () if (len (args) != 1): @@ -81,6 +83,9 @@ def main(): if options.custom_config: vm.conf_file = options.custom_config + if options.debug: + vm.debug = True + try: vm.verify_files() xid = vm.start(verbose=options.verbose, preparing_dvm=options.preparing_dvm, start_guid=not options.noguid) @@ -88,4 +93,10 @@ def main(): print >> sys.stderr, "ERROR: {0}".format(err) exit (1) + if options.debug: + print >> sys.stderr, "--> Debug mode enabled. Useful logs: " + print >> sys.stderr, " /var/log/xen/console/guest-%s.log" % vmname + print >> sys.stderr, " /var/log/qubes/guid.%d.log" % xid + print >> sys.stderr, " /var/log/qubes/qrexec.%d.log" % xid + main() From ac804b5c2df5d7e389440811bb8090a7e2678c03 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Mon, 23 Apr 2012 22:01:13 +0200 Subject: [PATCH 07/17] dom0/qvm-prefs: relax memory check Allow memory > maxmem, anyway it will be enforced at VM boot. This allows to set memory and maxmem in any order. Also required to increase memory for HVM. --- dom0/qvm-tools/qvm-prefs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dom0/qvm-tools/qvm-prefs b/dom0/qvm-tools/qvm-prefs index f2707d48..a69a919a 100755 --- a/dom0/qvm-tools/qvm-prefs +++ b/dom0/qvm-tools/qvm-prefs @@ -106,8 +106,9 @@ def set_memory(vms, vm, args): print >>sys.stderr, "Memory size must be positive" return False - if new_memory > vm.maxmem: - print >>sys.stderr, "Memory size must be less or equal to maxmem" + qubes_host = QubesHost() + if new_memory > qubes_host.memory_total/1024: + print >> sys.stderr, "This host has only {0} MB of RAM".format(qubes_host.memory_total/1024) return False vm.memory = new_memory From db6b9b642c5e20d81c662e52628f8ccd0dd0d706 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Mon, 23 Apr 2012 23:26:40 +0200 Subject: [PATCH 08/17] dom0/core: setup xen logs permissions (#539) --- dom0/init.d/qubes_core | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dom0/init.d/qubes_core b/dom0/init.d/qubes_core index a3974289..dbcadccc 100755 --- a/dom0/init.d/qubes_core +++ b/dom0/init.d/qubes_core @@ -36,6 +36,9 @@ start() touch /var/run/qubes/xl-lock chgrp qubes /var/run/qubes/xl-lock chmod 660 /var/run/qubes/xl-lock + chgrp -R qubes /var/log/xen + chmod -R g+rX /var/log/xen + chmod g+s /var/log/xen/console mkdir -p /var/run/xen-hotplug xenstore-write /local/domain/0/name dom0 From 705699baf2659d4f2acd21bda739693098a40a4f Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Tue, 24 Apr 2012 01:38:02 +0200 Subject: [PATCH 09/17] dom0/core: include VM name in "insufficient memory" message (#534) --- dom0/qvm-core/qubes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom0/qvm-core/qubes.py b/dom0/qvm-core/qubes.py index 98997838..b34a5eb2 100755 --- a/dom0/qvm-core/qubes.py +++ b/dom0/qvm-core/qubes.py @@ -1391,7 +1391,7 @@ class QubesVm(object): qmemman_client = QMemmanClient() if not qmemman_client.request_memory(mem_required): qmemman_client.close() - raise MemoryError ("ERROR: insufficient memory to start this VM") + raise MemoryError ("ERROR: insufficient memory to start VM '%s'" % self.name) # Bind pci devices to pciback driver for pci in self.pcidevs: From 7d799e1d12253e76081674c44352f953228c36db Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Tue, 24 Apr 2012 01:40:56 +0200 Subject: [PATCH 10/17] dom0/qvm-tools: add GUI (tray balloon) error reporing to qvm-start and extend it in qvm-run (#534) --- dom0/qvm-tools/qvm-run | 2 ++ dom0/qvm-tools/qvm-start | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/dom0/qvm-tools/qvm-run b/dom0/qvm-tools/qvm-run index db5ad720..84f7e099 100755 --- a/dom0/qvm-tools/qvm-run +++ b/dom0/qvm-tools/qvm-run @@ -87,6 +87,8 @@ def vm_run_cmd(vm, cmd, options): notify_function = tray_notify_generic if options.tray else None, passio = options.passio, localcmd = options.localcmd) except QubesException as err: + if options.tray: + tray_notify_error(str(err)) print >> sys.stderr, "ERROR: %s" % str(err) exit(1) diff --git a/dom0/qvm-tools/qvm-start b/dom0/qvm-tools/qvm-start index 17d80fc6..bceadff8 100755 --- a/dom0/qvm-tools/qvm-start +++ b/dom0/qvm-tools/qvm-start @@ -26,13 +26,24 @@ from optparse import OptionParser import subprocess import os import sys +import dbus qubes_guid_path = "/usr/bin/qubes_guid" +notify_object = None + +def tray_notify(str, label, timeout = 3000): + notify_object.Notify("Qubes", 0, label.icon, "Qubes", str, [], [], timeout, dbus_interface="org.freedesktop.Notifications") + +def tray_notify_error(str, timeout = 3000): + notify_object.Notify("Qubes", 0, "dialog-error", "Qubes", str, [], [], timeout, dbus_interface="org.freedesktop.Notifications") + def main(): usage = "usage: %prog [options] " parser = OptionParser (usage) parser.add_option ("-q", "--quiet", action="store_false", dest="verbose", default=True) + parser.add_option ("--tray", action="store_true", dest="tray", default=False, + help="Use tray notifications instead of stdout" ) parser.add_option ("--no-guid", action="store_true", dest="noguid", default=False, help="Do not start the GUId (ignored)") parser.add_option ("--drive", dest="drive", default=None, @@ -53,6 +64,10 @@ def main(): parser.error ("You must specify VM name!") vmname = args[0] + if options.tray: + global notify_object + notify_object = dbus.SessionBus().get_object("org.freedesktop.Notifications", "/org/freedesktop/Notifications") + qvm_collection = QubesVmCollection() qvm_collection.lock_db_for_reading() qvm_collection.load() @@ -89,8 +104,11 @@ def main(): try: vm.verify_files() xid = vm.start(verbose=options.verbose, preparing_dvm=options.preparing_dvm, start_guid=not options.noguid) - except (IOError, OSError, QubesException) as err: - print >> sys.stderr, "ERROR: {0}".format(err) + except (IOError, OSError, QubesException, MemoryError) as err: + if options.tray: + tray_notify_error(str(err)) + else: + print >> sys.stderr, "ERROR: {0}".format(err) exit (1) if options.debug: From b0eb5d5f1460ec3975b21bb6efb6465e4c887af0 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Tue, 24 Apr 2012 01:41:22 +0200 Subject: [PATCH 11/17] dom0/appmenus: run qvm-start with --tray (#534) --- dom0/misc/qubes-start.desktop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom0/misc/qubes-start.desktop b/dom0/misc/qubes-start.desktop index e9eb63cc..63db9f3e 100644 --- a/dom0/misc/qubes-start.desktop +++ b/dom0/misc/qubes-start.desktop @@ -1,7 +1,7 @@ [Desktop Entry] Version=1.0 Type=Application -Exec=qvm-start --quiet %VMNAME% +Exec=qvm-start --quiet --tray %VMNAME% Icon=%VMDIR%/icon.png Terminal=false Name=%VMNAME%: Start From 2e7eb69c1a934b2785055174cf7505eb74a7cc9a Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Tue, 24 Apr 2012 02:08:49 +0200 Subject: [PATCH 12/17] dom0/qvm-firewall: clarify message (#24 pro) --- dom0/qvm-tools/qvm-firewall | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom0/qvm-tools/qvm-firewall b/dom0/qvm-tools/qvm-firewall index 301c6a0c..f85bc6ff 100755 --- a/dom0/qvm-tools/qvm-firewall +++ b/dom0/qvm-tools/qvm-firewall @@ -300,7 +300,7 @@ def main(): if not options.numeric: load_services() if not vm.has_firewall(): - print "INFO: This VM has no firewall set, below defaults are listed" + print "INFO: This VM has no firewall rules set, below defaults are listed" display_firewall(conf) if changed: From 016837a19c95621131e290be4852b4e5b9c75439 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Tue, 24 Apr 2012 12:34:31 +0200 Subject: [PATCH 13/17] dom0/core: fix 'drive' saving logic There is no longer need to override get_xml_attrs. Also include 'drive' in properties retrieved from qubes.xml. --- dom0/qvm-core/qubes.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/dom0/qvm-core/qubes.py b/dom0/qvm-core/qubes.py index b34a5eb2..4124f7cf 100755 --- a/dom0/qvm-core/qubes.py +++ b/dom0/qvm-core/qubes.py @@ -2364,11 +2364,6 @@ class QubesHVm(QubesVm): xc.domain_unpause(self.stubdom_xid) super(QubesHVm, self).unpause() - def get_xml_attrs(self): - attrs = super(QubesHVm, self).get_xml_attrs() - attrs["drive"] = str(self.drive) - return attrs - class QubesVmCollection(dict): """ A collection of Qubes VMs indexed by Qubes id (qid) @@ -2731,7 +2726,7 @@ class QubesVmCollection(dict): "installed_by_rpm", "internal", "uses_default_netvm", "label", "memory", "vcpus", "pcidevs", "maxmem", "kernel", "uses_default_kernel", "kernelopts", "uses_default_kernelopts", - "mac", "services", "include_in_backups", "debug" ) + "mac", "services", "include_in_backups", "debug", "drive" ) for attribute in common_attr_list: kwargs[attribute] = element.get(attribute) @@ -2793,6 +2788,9 @@ class QubesVmCollection(dict): if "debug" in kwargs: kwargs["debug"] = True if kwargs["debug"] == "True" else False + if "drive" in kwargs and kwargs["drive"] == "None": + kwargs["drive"] = None + return kwargs def set_netvm_dependency(self, element): From 4ce7824fa0d40b8a6d3f8cfb2b43e2dbb6c1e8ca Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Tue, 24 Apr 2012 13:07:21 +0200 Subject: [PATCH 14/17] dom0/core: remove unnecessary assignment This is already done by 'eval' entry in _get_attrs_config. --- dom0/qvm-core/qubes.py | 1 - 1 file changed, 1 deletion(-) diff --git a/dom0/qvm-core/qubes.py b/dom0/qvm-core/qubes.py index 4124f7cf..10a0b4b4 100755 --- a/dom0/qvm-core/qubes.py +++ b/dom0/qvm-core/qubes.py @@ -2189,7 +2189,6 @@ class QubesHVm(QubesVm): kwargs["memory"] = default_hvm_memory super(QubesHVm, self).__init__(**kwargs) - self.config_file_template = config_template_hvm # HVM doesn't support dynamic memory management self.maxmem = self.memory From a8ec5a6506d8e525f7faf4e5925dd98e6648f659 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Tue, 24 Apr 2012 13:09:27 +0200 Subject: [PATCH 15/17] dom0/core: add 'timezone' property support (#1 pro) --- dom0/misc/vm-template-hvm.conf | 2 ++ dom0/qvm-core/qubes.py | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/dom0/misc/vm-template-hvm.conf b/dom0/misc/vm-template-hvm.conf index 2ddfe056..aae0f1b4 100644 --- a/dom0/misc/vm-template-hvm.conf +++ b/dom0/misc/vm-template-hvm.conf @@ -18,6 +18,8 @@ device_model='stubdom-dm' usbdevice='tablet' sdl=0 vnc=0 +localtime = {localtime} +rtc_timeoffset = {timeoffset} disk = [ {rootdev} {privatedev} {otherdevs} diff --git a/dom0/qvm-core/qubes.py b/dom0/qvm-core/qubes.py index 10a0b4b4..87b5a70f 100755 --- a/dom0/qvm-core/qubes.py +++ b/dom0/qvm-core/qubes.py @@ -2174,6 +2174,7 @@ class QubesHVm(QubesVm): attrs['config_file_template']['eval'] = 'config_template_hvm' attrs['drive'] = { 'save': 'str(self.drive)' } attrs['maxmem'].pop('save') + attrs['timezone'] = { 'default': 'localtime', 'save': 'str(self.timezone)' } return attrs @@ -2205,6 +2206,7 @@ class QubesHVm(QubesVm): attrs.remove('uses_default_kernel') attrs.remove('kernelopts') attrs.remove('uses_default_kernelopts') + attrs += [ 'timezone' ] return attrs def create_on_disk(self, verbose, source_template = None): @@ -2292,6 +2294,17 @@ class QubesHVm(QubesVm): params['otherdevs'] = "'script:file:%s,xvdc%s%s'," % (drive_path, type_mode, backend_domain) else: params['otherdevs'] = '' + + if self.timezone.lower() == 'localtime': + params['localtime'] = '1' + params['timeoffset'] = '0' + elif self.timezone.isdigit(): + params['localtime'] = '0' + params['timeoffset'] = self.timezone + else: + print >>sys.stderr, "WARNING: invalid 'timezone' value: %s" % self.timezone + params['localtime'] = '0' + params['timeoffset'] = '0' return params def verify_files(self): From a43fa8f06bbf2cee754b4135e4a9a487338afb3a Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Tue, 24 Apr 2012 13:10:01 +0200 Subject: [PATCH 16/17] dom0/qvm-prefs: support for setting timezone (#1 pro) --- dom0/qvm-tools/qvm-prefs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dom0/qvm-tools/qvm-prefs b/dom0/qvm-tools/qvm-prefs index a69a919a..dab46bdd 100755 --- a/dom0/qvm-tools/qvm-prefs +++ b/dom0/qvm-tools/qvm-prefs @@ -81,6 +81,9 @@ def do_list(vm): if hasattr(vm, 'drive'): print fmt.format("drive", str(vm.drive)) + if hasattr(vm, 'timezone'): + print fmt.format("timezone", str(vm.timezone)) + def set_label(vms, vm, args): if len (args) != 1: print >> sys.stderr, "Missing label name argument!" @@ -305,6 +308,18 @@ def set_debug(vms, vm, args): vm.debug = bool(eval(args[0].capitalize())) return True +def set_timezone(vms, vm, args): + if len (args) != 1: + print >> sys.stderr, "Missing value ('localtime' or timeoffset in seconds)!" + return False + + if not args[0].isdigit() and args[0].lower() == 'localtime': + print >> sys.stderr, "Invalid timezone value!" + return False + + vm.timezone = args[0] + return True + properties = { "include_in_backups": set_include_in_backups, "pcidevs": set_pcidevs, @@ -320,6 +335,7 @@ properties = { "drive": set_drive, "mac": set_mac, "debug": set_debug, + "timezone": set_timezone, } From 3aedb8f363f6660948367e30ad683333358f3cbf Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Tue, 24 Apr 2012 13:10:25 +0200 Subject: [PATCH 17/17] dom0/qvm-prefs: fix 'drive' setting Allow clear the property. --- dom0/qvm-tools/qvm-prefs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dom0/qvm-tools/qvm-prefs b/dom0/qvm-tools/qvm-prefs index dab46bdd..a1e60002 100755 --- a/dom0/qvm-tools/qvm-prefs +++ b/dom0/qvm-tools/qvm-prefs @@ -284,7 +284,10 @@ def set_drive(vms, vm, args): print >> sys.stderr, "Missing new drive content (file/device)!" return False - vm.drive = args[0] + if args[0] == '' or args[0].lower() == 'none': + vm.drive = None + else: + vm.drive = args[0] return True def set_include_in_backups(vms, vm, args):