xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ronald Rojas <ronladred@gmail.com>
To: George Dunlap <george.dunlap@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>, George Dunlap <dunlapg@umich.edu>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH RFC 59/59] tools/xenlight: Create interface for xenlight info
Date: Tue, 3 Jan 2017 12:45:51 -0500	[thread overview]
Message-ID: <20170103174549.GA1936@fedora.fios-router.home> (raw)
In-Reply-To: <c7591bd0-7ade-6274-9b9f-61971baee0b8@citrix.com>

[-- Attachment #1: Type: text/plain, Size: 8159 bytes --]

On Thu, Dec 29, 2016 at 01:45:54PM +0000, George Dunlap wrote:
> Hey Ronald!  Looks like you're getting going pretty well here.
> 
> At a high level: I think I began by saying that this would probably all
> be a single patch.  But I think it would probably be easier to review
> the different decisions made at each point by filling out the file bit
> by bit, and explaining what's going on at each point.
> 
> I think also it would be helpful to have somewhere -- either in a
> comment or in a text file -- a description of the general approach to
> converting the libxl C style into xenlight golang style.  For instance,
> saying that for functions, we'll take the function name
> (libxl_cpupool_remove), remove the libxl_ prefix (since the packages are
> namespaced already) and convert it to CamelCase by capitalizing the first
> 
> I'll take a stab at breaking it down in an example order that makes some
> sense to me, and then you can see what you think.

I made some guidelines that I think would nicely adjust the naming convention
from C to Go. I'll add it as a file below.
> 
> Futher comments...
> 
> On 29/12/16 01:14, Ronald Rojas wrote:
> > diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go
> > new file mode 100644
> > index 0000000..b0eb6f8
> > --- /dev/null
> > +++ b/tools/golang/xenlight/xenlight.go
> > @@ -0,0 +1,1000 @@
> > +/*
> > + * Copyright (C) 2016 George W. Dunlap, Citrix Systems UK Ltd
> > + *
> > + * This program is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU General Public License as
> > + * published by the Free Software Foundation; version 2 of the
> > + * License only.
> > + *
> > + * This program is distributed in the hope that it will be useful, but
> > + * WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > + * General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU General Public License
> > + * along with this program; if not, write to the Free Software
> > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> > + * 02110-1301, USA.
> > + */
> > +package xenlight
> > +
> > +/*
> > +#cgo LDFLAGS: -lxenlight -lyajl
> > +#include <stdlib.h>
> > +#include <libxl.h>
> > +*/
> > +import "C"
> 
> I see you switched back to dynamic linking -- any particular reason?
> 
> We probably need to put a "// FIXME" here saying that we need to
> generate these compile-time dependencies using pkg-config.

We discussed this on IRC but I'll just restate here that I was not able 
to compile the program through static linking and it would be fine to 
just use dynamic linking for now.
Since we are doing dynamic linking do we still need to use pkg-config?
> 
> > +
> > +/*
> > + * Other flags that may be needed at some point:
> > + *  -lnl-route-3 -lnl-3
> > +#cgo LDFLAGS: -lxenlight -lyajl_s -lxengnttab -lxenstore -lxenguest -lxentoollog -lxenevtchn -lxenctrl -lblktapctl -lxenforeignmemory -lxencall -lz -luuid -lutil
> > + *
> > + * To get back to simple dynamic linking:
> > +*/
> 
> Comment needs updating (to "To use static linking").

Fixed.
> 
> > +
> > +import (
> > +	"fmt"
> > +	"time"
> > +	"unsafe"
> > +)
> > +
> > +/*
> > + * Errors
> > + */
> > +const (
> > +	ErrorNonspecific                  = int(C.ERROR_NONSPECIFIC)
> > +	ErrorVersion                      = int(C.ERROR_VERSION)
> > +	ErrorFail                         = int(C.ERROR_FAIL)
> > +	ErrorNi                           = int(C.ERROR_NI)
> > +	ErrorNomem                        = int(C.ERROR_NOMEM)
> > +	ErrorInval                        = int(C.ERROR_INVAL)
> > +	ErrorBadfail                      = int(C.ERROR_BADFAIL)
> > +	ErrorGuestTimedout                = int(C.ERROR_GUEST_TIMEDOUT)
> > +	ErrorTimedout                     = int(C.ERROR_TIMEDOUT)
> > +	ErrorNoparavirt                   = int(C.ERROR_NOPARAVIRT)
> > +	ErrorNotReady                     = int(C.ERROR_NOT_READY)
> > +	ErrorOseventRegFail               = int(C.ERROR_OSEVENT_REG_FAIL)
> > +	ErrorBufferfull                   = int(C.ERROR_BUFFERFULL)
> > +	ErrorUnknownChild                 = int(C.ERROR_UNKNOWN_CHILD)
> > +	ErrorLockFail                     = int(C.ERROR_LOCK_FAIL)
> > +	ErrorJsonConfigEmpty              = int(C.ERROR_JSON_CONFIG_EMPTY)
> > +	ErrorDeviceExists                 = int(C.ERROR_DEVICE_EXISTS)
> > +	ErrorCheckpointDevopsDoesNotMatch = int(C.ERROR_CHECKPOINT_DEVOPS_DOES_NOT_MATCH)
> > +	ErrorCheckpointDeviceNotSupported = int(C.ERROR_CHECKPOINT_DEVICE_NOT_SUPPORTED)
> > +	ErrorVnumaConfigInvalid           = int(C.ERROR_VNUMA_CONFIG_INVALID)
> > +	ErrorDomainNotfound               = int(C.ERROR_DOMAIN_NOTFOUND)
> > +	ErrorAborted                      = int(C.ERROR_ABORTED)
> > +	ErrorNotfound                     = int(C.ERROR_NOTFOUND)
> > +	ErrorDomainDestroyed              = int(C.ERROR_DOMAIN_DESTROYED)
> > +	ErrorFeatureRemoved               = int(C.ERROR_FEATURE_REMOVED)
> > +)
> 
> The problem with this at the moment is that we don't actually return any
> of these errors -- instead we return a newly-generated error which
> contains text.
> 
> This pair of blog posts describes some approaches taken by different
> kinds of libraries to returning errors, and why:
> 
> https://www.goinggo.net/2014/10/error-handling-in-go-part-i.html
> https://www.goinggo.net/2014/11/error-handling-in-go-part-ii.html
> 
> Another approach is taken by the go syscall package:
> 
> https://golang.org/pkg/syscall/#Errno
> 
> (See also https://golang.org/src/syscall/syscall_unix.go, lines 93-100,
> and https://golang.org/src/syscall/zerrors_linux_amd64.go, at lines 1204
> and 1381.)
> 
> The approach taken by libraries in the second blog allows you to pass
> back a lot more information about what happened; but I think at the
> moment, given the limited number of things that libxl returns, that's
> probably overkill.
> 
> Which leaves us either taking the approach of something like bufio, and
> making things like this:
> 
> const (
>    ErrorNonspecific = errors.New("xenlight: Non-specific error")
>    ...
> )
> 
> Or taking the approach of the syscall package, and defining a type:
> 
> type xlerror int
> 
> func (e xlerror) Error() {
> 
> }
> 
> And making a (private) errors[] array, and re-impleminting Error() from
> the syscall package.
> 
> I think I would probably go with the syscall library's approach, since
> (like it) we are handed a set of pre-existing error numbers.
> 
> What do you think?

I was actually thinking that taking the approach similiar to bufio would
be better. It would not be difficult to create individual errors for each
error number and creating variables for each error would allow users to 
easily compare the error that's returned against specific errors. 

I've also been thinking about how to do the testing and I think it would
be good to seperate testing into two parts, testing functions that get
infomation about the system and functions that change the state of the 
system. 

I haven't been able to figure out how to use osstest to use the
Golang libxl but I think it would still be fine to do unit testing by
writing C and Go code that get information from a specific fuction(like
physinfo) and seeing if they produce the same output.

For functions that change the state of the system (like create/destroy
guests) I think your idea of using a chaos monkey would be good. Maybe
the general procedure would be something like this:
1. Get the complete system information through the functions tested
in the first part.
2. Pick a random operation from a set implemented functions. 
3. Make changes to the copy of the systems information that we have
4. Get the system information again through the golang functions and
see if this copy of the system information matches the copy we already
have.
5. Repeat as necessary

It will probably take some time to finalize the procedure so I will
plan to submit it as a seperate patch or with a later patch.
> 
> OK, there's more to look at but I think that's enough for now.
> 
>  -George
> 

thanks,
Ronald

[-- Attachment #2: rules --]
[-- Type: text/plain, Size: 843 bytes --]

Rules for changing the naming convention from C to Golang

Builtins:
Remove underscores from C style name and use camelCase. 
If the type is a primitive data type(such a boolean or int) 
the equivilant Golang type is used. Otherwise delare the
type as the C type. 
Example:
	type Scheduler int
	type Uuid C.lixl_uuid


IDL types:
Remove underscores from C style name, remove libxl prefix,
 and use camelCase. Data fields will follow the same format 
by removing underscores and using camelCase.
Example:
	type CpupoolInfo struct {
		Poolid      uint32
		PoolName    string
		Scheduler   Scheduler
		DomainCount int
		Cpumap      Bitmap
	}
	


Functions:
Removed the libxl prefix from the function name. Instead of 
underscores camelCase is used to seperate words. 
Example:
	func (Ctx *Context) CpupoolInfo(Poolid uint32) (pool CpupoolInfo){}

[-- Attachment #3: Type: text/plain, Size: 127 bytes --]

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

  parent reply	other threads:[~2017-01-03 17:45 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-29  1:13 [PATCH RFC 01/59] Initial controller framework Ronald Rojas
2016-12-29  1:13 ` [PATCH RFC 02/59] controller: Revamp communication structure Ronald Rojas
2016-12-29  1:13 ` [PATCH RFC 03/59] controller: Initial attempt to generalize process / vm creation Ronald Rojas
2016-12-29  1:13 ` [PATCH RFC 04/59] Controller: Move process worker into its own file Ronald Rojas
2016-12-29  1:13 ` [PATCH RFC 05/59] controller: Add WorkerParams argument to Init in Worker interface Ronald Rojas
2016-12-29  1:13 ` [PATCH RFC 06/59] Reorganize to enable "Dist" directory Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 07/59] controller: Introduce basic Xen functionality Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 08/59] controller: Exit after second SIGINT Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 09/59] controller: Refactor creation and stopping of workers into WorkerList methods Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 10/59] controller: First cut at BenchmarkParams Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 11/59] Refactor to move towards benchmark "plans" and data analysis Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 12/59] Basic 'report' functionality Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 13/59] Add GPL headers / COPYING file (v2 only) Ronald Rojas
2016-12-29 10:51   ` Wei Liu
2016-12-29  1:14 ` [PATCH RFC 14/59] benchmark: Store data in terms of worker sets and worker ids Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 15/59] controller: Move "running" code to a separate file Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 16/59] controller: Rename an element in BenchmarkRun to be more accurate Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 17/59] controller: Collect and display statistics on WorkerSets Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 18/59] controller: Add cpupool global config Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 19/59] Add basic libxl framework, get domain cpu_time Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 20/59] xenworker: Use libxl_domain_unpause rather than forking xl Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 21/59] Report utilization statistics Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 22/59] Use tsc for time rather than rumpkernel clock_gettime() Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 23/59] run: Don't collect results reported after command to stop guests is issued Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 24/59] report: Lots of changes Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 25/59] main: Change default workload to something a bit more extreme Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 26/59] Use kops rather than mops Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 27/59] report: Allow report verbosity to be specified Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 28/59] controller: Handle worker early death Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 29/59] report: Add basic html report Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 30/59] htmlreport: Include utilization scatterplots Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 31/59] Make a binary that can run reports on a system without libxl Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 32/59] controller: Allow specification of an input file Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 33/59] controller: Add verbosity argument and update README with new instructions Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 34/59] controller: Make a useful config file Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 35/59] libxl: Add ListCpupool Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 36/59] controller: Make 'dummy' at the level of 'run' rather than xenworker Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 37/59] libxl.go: Provide a single global context by default Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 38/59] controller: Allow multiple schedulers in the same benchmark file Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 39/59] libxl.go: Put common link flags in libxl.go Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 40/59] controller: Add / update GPL text Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 41/59] libxl.go: Link statically rather than dynamically Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 42/59] plan: Allow "templating" from other runs Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 43/59] libxl: Add bitmap support Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 44/59] libxl: Implement CpupoolCreate Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 45/59] libxl: Implement Destroy, Add/Remove operations Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 46/59] libxl: Reorganize bitmapGotoC Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 47/59] libxl: Reorganize code Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 48/59] libxl: Add Ctx.CheckOpen Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 49/59] libxl: Implement libxl_cpupool_info and Scheduler.FromString() Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 50/59] libxl: Fix Bitmap.Max(), make Test() / Clear() more robust Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 51/59] controller: Make and/or modify cpupools when possible Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 52/59] libxl: Implement Bitmap.String() Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 53/59] controller: Add WorkerConfig.SoftAffinity Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 54/59] controller/run: Add RunConfig.NumaDisable Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 55/59] plan: Make the matrix generation more programmatic Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 56/59] controller/plan: Add NumaDisable to SimpleMatrix Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 57/59] tools/blktap2: remove unused inclusion of sys/sysctl.l Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 58/59] remove irrelevant files from old repository Ronald Rojas
2016-12-29  1:14 ` [PATCH RFC 59/59] tools/xenlight: Create interface for xenlight info Ronald Rojas
2016-12-29 10:34   ` George Dunlap
2016-12-29 10:52     ` Wei Liu
2016-12-29 13:49       ` Ronald Rojas
2016-12-29 13:45   ` George Dunlap
2016-12-29 20:20     ` George Dunlap
2017-01-03 17:45     ` Ronald Rojas [this message]
2017-01-04 16:44       ` George Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170103174549.GA1936@fedora.fios-router.home \
    --to=ronladred@gmail.com \
    --cc=dunlapg@umich.edu \
    --cc=george.dunlap@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).