[libvirt] [PATCH] Refresh /etc/xen if inotify wasn't initialized

If libvirt was built against inotify, but an API user isn't using domain events (virsh, virt-manager), the xen xm driver doesn't poll /etc/xen for new config files. This means that domains created or deleted on other libvirt connections aren't reflected in the original connection (but they will show up for all newly opened connections). This causes newly created VMs to disappear from virt-manager < 0.8.0 once they are shutdown, since VMs were installed on a separate connection. The attached patch refreshes /etc/xen in all cases, unless inotify was successfully initialized (user is using domain events). Thanks, Cole

On Tue, Aug 04, 2009 at 12:29:02PM -0400, Cole Robinson wrote:
If libvirt was built against inotify, but an API user isn't using domain events (virsh, virt-manager), the xen xm driver doesn't poll /etc/xen for new config files. This means that domains created or deleted on other libvirt connections aren't reflected in the original connection (but they will show up for all newly opened connections). This causes newly created VMs to disappear from virt-manager < 0.8.0 once they are shutdown, since VMs were installed on a separate connection.
The attached patch refreshes /etc/xen in all cases, unless inotify was successfully initialized (user is using domain events).
Yeah, this is a serious bug and I prefer to push the fix, even if it's a bit large most of it is refactoring. So apply and commited, thanks for chasing the issue ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Tue, Aug 04, 2009 at 12:29:02PM -0400, Cole Robinson wrote:
If libvirt was built against inotify, but an API user isn't using domain events (virsh, virt-manager), the xen xm driver doesn't poll /etc/xen for new config files. This means that domains created or deleted on other libvirt connections aren't reflected in the original connection (but they will show up for all newly opened connections). This causes newly created VMs to disappear from virt-manager < 0.8.0 once they are shutdown, since VMs were installed on a separate connection.
The attached patch refreshes /etc/xen in all cases, unless inotify was successfully initialized (user is using domain events).
Thanks, Cole
diff --git a/src/xm_internal.c b/src/xm_internal.c index 9d021eb..c1188fe 100644 --- a/src/xm_internal.c +++ b/src/xm_internal.c @@ -122,6 +122,19 @@ struct xenUnifiedDriver xenXMDriver = { virReportErrorHelper(conn, VIR_FROM_XENXM, code, __FILE__, \ __FUNCTION__, __LINE__, fmt)
+static int xenInotifyActive(virConnectPtr conn) +{ + int ret; +#ifndef WITH_XEN_INOTIFY + ret = 0; +#else + xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData; + ret = (priv->inotifyWatch > 0); +#endif + + return ret; +}
THis will generate an unused variable warning on 'conn'. I'd prefer to have the conditional outside the fucntion, eg #ifndef WITH_XEN_INOTIFY static int xenInotifyActive(virConnectPtr conn ATTRIBUTE_UNUSED) { return 0; } #else static int xenInotifyActive(virConnectPtr conn) { xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData; return priv->inotifyWatch > 0; } #endif ACK to the rest of the patch Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Wed, Aug 05, 2009 at 10:52:03AM +0100, Daniel P. Berrange wrote:
On Tue, Aug 04, 2009 at 12:29:02PM -0400, Cole Robinson wrote:
If libvirt was built against inotify, but an API user isn't using domain events (virsh, virt-manager), the xen xm driver doesn't poll /etc/xen for new config files. This means that domains created or deleted on other libvirt connections aren't reflected in the original connection (but they will show up for all newly opened connections). This causes newly created VMs to disappear from virt-manager < 0.8.0 once they are shutdown, since VMs were installed on a separate connection.
The attached patch refreshes /etc/xen in all cases, unless inotify was successfully initialized (user is using domain events).
Thanks, Cole
diff --git a/src/xm_internal.c b/src/xm_internal.c index 9d021eb..c1188fe 100644 --- a/src/xm_internal.c +++ b/src/xm_internal.c @@ -122,6 +122,19 @@ struct xenUnifiedDriver xenXMDriver = { virReportErrorHelper(conn, VIR_FROM_XENXM, code, __FILE__, \ __FUNCTION__, __LINE__, fmt)
+static int xenInotifyActive(virConnectPtr conn) +{ + int ret; +#ifndef WITH_XEN_INOTIFY + ret = 0; +#else + xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData; + ret = (priv->inotifyWatch > 0); +#endif + + return ret; +}
THis will generate an unused variable warning on 'conn'. I'd prefer to have the conditional outside the fucntion, eg
#ifndef WITH_XEN_INOTIFY static int xenInotifyActive(virConnectPtr conn ATTRIBUTE_UNUSED) { return 0; } #else static int xenInotifyActive(virConnectPtr conn) { xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData; return priv->inotifyWatch > 0; } #endif
Argh I missed that comment, and of course I have inotify activated, I'm applying this separately thanks ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (3)
-
Cole Robinson
-
Daniel P. Berrange
-
Daniel Veillard