提交 deae2bb5 编写于 作者: C Cole Robinson 提交者: Daniel Veillard

nodedev: Add removable storage 'media_label' prop

Provides the CDROM label for current media. Only implemented for the
udev backend.
上级 a010165d
......@@ -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) {
......
<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");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册