|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH RFC 7/8] golang/xenlight: Implement libxl_scheduler enumeration
On 23/01/17 16:43, Ronald Rojas wrote:
> Include both constants and a Stringification for libxl_scheduler.
>
> Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxx>
> Signed-off-by: Ronald Rojas <ronladred@xxxxxxxxx>
> ---
> tools/golang/xenlight/xenlight.go | 62
> +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 62 insertions(+)
>
> diff --git a/tools/golang/xenlight/xenlight.go
> b/tools/golang/xenlight/xenlight.go
> index 54692fd..0990f07 100644
> --- a/tools/golang/xenlight/xenlight.go
> +++ b/tools/golang/xenlight/xenlight.go
> @@ -211,6 +211,68 @@ type Dominfo struct {
>
> }
>
> +// # Consistent with values defined in domctl.h
> +// # Except unknown which we have made up
> +// libxl_scheduler = Enumeration("scheduler", [
> +// (0, "unknown"),
> +// (4, "sedf"),
> +// (5, "credit"),
> +// (6, "credit2"),
> +// (7, "arinc653"),
> +// (8, "rtds"),
> +// ])
> +type Scheduler int
> +
> +var (
> + SchedulerUnknown Scheduler = C.LIBXL_SCHEDULER_UNKNOWN
> + SchedulerSedf Scheduler = C.LIBXL_SCHEDULER_SEDF
> + SchedulerCredit Scheduler = C.LIBXL_SCHEDULER_CREDIT
> + SchedulerCredit2 Scheduler = C.LIBXL_SCHEDULER_CREDIT2
> + SchedulerArinc653 Scheduler = C.LIBXL_SCHEDULER_ARINC653
> + SchedulerRTDS Scheduler = C.LIBXL_SCHEDULER_RTDS
> +)
> +
> +// const char *libxl_scheduler_to_string(libxl_scheduler p);
> +func (s Scheduler) String() string {
> + cs := C.libxl_scheduler_to_string(C.libxl_scheduler(s))
> + // No need to free const return value
> +
> + return C.GoString(cs)
> +}
> +
> +// int libxl_scheduler_from_string(const char *s, libxl_scheduler *e);
> +func (s *Scheduler) FromString(gstr string) (err error) {
> + cstr := C.CString(gstr)
> + defer C.free(unsafe.Pointer(cstr))
> +
> + var cs C.libxl_scheduler
> + ret := C.libxl_scheduler_from_string(cstr, &cs)
> + if ret != 0 {
> + err = Error(-ret)
> + return
> + }
> +
> + *s = Scheduler(cs)
> + return
> +}
> +
> +func SchedulerFromString(name string) (s Scheduler, err error) {
> + cname := C.CString(name)
> + defer C.free(unsafe.Pointer(cname))
> +
> + var cs C.libxl_scheduler
> +
> + ret := C.libxl_scheduler_from_string(cname, &cs)
> + if ret != 0 {
> + err = Error(-ret)
> + return
> + }
> +
> + s = Scheduler(cs)
> +
> + return
> +}
I don't think we need both of these functions. In my code I just used
the method one (FromString). What do you think?
BTW this file is an obvious template for the enumerations you need for
DomInfo. :-)
-George
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |