libvirt: Module libvirt-nodedev from libvirt
Description: libvirt, virtualization, virtualization API

# Module libvirt-nodedev from libvirt

Provides APIs for the management of nodedevs

## Table of Contents

### Macros

    #define VIR_NODE_DEVICE_EVENT_CALLBACK

### Types

    typedef enum virConnectListAllNodeDeviceFlags
    typedef struct _virNodeDevice virNodeDevice
    typedef enum virNodeDeviceCreateXMLFlags
    typedef enum virNodeDeviceDefineXMLFlags
    typedef enum virNodeDeviceEventID
    typedef enum virNodeDeviceEventLifecycleType
    typedef virNodeDevice * virNodeDevicePtr
    typedef enum virNodeDeviceUpdateFlags
    typedef enum virNodeDeviceXMLFlags

### Functions

    int	virConnectListAllNodeDevices	(virConnectPtr conn,
    					 virNodeDevicePtr ** devices,
    					 unsigned int flags)
    int	virConnectNodeDeviceEventDeregisterAny	(virConnectPtr conn,
    						 int callbackID)
    typedef virConnectNodeDeviceEventGenericCallback
    void	virConnectNodeDeviceEventGenericCallback	(virConnectPtr conn,
    							 virNodeDevicePtr dev,
    							 void * opaque)

    typedef virConnectNodeDeviceEventLifecycleCallback
    void	virConnectNodeDeviceEventLifecycleCallback	(virConnectPtr conn,
    							 virNodeDevicePtr dev,
    							 int event,
    							 int detail,
    							 void * opaque)

    int	virConnectNodeDeviceEventRegisterAny	(virConnectPtr conn,
    						 virNodeDevicePtr dev,
    						 int eventID,
    						 virConnectNodeDeviceEventGenericCallback cb,
    						 void * opaque,
    						 virFreeCallback freecb)
    int	virNodeDeviceCreate		(virNodeDevicePtr dev,
    					 unsigned int flags)
    virNodeDevicePtr	virNodeDeviceCreateXML	(virConnectPtr conn,
    						 const char * xmlDesc,
    						 unsigned int flags)
    virNodeDevicePtr	virNodeDeviceDefineXML	(virConnectPtr conn,
    						 const char * xmlDesc,
    						 unsigned int flags)
    int	virNodeDeviceDestroy		(virNodeDevicePtr dev)
    int	virNodeDeviceDetachFlags	(virNodeDevicePtr dev,
    					 const char * driverName,
    					 unsigned int flags)
    int	virNodeDeviceDettach		(virNodeDevicePtr dev)
    int	virNodeDeviceFree		(virNodeDevicePtr dev)
    int	virNodeDeviceGetAutostart	(virNodeDevicePtr dev,
    					 int * autostart)
    const char *	virNodeDeviceGetName	(virNodeDevicePtr dev)
    const char *	virNodeDeviceGetParent	(virNodeDevicePtr dev)
    char *	virNodeDeviceGetXMLDesc		(virNodeDevicePtr dev,
    					 unsigned int flags)
    int	virNodeDeviceIsActive		(virNodeDevicePtr dev)
    int	virNodeDeviceIsPersistent	(virNodeDevicePtr dev)
    int	virNodeDeviceListCaps		(virNodeDevicePtr dev,
    					 char ** const names,
    					 int maxnames)
    virNodeDevicePtr	virNodeDeviceLookupByName	(virConnectPtr conn,
    							 const char * name)
    virNodeDevicePtr	virNodeDeviceLookupSCSIHostByWWN	(virConnectPtr conn,
    							 const char * wwnn,
    							 const char * wwpn,
    							 unsigned int flags)
    int	virNodeDeviceNumOfCaps		(virNodeDevicePtr dev)
    int	virNodeDeviceReAttach		(virNodeDevicePtr dev)
    int	virNodeDeviceRef		(virNodeDevicePtr dev)
    int	virNodeDeviceReset		(virNodeDevicePtr dev)
    int	virNodeDeviceSetAutostart	(virNodeDevicePtr dev,
    					 int autostart)
    int	virNodeDeviceUndefine		(virNodeDevicePtr dev,
    					 unsigned int flags)
    int	virNodeDeviceUpdate		(virNodeDevicePtr dev,
    					 const char * xmlDesc,
    					 unsigned int flags)
    int	virNodeListDevices		(virConnectPtr conn,
    					 const char * cap,
    					 char ** const names,
    					 int maxnames,
    					 unsigned int flags)
    int	virNodeNumOfDevices		(virConnectPtr conn,
    					 const char * cap,
    					 unsigned int flags)

