Skip to content

Conversation

@ben-grande
Copy link
Contributor

@ben-grande ben-grande commented Jul 4, 2025

Plan:

  • pylint
  • remove code comments according to guidelines
  • renaming variables to have an explanatory name according to guidelines
  • annotate types
  • document the functions
  • maybe add tests to make codecov happy

@codecov
Copy link

codecov bot commented Jul 4, 2025

Codecov Report

Attention: Patch coverage is 38.43537% with 181 lines in your changes missing coverage. Please review.

Project coverage is 70.82%. Comparing base (9952998) to head (d03bc0b).
Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
qubes/qmemman/systemstate.py 0.00% 122 Missing ⚠️
qubes/tools/qmemmand.py 0.00% 43 Missing ⚠️
qubes/qmemman/algo.py 91.26% 9 Missing ⚠️
qubes/qmemman/client.py 50.00% 4 Missing ⚠️
qubes/vm/qubesvm.py 40.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #694      +/-   ##
==========================================
- Coverage   70.89%   70.82%   -0.08%     
==========================================
  Files          61       61              
  Lines       13463    13473      +10     
==========================================
- Hits         9545     9542       -3     
- Misses       3918     3931      +13     
Flag Coverage Δ
unittests 70.82% <38.43%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@qubesos-bot
Copy link

qubesos-bot commented Jul 9, 2025

OpenQA test summary

Complete test suite and dependencies: https://openqa.qubes-os.org/tests/overview?distri=qubesos&version=4.3&build=2025071903-4.3&flavor=pull-requests

Test run included the following:

New failures, excluding unstable

Compared to: https://openqa.qubes-os.org/tests/overview?distri=qubesos&version=4.3&build=2025061004-4.3&flavor=update

  • system_tests_pvgrub_salt_storage

  • system_tests_dispvm

    • TC_20_DispVM_whonix-workstation-17: test_030_edit_file (failure + cleanup)
      AssertionError: Timeout while waiting for disp[0-9]* window to show

    • TC_20_DispVM_whonix-workstation-17: test_100_open_in_dispvm (failure + cleanup)
      AssertionError: Timeout while waiting for disp[0-9]* window to show

  • system_tests_devices

    • TC_00_List_whonix-gateway-17: test_011_list_dm_mounted (failure)
      AssertionError: 'test-dm' == 'test-dm' : Device test-inst-vm:dm-0::...
  • system_tests_audio@hw1

  • system_tests_qwt_win10_seamless@hw13

    • windows_install: Failed (test died)
      # Test died: command 'script -e -c 'bash -x /usr/bin/qvm-create-win...
  • system_tests_qwt_win11@hw13

    • windows_install: Failed (test died)
      # Test died: command 'script -e -c 'bash -x /usr/bin/qvm-create-win...

Failed tests

10 failures
  • system_tests_pvgrub_salt_storage

  • system_tests_extra

    • TC_00_QVCTest_whonix-workstation-17: test_010_screenshare (failure)
      AssertionError: 1 != 0 : Timeout waiting for /dev/video0 in test-in...
  • system_tests_dispvm

    • TC_20_DispVM_whonix-workstation-17: test_030_edit_file (failure + cleanup)
      AssertionError: Timeout while waiting for disp[0-9]* window to show

    • TC_20_DispVM_whonix-workstation-17: test_100_open_in_dispvm (failure + cleanup)
      AssertionError: Timeout while waiting for disp[0-9]* window to show

  • system_tests_devices

    • TC_00_List_whonix-gateway-17: test_011_list_dm_mounted (failure)
      AssertionError: 'test-dm' == 'test-dm' : Device test-inst-vm:dm-0::...
  • system_tests_kde_gui_interactive

    • gui_keyboard_layout: wait_serial (wait serial expected)
      # wait_serial expected: "echo -e '[Layout]\nLayoutList=us,de' | sud...

    • gui_keyboard_layout: Failed (test died)
      # Test died: command 'test "$(cd ~user;ls e1*)" = "$(qvm-run -p wor...

  • system_tests_audio@hw1

  • system_tests_qwt_win10_seamless@hw13

    • windows_install: Failed (test died)
      # Test died: command 'script -e -c 'bash -x /usr/bin/qvm-create-win...
  • system_tests_qwt_win11@hw13

    • windows_install: Failed (test died)
      # Test died: command 'script -e -c 'bash -x /usr/bin/qvm-create-win...

Fixed failures

Compared to: https://openqa.qubes-os.org/tests/142375#dependencies

10 fixed

Unstable tests

Performance Tests

Performance degradation:

