mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 09:26:03 +00:00
feat(computes): a host evacuates its chosen VMs to another host
The host's Instances page gets an Evacuate button. Its page lists the
host's VMs for a chosen destination: running ones ticked, shut-off ones
left to choose ("Also migrate the shut-off VMs"), and a VM with a disk
file the two hosts do not share refused with the reason, since it needs
a copy chosen on its own Migrate tab.
One "Evacuate host" job migrates them: a migrate job each (live with
auto converge; a shut-off VM offline), at most the chosen number at
once, so a VM that fails stays on the host and the rest go on. The
choice goes up to half the worker's slots, which a host's jobs may take,
less the evacuation's own. Cancelling it cancels the migrations that
run and starts no more. One evacuation runs at a time: it waits in a
worker slot, and several could leave none for their migrations. A VM
that left the host meanwhile is skipped (a migrate job takes the host it
is to leave from the evacuation and refuses another); a host whose record points
elsewhere since, or a worker lowered to one slot, stops it before the
next VM. A busy VM lets the others go first; one an uncertain job holds is
not waited for.
Migrations now hold the hosts' VM sets shared, so several migrate at
once; creates, clones, deletes and the VM list reconcile still wait for
them. A destination gone since the form was shown is refused, not
replaced by another. The uses of the NVRAM directory's pool take turns
(NVRAM_LOCK): two UEFI migrations at once would share a transient pool
that the first destroys under the second.
This commit is contained in:
parent
c9fef349d5
commit
d20254f757
18 changed files with 861 additions and 106 deletions
|
|
@ -194,6 +194,11 @@ UNREAD_DISKS = etree.XPath("devices/disk[@device='disk'][not(driver/@type='raw')
|
|||
"devices/disk[@device='disk'][not(driver/@type='raw')]/source/@dev")
|
||||
|
||||
|
||||
# One use of NVRAM_DIR's pool at a time (_nvram_pool), on every host: a copy
|
||||
# holds two hosts' pools, and locks per host taken by migrations both ways
|
||||
# could deadlock. Reentrant, as that copy takes it twice.
|
||||
NVRAM_LOCK = threading.RLock()
|
||||
|
||||
class wvmConnection(object):
|
||||
"""
|
||||
class representing a single connection stored in the Connection Manager
|
||||
|
|
@ -1041,7 +1046,13 @@ class wvmConnect(object):
|
|||
@contextlib.contextmanager
|
||||
def _nvram_pool(self):
|
||||
"""An active, refreshed pool on NVRAM_DIR: libvirt reads and deletes
|
||||
files only as volumes of a pool. A transient one when none exists."""
|
||||
files only as volumes of a pool. A transient one when none exists,
|
||||
destroyed after: one use at a time (NVRAM_LOCK), as another would
|
||||
take that pool for the host's and lose it midway."""
|
||||
with NVRAM_LOCK:
|
||||
yield from self._nvram_pool_unlocked()
|
||||
|
||||
def _nvram_pool_unlocked(self):
|
||||
pool = self.pool_at(NVRAM_DIR)
|
||||
if pool is not None:
|
||||
pool.refresh(0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue