Commit Graph

2093 Commits

Author SHA1 Message Date
Rusty Bird
9122a14f94
tests/file: use self.loop 2020-04-07 21:04:02 +00:00
Marek Marczykowski-Górecki
3066190283
tests: fix qvm-copy-to-vm test
Make the check if remote file wasn't removed meaningful. Previously the
user didn't have permission to remote the source file, so even if the
tool would try, it would fail.
2020-04-01 17:57:12 +02:00
Marek Marczykowski-Górecki
1b7e2a5cbf
tests: ensure proper cleanup of auxiliary process
Various qrexec tests create auxiliary process (service_proc) as a local
variable. In case of test failure, process cleanup isn't called and may
lead to FD leaks and breaking subsequent tests.

Fix this by always saving such process instance in self.service_proc and
cleaning it up in self.tearDown() (this code is already there).

Add also waiting (and in case of timeout - killing) of a service call
process too.
2020-04-01 17:35:57 +02:00
Marek Marczykowski-Górecki
dd50e300c3
Fix multiple qmemman issues
First the main bug: when meminfo xenstore watch fires, in some cases
(just after starting some domain) XS_Watcher refreshes internal list of
domains before processing the event. This is done specifically to
include new domain in there. But the opposite could happen too - the
domain could be destroyed. In this case refres_meminfo() function raises
an exception, which isn't handled and interrupts the whole xenstore
watch loop. This issue is likely to be triggered by killing the domain,
as this way it could disappear shortly after writing updated meminfo
entry. In case of proper shutdown, meminfo-writer is stopped earlier and
do not write updates just before domain destroy.
Fix this by checking if the requested domain is still there just after
refreshing the list.

Then, catch exceptions in xenstore watch handling functions, to not
interrupt xenstore watch loop. If it gets interrupted, qmemman basically
stops memory balancing.

And finally, clear force_refresh_domain_list flag after refreshing the
domain list. That missing line caused domain refresh at every meminfo
change, making it use some more CPU time.

While at it, change "EOF" log message to something a bit more
meaningful.

Thanks @conorsch for capturing valuable logs.

Fixes QubesOS/qubes-issues#4890
2020-04-01 03:46:29 +02:00
Marek Marczykowski-Górecki
b11d6e058b
ext/admin: workaround for extension's __init__() called multiple times
... during tests.
qubes.ext.Extension class is a weird thing that tries to make each extension
a singleton. But this unfortunately have a side effect that __init__()
is called separately for each "instance" (created in Qubes()'s
__init__()), even though this is really the same object. During normal
execution this isn't an issue, because there is just one Qubes() object
instance. But during tests, multiple objects are created.

In this particular case, it caused PolicyCache() to be created twice and
the second one overriden the first one - without properly cleaning it
up. This leaks a file descriptor (inotify one). The fact that cleanup()
was called twice too didn't helped, because it was really called on
the same object, the one requiring cleanup was already gone.

Workaround this by checking if policy_cache field is initialize and
avoid re-initialize it. Also, on Qubes() object cleanup remove that
field, so it can be properly initialized on the next test iteration.
2020-03-31 01:57:22 +02:00
Marek Marczykowski-Górecki
0341cc5258
tests: teardown fixes
Add few missing app.close() calls on test teardown.
Fix socket cleanup in TC_00_QubesDaemonProtocol() - not only close the
FD, but also unregister it from asyncio event loop.
2020-03-28 03:23:29 +01:00
Marek Marczykowski-Górecki
3f96c72ee3
api/admin: (ext/admin) limit listing VMs based on qrexec policy
Various Admin API calls, when directed at dom0, retrieve global system
view instead of a specific VM. This applies to admin.vm.List (called at
dom0 retrieve full VM list) and admin.Events (called at dom0 listen for
events of all the VMs). This makes it tricky to configure a management
VM with access to limited set of VMs only, because many tools require
ability to list VMs, and that would return full list.

Fix this issue by adding a filter to admin.vm.List and admin.Events
calls (using event handlers in AdminExtension) that filters the output
using qrexec policy. This version evaluates policy for each VM or event
(but loads only once). If the performance will be an issue, it can be
optimized later.

Fixes QubesOS/qubes-issues#5509
2020-03-28 03:23:28 +01:00
Marek Marczykowski-Górecki
8f0ec59f95
Merge remote-tracking branch 'origin/pr/330'
* origin/pr/330:
  gui: fixes from Marek's comments
  gui: improvements of feature keyboard layout checks
  tests: adapt tests for keyboard-layout
  gui: drop legacy qubes-keyboard support