9 performance degradations
  • debian-12-xfce_exec-data-simplex: 72.42 🔺 ( previous job: 65.51, degradation: 110.54%)
  • debian-12-xfce_exec-data-duplex-root: 82.28 🔺 ( previous job: 70.01, degradation: 117.53%)
  • whonix-gateway-17_exec-root: 43.81 🔺 ( previous job: 39.57, degradation: 110.71%)
  • whonix-gateway-17_socket: 9.83 🔺 ( previous job: 7.85, degradation: 125.16%)
  • whonix-gateway-17_socket-root: 8.70 🔺 ( previous job: 7.89, degradation: 110.24%)
  • whonix-gateway-17_exec-data-duplex-root: 101.47 🔺 ( previous job: 90.74, degradation: 111.83%)
  • dom0_root_seq1m_q8t1_read 3:read_bandwidth_kb: 253646.00 :small_red_triangle: ( previous job: 289982.00, degradation: 87.47%)
  • dom0_root_rnd4k_q32t1_read 3:read_bandwidth_kb: 14119.00 :small_red_triangle: ( previous job: 17102.00, degradation: 82.56%)
  • dom0_varlibqubes_seq1m_q8t1_write 3:write_bandwidth_kb: 105280.00 :small_red_triangle: ( previous job: 122848.00, degradation: 85.70%)

Remaining performance tests:

63 tests
  • debian-12-xfce_exec: 7.29 🟢 ( previous job: 8.63, improvement: 84.48%)
  • debian-12-xfce_exec-root: 29.21 🟢 ( previous job: 29.44, improvement: 99.24%)
  • debian-12-xfce_socket: 8.96 🔺 ( previous job: 8.50, degradation: 105.43%)
  • debian-12-xfce_socket-root: 8.56 🔺 ( previous job: 8.31, degradation: 102.94%)
  • debian-12-xfce_exec-data-duplex: 67.72 🟢 ( previous job: 73.55, improvement: 92.08%)
  • debian-12-xfce_socket-data-duplex: 160.98 🟢 ( previous job: 161.35, improvement: 99.77%)
  • fedora-42-xfce_exec: 9.10
  • fedora-42-xfce_exec-root: 58.04
  • fedora-42-xfce_socket: 8.05
  • fedora-42-xfce_socket-root: 8.53
  • fedora-42-xfce_exec-data-simplex: 69.44
  • fedora-42-xfce_exec-data-duplex: 71.77
  • fedora-42-xfce_exec-data-duplex-root: 98.53
  • fedora-42-xfce_socket-data-duplex: 156.15
  • whonix-gateway-17_exec: 6.91 🟢 ( previous job: 7.34, improvement: 94.14%)
  • whonix-gateway-17_exec-data-simplex: 78.89 🔺 ( previous job: 77.76, degradation: 101.45%)
  • whonix-gateway-17_exec-data-duplex: 82.13 🔺 ( previous job: 78.39, degradation: 104.78%)
  • whonix-gateway-17_socket-data-duplex: 169.74 🔺 ( previous job: 161.95, degradation: 104.81%)
  • whonix-workstation-17_exec: 7.73 🟢 ( previous job: 8.27, improvement: 93.38%)
  • whonix-workstation-17_exec-root: 58.83 🔺 ( previous job: 57.61, degradation: 102.11%)
  • whonix-workstation-17_socket: 8.78 🟢 ( previous job: 8.97, improvement: 97.90%)
  • whonix-workstation-17_socket-root: 10.34 🔺 ( previous job: 9.46, degradation: 109.33%)
  • whonix-workstation-17_exec-data-simplex: 62.25 🟢 ( previous job: 74.54, improvement: 83.51%)
  • whonix-workstation-17_exec-data-duplex: 81.62 🔺 ( previous job: 74.84, degradation: 109.07%)
  • whonix-workstation-17_exec-data-duplex-root: 86.93 🔺 ( previous job: 86.00, degradation: 101.08%)
  • whonix-workstation-17_socket-data-duplex: 169.35 🔺 ( previous job: 160.20, degradation: 105.71%)
  • dom0_root_seq1m_q8t1_write 3:write_bandwidth_kb: 135279.00 :green_circle: ( previous job: 101988.00, improvement: 132.64%)
  • dom0_root_seq1m_q1t1_read 3:read_bandwidth_kb: 56932.00 :green_circle: ( previous job: 14284.00, improvement: 398.57%)
  • dom0_root_seq1m_q1t1_write 3:write_bandwidth_kb: 38763.00 :green_circle: ( previous job: 32696.00, improvement: 118.56%)
  • dom0_root_rnd4k_q32t1_write 3:write_bandwidth_kb: 1354.00 :green_circle: ( previous job: 1091.00, improvement: 124.11%)
  • dom0_root_rnd4k_q1t1_read 3:read_bandwidth_kb: 11835.00 :green_circle: ( previous job: 11086.00, improvement: 106.76%)
  • dom0_root_rnd4k_q1t1_write 3:write_bandwidth_kb: 4559.00 :green_circle: ( previous job: 1840.00, improvement: 247.77%)
  • dom0_varlibqubes_seq1m_q8t1_read 3:read_bandwidth_kb: 500991.00 :green_circle: ( previous job: 289182.00, improvement: 173.24%)
  • dom0_varlibqubes_seq1m_q1t1_read 3:read_bandwidth_kb: 439286.00 :green_circle: ( previous job: 433654.00, improvement: 101.30%)
  • dom0_varlibqubes_seq1m_q1t1_write 3:write_bandwidth_kb: 157711.00 :small_red_triangle: ( previous job: 167872.00, degradation: 93.95%)
  • dom0_varlibqubes_rnd4k_q32t1_read 3:read_bandwidth_kb: 103257.00 :small_red_triangle: ( previous job: 108760.00, degradation: 94.94%)
  • dom0_varlibqubes_rnd4k_q32t1_write 3:write_bandwidth_kb: 9261.00 :green_circle: ( previous job: 8874.00, improvement: 104.36%)
  • dom0_varlibqubes_rnd4k_q1t1_read 3:read_bandwidth_kb: 7920.00 :green_circle: ( previous job: 6356.00, improvement: 124.61%)
  • dom0_varlibqubes_rnd4k_q1t1_write 3:write_bandwidth_kb: 4954.00 :green_circle: ( previous job: 4420.00, improvement: 112.08%)
  • fedora-42-xfce_root_seq1m_q8t1_read 3:read_bandwidth_kb: 387786.00
  • fedora-42-xfce_root_seq1m_q8t1_write 3:write_bandwidth_kb: 274280.00
  • fedora-42-xfce_root_seq1m_q1t1_read 3:read_bandwidth_kb: 308223.00
  • fedora-42-xfce_root_seq1m_q1t1_write 3:write_bandwidth_kb: 139265.00
  • fedora-42-xfce_root_rnd4k_q32t1_read 3:read_bandwidth_kb: 83540.00
  • fedora-42-xfce_root_rnd4k_q32t1_write 3:write_bandwidth_kb: 5449.00
  • fedora-42-xfce_root_rnd4k_q1t1_read 3:read_bandwidth_kb: 8108.00
  • fedora-42-xfce_root_rnd4k_q1t1_write 3:write_bandwidth_kb: 2626.00
  • fedora-42-xfce_private_seq1m_q8t1_read 3:read_bandwidth_kb: 334154.00
  • fedora-42-xfce_private_seq1m_q8t1_write 3:write_bandwidth_kb: 225791.00
  • fedora-42-xfce_private_seq1m_q1t1_read 3:read_bandwidth_kb: 281044.00
  • fedora-42-xfce_private_seq1m_q1t1_write 3:write_bandwidth_kb: 125146.00
  • fedora-42-xfce_private_rnd4k_q32t1_read 3:read_bandwidth_kb: 36961.00
  • fedora-42-xfce_private_rnd4k_q32t1_write 3:write_bandwidth_kb: 2612.00
  • fedora-42-xfce_private_rnd4k_q1t1_read 3:read_bandwidth_kb: 8504.00
  • fedora-42-xfce_private_rnd4k_q1t1_write 3:write_bandwidth_kb: 1051.00
  • fedora-42-xfce_volatile_seq1m_q8t1_read 3:read_bandwidth_kb: 346293.00
  • fedora-42-xfce_volatile_seq1m_q8t1_write 3:write_bandwidth_kb: 208754.00
  • fedora-42-xfce_volatile_seq1m_q1t1_read 3:read_bandwidth_kb: 292489.00
  • fedora-42-xfce_volatile_seq1m_q1t1_write 3:write_bandwidth_kb: 106325.00
  • fedora-42-xfce_volatile_rnd4k_q32t1_read 3:read_bandwidth_kb: 46029.00
  • fedora-42-xfce_volatile_rnd4k_q32t1_write 3:write_bandwidth_kb: 2084.00
  • fedora-42-xfce_volatile_rnd4k_q1t1_read 3:read_bandwidth_kb: 8014.00
  • fedora-42-xfce_volatile_rnd4k_q1t1_write 3:write_bandwidth_kb: 1975.00

@marmarek
Copy link
Member

marmarek commented Jul 9, 2025

openQA says "no":

Jul 09 01:48:46.091822 dom0 qmemman.daemon.reqhandler[4872]: exception while handling request: ValueError('not enough values to unpack (expected 2, got 1)')
                                                             Traceback (most recent call last):
                                                               File "/usr/lib/python3.13/site-packages/qubes/tools/qmemmand.py", line 222, in handle
                                                                 if self.data.isdigit() and system_state.do_balloon(
                                                                                            ~~~~~~~~~~~~~~~~~~~~~~~^
                                                                     int(self.data.decode("ascii"))
                                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                                                 ):
                                                                 ^
                                                               File "/usr/lib/python3.13/site-packages/qubes/qmemman/systemstate.py", line 248, in do_balloon
                                                                 for domid, dom in prev_memory_actual.keys():
                                                                     ^^^^^^^^^^
                                                             ValueError: not enough values to unpack (expected 2, got 1)
Jul 09 01:48:46.100151 dom0 qubesd[4875]: ERROR: vm.debian-12-xfce: Start failed: Not enough memory to start domain 'debian-12-xfce'

@marmarek
Copy link
Member

Jul 10 09:54:04.235106 dom0 qmemman.daemon.reqhandler[13628]: exception while handling request: AttributeError("'int' object has no attribute 'memory_actual'")
                                                              Traceback (most recent call last):
                                                                File "/usr/lib/python3.13/site-packages/qubes/tools/qmemmand.py", line 222, in handle
                                                                  if self.data.isdigit() and system_state.do_balloon(
                                                                                             ~~~~~~~~~~~~~~~~~~~~~~~^
                                                                      int(self.data.decode("ascii"))
                                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                                                  ):
                                                                  ^
                                                                File "/usr/lib/python3.13/site-packages/qubes/qmemman/systemstate.py", line 249, in do_balloon
                                                                  if prev_memory_actual[domid] == dom.memory_actual:
                                                                                                  ^^^^^^^^^^^^^^^^^
                                                              AttributeError: 'int' object has no attribute 'memory_actual'

@marmarek
Copy link
Member

This one feels like pylint/mypy should notice? Maybe adding some type hints would help?

@ben-grande
Copy link
Contributor Author

openQA says "no":

There is a chance bigger than 0 that it might say "yes" now. I updated the code on my testbench, restarted qubesd and qubes-qmemman, started some domains, shutdown others, started various domains, updated all templates. No errors so far.

Comment on lines 55 to 56
# Overhead of per-page Xen structures, taken from OpenStack
# nova/virt/xenapi/driver.py
# see https://wiki.openstack.org/wiki/XenServer/Overhead
# we divide total and free physical memory by this to get
# "assignable" memory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment belongs to MEM_OVERHEAD_FACTOR - if you move one, move the other too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the top part of the commend until see link because the rest we divide appears to be related to the code after.


def clear_outdated_error_markers(self) -> None:
# Clear outdated errors.
for _, dom in self.dom_dict.items():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't use key, the maybe iterate over values()?


for i in self.domdict.keys():
self.domdict[i].no_progress = False
for _, dom in self.dom_dict.items():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here too

# domain not responding to memset requests, remove it
# from donors
self.domdict[i].no_progress = True
dom.no_progress = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Later commit fixes it, but this one mixes prev_mem_actual iteration) with self.domdict - dom is the former here, not the latter. (and similar few lines above and below). Please adjust this commit to not introduce a bug temporarily.

Comment on lines 67 to 71
def xs_wrapper(self, key, value=None) -> Optional[str]:
if value:
self.xs.write("", key, value)
return None
return self.xs.read("", key)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't, this doesn't save much (just one empty parameter), but makes it harder to see if it's a read or write (and easier to make a mistake).
OTOH the get_xs_path helper is useful change.



def MB(val):
def in_megabyte(val):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea of this function was to be concise, the new name kinda fails at that... If you don't like a function MB, maybe define it as a constant to multiply by instead?

Comment on lines 82 to 87
def xs_wrapper(self, key, value=None):
if value:
self.handle.write("", key, value)
return None
return self.handle.read("", key)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same comment as in the other place.

- Enable pylint;
- Rename keyword 'id' or variable 'i' to 'domid', which is always xid
  but better to use a VMM agnostic name;
- Move constants to module scope;
- Pylint trips on dictionary iteration of .keys() with
  'consider-using-dict-items' and 'unnecessary-dict-index'. Fixing that
  helped find some useless assignments which were already objects of the
  dictionary;
- Assign current domain dictionary domid looping to an object for easier
  reading and modification; and
- Separate 'do_balance()' to avoid 'too-many-nested-blocks'.
@ben-grande
Copy link
Contributor Author

All issues were addressed.

@marmarek marmarek merged commit 8de76b2 into QubesOS:main Jul 20, 2025
2 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants