]> xenbits.xensource.com Git - libvirt.git/commitdiff
Add support for timestamping QEMU logs
authorJán Tomko <jtomko@redhat.com>
Wed, 9 Apr 2014 13:23:45 +0000 (15:23 +0200)
committerJán Tomko <jtomko@redhat.com>
Wed, 7 May 2014 08:27:50 +0000 (10:27 +0200)
QEMU commit 5e2ac51 added a boolean '-msg timestamp=[on|off]'
option, which can enable timestamps on errors:
$ qemu-system-x86_64 -msg timestamp=on zghhdorf
2014-04-09T13:25:46.779484Z qemu-system-x86_64: -msg timestamp=on: could
not open disk image zghhdorf: Could not open 'zghhdorf': No such file or
directory

Enable this timestamp if the QEMU binary supports it.

Add a 'log_timestamp' option to qemu.conf for disabling this behavior.

13 files changed:
src/qemu/libvirtd_qemu.aug
src/qemu/qemu.conf
src/qemu/qemu_capabilities.c
src/qemu/qemu_capabilities.h
src/qemu/qemu_command.c
src/qemu/qemu_conf.c
src/qemu/qemu_conf.h
src/qemu/test_libvirtd_qemu.aug.in
tests/qemucapabilitiesdata/caps_1.6.0-1.caps
tests/qemucapabilitiesdata/caps_1.6.50-1.caps
tests/qemuxml2argvdata/qemuxml2argv-minimal-msg-timestamp.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-minimal-msg-timestamp.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c

index a9ff421eb6053f7b9bc04df5ca7a3555fde4fc1a..e985d22ec481da7e6526f86f55082d6ed8e05004 100644 (file)
@@ -85,6 +85,8 @@ module Libvirtd_qemu =
                  | int_entry "migration_port_min"
                  | int_entry "migration_port_max"
 
+   let log_entry = bool_entry "log_timestamp"
+
    (* Each entry in the config is one of the following ... *)
    let entry = vnc_entry
              | spice_entry
@@ -96,6 +98,7 @@ module Libvirtd_qemu =
              | device_entry
              | rpc_entry
              | network_entry
+             | log_entry
 
    let comment = [ label "#comment" . del /#[ \t]*/ "# " .  store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ]
    let empty = [ label "#empty" . eol ]
index f0e802f242f681d720a3b646fc3bb942e01463f0..42f812dc2563b0b35145e5994f62e500c30d5718 100644 (file)
 #
 #migration_port_min = 49152
 #migration_port_max = 49215
+
+
+
+# Timestamp QEMU's log messages (if QEMU supports it)
+#
+# Defaults to 1.
+#
+#log_timestamp = 0
index 834325854b2ae5fcebc5a931299e012347aa913b..03d88426aa5f1b83ca901e829f4ae65ea56afac3 100644 (file)
@@ -255,6 +255,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
 
               "usb-kbd", /* 165 */
               "host-pci-multidomain",
+              "msg-timestamp",
     );
 
 
@@ -2378,6 +2379,7 @@ static struct virQEMUCapsCommandLineProps virQEMUCapsCommandLine[] = {
     { "boot-opts", "strict", QEMU_CAPS_BOOT_STRICT },
     { "boot-opts", "reboot-timeout", QEMU_CAPS_REBOOT_TIMEOUT },
     { "spice", "disable-agent-file-xfer", QEMU_CAPS_SPICE_FILE_XFER_DISABLE },
+    { "msg", "timestamp", QEMU_CAPS_MSG_TIMESTAMP },
 };
 
 static int
index 26400d219aeb70a92fe16d14c06a696d2526a6e1..d755caab280a53441d1ef74d48664235b1e33c92 100644 (file)
@@ -205,6 +205,7 @@ enum virQEMUCapsFlags {
     QEMU_CAPS_CHARDEV_SPICEPORT  = 164, /* -chardev spiceport */
     QEMU_CAPS_DEVICE_USB_KBD     = 165, /* -device usb-kbd */
     QEMU_CAPS_HOST_PCI_MULTIDOMAIN = 166, /* support domain > 0 in host pci address */
+    QEMU_CAPS_MSG_TIMESTAMP      = 167, /* -msg timestamp */
 
     QEMU_CAPS_LAST,                   /* this must always be the last item */
 };
