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

Partial fix for https://github.com/QubesOS/qubes-issues/issues/6587 #559

Merged
merged 3 commits into from
Oct 11, 2023

Conversation

marmarek
Copy link
Member

@marmarek marmarek commented Oct 9, 2023

This is forward ported version of #407

Original description by @v6ak :

Partial fix for QubesOS/qubes-issues#6587

  • Persistently assigned block devices no longer reorder. (This does not matter much on its own, as their order in qubes.xml is mostly irelevant, but it is much easier to test, as I can increase the reproduction rate to nearly 100 % by assigning plenty of block devices.)
  • PCI devices seem to reorder less frequently. I'd like to investigate this deeper, but this is all I know ATM.
  • They are rather conservative – I haven't touched the original method assignments, but rather copied and created a new one. It doesn't seem to be hard to change other occurrences, but I am not sure about testing.
  • Tests: works on my machine. I see, it deserves to be better, but I am not sure how to do it properly.
  • I believe I have simplified the for cycle of DeviceCollection.assignments_list a bit. If the evolution is not clear, there is some intermediate step: https://gist.github.com/v6ak/23c6b5f84238e314a8a751c8ac6de48d

@codecov
Copy link

codecov bot commented Oct 10, 2023

Codecov Report

Merging #559 (7b8e09b) into main (c965d85) will increase coverage by 0.00%.
The diff coverage is 90.00%.

@@           Coverage Diff           @@
##             main     #559   +/-   ##
=======================================
  Coverage   67.14%   67.14%           
=======================================
  Files          55       55           
  Lines       11131    11128    -3     
=======================================
- Hits         7474     7472    -2     
+ Misses       3657     3656    -1     
Flag Coverage Δ
unittests 67.14% <90.00%> (+<0.01%) ⬆️

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

Files Coverage Δ
qubes/devices.py 92.09% <90.00%> (+0.42%) ⬆️

qubes/devices.py Outdated
Comment on lines 436 to 434
self._dict = {}
self._dict = OrderedDict()
Copy link
Contributor

Choose a reason for hiding this comment

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

Regular dicts are already ordered these days:

"Changed in version 3.7: Dictionary order is guaranteed to be insertion order. This behavior was an implementation detail of CPython from 3.6."

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is OK to exclude this change. I've found three reasons to use OrderedDict even in modern Python versions:

  1. You need some extra method provided by OrderedDict that is missing in dict. It doesn't apply to this PR.
  2. Equality (===). It doesn't apply to this PR.
  3. Documentation. By using OrderedDict, you make it explicit that you care about the order. I neither strongly support nor strongly oppose this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I dropped OrderedDict then. And also squashed the two commits, so it's easier to follow the history (no more splitting+merging again the function)

@qubesos-bot
Copy link

qubesos-bot commented Oct 10, 2023

OpenQA test summary

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

