Bug 1040281

Summary: the locked value did not change to false after umount the /dev/sr0 in guest (ide/scsi-cd)
Product: Red Hat Enterprise Linux 7 Reporter: Sibiao Luo <sluo>
Component: qemu-kvmAssignee: Virtualization Maintenance <virt-maint>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: acathrow, chayang, juzhang, michen, pbonzini, qzhang, virt-maint, xfu
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: 2013-12-12 05:14:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Sibiao Luo 2013-12-11 06:02:22 UTC
Description of problem:
boot up guest with a iSO attached via ide/scsi-cd interface, the locked value will changed to true after the cdrom mounted automatically in guest due to the udev rule, but the locked value did not change if i umount it manually.
Also tried it in rhel6.5 that did not hit such issue.

Version-Release number of selected component (if applicable):
host info:
3.10.0-60.el7.x86_64
qemu-kvm-rhev-1.5.3-21.el7.x86_64
seabios-1.7.2.2-4.el7.x86_64
guest info:
3.10.0-60.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.boot up guest with a iSO attached via ide/scsi-cd interface.
# /usr/libexec/qemu-kvm -M pc -S -cpu SandyBridge -enable-kvm -m 2048 -smp 4,sockets=2,cores=2,threads=1 -no-kvm-pit-reinjection...-drive file=/home/my-cdrom1.iso,if=none,id=drive-data-disk,cache=none,media=cdrom,format=raw,aio=native,werror=stop,rerror=stop -device virtio-scsi-pci,id=scsi1,bus=pci.0,addr=0x7 -device scsi-cd,drive=drive-data-disk,bus=scsi1.0,id=data-disk
2.check the locked value after the cdrom mounted automatically in guest.
guest ]# mount
...
/dev/sr0 on /run/media/root/CDROM type iso9660 (ro,nosuid,nodev,relatime,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500,uhelper=udisks2)
(qemu) info block
...
drive-data-disk: removable=1 locked=1 tray-open=0 io-status=ok file=/home/my-cdrom1.iso ro=1 drv=raw encrypted=0 bps=0 bps_rd=0 bps_wr=0 iops=0 iops_rd=0 iops_wr=0

{"execute":"qmp_capabilities"}
{"return": {}}
{"execute":"query-block"}
{"return": [...{"io-status": "ok", "device": "drive-data-disk", "locked": true, "removable": true, "inserted": {"iops_rd": 0, "image": {"virtual-size": 325482496, "filename": "/home/my-cdrom1.iso", "format": "raw", "actual-size": 325484544}, "iops_wr": 0, "ro": true, "backing_file_depth": 0, "drv": "raw", "iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": "/home/my-cdrom1.iso", "encryption_key_missing": false}, "tray_open": false, "type": "unknown"}...]}
3.umount the cdrom manually in guest and check the locked value.
# umount /run/media/root/CDROM
{"execute":"query-block"}

Actual results:
after step 3, the locked value still true after i umount the cdrom in guest.
{"execute":"query-block"}
{"return": [...{"io-status": "ok", "device": "drive-data-disk", "locked": true, "removable": true, "inserted": {"iops_rd": 0, "image": {"virtual-size": 325482496, "filename": "/home/my-cdrom1.iso", "format": "raw", "actual-size": 325484544}, "iops_wr": 0, "ro": true, "backing_file_depth": 0, "drv": "raw", "iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": "/home/my-cdrom1.iso", "encryption_key_missing": false}, "tray_open": false, "type": "unknown"}...]}

(qemu) info block
...
drive-data-disk: removable=1 locked=1 tray-open=0 io-status=ok file=/home/my-cdrom1.iso ro=1 drv=raw encrypted=0 bps=0 bps_rd=0 bps_wr=0 iops=0 iops_rd=0 iops_wr=0

Expected results:
it should change to false after umount the cdrom in guest.

Additional info:
# /usr/libexec/qemu-kvm -M pc -S -cpu SandyBridge -enable-kvm -m 2048 -smp 4,sockets=2,cores=2,threads=1 -no-kvm-pit-reinjection -usb -device usb-tablet,id=input0 -name sluo -uuid 990ea161-6b67-47b2-b803-19fb01d30d30 -rtc base=localtime,clock=host,driftfix=slew -device virtio-serial-pci,id=virtio-serial0,max_ports=16,vectors=0,bus=pci.0,addr=0x3 -chardev socket,id=channel1,path=/tmp/helloworld1,server,nowait -device virtserialport,chardev=channel1,name=com.redhat.rhevm.vdsm,bus=virtio-serial0.0,id=port1 -chardev socket,id=channel2,path=/tmp/helloworld2,server,nowait -device virtserialport,chardev=channel2,name=com.redhat.rhevm.vdsm,bus=virtio-serial0.0,id=port2 -drive file=iscsi://10.66.90.100:3260/iqn.2001-05.com.equallogic:0-8a0906-4c41f7d03-453f49b421052a57-s2-sluo-270305-1/0,if=none,id=drive-system-disk,cache=none,format=raw,aio=native,werror=stop,rerror=stop,discard=on -iscsi id=iqn0 -device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x4,num_queues=4,ioeventfd=on -device scsi-block,drive=drive-system-disk,bus=scsi0.0,id=libiscsi-system-disk,bootindex=1 -netdev tap,id=hostnet0,vhost=on,script=/etc/qemu-ifup -device rtl8139,netdev=hostnet0,id=rtl8139-net-pci0,mac=00:01:02:B6:40:21,bus=pci.0,addr=0x5 -device virtio-balloon-pci,id=ballooning,bus=pci.0,addr=0x6 -global PIIX4_PM.disable_s3=0 -global PIIX4_PM.disable_s4=0 -k en-us -boot menu=on -qmp tcp:0:4444,server,nowait -serial unix:/tmp/ttyS0,server,nowait -vnc :1 -spice disable-ticketing,port=5931 -monitor stdio -drive file=/home/my-cdrom1.iso,if=none,id=drive-data-disk,cache=none,media=cdrom,format=raw,aio=native,werror=stop,rerror=stop -device virtio-scsi-pci,id=scsi1,bus=pci.0,addr=0x7 -device scsi-cd,drive=drive-data-disk,bus=scsi1.0,id=data-disk

Comment 1 Paolo Bonzini 2013-12-11 13:38:23 UTC
Locking is handled differently in RHEL6 and RHEL7.  RHEL7 will keep the medium locked in order to receive "eject request" events from the disk (from qemu in this case).  So the medium is locked even after /dev/sr0 is unmounted, but if you eject it from the monitor, it will be ejected after 2-3 seconds.  Libvirt abstracts all this nicely so that eject and change work even with RHEL7.

Comment 2 Sibiao Luo 2013-12-12 05:12:28 UTC
(In reply to Paolo Bonzini from comment #1)
> Locking is handled differently in RHEL6 and RHEL7.  RHEL7 will keep the
> medium locked in order to receive "eject request" events from the disk (from
> qemu in this case).  So the medium is locked even after /dev/sr0 is
> unmounted, but if you eject it from the monitor, it will be ejected after
> 2-3 seconds.  Libvirt abstracts all this nicely so that eject and change
> work even with RHEL7.
OK,  thanks for your kindly reminds.