Bug 1848875 - The cdrom device can not list by nodedev-list
Summary: The cdrom device can not list by nodedev-list
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: libvirt
Version: 8.3
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: rc
: 8.3
Assignee: Michal Privoznik
QA Contact: yalzhang@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-06-19 06:39 UTC by Lili Zhu
Modified: 2021-11-16 07:55 UTC (History)
11 users (show)

Fixed In Version: libvirt-7.5.0-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-11-16 07:49:57 UTC
Type: Bug
Target Upstream Version: 7.5.0
Embargoed:


Attachments (Terms of Use)

Description Lili Zhu 2020-06-19 06:39:50 UTC
Description of problem:
The cdrom device can not list by nodedev-list

Version-Release number of selected component (if applicable):
libvirt-6.4.0-1.module+el8.3.0+6881+88468c00.x86_64

How reproducible:
100%

Steps to Reproduce:
1. list the storage devices on the node
# virsh nodedev-list --cap storage
block_sda_0QEMU_QEMU_HARDDISK_drive_scsi0_0_0_2
block_sdb_QEMU_HARDDISK_QM00001

2. retrieve storage devices list
# lsblk 
NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda             8:0    0  300M  0 disk 
sdb             8:16   0   10G  0 disk 
├─sdb1          8:17   0    1G  0 part /boot
└─sdb2          8:18   0    9G  0 part 
  ├─rhel-root 253:0    0    8G  0 lvm  /
  └─rhel-swap 253:1    0    1G  0 lvm  [SWAP]
sr0            11:0    1 1024M  0 rom  

Actual results:
As above description

Expected results:
The cdrom device should be listed either

Comment 1 Lili Zhu 2020-06-19 06:57:50 UTC
This bug also appeared with:
libvirt-6.0.0-24.module+el8.2.1+6997+c666f621.x86_64

Comment 2 Jaroslav Suchanek 2020-06-25 16:59:04 UTC
What does the nodevdev-list --tree prints out? Thanks.

Comment 3 Lili Zhu 2020-06-30 03:25:40 UTC
# virsh nodedev-list --tree
computer
  |
  +- net_lo_00_00_00_00_00_00
  +- net_virbr0_nic_52_54_00_ed_91_76
  +- pci_0000_00_00_0
  +- pci_0000_00_01_0
  |   |
  |   +- drm_card0
  |     
  +- pci_0000_00_02_0
  |   |
  |   +- pci_0000_01_00_0
  |       |
  |       +- net_enp1s0_52_54_00_8c_61_87
  |         
  +- pci_0000_00_02_1
  |   |
  |   +- pci_0000_02_00_0
  |       |
  |       +- usb_usb1
  |       |   |
  |       |   +- usb_1_0_1_0
  |       |   +- usb_1_1
  |       |       |
  |       |       +- usb_1_1_1_0
  |       |         
  |       +- usb_usb2
  |           |
  |           +- usb_2_0_1_0
  |             
  +- pci_0000_00_02_2
  |   |
  |   +- pci_0000_03_00_0
  |     
  +- pci_0000_00_02_3
  |   |
  |   +- pci_0000_04_00_0
  |       |
  |       +- block_vda
  |         
  +- pci_0000_00_02_4
  |   |
  |   +- pci_0000_05_00_0
  |     
  +- pci_0000_00_02_5
  |   |
  |   +- pci_0000_06_00_0
  |     
  +- pci_0000_00_02_6
  +- pci_0000_00_1b_0
  +- pci_0000_00_1f_0
  +- pci_0000_00_1f_2
  |   |
  |   +- scsi_host0
  |   |   |
  |   |   +- scsi_target0_0_0
  |   |       |
  |   |       +- scsi_0_0_0_0
  |   |           |
  |   |           +- scsi_generic_sg0
  |   |             
  |   +- scsi_host1
  |   +- scsi_host2
  |   +- scsi_host3
  |   +- scsi_host4
  |   +- scsi_host5
  |     
  +- pci_0000_00_1f_3

Comment 5 Michal Privoznik 2021-05-31 14:12:29 UTC
This is because there's a difference in RHEL udev and other udevs. For instance, on RHEL I get the following:

  udevadm info /sys/class/block/sr0 | grep ID_TYPE
  E: ID_TYPE=cd/dvd

