|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 08/11] tools/libxl: add functions for retrieving and setting xenstore quota
On Thu, Mar 5, 2026 at 8:52 AM Juergen Gross <jgross@xxxxxxxx> wrote:
>
> Add some functions allowing to retrieve and set Xenstore quota (either
> global or domain specific).
>
> Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
> ---
> tools/golang/xenlight/helpers.gen.go | 78 ++++++++++++++++++++
> tools/golang/xenlight/types.gen.go | 9 +++
> tools/include/libxl.h | 20 ++++++
> tools/libs/light/Makefile | 1 +
> tools/libs/light/libxl_types.idl | 9 +++
> tools/libs/light/libxl_xsquota.c | 102 +++++++++++++++++++++++++++
> 6 files changed, 219 insertions(+)
> create mode 100644 tools/libs/light/libxl_xsquota.c
>
> diff --git a/tools/golang/xenlight/helpers.gen.go
> b/tools/golang/xenlight/helpers.gen.go
> index 8909fe8a1b..6c9af904c5 100644
> --- a/tools/golang/xenlight/helpers.gen.go
> +++ b/tools/golang/xenlight/helpers.gen.go
> @@ -998,6 +998,84 @@ xc.policy = C.libxl_rdm_reserve_policy(x.Policy)
> return nil
> }
>
> +// NewXsQuotaItem returns an instance of XsQuotaItem initialized with
> defaults.
> +func NewXsQuotaItem() (*XsQuotaItem, error) {
> +var (
> +x XsQuotaItem
> +xc C.libxl_xs_quota_item)
> +
> +C.libxl_xs_quota_item_init(&xc)
> +defer C.libxl_xs_quota_item_dispose(&xc)
> +
> +if err := x.fromC(&xc); err != nil {
> +return nil, err }
> +
> +return &x, nil}
> +
> +func (x *XsQuotaItem) fromC(xc *C.libxl_xs_quota_item) error {
> + x.Name = C.GoString(xc.name)
> +x.Val = uint32(xc.val)
> +
> + return nil}
> +
> +func (x *XsQuotaItem) toC(xc *C.libxl_xs_quota_item) (err error){defer
> func(){
> +if err != nil{
> +C.libxl_xs_quota_item_dispose(xc)}
> +}()
> +
> +if x.Name != "" {
> +xc.name = C.CString(x.Name)}
> +xc.val = C.uint32_t(x.Val)
> +
> + return nil
> + }
> +
> +// NewXsQuotaSet returns an instance of XsQuotaSet initialized with defaults.
> +func NewXsQuotaSet() (*XsQuotaSet, error) {
> +var (
> +x XsQuotaSet
> +xc C.libxl_xs_quota_set)
> +
> +C.libxl_xs_quota_set_init(&xc)
> +defer C.libxl_xs_quota_set_dispose(&xc)
> +
> +if err := x.fromC(&xc); err != nil {
> +return nil, err }
> +
> +return &x, nil}
> +
> +func (x *XsQuotaSet) fromC(xc *C.libxl_xs_quota_set) error {
> + x.Quota = nil
> +if n := int(xc.num_quota); n > 0 {
> +cQuota := (*[1<<28]C.libxl_xs_quota_item)(unsafe.Pointer(xc.quota))[:n:n]
> +x.Quota = make([]XsQuotaItem, n)
> +for i, v := range cQuota {
> +if err := x.Quota[i].fromC(&v); err != nil {
> +return fmt.Errorf("converting field Quota: %v", err) }
> +}
> +}
> +
> + return nil}
> +
> +func (x *XsQuotaSet) toC(xc *C.libxl_xs_quota_set) (err error){defer func(){
> +if err != nil{
> +C.libxl_xs_quota_set_dispose(xc)}
> +}()
> +
> +if numQuota := len(x.Quota); numQuota > 0 {
> +xc.quota =
> (*C.libxl_xs_quota_item)(C.malloc(C.ulong(numQuota)*C.sizeof_libxl_xs_quota_item))
> +xc.num_quota = C.int(numQuota)
> +cQuota :=
> (*[1<<28]C.libxl_xs_quota_item)(unsafe.Pointer(xc.quota))[:numQuota:numQuota]
> +for i,v := range x.Quota {
> +if err := v.toC(&cQuota[i]); err != nil {
> +return fmt.Errorf("converting field Quota: %v", err)
> +}
> +}
> +}
> +
> + return nil
> + }
> +
> // NewDomainBuildInfo returns an instance of DomainBuildInfo initialized
> with defaults.
> func NewDomainBuildInfo(dtype DomainType) (*DomainBuildInfo, error) {
> var (
> diff --git a/tools/golang/xenlight/types.gen.go
> b/tools/golang/xenlight/types.gen.go
> index ab9d4ca7b4..5393277190 100644
> --- a/tools/golang/xenlight/types.gen.go
> +++ b/tools/golang/xenlight/types.gen.go
> @@ -543,6 +543,15 @@ Altp2MModeExternal Altp2MMode = 2
> Altp2MModeLimited Altp2MMode = 3
> )
>
> +type XsQuotaItem struct {
> +Name string
> +Val uint32
> +}
> +
> +type XsQuotaSet struct {
> +Quota []XsQuotaItem
> +}
> +
> type DomainBuildInfo struct {
> MaxVcpus int
> AvailVcpus Bitmap
For the golang stuff:
Acked-by: Nick Rosbrook <enr0n@xxxxxxxxxx
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |