Commit Graph

412 Commits

Author SHA1 Message Date
Rusty Bird
cf063a9638
qvm-backup-restore: also handle absent --ignore-missing
This was forgotten in 2d8bade.
2018-02-26 04:10:05 +00:00
Rusty Bird
0171269138
restore.py: add template-related debug log messages 2018-02-24 12:43:42 +00:00
Rusty Bird
ab65338cfb
restory.py: restore template_for_dispvms property early 2018-02-24 12:43:42 +00:00
Rusty Bird
c86b731d3e
restore.py: factor out _restore_property() helper 2018-02-24 12:43:42 +00:00
Rusty Bird
2ace32bb73
restore.py: deal with DispVM templates 2018-02-24 12:43:42 +00:00
Rusty Bird
68c8b7fafc
restore.py: sort into three tiers in _templates_first() 2018-02-24 12:43:42 +00:00
Rusty Bird
01ce5387d3
restore.py: don't try to restore dispid property 2018-02-23 17:15:20 +00:00
Rusty Bird
78571898da
qvm-backup: let backup core handle default VM selection
This takes the include_in_backups property into account, and does not
omit dom0.
2018-02-23 02:09:06 +00:00
Rusty Bird
2d8bade8b2
qvm-backup-restore: really pass options 2018-02-23 02:09:04 +00:00
Rusty Bird
a0d6327532
qvm-backup-restore: remove orphaned --replace-template option 2018-02-23 02:09:03 +00:00
Marek Marczykowski-Górecki
5a4577417f
Merge remote-tracking branch 'qubesos/pr/53'
* qubesos/pr/53:
  template-postprocess: fast path for file-reflink, like file
2018-02-14 04:45:59 +01:00
Marek Marczykowski-Górecki
d07475427f
Merge remote-tracking branch 'qubesos/pr/52'
* qubesos/pr/52:
  backup: don't crash when no 'qubes' group is present
  tests: dom0 backup restore, both v3 and v4
  backup: add support for openssl 1.1.0 options
  backup: skip dom0's properties while restoring core2 backup
  unused variable
  style issues
  Fix dom0 restore
  Fix dom0 handling
  Fix AdminVm class name
2018-02-14 04:45:12 +01:00
Marek Marczykowski-Górecki
56dc984507
backup: don't crash when no 'qubes' group is present
This is specifically the case on Travis-CI. But since dom0 backup is
restored into separate directory now, instead of directly overriding
user home, this check is much less relevant now.
2018-02-14 04:28:23 +01:00
Marek Marczykowski-Górecki
060171f19f
tests: dom0 backup restore, both v3 and v4
QubesOS/qubes-issues#3467
2018-02-14 04:28:23 +01:00
Marek Marczykowski-Górecki
a821034653
backup: add support for openssl 1.1.0 options
The command for listing available algorithms have changed:
old: openssl list-message-digest-algorithms
new: openssl list -digest-algorithms
2018-02-14 04:28:23 +01:00
Marek Marczykowski-Górecki
04635e7e80
backup: skip dom0's properties while restoring core2 backup
Fixes QubesOS/qubes-issues#3467
2018-02-14 04:28:22 +01:00
Marek Marczykowski-Górecki
24cfb4a581
vm: restore force_shutdown->kill deprecated alias
Apparently there are still users of this function - qubes manager.
2018-02-13 19:01:29 +01:00
Rusty Bird
e6466c3783
template-postprocess: fast path for file-reflink, like file
I don't know if any template currently hits this code path, even the
fedora-26-minimal root.img is large enough to be split into multiple
parts. Maybe Arch Linux?

Related to https://github.com/QubesOS/qubes-core-admin/pull/188
2018-02-12 21:51:01 +00:00
Christopher Laprise
e81c2f3cf6
unused variable 2018-02-01 23:20:31 -05:00
Christopher Laprise
e3d12fb96d
style issues 2018-02-01 23:00:06 -05:00
Christopher Laprise
30dd7acaa9
Fix dom0 restore 2018-02-01 22:21:24 -05:00
Christopher Laprise
60bfd63a25
Fix dom0 handling 2018-02-01 19:40:42 -05:00
Christopher Laprise
4b46d59179
Fix AdminVm class name 2018-01-24 20:42:15 -05:00
Marek Marczykowski-Górecki
2861d46dfa
backup/restore: do not shrink volumes on restore
This operation is blocked in current storage pool implementations.
2018-01-18 19:09:38 +01:00
Marek Marczykowski-Górecki
7211c7daff
storage: add size and usage properties
It's already available in config dict, but lets provide uniform API. And
also it's a bit weird to look for usage data in configuration...

QubesOS/qubes-issues#3240
2018-01-17 16:21:11 +01:00
Marek Marczykowski-Górecki
3d4f626515
Merge remote-tracking branch 'qubesos/pr/51'
* qubesos/pr/51:
  qvm-run: wait for X11 in --dispvm --gui case
  vm/DispVM: use 'qrexec_timeout' also for call connection timeout
2018-01-15 03:23:54 +01:00
Marek Marczykowski-Górecki
4a28c560d9
Merge remote-tracking branch 'qubesos/pr/50'
* qubesos/pr/50:
  Add property_get_default method
2018-01-15 03:23:00 +01:00
Rusty Bird
c83deccdd3
qvm-run: wait for X11 in --dispvm --gui case
'qvm-run --dispvm' cannot easily make a separate qubes.WaitForSession
call. Instead, if --gui is active, pass the new WaitForSession argument
to qubes.VMShell, which will do the equivalent.