but on Fedora I get different type:

  udevadm info /sys/class/block/sr0 | grep ID_TYPE
  E: ID_TYPE=cd

I'll investigate further, why udev reports different type and what we can do about it.

Comment 6 Michal Privoznik 2021-05-31 16:18:31 UTC
@msekleta Michal, do you perhaps have an idea whom should I ask about this? Libvirt is expecting "cd" but on RHEL we see "cd/dvd". Making libvirt accept both is trivial, it's just that I'd like to understand what has caused this.

Comment 7 Michal Privoznik 2021-06-02 07:14:11 UTC
Alright, after some more debugging I've found the root cause. The problem is with sg3_utils package, more specifically with its udev rules. When udev processes a SCSI device and if sg3_utils package is installed then /lib/udev/rules.d/61-scsi-sg3_id.rules file is processed too. And here lies the difference. On recently enough Fedora (sg3_utils-1.46-1.fc35.x86_64) The file contains the following rules (among plenty others which I'm leaving out):

  IMPORT{program}="/usr/bin/sg_inq --export $env{.INQUIRY_DEV}", ENV{ID_SCSI}="1"

  ENV{ID_TYPE}!="?*", ENV{SCSI_TYPE}=="?*", ENV{ID_TYPE}="$env{SCSI_TYPE}"

This sets ID_TYPE to whatever "sg_inq --export /dev/sr0" reports ("cd/dvd") but only if ID_TYPE was not set earlier (it was). Compare these rules to the following taken from RHEL (sg3_utils-1.44-5.el8.x86_64):

  KERNEL=="sd*[!0-9]|sr*", ENV{ID_SCSI}!="1", IMPORT{program}="/usr/bin/sg_inq --export $tempnode", ENV{ID_SCSI}="1"

  ENV{SCSI_TYPE}=="?*", ENV{ID_TYPE}="$env{SCSI_TYPE}"

Here we can see the same binary being executed with the same set of arguments, but the other rule is different. It overwrites ID_TYPE basically always. And I can confirm that removing sg3_utils package makes virsh report CDROMs too. Of course, the proper fix is to make libvirt acceps "cd/dvd" type. Will send a patch soon.

Comment 8 Michal Privoznik 2021-06-02 07:38:10 UTC
Patches posted here:

https://listman.redhat.com/archives/libvir-list/2021-June/msg00041.html

Comment 9 Michal Privoznik 2021-06-02 08:14:25 UTC
Merged upstream as:

e76ec0fe65 (HEAD -> master, origin/master, origin/HEAD, udev_class_storage) node_device_udev: Also process ID_TYPE=cd/dvd in udevProcessStorage()
791b1173d0 node_device_udev: Don't overwrite @ret in udevProcessStorage()
950a9b256b node_device_udev: Make udevGetStringProperty() return void
a5a47e9fa5 node_device_udev: Make udevGenerateDeviceName() return void

v7.4.0-32-ge76ec0fe65

Comment 10 yalzhang@redhat.com 2021-07-05 01:56:45 UTC
Reproduce this bug on libvirt-7.4.0-1.module+el8.5.0+11218+83343022.x86_64, and test on libvirt-7.5.0-1.module+el8.5.0+11664+59f87560.x86_64, the bug is fixed.

on libvirt-7.5.0-1.module+el8.5.0+11664+59f87560.x86_64, nodedev-list can list the cdrom device.
# lsblk
NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda             8:0    0   30G  0 disk 
├─sda1          8:1    0    1G  0 part /boot
└─sda2          8:2    0   29G  0 part 
  ├─rhel-root 253:0    0   28G  0 lvm  /
  └─rhel-swap 253:1    0    1G  0 lvm  [SWAP]
sr0            11:0    1 1024M  0 rom  

# virsh nodedev-list --cap storage
block_sda_QEMU_HARDDISK_QM00001
block_sr0_0QEMU_QEMU_CD_ROM_drive_scsi0_0_0_3

Comment 14 errata-xmlrpc 2021-11-16 07:49:57 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 (virt:av 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/RHBA-2021:4684


Note You need to log in before you can comment on or make changes to this bug.