Commit Graph

10 Commits

Author SHA1 Message Date
Marek Marczykowski-Górecki
411e8b5323
qmemman: refresh domain list holding global_lock
Retrieve a domain list only after obtaining global lock. Otherwise an
outdated list may be used, when a domain was introduced in the meantime
(starting a new domain is done with global lock held), leading to #1389.

QubesOS/qubes-issues#1389
2016-01-14 04:34:53 +01:00
Marek Marczykowski-Górecki
3eccc3a633
qmemman: use try/finally to really release the lock
Currently not needed in practice, but a preparation for the next
commit(s).

QubesOS/qubes-issues#1389
2016-01-14 03:32:18 +01:00
Marek Marczykowski-Górecki
181eb3e764
qmemman: handle memory assigned to VM but not yet used
When VM got some memory assigned, balloon driver may not pick it up
immediatelly and the memory will still be seen as "free" by Xen, but VM
can use (request) it at any time. Qmemman needs to take care of such
memory (exclude it from "free" pool), otherwise it would redistribute it
to other domains, allowing the original domain to drain Xen memory pool.

Do this by redefining DomainState.memory_actual - it is now amount of
memory available to the VM (currently used, or possibly used). Then
calculate free memory by subtracting memory allocated but not used
(memory_target-memory_current).

Fixes QubesOS/qubes-issues#1389
2016-01-06 00:40:10 +01:00
Marek Marczykowski-Górecki
e30e802903
qmemman: add --debug option 2016-01-06 00:39:00 +01:00
qubesuser
9f04743388 qmemman: fix null reference bug 2015-12-05 17:25:33 +01:00
Marek Marczykowski-Górecki
fef8761f01
qmemman: improve check whether VM is still running
In some cases it may happen that qmemman or other application using
xenstore will re-create VM directory in xenstore just after VM was
destroyed. For example when multiple VMs was destroyed at the same time,
but qmemman will kick off just at first @releaseDomain event - other VMs
will still be there (at xenstore-list time). This means that qmemman
will consider them when redistributing memory (of just destroyed one),
so will update memory/target entry of every "running" VM. And at this
point it may recreate VM directory of another already destroyed VM.

Generally fixing this race condition would require running all the
operations (from xenstore-ls, to setting memory/target) in a single
xenstore transaction. But this can be lengthly process. And if any other
modification happens in the meantime, transaction will rejected and
qmemman would need to redo all the changes. Not worth the effort.

Fixes QubesOS/qubes-issues#1409
2015-11-27 20:00:33 +01:00
Wojtek Porczyk
fbdb2f07ac qmemman: add logging 2015-03-31 20:42:53 +02:00
Marek Marczykowski
4a4fb5e243 qmemman: change process model from forking to single process + sd_notify
Forking daemon after initializing hypervisor connection can cause
problems (and actually does in case of libvirt).
To notify systemd when daemon is ready use notify socket (previously it
was termination of parent process).
2014-11-19 12:47:00 +01: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
Marek Marczykowski
a84886db07 Move all files one level up 2013-03-16 19:56:51 +01:00