The unit tests have been copied (in slightly adapted form) from commit
a620f02e2a

Fixes QubesOS/qubes-issues#3012
Closes QubesOS/qubes-core-admin-client#49
2018-01-14 18:36:46 +00:00
Marek Marczykowski-Górecki
c98b33bcd6
vm/DispVM: use 'qrexec_timeout' also for call connection timeout
When calling a service in DispVM, the connection is established only
after session is ready (if required for given service). qrexec-client by
default use 5s here, which is too low depending on hardware. Use
'qrexec_timeout' property here for DispVM case.

Fixes QubesOS/qubes-issues#3012
2018-01-14 18:36:24 +00:00
Marek Marczykowski-Górecki
ce0d230866
Add property_get_default method
It is useful to get property default value, without changing it to
default. For example to list it in GUI tools

Fixes QubesOS/qubes-issues#3197
2018-01-12 23:40:05 +01:00
Marek Marczykowski-Górecki
04f8d85819
base: make WrapperObjectsCollection behave like a dict
In core-admin matching collections are real dicts, so clone this API
behaviour here too. Specific changes:
 - iteration yields keys, not values
 - implement values and items methods

Additionally fix keys method, it was broken on python2 (list have no
copy method).
2018-01-12 05:29:40 +01:00
Marek Marczykowski-Górecki
8584ca4057
tools/qvm-ls: clarify that disk usage is in percents 2018-01-12 05:29:40 +01:00
Marek Marczykowski-Górecki
b16f3ab79b
tools/qvm-ls: add --network and --disk compatibility options
Shortcuts for new --format=...
2018-01-12 05:29:39 +01:00
Marek Marczykowski-Górecki
080b563ae2
tools/qvm-ls: add --raw-list option for compatibility with R3.2
There was an option to list just VM names, useful for scripting.
Preserve that for compatibility.
2018-01-12 05:29:39 +01:00
Marek Marczykowski-Górecki
0533703ddf
tools/qvm-ls: allow list only selected VMs
Restore possibility to list only some VMs, by naming them on command
line.
2018-01-12 05:29:39 +01:00
Marek Marczykowski-Górecki
4af13d5445
tools: fix handling optional domain list
It wasn't possible to use QubesArgumentParser(vmname_nargs=...) for
optional domain list - the option forced usage of either --all or
explicit domain list.
2018-01-12 05:27:57 +01:00
Marek Marczykowski-Górecki
9b5546f1b0
tools/qvm-start: add naive waiting for cdrom device
When starting a VM with --cdrom=some-vm:/some/path/to.iso, it can be
started only when loop device matching the path is available. For now,
add naive waiting (while ... sleep(1)) for it. Later it might worth
converting it to events handling.
2018-01-12 05:27:57 +01:00
Marek Marczykowski-Górecki
5b0e7123b8
storage: add volume.is_outdated() function
This is to match core-admin API. Logically it could be a property not a
method (as other things like usage or size), but it is already defined
(and used in various places) as a method in core-admin, so lets don't
change the API right now.
2018-01-12 05:27:56 +01:00
Marek Marczykowski-Górecki
626c764459
Merge remote-tracking branch 'qubesos/pr/47'
* qubesos/pr/47:
  qvm-device.rst: Document '--ro' option
  qvm-device/block: Alias '--ro' to '--option read-only=yes'
2018-01-11 01:57:57 +01:00
Marek Marczykowski-Górecki
97724a2e00
add QubesVM.connected_vms attribute
One more step to core-admin/core-admin-client API compatibility.
2018-01-11 01:55:54 +01:00
Rusty Bird
58cecf6b3f
qvm-device/block: Alias '--ro' to '--option read-only=yes'
It's quicker to type and compatible with pre-R4.0 habits/scripts.
2018-01-10 19:30:30 +00:00
Marek Marczykowski-Górecki
51a89a9e77
Merge remote-tracking branch 'qubesos/pr/44'
* qubesos/pr/44:
  Fix style else-return
  tests: update qvm-template-process and qvm-remove tests
  Add --force to manpage.
  Avoid cloning installed_by_rpm
  Print vm list before prompt
  Use --force instead of --yes
  Toggle installed_by_rpm in template tool
  Fix error message grammar
  Add --yes option and confirm prompt.
2018-01-06 14:54:32 +01:00
Christopher Laprise
297dec9c55 Merge branch 'tasket01' of https://github.com/tasket/qubes-core-admin-client into tasket01 2018-01-05 23:14:42 -05:00
Christopher Laprise
acd5f2e524
Fix style else-return 2018-01-05 23:13:24 -05:00
Marek Marczykowski-Górecki
75a433f07a
tests: update qvm-template-process and qvm-remove tests 2018-01-06 03:40:51 +01:00
Marek Marczykowski-Górecki
0e033645ad
backup: restore Qubes 3.x VMs as HVMs
Make use of better security of Qubes 4.x by using HVM by default. If
some VMs are incompatible with it (like MirageOS based), user can always
switch it to PV manually later.
2018-01-04 23:39:31 +01:00
Christopher Laprise
7a9b0c232c
Avoid cloning installed_by_rpm 2018-01-03 05:07:57 -05:00
Christopher Laprise
8b03c9cc9c
Print vm list before prompt 2018-01-02 01:51:01 -05:00
Christopher Laprise
91928ae0c6
Use --force instead of --yes 2018-01-02 01:33:20 -05:00
Christopher Laprise
f7d27cdcdc
Toggle installed_by_rpm in template tool 2018-01-02 01:19:06 -05:00
Christopher Laprise
ac7461d1e8
Fix error message grammar 2018-01-02 00:42:47 -05:00
Christopher Laprise
ed11346977
Add --yes option and confirm prompt. 2017-12-29 14:17:30 -05:00
Marek Marczykowski-Górecki
917df5a8c5
tools/qvm-ls: fix handling columns with underscore
Mangling column type was inconsistent, resulting in
KeyError('VIRT_MODE').
2017-12-29 03:24:22 +01:00
Marek Marczykowski-Górecki
c82d5b0a73
Make pylint happy
Updated pylint on Travis-CI is slightly stricter.
2017-12-22 18:38:24 +01:00
Marek Marczykowski-Górecki
796a3d43ae
backup: make pylint happy
Use 'vm_info' instead of restore_info['dom0'], as it is available inside
the loop. And break some lines to not exceed 80 chars..
2017-12-22 17:23:27 +01:00
Marek Marczykowski-Górecki
c2281fefc8
Merge remote-tracking branch 'qubesos/pr/43'
* qubesos/pr/43:
  Fix dom0-related issues
2017-12-22 17:19:59 +01:00
Christopher Laprise
c6bc4f05cb
Fix dom0-related issues 2017-12-11 10:16:53 -05:00
Marek Marczykowski-Górecki
bc9fd47aa0
Another approach for making qvm-shutdown nice for tests 2017-12-10 22:52:29 +01:00
Marek Marczykowski-Górecki
5944de1eed
Make pylint happy 2017-12-10 22:42:48 +01:00
Marek Marczykowski-Górecki
448fbb8309
make qvm-shutdown nice for unit tests
Make it deterministic.
2017-12-10 22:39:39 +01:00
Marek Marczykowski-Górecki
8ebcb438dd
tests: update tests for fixed verify_only handling 2017-12-10 22:39:19 +01:00
Marek Marczykowski-Górecki
3541b7d883
Merge remote-tracking branch 'qubesos/pr/42'
* qubesos/pr/42:
  verify-only avoid dom0 handler
  Fix verify-only
  Issue #3303
2017-12-10 22:24:55 +01:00
Christopher Laprise
d84423b0b2
verify-only avoid dom0 handler 2017-12-07 22:36:58 -05:00
Christopher Laprise
f86c640d65
Fix verify-only 2017-12-06 21:31:30 -05:00
Marek Marczykowski-Górecki
01114e828b
tests: fix tests after dropping unnecessary admin.label.List call 2017-12-05 22:56:37 +01:00
Marek Marczykowski-Górecki
5b7ea16808
tests: make filter-esc tests working also on travis
There stderr is not a tty, so filtering isn't turned on by default. Mock
os.isatty() to fake it.
2017-12-05 22:56:37 +01:00
qubesuser
14b3acec24
don't use ast.literal_eval, just directly convert to the desired type
It's slow and unnecessary
2017-12-05 22:40:40 +01:00
qubesuser
565bdf8549
don't lookup list of labels just to read VM properties
If qubesd returns a label name, we can just assume it's valid.

This makes qvm-ls take only one qubesd call.
2017-12-05 22:36:07 +01:00
Marek Marczykowski-Górecki
cb069367d5
Merge remote-tracking branch 'qubesos/pr/41'
* qubesos/pr/41:
  Remove dead code
2017-12-05 22:23:02 +01:00
Marek Marczykowski-Górecki
bd9016a2db
Merge remote-tracking branch 'qubesos/pr/40'
* qubesos/pr/40:
  Disable spinner if --raw-data
  Fix qvm-ls --raw-data
2017-12-05 22:22:30 +01:00
Marek Marczykowski-Górecki
afc9e645fa
tests: Update tests after fix for filtering stderr 2017-12-05 22:20:53 +01:00
Christopher Laprise
6fe5f8c0e7
Issue #3303 2017-12-01 18:21:59 -05:00
Jean-Philippe Ouellet
123aa28e87
Remove dead code 2017-11-30 06:57:03 -05:00
Jean-Philippe Ouellet
16ae4a64b6
Disable spinner if --raw-data 2017-11-30 06:48:03 -05:00
Jean-Philippe Ouellet
b52371f614
Fix qvm-ls --raw-data 2017-11-29 21:33:50 -05:00
Jean-Philippe Ouellet
87230fc042
Stop leaking terminal escapes via stderr
This restores Qubes R3.2 behavior

Before this patch, the following:

    qvm-run -p sys-firewall 'echo -e "\e[0;46mcyan!" >&2' | wc -l

leaks the escape sequences through to the dom0 terminal via stderr,
in this case demonstrated by the ability to change the text color while
it should be fixed to red.

This can also be abused with xterm reporting sequences to cause input
to be sent to the dom0 terminal. This is potentially a security issue.
2017-11-20 23:33:44 -05:00
Marek Marczykowski-Górecki
afe4eef15f
Merge remote-tracking branch 'qubesos/pr/38'
* qubesos/pr/38:
  Restore correct colors in verbose mode
  Fix setting stderr default coloring policy
