Bug 1899748

Summary: [udev] virtio disks not shown in /dev/disk/by-id
Product: [Fedora] Fedora Reporter: Germano Massullo (Thetra) <germano.massullo>
Component: systemdAssignee: systemd-maint
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 33CC: fedoraproject, filbranden, flepied, kasong, lnykryn, msekleta, redhat-bugzilla, ssahani, s, systemd-maint, yuwatana, zbyszek, z
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-20 16:18:09 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 Germano Massullo (Thetra) 2020-11-19 22:03:15 UTC
Description of problem:
virtio disks are not listed in /dev/disk/by-id/


Version-Release number of selected component (if applicable):
Tested on both Fedora 33 and CentOS 8
systemd-udev-246.6-3.fc33.x86_64
systemd-udev-239-31.el8_2.2.x86_64

How reproducible:
In a virtual machine I have four virtio disks (vda,vdb,vdc,vdd). I also added a scsi and a sata disks (sda,sdb) in order to check if the problem concerns only virtio



Additional info:
# tree /dev/disk
/dev/disk
├── by-id
│   ├── ata-QEMU_DVD-ROM_QM00001 -> ../../sr0
│   ├── ata-QEMU_HARDDISK_QM00003 -> ../../sda
│   └── scsi-0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-2 -> ../../sdb
├── by-label
│   └── fedora_localhost-live -> ../../vda2
├── by-partlabel
│   └── Linux\x20filesystem -> ../../vdb1
├── by-partuuid
│   ├── 0e0a3fab-01 -> ../../vda1
│   ├── 0e0a3fab-02 -> ../../vda2
│   └── 79bfc351-4a45-44ea-a6ae-4d9e49398b6c -> ../../vdb1
├── by-path
│   ├── pci-0000:00:1f.2-ata-1 -> ../../sr0
│   ├── pci-0000:00:1f.2-ata-1.0 -> ../../sr0
│   ├── pci-0000:00:1f.2-ata-2 -> ../../sda
│   ├── pci-0000:00:1f.2-ata-2.0 -> ../../sda
│   ├── pci-0000:04:00.0 -> ../../vda
│   ├── pci-0000:04:00.0-part1 -> ../../vda1
│   ├── pci-0000:04:00.0-part2 -> ../../vda2
│   ├── pci-0000:07:00.0 -> ../../vdb
│   ├── pci-0000:07:00.0-part1 -> ../../vdb1
│   ├── pci-0000:08:00.0-scsi-0:0:0:2 -> ../../sdb
│   ├── pci-0000:09:00.0 -> ../../vdc
│   ├── pci-0000:0a:00.0 -> ../../vdd
│   ├── virtio-pci-0000:04:00.0 -> ../../vda
│   ├── virtio-pci-0000:04:00.0-part1 -> ../../vda1
│   ├── virtio-pci-0000:04:00.0-part2 -> ../../vda2
│   ├── virtio-pci-0000:07:00.0 -> ../../vdb
│   ├── virtio-pci-0000:07:00.0-part1 -> ../../vdb1
│   ├── virtio-pci-0000:09:00.0 -> ../../vdc
│   └── virtio-pci-0000:0a:00.0 -> ../../vdd
└── by-uuid
    ├── 459f3236-735b-46c6-9bf4-cedc70509fab -> ../../vdb1
    ├── c9a8c337-0188-4143-8446-f126fb3b7132 -> ../../vda2
    └── e0398153-1222-4a89-8ef5-9c1cfea11ce9 -> ../../vda1

6 directories, 30 files

# parted -l
Error: /dev/sda: disk label not recognized
Model: ATA QEMU HARDDISK (scsi)                                         
Disk /dev/sda: 2147MB
Sector size (local/physical): 512B/512B
Partition table: unknown
Flag del disco: 

Error: /dev/sdb: disk label not recognized
Model: QEMU QEMU HARDDISK (scsi)                                        
Disk /dev/sdb: 2147MB
Sector size (local/physical): 512B/512B
Partition table: unknown
Flag del disco: 

Error: /dev/vdd: disk label not recognized
Model: Block device Virtio (virtblk)                                
Disk /dev/vdd: 2147MB
Sector size (local/physical): 512B/512B
Partition table: unknown
Flag del disco: 

Model: Block device Virtio (virtblk)
Disk /dev/vdb: 64,4GB
Sector size (local/physical): 512B/512B
Partition table: gpt
Flag del disco: 

Number  Start  End    Dimension  File system  Nome              Flag
 1      1049kB  64,4GB  64,4GB      ext4         Linux filesystem


Error: /dev/vdc: disk label not recognized
Model: Block device Virtio (virtblk)                                
Disk /dev/vdc: 2147MB
Sector size (local/physical): 512B/512B
Partition table: unknown
Flag del disco: 

Model: Unknown (unknown)
Disk /dev/zram0: 2008MB
Sector size (local/physical): 4096B/4096B
Partition table: loop
Flag del disco: 

Number  Start  End    Dimension  File system     Flag
 1      0,00B   2008MB  2008MB      linux-swap(v1)


Model: Block device Virtio (virtblk)
Disk /dev/vda: 42,9GB
Sector size (local/physical): 512B/512B
Partition table: msdos
Flag del disco: 

Number  Start  End    Dimension  Type     File system  Flag
 1      1049kB  1075MB  1074MB      primary  ext4         boot
 2      1075MB  42,9GB  41,9GB      primary  btrfs

Comment 1 Germano Massullo (Thetra) 2020-11-19 22:39:30 UTC
Upstream bugreport
https://github.com/systemd/systemd/issues/17670

Comment 2 Germano Massullo (Thetra) 2020-11-20 09:47:15 UTC
```
# udevadm info /dev/vda
P: /devices/pci0000:00/0000:00:02.3/0000:04:00.0/virtio2/block/vda
N: vda
L: 0
S: disk/by-path/virtio-pci-0000:04:00.0
S: disk/by-path/pci-0000:04:00.0
E: DEVPATH=/devices/pci0000:00/0000:00:02.3/0000:04:00.0/virtio2/block/vda
E: DEVNAME=/dev/vda
E: DEVTYPE=disk
E: MAJOR=252
E: MINOR=0
E: SUBSYSTEM=block
E: USEC_INITIALIZED=7104295
E: ID_PATH=pci-0000:04:00.0
E: ID_PATH_TAG=pci-0000_04_00_0
E: ID_PART_TABLE_UUID=0e0a3fab
E: ID_PART_TABLE_TYPE=dos
E: DEVLINKS=/dev/disk/by-path/virtio-pci-0000:04:00.0 /dev/disk/by-path/pci-0000:04:00.0
E: TAGS=:systemd:

```

```
# udevadm info /dev/vdb
P: /devices/pci0000:00/0000:00:02.6/0000:07:00.0/virtio5/block/vdb
N: vdb
L: 0
S: disk/by-path/pci-0000:07:00.0
S: disk/by-path/virtio-pci-0000:07:00.0
E: DEVPATH=/devices/pci0000:00/0000:00:02.6/0000:07:00.0/virtio5/block/vdb
E: DEVNAME=/dev/vdb
E: DEVTYPE=disk
E: MAJOR=252
E: MINOR=16
E: SUBSYSTEM=block
E: USEC_INITIALIZED=7117372
E: ID_PATH=pci-0000:07:00.0
E: ID_PATH_TAG=pci-0000_07_00_0
E: ID_PART_TABLE_UUID=5f99b2bb-63c0-434e-8ef5-2091e6eb29d8
E: ID_PART_TABLE_TYPE=gpt
E: DEVLINKS=/dev/disk/by-path/pci-0000:07:00.0 /dev/disk/by-path/virtio-pci-0000:07:00.0
E: TAGS=:systemd:
```

```
# udevadm info --attribute-walk /dev/vda

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:02.3/0000:04:00.0/virtio2/block/vda':
    KERNEL=="vda"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTR{alignment_offset}=="0"
    ATTR{cache_type}=="write back"
    ATTR{capability}=="50"
    ATTR{discard_alignment}=="512"
    ATTR{events}==""
    ATTR{events_async}==""
    ATTR{events_poll_msecs}=="-1"
    ATTR{ext_range}=="256"
    ATTR{hidden}=="0"
    ATTR{inflight}=="       0        0"
    ATTR{integrity/device_is_integrity_capable}=="0"
    ATTR{integrity/format}=="none"
    ATTR{integrity/protection_interval_bytes}=="0"
    ATTR{integrity/read_verify}=="0"
    ATTR{integrity/tag_size}=="0"
    ATTR{integrity/write_generate}=="0"
    ATTR{mq/0/cpu_list}=="0, 1, 2, 3, 4, 5"
    ATTR{mq/0/nr_reserved_tags}=="0"
    ATTR{mq/0/nr_tags}=="128"
    ATTR{power/control}=="auto"
    ATTR{power/runtime_active_time}=="0"
    ATTR{power/runtime_status}=="unsupported"
    ATTR{power/runtime_suspended_time}=="0"
    ATTR{queue/add_random}=="0"
    ATTR{queue/chunk_sectors}=="0"
    ATTR{queue/dax}=="0"
    ATTR{queue/discard_granularity}=="512"
    ATTR{queue/discard_max_bytes}=="2147483136"
    ATTR{queue/discard_max_hw_bytes}=="2147483136"
    ATTR{queue/discard_zeroes_data}=="0"
    ATTR{queue/fua}=="0"
    ATTR{queue/hw_sector_size}=="512"
    ATTR{queue/io_poll}=="0"
    ATTR{queue/io_poll_delay}=="-1"
    ATTR{queue/iosched/fifo_batch}=="16"
    ATTR{queue/iosched/front_merges}=="1"
    ATTR{queue/iosched/read_expire}=="500"
    ATTR{queue/iosched/write_expire}=="5000"
    ATTR{queue/iosched/writes_starved}=="2"
    ATTR{queue/iostats}=="1"
    ATTR{queue/logical_block_size}=="512"
    ATTR{queue/max_discard_segments}=="1"
    ATTR{queue/max_hw_sectors_kb}=="2147483647"
    ATTR{queue/max_integrity_segments}=="0"
    ATTR{queue/max_sectors_kb}=="1280"
    ATTR{queue/max_segment_size}=="4294967295"
    ATTR{queue/max_segments}=="126"
    ATTR{queue/minimum_io_size}=="512"
    ATTR{queue/nomerges}=="0"
    ATTR{queue/nr_requests}=="256"
    ATTR{queue/nr_zones}=="0"
    ATTR{queue/optimal_io_size}=="0"
    ATTR{queue/physical_block_size}=="512"
    ATTR{queue/read_ahead_kb}=="128"
    ATTR{queue/rotational}=="1"
    ATTR{queue/rq_affinity}=="1"
    ATTR{queue/scheduler}=="[mq-deadline] kyber bfq none"
    ATTR{queue/wbt_lat_usec}=="75000"
    ATTR{queue/write_cache}=="write back"
    ATTR{queue/write_same_max_bytes}=="0"
    ATTR{queue/write_zeroes_max_bytes}=="2147483136"
    ATTR{queue/zone_append_max_bytes}=="0"
    ATTR{queue/zoned}=="none"
    ATTR{range}=="16"
    ATTR{removable}=="0"
    ATTR{ro}=="0"
    ATTR{serial}==""
    ATTR{size}=="83886080"
    ATTR{stat}=="   17343      691  1893346   602153    25564     2907  2088584    35766        0    48373   663260    29459        0 29793696      861      938    24479"
    ATTR{trace/act_mask}=="disabled"
    ATTR{trace/enable}=="0"
    ATTR{trace/end_lba}=="disabled"
    ATTR{trace/pid}=="disabled"
    ATTR{trace/start_lba}=="disabled"

  looking at parent device '/devices/pci0000:00/0000:00:02.3/0000:04:00.0/virtio2':
    KERNELS=="virtio2"
    SUBSYSTEMS=="virtio"
    DRIVERS=="virtio_blk"
    ATTRS{device}=="0x0002"
    ATTRS{features}=="0010101001110110000000000000110010000000000000000000000000000000"
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_time}=="0"
    ATTRS{power/runtime_status}=="unsupported"
    ATTRS{power/runtime_suspended_time}=="0"
    ATTRS{status}=="0x0000000f"
    ATTRS{vendor}=="0x1af4"

  looking at parent device '/devices/pci0000:00/0000:00:02.3/0000:04:00.0':
    KERNELS=="0000:04:00.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="virtio-pci"
    ATTRS{ari_enabled}=="0"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x010000"
    ATTRS{consistent_dma_mask_bits}=="64"
    ATTRS{current_link_speed}=="2.5 GT/s PCIe"
    ATTRS{current_link_width}=="1"
    ATTRS{d3cold_allowed}=="1"
    ATTRS{device}=="0x1042"
    ATTRS{dma_mask_bits}=="64"
    ATTRS{driver_override}=="(null)"
    ATTRS{enable}=="1"
    ATTRS{irq}=="22"
    ATTRS{link/l0s_aspm}=="0"
    ATTRS{local_cpulist}=="0-5"
    ATTRS{local_cpus}=="3f"
    ATTRS{max_link_speed}=="2.5 GT/s PCIe"
    ATTRS{max_link_width}=="1"
    ATTRS{msi_bus}=="1"
    ATTRS{msi_irqs/44}=="msix"
    ATTRS{msi_irqs/45}=="msix"
    ATTRS{numa_node}=="-1"
    ATTRS{power/control}=="on"
    ATTRS{power/runtime_active_time}=="43813231"
    ATTRS{power/runtime_status}=="active"
    ATTRS{power/runtime_suspended_time}=="0"
    ATTRS{power/wakeup}=="disabled"
    ATTRS{power/wakeup_abort_count}==""
    ATTRS{power/wakeup_active}==""
    ATTRS{power/wakeup_active_count}==""
    ATTRS{power/wakeup_count}==""
    ATTRS{power/wakeup_expire_count}==""
    ATTRS{power/wakeup_last_time_ms}==""
    ATTRS{power/wakeup_max_time_ms}==""
    ATTRS{power/wakeup_total_time_ms}==""
    ATTRS{revision}=="0x01"
    ATTRS{subsystem_device}=="0x1100"
    ATTRS{subsystem_vendor}=="0x1af4"
    ATTRS{vendor}=="0x1af4"

  looking at parent device '/devices/pci0000:00/0000:00:02.3':
    KERNELS=="0000:00:02.3"
    SUBSYSTEMS=="pci"
    DRIVERS=="pcieport"
    ATTRS{aer_rootport_total_err_cor}=="0"
    ATTRS{aer_rootport_total_err_fatal}=="0"
    ATTRS{aer_rootport_total_err_nonfatal}=="0"
    ATTRS{ari_enabled}=="0"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x060400"
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{current_link_speed}=="2.5 GT/s PCIe"
    ATTRS{current_link_width}=="1"
    ATTRS{d3cold_allowed}=="0"
    ATTRS{device}=="0x000c"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{driver_override}=="(null)"
    ATTRS{enable}=="1"
    ATTRS{irq}=="22"
    ATTRS{local_cpulist}=="0-5"
    ATTRS{local_cpus}=="3f"
    ATTRS{max_link_speed}=="16.0 GT/s PCIe"
    ATTRS{max_link_width}=="32"
    ATTRS{msi_bus}=="1"
    ATTRS{msi_irqs/27}=="msix"
    ATTRS{numa_node}=="-1"
    ATTRS{power/control}=="on"
    ATTRS{power/runtime_active_time}=="43813339"
    ATTRS{power/runtime_status}=="active"
    ATTRS{power/runtime_suspended_time}=="0"
    ATTRS{power/wakeup}=="disabled"
    ATTRS{power/wakeup_abort_count}==""
    ATTRS{power/wakeup_active}==""
    ATTRS{power/wakeup_active_count}==""
    ATTRS{power/wakeup_count}==""
    ATTRS{power/wakeup_expire_count}==""
    ATTRS{power/wakeup_last_time_ms}==""
    ATTRS{power/wakeup_max_time_ms}==""
    ATTRS{power/wakeup_total_time_ms}==""
    ATTRS{revision}=="0x00"
    ATTRS{secondary_bus_number}=="4"
    ATTRS{subordinate_bus_number}=="4"
    ATTRS{subsystem_device}=="0x0000"
    ATTRS{subsystem_vendor}=="0x1b36"
    ATTRS{vendor}=="0x1b36"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_time}=="0"
    ATTRS{power/runtime_status}=="unsupported"
    ATTRS{power/runtime_suspended_time}=="0"
```

Comment 3 Zbigniew Jędrzejewski-Szmek 2020-11-20 16:18:09 UTC
As discussed in the upstream bug report, this is because libvirt creates the virtio devices
without a serial number. I would argue that this is OK as default behaviour: is seems better
to refer to those disks by partition or fs uuids, or even by path. Having also a serial number
doesn't seem very useful, unlike for real hardware devices. The "disk" here is just a file,
and can be duplicated at will, unlike real hardware.