[PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev

Peter Krempa posted 6 patches 3 years, 6 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/cover.1602775390.git.pkrempa@redhat.com
src/qemu/qemu_command.c                       |  33 +-----
src/qemu/qemu_domain.c                        |   5 +
src/qemu/qemu_driver.c                        |  65 ++++++++++-
src/qemu/qemu_hotplug.c                       |   3 +
src/qemu/qemu_process.c                       | 103 +++++++++++++++---
src/qemu/qemu_process.h                       |  21 ++--
tests/qemuxml2argvdata/disk-cdrom.args        |   4 +-
.../disk-cdrom.x86_64-2.12.0.args             |   4 +-
.../disk-cdrom.x86_64-latest.args             |   6 +-
tests/qemuxml2argvdata/disk-cdrom.xml         |   5 +-
...hostdev-scsi-virtio-scsi.x86_64-2.8.0.args |   3 +
...hostdev-scsi-virtio-scsi.x86_64-4.1.0.args |   3 +
...ostdev-scsi-virtio-scsi.x86_64-latest.args |   4 +
.../hostdev-scsi-virtio-scsi.xml              |   8 ++
tests/qemuxml2argvmock.c                      |  13 ---
tests/qemuxml2argvtest.c                      |  45 +++++++-
tests/qemuxml2xmloutdata/disk-cdrom.xml       |   5 +-
.../hostdev-scsi-virtio-scsi.xml              |   8 ++
18 files changed, 252 insertions(+), 86 deletions(-)
[PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
Posted by Peter Krempa 3 years, 6 months ago
-drive detects whether a device is a cdrom automatically but we need to
use 'host_cdrom' when using blockdev explicitly. Fix the hostdev code
which was recently converted to -blockdev.

Warning:

I _don't_ have a box with a CDROM handy so this code is not tested in action!

Peter Krempa (6):
  qemuProcessCreatePretendCmd: Split up preparation and command building
  qemu: hostdev: Prepare definition bits in qemuDomainPrepareHostdev
  qemu: Prepare hostdev data which depends on the host state separately
  qemuxml2argvmock: Remove mocking of 'virSCSIDeviceGetSgName'
  qemu: Detect whether a SCSI hostdev is a cdrom
  qemu: Add test cases for 'host_cdrom' blockdev backend via <disk>

 src/qemu/qemu_command.c                       |  33 +-----
 src/qemu/qemu_domain.c                        |   5 +
 src/qemu/qemu_driver.c                        |  65 ++++++++++-
 src/qemu/qemu_hotplug.c                       |   3 +
 src/qemu/qemu_process.c                       | 103 +++++++++++++++---
 src/qemu/qemu_process.h                       |  21 ++--
 tests/qemuxml2argvdata/disk-cdrom.args        |   4 +-
 .../disk-cdrom.x86_64-2.12.0.args             |   4 +-
 .../disk-cdrom.x86_64-latest.args             |   6 +-
 tests/qemuxml2argvdata/disk-cdrom.xml         |   5 +-
 ...hostdev-scsi-virtio-scsi.x86_64-2.8.0.args |   3 +
 ...hostdev-scsi-virtio-scsi.x86_64-4.1.0.args |   3 +
 ...ostdev-scsi-virtio-scsi.x86_64-latest.args |   4 +
 .../hostdev-scsi-virtio-scsi.xml              |   8 ++
 tests/qemuxml2argvmock.c                      |  13 ---
 tests/qemuxml2argvtest.c                      |  45 +++++++-
 tests/qemuxml2xmloutdata/disk-cdrom.xml       |   5 +-
 .../hostdev-scsi-virtio-scsi.xml              |   8 ++
 18 files changed, 252 insertions(+), 86 deletions(-)

-- 
2.26.2

Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
Posted by daggs 3 years, 6 months ago
Greetings All,

> Sent: Thursday, October 15, 2020 at 6:25 PM
> From: "Peter Krempa" <pkrempa@redhat.com>
> To: libvir-list@redhat.com
> Cc: "daggs" <daggs@gmx.com>
> Subject: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
>
> -drive detects whether a device is a cdrom automatically but we need to
> use 'host_cdrom' when using blockdev explicitly. Fix the hostdev code
> which was recently converted to -blockdev.
>
> Warning:
>
> I _don't_ have a box with a CDROM handy so this code is not tested in action!
>
> Peter Krempa (6):
>   qemuProcessCreatePretendCmd: Split up preparation and command building
>   qemu: hostdev: Prepare definition bits in qemuDomainPrepareHostdev
>   qemu: Prepare hostdev data which depends on the host state separately
>   qemuxml2argvmock: Remove mocking of 'virSCSIDeviceGetSgName'
>   qemu: Detect whether a SCSI hostdev is a cdrom
>   qemu: Add test cases for 'host_cdrom' blockdev backend via <disk>

I've tested the bellow on libvirt 6.8.0, I wasn't able to get it to work, with the same entry as the example, e.g.:
    <hostdev mode='subsystem' type='scsi' managed='yes'>
      <source>
        <adapter name='cdrom'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>
I get this error:
error: XML error: SCSI host device doesn't support managed mode.

if I mark the managed as no (like other pci pass-through devices I have in the vm), I get this error:
error: internal error: Cannot parse adapter 'cdrom'

full machine xml can be found at https://dpaste.com/G32WWAJA2

Dagg.


Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
Posted by Peter Krempa 3 years, 6 months ago
On Sun, Oct 18, 2020 at 14:34:16 +0200, daggs wrote:
> Greetings All,
> 
> > Sent: Thursday, October 15, 2020 at 6:25 PM
> > From: "Peter Krempa" <pkrempa@redhat.com>
> > To: libvir-list@redhat.com
> > Cc: "daggs" <daggs@gmx.com>
> > Subject: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
> >
> > -drive detects whether a device is a cdrom automatically but we need to
> > use 'host_cdrom' when using blockdev explicitly. Fix the hostdev code
> > which was recently converted to -blockdev.
> >
> > Warning:
> >
> > I _don't_ have a box with a CDROM handy so this code is not tested in action!
> >
> > Peter Krempa (6):
> >   qemuProcessCreatePretendCmd: Split up preparation and command building
> >   qemu: hostdev: Prepare definition bits in qemuDomainPrepareHostdev
> >   qemu: Prepare hostdev data which depends on the host state separately
> >   qemuxml2argvmock: Remove mocking of 'virSCSIDeviceGetSgName'
> >   qemu: Detect whether a SCSI hostdev is a cdrom
> >   qemu: Add test cases for 'host_cdrom' blockdev backend via <disk>
> 
> I've tested the bellow on libvirt 6.8.0, I wasn't able to get it to work, with the same entry as the example, e.g.:
>     <hostdev mode='subsystem' type='scsi' managed='yes'>
>       <source>
>         <adapter name='cdrom'/>

This is purely for tests, to force a cdrom since we can't probe the
host. Using it for a VM will fail.

>         <address bus='0' target='0' unit='0'/>
>       </source>
>       <readonly/>
>       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
>     </hostdev>
> I get this error:
> error: XML error: SCSI host device doesn't support managed mode.
> 
> if I mark the managed as no (like other pci pass-through devices I have in the vm), I get this error:
> error: internal error: Cannot parse adapter 'cdrom'

Yup, this is expected, you need to use a real 'adapterN' here.

Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
Posted by daggs 3 years, 6 months ago
Greetings Peter,

> Sent: Monday, October 19, 2020 at 10:17 AM
> From: "Peter Krempa" <pkrempa@redhat.com>
> To: "daggs" <daggs@gmx.com>
> Cc: libvir-list@redhat.com
> Subject: Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
>
> On Sun, Oct 18, 2020 at 14:34:16 +0200, daggs wrote:
>
> This is purely for tests, to force a cdrom since we can't probe the
> host. Using it for a VM will fail.
>
>
> Yup, this is expected, you need to use a real 'adapterN' here.
>
>

so there is a bug in my xml? if so, where is the error?

Dagg.


Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
Posted by Peter Krempa 3 years, 6 months ago
On Mon, Oct 19, 2020 at 09:45:31 +0200, daggs wrote:
> Greetings Peter,
> 
> > Sent: Monday, October 19, 2020 at 10:17 AM
> > From: "Peter Krempa" <pkrempa@redhat.com>
> > To: "daggs" <daggs@gmx.com>
> > Cc: libvir-list@redhat.com
> > Subject: Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
> >
> > On Sun, Oct 18, 2020 at 14:34:16 +0200, daggs wrote:
> >
> > This is purely for tests, to force a cdrom since we can't probe the
> > host. Using it for a VM will fail.
> >
> >
> > Yup, this is expected, you need to use a real 'adapterN' here.
> >
> >
> 
> so there is a bug in my xml? if so, where is the error?

Well, you used an XML from our tests, with following config:

    <hostdev mode='subsystem' type='scsi' managed='yes'>
      <source>
       	<adapter name='cdrom'/>

If you look into patch 5/6 for the change to tests/qemuxml2argvtest.c
you'll see that using 'cdrom' as an adapter name is a hack made for just
tests. That will _not_ work anywhere else.

You should use the XML that you've used before with the adapter name
corresponding to the adapter the cdrom is on.

The command line you've posted:

-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 \

Shows that nothing has changed, but unfortunately doesn't show enough
for me to debug it. Unfortunately the cdrom detection code doesn't log
anything so debug logs won't help either.

I'll need to try it in a nested virtualization environment since I don't
have a physical CD drive handy.

Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
Posted by daggs 3 years, 6 months ago
Greetings Peter,

> Sent: Monday, October 19, 2020 at 11:06 AM
> From: "Peter Krempa" <pkrempa@redhat.com>
> To: "daggs" <daggs@gmx.com>
> Cc: libvir-list@redhat.com
> Subject: Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
>
> Well, you used an XML from our tests, with following config:
>
>     <hostdev mode='subsystem' type='scsi' managed='yes'>
>       <source>
>        	<adapter name='cdrom'/>
>
> If you look into patch 5/6 for the change to tests/qemuxml2argvtest.c
> you'll see that using 'cdrom' as an adapter name is a hack made for just
> tests. That will _not_ work anywhere else.
>
> You should use the XML that you've used before with the adapter name
> corresponding to the adapter the cdrom is on.
>
> The command line you've posted:
>
> -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 \
>
> Shows that nothing has changed, but unfortunately doesn't show enough
> for me to debug it. Unfortunately the cdrom detection code doesn't log
> anything so debug logs won't help either.
>
> I'll need to try it in a nested virtualization environment since I don't
> have a physical CD drive handy.
>
>

if you wish, you can send my a patch with the debug code you want to add, I'll apply it, run and send you the log.

Dagg.


Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
Posted by Han Han 3 years, 6 months ago
On Mon, Oct 19, 2020 at 4:07 PM Peter Krempa <pkrempa@redhat.com> wrote:

> On Mon, Oct 19, 2020 at 09:45:31 +0200, daggs wrote:
> > Greetings Peter,
> >
> > > Sent: Monday, October 19, 2020 at 10:17 AM
> > > From: "Peter Krempa" <pkrempa@redhat.com>
> > > To: "daggs" <daggs@gmx.com>
> > > Cc: libvir-list@redhat.com
> > > Subject: Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
> > >
> > > On Sun, Oct 18, 2020 at 14:34:16 +0200, daggs wrote:
> > >
> > > This is purely for tests, to force a cdrom since we can't probe the
> > > host. Using it for a VM will fail.
> > >
> > >
> > > Yup, this is expected, you need to use a real 'adapterN' here.
> > >
> > >
> >
> > so there is a bug in my xml? if so, where is the error?
>
> Well, you used an XML from our tests, with following config:
>
>     <hostdev mode='subsystem' type='scsi' managed='yes'>
>       <source>
>         <adapter name='cdrom'/>
>
> If you look into patch 5/6 for the change to tests/qemuxml2argvtest.c
> you'll see that using 'cdrom' as an adapter name is a hack made for just
> tests. That will _not_ work anywhere else.
>
> You should use the XML that you've used before with the adapter name
> corresponding to the adapter the cdrom is on.
>
> The command line you've posted:
>
> -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
> \
>
> Shows that nothing has changed, but unfortunately doesn't show enough
> for me to debug it. Unfortunately the cdrom detection code doesn't log
> anything so debug logs won't help either.
>
> I'll need to try it in a nested virtualization environment since I don't
> have a physical CD drive handy.
>
> You can emulate it by scsi_debug:
➜  ~ modprobe scsi_debug ptype=5
➜  ~ lsscsi
[2:0:0:0]    cd/dvd  Linux    scsi_debug       0188  /dev/sr0
Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
Posted by daggs 3 years, 6 months ago
Greetings Han,
 
> Sent: Tuesday, October 20, 2020 at 12:33 PM
> From: "Han Han" <hhan@redhat.com>
> To: "Peter Krempa" <pkrempa@redhat.com>
> Cc: "daggs" <daggs@gmx.com>, libvir-list@redhat.com
> Subject: Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev

> You can emulate it by scsi_debug:
> ➜  ~ modprobe scsi_debug ptype=5
> ➜  ~ lsscsi
> [2:0:0:0]    cd/dvd  Linux    scsi_debug       0188  /dev/sr0

extremely cool, I did not know that.

thanks for sharing

Dagg.


Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
Posted by Peter Krempa 3 years, 6 months ago
On Thu, Oct 15, 2020 at 17:25:08 +0200, Peter Krempa wrote:
> -drive detects whether a device is a cdrom automatically but we need to
> use 'host_cdrom' when using blockdev explicitly. Fix the hostdev code
> which was recently converted to -blockdev.
> 
> Warning:
> 
> I _don't_ have a box with a CDROM handy so this code is not tested in action!

I've tried this a bit more in a virtual environment ...

> Peter Krempa (6):
>   qemuProcessCreatePretendCmd: Split up preparation and command building
>   qemu: hostdev: Prepare definition bits in qemuDomainPrepareHostdev
>   qemu: Prepare hostdev data which depends on the host state separately
>   qemuxml2argvmock: Remove mocking of 'virSCSIDeviceGetSgName'

These above are pure refactors which are IMO worth keeping, so somebody,
please review.

>   qemu: Detect whether a SCSI hostdev is a cdrom
>   qemu: Add test cases for 'host_cdrom' blockdev backend via <disk>

(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
lsblk
lsscsi
VM XML file
VM command line

guest OS side:

lsblk
lsscsi
lspci

thanks!

Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
Posted by daggs 3 years, 6 months ago
Greetings Peter,

> Sent: Monday, October 19, 2020 at 7:35 PM
> From: "Peter Krempa" <pkrempa@redhat.com>
> To: libvir-list@redhat.com
> Cc: "daggs" <daggs@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-83
 7c-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.qc
 ow2","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!
> 
>


Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
Posted by Peter Krempa 3 years, 6 months ago
On Mon, Oct 19, 2020 at 20:37:53 +0200, daggs wrote:
> Greetings Peter,
> 
> > Sent: Monday, October 19, 2020 at 7:35 PM
> > From: "Peter Krempa" <pkrempa@redhat.com>
> > To: libvir-list@redhat.com
> > Cc: "daggs" <daggs@gmx.com>
> > Subject: Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev

[...]

> >
> 
> > 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

try 'ls -lia /sys/bus/scsi/devices' that has all the data

Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
Posted by daggs 3 years, 6 months ago
Greetings Peter,

> Sent: Tuesday, October 20, 2020 at 3:00 PM
> From: "Peter Krempa" <pkrempa@redhat.com>
> To: "daggs" <daggs@gmx.com>
> Cc: libvir-list@redhat.com
> Subject: Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
>
> [...]
>
> try 'ls -lia /sys/bus/scsi/devices' that has all the data
>
>

$ ls -lia /sys/bus/scsi/devices
total 0
   7017 drwxr-xr-x    2 root     root             0 Oct 20 11:11 .
   7015 drwxr-xr-x    4 root     root             0 Oct 20 11:11 ..
  17968 lrwxrwxrwx    1 root     root             0 Oct 20 11:11 host0 -> ../../../devices/pci0000:00/0000:00:1f.2/ata1/host0
  18016 lrwxrwxrwx    1 root     root             0 Oct 20 11:11 host1 -> ../../../devices/pci0000:00/0000:00:1f.2/ata2/host1
  18064 lrwxrwxrwx    1 root     root             0 Oct 20 11:11 host2 -> ../../../devices/pci0000:00/0000:00:1f.2/ata3/host2
  18112 lrwxrwxrwx    1 root     root             0 Oct 20 11:11 host3 -> ../../../devices/pci0000:00/0000:00:1f.2/ata4/host3
  18160 lrwxrwxrwx    1 root     root             0 Oct 20 11:11 host4 -> ../../../devices/pci0000:00/0000:00:1f.2/ata5/host4
  18208 lrwxrwxrwx    1 root     root             0 Oct 20 11:11 host5 -> ../../../devices/pci0000:00/0000:00:1f.2/ata6/host5

Dagg.


Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
Posted by Peter Krempa 3 years, 6 months ago
On Tue, Oct 20, 2020 at 14:10:12 +0200, daggs wrote:
> Greetings Peter,
> 
> > Sent: Tuesday, October 20, 2020 at 3:00 PM
> > From: "Peter Krempa" <pkrempa@redhat.com>
> > To: "daggs" <daggs@gmx.com>
> > Cc: libvir-list@redhat.com
> > Subject: Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
> >
> > [...]
> >
> > try 'ls -lia /sys/bus/scsi/devices' that has all the data
> >
> >
> 
> $ ls -lia /sys/bus/scsi/devices
> total 0
>    7017 drwxr-xr-x    2 root     root             0 Oct 20 11:11 .
>    7015 drwxr-xr-x    4 root     root             0 Oct 20 11:11 ..
>   17968 lrwxrwxrwx    1 root     root             0 Oct 20 11:11 host0 -> ../../../devices/pci0000:00/0000:00:1f.2/ata1/host0
>   18016 lrwxrwxrwx    1 root     root             0 Oct 20 11:11 host1 -> ../../../devices/pci0000:00/0000:00:1f.2/ata2/host1
>   18064 lrwxrwxrwx    1 root     root             0 Oct 20 11:11 host2 -> ../../../devices/pci0000:00/0000:00:1f.2/ata3/host2
>   18112 lrwxrwxrwx    1 root     root             0 Oct 20 11:11 host3 -> ../../../devices/pci0000:00/0000:00:1f.2/ata4/host3
>   18160 lrwxrwxrwx    1 root     root             0 Oct 20 11:11 host4 -> ../../../devices/pci0000:00/0000:00:1f.2/ata5/host4
>   18208 lrwxrwxrwx    1 root     root             0 Oct 20 11:11 host5 -> ../../../devices/pci0000:00/0000:00:1f.2/ata6/host5

Oh, so your guest OS doesn't seem to recognize virtio-scsi apparently!

On my test VM I've got the following:

$ ls -lia /sys/bus/scsi/devices
total 0
 5659 drwxr-xr-x. 2 root root 0 Oct 19 17:34 .
 5657 drwxr-xr-x. 4 root root 0 Oct 19 17:34 ..
18418 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 0:0:0:0 -> ../../../devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0
20322 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 6:0:0:1 -> ../../../devices/pci0000:00/0000:00:02.7/0000:08:00.0/virtio6/host6/target6:0:0/6:0:0:1
19773 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 6:0:0:3 -> ../../../devices/pci0000:00/0000:00:02.7/0000:08:00.0/virtio6/host6/target6:0:0/6:0:0:3
15523 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 host0 -> ../../../devices/pci0000:00/0000:00:1f.2/ata1/host0
15571 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 host1 -> ../../../devices/pci0000:00/0000:00:1f.2/ata2/host1
15619 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 host2 -> ../../../devices/pci0000:00/0000:00:1f.2/ata3/host2
15667 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 host3 -> ../../../devices/pci0000:00/0000:00:1f.2/ata4/host3
15715 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 host4 -> ../../../devices/pci0000:00/0000:00:1f.2/ata5/host4
15763 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 host5 -> ../../../devices/pci0000:00/0000:00:1f.2/ata6/host5
19403 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 host6 -> ../../../devices/pci0000:00/0000:00:02.7/0000:08:00.0/virtio6/host6
18376 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 target0:0:0 -> ../../../devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0
19733 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 target6:0:0 -> ../../../devices/pci0000:00/0000:00:02.7/0000:08:00.0/virtio6/host6/target6:0:0

You can see that host6 is a virtio-scsi controller and it has targets.

You need to figure out why your guest doesn't have the driver.
Alternative would be to use a different scsi controller model, but any
emulated will result in overhead, so the best solution will be to get
drivers.

Sorry I've mislead you with the initial red herring, but your report
really came after I've modified how we do hostdevs so I thought I messed
up something.

Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
Posted by daggs 3 years, 6 months ago
Greetings Peter,

> Sent: Tuesday, October 20, 2020 at 3:22 PM
> From: "Peter Krempa" <pkrempa@redhat.com>
> To: "daggs" <daggs@gmx.com>
> Cc: libvir-list@redhat.com
> Subject: Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
>
> Oh, so your guest OS doesn't seem to recognize virtio-scsi apparently!
>
> On my test VM I've got the following:
>
> $ ls -lia /sys/bus/scsi/devices
> total 0
>  5659 drwxr-xr-x. 2 root root 0 Oct 19 17:34 .
>  5657 drwxr-xr-x. 4 root root 0 Oct 19 17:34 ..
> 18418 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 0:0:0:0 -> ../../../devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0
> 20322 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 6:0:0:1 -> ../../../devices/pci0000:00/0000:00:02.7/0000:08:00.0/virtio6/host6/target6:0:0/6:0:0:1
> 19773 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 6:0:0:3 -> ../../../devices/pci0000:00/0000:00:02.7/0000:08:00.0/virtio6/host6/target6:0:0/6:0:0:3
> 15523 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 host0 -> ../../../devices/pci0000:00/0000:00:1f.2/ata1/host0
> 15571 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 host1 -> ../../../devices/pci0000:00/0000:00:1f.2/ata2/host1
> 15619 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 host2 -> ../../../devices/pci0000:00/0000:00:1f.2/ata3/host2
> 15667 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 host3 -> ../../../devices/pci0000:00/0000:00:1f.2/ata4/host3
> 15715 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 host4 -> ../../../devices/pci0000:00/0000:00:1f.2/ata5/host4
> 15763 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 host5 -> ../../../devices/pci0000:00/0000:00:1f.2/ata6/host5
> 19403 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 host6 -> ../../../devices/pci0000:00/0000:00:02.7/0000:08:00.0/virtio6/host6
> 18376 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 target0:0:0 -> ../../../devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0
> 19733 lrwxrwxrwx. 1 root root 0 Oct 19 17:34 target6:0:0 -> ../../../devices/pci0000:00/0000:00:02.7/0000:08:00.0/virtio6/host6/target6:0:0
>
> You can see that host6 is a virtio-scsi controller and it has targets.
>
> You need to figure out why your guest doesn't have the driver.
> Alternative would be to use a different scsi controller model, but any
> emulated will result in overhead, so the best solution will be to get
> drivers.
>
> Sorry I've mislead you with the initial red herring, but your report
> really came after I've modified how we do hostdevs so I thought I messed
> up something.
>
>

that might consistent with the fact that I had to use e1000e for the nic because virtio didn't worked as should.
the docs states the model one of 'auto', 'buslogic', 'ibmvscsi', 'lsilogic', 'lsisas1068', 'lsisas1078', 'virtio-scsi', 'vmpvscsi', 'virtio-transitional', 'virtio-non-transitional'. any recommendation on which to use?

DAgg.


Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
Posted by daggs 3 years, 6 months ago
Greetings Peter,

> Sent: Tuesday, October 20, 2020 at 3:39 PM
> From: "daggs" <daggs@gmx.com>
> To: "Peter Krempa" <pkrempa@redhat.com>
> Cc: libvir-list@redhat.com
> Subject: Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
>
> Greetings Peter,
>
>
> that might consistent with the fact that I had to use e1000e for the nic because virtio didn't worked as should.
> the docs states the model one of 'auto', 'buslogic', 'ibmvscsi', 'lsilogic', 'lsisas1068', 'lsisas1078', 'virtio-scsi', 'vmpvscsi', 'virtio-transitional', 'virtio-non-transitional'. any recommendation on which to use?
>
> DAgg.
>
>
>

so apparently, the os I'm using in the vm comes with scsi virtio disabled in the kernel...
will rebuild the os and report.

thanks for all your work.

Dagg.


Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
Posted by daggs 3 years, 6 months ago
Greetings Peter,

> Sent: Tuesday, October 20, 2020 at 2:54 PM
> From: "daggs" <daggs@gmx.com>
> To: "daggs" <daggs@gmx.com>
> Cc: "Peter Krempa" <pkrempa@redhat.com>, libvir-list@redhat.com
> Subject: Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
>
> Greetings Peter,
>
> so apparently, the os I'm using in the vm comes with scsi virtio disabled in the kernel...
> will rebuild the os and report.
>
> thanks for all your work.
>
> Dagg.
>

I've built the os with scsi virtio, now I do see the cdrom, see:
# ls -lia /sys/bus/scsi/devices
total 0
   7017 drwxr-xr-x    2 root     root             0 Oct 22  2020 .
   7015 drwxr-xr-x    4 root     root             0 Oct 22  2020 ..
  18874 lrwxrwxrwx    1 root     root             0 Oct 22  2020 0:0:0:0 -> ../../../devices/pci0000:00/0000:00:1e.0/0000:06:00.0/0000:07:01.0/virtio2/host0/target0:0:0/0:0:0:0
  17468 lrwxrwxrwx    1 root     root             0 Oct 22  2020 host0 -> ../../../devices/pci0000:00/0000:00:1e.0/0000:06:00.0/0000:07:01.0/virtio2/host0
  18051 lrwxrwxrwx    1 root     root             0 Oct 22  2020 host1 -> ../../../devices/pci0000:00/0000:00:1f.2/ata1/host1
  18099 lrwxrwxrwx    1 root     root             0 Oct 22  2020 host2 -> ../../../devices/pci0000:00/0000:00:1f.2/ata2/host2
  18147 lrwxrwxrwx    1 root     root             0 Oct 22  2020 host3 -> ../../../devices/pci0000:00/0000:00:1f.2/ata3/host3
  18195 lrwxrwxrwx    1 root     root             0 Oct 22  2020 host4 -> ../../../devices/pci0000:00/0000:00:1f.2/ata4/host4
  18243 lrwxrwxrwx    1 root     root             0 Oct 22  2020 host5 -> ../../../devices/pci0000:00/0000:00:1f.2/ata5/host5
  18291 lrwxrwxrwx    1 root     root             0 Oct 22  2020 host6 -> ../../../devices/pci0000:00/0000:00:1f.2/ata6/host6
  18835 lrwxrwxrwx    1 root     root             0 Oct 22  2020 target0:0:0 -> ../../../devices/pci0000:00/0000:00:1e.0/0000:06:00.0/0000:07:01.0/virtio2/host0/target0:0:0

I've tested with 6.7.0 and 6.8.0 + your patchset, in both the cdrom is visible, in 6.7.0, the guest's dmesg is filled with theses errors:
[   57.510366] sr 0:0:0:0: ioctl_internal_command return code = 8000002
[   57.510400] sr 0:0:0:0: Sense Key : 0xb [current]
[   57.510403] sr 0:0:0:0: ASC=0x0 ASCQ=0x6

every few seconds these lines are added to the log.
with 6.8.0 + your patchset, I see these outputs only few times in the boot process. here is the dmesg: https://dpaste.com/F32A9B92H
I've inserted a audio cd and expected the os ui to detected it but it didn't. I assume there is another bug there.
anything I can do to help hunting this bug?

Thanks.

Dagg.


Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
Posted by daggs 3 years, 5 months ago
Greetings Peter,

> Sent: Thursday, October 22, 2020 at 8:54 PM
> From: "daggs" <daggs@gmx.com>
> To: "Peter Krempa" <pkrempa@redhat.com>
> Cc: libvir-list@redhat.com
> Subject: Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
>
> Greetings Peter,
>
> I've built the os with scsi virtio, now I do see the cdrom, see:
> # ls -lia /sys/bus/scsi/devices
> total 0
>    7017 drwxr-xr-x    2 root     root             0 Oct 22  2020 .
>    7015 drwxr-xr-x    4 root     root             0 Oct 22  2020 ..
>   18874 lrwxrwxrwx    1 root     root             0 Oct 22  2020 0:0:0:0 -> ../../../devices/pci0000:00/0000:00:1e.0/0000:06:00.0/0000:07:01.0/virtio2/host0/target0:0:0/0:0:0:0
>   17468 lrwxrwxrwx    1 root     root             0 Oct 22  2020 host0 -> ../../../devices/pci0000:00/0000:00:1e.0/0000:06:00.0/0000:07:01.0/virtio2/host0
>   18051 lrwxrwxrwx    1 root     root             0 Oct 22  2020 host1 -> ../../../devices/pci0000:00/0000:00:1f.2/ata1/host1
>   18099 lrwxrwxrwx    1 root     root             0 Oct 22  2020 host2 -> ../../../devices/pci0000:00/0000:00:1f.2/ata2/host2
>   18147 lrwxrwxrwx    1 root     root             0 Oct 22  2020 host3 -> ../../../devices/pci0000:00/0000:00:1f.2/ata3/host3
>   18195 lrwxrwxrwx    1 root     root             0 Oct 22  2020 host4 -> ../../../devices/pci0000:00/0000:00:1f.2/ata4/host4
>   18243 lrwxrwxrwx    1 root     root             0 Oct 22  2020 host5 -> ../../../devices/pci0000:00/0000:00:1f.2/ata5/host5
>   18291 lrwxrwxrwx    1 root     root             0 Oct 22  2020 host6 -> ../../../devices/pci0000:00/0000:00:1f.2/ata6/host6
>   18835 lrwxrwxrwx    1 root     root             0 Oct 22  2020 target0:0:0 -> ../../../devices/pci0000:00/0000:00:1e.0/0000:06:00.0/0000:07:01.0/virtio2/host0/target0:0:0
>
> I've tested with 6.7.0 and 6.8.0 + your patchset, in both the cdrom is visible, in 6.7.0, the guest's dmesg is filled with theses errors:
> [   57.510366] sr 0:0:0:0: ioctl_internal_command return code = 8000002
> [   57.510400] sr 0:0:0:0: Sense Key : 0xb [current]
> [   57.510403] sr 0:0:0:0: ASC=0x0 ASCQ=0x6
>
> every few seconds these lines are added to the log.
> with 6.8.0 + your patchset, I see these outputs only few times in the boot process. here is the dmesg: https://dpaste.com/F32A9B92H
> I've inserted a audio cd and expected the os ui to detected it but it didn't. I assume there is another bug there.
> anything I can do to help hunting this bug?

looks like I was mistaken, I see the same prints in 6.8.0 + your patchset. this means it is not related, so question is, is this a livbirt misconfig or qemu bug?

any insights?

Thanks,

Dagg.


Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
Posted by daggs 3 years, 5 months ago
Peter,

> Sent: Saturday, October 24, 2020 at 8:28 AM
> From: "daggs" <daggs@gmx.com>
> To: "Peter Krempa" <pkrempa@redhat.com>
> Cc: libvir-list@redhat.com
> Subject: Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
>
> Greetings Peter,
>
> looks like I was mistaken, I see the same prints in 6.8.0 + your patchset. this means it is not related, so question is, is this a livbirt misconfig or qemu bug?
>
> any insights?
>

can you comment on the below please? I think it is an qemu bug

Dagg.


Re: [PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
Posted by Michal Prívozník 3 years, 6 months ago
On 10/15/20 5:25 PM, Peter Krempa wrote:
> -drive detects whether a device is a cdrom automatically but we need to
> use 'host_cdrom' when using blockdev explicitly. Fix the hostdev code
> which was recently converted to -blockdev.
> 
> Warning:
> 
> I _don't_ have a box with a CDROM handy so this code is not tested in action!
> 
> Peter Krempa (6):
>    qemuProcessCreatePretendCmd: Split up preparation and command building
>    qemu: hostdev: Prepare definition bits in qemuDomainPrepareHostdev
>    qemu: Prepare hostdev data which depends on the host state separately
>    qemuxml2argvmock: Remove mocking of 'virSCSIDeviceGetSgName'
>    qemu: Detect whether a SCSI hostdev is a cdrom
>    qemu: Add test cases for 'host_cdrom' blockdev backend via <disk>
> 
>   src/qemu/qemu_command.c                       |  33 +-----
>   src/qemu/qemu_domain.c                        |   5 +
>   src/qemu/qemu_driver.c                        |  65 ++++++++++-
>   src/qemu/qemu_hotplug.c                       |   3 +
>   src/qemu/qemu_process.c                       | 103 +++++++++++++++---
>   src/qemu/qemu_process.h                       |  21 ++--
>   tests/qemuxml2argvdata/disk-cdrom.args        |   4 +-
>   .../disk-cdrom.x86_64-2.12.0.args             |   4 +-
>   .../disk-cdrom.x86_64-latest.args             |   6 +-
>   tests/qemuxml2argvdata/disk-cdrom.xml         |   5 +-
>   ...hostdev-scsi-virtio-scsi.x86_64-2.8.0.args |   3 +
>   ...hostdev-scsi-virtio-scsi.x86_64-4.1.0.args |   3 +
>   ...ostdev-scsi-virtio-scsi.x86_64-latest.args |   4 +
>   .../hostdev-scsi-virtio-scsi.xml              |   8 ++
>   tests/qemuxml2argvmock.c                      |  13 ---
>   tests/qemuxml2argvtest.c                      |  45 +++++++-
>   tests/qemuxml2xmloutdata/disk-cdrom.xml       |   5 +-
>   .../hostdev-scsi-virtio-scsi.xml              |   8 ++
>   18 files changed, 252 insertions(+), 86 deletions(-)
> 

To patches 1-4:

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

Michal