[libvirt] [PATCH] sanlock: Fix condition left crippled while debugging

Peter Krempa pkrempa at redhat.com
Wed Mar 7 14:36:48 UTC 2012


---
Extra context for review.

 src/locking/lock_driver_sanlock.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c
index f2623a0..d344d6a 100644
--- a/src/locking/lock_driver_sanlock.c
+++ b/src/locking/lock_driver_sanlock.c
@@ -669,73 +669,73 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock,
                                         const char *state,
                                         unsigned int flags,
                                         int *fd)
 {
     virLockManagerSanlockPrivatePtr priv = lock->privateData;
     struct sanlk_options *opt;
     struct sanlk_resource **res_args;
     int res_count;
     bool res_free = false;
     int sock = -1;
     int rv;
     int i;

     virCheckFlags(VIR_LOCK_MANAGER_ACQUIRE_RESTRICT |
                   VIR_LOCK_MANAGER_ACQUIRE_REGISTER_ONLY, -1);

     if (priv->res_count == 0 &&
         priv->hasRWDisks &&
         driver->requireLeaseForDisks) {
         virLockError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                      _("Read/write, exclusive access, disks were present, but no leases specified"));
         return -1;
     }

     if (VIR_ALLOC(opt) < 0) {
         virReportOOMError();
         return -1;
     }

     if (!virStrcpy(opt->owner_name, priv->vm_name, SANLK_NAME_LEN)) {
         virLockError(VIR_ERR_INTERNAL_ERROR,
                      _("Domain name '%s' exceeded %d characters"),
                      priv->vm_name, SANLK_NAME_LEN);
         goto error;
     }

-    if (state && STRNEQ(state, "") && 0) {
+    if (state && STRNEQ(state, "")) {
         if ((rv = sanlock_state_to_args((char *)state,
                                         &res_count,
                                         &res_args)) < 0) {
             if (rv <= -200)
                 virLockError(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;
     }

     VIR_DEBUG("Register sanlock %d", flags);
     /* We only initialize 'sock' if we are in the real
      * child process and we need it to be inherited
      *
      * If sock==-1, then sanlock auto-open/closes a
      * temporary sock
      */
     if (priv->vm_pid == getpid() &&
         (sock = sanlock_register()) < 0) {
         if (sock <= -200)
             virLockError(VIR_ERR_INTERNAL_ERROR,
                          _("Failed to open socket to sanlock daemon: error %d"),
                          sock);
         else
             virReportSystemError(-sock, "%s",
                                  _("Failed to open socket to sanlock daemon"));
         goto error;
-- 
1.7.3.4




More information about the libvir-list mailing list