[libvirt] [libvirt PATCH] udev: consider the device a CDROM when ID_CDROM=1

Some CDROM devices are reported by udev to have an ID_TYPE="generic" thus it is necessary to check if ID_CDROM is present. As a side effect, treating ID_TYPE="generic" as a missing ID_TYPE will enable checks for ID_DRIVE_FLASH_SD and ID_DRIVE_FLOPPY and the udevKludgeStorageType heuristic. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> --- src/node_device/node_device_udev.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 71b3c79..de1cc67 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1,7 +1,7 @@ /* * node_device_udev.c: node device enumeration - libudev implementation * - * Copyright (C) 2009-2013 Red Hat, Inc. + * Copyright (C) 2009-2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -1093,7 +1093,8 @@ static int udevProcessStorage(struct udev_device *device, if (udevGetStringProperty(device, "ID_TYPE", - &data->storage.drive_type) != PROPERTY_FOUND) { + &data->storage.drive_type) != PROPERTY_FOUND + || STREQ(def->caps->data.storage.drive_type, "generic")) { int tmp_int = 0; /* All floppy drives have the ID_DRIVE_FLOPPY prop. This is @@ -1104,6 +1105,12 @@ static int udevProcessStorage(struct udev_device *device, if (VIR_STRDUP(data->storage.drive_type, "floppy") < 0) goto out; + } else if ((udevGetIntProperty(device, "ID_CDROM", + &tmp_int, 0) == PROPERTY_FOUND) && + (tmp_int == 1)) { + + if (VIR_STRDUP(data->storage.drive_type, "cd") < 0) + goto out; } else if ((udevGetIntProperty(device, "ID_DRIVE_FLASH_SD", &tmp_int, 0) == PROPERTY_FOUND) && (tmp_int == 1)) { -- 1.9.0

Giuseppe Scrivano <gscrivan@redhat.com> writes:
Some CDROM devices are reported by udev to have an ID_TYPE="generic" thus it is necessary to check if ID_CDROM is present.
As a side effect, treating ID_TYPE="generic" as a missing ID_TYPE will enable checks for ID_DRIVE_FLASH_SD and ID_DRIVE_FLOPPY and the udevKludgeStorageType heuristic.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
ping? Regards, Giuseppe

On Wed, Apr 23, 2014 at 12:42:01PM +0200, Giuseppe Scrivano wrote:
Some CDROM devices are reported by udev to have an ID_TYPE="generic" thus it is necessary to check if ID_CDROM is present.
As a side effect, treating ID_TYPE="generic" as a missing ID_TYPE will enable checks for ID_DRIVE_FLASH_SD and ID_DRIVE_FLOPPY and the udevKludgeStorageType heuristic.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> --- src/node_device/node_device_udev.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
ACK Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

"Daniel P. Berrange" <berrange@redhat.com> writes:
On Wed, Apr 23, 2014 at 12:42:01PM +0200, Giuseppe Scrivano wrote:
Some CDROM devices are reported by udev to have an ID_TYPE="generic" thus it is necessary to check if ID_CDROM is present.
As a side effect, treating ID_TYPE="generic" as a missing ID_TYPE will enable checks for ID_DRIVE_FLASH_SD and ID_DRIVE_FLOPPY and the udevKludgeStorageType heuristic.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> --- src/node_device/node_device_udev.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
ACK
Thanks. Can somebody please push the patch as I've no write access to the repo? Giuseppe

On 05/06/2014 05:11 AM, Giuseppe Scrivano wrote:
"Daniel P. Berrange" <berrange@redhat.com> writes:
On Wed, Apr 23, 2014 at 12:42:01PM +0200, Giuseppe Scrivano wrote:
Some CDROM devices are reported by udev to have an ID_TYPE="generic" thus it is necessary to check if ID_CDROM is present.
As a side effect, treating ID_TYPE="generic" as a missing ID_TYPE will enable checks for ID_DRIVE_FLASH_SD and ID_DRIVE_FLOPPY and the udevKludgeStorageType heuristic.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> --- src/node_device/node_device_udev.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
ACK
Thanks.
Can somebody please push the patch as I've no write access to the repo?
Done. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 04/23/2014 04:42 AM, Giuseppe Scrivano wrote:
Some CDROM devices are reported by udev to have an ID_TYPE="generic" thus it is necessary to check if ID_CDROM is present.
As a side effect, treating ID_TYPE="generic" as a missing ID_TYPE will enable checks for ID_DRIVE_FLASH_SD and ID_DRIVE_FLOPPY and the udevKludgeStorageType heuristic.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> ---
if (udevGetStringProperty(device, "ID_TYPE", - &data->storage.drive_type) != PROPERTY_FOUND) { + &data->storage.drive_type) != PROPERTY_FOUND + || STREQ(def->caps->data.storage.drive_type, "generic")) {
Style: HACKING documents that we tend to leave || hanging on the first line, not wrapped to the next line (closer to kernel style than GNU style).
int tmp_int = 0;
/* All floppy drives have the ID_DRIVE_FLOPPY prop. This is @@ -1104,6 +1105,12 @@ static int udevProcessStorage(struct udev_device *device,
if (VIR_STRDUP(data->storage.drive_type, "floppy") < 0) goto out; + } else if ((udevGetIntProperty(device, "ID_CDROM", + &tmp_int, 0) == PROPERTY_FOUND) && + (tmp_int == 1)) {
Style: over-parenthesized, and indentation is odd.
+ + if (VIR_STRDUP(data->storage.drive_type, "cd") < 0) + goto out; } else if ((udevGetIntProperty(device, "ID_DRIVE_FLASH_SD", &tmp_int, 0) == PROPERTY_FOUND) && (tmp_int == 1)) {
But you were just copying existing oddness. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Giuseppe Scrivano