2017-11-20 13:04:42 +01:00
Jean-Philippe Ouellet
6afe5a98c2
Restore correct colors in verbose mode
Restore stderr color when printing to stderr, not stdout color
2017-11-20 00:45:53 -05:00
Jean-Philippe Ouellet
57bf88aa30
Fix setting stderr default coloring policy
stderr default should be set if stderr is None, not if stdout is None
2017-11-20 00:44:07 -05:00
qubesuser
6e844940cc replace key in dir(self) with faster and better code 2017-11-10 16:31:45 +01:00
qubesuser
d08f1a58b7 don't import pkg_resources in the top of qubesadmin/utils.py
It's slow to import
2017-11-10 16:31:45 +01:00
qubesuser
dbd2f0ee06 remove format_doc and docutils import
This wastes 100-200ms loading and removing markup every run and none
of the strings contain any markup anyway...
2017-11-10 16:31:45 +01:00
Marek Marczykowski-Górecki
dc5afa56bf
Merge remote-tracking branch 'qubesos/pr/35'
* qubesos/pr/35:
  make qvm-run work for non-blocking stdin
2017-11-07 22:22:29 +01:00
qubesuser
cb644eb174 make qvm-run work for non-blocking stdin
The main process sometimes sets fd 1 to O_NONBLOCK, and since in the
terminal case fd 0 and 1 are the same fd, this also results in fd 0
being non-blocking, causing qvm-run to crash with EAGAIN.

So just make the code work for both blocking and non-blocking stdin.
2017-11-07 20:43:16 +01:00
Marek Marczykowski-Górecki
7f728e2dad
backup: fix handling labels in Qubes 4.0 backups
Labels can be referred as either id or name. Support both ways.

Fixes QubesOS/qubes-issues#3211
2017-10-29 02:58:37 +02:00
Marek Marczykowski-Górecki
7bcab46f96
tools/qvm-shutdown: fix handling shutdown timeout for multiple VMs
When some VM timeout on shutdown, the tool will try to kill all of them,
but at this point some of them may be already powered off (not all
hanged during shutdown, but only some). Handle this
situation instead of crashing. And add appropriate test.
2017-10-28 22:40:24 +02:00
Marek Marczykowski-Górecki
2fac77da6f
Document device attach options in man page
Fixes QubesOS/qubes-issues#3204
2017-10-24 03:24:43 +02:00
Marek Marczykowski-Górecki
7f269770d5
Merge branch 'fixes-20171019'
* fixes-20171019:
  tools: fix handling qvm-run --no-autostart
  backup: improve migrating templates from Qubes 3.x
2017-10-21 04:10:02 +02:00
Marek Marczykowski-Górecki
61ddccb6d6
Merge branch 'bug3179'
* bug3179:
  Drop log.DBusHandler
  vm: fix handling policy deny on admin.vm.List
2017-10-21 04:09:41 +02:00
Marek Marczykowski-Górecki
8981e71b88
tools: fix handling qvm-run --no-autostart
Fixes QubesOS/qubes-issues#3083
2017-10-19 14:55:33 +02:00
Marek Marczykowski-Górecki
f89d67c3e3
backup: improve migrating templates from Qubes 3.x
In Qubes 3.x any PV template had qrexec-agent and gui-agent installed.
Adjust features appropriately while restoring them.
2017-10-19 14:54:30 +02:00
Marek Marczykowski-Górecki
abc0d0063e
Fix DeviceInfo objects comparing
Do not crash if the other object is completely different type. Return
False ("unequal") instead.

This crashed preparing list of devices in qubes-vm-boot-from-device.

Fixes QubesOS/qubes-issues#3182
2017-10-17 20:40:16 +02:00
Marek Marczykowski-Górecki
a6ff459a1d
tests: multi-part volume in backup tests
Create on of VM's disk volumes big enough to split it into multiple
parts. To do that, add a test of uncompressed backup.

QubesOS/qubes-issues#3167
2017-10-16 04:11:04 +02:00
Marek Marczykowski-Górecki
513163276f
backup: do not try to read tar's stderr past EOF
If EOF is reached on tar's stderr, stop reading it, even if didn't found
expected data. Log this event.

This may happen when tar output some fatal error, instead of filelist.
2017-10-16 04:11:04 +02:00
Marek Marczykowski-Górecki
7a6e8d04b8
backup: improve restoring HVMs from Qubes 3.2
Set kernel to '' - boot from VM's own bootloader.
Keep it on MiniOS-based stubdomain - otherwise Windows would not boot.
2017-10-16 04:11:04 +02:00
Marek Marczykowski-Górecki
d1eab2d4f5
backup: update DispVM template property: template_for_dispvms
It was renamed from 'dispvm_allowed'.

QubesOS/qubes-issues#3047
2017-10-16 04:11:03 +02:00
Marek Marczykowski-Górecki
001b42f7d8
backup: fix name of meminfo-writer feature
It's 'service.meminfo-writer'.
2017-10-16 04:11:02 +02:00
Marek Marczykowski-Górecki
cbdc2170b4
tools: clarify that qvm-backup needs absolute path
Fixes QubesOS/qubes-issues#3066
2017-10-16 03:09:10 +02:00
Marek Marczykowski-Górecki
9cdb2a8152
backup: fix restoring template VMs
os.path.splitext fails on path without proper file base name, like
'/something/..000'. Use plain string methods (rsplit).

Fixes QubesOS/qubes-issues#3167
2017-10-16 03:04:59 +02:00
Marek Marczykowski-Górecki
654da7cb03
Drop log.DBusHandler
Packages had missing dependency on python-dbus. Since DBusHandler isn't
used anywhere, drop it, instead of introducing more dependencies.

Reported by @pietrushnic
QubesOS/qubes-issues#3179
2017-10-16 01:33:03 +02:00
Marek Marczykowski-Górecki
2f7d1ca476
vm: fix handling policy deny on admin.vm.List
vm.get_power_state() have specifically documented 'NA' state for cases
when it's unable to get VM's power state. Use this when qrexec policy
forbid checking it.

Reported by @pietrushnic
Fixes QubesOS/qubes-issues#3179
2017-10-16 01:32:56 +02:00
Marek Marczykowski-Górecki
0187588531
tools: adjust qvm-start message and logic, update tests
QubesOS/qubes-issues#3130
2017-10-08 18:17:03 +02:00
Marek Marczykowski-Górecki
bf4c9bacb4
Merge remote-tracking branch 'qubesos/pr/28'
* qubesos/pr/28:
  qvm-start: exit if domain running and no --skip-if-running
2017-10-08 17:14:47 +02:00
Marek Marczykowski-Górecki
98e39ca63b
vm: drop suspend and resume methods - not part of the Admin API 2017-10-04 15:26:57 +02:00
Marek Marczykowski-Górecki
559cc9b0d6
tools/qvm-start: fix starting a VM with cdrom image
1. Output of `losetup` command contains `\n` - strip it.
2. Provide read-only option - if device info hasn't propagated to qubesd
yet, it will not be set automatically.

Fixes QubesOS/qubes-issues#3146
2017-10-04 15:18:28 +02:00
Marek Marczykowski-Górecki
8476afc306
tools: finish 'qvm-volume revert' implementation, add tests
It wasn't aware of snapshot identifier, fix that. Also update to use
VM:VOLUME syntax, not POOL:VID.
2017-10-02 21:12:17 +02:00
Marek Marczykowski-Górecki
c87820fba8
Drop individual VM classes as python types completely
Since those are unused now, remove them from the source, so it is easier
to debug the code (avoid never matching isinstance(...)).
2017-10-02 21:12:16 +02:00
Marek Marczykowski-Górecki
b55f615942
Move vm.appvms to QubesVM
First, TemplateVM is not used anymore (see previous commit). Second,
don't harcode on client side that "only TemplateVM can be a template for
any VM" (which actually isn't true: AppVM can be a template for DispVM).
2017-10-02 21:12:16 +02:00
Marek Marczykowski-Górecki
edcaed537a
Always use QubesVM objects, instead of AppVM/TemplateVM etc
Very few calls at client side really needs VM class name. So, even in
non-blind mode use just QubesVM class, to avoid strange cases depending
on blind mode being enabled or not. Then, have VM class name in 'klass'
property. If known at object creation time, cache it, otherwise query
qubesd at first access.
2017-10-02 21:12:16 +02:00
Mindy Preston
76c4a6421b qvm-start: exit if domain running and no --skip-if-running 2017-09-27 17:15:52 -05:00
Marek Marczykowski-Górecki
ab9a57a544
tools: fix qvm-run --help
QubesOS/qubes-issues#
2017-09-20 22:53:30 +02:00
Marek Marczykowski-Górecki
0a06ad9152
events: ignore events from non-existing domains
It may happen that when client handle the event, domain no longer
exists. This is for example common for DispVMs, which get removed just
after shutdown.
This will cause some events to be dropped, but one can enable blind
mode, to get them anyway (because it will not cause KeyError, even if
domain is already removed).

QubesOS/qubes-issues#3100
2017-09-20 20:19:38 +02:00
Marek Marczykowski-Górecki
b28ddb6621
Implement "blind mode" to avoid listing objects
This allows to perform actions on objects (VM, storage etc), without
listing them. This is useful when calling VM have minimal permissions
and only selected actions are allowed.

This means that app.domains['some-name'] will not raise KeyError, even
when domain do not exists. But performing actual action (like
vm.start()) will fail in that case.
2017-09-20 20:18:59 +02:00
Marek Marczykowski-Górecki
5e2638ab5e
tools: restore qvm-start --cdrom and similar options
Booting a VM from cdrom require attaching the device before VM startup,
which is possible only in persistent mode. But for qvm-start --cdrom
adding a cdrom only temporarily, use new update_persistence() function
to convert the assignment to temporary one.

Fixes QubesOS/qubes-issues#3055
2017-09-05 08:33:47 +02:00
Marek Marczykowski-Górecki
1481dc4fb8
devices: client stub for DeviceCollection.update_persistent
QubesOS/qubes-issues#3055
2017-09-05 03:59:01 +02:00
Marek Marczykowski-Górecki
b895015274
tools: cleanup temporary files after qvm-template-postprocess 2017-09-05 03:57:55 +02:00
Marek Marczykowski-Górecki
336807e8da
tools: fix too long lines
QubesOS/qubes-issues#2983
2017-09-04 03:07:03 +02:00
Marek Marczykowski-Górecki
533fccfc10
Merge remote-tracking branch 'qubesos/pr/24'
* qubesos/pr/24:
  Fixed https://github.com/QubesOS/qubes-issues/issues/2983
2017-09-04 03:02:49 +02:00
Marek Marczykowski-Górecki
3c9e5f6630
Merge branch 'bug2986' 2017-08-30 17:33:32 +02:00
Marek Marczykowski-Górecki
0fa374264f
tools: add qvm-create --help-classes
List available VM classes

