vm: change kernel=None to kernel=''

vm.kernel property have type 'str'. Putting None there makes a lot of
troubles: it gets encoded as 'None' in qubes.xml and then loaded back as
'None' string, not None value. Also it isn't possible to assign None
value to str property throgh Admin API.

kernel='' is equally good to specify "no kernel from dom0".

QubesOS/qubes-issues#2622
This commit is contained in:
Marek Marczykowski-Górecki 2017-06-02 15:43:43 +02:00
parent d5cd58df51
commit 4c4f903fe3
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 8 additions and 8 deletions

View File

@ -52,28 +52,28 @@ class LinuxModules(Volume):
@property
def kernels_dir(self):
kernel_version = self.vid
if kernel_version is None:
if not kernel_version:
return None
return os.path.join(self.target_dir, kernel_version)
@property
def path(self):
kernels_dir = self.kernels_dir
if kernels_dir is None:
if not kernels_dir:
return None
return os.path.join(kernels_dir, 'modules.img')
@property
def vmlinuz(self):
kernels_dir = self.kernels_dir
if kernels_dir is None:
if not kernels_dir:
return None
return os.path.join(kernels_dir, 'vmlinuz')
@property
def initramfs(self):
kernels_dir = self.kernels_dir
if kernels_dir is None:
if not kernels_dir:
return None
return os.path.join(kernels_dir, 'initramfs')
@ -82,7 +82,7 @@ class LinuxModules(Volume):
return {}
def block_device(self):
if self.vid is not None:
if self.vid:
return super().block_device()
@ -154,7 +154,7 @@ class LinuxKernel(Pool):
pass
def verify(self, volume):
if volume.vid is not None:
if volume.vid:
_check_path(volume.path)
_check_path(volume.vmlinuz)
_check_path(volume.initramfs)

View File

@ -97,8 +97,8 @@ def _setter_name(self, prop, value):
def _setter_kernel(self, prop, value):
''' Helper for setting the domain kernel and running sanity checks on it.
''' # pylint: disable=unused-argument
if value is None:
return value
if value is None or value == '':
return ''
value = str(value)
if '/' in value:
raise qubes.exc.QubesPropertyValueError(self, prop, value,