After comments from Daniel P. Berrange and from Bull people, my proposal
is reduced to following 2 functions:
/* Create a virtual device attachment to backend */
int virDomainAttachDevice(virDomainPtr domain, char *xml);
/* Destroy a virtual device attachment to backend */
int virDomainDetachDevice(virDomainPtr domain, char *xml);
/* @domain: pointer to domain object
* @xml: pointer to XML description of one device
* Returns 0 in case of success, -1 in case of failure. */
The XML would be in same form as the part of domain description for a
single device, either <disk.../disk> or <interface.../interface>.
The device is identified by its target name. This attribute is optional
for "interface" in domain description, but would become mandatory in
Attach/Detach description. It is not yet processed in Libvirt-0.1.6 source
xml.c (function virDomainParseXMLIfDesc). I have successfully tried the attached patch,
which tranlates "target"
into Xen "vifname". (It processes "ip" attribute in same way, but my
try
failed, maybe because address value was invalid for Xen).