[libvirt] [PATCH] Fix race condition reconnecting to vms & loading configs
Daniel P. Berrange
berrange at redhat.com
Tue Oct 29 14:01:56 UTC 2013
On Mon, Oct 28, 2013 at 11:52:50AM +0000, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
>
> 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 guets
>
> 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.
>
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---
> src/qemu/qemu_driver.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index c613967..9c3daad 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -816,8 +816,6 @@ qemuStateInitialize(bool privileged,
>
> conn = virConnectOpen(cfg->uri);
>
> - qemuProcessReconnectAll(conn, qemu_driver);
> -
> /* Then inactive persistent configs */
> if (virDomainObjListLoadAllConfigs(qemu_driver->domains,
> cfg->configDir,
> @@ -828,6 +826,7 @@ qemuStateInitialize(bool privileged,
> NULL, NULL) < 0)
> goto error;
>
> + qemuProcessReconnectAll(conn, qemu_driver);
>
> virDomainObjListForEach(qemu_driver->domains,
> qemuDomainSnapshotLoad,
Self-NACK.
The qemuProcessReconnectAll() method assumes that *only* live configs have
been loaded. Reordering this, makes it try to connect to all VMs, even
those which were never live.
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the libvir-list
mailing list