New failures, excluding unstable

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

  • system_tests_basic_vm_qrexec_gui

    • TC_20_AudioVM_Pulse_fedora-38-xfce: test_223_audio_play_hvm (failure)
      AssertionError: Command 'paplay --format=float32le --rate=44100 --c...

    • TC_20_NonAudio_whonix-workstation-17: test_130_qrexec_filemove_disk_full (error)
      subprocess.CalledProcessError: Command 'qubes.WaitForSession' retur...

  • system_tests_pvgrub_salt_storage

    • TC_41_HVMGrub_fedora-38-xfce: test_010_template_based_vm (error)
      qubes.exc.QubesVMError: Cannot connect to qrexec agent for 120 seco...
  • system_tests_splitgpg

  • system_tests_usbproxy

  • system_tests_qrexec

  • system_tests_devices

    • TC_00_List_debian-12-xfce: test_001_list_loop_mounted (failure)
      AssertionError: Device test-inst-vm:loop0 (/tmp/test.img) should no...
  • system_tests_vm_qrexec_gui_pipewire

    • pipewire_install: Failed (test died)
      # Test died: command '(set -o pipefail; qubesctl --skip-dom0 --max-...
  • system_tests_basic_vm_qrexec_gui_btrfs

    • TC_20_AudioVM_Pulse_fedora-38-xfce-pool: test_223_audio_play_hvm (failure)
      AssertionError: Command 'paplay --format=float32le --rate=44100 --c...
  • system_tests_basic_vm_qrexec_gui_xfs

    • TC_20_AudioVM_Pulse_fedora-38-xfce-pool: test_223_audio_play_hvm (failure)
      AssertionError: Command 'paplay --format=float32le --rate=44100 --c...
  • system_tests_basic_vm_qrexec_gui@hw1

    • TC_20_AudioVM_Pulse_fedora-38-xfce: test_223_audio_play_hvm (failure)
      AssertionError: Command 'paplay --format=float32le --rate=44100 --c...
  • system_tests_basic_vm_qrexec_gui_ext4

    • TC_20_AudioVM_Pulse_fedora-38-xfce-pool: test_223_audio_play_hvm (failure)
      AssertionError: Command 'paplay --format=float32le --rate=44100 --c...
  • system_tests_dispvm

    • TC_20_DispVM_debian-12-xfce: test_030_edit_file (failure + cleanup)
      AssertionError: Timeout while waiting for disp[0-9]* window to show

    • TC_20_DispVM_debian-12-xfce: test_100_open_in_dispvm (failure + cleanup)
      AssertionError: Timeout while waiting for disp[0-9]* window to show

    • TC_20_DispVM_fedora-38-xfce: test_010_simple_dvm_run (failure)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^... AssertionError

  • system_tests_gui_tools@hw1

    • qubesmanager_templatemanager: unnamed test (unknown)
    • qubesmanager_templatemanager: Failed (test died)
      # Test died: no candidate needle with tag(s) 'template-change-vm-te...
  • system_tests_gui_interactive@hw1

    • simple_gui_apps: unnamed test (unknown)

    • simple_gui_apps: Failed (test died)
      # Test died: no candidate needle with tag(s) 'menu-vm-work' matched...

    • simple_gui_apps: unnamed test (unknown)

Failed tests

35 failures
  • system_tests_basic_vm_qrexec_gui

    • TC_20_AudioVM_Pulse_fedora-38-xfce: test_223_audio_play_hvm (failure)
      AssertionError: Command 'paplay --format=float32le --rate=44100 --c...

    • TC_20_NonAudio_whonix-workstation-17: test_130_qrexec_filemove_disk_full (error)
      subprocess.CalledProcessError: Command 'qubes.WaitForSession' retur...

  • system_tests_pvgrub_salt_storage

    • [unstable] TC_41_HVMGrub_fedora-38-xfce: test_000_standalone_vm (error)
      qubes.exc.QubesVMError: Cannot connect to qrexec agent for 120 seco...

    • TC_41_HVMGrub_fedora-38-xfce: test_010_template_based_vm (error)
      qubes.exc.QubesVMError: Cannot connect to qrexec agent for 120 seco...

  • system_tests_splitgpg

  • system_tests_usbproxy

  • system_tests_qrexec

  • system_tests_network_ipv6

    • [unstable] VmIPv6Networking_fedora-38-xfce: test_540_ipv6_inter_vm (error)
      qubes.exc.QubesVMError: Cannot connect to qrexec agent for 120 seco...
  • system_tests_devices

    • TC_00_List_debian-12-xfce: test_001_list_loop_mounted (failure)
      AssertionError: Device test-inst-vm:loop0 (/tmp/test.img) should no...
  • system_tests_vm_qrexec_gui_pipewire

    • pipewire_install: Failed (test died)
      # Test died: command '(set -o pipefail; qubesctl --skip-dom0 --max-...
  • system_tests_basic_vm_qrexec_gui_btrfs

    • TC_20_AudioVM_Pulse_fedora-38-xfce-pool: test_223_audio_play_hvm (failure)
      AssertionError: Command 'paplay --format=float32le --rate=44100 --c...
  • system_tests_basic_vm_qrexec_gui_xfs

    • TC_20_AudioVM_Pulse_fedora-38-xfce-pool: test_223_audio_play_hvm (failure)
      AssertionError: Command 'paplay --format=float32le --rate=44100 --c...

    • [unstable] TC_20_AudioVM_PipeWire_debian-12-xfce-pool: test_226_audio_playback_pipewire (failure)
      AssertionError: Command 'pw-play --format=f32 --rate=44100 --channe...

  • system_tests_basic_vm_qrexec_gui@hw1

    • TC_20_AudioVM_Pulse_fedora-38-xfce: test_223_audio_play_hvm (failure)
      AssertionError: Command 'paplay --format=float32le --rate=44100 --c...
  • system_tests_basic_vm_qrexec_gui_ext4

    • TC_20_AudioVM_Pulse_fedora-38-xfce-pool: test_223_audio_play_hvm (failure)
      AssertionError: Command 'paplay --format=float32le --rate=44100 --c...
  • system_tests_dispvm

    • TC_20_DispVM_debian-12-xfce: test_030_edit_file (failure + cleanup)
      AssertionError: Timeout while waiting for disp[0-9]* window to show

    • TC_20_DispVM_debian-12-xfce: test_100_open_in_dispvm (failure + cleanup)
      AssertionError: Timeout while waiting for disp[0-9]* window to show

    • TC_20_DispVM_fedora-38-xfce: test_010_simple_dvm_run (failure)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^... AssertionError

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

    • [unstable] 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_gui_tools@hw1

    • qubesmanager_templatemanager: unnamed test (unknown)
    • qubesmanager_templatemanager: Failed (test died)
      # Test died: no candidate needle with tag(s) 'template-change-vm-te...
  • system_tests_gui_interactive@hw1

    • simple_gui_apps: unnamed test (unknown)

    • simple_gui_apps: Failed (test died)
      # Test died: no candidate needle with tag(s) 'menu-vm-work' matched...

    • simple_gui_apps: unnamed test (unknown)

