diff --git a/docs/logging.html.in b/docs/logging.html.in
index 5ff9c157f3520dae65b04454aacb1197e967f0e8..a8cb53846e03006b4adfd5b065b76f42e19c06d6 100644
--- a/docs/logging.html.in
+++ b/docs/logging.html.in
@@ -179,6 +179,50 @@
The libvirt error code (values from virErrorCode enum), if LIBVIRT_SOURCE="error"
+
+
+
+ Certain areas of the code will emit log records tagged with well known
+ unique id values, which are guaranteed never to change in the future.
+ This allows applications to identify critical log events without doing
+ string matching on the MESSAGE
field.
+
+
+
+ MESSAGE_ID=8ae2f3fb-2dbe-498e-8fbd-012d40afa361
+ - Generated by the QEMU driver when it identifies a QEMU system
+ emulator binary, but is unable to extract information about its
+ capabilities. This is usually an indicator of a broken QEMU
+ build or installation. When this is emitted, the
LIBVIRT_QEMU_BINARY
+ message field will provide the full path of the QEMU binary that failed.
+
+
+
+
+ The journalctl
command can be used to search the journal
+ matching on specific message ID values
+
+
+
+ $ journalctl MESSAGE_ID=8ae2f3fb-2dbe-498e-8fbd-012d40afa361 --output=json
+ { ...snip...
+ "LIBVIRT_SOURCE" : "file",
+ "PRIORITY" : "3",
+ "CODE_FILE" : "qemu/qemu_capabilities.c",
+ "CODE_LINE" : "2770",
+ "CODE_FUNC" : "virQEMUCapsLogProbeFailure",
+ "MESSAGE_ID" : "8ae2f3fb-2dbe-498e-8fbd-012d40afa361",
+ "LIBVIRT_QEMU_BINARY" : "/bin/qemu-system-xtensa",
+ "MESSAGE" : "Failed to probe capabilities for /bin/qemu-system-xtensa:" \
+ "internal error: Child process (LC_ALL=C LD_LIBRARY_PATH=/home/berrange" \
+ "/src/virt/libvirt/src/.libs PATH=/usr/lib64/ccache:/usr/local/sbin:" \
+ "/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin HOME=/root " \
+ "USER=root LOGNAME=root /bin/qemu-system-xtensa -help) unexpected " \
+ "exit status 127: /bin/qemu-system-xtensa: error while loading shared " \
+ "libraries: libglapi.so.0: cannot open shared object file: No such " \
+ "file or directory\n" }
+
+
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index d618b3fd9cbf45b218a8690101aaf1253ba55426..76a8c7359c06c47c86f496b34229a34354f5bcc1 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2754,6 +2754,28 @@ cleanup:
}
+#define MESSAGE_ID_CAPS_PROBE_FAILURE "8ae2f3fb-2dbe-498e-8fbd-012d40afa361"
+
+static void
+virQEMUCapsLogProbeFailure(const char *binary)
+{
+ virLogMetadata meta[] = {
+ { .key = "MESSAGE_ID", .s = MESSAGE_ID_CAPS_PROBE_FAILURE, .iv = 0 },
+ { .key = "LIBVIRT_QEMU_BINARY", .s = binary, .iv = 0 },
+ { .key = NULL },
+ };
+ virErrorPtr err = virGetLastError();
+
+ virLogMessage(VIR_LOG_FROM_FILE,
+ VIR_LOG_WARN,
+ __FILE__, __LINE__, __func__,
+ meta,
+ _("Failed to probe capabilities for %s: %s"),
+ binary, err && err->message ? err->message :
+ _("unknown failure"));
+}
+
+
virQEMUCapsPtr virQEMUCapsNewForBinary(const char *binary,
const char *libDir,
uid_t runUid,
@@ -2785,12 +2807,16 @@ virQEMUCapsPtr virQEMUCapsNewForBinary(const char *binary,
goto error;
}
- if ((rv = virQEMUCapsInitQMP(qemuCaps, libDir, runUid, runGid)) < 0)
+ if ((rv = virQEMUCapsInitQMP(qemuCaps, libDir, runUid, runGid)) < 0) {
+ virQEMUCapsLogProbeFailure(binary);
goto error;
+ }
if (!qemuCaps->usedQMP &&
- virQEMUCapsInitHelp(qemuCaps, runUid, runGid) < 0)
+ virQEMUCapsInitHelp(qemuCaps, runUid, runGid) < 0) {
+ virQEMUCapsLogProbeFailure(binary);
goto error;
+ }
return qemuCaps;