Bug 734994

Summary: qdev: weird syntax and rules (with usb device)
Product: Red Hat Enterprise Linux 6 Reporter: Chao Yang <chayang>
Component: qemu-kvmAssignee: Markus Armbruster <armbru>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2CC: ajia, areis, juzhang, michen, mkenneth, qzhou, shuang, tburke, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-08 08:20:54 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Chao Yang 2011-09-01 06:34:17 UTC
Description of problem:
Boot a guest, then hot plug a usb storage into guest, suspend guest to disk, qemu-kvm rejects to resume from s4 due to device drive is in use. In order to test s4, I disabled kvmclock.

Version-Release number of selected component (if applicable):
# uname -r
2.6.32-191.el6.x86_64
# rpm -q qemu-kvm
qemu-kvm-0.12.1.2-2.184.el6.x86_64


How reproducible:
100%

Steps to Reproduce:
1. boot a guest by:
# /usr/libexec/qemu-kvm -M rhel6.2.0 -enable-kvm -m 4096 -smp 4,sockets=1,cores=4,threads=1 -cpu cpu64-rhel6,-kvmclock -name RHEL6.1_32 -uuid e4d61315-1eb9-443c-9852-689b3f33885e -rtc base=utc,clock=host,driftfix=slew -boot dc -drive file=/tmp/mount-point/RHEL6.1-32-copy.qcow2,if=none,id=drive-ide-0-0,media=disk,format=qcow2,cache=none,werror=stop,rerror=stop -device ide-drive,drive=drive-ide-0-0,id=virt0-0-0,bootindex=1 -netdev tap,id=hostnet1 -device rtl8139,netdev=hostnet1,id=net1,mac=64:31:50:41:e1:c3 -usb -device usb-tablet,id=input1,port=1 -spice port=9000,disable-ticketing -vga qxl -global qxl-vga.vram_size=67108864 -monitor stdio -balloon none -device usb-ehci,id=ehci
2. hot add a usb storage by:
(qemu)  __com.redhat_drive_add file=/home/image/usb-storage.qcow2,id=drive-usb-0-0,media=disk,format=qcow2,cache=none,werror=stop,rerror=stop
(qemu) device_add usb-storage,drive=drive-usb-0-0,id=usb-0-0,bus=ehci.0
This usb storage works fine in guest, can create and delete files.
3. suspend to disk by
# echo disk > /sys/power/state
4. resume from s4 by adding following to the cli mentioned above:
-drive file=/home/image/usb-storage.qcow2,id=drive-usb-0-0,media=disk,format=qcow2,cache=none,werror=stop,rerror=stop -device usb-storage,drive=drive-usb-0-0,id=usb-0-0,bus=ehci.0

Actual results:
After step 4, qemu-kvm refused to boot guest with:
*** EHCI support is under development ***
qemu-kvm: -device usb-storage,drive=drive-usb-0-0,id=usb-0-0,bus=ehci.0: Property 'usb-storage.drive' can't take value 'drive-usb-0-0', it's in use


Expected results:


Additional info:

Comment 2 Chao Yang 2011-09-01 07:46:37 UTC
Here is a update:
I found it should be 'if=none' that caused this issue. In step 4, if adding 'if=none', guest can launch from S4 successfully. But it is raising another question here:

In step 2, hot add a usb storage, please see the following output with/without 'if=none':
(qemu)  __com.redhat_drive_add file=/home/image/usb-storage.qcow2,id=drive-usb-0-0,media=disk,format=qcow2,cache=none,werror=stop,rerror=stop

(qemu) __com.redhat_drive_add file=/home/image/usb-storage.qcow2,id=drive-usb-0-0,media=disk,format=qcow2,cache=none,werror=stop,rerror=stop,if=none
                                                                   ^^^^^^^^
Invalid parameter 'if'

And in step 4,  adding 'if=none', guest booted up. without 'if=none', failed to boot up.

Q: Why there is a different rule?

Comment 4 Amit Shah 2011-12-08 07:17:46 UTC
Updating summary; this is not related to S4 at all.  Markus, can you look into what's going on here?

Comment 5 Markus Armbruster 2011-12-08 08:20:54 UTC
Step 4 adds an IDE disk, then tries to reuse its backend for an usb-storage device.  Fails as expected.

The command line version of "__com.redhat_drive_add OPTS" is "-drive if=none,OPTS".  The reporter mistakenly tried just "-drive OPTS", which is short for "-drive if=ide,OPTS".

Why is this so?

-drive configures both backend and frontend.  if=ide gets you an IDE disk frontend, if=floppy a floppy drive frontend, if=virtio a virtio-blk frontend, and so forth.  Default is if=ide.

Except for if=none, which configures *only* a backend.  You configure the frontend separately, with -device.  Separate configuration is desirable for cleanliness and flexibility.  Unfortunately, it was shoehorned into -drive using the special if=none.  That was probably a design mistake, but it's ABI now, and can't be changed.

__com.redhat_drive_add is *not* like -drive, it's like -drive if=none:

(qemu) help __com.redhat_drive_add 
__com.redhat_drive_add id=name,[file=file][,format=f][,media=d]... -- Create a drive similar to -device if=none.

Note: if=none is *implied* with __com.redhat_drive_add, you can't have it in the argument.

We hope to have a cleaner and less confusing way to create block backends in time for RHEL-7.

Closing NOTABUG.