Bug 831708 - Spice-Server, VM Creation works when a bad value is entered for streaming-video
Summary: Spice-Server, VM Creation works when a bad value is entered for streaming-video
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm
Version: 6.3
Hardware: x86_64
OS: Linux
Target Milestone: rc
: ---
Assignee: Uri Lublin
QA Contact: Virtualization Bugs
Depends On:
TreeView+ depends on / blocked
Reported: 2012-06-13 15:51 UTC by Vimal Patel
Modified: 2013-02-21 07:37 UTC (History)
9 users (show)

Fixed In Version: qemu-kvm-
Doc Type: Bug Fix
Doc Text:
Before Fix: When a bad value was given for qemu-kvm command line "-spice" option "streaming-video", it was ignored. The default value was used and the VM was running. After Fix: When a bad value is given for qemu-kvm command line "-spice" option "streaming-video", an error message is shown and the program exits.
Clone Of:
Last Closed: 2013-02-21 07:37:09 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2013:0527 0 normal SHIPPED_LIVE qemu-kvm bug fix and enhancement update 2013-02-20 21:51:08 UTC

Description Vimal Patel 2012-06-13 15:51:58 UTC
Description of problem:
When creating a VM with qemu-kvm and a bad_value is entered for the streaming-video option, the VM creation still works.  However, the only acceptable values should be [off | all | filter], and if these aren't set, then VM creation should not occur and it should gracefully exit.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Start VM creation using qemu-kvm, and set the streaming-video=bad_value (Actual cmd used: /usr/libexec/qemu-kvm -name 'vm1' -nodefaults -monitor unix:'/tmp/monitor-humanmonitor1-20120608-155203-bZeX',server,nowait -serial unix:'/tmp/serial-20120608-155203-bZeX',server,nowait -device ich9-usb-uhci1,id=usb1 -drive file='/tmp/kvm_autotest_root/images/rhel63-64.qcow2',index=0,if=ide,cache=none -device e1000,netdev=idRxxrhi,mac='9a:12:47:29:97:66',id='idjm0PxD' -netdev tap,id=idRxxrhi,fd=22 -m 1024 -smp 1 -device usb-tablet,id=usb-tablet1,bus=usb1.0 -spice port=3000,disable-ticketing,image-compression=auto_glz,jpeg-wan-compression=auto,zlib-glz-wan-compression=auto,streaming-video=bad_value,playback-compression=on -vga qxl)

Actual results:
VM Creation is successful

Expected results:
Graceful exit of the command.

Additional info:
Same behavior on 6.2 and 6.3

Comment 2 Uri Lublin 2012-08-07 17:25:09 UTC
When using libvirt to start VMs, this problem would not happen.
Currently, when a bad param is given to the -spice streaming-video option, it is ignored and the default ("filter") value is used.

Looking at the code, I found that spice_server_set_streaming_video() (spice-server) does returns -1 on bad param. The calling function qemu_spice_init (qemu-kvm) does not check the return value. I'm not sure if using the default value on bad param done on purpose or not.

If we want to fix this bug, the return value should be looked at, and if it's -1 (or <0) exit the program

Comment 3 Vimal Patel 2012-08-07 18:16:30 UTC
From our testing, We found that an invalid value entered from streaming-video is the only spice value that lets the VM be launched instead of returning an error.  For the other cases (image compression, wan compression, playback compression, bad port value), the VM does not get launched and returns an error.

Comment 4 Christophe Fergeau 2012-08-10 16:41:06 UTC
Took me a while to understand why streaming-video was behaving differently from the other options, and actually I think this can be fixed with a simple one-line patch:

diff --git a/ui/spice-core.c b/ui/spice-core.c
index 4fc48f8..3eed1da 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -344,7 +344,7 @@ static const char *stream_video_names[] = {
     [ SPICE_STREAM_VIDEO_FILTER ] = "filter",
 #define parse_stream_video(_name) \
-    name2enum(_name, stream_video_names, ARRAY_SIZE(stream_video_names))
+    parse_name(_name, "stream video control", stream_video_names, ARRAY_SIZE(stream_video_names))

 static const char *compression_names[] = {
     [ SPICE_IMAGE_COMPRESS_OFF ]      = "off",

Comment 5 Uri Lublin 2012-08-13 08:22:42 UTC
(In reply to comment #4)
Yes, that should fix it.

Comment 6 Christophe Fergeau 2012-08-13 08:35:08 UTC
Patch sent to qemu-devel, thanks for confirming the patch makes sense!

Comment 7 Uri Lublin 2012-08-13 08:48:35 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    New Contents:
Before Fix:
    When a bad value was given for qemu-kvm command line "-spice" option "streaming-video", it was ignored. The default value was used and the VM was running.

After Fix:
    When a bad value is given for qemu-kvm command line "-spice" option "streaming-video", an error message is shown and the program exits.

Comment 8 Chao Yang 2012-09-13 02:57:02 UTC
Reproduced with qemu-kvm-, spice-server-0.10.1-10.el6.x86_64.

1. passing invalid value to streaming-video
/usr/libexec/qemu-kvm -M rhel6.3.0 -enable-kvm -m 2048 -smp 4,sockets=2,cores=2,threads=1 -drive file=test.qcow2,if=none,id=drive-virtio-disk0,format=qcow2,serial=f82002eb-520c-469b-90c2-663277e90437,cache=none,werror=stop,rerror=stop,aio=native -device virtio-blk-pci,scsi=off,bus=pci.0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1  -netdev tap,id=hostnet0,vhost=on -device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:1a:4a:42:0b:38,bus=pci.0  -k en-us -vga qxl -spice port=5900,disable-ticketing,image-compression=auto_glz,jpeg-wan-compression=auto,zlib-glz-wan-compression=auto,streaming-video=bad_value,playback-compression=on -monitor stdio
Actual Result:
Guest successfully booted up instead of quitting on error.
Did same tests on image-compression, jpeg-wan-compression, zlib-glz-wan-compression=auto, playback-compression=on. All caused qemu-kvm quitted on invalid error.

Detail error info:
1. image-compression=bad_value
spice: invalid image compression: bad_value
 2.1 jpeg-wan-compression=bad_value
     spice: invalid wan compression: bad_value
 2.2 zlib-glz-wan-compression=bad_value
     spice: invalid wan compression: bad_value
3. playback-compression=bad_value
qemu-kvm: -spice port=5900,disable-ticketing,image-compression=auto_glz,jpeg-wan-compression=auto,zlib-glz-wan-compression=auto,streaming-video=filter,playback-compression=bad_value: Parameter 'playback-compression' expects 'on' or 'off'
parse error: port=5900,disable-ticketing,image-compression=auto_glz,jpeg-wan-compression=auto,zlib-glz-wan-compression=auto,streaming-video=filter,playback-compression=bad_value

Comment 14 Vimal Patel 2012-10-05 13:23:57 UTC
Verified on: RHEL 6.3, using qemu-kvm-, that qemu-kvm no longer allows the VM to be launched if an invalid value is set for streaming-video.

It now exits and displays the error message: 
spice: invalid stream video control: <invalid value>

Also verified that the 3 valid values of off, all, and filter work properly.

Comment 15 errata-xmlrpc 2013-02-21 07:37:09 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.