## Description

### Macros

### `VIR_NODE_DEVICE_EVENT_CALLBACK`

    #define VIR_NODE_DEVICE_EVENT_CALLBACK

Used to cast the event specific callback into the generic one for use for virConnectNodeDeviceEventRegisterAny()

### Types

### `virConnectListAllNodeDeviceFlags`

Flags used to filter either by capability or active state, the returned node devices.

    enum virConnectListAllNodeDeviceFlags {

VIR_CONNECT_LIST_NODE_DEVICES_CAP_SYSTEM | = | 1 (0x1; 1 << 0) | System capability
VIR_CONNECT_LIST_NODE_DEVICES_CAP_PCI_DEV | = | 2 (0x2; 1 << 1) | PCI device
VIR_CONNECT_LIST_NODE_DEVICES_CAP_USB_DEV | = | 4 (0x4; 1 << 2) | USB device
VIR_CONNECT_LIST_NODE_DEVICES_CAP_USB_INTERFACE | = | 8 (0x8; 1 << 3) | USB interface
VIR_CONNECT_LIST_NODE_DEVICES_CAP_NET | = | 16 (0x10; 1 << 4) | Network device
VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_HOST | = | 32 (0x20; 1 << 5) | SCSI Host Bus Adapter
VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_TARGET | = | 64 (0x40; 1 << 6) | SCSI Target
VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI | = | 128 (0x80; 1 << 7) | SCSI device
VIR_CONNECT_LIST_NODE_DEVICES_CAP_STORAGE | = | 256 (0x100; 1 << 8) | Storage device
VIR_CONNECT_LIST_NODE_DEVICES_CAP_FC_HOST | = | 512 (0x200; 1 << 9) | FC Host Bus Adapter
VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS | = | 1024 (0x400; 1 << 10) | Capable of vport
VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC | = | 2048 (0x800; 1 << 11) | Capable of scsi_generic
VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM | = | 4096 (0x1000; 1 << 12) | DRM device
VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV_TYPES | = | 8192 (0x2000; 1 << 13) | Capable of mediated devices
VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV | = | 16384 (0x4000; 1 << 14) | Mediated device
VIR_CONNECT_LIST_NODE_DEVICES_CAP_CCW_DEV | = | 32768 (0x8000; 1 << 15) | CCW device
VIR_CONNECT_LIST_NODE_DEVICES_CAP_CSS_DEV | = | 65536 (0x10000; 1 << 16) | CSS device
VIR_CONNECT_LIST_NODE_DEVICES_CAP_VDPA | = | 131072 (0x20000; 1 << 17) | vDPA device
VIR_CONNECT_LIST_NODE_DEVICES_CAP_AP_CARD | = | 262144 (0x40000; 1 << 18) | s390 AP Card device
VIR_CONNECT_LIST_NODE_DEVICES_CAP_AP_QUEUE | = | 524288 (0x80000; 1 << 19) | s390 AP Queue
VIR_CONNECT_LIST_NODE_DEVICES_CAP_AP_MATRIX | = | 1048576 (0x100000; 1 << 20) | s390 AP Matrix
VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPD | = | 2097152 (0x200000; 1 << 21) | Device with VPD
VIR_CONNECT_LIST_NODE_DEVICES_CAP_CCWGROUP_DEV | = | 4194304 (0x400000; 1 << 22) | s390 CCWGROUP device
VIR_CONNECT_LIST_NODE_DEVICES_CAP_CCWGROUP_MEMBER | = | 8388608 (0x800000; 1 << 23) | s390 CCW device member of CCWGROUP device
VIR_CONNECT_LIST_NODE_DEVICES_PERSISTENT | = | 268435456 (0x10000000; 1 << 28) | Persisted devices
VIR_CONNECT_LIST_NODE_DEVICES_TRANSIENT | = | 536870912 (0x20000000; 1 << 29) | Transient devices
VIR_CONNECT_LIST_NODE_DEVICES_INACTIVE | = | 1073741824 (0x40000000; 1 << 30) | Inactive devices
VIR_CONNECT_LIST_NODE_DEVICES_ACTIVE | = | 2147483648 (0x80000000; 1 << 31) | Active devices

    }

