Merge branch 'master' of git.qubes-os.org:/var/lib/qubes/git/marmarek/core

This commit is contained in:
Joanna Rutkowska 2012-06-14 11:22:53 +02:00
commit c717ac180b
5 changed files with 40 additions and 13 deletions

View File

@ -53,8 +53,12 @@ start()
MEMINFO_DELAY_USEC=100000 MEMINFO_DELAY_USEC=100000
/usr/lib/qubes/meminfo-writer $MEM_CHANGE_THRESHOLD_KB $MEMINFO_DELAY_USEC & /usr/lib/qubes/meminfo-writer $MEM_CHANGE_THRESHOLD_KB $MEMINFO_DELAY_USEC &
# Reply block events to hide mounted devices from qubes-block list (at first udev run, only / is mounted) # Hide mounted devices from qubes-block list (at first udev run, only / is mounted)
udevadm trigger --subsystem-match=block --action=add for dev in `xenstore-list /local/domain/0/qubes-block-devices`; do
( eval `udevadm info -q property -n $dev|sed -e 's/\([^=]*\)=\(.*\)/export \1="\2"/'`;
/usr/lib/qubes/block_add_change
)
done
touch /var/lock/subsys/qubes_core touch /var/lock/subsys/qubes_core
success success

View File

@ -245,12 +245,13 @@ class QubesVm(object):
"kernel": { "default": None, 'order': 30 }, "kernel": { "default": None, 'order': 30 },
"uses_default_kernel": { "default": True, 'order': 30 }, "uses_default_kernel": { "default": True, 'order': 30 },
"uses_default_kernelopts": { "default": True, 'order': 30 }, "uses_default_kernelopts": { "default": True, 'order': 30 },
"kernelopts": { "default": "", 'order': 30, "eval": \ "kernelopts": { "default": "", 'order': 31, "eval": \
'value if not self.uses_default_kernelopts else default_kernelopts_pcidevs if len(self.pcidevs) > 0 else default_kernelopts' }, 'value if not self.uses_default_kernelopts else default_kernelopts_pcidevs if len(self.pcidevs) > 0 else default_kernelopts' },
"mac": { "attr": "_mac", "default": None }, "mac": { "attr": "_mac", "default": None },
"include_in_backups": { "default": True }, "include_in_backups": { "default": True },
"services": { "default": {}, "eval": "eval(str(value))" }, "services": { "default": {}, "eval": "eval(str(value))" },
"debug": { "default": False }, "debug": { "default": False },
"default_user": { "default": "user" },
##### Internal attributes - will be overriden in __init__ regardless of args ##### Internal attributes - will be overriden in __init__ regardless of args
"appmenus_templates_dir": { "eval": \ "appmenus_templates_dir": { "eval": \
'self.dir_path + "/" + default_appmenus_templates_subdir if self.updateable else ' + \ 'self.dir_path + "/" + default_appmenus_templates_subdir if self.updateable else ' + \
@ -267,7 +268,8 @@ class QubesVm(object):
for prop in ['qid', 'name', 'dir_path', 'memory', 'maxmem', 'pcidevs', 'vcpus', 'internal',\ for prop in ['qid', 'name', 'dir_path', 'memory', 'maxmem', 'pcidevs', 'vcpus', 'internal',\
'uses_default_kernel', 'kernel', 'uses_default_kernelopts',\ 'uses_default_kernel', 'kernel', 'uses_default_kernelopts',\
'kernelopts', 'services', 'installed_by_rpm',\ 'kernelopts', 'services', 'installed_by_rpm',\
'uses_default_netvm', 'include_in_backups', 'debug' ]: 'uses_default_netvm', 'include_in_backups', 'debug',\
'default_user' ]:
attrs[prop]['save'] = 'str(self.%s)' % prop attrs[prop]['save'] = 'str(self.%s)' % prop
# Simple paths # Simple paths
for prop in ['conf_file', 'root_img', 'volatile_img', 'private_img']: for prop in ['conf_file', 'root_img', 'volatile_img', 'private_img']:
@ -642,12 +644,18 @@ class QubesVm(object):
return "NA" return "NA"
def is_fully_usable(self): def is_guid_running(self):
xid = self.get_xid() xid = self.get_xid()
if xid < 0: if xid < 0:
return False return False
if not os.path.exists('/var/run/qubes/guid_running.%d' % xid): if not os.path.exists('/var/run/qubes/guid_running.%d' % xid):
return False return False
return True
def is_fully_usable(self):
# Running gui-daemon implies also VM running
if not self.is_guid_running():
return False
# currently qrexec daemon doesn't cleanup socket in /var/run/qubes, so # currently qrexec daemon doesn't cleanup socket in /var/run/qubes, so
# it can be left from some other VM # it can be left from some other VM
return True return True
@ -1298,7 +1306,7 @@ class QubesVm(object):
raise QubesException("Not enough memory to start '{0}' VM! Close one or more running VMs and try again.".format(self.name)) raise QubesException("Not enough memory to start '{0}' VM! Close one or more running VMs and try again.".format(self.name))
xid = self.get_xid() xid = self.get_xid()
if os.getenv("DISPLAY") is not None and not os.path.isfile("/var/run/qubes/guid_running.{0}".format(xid)): if os.getenv("DISPLAY") is not None and not self.is_guid_running():
self.start_guid(verbose = verbose, notify_function = notify_function) self.start_guid(verbose = verbose, notify_function = notify_function)
args = [qrexec_client_path, "-d", str(xid), command] args = [qrexec_client_path, "-d", str(xid), command]
@ -2534,7 +2542,7 @@ class QubesVmCollection(dict):
"installed_by_rpm", "internal", "installed_by_rpm", "internal",
"uses_default_netvm", "label", "memory", "vcpus", "pcidevs", "uses_default_netvm", "label", "memory", "vcpus", "pcidevs",
"maxmem", "kernel", "uses_default_kernel", "kernelopts", "uses_default_kernelopts", "maxmem", "kernel", "uses_default_kernel", "kernelopts", "uses_default_kernelopts",
"mac", "services", "include_in_backups", "debug" ) "mac", "services", "include_in_backups", "debug", "default_user" )
for attribute in common_attr_list: for attribute in common_attr_list:
kwargs[attribute] = element.get(attribute) kwargs[attribute] = element.get(attribute)

View File

@ -76,6 +76,9 @@ def do_list(vm):
if hasattr(vm, 'debug'): if hasattr(vm, 'debug'):
print fmt.format("debug", "on" if vm.debug else "off") print fmt.format("debug", "on" if vm.debug else "off")
if hasattr(vm, 'default_user'):
print fmt.format("default user", str(vm.default_user))
def set_label(vms, vm, args): def set_label(vms, vm, args):
if len (args) != 1: if len (args) != 1:
print >> sys.stderr, "Missing label name argument!" print >> sys.stderr, "Missing label name argument!"
@ -283,7 +286,14 @@ def set_debug(vms, vm, args):
vm.debug = False vm.debug = False
else: else:
vm.debug = bool(eval(args[0].capitalize())) vm.debug = bool(eval(args[0].capitalize()))
return True
def set_default_user(vms, vm, args):
if len (args) != 1:
print >> sys.stderr, "Missing user name!"
return False
vm.default_user = args[0]
return True return True
def set_include_in_backups(vms, vm, args): def set_include_in_backups(vms, vm, args):
@ -308,6 +318,7 @@ properties = {
"name": set_name, "name": set_name,
"mac": set_mac, "mac": set_mac,
"debug": set_debug, "debug": set_debug,
"default_user": set_default_user,
} }

View File

@ -98,7 +98,7 @@ def main():
parser.add_option ("-q", "--quiet", action="store_false", dest="verbose", default=True) parser.add_option ("-q", "--quiet", action="store_false", dest="verbose", default=True)
parser.add_option ("-a", "--auto", action="store_true", dest="auto", default=False, parser.add_option ("-a", "--auto", action="store_true", dest="auto", default=False,
help="Auto start the VM if not running") help="Auto start the VM if not running")
parser.add_option ("-u", "--user", action="store", dest="user", default="user", parser.add_option ("-u", "--user", action="store", dest="user", default=None,
help="Run command in a VM as a specified user") help="Run command in a VM as a specified user")
parser.add_option ("--tray", action="store_true", dest="tray", default=False, parser.add_option ("--tray", action="store_true", dest="tray", default=False,
help="Use tray notifications instead of stdout" ) help="Use tray notifications instead of stdout" )
@ -188,12 +188,12 @@ def main():
exit(1) exit(1)
vms_list.append(vm) vms_list.append(vm)
if takes_cmd_argument:
cmd = "{user}:{cmd}".format(user=options.user, cmd=cmdstr)
else:
cmd = None
for vm in vms_list: for vm in vms_list:
if takes_cmd_argument:
cmd = "{user}:{cmd}".format(user=options.user if options.user else vm.default_user, cmd=cmdstr)
else:
cmd = None
vm_run_cmd(vm, cmd, options) vm_run_cmd(vm, cmd, options)

View File

@ -43,6 +43,10 @@ fi
mkdir -p $DOM0_UPDATES_DIR/etc mkdir -p $DOM0_UPDATES_DIR/etc
sed -i '/^reposdir\s*=/d' $DOM0_UPDATES_DIR/etc/yum.conf sed -i '/^reposdir\s*=/d' $DOM0_UPDATES_DIR/etc/yum.conf
# Rebuild rpm database in case of different rpm version
rm -f $DOM0_UPDATES_DIR/var/lib/rpm/__*
rpm --root=$DOM0_UPDATES_DIR --rebuilddb
if [ "$CLEAN" = "1" ]; then if [ "$CLEAN" = "1" ]; then
yum $OPTS clean all yum $OPTS clean all
rm -f $DOM0_UPDATES_DIR/packages/* rm -f $DOM0_UPDATES_DIR/packages/*