[libvirt] [PATCH 0/1] Add support for disk serial number in node device code

This small patch extends the information for storage devices to include their serial number. This information is useful in figuring out which devices are actually multiple paths to the same backend device, as well as identifying devices uniquely across nodes. This code will be used by the multipath support that I'm working on, but since it's capable of standing alone, and might be useful for other reasons, I'm submitting it separately. Dave

--- src/node_device_conf.c | 5 +++++ src/node_device_conf.h | 1 + src/node_device_hal.c | 1 + 3 files changed, 7 insertions(+), 0 deletions(-) diff --git a/src/node_device_conf.c b/src/node_device_conf.c index 2360427..e37295a 100644 --- a/src/node_device_conf.c +++ b/src/node_device_conf.c @@ -325,6 +325,9 @@ char *virNodeDeviceDefFormat(virConnectPtr conn, if (data->storage.vendor) virBufferVSprintf(&buf, " <vendor>%s</vendor>\n", data->storage.vendor); + if (data->storage.serial) + virBufferVSprintf(&buf, " <serial>%s</serial>\n", + data->storage.serial); if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_REMOVABLE) { int avl = data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_REMOVABLE_MEDIA_AVAILABLE; @@ -439,6 +442,7 @@ virNodeDevCapStorageParseXML(virConnectPtr conn, data->storage.drive_type = virXPathString(conn, "string(./drive_type[1])", ctxt); data->storage.model = virXPathString(conn, "string(./model[1])", ctxt); data->storage.vendor = virXPathString(conn, "string(./vendor[1])", ctxt); + data->storage.serial = virXPathString(conn, "string(./serial[1])", ctxt); if ((n = virXPathNodeSet(conn, "./capability", ctxt, &nodes)) < 0) { virNodeDeviceReportError(conn, VIR_ERR_INTERNAL_ERROR, @@ -1091,6 +1095,7 @@ void virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps) VIR_FREE(data->storage.drive_type); VIR_FREE(data->storage.model); VIR_FREE(data->storage.vendor); + VIR_FREE(data->storage.serial); break; case VIR_NODE_DEV_CAP_LAST: /* This case is here to shutup the compiler */ diff --git a/src/node_device_conf.h b/src/node_device_conf.h index 26e5558..8919335 100644 --- a/src/node_device_conf.h +++ b/src/node_device_conf.h @@ -124,6 +124,7 @@ struct _virNodeDevCapsDef { char *drive_type; char *model; char *vendor; + char *serial; unsigned flags; /* virNodeDevStorageCapFlags bits */ } storage; } data; diff --git a/src/node_device_hal.c b/src/node_device_hal.c index 2f7ca8d..2998b02 100644 --- a/src/node_device_hal.c +++ b/src/node_device_hal.c @@ -240,6 +240,7 @@ static int gather_storage_cap(LibHalContext *ctx, const char *udi, (void)get_str_prop(ctx, udi, "storage.drive_type", &d->storage.drive_type); (void)get_str_prop(ctx, udi, "storage.model", &d->storage.model); (void)get_str_prop(ctx, udi, "storage.vendor", &d->storage.vendor); + (void)get_str_prop(ctx, udi, "storage.serial", &d->storage.serial); if (get_bool_prop(ctx, udi, "storage.removable", &val) == 0 && val) { d->storage.flags |= VIR_NODE_DEV_CAP_STORAGE_REMOVABLE; if (get_bool_prop(ctx, udi, "storage.removable.media_available", -- 1.6.0.6

On Mon, Jun 08, 2009 at 02:18:14PM -0400, David Allan wrote:
--- src/node_device_conf.c | 5 +++++ src/node_device_conf.h | 1 + src/node_device_hal.c | 1 + 3 files changed, 7 insertions(+), 0 deletions(-)
Patch looks fine to me, my main question is if we can get the same thing from devkit backend. Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

Daniel Veillard wrote:
On Mon, Jun 08, 2009 at 02:18:14PM -0400, David Allan wrote:
--- src/node_device_conf.c | 5 +++++ src/node_device_conf.h | 1 + src/node_device_hal.c | 1 + 3 files changed, 7 insertions(+), 0 deletions(-)
Patch looks fine to me, my main question is if we can get the same thing from devkit backend.
Daniel
It doesn't look to me like any of the storage stuff is implemented for devkit, so I'm not sure what's going to be required there. It's a good question, though. Dave

On Mon, Jun 08, 2009 at 02:55:02PM -0400, Dave Allan wrote:
Daniel Veillard wrote:
On Mon, Jun 08, 2009 at 02:18:14PM -0400, David Allan wrote:
--- src/node_device_conf.c | 5 +++++ src/node_device_conf.h | 1 + src/node_device_hal.c | 1 + 3 files changed, 7 insertions(+), 0 deletions(-)
Patch looks fine to me, my main question is if we can get the same thing from devkit backend.
It doesn't look to me like any of the storage stuff is implemented for devkit, so I'm not sure what's going to be required there. It's a good question, though.
The position of DeviceKit developers is that it will be a sub-set of the HAL functionality. Some of the functionality will only be provided by the lower level udev or even sysfs, and other functionality will only be available via higher level like DeviceKit-disks. So I would not be at all suprised if we can't get serial number from DeviceKit, but there will be *somewhere* we can get it.... Yes, for libvirt's needs it looks like the new DeviceKit will be more work for us, compared to HAL :-( Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Mon, Jun 08, 2009 at 02:18:14PM -0400, David Allan wrote:
--- src/node_device_conf.c | 5 +++++ src/node_device_conf.h | 1 + src/node_device_hal.c | 1 + 3 files changed, 7 insertions(+), 0 deletions(-)
ACK, patch looks pretty trivial & fine. Could you also extend the docs/schemas/nodedev.rng file and add a file in tests/nodedevschemadata/ with example usage. An additive patch to this one is fine. Regards, Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

Daniel P. Berrange wrote:
On Mon, Jun 08, 2009 at 02:18:14PM -0400, David Allan wrote:
--- src/node_device_conf.c | 5 +++++ src/node_device_conf.h | 1 + src/node_device_hal.c | 1 + 3 files changed, 7 insertions(+), 0 deletions(-)
ACK, patch looks pretty trivial & fine. Could you also extend the docs/schemas/nodedev.rng file and add a file in tests/nodedevschemadata/ with example usage. An additive patch to this one is fine.
I think the attached patch does both of those things. Dave
From b6e24f38bc31871078c98b0a734f61590c781c91 Mon Sep 17 00:00:00 2001 From: David Allan <dallan@redhat.com> Date: Wed, 10 Jun 2009 16:12:36 -0400 Subject: [PATCH 1/1] Add serial to nodedev schema & tests
--- docs/schemas/nodedev.rng | 5 +++++ ...ge_serial_3600c0ff000d7a2a5d463ff4902000000.xml | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 0 deletions(-) create mode 100644 tests/nodedevschemadata/storage_serial_3600c0ff000d7a2a5d463ff4902000000.xml diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng index ae6654c..78bd6a8 100644 --- a/docs/schemas/nodedev.rng +++ b/docs/schemas/nodedev.rng @@ -283,6 +283,11 @@ <text/> </element> </optional> + <optional> + <element name='serial'> + <text/> + </element> + </optional> <choice> <ref name='capstorageremoveable'/> diff --git a/tests/nodedevschemadata/storage_serial_3600c0ff000d7a2a5d463ff4902000000.xml b/tests/nodedevschemadata/storage_serial_3600c0ff000d7a2a5d463ff4902000000.xml new file mode 100644 index 0000000..e341f39 --- /dev/null +++ b/tests/nodedevschemadata/storage_serial_3600c0ff000d7a2a5d463ff4902000000.xml @@ -0,0 +1,15 @@ +<device> + <name>storage_serial_3600c0ff000d7a2a5d463ff4902000000</name> + <parent>pci_10df_fe00_scsi_host_scsi_device_lun8</parent> + <capability type='storage'> + <block>/dev/sdj</block> + <bus>pci</bus> + <drive_type>disk</drive_type> + <model>MSA2012fc</model> + <vendor>HP</vendor> + <serial>3600c0ff000d7a2a5d463ff4902000000</serial> + <size>15626928128</size> + </capability> +</device> + + -- 1.6.0.6

On Wed, Jun 10, 2009 at 04:20:08PM -0400, Dave Allan wrote:
Daniel P. Berrange wrote:
On Mon, Jun 08, 2009 at 02:18:14PM -0400, David Allan wrote:
--- src/node_device_conf.c | 5 +++++ src/node_device_conf.h | 1 + src/node_device_hal.c | 1 + 3 files changed, 7 insertions(+), 0 deletions(-)
ACK, patch looks pretty trivial & fine. Could you also extend the docs/schemas/nodedev.rng file and add a file in tests/nodedevschemadata/ with example usage. An additive patch to this one is fine.
I think the attached patch does both of those things.
Okidoc, applied both patches, the test filename is a bit long but I don't think it's really a problem. thanks ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (4)
-
Daniel P. Berrange
-
Daniel Veillard
-
Dave Allan
-
David Allan