From 0eb2f8aa90d26e75ce5d9449da03bb553da85d2d Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 3 Jun 2013 16:12:52 +0200 Subject: [PATCH] libvirt-qemu: Dispatch errors from virDomainQemuAgentCommand() The original implementation didn't follow the established pattern and did not dispatch errors in case of failure. --- src/libvirt-qemu.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/libvirt-qemu.c b/src/libvirt-qemu.c index 747488da18..2a1432b862 100644 --- a/src/libvirt-qemu.c +++ b/src/libvirt-qemu.c @@ -211,6 +211,7 @@ virDomainQemuAgentCommand(virDomainPtr domain, unsigned int flags) { virConnectPtr conn; + char *ret; VIR_DEBUG("domain=%p, cmd=%s, timeout=%d, flags=%x", domain, cmd, timeout, flags); @@ -220,21 +221,26 @@ virDomainQemuAgentCommand(virDomainPtr domain, virDispatchError(NULL); return NULL; } - if (domain->conn->flags & VIR_CONNECT_RO) { - virLibDomainError(NULL, VIR_ERR_OPERATION_DENIED, __FUNCTION__); - return NULL; - } conn = domain->conn; + if (conn->flags & VIR_CONNECT_RO) { + virLibDomainError(NULL, VIR_ERR_OPERATION_DENIED, __FUNCTION__); + goto error; + } + if (conn->driver->domainQemuAgentCommand) { - return conn->driver->domainQemuAgentCommand(domain, cmd, - timeout, flags); + ret = conn->driver->domainQemuAgentCommand(domain, cmd, + timeout, flags); + if (!ret) + goto error; + return ret; } virLibConnError(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__); /* Copy to connection error object for back compatibility */ +error: virDispatchError(conn); return NULL; }