Commit Graph

98 Commits

Author SHA1 Message Date
Marek Marczykowski-Górecki
869675c15c core: convert memory/cpu stats to libvirt API 2015-02-09 03:28:01 +01:00
Marek Marczykowski-Górecki
89f8f219bf core: changes in libvirt config for libvirt-1.2.12 2015-02-05 06:31:00 +01:00
Marek Marczykowski-Górecki
49d510dc65 core: prevent permissions error when VM was started by root
When VM is started by root, config file is created with root owner and
user has no write access to it. As the directory is user-writable,
delete the file first.

Conflicts:
	core-modules/000QubesVm.py
2015-01-30 01:39:57 +01:00
Marek Marczykowski-Górecki
52334bc414 core: fix firewall update code
Do not load qubes.xml again, it can cause race conditions between two
instances of the same VM objects.
Especially when VM is starting ProxyVM to which it is connected,
firewall rules could not be loaded.
2015-01-30 01:38:56 +01:00
Marek Marczykowski-Górecki
73301a67c8 core: fix vm.run(..., passio=False) handling
Long time ago passio=True was used to replace current process with
qrexec-client directly (qvm-run --pass-io was the called), but this
behaviour is not used anymore (qvm-run was the only user). And this
option was left untouched, with misleading name - one would assume that
using passio=False should disallow any I/O, but this isn't the case.

Especially qvm-sync-clock is calling clockvm.run('...', wait=True),
default value for passio=False. This causes to output data from
untrusted VM, without sanitising terminal sequences, which can be fatal.

This patch changes passio semantic to actually do what it means - when
set to True - VM process will be able to interact with
stdin/stdout/stderr. But when set to False, all those FDs will be
connected to /dev/null.

Conflicts:
	core-modules/000QubesVm.py
2015-01-30 01:38:52 +01:00
Marek Marczykowski-Górecki
7a3bce6c61 core: fix is_paused method 2014-11-29 02:58:47 +01:00
Marek Marczykowski-Górecki
592a4901c9 core: import monitorlayoutnotify instead of calling it as external script
Otherwise deadlock could happen - the script will try to get read lock
on qubes.xml, while the calling tool can already hold the lock. If that
was write lock (which is in case of qfile-daemon-dvm), the deadlock
occurs.
2014-11-21 21:45:03 +01:00
Marek Marczykowski-Górecki
1df73d31c6 core: xid is no longer local variable here 2014-11-19 12:50:32 +01:00
Marek Marczykowski-Górecki
479ac1e42d core: check libvirt error on specific connection
Not global last one.
2014-11-19 12:50:32 +01:00
Rafał Wojdyła
97c793ed16 QubesVm.run(): wait for client to exit on Windows 2014-11-19 12:50:31 +01:00
Marek Marczykowski-Górecki
3ba424e6ac Use VM name as argument to qrexec-client
This is the only place where ID was used - all other places uses name.
Linux qrexec-client accepts both ID and name, but sticking to one option
will simplify things (especially Windows qrexec-client/daemon).
2014-11-19 12:50:31 +01:00
Marek Marczykowski-Górecki
def58ab911 core: typo fix 2014-11-19 12:50:30 +01:00
Marek Marczykowski-Górecki
687e004b1d windows: workaround for windows "behavior" regarding parsing exec() arguments 2014-11-19 12:50:30 +01:00
Marek Marczykowski-Górecki
27b031c59f Check for None before calling method (VM rename fix) 2014-11-19 12:50:29 +01:00
Marek Marczykowski-Górecki
c3d9b1971a Handle the case when libvirt object doesn't exists for given VM
This can be some "virtual" VM (like dom0).
2014-11-19 12:50:29 +01:00
Marek Marczykowski-Górecki
7e355c5dad core: ignore error when PCI device already "detached"
This can be the case at startup, when all network devices are connected
to pciback module by initramfs.
2014-11-19 12:50:29 +01:00
Marek Marczykowski-Górecki
11047bf427 Use platform specific locking method
None of found existing portable locking module does support RW locks.
Use lowlevel system locking support - both Windows and Linux support
such feature.

