Commit 8c3f7a33 authored by Michal Privoznik's avatar Michal Privoznik

showError: Switch to less ancient error reporting

So far, the function calls virConnCopyLastError() which is
suboptimal since we have virGetLastErrorMessage(). Switch to
that.
Signed-off-by: 's avatarMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: 's avatarMartin Kletzander <mkletzan@redhat.com>
parent 1cd852ba
......@@ -23,7 +23,7 @@ dnl
dnl do we have libvirt installed?
LIBVIRT_REQUIRED=0.9.0
LIBVIRT_REQUIRED=1.0.6
PKG_CHECK_MODULES(LIBVIRT, libvirt >= $LIBVIRT_REQUIRED)
AC_SUBST(LIBVIRT_LIBS)
......
......@@ -76,36 +76,11 @@ stop(int sig)
static void
showError(virConnectPtr conn)
{
int ret;
virErrorPtr err;
err = malloc(sizeof(*err));
if (NULL == err) {
printf("Could not allocate memory for error data\n");
goto out;
}
ret = virConnCopyLastError(conn, err);
switch (ret) {
case 0:
snmp_log(LOG_ERR, "No error found\n");
break;
const char *err = virGetLastErrorMessage();
case -1:
snmp_log(LOG_ERR, "Parameter error when attempting to get last error\n");
break;
snmp_log(LOG_ERR, "libvirt reported: \"%s\"\n", err);
default:
snmp_log(LOG_ERR, "libvirt reported: \"%s\"\n", err->message);
break;
}
virResetError(err);
free(err);
out:
return;
virResetLastError();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment