src/qemu/qemu_domain.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-)
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>
---
src/qemu/qemu_domain.c | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index c7eb0b5e9a..709e4e568b 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -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 (logCtxt) {
+ rc = qemuDomainLogContextWrite(logCtxt,
+ "%s: Domain id=%d is tainted: %s\n",
+ timestamp,
+ obj->def->id,
+ virDomainTaintTypeToString(taint));
+ } else {
+ rc = qemuDomainLogAppendMessage(driver, obj,
+ "%s: Domain id=%d is tainted: %s\n",
+ timestamp,
+ obj->def->id,
+ virDomainTaintTypeToString(taint));
}
- if (qemuDomainLogContextWrite(logCtxt,
- "%s: Domain id=%d is tainted: %s\n",
- timestamp,
- obj->def->id,
- virDomainTaintTypeToString(taint)) < 0)
+ if (rc < 0)
virResetLastError();
cleanup:
VIR_FREE(timestamp);
- if (closeLog)
- virObjectUnref(logCtxt);
if (orig_err) {
virSetError(orig_err);
virFreeError(orig_err);
--
2.23.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On Thu, Sep 05, 2019 at 03:48:10PM +0200, Jiri Denemark wrote: >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> >--- > src/qemu/qemu_domain.c | 30 ++++++++++++++---------------- > 1 file changed, 14 insertions(+), 16 deletions(-) > Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2024 Red Hat, Inc.