### `virNodeDevice`

    struct virNodeDevice {

The content of this structure is not made public by the API

    }

### `virNodeDeviceCreateXMLFlags`

    enum virNodeDeviceCreateXMLFlags {

VIR_NODE_DEVICE_CREATE_XML_VALIDATE | = | 1 (0x1; 1 << 0) | Validate the XML document against schema

    }

### `virNodeDeviceDefineXMLFlags`

    enum virNodeDeviceDefineXMLFlags {

VIR_NODE_DEVICE_DEFINE_XML_VALIDATE | = | 1 (0x1; 1 << 0) | Validate the XML document against schema

    }

### `virNodeDeviceEventID`

An enumeration of supported eventId parameters for virConnectNodeDeviceEventRegisterAny(). Each event id determines which signature of callback function will be used.

    enum virNodeDeviceEventID {

VIR_NODE_DEVICE_EVENT_ID_LIFECYCLE | = | 0 (0x0) | virConnectNodeDeviceEventLifecycleCallback
VIR_NODE_DEVICE_EVENT_ID_UPDATE | = | 1 (0x1) | virConnectNodeDeviceEventGenericCallback
VIR_NODE_DEVICE_EVENT_ID_LAST | = | 2 (0x2) | NB: this enum value will increase over time as new events are added to the libvirt API. It reflects the last event ID supported by this version of the libvirt API.

    }

### `virNodeDeviceEventLifecycleType`

a virNodeDeviceEventLifecycleType is emitted during node device lifecycle events

    enum virNodeDeviceEventLifecycleType {

VIR_NODE_DEVICE_EVENT_CREATED | = | 0 (0x0) |
VIR_NODE_DEVICE_EVENT_DELETED | = | 1 (0x1) |
VIR_NODE_DEVICE_EVENT_DEFINED | = | 2 (0x2) |
VIR_NODE_DEVICE_EVENT_UNDEFINED | = | 3 (0x3) |
VIR_NODE_DEVICE_EVENT_LAST | = | 4 (0x4) |

    }

### `virNodeDevicePtr`

    typedef virNodeDevice * virNodeDevicePtr;

A virNodeDevicePtr is a pointer to a virNodeDevice structure. Get one via virNodeDeviceLookupByName, or virNodeDeviceCreate. Be sure to call virNodeDeviceFree when done using a virNodeDevicePtr obtained from any of the above functions to avoid leaking memory.

### `virNodeDeviceUpdateFlags`

Flags to control options for virNodeDeviceUpdate()

    enum virNodeDeviceUpdateFlags {

VIR_NODE_DEVICE_UPDATE_AFFECT_CURRENT | = | 0 (0x0) | affect live if node device is active, config if it's not active
VIR_NODE_DEVICE_UPDATE_AFFECT_LIVE | = | 1 (0x1; 1 << 0) | affect live state of node device only
VIR_NODE_DEVICE_UPDATE_AFFECT_CONFIG | = | 2 (0x2; 1 << 1) | affect persistent config only

    }

### `virNodeDeviceXMLFlags`

Flags used to provide the state of the returned node device configuration.

    enum virNodeDeviceXMLFlags {

VIR_NODE_DEVICE_XML_INACTIVE | = | 1 (0x1; 1 << 0) | dump inactive device configuration

    }

### Functions

### `virConnectListAllNodeDevices`

    int	virConnectListAllNodeDevices	(virConnectPtr conn,
    					 virNodeDevicePtr ** devices,
    					 unsigned int flags)

Collect the list of node devices, and allocate an array to store those objects.

