mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
nodedev: Add removable storage 'media_label' prop
Provides the CDROM label for current media. Only implemented for the udev backend.
This commit is contained in:
parent
a010165d27
commit
deae2bb57f
@ -314,6 +314,11 @@
|
||||
<element name='media_size'>
|
||||
<ref name='uint'/>
|
||||
</element>
|
||||
<optional>
|
||||
<element name='media_label'>
|
||||
<text/>
|
||||
</element>
|
||||
</optional>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
|
@ -446,6 +446,11 @@ char *virNodeDeviceDefFormat(virConnectPtr conn,
|
||||
"</media_available>\n", avl ? 1 : 0);
|
||||
virBufferVSprintf(&buf, " <media_size>%llu</media_size>\n",
|
||||
data->storage.removable_media_size);
|
||||
if (data->storage.media_label)
|
||||
virBufferEscapeString(&buf,
|
||||
" <media_label>%s</media_label>\n",
|
||||
data->storage.media_label);
|
||||
|
||||
if (data->storage.logical_block_size > 0)
|
||||
virBufferVSprintf(&buf, " <logical_block_size>%llu"
|
||||
"</logical_block_size>\n",
|
||||
@ -598,6 +603,8 @@ virNodeDevCapStorageParseXML(virConnectPtr conn,
|
||||
if (virXPathBoolean(conn, "count(./media_available[. = '1']) > 0", ctxt))
|
||||
data->storage.flags |= VIR_NODE_DEV_CAP_STORAGE_REMOVABLE_MEDIA_AVAILABLE;
|
||||
|
||||
data->storage.media_label = virXPathString(conn, "string(./media_label[1])", ctxt);
|
||||
|
||||
val = 0;
|
||||
if (virNodeDevCapsDefParseULongLong(conn, "number(./media_size[1])", ctxt, &val, def,
|
||||
_("no removable media size supplied for '%s'"),
|
||||
@ -1459,6 +1466,7 @@ void virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
|
||||
VIR_FREE(data->storage.model);
|
||||
VIR_FREE(data->storage.vendor);
|
||||
VIR_FREE(data->storage.serial);
|
||||
VIR_FREE(data->storage.media_label);
|
||||
break;
|
||||
case VIR_NODE_DEV_CAP_LAST:
|
||||
/* This case is here to shutup the compiler */
|
||||
|
@ -170,6 +170,7 @@ struct _virNodeDevCapsDef {
|
||||
char *model;
|
||||
char *vendor;
|
||||
char *serial;
|
||||
char *media_label;
|
||||
unsigned flags; /* virNodeDevStorageCapFlags bits */
|
||||
} storage;
|
||||
} data;
|
||||
|
@ -868,6 +868,11 @@ static int udevProcessCDROM(struct udev_device *device,
|
||||
def->caps->data.storage.flags |=
|
||||
VIR_NODE_DEV_CAP_STORAGE_REMOVABLE_MEDIA_AVAILABLE;
|
||||
|
||||
if (udevGetStringProperty(device, "ID_FS_LABEL",
|
||||
&data->storage.media_label) == PROPERTY_ERROR) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (udevGetUint64SysfsAttr(device,
|
||||
"size",
|
||||
&data->storage.num_blocks) == PROPERTY_ERROR) {
|
||||
|
16
tests/nodedevschemadata/DVD_with_media.xml
Normal file
16
tests/nodedevschemadata/DVD_with_media.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<device>
|
||||
<name>DVD_GCC_4247N</name>
|
||||
<parent>pci_8086_27df_scsi_host_scsi_device_lun0</parent>
|
||||
<capability type='storage'>
|
||||
<block>/dev/sr0</block>
|
||||
<bus>scsi</bus>
|
||||
<drive_type>cdrom</drive_type>
|
||||
<model>RW/DVD GCC-4247N</model>
|
||||
<vendor>HL-DT-ST</vendor>
|
||||
<capability type='removable'>
|
||||
<media_available>1</media_available>
|
||||
<media_size>12345678</media_size>
|
||||
<media_label>Windows_XP_Label</media_label>
|
||||
</capability>
|
||||
</capability>
|
||||
</device>
|
@ -80,6 +80,7 @@ mymain(int argc, char **argv)
|
||||
|
||||
DO_TEST("computer");
|
||||
DO_TEST("DVD_GCC_4247N");
|
||||
DO_TEST("DVD_with_media");
|
||||
DO_TEST("net_00_13_02_b9_f9_d3");
|
||||
DO_TEST("net_00_15_58_2f_e9_55");
|
||||
DO_TEST("pci_1002_71c4");
|
||||
|
Loading…
Reference in New Issue
Block a user