[libvirt] PATCH: Fix bug in error reporting for security driver

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

 



There are a couple more bugs in the security driver error reporting
code

 - The remote daemon driver was formatting a generic string error, instead
   of sending back the actual libvirt error
 - The public interface was not raising a full error, nor copying the error
   from the connection to the global error object

Daniel

diff -rup libvirt-0.6.3/qemud/remote.c libvirt-0.6.3.new/qemud/remote.c
--- libvirt-0.6.3/qemud/remote.c	2009-04-24 09:12:05.000000000 -0400
+++ libvirt-0.6.3.new/qemud/remote.c	2009-07-13 06:30:02.000000000 -0400
@@ -1366,7 +1366,7 @@ remoteDispatchDomainGetSecurityLabel(str
     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;
     }
 
@@ -1395,7 +1395,7 @@ remoteDispatchNodeGetSecurityModel(struc
 
     memset(&secmodel, 0, sizeof secmodel);
     if (virNodeGetSecurityModel(conn, &secmodel) == -1) {
-        remoteDispatchFormatError(rerr, "%s", _("unable to get security model"));
+        remoteDispatchConnError(rerr, conn);
         return -1;
     }
 
diff -rup libvirt-0.6.3/src/libvirt.c libvirt-0.6.3.new/src/libvirt.c
--- libvirt-0.6.3/src/libvirt.c	2009-07-13 06:31:29.000000000 -0400
+++ libvirt-0.6.3.new/src/libvirt.c	2009-07-13 06:27:42.000000000 -0400
@@ -4212,15 +4212,24 @@ virDomainGetSecurityLabel(virDomainPtr d
 
     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;
 }
 
@@ -4245,13 +4254,22 @@ virNodeGetSecurityModel(virConnectPtr co
 
     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;
 }
 


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

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