Commit Graph

46 Commits

Author SHA1 Message Date
Marek Marczykowski-Górecki
04ad224a9d
tests: add v4 (Qubes 4.0) backup format tests, move qubes.xml
Move qubes.xml to be tested into separate files. The backup tests script
is long enouch already.
2017-07-17 20:28:21 +02:00
Marek Marczykowski-Górecki
525f8dc7f3
tests/backup: use smaller images
This will be less realistic (private.img of 2MB?!), but makes tests much
quicker. And since tar is used to make files sparse, we don't really
test multi-part archives anyway.
2017-07-17 20:28:20 +02:00
Marek Marczykowski-Górecki
a91372a919
devices,features: fix bool values handling
API define False value serialized as '' and True as 'True'. Do not
serialize 0 as '' (features) or True as 'yes' (devices).
2017-07-17 20:27:35 +02:00
Marek Marczykowski-Górecki
e6d3425047
tests/backup: tests for backup-restore code
Based on "backup compatibility" tests, which manually assemble the
backup. This is because we don't have access to actual backup creation
code here.

QubesOS/qubes-issues#1214
2017-07-17 20:27:32 +02:00
Marek Marczykowski-Górecki
a3e3dac6dc
tests: improve test failure message
When multiple Admin API calls are expected, but not all were made, show
which were missing.
2017-07-08 00:08:20 +02:00
Marek Marczykowski-Górecki
e6149b09ce
Fix VM creation with default template
Fixes QubesOS/qubes-issues#2866
2017-07-08 00:08:19 +02:00
Marek Marczykowski-Górecki
9036103102
tests: qvm-shutdown --wait tests 2017-07-08 00:08:19 +02:00
Marek Marczykowski-Górecki
6b1c6141f6
tests/tools: add MockEventsReader
Make it easy to test things listening for events
2017-07-08 00:08:19 +02:00
Marek Marczykowski-Górecki
2052b32202
events: simplify wait_for_domain_shutdown coroutine
1. Handle timeout externally - using asyncio.wait_for.
2. Add support for waiting for multiple VMs.
2017-07-06 22:01:17 +02:00
Marek Marczykowski-Górecki
627aebf2cd
tools: remove policy handling from qvm-firewall tool
Follow the API removal

QubesOS/qubes-issues#2869
2017-07-05 14:16:30 +02:00
Marek Marczykowski-Górecki
942e122d27
firewall: drop GetPolicy/SetPolicy calls
Firewall policy is now hardcoded to 'drop'. Keep the property, so anyone
trying to assign it will get an exception

QubesOS/qubes-issues#2869
2017-07-05 14:16:30 +02:00
Marek Marczykowski-Górecki
c6eb4c49a3
storage: rework clone as two-stage operation
Split clone to two Admin API calls - one to the source volume, then
other to destination.
2017-07-05 14:16:30 +02:00
Marek Marczykowski-Górecki
88de4f77a5
tests: handle returning different response for the same request
Allow programming different responses for the same request when called
multiple times. This is useful for example for shutdown tests - first
domain is running, but after issuing shutdown request is is not.
2017-07-05 14:16:29 +02:00
Marek Marczykowski-Górecki
5430e04e1c
tools: move event loop creation/closing to main function
Do not close event loop in utility function - handle it only in main().
For this reason, change appropriate functions to coroutines.

Fixes QubesOS/qubes-issues#2865
2017-06-25 20:09:10 +02:00
Marek Marczykowski-Górecki
ce7d4865b6
events: fix calling mgmt.Events from VM
asyncio.create_subprocess_exec expects program and arguments directly,
not as a list.
2017-06-25 14:01:14 +02:00
Marek Marczykowski-Górecki
c545c95660
tests: fix qvm-run test on travis
stdout there is not a tty, which change default value of filter_esc.
2017-06-25 13:44:17 +02:00
Marek Marczykowski-Górecki
3cf5840d7a
Merge branch 'devel-4'
* devel-4:
  tools/qvm-start-gui: multiple fixes
  vm: raise CalledProcessError instead of QubesVMError on failed service call
  events: improve handling qubesd restart
2017-06-25 13:16:50 +02:00
Marek Marczykowski-Górecki
cef80a76e4
Merge branch 'devel-3'
* devel-3:
  Implement VM clone as create + copy data+metadata
  storage: make Volumes sortable
  base: add PropertyHolder.clone_properties
  doc: minor fixes to man pages
  storage: add volume clone method
  doc: fix skel-manpage tool
  tools: add qvm-tags tool
  tags support
2017-06-25 13:16:22 +02:00
Marek Marczykowski-Górecki
64377207a8
tools/qvm-start-gui: multiple fixes
Don't start GUI daemon for given VM twice when qvm-start-gui was started
during VM startup (while waiting for qrexec startup). This is especially
common while running tests.

Report failed qubes.SetMonitorLayout as warning (instead of unhandled
exception).

Clear VM cache on qubesd reconnect.

Fix logging.
2017-06-21 06:01:53 +02:00
Marek Marczykowski-Górecki
bcd026d141
Implement VM clone as create + copy data+metadata
This way we don't need separate admin.vm.Clone call, which is tricky to
handler properly with policy.
A VM may not have access to all the properties and other metadata, so
add ignore_errors argument, for best-effort approach (copy what is
possible). In any case, failure of cloning VM data fails the whole
operation.
When operation fails, VM is removed.

While at it, allow to specify alternative VM class - this allows
morphing one VM into another (for example AppVM -> StandaloneVM).

Adjust qvm-clone tool and tests accordingly.

QubesOS/qubes-issues#2622
2017-06-20 01:34:18 +02:00
Marek Marczykowski-Górecki
998a42703f
storage: add volume clone method
Clone volume without retrieving all the data.

QubesOS/qubes-issues#2622
2017-06-20 01:34:17 +02:00
Marek Marczykowski-Górecki
8e5f90c273
tools: add qvm-tags tool
QubesOS/qubes-issues#2388
2017-06-20 01:34:17 +02:00
Marek Marczykowski-Górecki
31988a9bd8
tags support
QubesOS/qubes-issues#2622
2017-06-20 01:34:16 +02:00
Marek Marczykowski-Górecki
d1b67daa63
tests: basic tests for vm.features 2017-06-14 10:43:52 +02:00
Marek Marczykowski-Górecki
9dd659d60f
tools/qvm_template_postprocess: set vm.features['qrexec']
Enable 'qrexec' VM feature to wait for qrexec initialization - it is
required to call qubes.PostInstall service. If VM start fails, assume
there is no qrexec and drop that feature.
2017-06-14 10:43:52 +02:00
Marek Marczykowski-Górecki
c07c57bfef
Merge remote-tracking branch 'qubesos/pr/7'
* qubesos/pr/7:
  qvm-ls: hide flags (aka status), get more descriptive
  qvm-ls: fix -O with uppercase names
  vm: fix get_power_state() for dom0
2017-06-08 22:20:31 +02:00
Wojtek Porczyk
59eda63923 qvm-ls: hide flags (aka status), get more descriptive
Enterprise™ continues.
2017-06-08 15:03:00 +02:00
Marek Marczykowski-Górecki
065eb036df
events: fix parsing events with empty parameters
Empty parameter value is encoded as b'parameter\0\0', so we can't simply
read the data until b'\0\0', because it isn't necessary event end.
Instead, read event parts separately, according to specification.
2017-05-30 01:31:13 +02:00
Marek Marczykowski-Górecki
2675d63579
tools: add qvm-template-postprocess
Tool to be called from template's rpm post-installation script.
2017-05-26 01:33:43 +02:00
Marek Marczykowski-Górecki
9cdf9a0e60
tests: fix file descriptor leak 2017-05-26 00:42:48 +02:00
Marek Marczykowski-Górecki
c435de06a1
tests: fix handling TestProcess.communicate(None) 2017-05-26 00:42:48 +02:00
Marek Marczykowski-Górecki
fe51e8862a
Fix qubesadmin/tests/tools/qvm_firewall.py license header 2017-05-26 00:42:48 +02:00
Marek Marczykowski-Górecki
50237d4953
storage: implement admin.vm.volume.Import as volume.import_data
Use newly introduced payload_stream= argument to qubesd_call to pass
data directly from some file-like object - without loading it all into
memory.

QubesOS/qubes-issues#853
2017-05-26 00:42:47 +02:00
Marek Marczykowski-Górecki
c988ef41a3
Fix setting VM property to None
None value should be encoded as empty string.
2017-05-26 00:42:47 +02:00
Marek Marczykowski-Górecki
1aab64d5b0
tests: add more test cases for qvm-start-gui 2017-05-26 00:42:46 +02:00
Marek Marczykowski-Górecki
0b2f7ac958
Add efficient method to handle large payloads for Admin API methods
Add qubesd_call(..., payload_stream=...) argument to allow streaming
payload directly from some file/process stdout. This is mainly (only?)
useful for admin.vm.volume.Import, where disk volume raw data is passed
to the service.
2017-05-26 00:42:46 +02:00
Marek Marczykowski-Górecki
de2f23b9fe
Add QubesNoSuchPropertyError exception, expect it on invalid property
It inherits from AttributeError, so standard handling should just work.
2017-05-23 04:31:41 +02:00
Marek Marczykowski-Górecki
54d5ec79b5
qvm-run: fix race condition in SIGCHLD handling
Don't terminate qvm-run on any SIGCHLD, check if the process we're
waiting for have finished.

Currently the only situation when it's broken is a test (which starts
additional process, whose SIGCHLD may be caught here), but lets do not
assume that much (starting only one process) about environment.
2017-05-22 10:54:51 +02:00
Marek Marczykowski-Górecki
c826378579
devices: adjust API for 'devices: add assignment.device property' change
Make it easy to retrieve DeviceInfo object out of DeviceAssignment
object. The only missing piece of information for that is device class,
so add it. Make it optional, as it can be filled on demand when passing
the object through DeviceCollection (either by listing devices, or
attaching/detaching).

This also makes DeviceCollection._device method not needed anymore.
2017-05-22 01:18:02 +02:00
Marek Marczykowski-Górecki
38abd81ea8
tools: add qvm-run --service
Make it convenient wrapper around qrexec-client{-vm}, which would start
a VM, wait for user session etc.
2017-05-20 03:15:23 +02:00
Marek Marczykowski-Górecki
8686ef423a
tools/qvm-run: exit the shell after executing requested command
Since we use qubes.VMShell service now and send requested command on its
stdin, we need to terminate that shell after requested command -
otherwise the service will not terminate automatically waiting for
further input (next commands).
2017-05-18 09:54:26 +02:00
Marek Marczykowski-Górecki
ee81902979
features: fix serialization
qubesd_call expect "bytes" type. Additionally serialize false value as
empty string (which is treated by python as false value), because
otherwise would be serialized to (non-empty) string, which is true value
in python.
2017-05-18 09:48:18 +02:00
Marek Marczykowski-Górecki
2d7ca9f95e
tools/qvm-run: wait for user session unless qvm-run --no-gui is used
Avoid race condition with X server startup, especially important for
qvm-run --autostart.
2017-05-17 11:07:48 +02:00
Marek Marczykowski-Górecki
210876bd8f
tools/qvm-run: use subproces.DEVNULL instead of manually opened /dev/null 2017-05-17 11:06:56 +02:00
Marek Marczykowski-Górecki
cfc9ff2ce5
Rename Mgmt API to Admin API: methods names
QubesOS/qubes-issues#853
2017-05-12 19:36:03 +02:00
Marek Marczykowski-Górecki
4ceff0f8c0
Rename qubesmgmt to qubesadmin module
QubesOS/qubes-issues#853
2017-05-11 23:40:03 +02:00