Skip to content

Commit

Permalink
vm: change kernel=None to kernel=''
Browse files Browse the repository at this point in the history
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
  • Loading branch information
marmarek committed Jun 5, 2017
1 parent d5cd58d commit 4c4f903
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions qubes/storage/kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,28 @@ def vid(self, value):
@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')

Expand All @@ -82,7 +82,7 @@ def revisions(self):
return {}

def block_device(self):
if self.vid is not None:
if self.vid:
return super().block_device()


Expand Down Expand Up @@ -154,7 +154,7 @@ def stop(self, volume):
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)
Expand Down
4 changes: 2 additions & 2 deletions qubes/vm/qubesvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4c4f903

Please sign in to comment.