]> xenbits.xensource.com Git - libvirt.git/commit
Fix race condition reconnecting to vms & loading configs
authorDaniel P. Berrange <berrange@redhat.com>
Mon, 28 Oct 2013 11:49:18 +0000 (11:49 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 30 Oct 2013 11:16:18 +0000 (11:16 +0000)
commitf26701f565525dd402df021d8923489e62412158
treec121f50a2d828b607510194ee4b814c505ef5b18
parent54a241122063094146f1bdec9fab38df5617fb68
Fix race condition reconnecting to vms & loading configs

The following sequence

 1. Define a persistent QMEU guest
 2. Start the QEMU guest
 3. Stop libvirtd
 4. Kill the QEMU process
 5. Start libvirtd
 6. List persistent guests

At the last step, the previously running persistent guest
will be missing. This is because of a race condition in the
QEMU driver startup code. It does

 1. Load all VM state files
 2. Spawn thread to reconnect to each VM
 3. Load all VM config files

Only at the end of step 3, does the 'virDomainObjPtr' get
marked as "persistent". There is therefore a window where
the thread reconnecting to the VM will remove the persistent
VM from the list.

The easy fix is to simply switch the order of steps 2 & 3.

In addition to this though, we must only attempt to reconnect
to a VM which had a non-zero PID loaded from its state file.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/qemu/qemu_driver.c
src/qemu/qemu_process.c