mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Add support for timestamping QEMU logs
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.
This commit is contained in:
parent
b6d4dad11b
commit
f3be5f0c50
@ -85,6 +85,8 @@ module Libvirtd_qemu =
|
|||||||
| int_entry "migration_port_min"
|
| int_entry "migration_port_min"
|
||||||
| int_entry "migration_port_max"
|
| int_entry "migration_port_max"
|
||||||
|
|
||||||
|
let log_entry = bool_entry "log_timestamp"
|
||||||
|
|
||||||
(* Each entry in the config is one of the following ... *)
|
(* Each entry in the config is one of the following ... *)
|
||||||
let entry = vnc_entry
|
let entry = vnc_entry
|
||||||
| spice_entry
|
| spice_entry
|
||||||
@ -96,6 +98,7 @@ module Libvirtd_qemu =
|
|||||||
| device_entry
|
| device_entry
|
||||||
| rpc_entry
|
| rpc_entry
|
||||||
| network_entry
|
| network_entry
|
||||||
|
| log_entry
|
||||||
|
|
||||||
let comment = [ label "#comment" . del /#[ \t]*/ "# " . store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ]
|
let comment = [ label "#comment" . del /#[ \t]*/ "# " . store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ]
|
||||||
let empty = [ label "#empty" . eol ]
|
let empty = [ label "#empty" . eol ]
|
||||||
|
@ -465,3 +465,11 @@
|
|||||||
#
|
#
|
||||||
#migration_port_min = 49152
|
#migration_port_min = 49152
|
||||||
#migration_port_max = 49215
|
#migration_port_max = 49215
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Timestamp QEMU's log messages (if QEMU supports it)
|
||||||
|
#
|
||||||
|
# Defaults to 1.
|
||||||
|
#
|
||||||
|
#log_timestamp = 0
|
||||||
|
@ -255,6 +255,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
|
|||||||
|
|
||||||
"usb-kbd", /* 165 */
|
"usb-kbd", /* 165 */
|
||||||
"host-pci-multidomain",
|
"host-pci-multidomain",
|
||||||
|
"msg-timestamp",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -2378,6 +2379,7 @@ static struct virQEMUCapsCommandLineProps virQEMUCapsCommandLine[] = {
|
|||||||
{ "boot-opts", "strict", QEMU_CAPS_BOOT_STRICT },
|
{ "boot-opts", "strict", QEMU_CAPS_BOOT_STRICT },
|
||||||
{ "boot-opts", "reboot-timeout", QEMU_CAPS_REBOOT_TIMEOUT },
|
{ "boot-opts", "reboot-timeout", QEMU_CAPS_REBOOT_TIMEOUT },
|
||||||
{ "spice", "disable-agent-file-xfer", QEMU_CAPS_SPICE_FILE_XFER_DISABLE },
|
{ "spice", "disable-agent-file-xfer", QEMU_CAPS_SPICE_FILE_XFER_DISABLE },
|
||||||
|
{ "msg", "timestamp", QEMU_CAPS_MSG_TIMESTAMP },
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -205,6 +205,7 @@ enum virQEMUCapsFlags {
|
|||||||
QEMU_CAPS_CHARDEV_SPICEPORT = 164, /* -chardev spiceport */
|
QEMU_CAPS_CHARDEV_SPICEPORT = 164, /* -chardev spiceport */
|
||||||
QEMU_CAPS_DEVICE_USB_KBD = 165, /* -device usb-kbd */
|
QEMU_CAPS_DEVICE_USB_KBD = 165, /* -device usb-kbd */
|
||||||
QEMU_CAPS_HOST_PCI_MULTIDOMAIN = 166, /* support domain > 0 in host pci address */
|
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 */
|
QEMU_CAPS_LAST, /* this must always be the last item */
|
||||||
};
|
};
|
||||||
|
@ -9742,6 +9742,10 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|||||||
virCommandSetMaxMemLock(cmd, memKB * 1024);
|
virCommandSetMaxMemLock(cmd, memKB * 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MSG_TIMESTAMP) &&
|
||||||
|
cfg->logTimestamp)
|
||||||
|
virCommandAddArgList(cmd, "-msg", "timestamp=on", NULL);
|
||||||
|
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return cmd;
|
return cmd;
|
||||||
|
|
||||||
|
@ -255,6 +255,8 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged)
|
|||||||
cfg->keepAliveCount = 5;
|
cfg->keepAliveCount = 5;
|
||||||
cfg->seccompSandbox = -1;
|
cfg->seccompSandbox = -1;
|
||||||
|
|
||||||
|
cfg->logTimestamp = true;
|
||||||
|
|
||||||
return cfg;
|
return cfg;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
@ -576,6 +578,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
|
|||||||
|
|
||||||
GET_VALUE_STR("migration_address", cfg->migrationAddress);
|
GET_VALUE_STR("migration_address", cfg->migrationAddress);
|
||||||
|
|
||||||
|
GET_VALUE_BOOL("log_timestamp", cfg->logTimestamp);
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -167,6 +167,8 @@ struct _virQEMUDriverConfig {
|
|||||||
char *migrationAddress;
|
char *migrationAddress;
|
||||||
int migrationPortMin;
|
int migrationPortMin;
|
||||||
int migrationPortMax;
|
int migrationPortMax;
|
||||||
|
|
||||||
|
bool logTimestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Main driver state */
|
/* Main driver state */
|
||||||
|
@ -72,3 +72,4 @@ module Test_libvirtd_qemu =
|
|||||||
{ "migration_address" = "127.0.0.1" }
|
{ "migration_address" = "127.0.0.1" }
|
||||||
{ "migration_port_min" = "49152" }
|
{ "migration_port_min" = "49152" }
|
||||||
{ "migration_port_max" = "49215" }
|
{ "migration_port_max" = "49215" }
|
||||||
|
{ "log_timestamp" = "0" }
|
||||||
|
@ -143,4 +143,5 @@
|
|||||||
<flag name='spiceport'/>
|
<flag name='spiceport'/>
|
||||||
<flag name='usb-kbd'/>
|
<flag name='usb-kbd'/>
|
||||||
<flag name='host-pci-multidomain'/>
|
<flag name='host-pci-multidomain'/>
|
||||||
|
<flag name='msg-timestamp'/>
|
||||||
</qemuCaps>
|
</qemuCaps>
|
||||||
|
@ -141,4 +141,5 @@
|
|||||||
<flag name='spiceport'/>
|
<flag name='spiceport'/>
|
||||||
<flag name='usb-kbd'/>
|
<flag name='usb-kbd'/>
|
||||||
<flag name='host-pci-multidomain'/>
|
<flag name='host-pci-multidomain'/>
|
||||||
|
<flag name='msg-timestamp'/>
|
||||||
</qemuCaps>
|
</qemuCaps>
|
||||||
|
@ -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
|
@ -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'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>
|
@ -578,6 +578,7 @@ mymain(void)
|
|||||||
unsetenv("SDL_AUDIODRIVER");
|
unsetenv("SDL_AUDIODRIVER");
|
||||||
|
|
||||||
DO_TEST("minimal", QEMU_CAPS_NAME);
|
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("minimal-s390", QEMU_CAPS_NAME);
|
||||||
DO_TEST("machine-aliases1", NONE);
|
DO_TEST("machine-aliases1", NONE);
|
||||||
DO_TEST("machine-aliases2", QEMU_CAPS_KVM);
|
DO_TEST("machine-aliases2", QEMU_CAPS_KVM);
|
||||||
|
Loading…
Reference in New Issue
Block a user