On 11/12/2015 12:19 PM, Daniel P. Berrange wrote:
The qemuDomainTaint APIs currently expect to be passed a log file
descriptor. Change them to instead use a qemuDomainLogContextPtr
to hide the implementation details.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_domain.c | 96 ++++++++++++++++++-------------------------------
src/qemu/qemu_domain.h | 15 +++-----
src/qemu/qemu_driver.c | 10 +++---
src/qemu/qemu_process.c | 4 +--
4 files changed, 47 insertions(+), 78 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index f3bb8d4..75f78fe 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2107,9 +2107,10 @@ qemuDomainDefFormatLive(virQEMUDriverPtr driver,
void qemuDomainObjTaint(virQEMUDriverPtr driver,
virDomainObjPtr obj,
virDomainTaintFlags taint,
- int logFD)
+ qemuDomainLogContextPtr logCtxt)
{
virErrorPtr orig_err = NULL;
+ bool closeLog = false;
if (virDomainObjTaint(obj, taint)) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -2125,11 +2126,23 @@ void qemuDomainObjTaint(virQEMUDriverPtr driver,
* preserve original error, and clear any error that
* is raised */
orig_err = virSaveLastError();
- if (qemuDomainAppendLog(driver, obj, logFD,
- "Domain id=%d is tainted: %s\n",
- obj->def->id,
- virDomainTaintTypeToString(taint)) < 0)
+ if (logCtxt == NULL) {
+ logCtxt = qemuDomainLogContextNew(driver, obj,
+ QEMU_DOMAIN_LOG_CONTEXT_MODE_ATTACH);
+ if (!logCtxt) {
+ VIR_WARN("Unable to open domainlog");
Coverity found - leaking orig_err
+ return;
+ }
+ closeLog = true;
+ }
+
+ if (qemuDomainLogContextWrite(logCtxt,
+ "Domain id=%d is tainted: %s\n",
+ obj->def->id,
+ virDomainTaintTypeToString(taint)) < 0)
virResetLastError();
+ if (closeLog)
+ qemuDomainLogContextFree(logCtxt);
if (orig_err) {
virSetError(orig_err);
virFreeError(orig_err);
@@ -2140,7 +2153,7 @@ void qemuDomainObjTaint(virQEMUDriverPtr driver,
[...]
ACK with the adjustment
John