From d1abb37a5fe38df046bee9bda74f6ec7fc33c869 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Wed, 6 Apr 2011 23:30:14 +0200 Subject: [PATCH 1/4] Do not fail if cannot remove VM from xen store just before adding it again (#204) --- dom0/qvm-core/qubes.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dom0/qvm-core/qubes.py b/dom0/qvm-core/qubes.py index 230f4889..27d2a667 100755 --- a/dom0/qvm-core/qubes.py +++ b/dom0/qvm-core/qubes.py @@ -372,7 +372,11 @@ class QubesVm(object): self.session_metrics = None def update_xen_storage(self): - self.remove_from_xen_storage() + try: + self.remove_from_xen_storage() + except OSError as ex: + print "WARNING: {0}. Continuing anyway...".format(str(ex)) + pass self.add_to_xen_storage() if not dry_run and xend_session.session is not None: self.refresh_xend_session() From c569d4070e40ad059555203cbc16ecfc09980c57 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Wed, 6 Apr 2011 23:52:39 +0200 Subject: [PATCH 2/4] Warning the user if calling qvm-{create,remove} as root (#200) --- dom0/qvm-tools/qvm-create | 11 +++++++++++ dom0/qvm-tools/qvm-remove | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/dom0/qvm-tools/qvm-create b/dom0/qvm-tools/qvm-create index eaa86352..f6197590 100755 --- a/dom0/qvm-tools/qvm-create +++ b/dom0/qvm-tools/qvm-create @@ -65,6 +65,8 @@ def main(): help="VCPUs count") parser.add_option ("-i", "--internal", action="store_true", dest="internal", default=False, help="Create VM for internal use only (hidden in qubes-manager, no appmenus)") + parser.add_option ("--force-root", action="store_true", dest="force_root", default=False, + help="Force to run, even with root privileges") parser.add_option ("-q", "--quiet", action="store_false", dest="verbose", default=True) (options, args) = parser.parse_args () @@ -75,6 +77,15 @@ def main(): if options.netvm and options.proxyvm: parser.error ("You must specify at most one of --proxy and --net") + if os.geteuid() == 0: + print "*** Running this tool as root is strongly discouraged, this will lead you in permissions problems." + if options.force_root: + print "Continuing as commanded. You have been warned." + else: + print "Retry as unprivileged user." + print "... or use --force-root to continue anyway." + exit(1) + if options.label is None: print "You must choose a label for the new VM by passing the --label option." print "Possible values are:" diff --git a/dom0/qvm-tools/qvm-remove b/dom0/qvm-tools/qvm-remove index e29cb6bd..a299ea51 100755 --- a/dom0/qvm-tools/qvm-remove +++ b/dom0/qvm-tools/qvm-remove @@ -29,6 +29,8 @@ def main(): parser.add_option ("-q", "--quiet", action="store_false", dest="verbose", default=True) parser.add_option ("--just-db", action="store_true", dest="remove_from_db_only", default=False, help="Remove only from the Qubes Xen DB, do not remove any files") + parser.add_option ("--force-root", action="store_true", dest="force_root", default=False, + help="Force to run, even with root privileges") (options, args) = parser.parse_args () if (len (args) != 1): parser.error ("You must specify VM name!") @@ -42,6 +44,15 @@ def main(): print "A VM with the name '{0}' does not exist in the system.".format(vmname) exit(1) + if os.geteuid() == 0: + print "*** Running this tool as root is strongly discouraged, this will lead you in permissions problems." + if options.force_root: + print "Continuing as commanded. You have been warned." + else: + print "Retry as unprivileged user." + print "... or use --force-root to continue anyway." + exit(1) + if vm.is_template(): dependent_vms = qvm_collection.get_vms_based_on(vm.qid) if len(dependent_vms) > 0: From 086f2720dfcff1b3ce4c60341d81f6c9872097d8 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Wed, 6 Apr 2011 23:55:16 +0200 Subject: [PATCH 3/4] Add missing import (#200) --- dom0/qvm-tools/qvm-create | 1 + dom0/qvm-tools/qvm-remove | 1 + 2 files changed, 2 insertions(+) diff --git a/dom0/qvm-tools/qvm-create b/dom0/qvm-tools/qvm-create index f6197590..b4479fab 100755 --- a/dom0/qvm-tools/qvm-create +++ b/dom0/qvm-tools/qvm-create @@ -25,6 +25,7 @@ from qubes.qubes import QubesVmLabels from optparse import OptionParser; import subprocess import re +import os def find_net_devices(): p = subprocess.Popen (["lspci", "-mm", "-n"], stdout=subprocess.PIPE) diff --git a/dom0/qvm-tools/qvm-remove b/dom0/qvm-tools/qvm-remove index a299ea51..5f1b1aa2 100755 --- a/dom0/qvm-tools/qvm-remove +++ b/dom0/qvm-tools/qvm-remove @@ -22,6 +22,7 @@ from qubes.qubes import QubesVmCollection from optparse import OptionParser; +import os def main(): usage = "usage: %prog [options] " From e9c6dc387ecb048ef580c701585edffa69062010 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Thu, 7 Apr 2011 10:42:24 +0200 Subject: [PATCH 4/4] Fixed getting VMs connected to NetVM (#172) --- 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 27d2a667..4555e629 100755 --- a/dom0/qvm-core/qubes.py +++ b/dom0/qvm-core/qubes.py @@ -1811,7 +1811,7 @@ class QubesVmCollection(dict): while len(new_vms) > 0: cur_vm = new_vms.pop() - for vm in cur_vm.connected_vms.values(): + for vm in self[cur_vm].connected_vms.values(): if vm.qid not in dependend_vms_qid: dependend_vms_qid.append(vm.qid) if vm.is_netvm():