Bug 1995710

Summary: RFE: Allow virtio-scsi CD-ROM media change with IOThreads
Product: Red Hat Enterprise Linux 9 Reporter: Stefan Hajnoczi <stefanha>
Component: qemu-kvmAssignee: Emanuele Giuseppe Esposito <eesposit>
qemu-kvm sub component: virtio-blk,scsi QA Contact: qing.wang <qinwang>
Status: CLOSED ERRATA Docs Contact:
Severity: low    
Priority: low CC: coli, eesposit, jinzhao, juzhang, kkiwi, menli, phou, qinwang, smitterl, virt-maint, zhenyzha
Version: 9.0Keywords: FutureFeature, RFE, Triaged
Target Milestone: beta   
Target Release: ---   
Hardware: All   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-7.0.0-4.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-15 09:53:23 UTC Type: Feature Request
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Stefan Hajnoczi 2021-08-19 16:08:46 UTC
Description of problem:
scsi-cd media change with virtio-scsi dataplane (IOThreads) was forbidden downstream in 2017 (see bz1378816). This was implemented as a temporary downstream-only patch while upstream worked on a proper solution. It seems we never revisited this so it's time to do that for RHEL9.

Downstream is still carrying this patch. The upstream status needs to be investigated. Since the infrastructure for AioContext changes has improved since 2017, it may already work but it at least needs to be tested.

The goal is to enable scsi-cd media change with virtio-scsi dataplane. Given that this limitation hasn't been requested thus far, consider this a lower priority bug for now.

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


How reproducible:
100%

Steps to Reproduce:
These steps were taken from bz1378816.
1.Start VM with following commands:
/usr/libexec/qemu-kvm \
 -device virtio-scsi-pci,id=scsi0 \
 -drive file=sysdisk.qcow2,format=qcow2,id=drive_sysdisk,if=none,cache=none,aio=native,werror=stop,rerror=stop \
 -device scsi-hd,drive=drive_sysdisk,bus=scsi0.0,id=device_sysdisk,bootindex=0 \
 -object iothread,id=iothread0 \
 -device virtio-scsi-pci,id=scsi1,iothread=iothread0 \
 -drive file=/home/test/backup/cd.iso,if=none,cache=none,media=cdrom,id=drive_cd,readonly=on \
 -device scsi-cd,bus=scsi1.0,drive=drive_cd,id=device_cd \