index 29ae8e4b1a5acd4342d7b42fe30c41f434b4723a..dd8e40a6363e06df12b83cc767af9ea6119181e3 100644 (file)
@@ -9742,6 +9742,10 @@ qemuBuildCommandLine(virConnectPtr conn,
         virCommandSetMaxMemLock(cmd, memKB * 1024);
     }
 
+    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MSG_TIMESTAMP) &&
+        cfg->logTimestamp)
+        virCommandAddArgList(cmd, "-msg", "timestamp=on", NULL);
+
     virObjectUnref(cfg);
     return cmd;
 
index 198ee2fbdd0705db063e2d4d5727c533350b7cdd..e487f5e1ffb0cc1826881acad45ff935aa774efe 100644 (file)
@@ -255,6 +255,8 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged)
     cfg->keepAliveCount = 5;
     cfg->seccompSandbox = -1;
 
+    cfg->logTimestamp = true;
+
     return cfg;
 
  error:
@@ -576,6 +578,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
 
     GET_VALUE_STR("migration_address", cfg->migrationAddress);
 
+    GET_VALUE_BOOL("log_timestamp", cfg->logTimestamp);
+
     ret = 0;
 
  cleanup:
index a36ea63392ca9134b1f7183a811b09e61c083511..5d2983af3ab02bc1bac8497c1f521ac413a1a38f 100644 (file)
@@ -167,6 +167,8 @@ struct _virQEMUDriverConfig {
     char *migrationAddress;
     int migrationPortMin;
     int migrationPortMax;
+
+    bool logTimestamp;
 };
 
 /* Main driver state */
index b2328d365ec48388acfb28aed91e58840c2a39c3..30a425793e895e69e0472c36b756b8b5d4f9a16f 100644 (file)
@@ -72,3 +72,4 @@ module Test_libvirtd_qemu =
 { "migration_address" = "127.0.0.1" }
 { "migration_port_min" = "49152" }
 { "migration_port_max" = "49215" }
+{ "log_timestamp" = "0" }
index 7b86c3b650f8e35aedf83696141419c34cbd8172..ca2c236ca0cc5442606983e67f0c2d87e45c909d 100644 (file)
     <flag name='spiceport'/>
     <flag name='usb-kbd'/>
     <flag name='host-pci-multidomain'/>
+    <flag name='msg-timestamp'/>
   </qemuCaps>
index 10b8251f0710890d17c4ed00504232584157db6d..32bccdbbefb5f2687c9eafaea2bd97e04a0e54f0 100644 (file)
     <flag name='spiceport'/>
     <flag name='usb-kbd'/>
     <flag name='host-pci-multidomain'/>
+    <flag name='msg-timestamp'/>
   </qemuCaps>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-minimal-msg-timestamp.args b/tests/qemuxml2argvdata/qemuxml2argv-minimal-msg-timestamp.args
new file mode 100644 (file)
index 0000000..f85aae9
--- /dev/null
@@ -0,0 +1,6 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu \
+-name QEMUGuest1 -S -M pc -m 214 -smp 1 -nographic -monitor \
+unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
+-usb -hda /dev/HostVG/QEMUGuest1 -net none -serial \
+none -parallel none -msg timestamp=on
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-minimal-msg-timestamp.xml b/tests/qemuxml2argvdata/qemuxml2argv-minimal-msg-timestamp.xml
new file mode 100644 (file)
index 0000000..4a938b3
--- /dev/null
@@ -0,0 +1,32 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <title>A description of the test machine.</title>
+  <description>
+      A test of qemu&apos;s minimal configuration.
+      This test also tests the description and title elements.
+  </description>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
index ad5e2cd6bd42006ee0686dec20879b4e9a8ba216..1ea7bf87165a5c469b5b6794c0f4d50ff61ef8e1 100644 (file)
@@ -578,6 +578,7 @@ mymain(void)
     unsetenv("SDL_AUDIODRIVER");
 
     DO_TEST("minimal", QEMU_CAPS_NAME);
+    DO_TEST("minimal-msg-timestamp", QEMU_CAPS_NAME, QEMU_CAPS_MSG_TIMESTAMP);
     DO_TEST("minimal-s390", QEMU_CAPS_NAME);
     DO_TEST("machine-aliases1", NONE);
     DO_TEST("machine-aliases2", QEMU_CAPS_KVM);