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

[libvirt] PATCH: Fix missing thread locking for new remote APIs



The remote driver additions for the sVirt APIs pre-date the time when we
added thread support, and I didn't notice they were mising the lock calls.
This patch adds the missing lock calls, so 'virsh dominfo' doesn't hang
anymore due to an unlock without initial lock. It also fixes two return
values to be -1 rather than -2

Daniel

Index: src/libvirt.c
===================================================================
RCS file: /data/cvs/libvirt/src/libvirt.c,v
retrieving revision 1.198
diff -u -p -r1.198 libvirt.c
--- src/libvirt.c	3 Mar 2009 09:14:28 -0000	1.198
+++ src/libvirt.c	3 Mar 2009 18:32:25 -0000
@@ -4206,7 +4206,7 @@ virDomainGetSecurityLabel(virDomainPtr d
         return conn->driver->domainGetSecurityLabel(domain, seclabel);
 
     virLibConnWarning(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
-    return -2;
+    return -1;
 }
 
 /**
@@ -4236,7 +4236,7 @@ virNodeGetSecurityModel(virConnectPtr co
         return conn->driver->nodeGetSecurityModel(conn, secmodel);
 
     virLibConnWarning(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
-    return -2;
+    return -1;
 }
 
 /**
Index: src/remote_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/remote_internal.c,v
retrieving revision 1.140
diff -u -p -r1.140 remote_internal.c
--- src/remote_internal.c	3 Mar 2009 09:27:03 -0000	1.140
+++ src/remote_internal.c	3 Mar 2009 18:32:25 -0000
@@ -2302,26 +2302,33 @@ remoteDomainGetSecurityLabel (virDomainP
     remote_domain_get_security_label_args args;
     remote_domain_get_security_label_ret ret;
     struct private_data *priv = domain->conn->privateData;
+    int rv = -1;
+
+    remoteDriverLock(priv);
 
     make_nonnull_domain (&args.dom, domain);
     memset (&ret, 0, sizeof ret);
     if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_SECURITY_LABEL,
               (xdrproc_t) xdr_remote_domain_get_security_label_args, (char *)&args,
               (xdrproc_t) xdr_remote_domain_get_security_label_ret, (char *)&ret) == -1) {
-        return -1;
+        goto done;
     }
 
     if (ret.label.label_val != NULL) {
         if (strlen (ret.label.label_val) >= sizeof seclabel->label) {
             errorf (domain->conn, VIR_ERR_RPC, _("security label exceeds maximum: %zd"),
                     sizeof seclabel->label - 1);
-            return -1;
+            goto done;
         }
         strcpy (seclabel->label, ret.label.label_val);
         seclabel->enforcing = ret.enforcing;
     }
 
-    return 0;
+    rv = 0;
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
 }
 
 static int
@@ -2329,19 +2336,22 @@ remoteNodeGetSecurityModel (virConnectPt
 {
     remote_node_get_security_model_ret ret;
     struct private_data *priv = conn->privateData;
+    int rv = -1;
+
+    remoteDriverLock(priv);
 
     memset (&ret, 0, sizeof ret);
     if (call (conn, priv, 0, REMOTE_PROC_NODE_GET_SECURITY_MODEL,
               (xdrproc_t) xdr_void, NULL,
               (xdrproc_t) xdr_remote_node_get_security_model_ret, (char *)&ret) == -1) {
-        return -1;
+        goto done;
     }
 
     if (ret.model.model_val != NULL) {
         if (strlen (ret.model.model_val) >= sizeof secmodel->model) {
             errorf (conn, VIR_ERR_RPC, _("security model exceeds maximum: %zd"),
                     sizeof secmodel->model - 1);
-            return -1;
+            goto done;
         }
         strcpy (secmodel->model, ret.model.model_val);
     }
@@ -2350,11 +2360,16 @@ remoteNodeGetSecurityModel (virConnectPt
         if (strlen (ret.doi.doi_val) >= sizeof secmodel->doi) {
             errorf (conn, VIR_ERR_RPC, _("security doi exceeds maximum: %zd"),
                     sizeof secmodel->doi - 1);
-            return -1;
+            goto done;
         }
         strcpy (secmodel->doi, ret.doi.doi_val);
     }
-    return 0;
+
+    rv = 0;
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
 }
 
 static char *


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


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