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

Fixes, improvements #109

Merged
merged 30 commits into from
Jun 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
866d908
qubesd-query-fast: fix compile warnings, enable -Werror
marmarek May 29, 2017
9bb5054
ext: BlockDevices extension
marmarek May 29, 2017
b5a4573
storage: remove DomainPool
marmarek May 29, 2017
b08574a
api/internal: make GetSystemInfo not crash on not set default DispVM
marmarek May 30, 2017
257c8c0
devices : make DeviceInfo sortable
marmarek May 30, 2017
05f70b8
rpm: don't set default-kernel at installation time
marmarek May 30, 2017
ae66d29
Cleanup qubes-block-cleaner from one more place
marmarek May 31, 2017
0816f00
systemd: use appropriate meminfo-writer service for dom0
marmarek May 31, 2017
79a8d9c
systemd: fix [email protected] - qvm-start no longer have --no-guid arg
marmarek May 31, 2017
1f86c92
rpm: depend on linux-stubdom package
marmarek May 31, 2017
018877a
vm: avoid starting the same VM multiple times simultaneously
marmarek Jun 1, 2017
5d3204c
vm: remove prepare_dvm parameter from methods and events
marmarek Jun 1, 2017
1ed0b14
vm: make vm.hvm=True by default
marmarek Jun 1, 2017
d5cd58d
templatevm: set default netvm to None for templates
marmarek Jun 1, 2017
4c4f903
vm: change kernel=None to kernel=''
marmarek Jun 2, 2017
f80fddf
vm: restore code for suspending domains with PCI devices
marmarek Jun 2, 2017
05ba73b
api/internal: add methods for handling host suspend
marmarek Jun 2, 2017
43fd1d7
tools/qubesd-query: add option to report failure with exit code
marmarek Jun 2, 2017
28737d1
Migrate qubes.NotifyTools, qubes.FeaturesRequest, qubes.NotifyUpdates
marmarek Jun 3, 2017
63c23c8
vm: reduce code duplication
marmarek Jun 3, 2017
04fd2ff
vm: adjust VM's root volume when changing its template
marmarek Jun 3, 2017
313d742
tests: remove obsolete tests, formatting
marmarek Jun 3, 2017
89e025c
vm: make vm.get_power_state() return 'Halted' in offline_mode
marmarek Jun 3, 2017
67fcda2
tests: basic tests for AppVM
marmarek Jun 3, 2017
fa1da42
vm/adminvm: don't base AdminVM on QubesVM
marmarek Mar 31, 2017
26f25ae
vm/mix/net: remove cleanup_vifs
marmarek Jun 6, 2017
e8c3039
vm/adminvm: fix str(AdminVM) after changing its base
marmarek Jun 12, 2017
ee442c7
api/misc: integrate qubes.NotifyTools logic with qubes.FeaturesRequest
marmarek Jun 12, 2017
caa03a9
vm/qubesvm: simplify 'None' kernel handling
marmarek Jun 12, 2017
37245ac
vm: change vm.updates_available to a 'updates-available' feature
marmarek Jun 12, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ endif
cp qubes-rpc/qubes.GetRandomizedTime $(DESTDIR)/etc/qubes-rpc/
cp qubes-rpc/qubes.NotifyTools $(DESTDIR)/etc/qubes-rpc/
cp qubes-rpc/qubes.NotifyUpdates $(DESTDIR)/etc/qubes-rpc/
cp qubes-rpc/qubes-notify-updates $(DESTDIR)/usr/libexec/qubes/
cp qubes-rpc/qubes-notify-tools $(DESTDIR)/usr/libexec/qubes/
install qubes-rpc/qubesd-query-fast $(DESTDIR)/usr/libexec/qubes/
for method in $(ADMIN_API_METHODS_SIMPLE); do \
ln -s ../../usr/libexec/qubes/qubesd-query-fast \
Expand Down
6 changes: 6 additions & 0 deletions doc/manpages/qubesd-query.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ Options
Send empty payload. Do not attempt to read anything from standard input, but
send the request immediately.

.. option:: --fail

Exit with non-0 exit code when qubesd response is not-OK. By default the tool
will exit with 0 when request is successfully delivered to qubesd, regardless
of response.

Description
-----------

Expand Down
2 changes: 1 addition & 1 deletion linux/systemd/qubes-core.service
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ ExecStop=-/usr/bin/killall qubesdb-daemon

[Install]
WantedBy=multi-user.target
Also=qubes-block-cleaner.service qubes-meminfo-writer.service qubes-qmemman.service
Also=qubes-meminfo-writer-dom0.service qubes-qmemman.service
Alias=qubes_core.service
2 changes: 1 addition & 1 deletion linux/systemd/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Before=systemd-user-sessions.service
[Service]
Type=oneshot
Environment=DISPLAY=:0
ExecStart=/usr/bin/qvm-start --no-guid --skip-if-running %i
ExecStart=/usr/bin/qvm-start --skip-if-running %i
Group=qubes
RemainAfterExit=yes

Expand Down
2 changes: 1 addition & 1 deletion qubes-rpc/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CFLAGS=-O3
CFLAGS=-O2 -g -Wall -Werror -Wextra

