[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH RFC 4/8] golang/xenlight: Implement libxl_domain_info and libxl_domain_unpause



On 23/01/17 16:43, Ronald Rojas wrote:
> Add calls for the following host-related functionality:
> - libxl_domain_info
> - libxl_domain_unpause
> 
> Include Golang version for the libxl_domain_info as
> DomainInfo.
> 
> Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxx>
> Signed-off-by: Ronald Rojas <ronladred@xxxxxxxxx>
> ---
>  tools/golang/xenlight/xenlight.go | 92 
> +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 92 insertions(+)
> 
> diff --git a/tools/golang/xenlight/xenlight.go 
> b/tools/golang/xenlight/xenlight.go
> index 92410a8..dd6893c 100644
> --- a/tools/golang/xenlight/xenlight.go
> +++ b/tools/golang/xenlight/xenlight.go
> @@ -36,6 +36,7 @@ import "C"
>  import (
>       "fmt"
>       "unsafe"
> +     "time"
>  )
>  
>  /*
> @@ -104,6 +105,12 @@ var errors = [...]string{
>   * Types: Builtins
>   */
>  
> +type Domid uint32
> +
> +type MemKB uint64
> +
> +type Uuid C.libxl_uuid
> +
>  type Context struct {
>       ctx *C.libxl_ctx
>  }
> @@ -165,6 +172,32 @@ type VersionInfo struct {
>       BuildId          string
>  }
>  
> +type Dominfo struct {
> +     Uuid       Uuid
> +     Domid      Domid
> +     Ssidref uint32
> +     SsidLabel string
> +     Running    bool
> +     Blocked    bool
> +     Paused     bool
> +     Shutdown   bool
> +     Dying      bool
> +     NeverStop bool

Run 'go fmt' to align these.

> +
> +     ShutdownReason   int32 // FIXME shutdown_reason enumeration
> +     OutstandingMemkb MemKB
> +     CurrentMemkb     MemKB
> +     SharedMemkb      MemKB
> +     PagedMemkb       MemKB
> +     MaxMemkb         MemKB
> +     CpuTime          time.Duration
> +     VcpuMaxId       uint32
> +     VcpuOnline       uint32
> +     Cpupool           uint32
> +     DomainType       int32 //FIXME libxl_domain_type enumeration

We need to have these enumerations actually created as consts, like we
do with the errors.

We should also make a type for these enums, and a String method that
calls the libxl_<type>_to_string() function to convert it to a string.

> +
> +}
> +
>  /*
>   * Context
>   */
> @@ -343,3 +376,62 @@ func (Ctx *Context) GetVersionInfo() (info *VersionInfo, 
> err error) {
>  
>       return
>  }
> +
> +func (Ctx *Context) DomainInfo(Id Domid) (di *Dominfo, err error) {
> +     err = Ctx.CheckOpen()
> +     if err != nil {
> +             return
> +     }
> +
> +     var cdi C.libxl_dominfo
> +
> +     ret := C.libxl_domain_info(Ctx.ctx, unsafe.Pointer(&cdi), 
> C.uint32_t(Id))
> +
> +     if ret != 0 {
> +             err = Error(-ret)
> +             return
> +     }
> +
> +     // We could consider having this boilerplate generated by the
> +     // idl, in a function like this:
> +     //
> +     // di = translateCdomaininfoToGoDomaininfo(cdi)

Stale comment; you could remove this, or make it cdi.toGo().

> +     di = &Dominfo{}
> +     di.Uuid = Uuid(cdi.uuid)
> +     di.Domid = Domid(cdi.domid)
> +     di.Ssidref = uint32(cdi.ssidref)
> +     di.SsidLabel = C.GoString(cdi.ssid_label)

And here we'll probably leak memory if we don't call
libxl_dominfo_dispose() before returning.

Everything else looks good, thanks!

 -George


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.