[libvirt] [PATCH] qemu: include kernel version in QEMU log file

We currently print the libvirt and qemu version strings into the per-guest logfile. It would be useful to know what kernel is running too, so add that. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- src/qemu/qemu_process.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 5b73a61962..174d932ae7 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -32,6 +32,8 @@ # include <sys/cpuset.h> #endif +#include <sys/utsname.h> + #include "qemu_process.h" #include "qemu_processpriv.h" #include "qemu_alias.h" @@ -4283,17 +4285,21 @@ qemuLogOperation(virDomainObjPtr vm, int qemuVersion = virQEMUCapsGetVersion(priv->qemuCaps); const char *package = virQEMUCapsGetPackage(priv->qemuCaps); char *hostname = virGetHostname(); + struct utsname uts; + + uname(&uts); if ((timestamp = virTimeStringNow()) == NULL) goto cleanup; if (qemuDomainLogContextWrite(logCtxt, - "%s: %s %s, qemu version: %d.%d.%d%s, hostname: %s\n", + "%s: %s %s, qemu version: %d.%d.%d%s, kernel: %s, hostname: %s\n", timestamp, msg, VIR_LOG_VERSION_STRING, (qemuVersion / 1000000) % 1000, (qemuVersion / 1000) % 1000, qemuVersion % 1000, package ? package : "", + uts.release, hostname ? hostname : "") < 0) goto cleanup; -- 2.17.0

On 05/18/2018 01:24 PM, Daniel P. Berrangé wrote:
We currently print the libvirt and qemu version strings into the per-guest logfile. It would be useful to know what kernel is running too, so add that.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- src/qemu/qemu_process.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
ACK Michal

On Fri, May 18, 2018 at 12:24:32PM +0100, Daniel P. Berrangé wrote:
We currently print the libvirt and qemu version strings into the per-guest logfile. It would be useful to know what kernel is running too, so add that.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- src/qemu/qemu_process.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
I applied your patch and built libvirt locally; then I started my freshly-built libvirt, et al: $ sudo systemctl stop libvirtd virtlockd virtlogd # Start freshly-built libvirtd, virtlockd, virtlogd # Define and start a network # Then, start a guest from an XML When you start a guest with "sudo ./tools/virsh start cvm2", where will the per-guest log file go? Is it even configurable? I never tried this before. FWIW I started guest the following way, preserving the log filters environment variable: $> sudo LIBVIRT_LOG_FILTERS="1:libvirt 1:qemu 1:conf 1:security 3:event 3:json 3:file 3:object 1:util" -E ./tools/virsh start cvm2 2018-05-18 18:08:52.896+0000: 26556: info : libvirt version: 4.4.0 2018-05-18 18:08:52.896+0000: 26556: info : hostname: paraplu 2018-05-18 18:08:52.896+0000: 26556: debug : virLogParseFilters:1821 : filters=1:libvirt 1:qemu 1:conf 1:security 3:event 3:json 3:file 3:object 1:util 2018-05-18 18:08:52.896+0000: 26556: debug : virLogParseFilter:1699 : filter=1:libvirt 2018-05-18 18:08:52.896+0000: 26556: debug : virLogParseFilter:1699 : filter=1:qemu 2018-05-18 18:08:52.896+0000: 26556: debug : virLogParseFilter:1699 : filter=1:conf [...] Domain cvm2 started I think I am simply looking in the wrong place (the libvirtd log), instead of the per-guest log. But I'm not where it goes when running a custom libvirtd. I looked in the `journalctl --since=today`, also no dice. What am I missing? I'm curious how you tested it.
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 5b73a61962..174d932ae7 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -32,6 +32,8 @@ # include <sys/cpuset.h> #endif
+#include <sys/utsname.h> + #include "qemu_process.h" #include "qemu_processpriv.h" #include "qemu_alias.h" @@ -4283,17 +4285,21 @@ qemuLogOperation(virDomainObjPtr vm, int qemuVersion = virQEMUCapsGetVersion(priv->qemuCaps); const char *package = virQEMUCapsGetPackage(priv->qemuCaps); char *hostname = virGetHostname(); + struct utsname uts; + + uname(&uts);
if ((timestamp = virTimeStringNow()) == NULL) goto cleanup;
if (qemuDomainLogContextWrite(logCtxt, - "%s: %s %s, qemu version: %d.%d.%d%s, hostname: %s\n", + "%s: %s %s, qemu version: %d.%d.%d%s, kernel: %s, hostname: %s\n", timestamp, msg, VIR_LOG_VERSION_STRING, (qemuVersion / 1000000) % 1000, (qemuVersion / 1000) % 1000, qemuVersion % 1000, package ? package : "", + uts.release, hostname ? hostname : "") < 0) goto cleanup;
-- 2.17.0
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
-- /kashyap

On Fri, May 18, 2018 at 08:16:39PM +0200, Kashyap Chamarthy wrote:
On Fri, May 18, 2018 at 12:24:32PM +0100, Daniel P. Berrangé wrote:
We currently print the libvirt and qemu version strings into the per-guest logfile. It would be useful to know what kernel is running too, so add that.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- src/qemu/qemu_process.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
I applied your patch and built libvirt locally; then I started my freshly-built libvirt, et al:
[...]
When you start a guest with "sudo ./tools/virsh start cvm2", where will the per-guest log file go? Is it even configurable? I never tried this before.
[...]
What am I missing? I'm curious how you tested it.
Eric Blake on IRC reminded me that if I built with 'autogen.sh --system' will, then the per-guest log should go to the standard location. On my above compile, I didn't use '--system'; re-doing a fresh compile with 'autogen.sh --system' indeed results in the Linux kernel version being printed in the per-guest log, in the stndard location: [...] 2018-05-18 18:52:15.725+0000: starting up libvirt version: 4.4.0, qemu version: 2.10.1(qemu-2.10.1-2.fc27), kernel: 4.14.16-300.fc27.x86_64 ... [...] FWIW: Reviewed-by and Tested-by: Kashyap Chamarthy <kchamart@redhat.com> -- /kashyap
participants (3)
-
Daniel P. Berrangé
-
Kashyap Chamarthy
-
Michal Privoznik