Re: [libvirt] [PATCH V2 07/13] libxl: use job functions when cleaning up a domain

2014-02-19 Thread Daniel P. Berrange
On Wed, Feb 12, 2014 at 06:56:21PM -0700, Jim Fehlig wrote:
 When explicitly destroying a domain (libxlDomainDestroyFlags), or
 handling an out-of-band domain shutdown event, cleanup the domain
 in the context of a job.  Introduce libxlVmCleanupJob to wrap
 libxlVmCleanup in a job block.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
 
 V2:
   Introduce libxlVmCleanupJob and call it when needing libxlVmCleanup
   in a job block.
   Check libxlDomainObjEndJob() return value
 
  src/libxl/libxl_driver.c | 38 ++
  1 file changed, 30 insertions(+), 8 deletions(-)

ACK

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 :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH V2 07/13] libxl: use job functions when cleaning up a domain

2014-02-12 Thread Jim Fehlig
When explicitly destroying a domain (libxlDomainDestroyFlags), or
handling an out-of-band domain shutdown event, cleanup the domain
in the context of a job.  Introduce libxlVmCleanupJob to wrap
libxlVmCleanup in a job block.

Signed-off-by: Jim Fehlig jfeh...@suse.com
---

V2:
  Introduce libxlVmCleanupJob and call it when needing libxlVmCleanup
  in a job block.
  Check libxlDomainObjEndJob() return value

 src/libxl/libxl_driver.c | 38 ++
 1 file changed, 30 insertions(+), 8 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 36fc9f5..0c2c1d7 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -317,6 +317,26 @@ libxlVmCleanup(libxlDriverPrivatePtr driver,
 }
 
 /*
+ * Cleanup function for domain that has reached shutoff state.
+ * Executed in the context of a job.
+ *
+ * virDomainObjPtr should be locked on invocation
+ * Returns true if references remain on virDomainObjPtr, false otherwise.
+ */
+static bool
+libxlVmCleanupJob(libxlDriverPrivatePtr driver,
+  virDomainObjPtr vm,
+  virDomainShutoffReason reason)
+{
+if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_DESTROY)  0)
+return true;
+
+libxlVmCleanup(driver, vm, reason);
+
+return libxlDomainObjEndJob(driver, vm);
+}
+
+/*
  * Handle previously registered event notification from libxenlight.
  *
  * Note: Xen 4.3 removed the const from the event handler signature.
@@ -364,10 +384,11 @@ libxlDomainShutdownThread(void *opaque)
 reason = VIR_DOMAIN_SHUTOFF_SHUTDOWN;
 }
 libxl_domain_destroy(ctx, vm-def-id, NULL);
-libxlVmCleanup(driver, vm, reason);
-if (!vm-persistent) {
-virDomainObjListRemove(driver-domains, vm);
-vm = NULL;
+if (libxlVmCleanupJob(driver, vm, reason)) {
+if (!vm-persistent) {
+virDomainObjListRemove(driver-domains, vm);
+vm = NULL;
+}
 }
 break;
 case LIBXL_SHUTDOWN_REASON_REBOOT:
@@ -1561,10 +1582,11 @@ libxlDomainDestroyFlags(virDomainPtr dom,
 goto cleanup;
 }
 
-libxlVmCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED);
-if (!vm-persistent) {
-virDomainObjListRemove(driver-domains, vm);
-vm = NULL;
+if (libxlVmCleanupJob(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED)) {
+if (!vm-persistent) {
+virDomainObjListRemove(driver-domains, vm);
+vm = NULL;
+}
 }
 
 ret = 0;
-- 
1.8.1.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list