QubesOS/qubes-issues#3017
2017-08-30 16:54:24 +02:00
Marek Marczykowski-Górecki
0464a3ebfc
tools: implement qvm-create --root-move-from/--root-copy-from 2017-08-30 16:54:23 +02:00
Marek Marczykowski-Górecki
f98ea4a520
backup/restore: do not fail the whole restore when qvm-appmenus is missing
Fixes QubesOS/qubes-issues#2991
2017-08-30 16:00:00 +02:00
Marek Marczykowski-Górecki
6568d624cc
backup/restore: make backup header extraction faster
Abort tar process after extracting requested files - do not parse the
archive until the end (possibly tens of GB later).

Fixes QubesOS/qubes-issues#2986
2017-08-30 15:51:44 +02:00
Marek Marczykowski-Górecki
a260685bd1
tools: drop --delete and --unset aliases for --default option
This may be confiusing, for example one may think that
`qvm-prefs --unset vmname netvm` will make vmname network-disconnected.
This type of mistakes may have severe security consequence, so better
drop those option names.

QubesOS/qubes-issues#3002

cc @rootkovska
2017-08-12 22:33:36 +02:00
Marek Marczykowski-Górecki
5b7947b51a
Improve QubesDaemonNoResponseError error message
Include hint to look into dom0 logs

QubesOS/qubes-issues#3016
2017-08-12 15:15:52 +02:00
Marek Marczykowski-Górecki
188bc2799b
tests: add DispVM tests
Especially for one service call wrapper

QubesOS/qubes-issues#3016
2017-08-12 15:15:19 +02:00
Marek Marczykowski-Górecki
3d2d3a2974
vm/dispvm: fix dispvm.cleanup() when no service was called
In such a case (especially when running in dom0) there is nothing to
cleanup.

Fixes QubesOS/qubes-issues#3016
2017-08-12 15:15:06 +02:00
Marek Marczykowski-Górecki
596eb3d96c
tools/qvm-run: ignore --filter-esc/--no-filter-esc unless --pass-io is given
If no VM output is printed on terminal, those options doesn't make sense
anyway.

Fixes QubesOS/qubes-issues#3013
2017-08-12 14:19:41 +02:00
blackpit
6534f8c191 Fixed https://github.com/QubesOS/qubes-issues/issues/2983
qvm-create -l yellow backuptest-1-vm
qvm-create -l yellow backuptest-2-vm
echo -n passphrase >test.passphrase

qvm-backup --passphrase-file test.passphrase --yes `pwd` backuptest-1-vm backuptest-2-vm

qvm-remove backuptest-1-vm1 || true
qvm-remove backuptest-2-vm1 || true
qvm-backup-restore --rename-conflicting --passphrase-file test.passphrase qubes-2017-08-09T165253 backuptest-1-vm

qvm-remove backuptest-1-vm1 || true
qvm-remove backuptest-2-vm1 || true
qvm-backup-restore --rename-conflicting --passphrase-file test.passphrase qubes-2017-08-09T165253 backuptest-2-vm
2017-08-09 19:43:53 +02:00
Marek Marczykowski-Górecki
414be0945d
tools/qvm-device: list attach options 2017-08-09 04:04:27 +02:00
Marek Marczykowski-Górecki
430ff342d4
tools/qvm-run: do not use os.set_blocking
It's available only in python >= 3.5, but we do support tools on python
3.4 (Debian jessie).
2017-08-09 04:04:26 +02:00
Marek Marczykowski-Górecki
7d25f1bf2b
app: add VMCollection.values()
Let it behave more like a dict()
2017-08-09 04:04:26 +02:00
Marek Marczykowski-Górecki
37ae76823b
tools: add qvm-run --dispvm option
Add option to uniformly start new DispVM from either VM or Dom0. This
use DispVMWrapper, which translate it to either qrexec call to $dispvm,
or (in dom0) to appropriate Admin API call to create fresh DispVM
first.
This require abandoning registering --all and --exclude by
QubesArgumentParser, because we need to add --dispvm mutually exclusive
with those two. But actually handling those two options is still done by
QubesArgumentParser.

This also updates man page and tests.

Fixes QubesOS/qubes-issues#2974
2017-08-06 20:44:55 +02:00
Marek Marczykowski-Górecki
9bb59cdd20
vm: add DispVMWrapper for calling a single service in new DispVM
This is a wrapper to use `$dispvm` target of qrexec call, just like any
other service call in qubesadmin module - using vm.run_service().
When running in dom0, qrexec-client-vm is not available, so DispVM needs
to be created "manually", using appropriate Admin API call
(admin.vm.CreateDisposable).

QubesOS/qubes-issues#2974
2017-08-06 12:22:47 +02:00
Marek Marczykowski-Górecki
50bd9f5fab
tools/qvm-run: fix handling small data blocks
When data block is smaller than 4096 (and no EOF is reached), python's
io.read() will call read(2) again to get more data. This may deadlock if
the other end of connection will write anything only after receiveing
data (which is the case for qubes.Filecopy).
Disable this buffering by using syscall wrappers directly. To not affect
performance that much, increase buffer size to 64k.

Fixes QubesOS/qubes-issues#2948
2017-08-02 02:43:03 +02:00
Marek Marczykowski-Górecki
c4460751a9
tools/qvm-start-gui: do not start stubdomain GUI for VMs with gui-agent 2017-07-30 18:54:08 +02:00
Marek Marczykowski-Górecki
f48321dd98
Merge branch 'devel-6'
* devel-6:
  qvm-ls: fix total VM size reporting
  doc: update manpage of qvm-service
  tools: qvm-service tool
  tests: too much copy&paste
  features: serialize True as '1'
  tools/qvm-start-gui: add --force-stubdomain options
  tools/qvm-shutdown: fix help message
  tools/qvm-shutdown: drop --force option, it isn't supported anymore
