mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-08 22:15:21 +00:00
Add several fields to node device capabilities
* src/conf/node_device_conf.h src/conf/node_device_conf.c: add the new fields in the structure as well as parsing and serialization
This commit is contained in:
parent
ce4c0bf5a2
commit
fe2af45bb2
@ -248,6 +248,12 @@ char *virNodeDeviceDefFormat(virConnectPtr conn,
|
||||
if (data->system.product_name)
|
||||
virBufferEscapeString(&buf, " <product>%s</product>\n",
|
||||
data->system.product_name);
|
||||
if (data->system.dmi_devpath)
|
||||
virBufferEscapeString(&buf, " <dmi_devpath>%s</dmi_devpath>\n",
|
||||
data->system.dmi_devpath);
|
||||
if (data->system.description)
|
||||
virBufferEscapeString(&buf, " <description>%s</description>\n",
|
||||
data->system.description);
|
||||
virBufferAddLit(&buf, " <hardware>\n");
|
||||
if (data->system.hardware.vendor_name)
|
||||
virBufferEscapeString(&buf, " <vendor>%s</vendor>\n",
|
||||
@ -325,6 +331,9 @@ char *virNodeDeviceDefFormat(virConnectPtr conn,
|
||||
data->usb_if.subclass);
|
||||
virBufferVSprintf(&buf, " <protocol>%d</protocol>\n",
|
||||
data->usb_if.protocol);
|
||||
if (data->usb_if.interface_name)
|
||||
virBufferVSprintf(&buf, " <interface_name>%s</interface_name>\n",
|
||||
data->usb_if.interface_name);
|
||||
if (data->usb_if.description)
|
||||
virBufferVSprintf(&buf, " <description>%s</description>\n",
|
||||
data->usb_if.description);
|
||||
@ -394,10 +403,26 @@ 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.logical_block_size > 0)
|
||||
virBufferVSprintf(&buf, " <logical_block_size>%llu"
|
||||
"</logical_block_size>\n",
|
||||
data->storage.logical_block_size);
|
||||
if (data->storage.num_blocks > 0)
|
||||
virBufferVSprintf(&buf,
|
||||
" <num_blocks>%llu</num_blocks>\n",
|
||||
data->storage.num_blocks);
|
||||
virBufferAddLit(&buf, " </capability>\n");
|
||||
} else {
|
||||
virBufferVSprintf(&buf, " <size>%llu</size>\n",
|
||||
data->storage.size);
|
||||
if (data->storage.logical_block_size > 0)
|
||||
virBufferVSprintf(&buf, " <logical_block_size>%llu"
|
||||
"</logical_block_size>\n",
|
||||
data->storage.logical_block_size);
|
||||
if (data->storage.num_blocks > 0)
|
||||
virBufferVSprintf(&buf,
|
||||
" <num_blocks>%llu</num_blocks>\n",
|
||||
data->storage.num_blocks);
|
||||
}
|
||||
if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_HOTPLUGGABLE)
|
||||
virBufferAddLit(&buf,
|
||||
@ -1315,6 +1340,8 @@ void virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
|
||||
switch (caps->type) {
|
||||
case VIR_NODE_DEV_CAP_SYSTEM:
|
||||
VIR_FREE(data->system.product_name);
|
||||
VIR_FREE(data->system.dmi_devpath);
|
||||
VIR_FREE(data->system.description);
|
||||
VIR_FREE(data->system.hardware.vendor_name);
|
||||
VIR_FREE(data->system.hardware.version);
|
||||
VIR_FREE(data->system.hardware.serial);
|
||||
@ -1331,6 +1358,7 @@ void virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
|
||||
VIR_FREE(data->usb_dev.vendor_name);
|
||||
break;
|
||||
case VIR_NODE_DEV_CAP_USB_INTERFACE:
|
||||
VIR_FREE(data->usb_if.interface_name);
|
||||
VIR_FREE(data->usb_if.description);
|
||||
break;
|
||||
case VIR_NODE_DEV_CAP_NET:
|
||||
|
@ -82,6 +82,8 @@ struct _virNodeDevCapsDef {
|
||||
union _virNodeDevCapData {
|
||||
struct {
|
||||
char *product_name;
|
||||
char *description;
|
||||
char *dmi_devpath;
|
||||
struct {
|
||||
char *vendor_name;
|
||||
char *version;
|
||||
@ -101,6 +103,7 @@ struct _virNodeDevCapsDef {
|
||||
unsigned function;
|
||||
unsigned product;
|
||||
unsigned vendor;
|
||||
unsigned class;
|
||||
char *product_name;
|
||||
char *vendor_name;
|
||||
} pci_dev;
|
||||
@ -117,10 +120,12 @@ struct _virNodeDevCapsDef {
|
||||
unsigned _class; /* "class" is reserved in C */
|
||||
unsigned subclass;
|
||||
unsigned protocol;
|
||||
char *interface_name;
|
||||
char *description;
|
||||
} usb_if;
|
||||
struct {
|
||||
char *address;
|
||||
unsigned address_len;
|
||||
char *ifname;
|
||||
enum virNodeDevNetCapType subtype; /* LAST -> no subtype */
|
||||
} net;
|
||||
@ -139,6 +144,8 @@ struct _virNodeDevCapsDef {
|
||||
} scsi;
|
||||
struct {
|
||||
unsigned long long size;
|
||||
unsigned long long num_blocks;
|
||||
unsigned long long logical_block_size;
|
||||
unsigned long long removable_media_size;
|
||||
char *block;
|
||||
char *bus;
|
||||
|
Loading…
Reference in New Issue
Block a user