From 23f55840f5a8dcdd875b270c1e7ade59820eddc5 Mon Sep 17 00:00:00 2001 From: Anya Harter Date: Mon, 18 Jun 2018 13:57:26 -0400 Subject: [PATCH] qemu: Escape commas for qemuBuildGrapicsSPICECommandLine Add comma escaping for cfg->spiceTLSx509certdir and graphics->data.spice.rendernode. Signed-off-by: Anya Harter Reviewed-by: John Ferlan --- src/qemu/qemu_command.c | 11 ++++++++--- tests/qemuxml2argvdata/name-escape.args | 5 +++-- tests/qemuxml2argvdata/name-escape.xml | 1 + tests/qemuxml2argvtest.c | 5 +++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a9a5e200e9..20c6ac2a04 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7974,8 +7974,11 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, !cfg->spicePassword) virBufferAddLit(&opt, "disable-ticketing,"); - if (hasSecure) - virBufferAsprintf(&opt, "x509-dir=%s,", cfg->spiceTLSx509certdir); + if (hasSecure) { + virBufferAddLit(&opt, "x509-dir="); + virQEMUBuildBufferEscapeComma(&opt, cfg->spiceTLSx509certdir); + virBufferAddLit(&opt, ","); + } switch (graphics->data.spice.defaultMode) { case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE: @@ -8082,7 +8085,9 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, goto error; } - virBufferAsprintf(&opt, "rendernode=%s,", graphics->data.spice.rendernode); + virBufferAddLit(&opt, "rendernode="); + virQEMUBuildBufferEscapeComma(&opt, graphics->data.spice.rendernode); + virBufferAddLit(&opt, ","); } } diff --git a/tests/qemuxml2argvdata/name-escape.args b/tests/qemuxml2argvdata/name-escape.args index d3b908a7e6..72ed2e8410 100644 --- a/tests/qemuxml2argvdata/name-escape.args +++ b/tests/qemuxml2argvdata/name-escape.args @@ -33,6 +33,7 @@ cert3=cert3,db=/etc/pki/nssdb,,foo,id=smartcard0,bus=ccid0.0 \ -chardev pipe,id=charchannel0,path=/tmp/guestfwd,,foo \ -netdev user,guestfwd=tcp:10.0.2.1:4600-chardev:charchannel0,id=user-channel0 \ -vnc unix:/tmp/lib/domain--1-foo=1,,bar=2/vnc.sock \ --spice unix,addr=/tmp/lib/domain--1-foo=1,,bar=2/spice.sock \ --vga cirrus \ +-spice unix,addr=/tmp/lib/domain--1-foo=1,,bar=2/spice.sock,gl=on,\ +rendernode=/dev/dri/foo,,bar \ +-device cirrus-vga,id=video0,bus=pci.0,addr=0x2 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/name-escape.xml b/tests/qemuxml2argvdata/name-escape.xml index 9ca7be5968..0580de1813 100644 --- a/tests/qemuxml2argvdata/name-escape.xml +++ b/tests/qemuxml2argvdata/name-escape.xml @@ -19,6 +19,7 @@ + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index b4b98152e6..a9a493e308 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2763,6 +2763,11 @@ mymain(void) QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_SPICE, QEMU_CAPS_SPICE_UNIX, + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_VIRTIO_GPU_VIRGL, + QEMU_CAPS_SPICE_GL, + QEMU_CAPS_SPICE_RENDERNODE, + QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_CHARDEV_FILE_APPEND, QEMU_CAPS_CCID_EMULATED);