2017-07-29 05:28:57 +02:00
Marek Marczykowski-Górecki
f25321bdcc
Merge branch 'events2'
* events2:
  events: add variable Admin API method name
2017-07-29 05:28:37 +02:00
Marek Marczykowski-Górecki
9210048673
backup/restore: add option to ignore size limit
Allow to restore backup which have miscalculated VMs size, but otherwise
is good.
2017-07-29 05:13:46 +02:00
Marek Marczykowski-Górecki
7db2ed82ea
qvm-ls: fix total VM size reporting
There is no vm.storage object in qubesadmin module.
2017-07-29 04:56:20 +02:00
Marek Marczykowski-Górecki
213760f263
backup/restore: improve error reporting 2017-07-29 04:48:46 +02:00
Marek Marczykowski-Górecki
9c5531c5ad
events: add variable Admin API method name
Add support for differnet methods, not only admin.Events. For example
admin.vm.Stats also return events.
2017-07-28 22:28:27 +02:00
Marek Marczykowski-Górecki
18153652f3
tools: qvm-service tool
This really use features, but keep compatibility with Qubes 3.x

Fixes QubesOS/qubes-issues#1227
2017-07-28 14:24:04 +02:00
Marek Marczykowski-Górecki
1000d7902d
tests: too much copy&paste 2017-07-28 13:56:39 +02:00
Marek Marczykowski-Górecki
0fae70be53
features: serialize True as '1'
Do the same as core-admin code.
2017-07-28 13:56:05 +02:00
Marek Marczykowski-Górecki
416ee0bd22
tools/qvm-start-gui: add --force-stubdomain options
Sometimes it's useful to access emulated VGA, without rebooting the VM
in debug mode
2017-07-27 19:17:47 +02:00
Marek Marczykowski-Górecki
5b0c8e84d8
tools/qvm-shutdown: fix help message 2017-07-27 19:17:47 +02:00
Marek Marczykowski-Górecki
5d0bd4f6dc
tools/qvm-shutdown: drop --force option, it isn't supported anymore
Admin API does not allow this action.
2017-07-27 19:17:47 +02:00
Marek Marczykowski-Górecki
2d5d9d6d7d
tools: add qvm-backup tool
New qvm-backup tool can either use pre-existing backup profile
(--profile), or - when running in dom0 - can create new one based on
used options (--save-profile).

This commit add a tool itself, update its man page, and add tests for
it.

Fixes QubesOS/qubes-issues#2931
2017-07-21 03:58:18 +02:00
Marek Marczykowski-Górecki
d8af76ed60
backup: move BackupRestore class and helpers to 'restore' submodule
This breaks cyclic imports and also allow cleaner separation between
backup make and restore code.

No functional change.
2017-07-21 03:54:04 +02:00
Marek Marczykowski-Górecki
8d884a52e6
tests: disable slow tests unless ENABLE_SLOW_TESTS=1 is set 2017-07-21 03:54:04 +02:00
Marek Marczykowski-Górecki
ea47701fe6
tools/qvm-backup-restore: fix restoring only specific VMs
Related to QubesOS/qubes-issues#2924
2017-07-21 03:54:04 +02:00
Marek Marczykowski-Górecki
c50fc21e44
tests: qvm-backup-restore tool tests
Very simple one, but also fix reporting errors detected by tests.
2017-07-21 03:54:04 +02:00
Marek Marczykowski-Górecki
3c9fb8dbac
tools/qvm-volume: fix default action handling 2017-07-21 03:10:02 +02:00
Marek Marczykowski-Górecki
ae0729fb53
storage: drop 'internal' volume property
Since external block devices use Devices API now, it isn't useful
anymore.

QubesOS/qubes-issues#2256
2017-07-21 03:10:01 +02:00
Marek Marczykowski-Górecki
c736395432
tools/qvm-backup-restore: fix default list of VMs to restore
By default restore all of them, not only the ones named "[" or "]"
(which are invalid name).

Fixes QubesOS/qubes-issues#2924
2017-07-19 23:52:11 +02:00
Marek Marczykowski-Górecki
756235d4f3
Change 'hvm' property to 'virt_mode'
QubesOS/qubes-issues#2912
2017-07-18 04:22:34 +02:00
Marek Marczykowski-Górecki
7b9ee45c07
Choose QubesLocal or QubesRemote based on /etc/qubes-release presence
Do not check for qubesd socket (at module import time), because if not
running at this precise time, it will lead to wrong choice. And a weird
error message in consequence (looking for qrexec-client-vm in dom0).

Fixes QubesOS/qubes-issues#2917
2017-07-18 01:58:33 +02:00
Marek Marczykowski-Górecki
0c0b625a70
Merge branch 'devel-backup' 2017-07-18 01:49:37 +02:00
Marek Marczykowski-Górecki
f058c48c92
Merge branch 'devel-2-qvm-run-1'
* devel-2-qvm-run-1:
  Make pylint happy
  tools/qvm-run: fix handling EOF
  tests: mark qvm-run tests with "expected failure"
  tools/qvm-run: fix handling copying stdin to the process
