[libvirt] [libvirt-glib 2/2] Remove transient domain reference on shutdown
Christophe Fergeau
cfergeau at redhat.com
Tue Nov 29 22:51:38 UTC 2011
On Tue, Nov 29, 2011 at 05:00:54PM +0200, Zeeshan Ali (Khattak) wrote:
> From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>
>
> This patch doesn't work cause virDomainIsPersistent() is returning '1'
> on transient domain for some reason. Send it to list to get some help.
> ---
> libvirt-gobject/libvirt-gobject-connection.c | 9 +++++++++
> 1 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c
> index b647bfa..1b0259e 100644
> --- a/libvirt-gobject/libvirt-gobject-connection.c
> +++ b/libvirt-gobject/libvirt-gobject-connection.c
> @@ -362,6 +362,15 @@ static int domain_event_cb(virConnectPtr conn G_GNUC_UNUSED,
> g_signal_emit_by_name(gdom, "stopped::from-snapshot");
> else
> g_warn_if_reached();
> +
> + if (!virDomainIsPersistent(dom)) {
> + g_mutex_lock(priv->lock);
> + g_hash_table_steal(priv->domains, uuid);
> + g_mutex_unlock(priv->lock);
> +
> + g_signal_emit(gconn, signals[VIR_DOMAIN_REMOVED], 0, gdom);
> + g_object_unref(gdom);
> + }
> break;
Not directly related to this patch since the same pattern is already
present in domain_event_cb, but this can race with gvir_connection_close,
ie gdom is looked up in domain_event_cb, gvir_connection_close frees
priv->domains and its content, domain_event_cb resumes and happily uses
gdom which it hasn't reffed and priv->domains. Something similar can also
happen between domain_event_cb and gvir_connection_fetch_domains.
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20111129/85ce17d9/attachment-0001.sig>
More information about the libvir-list
mailing list