Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix locking in qmemman on Python 3.13 #629

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions qubes/tools/qmemmand.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,19 @@
self.watch_token_dict[i])
self.watch_token_dict.pop(i)
system_state.del_domain(i)

if not refresh_only:
try:
system_state.do_balance()
except: # pylint: disable=bare-except
self.log.exception('do_balance() failed')

Check warning on line 136 in qubes/tools/qmemmand.py

View check run for this annotation

Codecov / codecov/patch

qubes/tools/qmemmand.py#L132-L136

Added lines #L132 - L136 were not covered by tests
except: # pylint: disable=bare-except
self.log.exception('Updating domain list failed')
finally:
if got_lock:
global_lock.release()
self.log.debug('global_lock released')

if not refresh_only:
try:
system_state.do_balance()
except: # pylint: disable=bare-except
self.log.exception('do_balance() failed')


def meminfo_changed(self, domain_id):
self.log.debug('meminfo_changed(domain_id={!r})'.format(domain_id))
untrusted_meminfo_key = self.handle.read(
Expand Down
10 changes: 6 additions & 4 deletions qubes/vm/qubesvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1761,10 +1761,12 @@
try:
mem_required_with_overhead = mem_required + MEM_OVERHEAD_BASE \
+ self.vcpus * MEM_OVERHEAD_PER_VCPU
if self.use_memory_hotplug:
# extra overhead to account future hotplug memory
# 1 page per 1MB of RAM, see libxl__get_required_paging_memory()
mem_required_with_overhead += self.maxmem * 4096
maxmem = self.maxmem if self.maxmem else self.memory
if self.virt_mode != "pv":

Check warning on line 1765 in qubes/vm/qubesvm.py

View check run for this annotation

Codecov / codecov/patch

qubes/vm/qubesvm.py#L1764-L1765

Added lines #L1764 - L1765 were not covered by tests
# extra overhead to account (possibly future hotplug) memory
# 2 pages per 1MB of RAM, see
# libxl__get_required_paging_memory()
mem_required_with_overhead += maxmem * 8192

Check warning on line 1769 in qubes/vm/qubesvm.py

View check run for this annotation

Codecov / codecov/patch

qubes/vm/qubesvm.py#L1769

Added line #L1769 was not covered by tests
got_memory = qmemman_client.request_memory(
mem_required_with_overhead)

Expand Down