Normally, all node devices are returned; however, `flags` can be used to filter the results for a smaller list of targeted node devices.

conn
  Pointer to the hypervisor connection.
devices
  Pointer to a variable to store the array containing the node device objects or NULL if the list is not required (just returns number of node devices).
flags
  bitwise-OR of virConnectListAllNodeDeviceFlags.
Returns
  the number of node devices found or -1 and sets `devices` to NULL in case of error. On success, the array stored into `devices` is guaranteed to have an extra allocated element set to NULL but not included in the return count, to make iteration easier. The caller is responsible for calling virNodeDeviceFree() on each array element, then calling free() on `devices`.

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
connect | search-node-devices | -

##### Access control return value filters

Object | Permission
--- | ---
node-device | getattr

### `virConnectNodeDeviceEventDeregisterAny`

    int	virConnectNodeDeviceEventDeregisterAny	(virConnectPtr conn,
    						 int callbackID)

Removes an event callback. The callbackID parameter should be the value obtained from a previous virConnectNodeDeviceEventRegisterAny() method.

conn
  pointer to the connection
callbackID
  the callback identifier
Returns
  0 on success, -1 on failure.

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
connect | read | -

### `virConnectNodeDeviceEventGenericCallback`

    typedef void	(*virConnectNodeDeviceEventGenericCallback)	(virConnectPtr conn,
    							 virNodeDevicePtr dev,
    							 void * opaque)

A generic node device event callback handler, for use with virConnectNodeDeviceEventRegisterAny(). Specific events usually have a customization with extra parameters, often with `opaque` being passed in a different parameter position; use VIR_NODE_DEVICE_EVENT_CALLBACK() when registering an appropriate handler.

conn
  the connection pointer
dev
  the node device pointer
opaque
  application specified data

### `virConnectNodeDeviceEventLifecycleCallback`

    typedef void	(*virConnectNodeDeviceEventLifecycleCallback)	(virConnectPtr conn,
    							 virNodeDevicePtr dev,
    							 int event,
    							 int detail,
    							 void * opaque)

This callback is called when a node device lifecycle action is performed, like added or removed.

The callback signature to use when registering for an event of type VIR_NODE_DEVICE_EVENT_ID_LIFECYCLE with virConnectNodeDeviceEventRegisterAny()

conn
  connection object
dev
  node device on which the event occurred
event
  The specific virNodeDeviceEventLifecycleType which occurred
detail
  contains some details on the reason of the event.
opaque
  application specified data

### `virConnectNodeDeviceEventRegisterAny`

    int	virConnectNodeDeviceEventRegisterAny	(virConnectPtr conn,
    						 virNodeDevicePtr dev,
    						 int eventID,
    						 virConnectNodeDeviceEventGenericCallback cb,
    						 void * opaque,
    						 virFreeCallback freecb)

Adds a callback to receive notifications of arbitrary node device events occurring on a node device. This function requires that an event loop has been previously registered with virEventRegisterImpl() or virEventRegisterDefaultImpl().

If `dev` is NULL, then events will be monitored for any node device. If `dev` is non-NULL, then only the specific node device will be monitored.

Most types of events have a callback providing a custom set of parameters for the event. When registering an event, it is thus necessary to use the VIR_NODE_DEVICE_EVENT_CALLBACK() macro to cast the supplied function pointer to match the signature of this method.

The virNodeDevicePtr object handle passed into the callback upon delivery of an event is only valid for the duration of execution of the callback. If the callback wishes to keep the node device object after the callback returns, it shall take a reference to it, by calling virNodeDeviceRef(). The reference can be released once the object is no longer required by calling virNodeDeviceFree().

The return value from this method is a positive integer identifier for the callback. To unregister a callback, this callback ID should be passed to the virConnectNodeDeviceEventDeregisterAny() method.

conn
  pointer to the connection
dev
  pointer to the node device
eventID
  the event type to receive
cb
  callback to the function handling node device events
opaque
  opaque data to pass on to the callback
freecb
  optional function to deallocate opaque when not used anymore
Returns
  a callback identifier on success, -1 on failure.

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
connect | search-node-devices | -

