I previously made a proposal for block devices. It was rejected because it
was VBD-specific and Xen-specific. Here is a proposal for transparent
interface with Xen or other. The virtual device attributes (VDA) are
transferred from/to application without considering their meaning, except
backend domain, previously requested to be the name for user, while it is
the ID for Xen.
typedef struct virVDA { /* virtual device attribute */
char name[16];
char value[64];
} virVDA;
int virDomainGetVdevs(virDomainPtr domain, char *type, virVDA *attr, int
maxattr);
* @type: pointer to device type, "disk", "network" ...
* @attr: pointer to an array of virVDA structures
* @maxattr: number of structures in attr array
* Return: (number of VDAs per device)<<16 + (number of devices), if
success;
* -1 if failure.
For "disk" type, Xen provides the following VDA names:
"virtual-device" (virtual device number)
"backend-id" (backend domain ID)
"state"
"backend" (backend device or file)
"ring-ref"
"event-channel"
This function changes "backend-id" to "bkdom-name" and translates
value ID
into name.
int virDomainCreateVdev(virDomainPtr domain, char *type, virVDA *attr, int
nbattr);
* @type: pointer to device type, "disk", "network" ...
* @attr: pointer to an array of virVDA structures
* @nbattr: number of structures in attr array
For "disk" type, Xen requires the following VDA names:
"uname" (backend device, value either "phy:<>" or
"file:<>"
"dev" (virtual device number)
"mode" (value "ro" for read-only, or "rw" for
read/write)
"backend" (backend domain ID)
This function translates "backend" user value (name) into ID.
int virDomainDestroyVdev(virDomainPtr domain, char *type, char *ref);
* @type: pointer to device type, "disk", "network" ...
* @ref: pointer to virtual device reference (number for Xen...)