Bug 1583484

Summary: "Property '.write-cache' not found" when set cache mode for scsi block device
Product: Red Hat Enterprise Linux 7 Reporter: Fangge Jin <fjin>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
Status: CLOSED ERRATA QA Contact: Han Han <hhan>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.6CC: hhan, jdenemar, lmen, pkrempa, xuzhang, yanqzhan, yisun
Target Milestone: rcKeywords: Automation, Regression
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-4.4.0-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-30 09:55:31 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:
Embargoed:

Description Fangge Jin 2018-05-29 06:06:17 UTC
Description of problem:
"Property '.write-cache' not found" when set cache mode for scsi block device

Version-Release number of selected component:
libvirt-4.3.0-1.el7.x86_64
qemu-kvm-rhev-2.12.0-2.el7.x86_64

How reproducible:
qemu-kvm-rhev-2.12.0-2.el7.x86_64

Steps to Reproduce:
1.Prepare a guest with scsi disk and set cache mode for the disk:
    <disk type='block' device='lun'>
      <driver name='qemu' type='raw' cache='writeback'/>
      <source dev='/dev/sdb'/>
      <target dev='sda' bus='scsi'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

2. Start guest:
# virsh start 1
error: Failed to start domain 1
error: internal error: qemu unexpectedly closed the monitor: 2018-05-29T03:42:56.184086Z qemu-kvm: -device scsi-block,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,write-cache=on: Property '.write-cache' not found

The whole qemu command line is:
...
-drive file=/dev/sdb,format=raw,if=none,id=drive-scsi0-0-0-0,cache=writeback 
-device scsi-block,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,write-cache=on...


Actual results:
Guest fails to start

Expected results:
Guest can start successfully


Additional info:
libvirt-3.9.0-14.el7_5.4.x86_64 works well, and the qemu command line is: 
...
-drive file=/dev/sdb,format=raw,if=none,id=drive-scsi0-0-0-0,cache=writeback 
-device scsi-block,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0...

Comment 2 Peter Krempa 2018-05-29 07:11:52 UTC
This is already fixed upstream:

commit 16782dc329f63d41b6e9cc5717f132b769945cec 
Author: Michal Privoznik <mprivozn>
Date:   Mon May 28 16:28:09 2018 +0200

    qemu: Don't build cache= cmd line for scsi-block
    
    Trying to set any cache for <disk device='lun'/> makes no sense.
    Such disk translates into -device scsi-block on the command line
    and the device lacks any cache setting because it's merely a
    middle man between qemu and real SCSI device.

Comment 5 Han Han 2018-07-10 06:03:57 UTC
Verified on libvirt-4.5.0-2.virtcov.el7.x86_64 qemu-kvm-rhev-2.12.0-7.el7.x86_64:

1. Prepare a VM, disk of scsi controller, with cache='writeback'
# virsh dumpxml usb|awk '/<disk/,/<\/disk/' 
    <disk type='block' device='lun'>
      <driver name='qemu' type='raw' cache='writeback'/>
      <source dev='/dev/sdb'/>
      <target dev='sdb' bus='scsi'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>

2. Try to start the VM, then check the qemu cmdline:
# virsh start usb
Domain usb started

# ps aux|grep 'qemu.*cache'
qemu     15840 15.3  1.0 1721728 81308 ?       Sl   14:02   0:00 /usr/libexec/qemu-kvm -name guest=usb,debug-threads=on -S -object secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-74-usb/master-key.aes -machine pc-i440fx-rhel7.5.0,accel=kvm,usb=off,vmport=off,dump-guest-core=off -cpu SandyBridge-IBRS,vme=on,ss=on,vmx=on,pcid=on,hypervisor=on,arat=on,tsc_adjust=on,xsaveopt=on -m 1024 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid c79afb3b-399c-4d0b-aa0a-6554058967ca -device vmgenid,guid=08cff693-dcaf-4265-8301-eef484f97bb1,id=vmgenid0 -no-user-config -nodefaults -chardev socket,id=charmonitor,fd=27,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc,driftfix=slew -global kvm-pit.lost_tick_policy=delay -no-hpet -no-shutdown -global PIIX4_PM.disable_s3=1 -global PIIX4_PM.disable_s4=1 -boot menu=on,strict=on -device pci-bridge,chassis_nr=1,id=pci.1,bus=pci.0,addr=0x9 -device ich9-usb-ehci1,id=ua-usb0350607c2-728c-4af1-ad47-35a8dadbcde1,bus=pci.0,addr=0x5.0x7 -device ich9-usb-uhci1,masterbus=ua-usb0350607c2-728c-4af1-ad47-35a8dadbcde1.0,firstport=0,bus=pci.0,multifunction=on,addr=0x5 -device ich9-usb-uhci2,masterbus=ua-usb0350607c2-728c-4af1-ad47-35a8dadbcde1.0,firstport=2,bus=pci.0,addr=0x5.0x1 -device ich9-usb-uhci3,masterbus=ua-usb0350607c2-728c-4af1-ad47-35a8dadbcde1.0,firstport=4,bus=pci.0,addr=0x5.0x2 -device piix3-usb-uhci,id=ua-usb4350607c2-728c-4af1-ad47-35a8dadbcde1,bus=pci.0,addr=0x6 -device piix4-usb-uhci,id=ua-usb5350607c2-728c-4af1-ad47-35a8dadbcde1,bus=pci.0,addr=0xa -device vt82c686b-usb-uhci,id=ua-usb6350607c2-728c-4af1-ad47-35a8dadbcde1,bus=pci.0,addr=0xb -device nec-usb-xhci,p2=15,p3=15,id=ua-usb7350607c2-728c-4af1-ad47-35a8dadbcde1,bus=pci.0,addr=0xc -device qemu-xhci,p2=15,p3=15,id=ua-usb8350607c2-728c-4af1-ad47-35a8dadbcde1,bus=pci.0,addr=0xd -device nec-usb-xhci,id=usb6,bus=pci.0,addr=0xe -device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x7 -device ahci,id=sata0,bus=pci.0,addr=0x10 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0xf -device usb-ccid,id=ccid0,bus=ua-usb0350607c2-728c-4af1-ad47-35a8dadbcde1.0,port=1 -drive file=/var/lib/libvirt/images/usb.qcow2,format=qcow2,if=none,id=drive-scsi0-0-0-0 -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,bootindex=1 -drive file=/dev/sdb,format=raw,if=none,id=drive-scsi0-0-0-1,**cache=writeback** -device scsi-block,bus=scsi0.0,channel=0,scsi-id=0,lun=1,drive=drive-scsi0-0-0-1,id=scsi0-0-0-1 -netdev tap,fd=30,id=hostnet0 -device rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:51:11:93,bus=pci.0,addr=0x3 -chardev spicevmc,id=charsmartcard0,name=smartcard -device ccid-card-passthru,chardev=charsmartcard0,id=smartcard0,bus=ccid0.0 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -chardev spicevmc,id=charchannel0,name=vdagent -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=com.redhat.spice.0 -chardev socket,id=charchannel1,fd=31,server,nowait -device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,id=channel1,name=org.qemu.guest_agent.0 -device usb-tablet,id=input2,bus=ua-usb0350607c2-728c-4af1-ad47-35a8dadbcde1.0,port=2 -device usb-mouse,id=input3,bus=ua-usb0350607c2-728c-4af1-ad47-35a8dadbcde1.0,port=3 -device usb-kbd,id=input4,bus=ua-usb0350607c2-728c-4af1-ad47-35a8dadbcde1.0,port=4 -spice port=5900,addr=0.0.0.0,disable-ticketing,image-compression=off,seamless-migration=on -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vram64_size_mb=0,vgamem_mb=16,max_outputs=1,bus=pci.0,addr=0x2 -device intel-hda,id=sound0,bus=pci.0,addr=0x4 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -chardev spicevmc,id=charredir0,name=usbredir -device usb-redir,chardev=charredir0,id=redir0,filter=0x08:0x090C:0x1000:0x0200:1|-1:-1:-1:-1:0,bus=ua-usb4350607c2-728c-4af1-ad47-35a8dadbcde1.0,port=1 -chardev spicevmc,id=charredir1,name=usbredir -device usb-redir,chardev=charredir1,id=redir1,filter=0x08:0x090C:0x1000:0x0200:1|-1:-1:-1:-1:0,bus=ua-usb0350607c2-728c-4af1-ad47-35a8dadbcde1.0,port=5 -chardev socket,id=charredir2,host=10.66.4.183,port=4000,reconnect=5 -device usb-redir,chardev=charredir2,id=redir2,filter=0x08:0x090C:0x1000:0x0200:1|-1:-1:-1:-1:0,bus=ua-usb0350607c2-728c-4af1-ad47-35a8dadbcde1.0,port=6 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x8 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny -msg timestamp=on

3. Try to detach the disk
# virsh detach-disk usb sdb
Disk detached successfully

# virsh dumpxml usb|awk '/<disk/,/<\/disk/'
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/usb.qcow2'/>
      <backingStore/>
      <target dev='sda' bus='scsi'/>
      <alias name='scsi0-0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

Works as expected. Verified.

Comment 7 errata-xmlrpc 2018-10-30 09:55:31 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.

https://access.redhat.com/errata/RHSA-2018:3113