2017-07-18 01:49:16 +02:00
Marek Marczykowski-Górecki
5178029a3c
Make pylint happy 2017-07-18 01:32:06 +02:00
Marek Marczykowski-Górecki
706cecd60d
tools/qvm-run: fix handling EOF 2017-07-18 01:12:43 +02:00
Marek Marczykowski-Górecki
40a1769806
tests: mark qvm-run tests with "expected failure"
since qvm-run use multiprocessing.Process now, stdin sent to it is
processed in separate process and doesn't come back to
TestApp.actual_calls (self.app). Annotate tests for now, to be fixed
later.
2017-07-18 01:03:57 +02:00
Marek Marczykowski-Górecki
e7ee06936a
tools/qvm-backup-restore: handle VMs selection, not only exclusion
QubesOS/qubes-issues#1214
2017-07-17 23:34:03 +02:00
Marek Marczykowski-Górecki
ce2215c603
backup: improve error logging
Include VM and volume name in data-related error mesages.

QubesOS/qubes-issues#1214
2017-07-17 23:32:31 +02:00
Marek Marczykowski-Górecki
f2fa613dce
backup: use 'cat' instead of read-write loop in python
The most important part is fixing resize handling - call size_func
before data_func, but after tar gets initial data (and output file
size).
But other than that, it makes the process a little faster.

QubesOS/qubes-issues#1214
2017-07-17 23:30:37 +02:00
Marek Marczykowski-Górecki
96d4a2f066
backup: change 'hvm' property to 'virt_mode'
QubesOS/qubes-issues#2912
2017-07-17 20:40:08 +02:00
Marek Marczykowski-Górecki
ced735b476
backup: do not show full stacktrace to the user
Opt for a simple one-liner error messages, instead of meaningless stack
trace (it's most of the time about qubesd responding with error, so the
stack trace of actual problem is elsewhere).
2017-07-17 20:28:23 +02:00
Marek Marczykowski-Górecki
ca399c1a5a
app: call admin.vm.volume.Import as root
This is needed to write LVM data.
2017-07-17 20:28:23 +02:00
Marek Marczykowski-Górecki
f0151d73b3
tools: add qvm-backup-restore
Frontend tool for backup restore code.

Fixes QubesOS/qubes-issues#1214
2017-07-17 20:28:22 +02:00
Marek Marczykowski-Górecki
137e1ed877
tests: backup: add firewall.xml and appmenus checking 2017-07-17 20:28:22 +02:00
Marek Marczykowski-Górecki
51f77d5834
firewall: fix handling DstHost.prefixlen=0
Do not silently convert it into 32 or 128 netmask. And also do not
include it actual rule (it's no-op check).
2017-07-17 20:28:22 +02:00
Marek Marczykowski-Górecki
f1036c27a7
backup: add firewall and appmenus list handling 2017-07-17 20:28:21 +02:00
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
268a3453a9
backup: initial support for backup restore over Admin API
The code is mostly copied from core-admin.

QubesOS/qubes-issues#1214
2017-07-17 20:24:34 +02:00
Marek Marczykowski-Górecki
66f2e9c889
Merge remote-tracking branch 'qubesos/pr/11'
* qubesos/pr/11:
  added helper function updates_vms_status
2017-07-15 22:01:04 +02:00
Marek Marczykowski-Górecki
68ed06a200
Don't try to set 'created-by-' tag when cloning VM
This tag can't be set from outside of qubesd.
2017-07-14 04:14:46 +02:00
Marek Marczykowski-Górecki
941b553b81
tools/qvm-run: fix handling copying stdin to the process
Launch stdin copy loop in a separate process (multiprocessing.Process)
and terminate it when target process is terminated.
Another idea here was threads, but there is no API to kill a thread
waiting on read().
2017-07-08 00:11:15 +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
b35303ff62
events: fix cleanup function in qrexec case
qrexec-client-vm process may be already dead, don't treat this as an
error.
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
389252f386
tools: handle shutdown order in qvm-shutdown
VMs can have runtime dependencies - for example it isn't possible to
shutdown netvm used by some other running VM(s). Since client-side tools
may not have full knowledge about rules enforcing those dependencies
(for example may not have access to 'netvm' property), implement
best-effort approach:
1. Try to shutdown all requested VMs
2. For those where shutdown request succeed, wait for actual shutdown
3. For others - go back to step 1

And loop until all VMs are shutdown, or all shutdown requests fails.
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
43ef244eaa
vm: make QubesVM objects hashable 2017-07-06 22:01:16 +02:00
Marek Marczykowski-Górecki
a2d9303ea9
app: fix policy deny reporting when running in VM
qrexec-client-vm non-zero exit code means policy have denied the call.
Treat this exactly the same as empty response (in dom0 case).
2017-07-05 14:16:31 +02:00
Marek Marczykowski-Górecki
d8f018eb95
tools: clarify help in qvm-template-postprocess 2017-07-05 14:16:31 +02:00
Marek Marczykowski-Górecki
7c9699cd87
tools: split calling qubes.PostInstall service to a separate function
The code is long enough to warrant separate function (suggested by
pylint).
2017-07-05 14:16:31 +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
ade5083e5e
app: do not clone 'uuid' property
Cloned VM have new UUID
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
Marta Marczykowska-Górecka
9174d8c378
added helper function updates_vms_status 2017-06-25 22:09:34 +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
0012eb3ac6
tools/qvm-template-postprocess: improve error handling
Don't fail the whole process when "just" appmenus import fails.
But if data import fails, remove the VM

Also update for vm.run_service_for_stdio raising CalledProcessError.
2017-06-25 18:22:06 +02:00