1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

Fix error reporting for security driver over remote protocol

* 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
This commit is contained in:
Daniel P. Berrange 2009-07-15 10:36:32 +01:00
parent a90629aa13
commit 845659340e
2 changed files with 28 additions and 10 deletions

View 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;
}

View 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;
}
virLibConnWarning(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
virLibConnError (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)
return conn->driver->nodeGetSecurityModel(conn, secmodel);
if (conn->driver->nodeGetSecurityModel) {
int ret;
ret = conn->driver->nodeGetSecurityModel(conn, secmodel);
if (ret < 0)
goto error;
return ret;
}
virLibConnWarning(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
error:
/* Copy to connection error object for back compatability */
virSetConnError(conn);
return -1;
}