Greetings Peter,
Sent: Monday, October 19, 2020 at 7:35 PM
From: "Peter Krempa" <pkrempa(a)redhat.com>
To: libvir-list(a)redhat.com
Cc: "daggs" <daggs(a)gmx.com>
Subject: Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
(self) NACK to those above 'host_cdrom' doesn't work with /dev/sg* as it
doesn't detect that its a generic device for passthrough. Using
'host_device' is needed here, so the code we have currently is correct.
I've tried this in nested virtual environment and the passthrough works
fine for me.
daggs,
I need to start over, could you please post the following info. (please
gather it again, so that it's all consistent):
host OS side:
libvirt version
libvirtd (libvirt) 6.8.0
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 2.7T 0 disk
└─sda1 8:1 0 2.7T 0 part /mnt/media
sdb 8:16 1 14.3G 0 disk
├─sdb1 8:17 1 2M 0 part
├─sdb2 8:18 1 128M 0 part
├─sdb3 8:19 1 2.5G 0 part [SWAP]
└─sdb4 8:20 1 11.7G 0 part /
sr0 11:0 1 1024M 0 rom
lsscsi
[0:0:0:0] cd/dvd HL-DT-ST DVDRAM GH24NSD1 LW00
/dev/sr0
[3:0:0:0] disk ATA ST3000DM001-1ER1 CC25 /dev/sda
[6:0:0:0] disk SanDisk Ultra Fit 1.00 /dev/sdb
VM XML file
<domain type='kvm' id='3'>
<name>streamer-vm-q35</name>
<uuid>4fb1463b-837c-40fc-a760-a69afc040a1a</uuid>
<memory unit='KiB'>8388608</memory>
<currentMemory unit='KiB'>8388608</currentMemory>
<vcpu placement='static' current='1'>2</vcpu>
<resource>
<partition>/machine</partition>
</resource>
<os>
<type arch='x86_64' machine='pc-q35-5.0'>hvm</type>
<loader readonly='yes'
type='pflash'>/usr/share/qemu/edk2-x86_64-secure-code.fd</loader>
<nvram
template='/usr/share/qemu/edk2-i386-vars.fd'>/var/lib/libvirt/qemu/nvram/streamer-vm-q35_VARS.fd</nvram>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<smm state='on'/>
</features>
<cpu mode='host-passthrough' check='none'
migratable='on'>
<topology sockets='1' dies='1' cores='1'
threads='2'/>
</cpu>
<clock offset='utc'>
<timer name='rtc' tickpolicy='catchup'/>
<timer name='pit' tickpolicy='delay'/>
<timer name='hpet' present='no'/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<pm>
<suspend-to-mem enabled='no'/>
<suspend-to-disk enabled='no'/>
</pm>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/home/streamer/streamer.qcow2' index='1'/>
<backingStore/>
<target dev='vda' bus='virtio'/>
<alias name='virtio-disk0'/>
<address type='pci' domain='0x0000' bus='0x05'
slot='0x00' function='0x0'/>
</disk>
<controller type='usb' index='0' model='qemu-xhci'>
<alias name='usb'/>
<address type='pci' domain='0x0000' bus='0x04'
slot='0x00' function='0x0'/>
</controller>
<controller type='sata' index='0'>
<alias name='ide'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x1f' function='0x2'/>
</controller>
<controller type='pci' index='0' model='pcie-root'>
<alias name='pcie.0'/>
</controller>
<controller type='pci' index='1'
model='dmi-to-pci-bridge'>
<model name='i82801b11-bridge'/>
<alias name='pci.1'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x1e' function='0x0'/>
</controller>
<controller type='pci' index='2' model='pci-bridge'>
<model name='pci-bridge'/>
<target chassisNr='2'/>
<alias name='pci.2'/>
<address type='pci' domain='0x0000' bus='0x01'
slot='0x00' function='0x0'/>
</controller>
<controller type='pci' index='3'
model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='3' port='0x8'/>
<alias name='pci.3'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x0' multifunction='on'/>
</controller>
<controller type='pci' index='4'
model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='4' port='0x9'/>
<alias name='pci.4'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x1'/>
</controller>
<controller type='pci' index='5'
model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='5' port='0xa'/>
<alias name='pci.5'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x2'/>
</controller>
<controller type='pci' index='6'
model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='6' port='0xb'/>
<alias name='pci.6'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x3'/>
</controller>
<controller type='pci' index='7'
model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='7' port='0xc'/>
<alias name='pci.7'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x4'/>
</controller>
<controller type='scsi' index='0' model='virtio-scsi'>
<alias name='scsi0'/>
<address type='pci' domain='0x0000' bus='0x02'
slot='0x01' function='0x0'/>
</controller>
<interface type='network'>
<mac address='52:54:00:5a:4c:8c'/>
<source network='default'
portid='11d02025-6f04-4cfd-9236-28af102b6edf' bridge='virtsw'/>
<target dev='virtsw-streamer'/>
<model type='e1000e'/>
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x03'
slot='0x00' function='0x0'/>
</interface>
<serial type='pty'>
<source path='/dev/pts/2'/>
<target type='isa-serial' port='0'>
<model name='isa-serial'/>
</target>
<alias name='serial0'/>
</serial>
<console type='pty' tty='/dev/pts/2'>
<source path='/dev/pts/2'/>
<target type='serial' port='0'/>
<alias name='serial0'/>
</console>
<input type='mouse' bus='ps2'>
<alias name='input0'/>
</input>
<input type='keyboard' bus='ps2'>
<alias name='input1'/>
</input>
<hostdev mode='subsystem' type='scsi' managed='no'>
<source>
<adapter name='scsi_host0'/>
<address bus='0' target='0' unit='0'/>
</source>
<readonly/>
<alias name='hostdev0'/>
<address type='drive' controller='0' bus='0'
target='0' unit='0'/>
</hostdev>
<hostdev mode='subsystem' type='pci' managed='yes'>
<driver name='vfio'/>
<source>
<address domain='0x0000' bus='0x00' slot='0x02'
function='0x0'/>
</source>
<alias name='hostdev1'/>
<rom file='/home/streamer/gpu-8086:5902-uefi.rom'/>
<address type='pci' domain='0x0000' bus='0x07'
slot='0x00' function='0x0'/>
</hostdev>
<hostdev mode='subsystem' type='pci' managed='yes'>
<driver name='vfio'/>
<source>
<address domain='0x0000' bus='0x00' slot='0x1f'
function='0x3'/>
</source>
<alias name='hostdev2'/>
<address type='pci' domain='0x0000' bus='0x02'
slot='0x02' function='0x0'/>
</hostdev>
<hostdev mode='subsystem' type='usb' managed='yes'>
<source startupPolicy='optional' missing='yes'>
<vendor id='0x046d'/>
<product id='0xc52e'/>
</source>
<alias name='hostdev3'/>
<address type='usb' bus='0' port='1'/>
</hostdev>
<hostdev mode='subsystem' type='usb' managed='yes'>
<source startupPolicy='optional' missing='yes'>
<vendor id='0x2548'/>
<product id='0x1002'/>
</source>
<alias name='hostdev4'/>
<address type='usb' bus='0' port='2'/>
</hostdev>
<memballoon model='virtio'>
<alias name='balloon0'/>
<address type='pci' domain='0x0000' bus='0x06'
slot='0x00' function='0x0'/>
</memballoon>
</devices>
<seclabel type='dynamic' model='dac' relabel='yes'>
<label>+77:+77</label>
<imagelabel>+77:+77</imagelabel>
</seclabel>
</domain
VM command line
/usr/bin/qemu-system-x86_64 -name
guest=streamer-vm-q35,debug-threads=on -S -object
secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-3-streamer-vm-q35/master-key.aes
-blockdev
{"driver":"file","filename":"/usr/share/qemu/edk2-x86_64-secure-code.fd","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}
-blockdev
{"node-name":"libvirt-pflash0-format","read-only":true,"driver":"raw","file":"libvirt-pflash0-storage"}
-blockdev
{"driver":"file","filename":"/var/lib/libvirt/qemu/nvram/streamer-vm-q35_VARS.fd","node-name":"libvirt-pflash1-storage","auto-read-only":true,"discard":"unmap"}
-blockdev
{"node-name":"libvirt-pflash1-format","read-only":false,"driver":"raw","file":"libvirt-pflash1-storage"}
-machine
pc-q35-5.0,accel=kvm,usb=off,smm=on,dump-guest-core=off,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format
-cpu host,migratable=on -m 8192 -overcommit mem-lock=off -smp
1,maxcpus=2,sockets=1,dies=1,cores=1,threads=2 -uuid 4fb1463b-837c-40fc-a760-a69afc040a1a
-display none -no-user-config -nodefaults -chardev
socket,id=charmonitor,fd=29,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 ICH9-LPC.disable_s3=1 -global ICH9-LPC.disable_s4=1 -boot strict=on -device
i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e -device
pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 -device
pcie-root-port,port=0x8,chassis=3,id=pci.3,bus=pcie.0,multifunction=on,addr=0x1 -device
pcie-root-port,port=0x9,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x1 -device
pcie-root-port,port=0xa,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x2 -device
pcie-root-port,port=0xb,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x3 -device
pcie-root-port,port=0xc,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x4 -device
qemu-xhci,id=usb,bus=pci.4,addr=0x0 -device virtio-scsi-pci,id=scsi0,bus=pci.2,addr=0x1
-blockdev
{"driver":"file","filename":"/home/streamer/streamer.qcow2","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}
-blockdev
{"node-name":"libvirt-1-format","read-only":false,"driver":"qcow2","file":"libvirt-1-storage","backing":null}
-device
virtio-blk-pci,bus=pci.5,addr=0x0,drive=libvirt-1-format,id=virtio-disk0,bootindex=1
-netdev tap,fd=31,id=hostnet0 -device
e1000e,netdev=hostnet0,id=net0,mac=52:54:00:5a:4c:8c,bus=pci.3,addr=0x0 -chardev
pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -blockdev
{"driver":"host_device","filename":"/dev/sg0","node-name":"libvirt-2-backend","read-only":true}
-device
scsi-generic,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=libvirt-2-backend,id=hostdev0
-device
vfio-pci,host=0000:00:02.0,id=hostdev1,bus=pci.7,addr=0x0,romfile=/home/streamer/gpu-8086:5902-uefi.rom
-device vfio-pci,host=0000:00:1f.3,id=hostdev2,bus=pci.2,addr=0x2 -device
usb-host,id=hostdev3,bus=usb.0,port=1 -device usb-host,id=hostdev4,bus=usb.0,port=2
-device virtio-balloon-pci,id=balloon0,bus=pci.6,addr=0x0 -sandbox
on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny -msg timestamp=on
>
> guest OS side:
>
lsblk
system has no lsblk so here is the content of /dev/disk
and the output of blkid:
/dev/disk/by-label:
total 0
lrwxrwxrwx 1 root root 10 Oct 19 13:08 Storage -> ../../vda2
lrwxrwxrwx 1 root root 10 Oct 19 13:08 System -> ../../vda1
/dev/disk/by-partuuid:
total 0
lrwxrwxrwx 1 root root 10 Oct 19 13:08 ad58aa27-01 -> ../../vda1
lrwxrwxrwx 1 root root 10 Oct 19 13:08 ad58aa27-02 -> ../../vda2
/dev/disk/by-path:
total 0
lrwxrwxrwx 1 root root 9 Oct 19 13:08 pci-0000:03:00.0 -> ../../vda
lrwxrwxrwx 1 root root 10 Oct 19 13:08 pci-0000:03:00.0-part1 ->
../../vda1
lrwxrwxrwx 1 root root 10 Oct 19 13:08 pci-0000:03:00.0-part2 ->
../../vda2
lrwxrwxrwx 1 root root 9 Oct 19 13:08 virtio-pci-0000:03:00.0 ->
../../vda
lrwxrwxrwx 1 root root 10 Oct 19 13:08 virtio-pci-0000:03:00.0-part1
-> ../../vda1
lrwxrwxrwx 1 root root 10 Oct 19 13:08 virtio-pci-0000:03:00.0-part2
-> ../../vda2
/dev/disk/by-uuid:
total 0
lrwxrwxrwx 1 root root 10 Oct 19 13:08 0672-E518 -> ../../vda1
lrwxrwxrwx 1 root root 10 Oct 19 13:08
51eb82f3-0710-4bfa-82b0-fd0d1da1abeb -> ../../vda2
/dev/vda1: SEC_TYPE="msdos" LABEL_FATBOOT="System"
LABEL="System" UUID="0672-E518" TYPE="vfat"
PARTUUID="ad58aa27-01"
/dev/vda2: LABEL="Storage" UUID="51eb82f3-0710-4bfa-82b0-fd0d1da1abeb"
TYPE="ext4" PARTUUID="ad58aa27-02"
/dev/loop0: TYPE="squashfs"
lsscsi
system has no /proc/scsi, thus no output. will this
help?
lrwxrwxrwx 1 root root 0 Oct 19 13:08 /sys/bus/scsi/devices/host0 ->
../../../devices/pci0000:00/0000:00:1f.2/ata1/host0
lrwxrwxrwx 1 root root 0 Oct 19 13:08 /sys/bus/scsi/devices/host1 ->
../../../devices/pci0000:00/0000:00:1f.2/ata2/host1
lrwxrwxrwx 1 root root 0 Oct 19 13:08 /sys/bus/scsi/devices/host2 ->
../../../devices/pci0000:00/0000:00:1f.2/ata3/host2
lrwxrwxrwx 1 root root 0 Oct 19 13:08 /sys/bus/scsi/devices/host3 ->
../../../devices/pci0000:00/0000:00:1f.2/ata4/host3
lrwxrwxrwx 1 root root 0 Oct 19 13:08 /sys/bus/scsi/devices/host4 ->
../../../devices/pci0000:00/0000:00:1f.2/ata5/host4
lrwxrwxrwx 1 root root 0 Oct 19 13:08 /sys/bus/scsi/devices/host5 ->
../../../devices/pci0000:00/0000:00:1f.2/ata6/host5
lspci
00:00.0 Host bridge: Intel Corporation 82G33/G31/P35/P31
Express DRAM Controller
00:01.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
00:01.1 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
00:01.2 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
00:01.3 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
00:01.4 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev 92)
00:1f.0 ISA bridge: Intel Corporation 82801IB (ICH9) LPC Interface Controller (rev 02)
00:1f.2 SATA controller: Intel Corporation 82801IR/IO/IH (ICH9R/DO/DH) 6 port SATA
Controller [AHCI mode] (rev 02)
00:1f.3 SMBus: Intel Corporation 82801I (ICH9 Family) SMBus Controller (rev 02)
01:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
02:00.0 USB controller: Red Hat, Inc. QEMU XHCI Host Controller (rev 01)
03:00.0 SCSI storage controller: Red Hat, Inc. Virtio block device (rev 01)
04:00.0 Unclassified device [00ff]: Red Hat, Inc. Virtio memory balloon (rev 01)
05:00.0 VGA compatible controller: Intel Corporation HD Graphics 610 (rev 04)
06:00.0 PCI bridge: Red Hat, Inc. QEMU PCI-PCI bridge
07:01.0 SCSI storage controller: Red Hat, Inc. Virtio SCSI
07:02.0 Audio device: Intel Corporation 100 Series/C230 Series Chipset Family HD Audio
Controller (rev 31)
thanks!