mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
qemu: Process new 'append' attribute for char dev with output to a file
By default, QEMU truncates serial file on open. Sometimes, it could be weird - for example, when we are trying to investigate some event, which occured several restarts ago. This patch adds an ability to preserve previous content. Signed-off-by: Dmitry Mishin <dim@virtuozzo.com>
This commit is contained in:
parent
70ffa02fc2
commit
53a15aed39
@ -308,6 +308,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
|
|||||||
|
|
||||||
"virtio-tablet", /* 205 */
|
"virtio-tablet", /* 205 */
|
||||||
"virtio-input-host",
|
"virtio-input-host",
|
||||||
|
"chardev-file-append",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -2600,6 +2601,7 @@ static struct virQEMUCapsCommandLineProps virQEMUCapsCommandLine[] = {
|
|||||||
{ "drive", "throttling.bps-total-max", QEMU_CAPS_DRIVE_IOTUNE_MAX},
|
{ "drive", "throttling.bps-total-max", QEMU_CAPS_DRIVE_IOTUNE_MAX},
|
||||||
{ "machine", "aes-key-wrap", QEMU_CAPS_AES_KEY_WRAP },
|
{ "machine", "aes-key-wrap", QEMU_CAPS_AES_KEY_WRAP },
|
||||||
{ "machine", "dea-key-wrap", QEMU_CAPS_DEA_KEY_WRAP },
|
{ "machine", "dea-key-wrap", QEMU_CAPS_DEA_KEY_WRAP },
|
||||||
|
{ "chardev", "append", QEMU_CAPS_CHARDEV_FILE_APPEND },
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -335,6 +335,7 @@ typedef enum {
|
|||||||
/* 205 */
|
/* 205 */
|
||||||
QEMU_CAPS_VIRTIO_TABLET, /* -device virtio-tablet-{device,pci} */
|
QEMU_CAPS_VIRTIO_TABLET, /* -device virtio-tablet-{device,pci} */
|
||||||
QEMU_CAPS_VIRTIO_INPUT_HOST, /* -device virtio-input-host-{device,pci} */
|
QEMU_CAPS_VIRTIO_INPUT_HOST, /* -device virtio-input-host-{device,pci} */
|
||||||
|
QEMU_CAPS_CHARDEV_FILE_APPEND, /* -chardev file,append=on|off */
|
||||||
|
|
||||||
QEMU_CAPS_LAST /* this must always be the last item */
|
QEMU_CAPS_LAST /* this must always be the last item */
|
||||||
} virQEMUCapsFlags;
|
} virQEMUCapsFlags;
|
||||||
|
@ -6555,6 +6555,16 @@ qemuBuildChrChardevStr(virDomainChrSourceDefPtr dev, const char *alias,
|
|||||||
case VIR_DOMAIN_CHR_TYPE_FILE:
|
case VIR_DOMAIN_CHR_TYPE_FILE:
|
||||||
virBufferAsprintf(&buf, "file,id=char%s,path=%s", alias,
|
virBufferAsprintf(&buf, "file,id=char%s,path=%s", alias,
|
||||||
dev->data.file.path);
|
dev->data.file.path);
|
||||||
|
if (dev->data.file.append) {
|
||||||
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FILE_APPEND)) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("append not supported in this QEMU binary"));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
virBufferAsprintf(&buf, ",append=%s",
|
||||||
|
virTristateSwitchTypeToString(dev->data.file.append));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_CHR_TYPE_PIPE:
|
case VIR_DOMAIN_CHR_TYPE_PIPE:
|
||||||
|
@ -169,4 +169,5 @@
|
|||||||
<flag name='virtio-mouse'/>
|
<flag name='virtio-mouse'/>
|
||||||
<flag name='virtio-tablet'/>
|
<flag name='virtio-tablet'/>
|
||||||
<flag name='virtio-input-host'/>
|
<flag name='virtio-input-host'/>
|
||||||
|
<flag name='chardev-file-append'/>
|
||||||
</qemuCaps>
|
</qemuCaps>
|
||||||
|
@ -21,6 +21,6 @@ QEMU_AUDIO_DRV=none \
|
|||||||
-usb \
|
-usb \
|
||||||
-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-ide0-0-0,format=raw \
|
-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-ide0-0-0,format=raw \
|
||||||
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
|
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
|
||||||
-chardev file,id=charserial0,path=/tmp/serial.log \
|
-chardev file,id=charserial0,path=/tmp/serial.log,append=on \
|
||||||
-device isa-serial,chardev=charserial0,id=serial0 \
|
-device isa-serial,chardev=charserial0,id=serial0 \
|
||||||
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
|
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
<controller type='usb' index='0'/>
|
<controller type='usb' index='0'/>
|
||||||
<controller type='ide' index='0'/>
|
<controller type='ide' index='0'/>
|
||||||
<serial type='file'>
|
<serial type='file'>
|
||||||
<source path='/tmp/serial.log'/>
|
<source path='/tmp/serial.log' append='on'/>
|
||||||
<target port='0'/>
|
<target port='0'/>
|
||||||
</serial>
|
</serial>
|
||||||
<console type='file'>
|
<console type='file'>
|
||||||
|
@ -1047,7 +1047,8 @@ mymain(void)
|
|||||||
DO_TEST("serial-dev-chardev-iobase",
|
DO_TEST("serial-dev-chardev-iobase",
|
||||||
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
|
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
|
||||||
DO_TEST("serial-file-chardev",
|
DO_TEST("serial-file-chardev",
|
||||||
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
|
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
|
||||||
|
QEMU_CAPS_CHARDEV_FILE_APPEND);
|
||||||
DO_TEST("serial-unix-chardev",
|
DO_TEST("serial-unix-chardev",
|
||||||
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
|
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
|
||||||
DO_TEST("serial-tcp-chardev",
|
DO_TEST("serial-tcp-chardev",
|
||||||
|
Loading…
Reference in New Issue
Block a user