Fixed failures

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

23 fixed
  • system_tests_network

  • system_tests_splitgpg

  • system_tests_manager

    • VMSettingsTest: test_26_default_dispvm (failure)
      self.assertTrue(self.vm.property_... AssertionError: False is not true
  • system_tests_qrexec

  • system_tests_network_ipv6

    • VmIPv6Networking_fedora-38: test_040_inter_vm (error)
      qubes.exc.QubesMemoryError: Not enough memory to start domain 'test...

    • VmIPv6Networking_fedora-38: test_203_fake_ip_inter_vm_allow (error)
      qubes.exc.QubesMemoryError: Not enough memory to start domain 'test...

  • system_tests_dispvm

  • system_tests_whonix

  • system_tests_guivm_gui_interactive

    • update_templates: Failed (test died)
      # Test died: command 'curl --form upload=@template-fedora-38-xfce-v...

Unstable tests

  • system_tests_suspend

    suspend/Failed (1/5 times with errors)
    • job 83088 # Test died: command 'true' timed out at /usr/lib/os-autoinst/autot...
    suspend/wait_serial (1/5 times with errors)
    • job 83088 # wait_serial expected: qr/p5~T5-\d+-/...
  • system_tests_basic_vm_qrexec_gui

    TC_00_Basic/test_120_start_standalone_with_cdrom_dom0 (1/5 times with errors)
    • job 80971 AssertionError: 1 != 0 : b'Timeout waiting for dom0:loop4 device to...
    TC_20_AudioVM_Pulse_debian-12-xfce/test_222_audio_rec_unmuted_pulseaudio (1/5 times with errors)
    • job 82899 qubes.exc.QubesVMError: Failed to attach audio input from dom0 to t...
    TC_20_AudioVM_Pulse_fedora-38-xfce/test_222_audio_rec_unmuted_pulseaudio (1/5 times with errors)
    • job 82367 AssertionError: frequency 3366.354981298878 not in specified range,...
    TC_20_NonAudio_whonix-gateway-17/test_300_bug_1028_gui_memory_pinning (1/5 times with errors)
    • job 82367 AssertionError: Dom0 window doesn't match VM window content, saved ...
  • system_tests_pvgrub_salt_storage

    TC_41_HVMGrub_fedora-38-xfce/test_000_standalone_vm (3/5 times with errors)
    • job 81879 qubes.exc.QubesVMError: Cannot connect to qrexec agent for 120 seco...
    • job 82004 qubes.exc.QubesVMError: Cannot connect to qrexec agent for 120 seco...
    • job 82379 qubes.exc.QubesVMError: Cannot connect to qrexec agent for 120 seco...
  • system_tests_usbproxy

    TC_20_USBProxy_core3_whonix-workstation-17/test_070_attach_not_installed_front (1/5 times with errors)
    • job 81882 qubesusbproxy.core3ext.QubesUSBException: Device attach failed: 202...
  • system_tests_network_ipv6

    VmIPv6Networking_debian-12-xfce/test_113_reattach_after_provider_kill (1/5 times with errors)
    • job 82377 raise exceptions.TimeoutError() from exc... TimeoutError
    VmIPv6Networking_fedora-38-xfce/test_540_ipv6_inter_vm (1/5 times with errors)
    • job 80991 qubes.exc.QubesVMError: Cannot connect to qrexec agent for 120 seco...
  • system_tests_network_updates

    TC_00_Dom0Upgrade_debian-12-xfce/test_001_update_check (1/3 times with errors)
    • job 82378 self.assertFalse(self.app.domains[... AssertionError: '1' is not false
    TC_00_Dom0Upgrade_fedora-38-xfce/test_001_update_check (1/3 times with errors)
    • job 82378 self.assertFalse(self.app.domains[... AssertionError: '1' is not false
  • system_tests_basic_vm_qrexec_gui_btrfs

    TC_20_AudioVM_Pulse_debian-12-xfce-pool/test_220_audio_play_pulseaudio (1/5 times with errors)
    • job 81808 AssertionError: Command 'paplay --format=float32le --rate=44100 --c...
    TC_20_AudioVM_PipeWire_debian-12-xfce-pool/test_226_audio_playback_pipewire (1/5 times with errors)
    • job 81995 AssertionError: Command 'pw-play --format=f32 --rate=44100 --channe...
  • system_tests_basic_vm_qrexec_gui_xfs

    TC_20_AudioVM_Pulse_debian-12-xfce-pool/test_221_audio_rec_muted_pulseaudio (1/5 times with errors)
    • job 82370 AssertionError: source-output for VM test-inst-vm1 not found
    TC_20_AudioVM_PipeWire_debian-12-xfce-pool/test_226_audio_playback_pipewire (2/5 times with errors)
    • job 82370 AssertionError: Command 'pw-play --format=f32 --rate=44100 --channe...
    • job 82902 AssertionError: Command 'pw-play --format=f32 --rate=44100 --channe...
    TC_20_NonAudio_whonix-gateway-17-pool/test_300_bug_1028_gui_memory_pinning (1/5 times with errors)
    • job 81871 AssertionError: Dom0 window doesn't match VM window content, saved ...
  • system_tests_basic_vm_qrexec_gui@hw1

    TC_00_Basic/test_120_start_standalone_with_cdrom_dom0 (1/5 times with errors)
    • job 80971 AssertionError: 1 != 0 : b'Timeout waiting for dom0:loop4 device to...
    TC_20_AudioVM_Pulse_debian-12-xfce/test_222_audio_rec_unmuted_pulseaudio (1/5 times with errors)
    • job 82899 qubes.exc.QubesVMError: Failed to attach audio input from dom0 to t...
    TC_20_AudioVM_Pulse_fedora-38-xfce/test_222_audio_rec_unmuted_pulseaudio (1/5 times with errors)
    • job 82367 AssertionError: frequency 3366.354981298878 not in specified range,...
    TC_20_NonAudio_whonix-gateway-17/test_300_bug_1028_gui_memory_pinning (1/5 times with errors)
    • job 82367 AssertionError: Dom0 window doesn't match VM window content, saved ...
  • system_tests_basic_vm_qrexec_gui_zfs

    TC_00_Basic/test_120_start_standalone_with_cdrom_dom0 (2/5 times with errors)
    • job 81872 AssertionError: 1 != 0 : b'Timeout waiting for dom0:loop4 device to...
    • job 82357 AssertionError: 1 != 0 : b'Timeout waiting for dom0:loop4 device to...
    TC_00_Basic/test_200_shutdown_event_race (1/5 times with errors)
    • job 82357 AssertionError: libvirt event impl drain timeout
    TC_00_Basic/test_202_udev_block_exclude_default (1/5 times with errors)
    • job 81872 raise exceptions.TimeoutError() from exc... TimeoutError
    TC_20_AudioVM_Pulse_debian-12-xfce-pool/test_222_audio_rec_unmuted_pulseaudio (1/5 times with errors)
    • job 81872 AssertionError: frequency 3379.6121459556007 not in specified range...
    TC_20_AudioVM_PipeWire_debian-12-xfce-pool/test_227_audio_rec_muted_pipewire (1/5 times with errors)
    • job 82889 subprocess.CalledProcessError: Command 'pkill pw-record' returned n...
  • system_tests_basic_vm_qrexec_gui_ext4

    TC_30_Gui_daemon/test_000_clipboard (1/5 times with errors)
    • job 80996 qubes.exc.QubesVMError: Cannot connect to qrexec agent for 120 seco...
    TC_00_Basic/test_120_start_standalone_with_cdrom_dom0 (1/5 times with errors)
    • job 81994 AssertionError: 1 != 0 : b'Timeout waiting for dom0:loop12 device t...
    TC_20_NonAudio_whonix-workstation-17-pool/test_130_qrexec_filemove_disk_full (1/5 times with errors)
    • job 82901 raise exceptions.TimeoutError() from exc... TimeoutError
    TC_20_AudioVM_Pulse_fedora-38-xfce-pool/test_222_audio_rec_unmuted_pulseaudio (1/5 times with errors)
    • job 82369 AssertionError: frequency 3252.494577006508 not in specified range,...
    TC_20_AudioVM_PipeWire_debian-12-xfce-pool/test_226_audio_playback_pipewire (1/5 times with errors)
    • job 81870 AssertionError: Command 'pw-play --format=f32 --rate=44100 --channe...
  • system_tests_dispvm

    TC_20_DispVM_whonix-gateway-17/test_010_simple_dvm_run (1/5 times with errors)
    TC_20_DispVM_whonix-workstation-17/test_010_simple_dvm_run (1/5 times with errors)
    • job 81874 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^... AssertionError
    TC_20_DispVM_whonix-gateway-17/test_020_gui_app (1/5 times with errors)
    TC_20_DispVM_fedora-38-xfce/test_030_edit_file (2/5 times with errors)
    • job 81874 AssertionError: Timeout while waiting for disp[0-9]* window to show
    • job 82011 AssertionError: Timeout while waiting for disp[0-9]* window to show
    TC_20_DispVM_whonix-gateway-17/test_030_edit_file (1/5 times with errors)
    TC_20_DispVM_whonix-workstation-17/test_030_edit_file (2/5 times with errors)
    • job 81874 AssertionError: Timeout while waiting for disp[0-9]* window to show
    • job 82011 AssertionError: Timeout while waiting for disp[0-9]* window to show
    TC_20_DispVM_fedora-38-xfce/test_100_open_in_dispvm (1/5 times with errors)
    • job 81874 AssertionError: Timeout while waiting for disp[0-9]* window to show
    TC_20_DispVM_whonix-gateway-17/test_100_open_in_dispvm (1/5 times with errors)
    TC_20_DispVM_whonix-workstation-17/test_100_open_in_dispvm (2/5 times with errors)
    • job 81874 AssertionError: Timeout while waiting for disp[0-9]* window to show
    • job 82011 AssertionError: Timeout while waiting for disp[0-9]* window to show
  • system_tests_whonix

    whonix_torbrowser/ (1/5 times with errors)
    whonix_torbrowser/ (1/5 times with errors)
    whonix_torbrowser/Failed (1/5 times with errors)
    • job 82385 # Test died: no candidate needle with tag(s) 'anon-whonix-tor-brows...
  • system_tests_whonix@hw1

    whonix_torbrowser/ (1/5 times with errors)
    whonix_torbrowser/ (1/5 times with errors)
    whonix_torbrowser/Failed (1/5 times with errors)
    • job 82385 # Test died: no candidate needle with tag(s) 'anon-whonix-tor-brows...
  • system_tests_suspend@hw1

    suspend/Failed (1/5 times with errors)
    • job 83088 # Test died: command 'true' timed out at /usr/lib/os-autoinst/autot...
    suspend/wait_serial (1/5 times with errors)
    • job 83088 # wait_serial expected: qr/p5~T5-\d+-/...

@marmarek marmarek merged commit 64a0da7 into QubesOS:main Oct 11, 2023
4 checks passed
@@ -351,24 +353,19 @@ def assignments(self, persistent=None):
self._bus))
if persistent is True:
# don't break app.save()
return self._set
return list(self._set)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could these be sorted?

Copy link
Contributor

Choose a reason for hiding this comment

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

I know the line looks a bit silly, because it looks like we are converting a set (i.e., randomly sorted collection) to a list. However, self._set is a PersistentCollection, which is backed by dict. So, IIUC, PersistentCollection keeps the order of the items.

Yeah, we could rename self._set to some more descriptive. But it is a set (it cannot contain any item twice), just not an ordinary Python set.

DeviceAssignment(
backend_domain=dev.backend_domain,
ident=dev.ident, options=options,
bus=self._bus))
return result
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be sorted(result)?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. Otherwise adding new device could move another one attached earlier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants