Zhihua Che
2012-Apr-06 07:24 UTC
[libvirt-users] [API reference] Are there XML-handling API to retrieve info directly from xml configure file
Hi, everyone I'm writing a application using libvirt and need to query guest os's virtual network interface usage, like bytes read or written through a given interface. I know int virDomainInterfaceStats(virDomainPtr dom, const char * path, virDomainInterfaceStatsPtr stats, size_t size) is designed for my purpose but I 'm not sure how I determine the second parameter path. I'm now think of determining the virtual interface by parsing the domain's xml configure file. But I don't find that libvirt supply such functions, that means, I have to resort to other library lik libxml? thanks
Eric Blake
2012-Apr-06 14:27 UTC
[libvirt-users] [API reference] Are there XML-handling API to retrieve info directly from xml configure file
On 04/06/2012 01:24 AM, Zhihua Che wrote:> Hi, everyone > > I'm writing a application using libvirt and need to query guest > os's virtual network interface usage, like bytes read or written > through a given interface. I know int > virDomainInterfaceStats(virDomainPtr dom, const char * path, > virDomainInterfaceStatsPtr stats, size_t size) is designed for my > purpose but I 'm not sure how I determine the second parameter path. > I'm now think of determining the virtual interface by parsing the > domain's xml configure file. > But I don't find that libvirt supply such functions, that means, I > have to resort to other library lik libxml?You may be interested in the libvirt-glib project, which includes the libvirt-gconfig subpackage to provide an API on top of libvirt for more convenient access into domain XML: https://www.redhat.com/archives/libvirt-announce/2012-March/msg00004.html -- Eric Blake eblake at redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 620 bytes Desc: OpenPGP digital signature URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20120406/50cefdb0/attachment.sig>
Richard W.M. Jones
2012-Apr-07 21:36 UTC
[libvirt-users] [API reference] Are there XML-handling API to retrieve info directly from xml configure file
On Fri, Apr 06, 2012 at 03:24:25PM +0800, Zhihua Che wrote:> Hi, everyone > > I'm writing a application using libvirt and need to query guest > os's virtual network interface usage, like bytes read or written > through a given interface. I know int > virDomainInterfaceStats(virDomainPtr dom, const char * path, > virDomainInterfaceStatsPtr stats, size_t size) is designed for my > purpose but I 'm not sure how I determine the second parameter path. > I'm now think of determining the virtual interface by parsing the > domain's xml configure file. > But I don't find that libvirt supply such functions, that means, I > have to resort to other library lik libxml?I would also really like to see such an API/APIs in the basic libvirt API. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org