[libvirt] libvirt question

Martin Kletzander mkletzan at redhat.com
Fri May 19 06:16:30 UTC 2017


On Fri, May 19, 2017 at 10:52:32AM +0800, zhunxun at gmail.com wrote:
>Hello,I wrote a program using libvirt API to get vm information like this:
>/*dom  is virDomainPtr type*/
>dom=virDomainLookupByID(conn,activeDomains[i]);
>if(dom!=NULL)
>    printf("%d    ----------%s\n",activeDomains[i],dom->name);
>......
>but when compile it,error occured like this:
>vm_eraser_detect.c:125:54: error: dereferencing pointer to incomplete type
>    printf("%d    ----------%s\n",activeDomains[i],dom->name);
>what is the reason of it???
>thanka a lot!
>

TL;DR s/dom->name/virDomainGetName(dom)/

Explanation:
Where did you get the idea that virDomainPtr has a name in it?  Is that
in some of our documentation?  Even if you saw it in the sources, the
compiler has no way of knowing that because you haven't included that
structure definition anywhere.  That's because we don't expose it in any
public header files.  That way we can change it at any point in the
future.  And for callers to access it, we just expose a function to get
the name.

>
>zhunxun at gmail.com

>--
>libvir-list mailing list
>libvir-list at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170519/985e866f/attachment-0001.sig>


More information about the libvir-list mailing list