]> xenbits.xensource.com Git - libvirt.git/commitdiff
sanlock: code movement in virLockManagerSanlockAcquire
authorMartin Kletzander <mkletzan@redhat.com>
Mon, 12 May 2014 09:38:08 +0000 (11:38 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Tue, 13 May 2014 08:51:43 +0000 (10:51 +0200)
Just move some code around for future patches to ease the review.
With this patch there is no need for drastic cleanup path later.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
src/locking/lock_driver_sanlock.c

index 7e4258dcbe071f778c32f52a758e0b4e4af8fc8c..01441a06e2dfe895b3400457cd6c5596219d3cdb 100644 (file)
@@ -896,31 +896,6 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock,
     if (VIR_ALLOC(opt) < 0)
         return -1;
 
-    /* sanlock doesn't use owner_name for anything, so it's safe to take just
-     * the first SANLK_NAME_LEN - 1 characters from vm_name */
-    ignore_value(virStrncpy(opt->owner_name, priv->vm_name,
-                            SANLK_NAME_LEN - 1, SANLK_NAME_LEN));
-
-    if (state && STRNEQ(state, "")) {
-        if ((rv = sanlock_state_to_args((char *)state,
-                                        &res_count,
-                                        &res_args)) < 0) {
-            if (rv <= -200)
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("Unable to parse lock state %s: error %d"),
-                               state, rv);
-            else
-                virReportSystemError(-rv,
-                                     _("Unable to parse lock state %s"),
-                                     state);
-            goto error;
-        }
-        res_free = true;
-    } else {
-        res_args = priv->res_args;
-        res_count = priv->res_count;
-    }
-
     /* We only initialize 'sock' if we are in the real
      * child process and we need it to be inherited
      *
@@ -949,6 +924,31 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock,
         }
     }
 
+    /* sanlock doesn't use owner_name for anything, so it's safe to take just
+     * the first SANLK_NAME_LEN - 1 characters from vm_name */
+    ignore_value(virStrncpy(opt->owner_name, priv->vm_name,
+                            SANLK_NAME_LEN - 1, SANLK_NAME_LEN));
+
+    if (state && STRNEQ(state, "")) {
+        if ((rv = sanlock_state_to_args((char *)state,
+                                        &res_count,
+                                        &res_args)) < 0) {
+            if (rv <= -200)
+                virReportError(VIR_ERR_INTERNAL_ERROR,
+                               _("Unable to parse lock state %s: error %d"),
+                               state, rv);
+            else
+                virReportSystemError(-rv,
+                                     _("Unable to parse lock state %s"),
+                                     state);
+            goto error;
+        }
+        res_free = true;
+    } else {
+        res_args = priv->res_args;
+        res_count = priv->res_count;
+    }
+
     if (!(flags & VIR_LOCK_MANAGER_ACQUIRE_REGISTER_ONLY)) {
         VIR_DEBUG("Acquiring object %u", priv->res_count);
         if ((rv = sanlock_acquire(sock, priv->vm_pid, 0,