提交 f7093773 编写于 作者: J Jiri Denemark

qemu: Fix qemuDomainObjTaint with virtlogd

When virtlogd is used to capture QEMU's stdout, qemuDomainObjTaint would
always fail to write the message to the log file when QEMU is already
running (i.e., outside qemuProcessLaunch). This can happen during device
hotplug or by sending a custom QEMU guest agent command:

    warning : qemuDomainObjTaint:8757 : Domain id=9 name='blaf'
        uuid=9cfa4e37-2930-405b-bcb4-faac1829dad8 is tainted:
        custom-ga-command
    error : virLogHandlerDomainOpenLogFile:388 : Cannot open log file:
        '/var/log/libvirt/qemu/blaf.log': Device or resource busy
    error : virNetClientProgramDispatchError:172 : Cannot open log file:
        '/var/log/libvirt/qemu/blaf.log': Device or resource busy

The fix is easy, we just need to use the right API for appending a
message to QEMU log file instead of creating a new log context.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 267699a0
...@@ -8783,9 +8783,9 @@ void qemuDomainObjTaint(virQEMUDriverPtr driver, ...@@ -8783,9 +8783,9 @@ void qemuDomainObjTaint(virQEMUDriverPtr driver,
qemuDomainLogContextPtr logCtxt) qemuDomainLogContextPtr logCtxt)
{ {
virErrorPtr orig_err = NULL; virErrorPtr orig_err = NULL;
bool closeLog = false;
char *timestamp = NULL; char *timestamp = NULL;
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
int rc;
if (!virDomainObjTaint(obj, taint)) if (!virDomainObjTaint(obj, taint))
return; return;
...@@ -8806,27 +8806,25 @@ void qemuDomainObjTaint(virQEMUDriverPtr driver, ...@@ -8806,27 +8806,25 @@ void qemuDomainObjTaint(virQEMUDriverPtr driver,
if (!(timestamp = virTimeStringNow())) if (!(timestamp = virTimeStringNow()))
goto cleanup; goto cleanup;
if (logCtxt == NULL) { if (logCtxt) {
logCtxt = qemuDomainLogContextNew(driver, obj, rc = qemuDomainLogContextWrite(logCtxt,
QEMU_DOMAIN_LOG_CONTEXT_MODE_ATTACH); "%s: Domain id=%d is tainted: %s\n",
if (!logCtxt) { timestamp,
VIR_WARN("Unable to open domainlog"); obj->def->id,
goto cleanup; virDomainTaintTypeToString(taint));
} } else {
closeLog = true; rc = qemuDomainLogAppendMessage(driver, obj,
}
if (qemuDomainLogContextWrite(logCtxt,
"%s: Domain id=%d is tainted: %s\n", "%s: Domain id=%d is tainted: %s\n",
timestamp, timestamp,
obj->def->id, obj->def->id,
virDomainTaintTypeToString(taint)) < 0) virDomainTaintTypeToString(taint));
}
if (rc < 0)
virResetLastError(); virResetLastError();
cleanup: cleanup:
VIR_FREE(timestamp); VIR_FREE(timestamp);
if (closeLog)
virObjectUnref(logCtxt);
if (orig_err) { if (orig_err) {
virSetError(orig_err); virSetError(orig_err);
virFreeError(orig_err); virFreeError(orig_err);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册