dom0: implement custom kernelopts (#323)

This commit is contained in:
Marek Marczykowski 2011-08-31 20:34:56 +02:00
parent 691545c492
commit 3cf1af0321
2 changed files with 46 additions and 8 deletions

View File

@ -74,6 +74,9 @@ default_kernels_subdir = "kernels"
default_firewall_conf_file = "firewall.xml"
default_memory = 400
default_servicevm_vcpus = 1
default_kernelopts = ""
# TODO: change to iommu=soft when we migrate to pvops in domU
default_kernelopts_pcidevs = "swiotlb=force pci=nomsi"
qubes_whitelisted_appmenus = 'whitelisted-appmenus.list'
@ -200,7 +203,9 @@ class QubesVm(object):
internal = False,
vcpus = None,
kernel = None,
uses_default_kernel = True):
uses_default_kernel = True,
kernelopts = "",
uses_default_kernelopts = True):
assert qid < qubes_max_qid, "VM id out of bounds!"
@ -312,6 +317,15 @@ class QubesVm(object):
else:
self.vcpus = vcpus
self.uses_default_kernelopts = uses_default_kernelopts
if self.uses_default_kernelopts:
if len(self.pcidevs) > 0:
self.kernelopts = default_kernelopts_pcidevs
else:
self.kernelopts = default_kernelopts
else:
self.kernelopts = kernelopts
# Internal VM (not shown in qubes-manager, doesn't create appmenus entries
self.internal = internal
@ -665,7 +679,7 @@ class QubesVm(object):
args['privatedev'] = "'script:file:{dir}/private.img,xvdb,w',".format(dir=self.dir_path)
args['volatiledev'] = "'script:file:{dir}/volatile.img,xvdc,w',".format(dir=self.dir_path)
args['otherdevs'] = "'script:file:{dir}/modules.img,xvdd,r',".format(dir=self.kernels_dir)
args['kernelopts'] = ''
args['kernelopts'] = self.kernelopts
return args
@ -1033,6 +1047,8 @@ class QubesVm(object):
attrs["internal"] = str(self.internal)
attrs["uses_default_kernel"] = str(self.uses_default_kernel)
attrs["kernel"] = str(self.kernel)
attrs["uses_default_kernelopts"] = str(self.uses_default_kernelopts)
attrs["kernelopts"] = str(self.kernelopts)
return attrs
def create_xml_element(self):
@ -1343,11 +1359,6 @@ class QubesNetVm(QubesVm):
assert lo >= 1 and lo <= 254, "Wrong IP address for VM"
return self.dispnetprefix + "{0}".format(lo)
def get_config_params(self, source_template=None):
args = super(QubesNetVm, self).get_config_params(source_template)
args['kernelopts'] = ' swiotlb=force pci=nomsi'
return args
def create_xenstore_entries(self, xid):
if dry_run:
return
@ -2007,7 +2018,7 @@ class QubesVmCollection(dict):
"private_img", "root_img", "template_qid",
"installed_by_rpm", "updateable", "internal",
"uses_default_netvm", "label", "memory", "vcpus", "pcidevs",
"maxmem", "kernel", "uses_default_kernel" )
"maxmem", "kernel", "uses_default_kernel", "kernelopts", "uses_default_kernel" )
for attribute in common_attr_list:
kwargs[attribute] = element.get(attribute)
@ -2055,6 +2066,9 @@ class QubesVmCollection(dict):
kwargs["kernel"]=None
# for other cases - generic assigment is ok
if "uses_default_kernelopts" in kwargs:
kwargs["uses_default_kernelopts"] = True if kwargs["uses_default_kernelopts"] == "True" else False
return kwargs
def set_netvm_dependency(self, element):

View File

@ -61,6 +61,10 @@ def do_list(vm):
print fmt.format ("kernel", "%s (default)" % vm.kernel)
else:
print fmt.format ("kernel", vm.kernel)
if vm.uses_default_kernelopts:
print fmt.format ("kernelopts", "%s (default)" % vm.kernelopts)
else:
print fmt.format ("kernelopts", vm.kernelopts)
def set_label(vms, vm, args):
@ -262,6 +266,25 @@ def set_vcpus(vms, vm, args):
vm.vcpus = vcpus
return True
def set_kernelopts(vms, vm, args):
if len (args) != 1:
print "Missing kernel opts argument!"
if len (args) != 1:
print "Missing kernel opts argument!"
print "Possible values:"
print "1) default"
print "2) <opts>"
return False
if args[0] == 'default':
vm.uses_default_kernelopts = True
else:
vm.uses_default_kernelopts = False
vm.kernelopts = args[0]
return True
properties = {
"updateable": set_updateable,
"nonupdateable": set_nonupdateable,
@ -273,6 +296,7 @@ properties = {
"kernel" : set_kernel,
"template" : set_template,
"vcpus" : set_vcpus,
"kernelopts": set_kernelopts,
}