##### Access control return value filters

Object | Permission
--- | ---
node-device | getattr

### `virNodeDeviceCreate`

    int	virNodeDeviceCreate		(virNodeDevicePtr dev,
    					 unsigned int flags)

Start a defined node device:

dev
  a device object
flags
  extra flags; not used yet, so callers should always pass 0
Returns
  0 in case of success and -1 in case of failure.

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
node-device | start | -

### `virNodeDeviceCreateXML`

    virNodeDevicePtr	virNodeDeviceCreateXML	(virConnectPtr conn,
    						 const char * xmlDesc,
    						 unsigned int flags)

Create a new device on the VM host machine, for example, virtual HBAs created using vport_create.

virNodeDeviceFree should be used to free the resources after the node device object is no longer needed.

conn
  pointer to the hypervisor connection
xmlDesc
  string containing an XML description of the device to be created
flags
  bitwise-OR of supported virNodeDeviceCreateXMLFlags
Returns
  a node device object if successful, NULL in case of failure

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
node-device | write | -
node-device | start | -

### `virNodeDeviceDefineXML`

    virNodeDevicePtr	virNodeDeviceDefineXML	(virConnectPtr conn,
    						 const char * xmlDesc,
    						 unsigned int flags)

Define a new inactive persistent device or modify an existing persistent one from the XML description on the VM host machine, for example, a mediated device.

virNodeDeviceFree should be used to free the resources after the node device object is no longer needed.

conn
  pointer to the hypervisor connection
xmlDesc
  string containing an XML description of the device to be defined
flags
  bitwise-OR of supported virNodeDeviceDefineXMLFlags
Returns
  a node device object if successful, NULL in case of failure

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
node-device | write | -
node-device | save | -

### `virNodeDeviceDestroy`

    int	virNodeDeviceDestroy		(virNodeDevicePtr dev)

Destroy the device object. The virtual device (only works for vHBA currently) is removed from the host operating system. This function may require privileged access.

dev
  a device object
Returns
  0 in case of success and -1 in case of failure.

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
node-device | stop | -

### `virNodeDeviceDetachFlags`

    int	virNodeDeviceDetachFlags	(virNodeDevicePtr dev,
    					 const char * driverName,
    					 unsigned int flags)

Detach the node device from the node itself so that it may be assigned to a guest domain.

Depending on the hypervisor, this may involve operations such as unbinding any device drivers from the device, binding the device to a dummy device driver and resetting the device. Different backend drivers expect the device to be bound to different dummy devices. For example, QEMU's "kvm" backend driver (the default) expects the device to be bound to "pci-stub", but its "vfio" backend driver expects the device to be bound to "vfio-pci".

If the device is currently in use by the node, this method may fail.

Once the device is not assigned to any guest, it may be re-attached to the node using the virNodeDeviceReAttach() method.

dev
  pointer to the node device
driverName
  name of backend driver that will be used for later device assignment to a domain. NULL means "use the hypervisor default driver"
flags
  extra flags; not used yet, so callers should always pass 0
Returns
  0 in case of success, -1 in case of failure.

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
node-device | detach | -

### `virNodeDeviceDettach`

    int	virNodeDeviceDettach		(virNodeDevicePtr dev)

Detach the node device from the node itself so that it may be assigned to a guest domain.

Depending on the hypervisor, this may involve operations such as unbinding any device drivers from the device, binding the device to a dummy device driver and resetting the device.

If the device is currently in use by the node, this method may fail.

Once the device is not assigned to any guest, it may be re-attached to the node using the virNodeDeviceReattach() method.

If the caller needs control over which backend driver will be used during PCI device assignment (to use something other than the default, for example VFIO), the newer virNodeDeviceDetachFlags() API should be used instead.

dev
  pointer to the node device
Returns
  0 in case of success, -1 in case of failure.

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
node-device | detach | -

### `virNodeDeviceFree`

    int	virNodeDeviceFree		(virNodeDevicePtr dev)

Drops a reference to the node device, freeing it if this was the last reference.

dev
  pointer to the node device
Returns
  the 0 for success, -1 for error.

### `virNodeDeviceGetAutostart`

    int	virNodeDeviceGetAutostart	(virNodeDevicePtr dev,
    					 int * autostart)

Provides a boolean value indicating whether the node device is configured to be automatically started when the host machine boots or the parent device becomes available.

dev
  the device object
autostart
  the value returned
Returns
  -1 in case of error, 0 in case of success

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
node-device | read | -

### `virNodeDeviceGetName`

    const char *	virNodeDeviceGetName	(virNodeDevicePtr dev)

Just return the device name

dev
  the device
Returns
  the device name or NULL in case of error

### `virNodeDeviceGetParent`

    const char *	virNodeDeviceGetParent	(virNodeDevicePtr dev)

Accessor for the parent of the device

dev
  the device
Returns
  the name of the device's parent, or NULL if an error occurred or when the device has no parent.

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
node-device | read | -

### `virNodeDeviceGetXMLDesc`

    char *	virNodeDeviceGetXMLDesc		(virNodeDevicePtr dev,
    					 unsigned int flags)

Fetch an XML document describing all aspects of the device.

dev
  pointer to the node device
flags
  bitwise-OR of virNodeDeviceXMLFlags
Returns
  the XML document, or NULL on error

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
node-device | read | -

### `virNodeDeviceIsActive`

    int	virNodeDeviceIsActive		(virNodeDevicePtr dev)

Determine if the node device is currently active

dev
  pointer to the node device object
Returns
  1 if active, 0 if inactive, -1 on error

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
node-device | read | -

### `virNodeDeviceIsPersistent`

    int	virNodeDeviceIsPersistent	(virNodeDevicePtr dev)

Determine if the node device has a persistent configuration which means it will still exist after shutting down

dev
  pointer to the nodedev object
Returns
  1 if persistent, 0 if transient, -1 on error

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
node-device | read | -

### `virNodeDeviceListCaps`

    int	virNodeDeviceListCaps		(virNodeDevicePtr dev,
    					 char ** const names,
    					 int maxnames)

Lists the names of the capabilities supported by the device.

dev
  the device
names
  array to collect the list of capability names
maxnames
  size of `names`
Returns
  the number of capability names listed in `names` or -1 in case of error.

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
node-device | read | -

### `virNodeDeviceLookupByName`

    virNodeDevicePtr	virNodeDeviceLookupByName	(virConnectPtr conn,
    							 const char * name)

Lookup a node device by its name.

virNodeDeviceFree should be used to free the resources after the node device object is no longer needed.

conn
  pointer to the hypervisor connection
name
  unique device name
Returns
  a virNodeDevicePtr if found, NULL otherwise.

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
node-device | getattr | -

### `virNodeDeviceLookupSCSIHostByWWN`

    virNodeDevicePtr	virNodeDeviceLookupSCSIHostByWWN	(virConnectPtr conn,
    							 const char * wwnn,
    							 const char * wwpn,
    							 unsigned int flags)

Lookup SCSI Host which is capable with 'fc_host' by its WWNN and WWPN.

virNodeDeviceFree should be used to free the resources after the node device object is no longer needed.

conn
  pointer to the hypervisor connection
wwnn
  WWNN of the SCSI Host.
wwpn
  WWPN of the SCSI Host.
flags
  extra flags; not used yet, so callers should always pass 0
Returns
  a virNodeDevicePtr if found, NULL otherwise.

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
node-device | getattr | -

### `virNodeDeviceNumOfCaps`

    int	virNodeDeviceNumOfCaps		(virNodeDevicePtr dev)

Accessor for the number of capabilities supported by the device.

dev
  the device
Returns
  the number of capabilities supported by the device or -1 in case of error.

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
node-device | read | -

### `virNodeDeviceReAttach`

    int	virNodeDeviceReAttach		(virNodeDevicePtr dev)

Re-attach a previously detached node device to the node so that it may be used by the node again.

Depending on the hypervisor, this may involve operations such as resetting the device, unbinding it from a dummy device driver and binding it to its appropriate driver.

If the device is currently in use by a guest, this method may fail.

