mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
New API: list-disk-labels Allow the user to pass an optional disk label when adding a drive. This is passed through to qemu / libvirt using the disk serial field, and from there to the appliance which exposes it through udev, creating a special alias of the device /dev/disk/guestfs/<label>. Partitions are named /dev/disk/guestfs/<label><partnum>. virtio-blk and virtio-scsi limit the serial field to 20 bytes. We further limit the name to maximum 20 ASCII characters in [a-zA-Z]. list-devices and list-partitions are not changed: these calls still return raw block device names. However a new call, list-disk-labels, returns a hash table allowing callers to map between disk labels, and block device and partition names. This commit also includes a test.
18 lines
798 B
Plaintext
18 lines
798 B
Plaintext
# For libguestfs, create /dev/disk/guestfs/<serial>
|
|
# and /dev/disk/guestfs/<serial><partnum>
|
|
|
|
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", ENV{ID_SCSI_SERIAL}=="?*", \
|
|
SYMLINK+="disk/guestfs/$env{ID_SCSI_SERIAL}"
|
|
KERNEL=="sd*", ENV{DEVTYPE}=="partition", ENV{ID_SCSI_SERIAL}=="?*", \
|
|
SYMLINK+="disk/guestfs/$env{ID_SCSI_SERIAL}%n"
|
|
|
|
# As written, it's likely the above only works with virtio-scsi
|
|
# because ID_SCSI_SERIAL is specific to the output of the 'scsi_id'
|
|
# program. The following will not work because ID_SERIAL contains
|
|
# some unwanted text.
|
|
|
|
#KERNEL=="vd*[!0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", \
|
|
# SYMLINK+="disk/guestfs/$env{ID_SERIAL}"
|
|
#KERNEL=="vd*[0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", \
|
|
# SYMLINK+="disk/guestfs/$env{ID_SERIAL}%n"
|