dom0: implement custom kernelopts (#323)
This commit is contained in:
parent
691545c492
commit
3cf1af0321
@ -74,6 +74,9 @@ default_kernels_subdir = "kernels"
|
|||||||
default_firewall_conf_file = "firewall.xml"
|
default_firewall_conf_file = "firewall.xml"
|
||||||
default_memory = 400
|
default_memory = 400
|
||||||
default_servicevm_vcpus = 1
|
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'
|
qubes_whitelisted_appmenus = 'whitelisted-appmenus.list'
|
||||||
|
|
||||||
@ -200,7 +203,9 @@ class QubesVm(object):
|
|||||||
internal = False,
|
internal = False,
|
||||||
vcpus = None,
|
vcpus = None,
|
||||||
kernel = 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!"
|
assert qid < qubes_max_qid, "VM id out of bounds!"
|
||||||
@ -312,6 +317,15 @@ class QubesVm(object):
|
|||||||
else:
|
else:
|
||||||
self.vcpus = vcpus
|
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
|
# Internal VM (not shown in qubes-manager, doesn't create appmenus entries
|
||||||
self.internal = internal
|
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['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['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['otherdevs'] = "'script:file:{dir}/modules.img,xvdd,r',".format(dir=self.kernels_dir)
|
||||||
args['kernelopts'] = ''
|
args['kernelopts'] = self.kernelopts
|
||||||
|
|
||||||
return args
|
return args
|
||||||
|
|
||||||
@ -1033,6 +1047,8 @@ class QubesVm(object):
|
|||||||
attrs["internal"] = str(self.internal)
|
attrs["internal"] = str(self.internal)
|
||||||
attrs["uses_default_kernel"] = str(self.uses_default_kernel)
|
attrs["uses_default_kernel"] = str(self.uses_default_kernel)
|
||||||
attrs["kernel"] = str(self.kernel)
|
attrs["kernel"] = str(self.kernel)
|
||||||
|
attrs["uses_default_kernelopts"] = str(self.uses_default_kernelopts)
|
||||||
|
attrs["kernelopts"] = str(self.kernelopts)
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
def create_xml_element(self):
|
def create_xml_element(self):
|
||||||
@ -1343,11 +1359,6 @@ class QubesNetVm(QubesVm):
|
|||||||
assert lo >= 1 and lo <= 254, "Wrong IP address for VM"
|
assert lo >= 1 and lo <= 254, "Wrong IP address for VM"
|
||||||
return self.dispnetprefix + "{0}".format(lo)
|
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):
|
def create_xenstore_entries(self, xid):
|
||||||
if dry_run:
|
if dry_run:
|
||||||
return
|
return
|
||||||
@ -2007,7 +2018,7 @@ class QubesVmCollection(dict):
|
|||||||
"private_img", "root_img", "template_qid",
|
"private_img", "root_img", "template_qid",
|
||||||
"installed_by_rpm", "updateable", "internal",
|
"installed_by_rpm", "updateable", "internal",
|
||||||
"uses_default_netvm", "label", "memory", "vcpus", "pcidevs",
|
"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:
|
for attribute in common_attr_list:
|
||||||
kwargs[attribute] = element.get(attribute)
|
kwargs[attribute] = element.get(attribute)
|
||||||
@ -2055,6 +2066,9 @@ class QubesVmCollection(dict):
|
|||||||
kwargs["kernel"]=None
|
kwargs["kernel"]=None
|
||||||
# for other cases - generic assigment is ok
|
# 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
|
return kwargs
|
||||||
|
|
||||||
def set_netvm_dependency(self, element):
|
def set_netvm_dependency(self, element):
|
||||||
|
@ -61,6 +61,10 @@ def do_list(vm):
|
|||||||
print fmt.format ("kernel", "%s (default)" % vm.kernel)
|
print fmt.format ("kernel", "%s (default)" % vm.kernel)
|
||||||
else:
|
else:
|
||||||
print fmt.format ("kernel", vm.kernel)
|
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):
|
def set_label(vms, vm, args):
|
||||||
@ -262,6 +266,25 @@ def set_vcpus(vms, vm, args):
|
|||||||
vm.vcpus = vcpus
|
vm.vcpus = vcpus
|
||||||
return True
|
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 = {
|
properties = {
|
||||||
"updateable": set_updateable,
|
"updateable": set_updateable,
|
||||||
"nonupdateable": set_nonupdateable,
|
"nonupdateable": set_nonupdateable,
|
||||||
@ -273,6 +296,7 @@ properties = {
|
|||||||
"kernel" : set_kernel,
|
"kernel" : set_kernel,
|
||||||
"template" : set_template,
|
"template" : set_template,
|
||||||
"vcpus" : set_vcpus,
|
"vcpus" : set_vcpus,
|
||||||
|
"kernelopts": set_kernelopts,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user