[libvirt] libvirt question

zhunxun at gmail.com zhunxun at gmail.com
Fri May 19 06:28:18 UTC 2017


Thanks a lot!



zhunxun at gmail.com
 
From: Martin Kletzander
Date: 2017-05-19 14:16
To: zhunxun at gmail.com
CC: libvir-list
Subject: Re: [libvirt] libvirt question
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 --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170519/ce63f026/attachment-0001.htm>


More information about the libvir-list mailing list