]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix error reporting for security driver over remote protocol
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 15 Jul 2009 09:36:32 +0000 (10:36 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 15 Jul 2009 11:27:42 +0000 (12:27 +0100)
* qemud/remote.c: Send back the actual libvirt connection error
  rather than formatting a generic error for security driver
  methods
* src/libvirt.c: Fix virDomainGetSecurityLabel, and
  virNodeGetSecurityModel to correctly set the error on
  the virConnectPtr object, and raise a full error rather
  than warning when not supported

qemud/remote.c
src/libvirt.c

index 1071c21ed44533f914b8efd86fb38ceac2c88a0c..78b6e3d44d740a018c9e83c3145129242c634dc5 100644 (file)
@@ -1411,7 +1411,7 @@ remoteDispatchDomainGetSecurityLabel(struct qemud_server *server ATTRIBUTE_UNUSE
     memset(&seclabel, 0, sizeof seclabel);
     if (virDomainGetSecurityLabel(dom, &seclabel) == -1) {
         virDomainFree(dom);
-        remoteDispatchFormatError(rerr, "%s", _("unable to get security label"));
+        remoteDispatchConnError(rerr, conn);
         return -1;
     }
 
@@ -1440,7 +1440,7 @@ remoteDispatchNodeGetSecurityModel(struct qemud_server *server ATTRIBUTE_UNUSED,
 
     memset(&secmodel, 0, sizeof secmodel);
     if (virNodeGetSecurityModel(conn, &secmodel) == -1) {
-        remoteDispatchFormatError(rerr, "%s", _("unable to get security model"));
+        remoteDispatchConnError(rerr, conn);
         return -1;
     }
 
index 33eafcbbe27d84b07512344c1123222adfb169ef..72221e9048536f56b9b7b7d91e8461edc5ab26b0 100644 (file)
@@ -4399,15 +4399,24 @@ virDomainGetSecurityLabel(virDomainPtr domain, virSecurityLabelPtr seclabel)
 
     if (seclabel == NULL) {
         virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
-        return -1;
+        goto error;
     }
 
     conn = domain->conn;
 
-    if (conn->driver->domainGetSecurityLabel)
-        return conn->driver->domainGetSecurityLabel(domain, seclabel);
+    if (conn->driver->domainGetSecurityLabel) {
+        int ret;
+        ret = conn->driver->domainGetSecurityLabel(domain, seclabel);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
 
-    virLibConnWarning(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+error:
+    /* Copy to connection error object for back compatability */
+    virSetConnError(domain->conn);
     return -1;
 }
 
@@ -4432,13 +4441,22 @@ virNodeGetSecurityModel(virConnectPtr conn, virSecurityModelPtr secmodel)
 
     if (secmodel == NULL) {
         virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
-        return -1;
+        goto error;
+    }
+
+    if (conn->driver->nodeGetSecurityModel) {
+        int ret;
+        ret = conn->driver->nodeGetSecurityModel(conn, secmodel);
+        if (ret < 0)
+            goto error;
+        return ret;
     }
 
-    if (conn->driver->nodeGetSecurityModel)
-        return conn->driver->nodeGetSecurityModel(conn, secmodel);
+    virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
 
-    virLibConnWarning(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+error:
+    /* Copy to connection error object for back compatability */
+    virSetConnError(conn);
     return -1;
 }