all: qubesd-query-fast

Expand Down
94 changes: 0 additions & 94 deletions qubes-rpc/qubes-notify-tools

This file was deleted.

92 changes: 0 additions & 92 deletions qubes-rpc/qubes-notify-updates

This file was deleted.

15 changes: 3 additions & 12 deletions qubes-rpc/qubes.FeaturesRequest
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
#!/usr/bin/env python2
#!/bin/sh

import os
import qubes

PREFIX = '/features-request/'

app = qubes.Qubes()
vm = app.domains[os.environ['QREXEC_REMOTE_DOMAIN']]
vm.fire_event('features-request',
untrusted_features={key[len(PREFIX):]: vm.qdb.read(key)
for key in vm.qdb.list(PREFIX)})
app.save()
exec /usr/bin/qubesd-query -c /var/run/qubesd.misc.sock -e --fail \
"$QREXEC_REMOTE_DOMAIN" qubes.FeaturesRequest dom0 "" >/dev/null 2>&1
5 changes: 4 additions & 1 deletion qubes-rpc/qubes.NotifyTools
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
/usr/libexec/qubes/qubes-notify-tools
#!/bin/sh

exec /usr/bin/qubesd-query -c /var/run/qubesd.misc.sock -e --fail \
"$QREXEC_REMOTE_DOMAIN" qubes.NotifyTools dom0 "" >/dev/null 2>&1
5 changes: 4 additions & 1 deletion qubes-rpc/qubes.NotifyUpdates
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
/usr/libexec/qubes/qubes-notify-updates
#!/bin/sh

exec /usr/bin/qubesd-query -c /var/run/qubesd.misc.sock --fail \
"$QREXEC_REMOTE_DOMAIN" qubes.NotifyUpdates dom0 "" >/dev/null 2>&1
4 changes: 2 additions & 2 deletions qubes-rpc/qubesd-query-fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define QUBESD_SOCKET "/var/run/qubesd.sock"

void write_wrapper(int fd, char *data, size_t len) {
int written = 0;
size_t written = 0;
int ret;
while (written < len) {
ret = write(fd, data+written, len-written);
Expand Down Expand Up @@ -36,7 +36,7 @@ int main(int argc, char **argv) {
service_name++;

if (!source_domain || !target_domain || !service_name || argc > 2) {
fprintf(stderr, "Usage: %s [service-argument]\n");
fprintf(stderr, "Usage: %s [service-argument]\n", argv[0]);
fprintf(stderr, "\n");
fprintf(stderr, "Expected environment variables:\n");
fprintf(stderr, " - QREXEC_REMOTE_DOMAIN - source domain for the call\n");
Expand Down
76 changes: 75 additions & 1 deletion qubes/api/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@

import asyncio
import json
import subprocess

import qubes.api
import qubes.api.admin
import qubes.vm.adminvm
import qubes.vm.dispvm


Expand All @@ -51,7 +53,7 @@ def getsysteminfo(self):
'type': domain.__class__.__name__,
'dispvm_allowed': getattr(domain, 'dispvm_allowed', False),
'default_dispvm': (str(domain.default_dispvm) if
domain.default_dispvm else None),
getattr(domain, 'default_dispvm', None) else None),
'icon': str(domain.label.icon),
} for domain in self.app.domains
}}
Expand Down Expand Up @@ -107,3 +109,75 @@ def vm_volume_import_end(self, untrusted_payload):

if not success:
raise qubes.exc.QubesException('Data import failed')

@qubes.api.method('internal.SuspendPre', no_payload=True)
@asyncio.coroutine
def suspend_pre(self):
'''
Method called before host system goes to sleep.

:return:
'''

# first notify all VMs
processes = []
for vm in self.app.domains:
if isinstance(vm, qubes.vm.adminvm.AdminVM):
continue
if vm.is_running():
proc = yield from vm.run_service(
'qubes.SuspendPreAll', user='root',
stdin=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
processes.append(proc)

# FIXME: some timeout?
if processes:
yield from asyncio.wait([p.wait() for p in processes])

coros = []
# then suspend/pause VMs
for vm in self.app.domains:
if isinstance(vm, qubes.vm.adminvm.AdminVM):
continue
if vm.is_running():
coros.append(vm.suspend())
if coros:
yield from asyncio.wait(coros)

@qubes.api.method('internal.SuspendPost', no_payload=True)
@asyncio.coroutine
def suspend_post(self):
'''
Method called after host system wake up from sleep.

:return:
'''

coros = []
# first resume/unpause VMs
for vm in self.app.domains:
if isinstance(vm, qubes.vm.adminvm.AdminVM):
continue
if vm.get_power_state() in ["Paused", "Suspended"]:
coros.append(vm.resume())
if coros:
yield from asyncio.wait(coros)

# then notify all VMs
processes = []
for vm in self.app.domains:
if isinstance(vm, qubes.vm.adminvm.AdminVM):
continue
if vm.is_running():
proc = yield from vm.run_service(
'qubes.SuspendPostAll', user='root',
stdin=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
processes.append(proc)

# FIXME: some timeout?
if processes:
yield from asyncio.wait([p.wait() for p in processes])
Loading