Skip to content

Commit

Permalink
Improve checking for memory hotplug support
Browse files Browse the repository at this point in the history
1. Fix handling HVM to match the intention described in the comment.
2. Fix distinguishing dom0-provided and vm-provided kernels - the actual
   "kernel" property value depends on the virt_mode

QubesOS/qubes-issues#7956
  • Loading branch information
marmarek committed Apr 20, 2024
1 parent ec10371 commit 8121cb0
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions qubes/vm/qubesvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,17 @@ def is_memory_balancing_possible(self):
return False
return True

def is_kernel_from_vm(self):
"""Does the kernel is really a bootloader loading the kernel
from within the VM?"""
if self.virt_mode == 'hvm':
return self.kernel is None
if self.virt_mode == 'pvh':
return self.kernel == 'pvgrub2-pvh'
if self.virt_mode == 'pv':
return self.kernel == 'pvgrub2'
assert False

@property
def use_memory_hotplug(self):
"""Use memory hotplug for memory balancing.
Expand All @@ -1655,9 +1666,11 @@ def use_memory_hotplug(self):
# if not explicitly set, check if support is advertised
# for dom0-provided kernel - check there
# Do not enable automatically for HVM, as qemu isn't happy about that -
# emulated devices wont work (DMA issues?); but still allow enabling
# manually in that case.
if self.kernel and self.virt_mode != 'hvm':
# emulated devices won't work (DMA issues?); but still allow enabling
# manually in that case (with the feature above).
if self.virt_mode == 'hvm':
return False
if not self.is_kernel_from_vm():
return (pathlib.Path(self.storage.kernels_dir) /
'memory-hotplug-supported').exists()
# otherwise - check advertised VM's features
Expand Down

0 comments on commit 8121cb0

Please sign in to comment.