2020-03-18 14:34:22 +01:00
Frédéric Pierret (fepitre)
577e4b24a6
gui: fixes from Marek's comments 2020-03-18 14:17:04 +01:00
Frédéric Pierret (fepitre)
f130ec0bf3
gui: improvements of feature keyboard layout checks 2020-03-18 09:46:21 +01:00
Frédéric Pierret (fepitre)
5cb0e61a84
tests: adapt tests for keyboard-layout 2020-03-18 09:17:37 +01:00
Frédéric Pierret (fepitre)
732e291ab6
gui: drop legacy qubes-keyboard support
Add check for keyboard-layout feature set
2020-03-18 09:17:37 +01:00
Marek Marczykowski-Górecki
29020d0c53
Merge branch 'feature-pre-set'
* feature-pre-set:
  Add pre- events to vm features
2020-03-17 19:26:53 +01:00
Marek Marczykowski-Górecki
d05592ba52
Add pre- events to vm features
Allow extensions to validate feature values, before it is set.
2020-03-17 18:46:12 +01:00
Marek Marczykowski-Górecki
ddc13d6b62
Merge remote-tracking branch 'origin/pr/329'
* origin/pr/329:
  tests: make PEP8 happier
  tests: fix already registered event impl
2020-03-17 12:07:18 +01:00
Frédéric Pierret (fepitre)
d8f80c9687
tests: make PEP8 happier 2020-03-16 23:22:36 +01:00
Frédéric Pierret (fepitre)
40156c3e78
tests: fix already registered event impl 2020-03-16 23:21:15 +01:00
Marek Marczykowski-Górecki
f62a861140
tests: fix test_053_qrexec_vm_service_eof_reverse
and not mark it as expected failure anymore. Note the removal of the
expected failure isn't just about the changes here, but also about the
actual fix on the qrexec side (ffafd01 "Fix not closed file descriptors in
qubes-rpc-multiplexer" commit in core-qrexec repository).
2020-03-15 02:55:18 +01:00
Marek Marczykowski-Górecki
5423ead27a
tests/vm_qrexec_gui: do not swallow stderr on failure
QubesVM.run_for_stdio() by default captures stderr. In case of call fail
(non-zero return code), captured stderr is included in the exception
object, but isn't printed by default CalledProcessError message.
Make it visible by:
 - handling CalledProcessError and including in the test failure message
   (when exception is captured already)
 - not capturing stderr (if no exception handling is present in the
   test)
2020-03-14 03:43:22 +01:00
Marek Marczykowski-Górecki
d033457f3d
tests: adjust for qrexec-client-vm exit code
It now consistently returns remote exit code, not a local one.
Check 'cat' exit code instead.
2020-03-14 03:43:17 +01:00
Marek Marczykowski-Górecki
7a750ea9c8
tests: QubesVM.run_for_stdio 2020-03-10 11:56:48 +01:00
Marek Marczykowski-Górecki
9ec86f3c41
Workaround different behaviour of asyncio's Process.communicate()
In asyncio's Process.communicate() input=None does not close stdin.
Workaround it by using b'' instead of None.

https://bugs.python.org/issue39744
2020-03-10 11:56:48 +01:00
Marek Marczykowski-Górecki
3ce4e5eaa5
tests: adjust SystemTestCase.create_remote_file to create executables
The main use case for this function is to create qrexec services in VMs.
Since qrexec now require service scripts to be executable, make
create_remote_file() adjust permissions.
2020-03-10 11:56:47 +01:00
Marek Marczykowski-Górecki
2460adbdef
tests: socket-based qrexec services
QubesOS/qubes-issues#3912
2020-03-10 11:56:47 +01:00
Marek Marczykowski-Górecki
3f5fb0de9e
tests: hide git output when checking local checkout 2020-03-10 11:56:47 +01:00
Marek Marczykowski-Górecki
534de9bc1c
tests: fix cleanup before test
If any test-* VMs remains from previous test run, there are removed
before test. self.app doesn't exist at this point, so don't require it
in self.remove_vms().
2020-03-10 11:56:47 +01:00
Marek Marczykowski-Górecki
879ee9e7d6
api/internal: extract get_system_info() function
This will be useful in other places too.

QubesOS/qubes-issues#5099
2020-03-09 19:25:10 +01:00
Marek Marczykowski-Górecki
135eda0582
Merge remote-tracking branch 'origin/pr/320'
* origin/pr/320:
  storage/lvm: don't try to resize non-existing lvm volumes
  storage/lvm: update volume.size attribute on resize
2020-03-09 18:34:49 +01:00
M. Vefa Bicakci
5d755eb065
tests: Add a test case for QubesVM.is_fully_usable
This commit adds a test case for the QubesVM class's is_fully_usable
method. The verified scenarios are as follows:

* The VM has qrexec enabled, and the qrexec service has been
  successfully started.
  (The VM becomes "fully usable" in this case.)

* The VM has qrexec enabled, and the qrexec service has failed to start
  (Error handling case; the VM is *not* fully usable.)

* The VM does *not* have qrexec enabled.
  (The VM becomes "fully usable" in this case.)
2020-03-09 00:22:51 -04:00
M. Vefa Bicakci
2d55841a5e
qubesvm: Let HVMs enter 'Running' state
Prior to this commit, a properly configured Linux HVM would not
transition from the 'Transient' state to the 'Running' state according
to qvm-ls output, even if the HVM in question had the 'qrexec' feature
disabled.

This issue is caused by an unconditional qrexec check in the
'on_domain_is_fully_usable' method, and is resolved by adding
a check that short-circuits the qrexec check if the aforementioned
feature is not enabled for the VM in question.
2020-03-08 22:39:16 -04:00
M. Vefa Bicakci
d81d6a9267
qubes module: Typo fix
This commit fixes a typo, where the exception type DontSave was used,
even though the name of the function dontsave was intended.
2020-03-08 22:39:16 -04:00
Marek Marczykowski-Górecki
16bdeea2c0
Merge remote-tracking branch 'origin/pr/295'
* origin/pr/295:
  tests: fix tag name in audiovm test
  tests: ensure notin while setting Audio/Gui VM
  gui: add checks for changing/removing guivm
  audio: add checks for changing/removing audiovm
  audio/gui: use simply vm.tags instead of list()
  tests: fix tests for gui/audio vm
  Make pylint happy
  gui/audio: fixes from Marek's comments
  Allow AudioVM to be ran after any attached qubes
  Allow GuiVM to be ran after any attached qubes
  xid: ensure vm is not running
  tests: fix missing default audiovm and guivm tags
  gui, audio: better handling of start/stop guivm/audiovm
  gui, audio: ensure guivm and audiovm tag are set
  Support for AudioVM
2020-03-09 01:48:01 +01:00
Marek Marczykowski-Górecki
36e9afe1ff
Merge branch 'tests20200301'
* tests20200301:
  tests/salt: don't depend on initial tags set
  tests: make audio tests less racy
2020-03-09 01:45:58 +01:00
Marek Marczykowski-Górecki
4cfc423d5e
tests: fix tag name in audiovm test 2020-03-09 01:11:58 +01:00
Marek Marczykowski-Górecki
84ec49e98d
Merge remote-tracking branch 'origin/pr/322'
* origin/pr/322:
  Ensure empty service value delete /var/run/qubes-service/ file
  services: fixes from Marek's comments
  config: fix mistake in path for services
  tests: add/remove services in dom0
  config: specify dom0 services path
  services: handle dom0 write permission errors
  services: handle /var/run/qubes/'SERVICE NAME' for dom0
  services: make PEP8 happier
2020-03-09 00:37:44 +01:00
Frédéric Pierret (fepitre)
a61bb9a0cb
Ensure empty service value delete /var/run/qubes-service/ file
- Add tests and stop patch path from Marek's comment
2020-03-08 23:08:48 +01:00
Frédéric Pierret (fepitre)
532d9a3a98
tests: ensure notin while setting Audio/Gui VM 2020-03-08 22:59:46 +01:00
Frédéric Pierret (fepitre)
90584c487a
gui: add checks for changing/removing guivm 2020-03-08 17:07:29 +01:00
Frédéric Pierret (fepitre)
c36ad38eb3
audio: add checks for changing/removing audiovm 2020-03-08 17:07:29 +01:00
Frédéric Pierret (fepitre)
9051aff15a
audio/gui: use simply vm.tags instead of list() 2020-03-08 17:07:29 +01:00
Frédéric Pierret (fepitre)
4b5ae0833b
tests: fix tests for gui/audio vm 2020-03-08 17:07:24 +01:00
Frédéric Pierret (fepitre)
43786e1478
Make pylint happy
- Drop unused 'asyncio'
- Drop useless 'else' after return
2020-03-08 17:05:34 +01:00
Frédéric Pierret (fepitre)
7506482d08
gui/audio: fixes from Marek's comments 2020-03-08 17:05:34 +01:00
Frédéric Pierret (fepitre)
660c224914
Allow AudioVM to be ran after any attached qubes 2020-03-08 17:05:34 +01:00
Frédéric Pierret (fepitre)
edfb251413
Allow GuiVM to be ran after any attached qubes 2020-03-08 17:05:34 +01:00
Frédéric Pierret (fepitre)
3f4ee9f8d9
xid: ensure vm is not running 2020-03-08 17:05:34 +01:00
Frédéric Pierret (fepitre)
820500a367
tests: fix missing default audiovm and guivm tags 2020-03-08 17:05:33 +01:00
Frédéric Pierret (fepitre)
a1752ef265
gui, audio: better handling of start/stop guivm/audiovm 2020-03-08 17:05:33 +01:00
Frédéric Pierret (fepitre)
8f67334c4f
gui, audio: ensure guivm and audiovm tag are set 2020-03-08 17:05:33 +01:00
Frédéric Pierret (fepitre)
795ff1233a
Support for AudioVM 2020-03-08 17:05:33 +01:00
Marek Marczykowski-Górecki
b569f5a2b0
tests/firewall: update future time to be really in the future
Mar 4 2020 is no longer future, move it much more into the future.
2020-03-08 16:35:39 +01:00
Frédéric Pierret (fepitre)
bdc3c6588b
services: fixes from Marek's comments 2020-03-08 09:51:30 +01:00
Frédéric Pierret (fepitre)
31c098d1bd
config: fix mistake in path for services 2020-03-08 09:47:09 +01:00
Marek Marczykowski-Górecki
283d251387
Merge remote-tracking branch 'origin/pr/319'
* origin/pr/319:
  gui: set xkb_layout manually
  tests: handle legacy layout
  gui: no check in subprocess.run
  gui: handle legacy keymap setting /qubes-keyboard
2020-03-08 01:29:21 +01:00
Marek Marczykowski-Górecki
6874c7fece
tests/salt: don't depend on initial tags set
Some extensions may add tags at VM creation (guivm-*, audiovm-*). Take
this into account when calculating expected tags.
2020-03-01 22:36:54 +01:00
Marek Marczykowski-Górecki
ec88796129
tests: make audio tests less racy
Wait specifically for pulseaudio to start in the VM, instead of just
waiting few seconds.
Also, improve failure message to distinguish total lack of audio from
just missing few samples.
2020-03-01 22:36:54 +01:00
Marek Marczykowski-Górecki
34e6c2ff34
Merge remote-tracking branch 'origin/pr/323'
* origin/pr/323:
  Add guivm to internal.GetSystemInfo
2020-03-01 03:51:24 +01:00
Paweł Marczewski
941b7f16a0
Add guivm to internal.GetSystemInfo
Needed to move qrexec-policy-agent out to a separate GuiVM.
2020-02-27 18:20:48 +01:00
Frédéric Pierret (fepitre)
a67b8f35ba
gui: set xkb_layout manually 2020-02-25 11:34:02 +01:00
Frédéric Pierret (fepitre)
9a6ff177ce
tests: add/remove services in dom0 2020-02-20 23:07:49 +01:00
Frédéric Pierret (fepitre)
0b8e5400a3
config: specify dom0 services path 2020-02-20 15:56:48 +01:00
Frédéric Pierret (fepitre)
a7e7166f7a
services: handle dom0 write permission errors 2020-02-20 15:55:04 +01:00
Frédéric Pierret (fepitre)
d0a8b49cc9
services: handle /var/run/qubes/'SERVICE NAME' for dom0 2020-02-20 15:55:04 +01:00
Frédéric Pierret (fepitre)
6f2f57caea
services: make PEP8 happier 2020-02-20 15:55:03 +01:00
Marek Marczykowski-Górecki
2f4b42e5cd
Merge remote-tracking branch 'origin/pr/318'
* origin/pr/318:
  Pass network parameters to linux-stubdom

Fixes QubesOS/qubes-issues#5022
2020-02-17 03:56:45 +01:00
Rusty Bird
e8a7a6c82c
qubes/config: reindent varlibqubes pool; add a blank line 2020-02-15 18:33:18 +00:00
Rusty Bird
d527e01136
Remove more core2 code 2020-02-15 17:48:32 +00:00
Rusty Bird
8e581108b7
Remove pylint pragma working around very old false positive 2020-02-15 17:33:35 +00:00
Rusty Bird
1f71a06aed
Remove python2 compat __future__ imports 2020-02-15 17:33:34 +00:00
Frédéric Pierret (fepitre)
65238c187f
tests: handle legacy layout 2020-02-13 22:46:52 +01:00
Frédéric Pierret (fepitre)
2e1290eec1
gui: no check in subprocess.run 2020-02-13 22:31:33 +01:00
Marek Marczykowski-Górecki
86881afeef
storage/lvm: don't try to resize non-existing lvm volumes
Volume with save_on_stop=False and snap_on_start=False exists only when
VM is running and this is already handled under is_dirty() condition.
For non-running VMs, skip LVM resize step and only update internal size
attribute.

Fixes QubesOS/qubes-issues#5645
2020-02-12 21:57:34 +01:00
Marek Marczykowski-Górecki
6b474e39f6
storage/lvm: update volume.size attribute on resize
When volume is resized, underlying LVM is adjusted if exists. For
persistent volumes it is enough, as generally the driver prefers
underlying LVM size than internal attribute. But volatile volume is
removed at vm shutdown, so that value is lost.

Fix it by updating Volume.size attribute too, to be updated in qubes.xml
later too.

Fixes QubesOS/qubes-issues#5645
2020-02-12 21:44:16 +01:00
Frédéric Pierret (fepitre)
dbacd07b43
gui: handle legacy keymap setting /qubes-keyboard 2020-02-10 14:42:30 +01:00
Marek Marczykowski-Górecki
c332de9653
Merge remote-tracking branch 'origin/pr/312'
* origin/pr/312:
  Added handling for 'force' option in vm shutdown
2020-02-06 23:31:43 +01:00
Marek Marczykowski-Górecki
f59fd3d474
Merge remote-tracking branch 'origin/pr/316'
* origin/pr/316:
  storage/reflink: trivial style tweaks
  storage/reflink: comment on _get_size() use in start()
  storage/reflink: don't bother using _get_size() in create()
  storage/reflink: delete all images at beginning of create()
  storage/reflink: get VM dir from less arbitrary-looking path
  storage/reflink: factor out _remove_all_images()
  storage/reflink: _remove_incomplete_{files -> images}()
  storage/reflink: omit redundant comment
2020-02-06 23:29:08 +01:00
Rusty Bird
ada27ee431
storage/reflink: trivial style tweaks
Avoid early return for short and not deeply nested functions.
2020-02-05 17:26:44 +00:00
Rusty Bird
21971d6d0a
storage/reflink: comment on _get_size() use in start() 2020-02-05 17:26:43 +00:00
Marta Marczykowska-Górecka
284fbe1d44
Added handling for 'force' option in vm shutdown
To be more precise: just allowed using it, as the option was
actually implemented previously.

references QubesOS/qubes-issues#5591
2020-01-29 22:12:49 +01:00
Pawel Marczewski
1d1cc10211
Pass network parameters to linux-stubdom
See QubesOS/qubes-issues#5022.
2020-01-29 09:45:05 +01:00
marmot1791
d7b90f92e0 Correct comments in to match current code behavior 2020-01-28 23:02:43 +00:00
Rusty Bird
749ce477df
storage/reflink: don't bother using _get_size() in create()
Only the nominal size is available at this point.
2020-01-28 13:40:15 +00:00
Rusty Bird
6659ed8d39
storage/reflink: delete all images at beginning of create()
Ensure that there are no leftover image files for the volume, e.g. from
an unsuccessful removal of a previous incarnation of this vid, or from
an messily restored pool filesystem backup. We don't want to preserve
any stale data (revisions) or metadata (size) in the new incarnation.
2020-01-28 13:40:14 +00:00
Rusty Bird
56f6a6ef65
storage/reflink: get VM dir from less arbitrary-looking path 2020-01-28 13:40:13 +00:00
Rusty Bird
12d882b355
storage/reflink: factor out _remove_all_images() 2020-01-28 13:40:11 +00:00
Rusty Bird
8f4c90c37a
storage/reflink: _remove_incomplete_{files -> images}() 2020-01-28 13:40:10 +00:00
Rusty Bird
9c9d71c069
storage/reflink: omit redundant comment
The is_dirty() one-liner is defined right above.
2020-01-28 13:40:09 +00:00
Pawel Marczewski
e8baf2a157
Remove leftovers from QubesVM.run_for_stdio() refactoring
We no longer use qubes.VMShell there.
2020-01-24 16:59:42 +01:00
Pawel Marczewski
08d83fb241
Support qubes.VMExec call
The feature is advertised by core-agent so that it can be used
instead of VMShell.

See QubesOS/qubes-issues#4850.
2020-01-24 16:57:13 +01:00
Marek Marczykowski-Górecki
0a66a0c7dd
Merge remote-tracking branch 'origin/pr/313'
* origin/pr/313:
  Fix overlapping block device names
2020-01-24 01:43:33 +01:00
Marek Marczykowski-Górecki
869f963335
Merge remote-tracking branch 'origin/pr/311'
* origin/pr/311:
  Add a test for loading volume config from XML
  Fix ThinVolume.size initialization from string
2020-01-24 01:38:16 +01:00
Marek Marczykowski-Górecki
edf5977b23
Merge remote-tracking branch 'origin/pr/309'
* origin/pr/309:
  import: check exact size of copied data
  Implement new admin.vm.ImportWithSize API call

Fixes QubesOS/qubes-issues#5239
2020-01-24 01:35:00 +01:00
Pawel Marczewski
fe72fe1681
Fix overlapping block device names
This was caused by a change in Jinja template engine that breaks
assignments like {% set i = i + 1 %} in a loop.

Jinja 2.10 introduces a "namespace" object for this use case, but
unfortunately dom0-fc25 uses 2.8.1.

See:

https://github.com/pallets/jinja/issues/641
https://github.com/pallets/jinja/pull/684

Fixes QubesOS/qubes-issues#5551.
2020-01-23 11:27:05 +01:00
Pawel Marczewski
66abc69a33
Add a test for loading volume config from XML 2020-01-23 10:42:26 +01:00
Pawel Marczewski
49f2c1b78d
Fix ThinVolume.size initialization from string
The size config parameter might be a string coming from XML.
The Volume base class handles the conversion to integer already.

Fixes QubesOS/qubes-issues#5219.
2020-01-23 10:39:47 +01:00
Pawel Marczewski
e9b97e42b1
import: check exact size of copied data
The import will error out if there is not enough data, or too
much data provided.
2020-01-23 09:48:58 +01:00
Pawel Marczewski
63ac952803
Implement new admin.vm.ImportWithSize API call
This should allow importing a volume and changing the size at the
same time, without performing the resize operation on original
volume first.

The internal API has been renamed to internal.vm.volume.ImportBegin
to avoid confusion, and for symmetry with ImportEnd.

See QubesOS/qubes-issues#5239.
2020-01-23 09:47:22 +01:00
Marek Marczykowski-Górecki
88037ff289
Merge remote-tracking branch 'origin/pr/310'
* origin/pr/310:
  storage/reflink: fix comment
  storage/reflink: bail out early on most FICLONE errnos
  storage/reflink: pool.setup_check -> pool._setup_check
2020-01-23 04:50:14 +01:00
Marek Marczykowski-Górecki
29f84d5105
Merge remote-tracking branch 'origin/pr/308'
* origin/pr/308:
  Move devices check to on_domain_pre_deleted
  Prevent removing VM if it provides devices in persistent mode
2020-01-23 04:32:39 +01:00
Pawel Marczewski
f1ff6c26d8
Move devices check to on_domain_pre_deleted 2020-01-21 15:35:30 +01:00
Rusty Bird
d54e4b0c6e
storage/reflink: fix comment 2020-01-17 16:45:29 +00:00
Rusty Bird
ba662d2819
storage/reflink: bail out early on most FICLONE errnos
Don't fall back on 'cp' if the FICLONE ioctl gives an errno that's not
plausibly reflink specific, because in such a case any fallback could
theoretically mask real but intermittent system/storage errors.

Looking through ioctl_ficlone(2) and the kernel source, it should be
sufficient to do the fallback only on EBADF/EINVAL/EOPNOTSUPP/EXDEV.
(EISDIR/ETXTBSY don't apply to this storage driver, which will never
legitimately attempt to reflink a directory or an active - in the
storage domain - swap file.)
2020-01-17 15:56:51 +00:00
Rusty Bird
90f25890cf
storage/reflink: pool.setup_check -> pool._setup_check 2020-01-17 15:56:50 +00:00
Marek Marczykowski-Górecki
8dda66d693
tests: fix key generation for dom0 updates tests
gpg2 requires explicit `%no-protection`, otherwise tries to
interactively (through gpg-agent) prompt for the passphrase.
2020-01-17 04:50:31 +01:00
Pawel Marczewski
b09a137b26
Prevent removing VM if it provides devices in persistent mode
Fixes QubesOS/qubes-issues#5136.
2020-01-16 11:13:07 +01:00
Marek Marczykowski-Górecki
309dd11b1d
Merge remote-tracking branch 'origin/pr/307'
* origin/pr/307:
  Implement missing get_cputime() in AdminVM
  Add admin.vm.CurrentState method
2020-01-16 04:12:42 +01:00
Marek Marczykowski-Górecki
161f139f98
Merge remote-tracking branch 'origin/pr/305'
* origin/pr/305:
  Test file copy hang when target machine qrexec is disabled
2020-01-16 04:05:09 +01:00
Marek Marczykowski-Górecki
0c08305f1a
Merge remote-tracking branch 'origin/pr/303'
* origin/pr/303:
  Update tests after adding /connected-ips
  Also reload /connected-ips on firewall change / domain spawn
  Also store /connected-ips6 for machines that have IPv6 addresses
  Don't try to write to qubesdb of an offline VM
  Maintain a list of connected machine IPs in qubesdb
2020-01-16 04:03:44 +01:00
Marek Marczykowski-Górecki
e6aa35fcdf
Merge branch 'tests-leaks'
* tests-leaks:
  ext/pci: handle 'qubes-close' event
  tests: allow extensions to cleanup objects references
2020-01-16 04:00:59 +01:00
Marek Marczykowski-Górecki
51adb434d1
tests: FileVolume.resize()
QubesOS/qubes-issues#5518
2020-01-16 01:38:14 +01:00
Pawel Marczewski
44dc35e972
Implement missing get_cputime() in AdminVM 2020-01-15 16:37:57 +01:00
Pawel Marczewski
62735d9696
Add admin.vm.CurrentState method
For all the transient values that should not be treated as
real properties. To be used in core-admin-client.
2020-01-15 16:06:08 +01:00
Pawel Marczewski
e69bdc5efa
Test file copy hang when target machine qrexec is disabled
See QubesOS/qubes-issues#5347.

Fix in QubesOS/qubes-core-qrexec#15.
2020-01-14 15:07:42 +01:00
Marek Marczykowski-Górecki
74e956e1f1
ext/pci: handle 'qubes-close' event
Move cache cleanup to 'qubes-close' event handler, instead of doing it
specifically in tests.
2020-01-11 03:54:30 +01:00
Marek Marczykowski-Górecki
a89d3f0cae
tests: allow extensions to cleanup objects references
Extension objects are singletons and normally do not require any special
cleanup. But in case of tests, we try to remove all the qubes objects
between tests and the cache in usb extension makes it hard.
Add a 'qubes-close' event that extensions can handle to remove extra
references stored in extension objects themselves.
2020-01-11 01:22:30 +01:00
Pawel Marczewski
70c862fe73
Update tests after adding /connected-ips 2020-01-09 16:41:14 +01:00
Pawel Marczewski
4d8fd0253b
Also reload /connected-ips on firewall change / domain spawn
There are scenarios where it turns out to be necessary, such as
enabling IPv6 on a machine causing it to acquire an IPv6 address.
2020-01-09 16:25:25 +01:00
Pawel Marczewski
40f372ee5f
Also store /connected-ips6 for machines that have IPv6 addresses 2020-01-09 16:18:07 +01:00
Pawel Marczewski
6bf230cf4d
Don't try to write to qubesdb of an offline VM 2020-01-09 12:37:43 +01:00
Pawel Marczewski
7597a50b20
Maintain a list of connected machine IPs in qubesdb
Necessary for anti-spoofing, see QubesOS/qubes-issues#5540.
2020-01-09 12:23:04 +01:00
Marek Marczykowski-Górecki
d181c0f354
storage/file: fix resize
Fixes QubesOS/qubes-issues#5518
2019-12-14 15:48:49 +01:00
Marta Marczykowska-Górecka
35fa733a67
Fixed Exceptions inferiting from KeyError
Due to strangeness of KeyError (it overrrides __str__ method) in some
cases exceptions received superflous quotation marks when inheriting
from it.

fixes QubesOS/qubes-issues#5106
2019-12-09 21:02:24 +01:00
Marek Marczykowski-Górecki
7cb46e6929
Merge remote-tracking branch 'origin/pr/298'
* origin/pr/298:
  tests/network: let xl devd bring the interfaces up
  tests/network: improve error reporting
  api/admin: implement *.property.GetAll methods
  Avoid resetting clocksync service of just enabled clockvm
  doc/tests: extend qubes-specific quirks in tests
  tests: add include and exclude lists for extra tests loader
2019-12-07 05:04:42 +01:00
Marek Marczykowski-Górecki
8965e9a8e4
tests/network: let xl devd bring the interfaces up
xl devd doesn't use startup notify, so when the service is started
(according to systemd) it may still be initializing interfaces. Add a
little sleep for that.
2019-12-05 23:31:15 +01:00
Marek Marczykowski-Górecki
ffa1a40e6e
tests/network: improve error reporting
Include stdout/stderr of failed command during netvm setup.
2019-12-05 23:31:15 +01:00
Marek Marczykowski-Górecki
10f99e5c4a
api/admin: implement *.property.GetAll methods
Allow getting all the VM properties with one call. This greatly improve
performance of an applications retrieving many/all of them (qvm-ls,
qubes manager etc)

QubesOS/qubes-issues#5415
Fixes QubesOS/qubes-issues#3293
2019-12-05 23:31:14 +01:00
Rusty Bird
87081d6ee3
storage/reflink: _cleanup() -> _remove_incomplete_files()
"cleanup" sounds related to the concept of a volume being "dirty" - but
it's unrelated. Rename it for clarity.
2019-12-03 18:21:55 +00:00
Rusty Bird
d7478d128b
storage/reflink: document hardcoded sizeof(int) for FICLONE
One alternative would look like

    import ctypes
    sizeof_int = ctypes.sizeof(ctypes.c_int)
    FICLONE = (1073741824 % 256**sizeof_int) | 37897 | (sizeof_int << 16)

but, even if the above really(?) is a 100% correct Python port of

    $ echo FICLONE | cpp -include linux/fs.h | tail -n 1

it still seems more likely that the ctypes package is somehow buggy
somewhere than for Qubes storage to run on an exotic architecture with
non 32 bit ints (in the foreseeable future).

So just document the baked in assumption.
2019-12-03 18:21:54 +00:00
Rusty Bird
3f0286220c
storage/reflink: simplify _replace_file() comment 2019-12-03 18:21:52 +00:00
Rusty Bird
9d5deffb13
storage/reflink: open in binary mode for loopdev resize ioctl
The default (= text) mode for a loop device which contains a VM image
looked weird, even though it didn't make a difference here because the
dev_io object was never actually read from.
2019-12-03 18:21:51 +00:00
Rusty Bird
4cd9e42416
storage/reflink: use a conditional expression 2019-12-03 18:21:50 +00:00
Marek Marczykowski-Górecki
5d77cf2298
Avoid resetting clocksync service of just enabled clockvm
When setting global clockvm property, 'clocksync' service is
automatically added to the new value and then removed from the old one.
But if the new value is the same as the old one, the service gets
removed from the just set new value.
Check for this case explicitly.

Fixes QubesOS/qubes-issues#4939
2019-11-30 05:20:08 +01:00
Marek Marczykowski-Górecki
7c18b187de
tests: add include and exclude lists for extra tests loader
'extra' tests run is getting ridiculously long. Allow splitting it into
several jobs. Since this appears as just one class from the test loader
perspective, implement it as environment variables:
 - QUBES_TEST_EXTRA_INCLUDE - load just selected tests
 - QUBES_TEST_EXTRA_EXCLUDE - skip selected tests (to select "the rest"
   tests)
2019-11-30 04:35:18 +01:00
Marek Marczykowski-Górecki
fd8e89c546
Merge remote-tracking branch 'origin/pr/297'
* origin/pr/297:
  doc: remove useless _static generated by sphinx
  cleanup-dispvms: fix python shebang
  spec: fix missing dependency
  Fix Sphinx 2 new API for Fedora 31+
  doc: Make PEP8 happier
  qmemmand: separate SystemState init xc and xs to a 'init' method
  doc: drop moved elsewhere components
2019-11-27 02:12:37 +01:00
Frédéric Pierret (fepitre)
be1c193e3c
Fix Sphinx 2 new API for Fedora 31+ 2019-11-22 21:39:31 +01:00
Frédéric Pierret (fepitre)
b4177cf7d2
doc: Make PEP8 happier 2019-11-22 21:39:30 +01:00
Frédéric Pierret (fepitre)
0d20639cc1
qmemmand: separate SystemState init xc and xs to a 'init' method
It prevents any connection to xen when initiallizing the class
notably in doc build generation.
2019-11-22 21:38:27 +01:00
Marek Marczykowski-Górecki
6c7af109e5
ext/block: prefer connecting cdrom as xvdd
Only first 4 disks can be emulated as IDE disks by QEMU. Specifically,
CDROM must be one of those first 4 disks, otherwise it will be
ignored. This is especially important if one wants to boot the VM from
that CDROM.
Since xvdd normally is a kernel-related volume (boot image, modules) it
makes perfect sense to re-use it for CDROM. It is either set for kernel
volume (in which case, VM should boot from it and not the CDROM), or
(possibly bootable) CDROM.

This needs to be done in two places:
 - BlockExtension for dynamic attach
 - libvirt xen.xml - for before-boot attach

In theory the latter would be enough, but it would be quite confusing
that device will get different options depending on when it's attached
(in addition to whether the kernel is set - introduced here).

This all also means, xvdd not always is a "system disk". Adjust listing
connected disks accordingly.
2019-11-19 14:03:21 +01:00
Marek Marczykowski-Górecki
9bf0cce11e
tests: extend mock objects in QubesVM tests
- allow TestQubesDB to be populated with initial data
- support list() method
- allow to register pre-created VM instance (useful for AdminVM, which
        don't accept setting qid)
2019-11-18 23:45:02 +01:00
Frédéric Pierret (fepitre)
e092b40350
tests: make PEP8 happier 2019-11-17 01:54:27 +01:00
Frédéric Pierret (fepitre)
3a6ed2d0cd
tests: fix test with not None default_guivm 2019-11-17 01:48:20 +01:00
Frédéric Pierret (fepitre)
85edf511cb
default_guivm: set to dom0 due to migration R4.0->R4.1 problems 2019-11-16 13:04:42 +01:00
Marta Marczykowska-Górecka
783832adde
Correct inconsistent behavior on unavailable usage data
fixes QubesOS/qubes-issues#5463
2019-11-15 20:01:43 +01:00
Marek Marczykowski-Górecki
ba105e89c6
Merge branch 'devel20191029' 2019-11-12 23:11:30 +01:00
Marek Marczykowski-Górecki
7de9f3e078
tests: is_iommu_supported function
QubesOS/qubes-issues#4689
2019-11-12 22:45:30 +01:00
Marek Marczykowski-Górecki
c79e91d59d
Merge remote-tracking branch 'origin/pr/292'
* origin/pr/292:
  Throw BackupAlreadyRunningError when backup is already running
2019-11-12 22:26:53 +01:00
Marta Marczykowska-Górecka
7a4455bbfa
Throw BackupAlreadyRunningError when backup is already running
Instead of generic PermissionDenied.

requires https://github.com/QubesOS/qubes-core-admin-client/pull/115
references QubesOS/qubes-issues#5432
2019-11-11 19:16:03 +01:00
Frédéric Pierret (fepitre)
2ccdd4ee8e
gui: make pylint happy 2019-11-11 11:27:40 +01:00
Marek Marczykowski-Górecki
77cf310c47
storage/kernels: fix listing volumes
Pool.volumes property is implemented in a base class, individual drivers
should provide list_volumes() method as a backend for that property.
Fix this in a LinuxKernel pool.
2019-11-10 01:14:34 +01:00
Marek Marczykowski-Górecki
263f218d40
api/admin: implement admin.pool.volume.List method
Similar to admin.vm.volume.List. There are still other
admin.pool.volume.* methods missing, but lets start with just this one.
Those with both pool name and volume id arguments may need some more
thoughts.
2019-11-09 18:38:56 +01:00