dev
  pointer to the node device
Returns
  0 in case of success, -1 in case of failure.

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
node-device | detach | -

### `virNodeDeviceRef`

    int	virNodeDeviceRef		(virNodeDevicePtr dev)

Increment the reference count on the dev. For each additional call to this method, there shall be a corresponding call to virNodeDeviceFree to release the reference count, once the caller no longer needs the reference to this object.

This method is typically useful for applications where multiple threads are using a connection, and it is required that the connection remain open until all threads have finished using it. ie, each new thread using a dev would increment the reference count.

dev
  the dev to hold a reference on
Returns
  0 in case of success, -1 in case of failure.

### `virNodeDeviceReset`

    int	virNodeDeviceReset		(virNodeDevicePtr dev)

Reset a previously detached node device to the node before or after assigning it to a guest.

The exact reset semantics depends on the hypervisor and device type but, for example, KVM will attempt to reset PCI devices with a Function Level Reset, Secondary Bus Reset or a Power Management D-State reset.

If the reset will affect other devices which are currently in use, this function may fail.

dev
  pointer to the node device
Returns
  0 in case of success, -1 in case of failure.

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
node-device | detach | -

### `virNodeDeviceSetAutostart`

    int	virNodeDeviceSetAutostart	(virNodeDevicePtr dev,
    					 int autostart)

Configure the node device to be automatically started when the host machine boots or the parent device becomes available.

dev
  the device object
autostart
  whether the device should be automatically started
Returns
  -1 in case of error, 0 in case of success

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
node-device | write | -

### `virNodeDeviceUndefine`

    int	virNodeDeviceUndefine		(virNodeDevicePtr dev,
    					 unsigned int flags)

Undefine the device object. The virtual device is removed from the host operating system. This function may require privileged access.

dev
  a device object
flags
  extra flags; not used yet, so callers should always pass 0
Returns
  0 in case of success and -1 in case of failure.

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
node-device | delete | -

### `virNodeDeviceUpdate`

    int	virNodeDeviceUpdate		(virNodeDevicePtr dev,
    					 const char * xmlDesc,
    					 unsigned int flags)

Update the definition of an existing node device, either its live running configuration, its persistent configuration, or both.

dev
  pointer to the node device object
xmlDesc
  string containing an XML description of the device to be defined
flags
  bitwise OR of virNodeDeviceUpdateFlags
Returns
  0 in case of success, -1 in case of error

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
node-device | write | -
node-device | save | !VIR_NODE_DEVICE_UPDATE_AFFECT_CONFIG|VIR_NODE_DEVICE_UPDATE_AFFECT_LIVE
node-device | save | VIR_NODE_DEVICE_UPDATE_AFFECT_CONFIG

### `virNodeListDevices`

    int	virNodeListDevices		(virConnectPtr conn,
    					 const char * cap,
    					 char ** const names,
    					 int maxnames,
    					 unsigned int flags)

Collect the list of node devices, and store their names in `names`

The use of this function is discouraged. Instead, use virConnectListAllNodeDevices().

If the optional 'cap' argument is non-NULL, then the count will be restricted to devices with the specified capability

conn
  pointer to the hypervisor connection
cap
  capability name
names
  array to collect the list of node device names
maxnames
  size of `names`
flags
  extra flags; not used yet, so callers should always pass 0
Returns
  the number of node devices found or -1 in case of error

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
connect | search-node-devices | -

##### Access control return value filters

Object | Permission
--- | ---
node-device | getattr

### `virNodeNumOfDevices`

    int	virNodeNumOfDevices		(virConnectPtr conn,
    					 const char * cap,
    					 unsigned int flags)

Provides the number of node devices.

If the optional 'cap' argument is non-NULL, then the count will be restricted to devices with the specified capability

conn
  pointer to the hypervisor connection
cap
  capability name
flags
  extra flags; not used yet, so callers should always pass 0
Returns
  the number of node devices or -1 in case of error

##### Access control parameter checks

Object | Permission | Condition
--- | --- | ---
connect | search-node-devices | -

##### Access control return value filters

Object | Permission
--- | ---
node-device | getattr