Drop locking code in write_firewall_conf() b/c is is called with
QubesVmCollection lock held anyway.
2014-11-19 12:50:28 +01:00
Marek Marczykowski-Górecki
21c908b9b2 Move storage-related VM rename code to storage class 2014-11-19 12:50:28 +01:00
Marek Marczykowski-Górecki
396011e227 Fix initialization of storage class
Move it earlier - before first access to *_img attrs.
2014-11-19 12:50:27 +01:00
Marek Marczykowski-Górecki
7b5dd67b58 Completely move *_img attrs to QubesVmStorage class 2014-11-19 12:50:27 +01:00
Marek Marczykowski-Górecki
2457a705d0 Load Qubes DB python module only when needed.
This is temporary band aid for the python module problems.
This should also slightly speed up some tools (not all uses Qubes DB).
2014-11-19 12:50:27 +01:00
Marek Marczykowski-Górecki
66b39ac2a2 Typo fix in error message. 2014-11-19 12:50:26 +01:00
Marek Marczykowski-Górecki
4ae720956d Use file copy instead of symlink on Windows 2014-11-19 12:50:26 +01:00
Marek Marczykowski-Górecki
d91162e74d minor comment fix 2014-11-19 12:50:26 +01:00
Marek Marczykowski-Górecki
0a1f3d0a44 core: split VM images handling to separate class
This will ease handling different types of VMM (which can require
different image types, location etc).
2014-11-19 12:50:25 +01:00
Marek Marczykowski-Górecki
69d1ae645f Do not use qmemman when not present (installed) on particular VMM 2014-11-19 12:50:25 +01:00
Marek Marczykowski
457737b6cc QubesVm: ignore errors during debug VM config file creation
Currently <vm-dir>/<vm-name>.conf file is used only for debugging
purposes - the real one is passed directly to libvirt, without storing
on disk for it.
In some cases (e.g. qvm-clone) QubesVM.create_config_file() can be
called before VM directory exists and in this case it would fail.
Because it isn't critical fail in any means (the config file will be
recreated on next occasion) just ignore this error.

Final version most likely will have this part of code removed
completely.
2014-11-19 12:48:28 +01:00
Marek Marczykowski
f159f3e168 Use QubesDB instead of Xenstore.
Mostly done. Things still using xenstore/not working at all:
 - DispVM
 - qubesutils.py (especially qvm-block and qvm-usb code)
 - external IP change notification for ProxyVM (should be done via RPC
   service)
2014-11-19 12:48:28 +01:00
Marek Marczykowski
9393b5f931 Fix domain rename
libvirt_domain object needs to be recreated, so force it. Also fix
config path setting (missing extension) - create_config_file
uses it as custom config indicator (if such detected, VM settings -
especially name, would not be updated).
2014-11-19 12:48:27 +01:00
Marek Marczykowski
062c3afcf5 Remove unused 'source_template' parameter from some QubesVm internal functions 2014-11-19 12:48:27 +01:00
Marek Marczykowski
25ee58217d Set umask before possibly creating new files - make them group-writable 2014-11-19 12:48:27 +01:00
Marek Marczykowski
b3af858502 Indentation fix - check for custom config file 2014-11-19 12:48:27 +01:00
Marek Marczykowski
b8c62c0279 Wrap all VMM connection related object into QubesVMMConnection class
This makes easier to import right objects in submodules (only one
object). This also implement lazy connection - at first access, not at
module import, which speeds up tools, which doesn't need runtime
information (like qvm-prefs or qvm-service). In the future this will
ease migration from xenstore to QubesDB.

Also implement "offline mode" - operate on qubes.xml without connecting
to VMM - raise exception at such try.
This is needed to run tools during installation, where only minimal
set of services are started, especially no libvirt.
2014-11-19 12:48:26 +01:00
Marek Marczykowski
550d8cac68 Create permanent libvirt domain objects
Do not recreate them at each startup. This will save some time and also
solve some problems from invalidated libvirt handles after domain
shutdown (e.g. causes qubes-manager crashes).
This requires storing uuid in qubes.xml.
2014-11-19 12:48:26 +01:00
Marek Marczykowski
1fda0502ab Check for invalid XID 2014-11-19 12:48:26 +01:00
Marek Marczykowski
895ca0633d Fix current memory reporting 2014-11-19 12:48:26 +01:00
Marek Marczykowski
4f090cdb5e pass VM name to guid via cmdline 2014-11-19 12:48:26 +01:00
Marek Marczykowski
f3a7d5f6e6 Remove debug_console QubesVm.start() argument
It isn't working for a long time, so remove it to not confuse reader.
2014-11-19 12:47:00 +01:00
Marek Marczykowski
a880483092 Migration to libvirt - core part
Still not all code migrated, added appropriate TODO/FIXME comments.
2014-11-19 12:47:00 +01:00
Marek Marczykowski-Górecki
aa958eeff6 core: really quiet mode if vm.start()
Pass '-q' option to gui-daemon and qrexec-daemon.
2014-10-25 01:45:01 +02:00
Victor Lopez
bf2173073b Linux VM specific: maxmem limited by init mem
Check maxmem taking into account the minimum init memory that allows
that requested maximum memory.

Explanation:
Linux kernel needs space for memory-related structures created at boot.
If init_mem is just 400MB, then max_mem can't balloon above 4.3GB (at
which poing it yields "add_memory() failed: -17" messages and apps
crash), regardless of the max_mem_size value.

Based on Marek's findings and my tests on a 16GB PC, using several
processes like:
   stress -m 1 --vm-bytes 1g --vm-hang 100

result in the following points:
init_mem  ==> actual max memory
400             4300
700             7554
800             8635
1024            11051
1200            12954
1300            14038
1500            14045 <== probably capped on my 16GB system

The actual ratio of max_mem_size/init_mem is surprisingly constant at
10.79

If less init memory is set than that ratio allows, then the set
maxmem is unreachable and the VM becomes unstable (app crashes)

Based on qubes-devel discussion titled "Qubes Dom0 init memory against
Xen best practices?" at:
https://groups.google.com/d/msg/qubes-devel/VRqkFj1IOtA/UgMgnwfxVSIJ
2014-10-06 04:02:07 +02:00
Marek Marczykowski-Górecki
ed15e15f50 core: make create_on_disk verbose parameter optional 2014-10-01 03:50:55 +02:00
Marek Marczykowski-Górecki
9ad4e15c66 core: inherit default_user from template 2014-09-16 01:46:41 +02:00
Marek Marczykowski-Górecki
17cf9f7a9b Remove duplicated line 2014-09-16 01:33:40 +02:00
Marek Marczykowski-Górecki
355ed640b2 hvm: reserve memory for stubdom
Previously it was allocated from 50MB memory margin left by qmemman.
Which wasn't reliable enough.
2014-09-16 01:18:55 +02:00
Wojciech Zygmunt Porczyk
d7958625c6 core+modules: provide meaingful repr()s for some classes 2014-08-11 16:34:33 +02:00
Marek Marczykowski-Górecki
279dc78a02 core: do not reject already existing VMs with invalid name
It would break the system when the rules for names change. Warn instead.
2014-07-28 01:07:02 +02:00
Marek Marczykowski-Górecki
98540ac513 core: reject VM names longer than 31 chars 2014-07-28 01:00:51 +02:00
Wojciech Zygmunt Porczyk
b2162b1af9 Forbid renaming of RPM-borne VMs (mainly templates) (#839)
User can still clone VM and remove old via rpm/yum.
2014-06-26 13:55:35 +02:00
Marek Marczykowski-Górecki
44f38fe076 Declare file encoding for all python files, fill missing copyright headers
Without that, python do not accept UTF-8 even in comments.
2014-05-18 21:03:27 +02:00