Re: [PATCH 07/11] libxl: use job functions in libxlDomainCoreDump

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07.02.2014 04:53, Jim Fehlig wrote:
Dumping a domain's core can take considerable time.  Use the
recently added job functions and unlock the virDomainObj while
dumping core.

Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxx>
---
  src/libxl/libxl_driver.c | 37 ++++++++++++++++++++++++++-----------
  1 file changed, 26 insertions(+), 11 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index a804b45..84d9ca3 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -2059,6 +2059,7 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
      libxlDomainObjPrivatePtr priv;
      virDomainObjPtr vm;
      virObjectEventPtr event = NULL;
+    bool remove_dom = false;
      bool paused = false;
      int ret = -1;

@@ -2070,9 +2071,12 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
      if (virDomainCoreDumpEnsureACL(dom->conn, vm->def) < 0)
          goto cleanup;

+    if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
+        goto cleanup;
+
      if (!virDomainObjIsActive(vm)) {
          virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not running"));
-        goto cleanup;
+        goto endjob;
      }

      priv = vm->privateData;
@@ -2084,38 +2088,41 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
                             _("Before dumping core, failed to suspend domain '%d'"
                               " with libxenlight"),
                             dom->id);
-            goto cleanup;
+            goto endjob;
          }
          virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_DUMP);
          paused = true;
      }

-    if (libxl_domain_core_dump(priv->ctx, dom->id, to, NULL) != 0) {
+    /* Unlock virDomainObj while dumping core */
+    virObjectUnlock(vm);
+    ret = libxl_domain_core_dump(priv->ctx, dom->id, to, NULL);
+    virObjectLock(vm);
+    if (ret != 0) {
          virReportError(VIR_ERR_INTERNAL_ERROR,
                         _("Failed to dump core of domain '%d' with libxenlight"),
                         dom->id);
-        goto cleanup_unpause;
+        ret = -1;
+        goto unpause;
      }

      if (flags & VIR_DUMP_CRASH) {
          if (libxlVmReap(driver, vm, VIR_DOMAIN_SHUTOFF_CRASHED) != 0) {
              virReportError(VIR_ERR_INTERNAL_ERROR,
                             _("Failed to destroy domain '%d'"), dom->id);
-            goto cleanup_unpause;
+            goto unpause;
          }

          event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
                                           VIR_DOMAIN_EVENT_STOPPED_CRASHED);
-        if (!vm->persistent) {
-            virDomainObjListRemove(driver->domains, vm);
-            vm = NULL;
-        }
+        if (!vm->persistent)
+            remove_dom = true;
      }

      ret = 0;

-cleanup_unpause:
-    if (vm && virDomainObjIsActive(vm) && paused) {
+unpause:
+    if (virDomainObjIsActive(vm) && paused) {
          if (libxl_domain_unpause(priv->ctx, dom->id) != 0) {
              virReportError(VIR_ERR_INTERNAL_ERROR,
                             _("After dumping core, failed to resume domain '%d' with"
@@ -2125,7 +2132,15 @@ cleanup_unpause:
                                   VIR_DOMAIN_RUNNING_UNPAUSED);
          }
      }
+
+endjob:
+    libxlDomainObjEndJob(driver, vm);
+
  cleanup:
+    if (remove_dom) {
+        virDomainObjListRemove(driver->domains, vm);
+        vm = NULL;
+    }
      if (vm)
          virObjectUnlock(vm);
      if (event)


Conditional ACK

Michal

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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]