At 06/30/2011 11:13 AM, Wen Congyang Write: > We want to control bandwidth for each vcpu, so we can not use the > API virDomainSetSchedulerParameters(). Introduce two new APIs to > change and query bandwidth for each vcpu. > > + > +/** > + * virDomainSetVcpuBW: > + * @domain: pointer to domain object > + * @params: pointer to vcpu bandwidth objects another typo error: s/params/vcpubw/ > + * @nparams: number of vcpu bandwidth objects s/nparams/nvcpubw/ > + * (this value can be the same or less than domain's vcpu num) > + * @flags: bitwise-OR of virDomainModificationImpact > + * > + * Change a subset or all vcpu bandwidth. The value of @flags > + * should be either VIR_DOMAIN_AFFECT_CURRENT, or a bitwise-or of > + * values from VIR_DOMAIN_AFFECT_LIVE and VIR_DOMAIN_AFFECT_CONFIG, > + * although hypervisors vary in which flags are supported. > + * > + * Returns -1 in case of error, 0 in case of success. > + */ > +int > +virDomainSetVcpuBW(virDomainPtr domain, virDomainVcpuBWDefPtr vcpubw, > + int nvcpu, unsigned int flags) > +{ > + virConnectPtr conn; > + > + VIR_DOMAIN_DEBUG(domain, "vcpubw=%p, nvcpu=%d, flags=%u", > + vcpubw, nvcpu, flags); > + > + virResetLastError(); > + > + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { > + virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); > + virDispatchError(NULL); > + return -1; > + } > + > + if (vcpubw == NULL || nvcpu < 0) { > + virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__); > + goto error; > + } > + > + if (domain->conn->flags & VIR_CONNECT_RO) { > + virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); > + goto error; > + } > + conn = domain->conn; > + > + if (conn->driver->domainSetVcpuBW) { > + int ret; > + ret = conn->driver->domainSetVcpuBW(domain, vcpubw, nvcpu, flags); > + if (ret < 0) > + goto error; > + return ret; > + } > + > + virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); > + > +error: > + virDispatchError(domain->conn); > + return -1; > +} > + > > /** > * virDomainBlockStats: > diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms > index 5f2541a..d4f80a6 100644 > --- a/src/libvirt_public.syms > +++ b/src/libvirt_public.syms > @@ -466,4 +466,10 @@ LIBVIRT_0.9.3 { > virNodeGetMemoryStats; > } LIBVIRT_0.9.2; > > +LIBVIRT_0.9.4 { > + global: > + virDomainGetVcpuBW; > + virDomainSetVcpuBW; > +} LIBVIRT_0.9.3; > + > # .... define new API here using predicted next version number .... -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list