mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
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: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
267699a03c
commit
f709377301
@ -8783,9 +8783,9 @@ void qemuDomainObjTaint(virQEMUDriverPtr driver,
|
||||
qemuDomainLogContextPtr logCtxt)
|
||||
{
|
||||
virErrorPtr orig_err = NULL;
|
||||
bool closeLog = false;
|
||||
char *timestamp = NULL;
|
||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||
int rc;
|
||||
|
||||
if (!virDomainObjTaint(obj, taint))
|
||||
return;
|
||||
@ -8806,27 +8806,25 @@ void qemuDomainObjTaint(virQEMUDriverPtr driver,
|
||||
if (!(timestamp = virTimeStringNow()))
|
||||
goto cleanup;
|
||||
|
||||
if (logCtxt == NULL) {
|
||||
logCtxt = qemuDomainLogContextNew(driver, obj,
|
||||
QEMU_DOMAIN_LOG_CONTEXT_MODE_ATTACH);
|
||||
if (!logCtxt) {
|
||||
VIR_WARN("Unable to open domainlog");
|
||||
goto cleanup;
|
||||
}
|
||||
closeLog = true;
|
||||
}
|
||||
|
||||
if (qemuDomainLogContextWrite(logCtxt,
|
||||
if (logCtxt) {
|
||||
rc = qemuDomainLogContextWrite(logCtxt,
|
||||
"%s: Domain id=%d is tainted: %s\n",
|
||||
timestamp,
|
||||
obj->def->id,
|
||||
virDomainTaintTypeToString(taint)) < 0)
|
||||
virDomainTaintTypeToString(taint));
|
||||
} else {
|
||||
rc = qemuDomainLogAppendMessage(driver, obj,
|
||||
"%s: Domain id=%d is tainted: %s\n",
|
||||
timestamp,
|
||||
obj->def->id,
|
||||
virDomainTaintTypeToString(taint));
|
||||
}
|
||||
|
||||
if (rc < 0)
|
||||
virResetLastError();
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(timestamp);
|
||||
if (closeLog)
|
||||
virObjectUnref(logCtxt);
|
||||
if (orig_err) {
|
||||
virSetError(orig_err);
|
||||
virFreeError(orig_err);
|
||||
|
Loading…
Reference in New Issue
Block a user