2.Eject cdrom:
(qemu) info block
drive_sysdisk (#block101): sysdisk.qcow2 (qcow2)
    Cache mode:       writeback, direct
drive_cd (#block367): /home/test/backup/cd.iso (raw, read-only)
    Removable device: locked, tray closed
    Cache mode:       writeback, direct

(qemu) eject drive_cd
Device 'drive_cd' is locked and force was not specified, wait for tray to open and try again

(qemu) info block
drive_sysdisk (#block101): sysdisk.qcow2 (qcow2)
    Cache mode:       writeback, direct
drive_cd (#block367): /home/test/backup/cd.iso (raw, read-only)
    Removable device: not locked, tray open
    Cache mode:       writeback, direct

3.Change cd:
(qemu) change drive_cd /home/test/backup/cd.iso

Actual results:
The following error is shown:
scsi-cd is not supported by data plane

Expected results:
Changing medium succeeds.


Additional info:
Daniel Berrange noticed we are still carrying the downstream-only patch here: https://gitlab.com/redhat/rhel/src/qemu-kvm/qemu-kvm/-/merge_requests/21#note_644353982

Comment 3 qing.wang 2022-05-07 07:53:23 UTC
Passed testing on
Red Hat Enterprise Linux release 9.0 (Plow)
5.14.0-70.13.1.el9_0.x86_64
qemu-kvm-6.2.0-11.el9_0.2.esposem202205051552.x86_64
seabios-bin-1.15.0-1.el9.noarch
edk2-ovmf-20220126gitbb1bba3d77-3.el9.noarch
virtio-win-prewhql-0.1-215.iso


Test steps
1.
dd if=/dev/urandom of=/tmp/orig.dat bs=1M count=100
mkisofs -o /tmp/orig0.iso /tmp/orig.dat
mkisofs -o /tmp/orig1.iso /tmp/orig.dat
cp -rf /tmp/orig0.iso /tmp/new0.iso
cp -rf /tmp/orig1.iso /tmp/new1.iso

2.boot vm
/usr/libexec/qemu-kvm \
  -name testvm \
  -machine q35 \
  -m  6G \
  -smp 2 \
  -cpu host,vmx,+kvm_pv_unhalt \
  -device ich9-usb-ehci1,id=usb1 \
  -device usb-tablet,id=usb-tablet1,bus=usb1.0,port=1 \
   \
   \
  -device pcie-root-port,id=pcie-root-port-0,multifunction=on,bus=pcie.0,addr=0x3,chassis=1 \
  -device pcie-root-port,id=pcie-root-port-1,port=0x1,addr=0x3.0x1,bus=pcie.0,chassis=2 \
  -device pcie-root-port,id=pcie-root-port-2,port=0x2,addr=0x3.0x2,bus=pcie.0,chassis=3 \
  -device pcie-root-port,id=pcie-root-port-3,port=0x3,addr=0x3.0x3,bus=pcie.0,chassis=4 \
  -device pcie-root-port,id=pcie-root-port-4,port=0x4,addr=0x3.0x4,bus=pcie.0,chassis=5 \
  -device pcie-root-port,id=pcie-root-port-5,port=0x5,addr=0x3.0x5,bus=pcie.0,chassis=6 \
  -device pcie-root-port,id=pcie-root-port-6,port=0x6,addr=0x3.0x6,bus=pcie.0,chassis=7 \
  -device pcie-root-port,id=pcie-root-port-7,port=0x7,addr=0x3.0x7,bus=pcie.0,chassis=8 \
  -device pcie-root-port,id=pcie_extra_root_port_0,bus=pcie.0,addr=0x4  \
  -object iothread,id=iothread0 \
  -device virtio-scsi-pci,id=scsi0,bus=pcie-root-port-5 \
  -device virtio-scsi-pci,id=scsi1,bus=pcie-root-port-6,iothread=iothread0 \
  -blockdev driver=qcow2,file.driver=file,cache.direct=off,cache.no-flush=on,file.filename=/home/kvm_autotest_root/images/rhel860-64-virtio-scsi.qcow2,node-name=drive_image1   \
  -device scsi-hd,id=os,drive=drive_image1,bus=scsi0.0,bootindex=0,serial=OS_DISK   \
  \
  -drive file=/tmp/orig0.iso,if=none,cache=none,media=cdrom,id=drive_cd0,readonly=on \
  -device scsi-cd,id=cd0,drive=drive_cd0,write-cache=on,bus=scsi1.0 \
  \
  -blockdev node-name=file_cd1,driver=file,read-only=on,filename=/tmp/orig1.iso \
  -blockdev node-name=drive_cd1,driver=raw,read-only=on,file=file_cd1 \
  -device scsi-cd,id=cd1,drive=drive_cd1,write-cache=on,bus=scsi1.0 \
    \
  -vnc :5 \
  -monitor stdio \
  -qmp tcp:0:5955,server=on,wait=off \
  -device virtio-net-pci,mac=9a:b5:b6:b1:b2:b7,id=nic1,netdev=nicpci,bus=pcie-root-port-7 \
  -netdev tap,id=nicpci \
  -chardev socket,id=qmpmonitor1,path=/var/tmp/run-qmp.log,server=on,wait=off \
  -mon chardev=qmpmonitor1,mode=control \
  -chardev socket,id=hmpmonitor1,path=/var/tmp/run-hmp.log,server=on,wait=off \
  -mon chardev=hmpmonitor1,mode=readline \
  -chardev socket,id=charserial1,path=/var/tmp/run-serial.log,server=on,wait=off \
  -device isa-serial,chardev=charserial1,id=serial1 \
  -chardev file,path=/var/tmp/run-seabios.log,id=charseabios1 \
  -device isa-debugcon,chardev=charseabios1,iobase=0x402 \
  -D debug.log \
  -boot menu=on,reboot-timeout=1000,strict=off \


3 execute hmp command for drive usage

(qemu) info block
drive_cd0 (#block241): /tmp/orig0.iso (raw, read-only)
    Attached to:      cd0
    Removable device: not locked, tray closed
    Cache mode:       writeback, direct

sd0: [not inserted]
    Removable device: not locked, tray closed

drive_image1: /home/kvm_autotest_root/images/rhel860-64-virtio-scsi.qcow2 (qcow2)
    Attached to:      os
    Cache mode:       writeback, ignore flushes

drive_cd1: /tmp/orig1.iso (raw, read-only)
    Attached to:      cd1
    Removable device: not locked, tray closed
    Cache mode:       writeback
(qemu) eject drive_cd0
(qemu) change drive_cd0 /tmp/new0.iso
(qemu) info block
drive_cd0 (#block471): /tmp/new0.iso (raw, read-only)
    Attached to:      cd0
    Removable device: not locked, tray closed
    Cache mode:       writeback, direct

sd0: [not inserted]
    Removable device: not locked, tray closed

drive_image1: /home/kvm_autotest_root/images/rhel860-64-virtio-scsi.qcow2 (qcow2)
    Attached to:      os
    Cache mode:       writeback, ignore flushes

drive_cd1: /tmp/orig1.iso (raw, read-only)
    Attached to:      cd1
    Removable device: not locked, tray closed
    Cache mode:       writeback
 
4.execute qmp command for blockdev usage

{"execute":"qmp_capabilities"}
{'execute': 'blockdev-change-medium', 'arguments': {'id': 'cd1', 'filename': '/tmp/new1.iso'}}
{"return": {}}
{"timestamp": {"seconds": 1651907347, "microseconds": 802699}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "", "tray-open": true, "id": "cd1"}}
{"timestamp": {"seconds": 1651907347, "microseconds": 802769}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "", "tray-open": false, "id": "cd1"}}
{"return": {}}

Comment 5 Klaus Heinrich Kiwi 2022-05-09 16:49:49 UTC
done. Setting DTM to 12 as well, let me know if that is not ok

Comment 8 Yanan Fu 2022-05-23 05:43:11 UTC
QE bot(pre verify): Set 'Verified:Tested,SanityOnly' as gating/tier1 test pass.

Comment 12 qing.wang 2022-05-24 09:03:48 UTC
Passed test on

Red Hat Enterprise Linux release 9.1 Beta (Plow)
5.14.0-96.el9.x86_64
qemu-kvm-7.0.0-4.el9.x86_64
seabios-bin-1.16.0-2.el9.noarch
edk2-ovmf-20220221gitb24306f15d-1.el9.noarch
virtio-win-prewhql-0.1-219.iso



Test steps
1.
dd if=/dev/urandom of=/tmp/orig.dat bs=1M count=100
mkisofs -o /tmp/orig0.iso /tmp/orig.dat
mkisofs -o /tmp/orig1.iso /tmp/orig.dat
cp -rf /tmp/orig0.iso /tmp/new0.iso
cp -rf /tmp/orig1.iso /tmp/new1.iso

2.boot vm
/usr/libexec/qemu-kvm \
  -name testvm \
  -machine q35 \
  -m  6G \
  -smp 2 \
  -cpu host,vmx,+kvm_pv_unhalt \
  -device ich9-usb-ehci1,id=usb1 \
  -device usb-tablet,id=usb-tablet1,bus=usb1.0,port=1 \
   \
   \
  -device pcie-root-port,id=pcie-root-port-0,multifunction=on,bus=pcie.0,addr=0x3,chassis=1 \
  -device pcie-root-port,id=pcie-root-port-1,port=0x1,addr=0x3.0x1,bus=pcie.0,chassis=2 \
  -device pcie-root-port,id=pcie-root-port-2,port=0x2,addr=0x3.0x2,bus=pcie.0,chassis=3 \
  -device pcie-root-port,id=pcie-root-port-3,port=0x3,addr=0x3.0x3,bus=pcie.0,chassis=4 \
  -device pcie-root-port,id=pcie-root-port-4,port=0x4,addr=0x3.0x4,bus=pcie.0,chassis=5 \
  -device pcie-root-port,id=pcie-root-port-5,port=0x5,addr=0x3.0x5,bus=pcie.0,chassis=6 \
  -device pcie-root-port,id=pcie-root-port-6,port=0x6,addr=0x3.0x6,bus=pcie.0,chassis=7 \
  -device pcie-root-port,id=pcie-root-port-7,port=0x7,addr=0x3.0x7,bus=pcie.0,chassis=8 \
  -device pcie-root-port,id=pcie_extra_root_port_0,bus=pcie.0,addr=0x4  \
  -object iothread,id=iothread0 \
  -device virtio-scsi-pci,id=scsi0,bus=pcie-root-port-5 \
  -device virtio-scsi-pci,id=scsi1,bus=pcie-root-port-6,iothread=iothread0 \
  -blockdev driver=qcow2,file.driver=file,cache.direct=off,cache.no-flush=on,file.filename=/home/kvm_autotest_root/images/rhel860-64-virtio-scsi.qcow2,node-name=drive_image1   \
  -device scsi-hd,id=os,drive=drive_image1,bus=scsi0.0,bootindex=0,serial=OS_DISK   \
  \
  -drive file=/tmp/orig0.iso,if=none,cache=none,media=cdrom,id=drive_cd0,readonly=on \
  -device scsi-cd,id=cd0,drive=drive_cd0,write-cache=on,bus=scsi1.0 \
  \
  -blockdev node-name=file_cd1,driver=file,read-only=on,filename=/tmp/orig1.iso \
  -blockdev node-name=drive_cd1,driver=raw,read-only=on,file=file_cd1 \
  -device scsi-cd,id=cd1,drive=drive_cd1,write-cache=on,bus=scsi1.0 \
    \
  -vnc :5 \
  -monitor stdio \
  -qmp tcp:0:5955,server=on,wait=off \
  -device virtio-net-pci,mac=9a:b5:b6:b1:b2:b7,id=nic1,netdev=nicpci,bus=pcie-root-port-7 \
  -netdev tap,id=nicpci \
  -chardev socket,id=qmpmonitor1,path=/var/tmp/run-qmp.log,server=on,wait=off \
  -mon chardev=qmpmonitor1,mode=control \
  -chardev socket,id=hmpmonitor1,path=/var/tmp/run-hmp.log,server=on,wait=off \
  -mon chardev=hmpmonitor1,mode=readline \
  -chardev socket,id=charserial1,path=/var/tmp/run-serial.log,server=on,wait=off \
  -device isa-serial,chardev=charserial1,id=serial1 \
  -chardev file,path=/var/tmp/run-seabios.log,id=charseabios1 \
  -device isa-debugcon,chardev=charseabios1,iobase=0x402 \
  -D debug.log \
  -boot menu=on,reboot-timeout=1000,strict=off \


3 execute hmp command for drive usage

(qemu) info block
drive_cd0 (#block241): /tmp/orig0.iso (raw, read-only)
    Attached to:      cd0
    Removable device: not locked, tray closed
    Cache mode:       writeback, direct

sd0: [not inserted]
    Removable device: not locked, tray closed

drive_image1: /home/kvm_autotest_root/images/rhel860-64-virtio-scsi.qcow2 (qcow2)
    Attached to:      os
    Cache mode:       writeback, ignore flushes

drive_cd1: /tmp/orig1.iso (raw, read-only)
    Attached to:      cd1
    Removable device: not locked, tray closed
    Cache mode:       writeback
(qemu) eject drive_cd0
(qemu) change drive_cd0 /tmp/new0.iso
(qemu) info block
drive_cd0 (#block471): /tmp/new0.iso (raw, read-only)
    Attached to:      cd0
    Removable device: not locked, tray closed
    Cache mode:       writeback, direct

sd0: [not inserted]
    Removable device: not locked, tray closed

drive_image1: /home/kvm_autotest_root/images/rhel860-64-virtio-scsi.qcow2 (qcow2)
    Attached to:      os
    Cache mode:       writeback, ignore flushes

drive_cd1: /tmp/orig1.iso (raw, read-only)
    Attached to:      cd1
    Removable device: not locked, tray closed
    Cache mode:       writeback
 
4.execute qmp command for blockdev usage

{"execute":"qmp_capabilities"}
{'execute': 'blockdev-change-medium', 'arguments': {'id': 'cd1', 'filename': '/tmp/new1.iso'}}
{"return": {}}
{"timestamp": {"seconds": 1651907347, "microseconds": 802699}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "", "tray-open": true, "id": "cd1"}}
{"timestamp": {"seconds": 1651907347, "microseconds": 802769}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "", "tray-open": false, "id": "cd1"}}
{"return": {}}

Comment 14 errata-xmlrpc 2022-11-15 09:53:23 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 (Moderate: qemu-kvm security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

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

https://access.redhat.com/errata/RHSA-2022:7967