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

Dennis Chen dennis.chen at tnsoft.com.cn
Wed Nov 21 09:42:04 UTC 2012

On 11/21/2012 05:34 PM, Daniel P. Berrange wrote:
> 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

Yeah, I know. So the email is try to get to know how to use cgroup to 
configure the cpu bandwidth of a specific VM, I am writing a separate 
project to control the cfs bandwidth of a VM specified, not taking use 
of the virsh shell.

Any tips?


More information about the libvirt-users mailing list