[libvirt-users] How to lookup the driver instance through virConnectPtr pointer

Daniel P. Berrange berrange at redhat.com
Wed Nov 21 09:34:39 UTC 2012


On Wed, Nov 21, 2012 at 05:24:18PM +0800, Dennis Chen wrote:
> Hi,
> 
> I plan to use virCgroupSetCpuCfsPeriod() and
> virCgroupSetCpuCfsQuota() to control cpu bandwidth with help of
> cgroup,
> so I need to instantiate the cgroup parameter first for the calling
> of virCgroupSetCpuCfsPeriod, below is my code piece:
> 
> 1        virConnectPtr conn;
> 2        struct qemud_driver *driver;
> 
> 3        conn = virConnectOpen("qemu:///system");
> 4        driver = conn->privateData;
> 5        virCgroupSetCpuCfsPeriod(driver->cgroup, cfs_period);
> 
> then I get an compiling error in line 4:
> error: dereferencing pointer to incomplete type
> 
> I know the reason is the actual definition of virConnectPtr is in
> datatyps.h, but it's not reasonable or ugly to include this file in
> my project.

datatypes.h is an internal *private* header file which applications
cannot use.

> So my question is, is there any API that I can get the driver
> instance from virConnectPtr conn in the libvirt?

No, this is internal code. Your connection to libvirtd goes over an
RPC protocol, so there is no way for you to directly access this.
You must only use the public APis in libvirt.h or virterror.h

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvirt-users mailing list