mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-24 21:45: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)
|
if (data->system.product_name)
|
||||||
virBufferEscapeString(&buf, " <product>%s</product>\n",
|
virBufferEscapeString(&buf, " <product>%s</product>\n",
|
||||||
data->system.product_name);
|
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");
|
virBufferAddLit(&buf, " <hardware>\n");
|
||||||
if (data->system.hardware.vendor_name)
|
if (data->system.hardware.vendor_name)
|
||||||
virBufferEscapeString(&buf, " <vendor>%s</vendor>\n",
|
virBufferEscapeString(&buf, " <vendor>%s</vendor>\n",
|
||||||
@ -325,6 +331,9 @@ char *virNodeDeviceDefFormat(virConnectPtr conn,
|
|||||||
data->usb_if.subclass);
|
data->usb_if.subclass);
|
||||||
virBufferVSprintf(&buf, " <protocol>%d</protocol>\n",
|
virBufferVSprintf(&buf, " <protocol>%d</protocol>\n",
|
||||||
data->usb_if.protocol);
|
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)
|
if (data->usb_if.description)
|
||||||
virBufferVSprintf(&buf, " <description>%s</description>\n",
|
virBufferVSprintf(&buf, " <description>%s</description>\n",
|
||||||
data->usb_if.description);
|
data->usb_if.description);
|
||||||
@ -394,10 +403,26 @@ char *virNodeDeviceDefFormat(virConnectPtr conn,
|
|||||||
"</media_available>\n", avl ? 1 : 0);
|
"</media_available>\n", avl ? 1 : 0);
|
||||||
virBufferVSprintf(&buf, " <media_size>%llu</media_size>\n",
|
virBufferVSprintf(&buf, " <media_size>%llu</media_size>\n",
|
||||||
data->storage.removable_media_size);
|
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");
|
virBufferAddLit(&buf, " </capability>\n");
|
||||||
} else {
|
} else {
|
||||||
virBufferVSprintf(&buf, " <size>%llu</size>\n",
|
virBufferVSprintf(&buf, " <size>%llu</size>\n",
|
||||||
data->storage.size);
|
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)
|
if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_HOTPLUGGABLE)
|
||||||
virBufferAddLit(&buf,
|
virBufferAddLit(&buf,
|
||||||
@ -1315,6 +1340,8 @@ void virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
|
|||||||
switch (caps->type) {
|
switch (caps->type) {
|
||||||
case VIR_NODE_DEV_CAP_SYSTEM:
|
case VIR_NODE_DEV_CAP_SYSTEM:
|
||||||
VIR_FREE(data->system.product_name);
|
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.vendor_name);
|
||||||
VIR_FREE(data->system.hardware.version);
|
VIR_FREE(data->system.hardware.version);
|
||||||
VIR_FREE(data->system.hardware.serial);
|
VIR_FREE(data->system.hardware.serial);
|
||||||
@ -1331,6 +1358,7 @@ void virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
|
|||||||
VIR_FREE(data->usb_dev.vendor_name);
|
VIR_FREE(data->usb_dev.vendor_name);
|
||||||
break;
|
break;
|
||||||
case VIR_NODE_DEV_CAP_USB_INTERFACE:
|
case VIR_NODE_DEV_CAP_USB_INTERFACE:
|
||||||
|
VIR_FREE(data->usb_if.interface_name);
|
||||||
VIR_FREE(data->usb_if.description);
|
VIR_FREE(data->usb_if.description);
|
||||||
break;
|
break;
|
||||||
case VIR_NODE_DEV_CAP_NET:
|
case VIR_NODE_DEV_CAP_NET:
|
||||||
|
@ -82,6 +82,8 @@ struct _virNodeDevCapsDef {
|
|||||||
union _virNodeDevCapData {
|
union _virNodeDevCapData {
|
||||||
struct {
|
struct {
|
||||||
char *product_name;
|
char *product_name;
|
||||||
|
char *description;
|
||||||
|
char *dmi_devpath;
|
||||||
struct {
|
struct {
|
||||||
char *vendor_name;
|
char *vendor_name;
|
||||||
char *version;
|
char *version;
|
||||||
@ -101,6 +103,7 @@ struct _virNodeDevCapsDef {
|
|||||||
unsigned function;
|
unsigned function;
|
||||||
unsigned product;
|
unsigned product;
|
||||||
unsigned vendor;
|
unsigned vendor;
|
||||||
|
unsigned class;
|
||||||
char *product_name;
|
char *product_name;
|
||||||
char *vendor_name;
|
char *vendor_name;
|
||||||
} pci_dev;
|
} pci_dev;
|
||||||
@ -117,10 +120,12 @@ struct _virNodeDevCapsDef {
|
|||||||
unsigned _class; /* "class" is reserved in C */
|
unsigned _class; /* "class" is reserved in C */
|
||||||
unsigned subclass;
|
unsigned subclass;
|
||||||
unsigned protocol;
|
unsigned protocol;
|
||||||
|
char *interface_name;
|
||||||
char *description;
|
char *description;
|
||||||
} usb_if;
|
} usb_if;
|
||||||
struct {
|
struct {
|
||||||
char *address;
|
char *address;
|
||||||
|
unsigned address_len;
|
||||||
char *ifname;
|
char *ifname;
|
||||||
enum virNodeDevNetCapType subtype; /* LAST -> no subtype */
|
enum virNodeDevNetCapType subtype; /* LAST -> no subtype */
|
||||||
} net;
|
} net;
|
||||||
@ -139,6 +144,8 @@ struct _virNodeDevCapsDef {
|
|||||||
} scsi;
|
} scsi;
|
||||||
struct {
|
struct {
|
||||||
unsigned long long size;
|
unsigned long long size;
|
||||||
|
unsigned long long num_blocks;
|
||||||
|
unsigned long long logical_block_size;
|
||||||
unsigned long long removable_media_size;
|
unsigned long long removable_media_size;
|
||||||
char *block;
|
char *block;
|
||||||
char *bus;
|
char *bus;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user