Outreachy Winter Internship
Hello Sir,I am Kavya Sharma, an aspiring Outreachy intern.It would be my privilege to be an intern with xenproject.org this winter.I have read about Xen Hypervisor Userspace Tools and I am interested in your project 'golang bindings for libxl'.
Sir,can you please guide me on this and also give some suggestions so that I can work on the bite-sized projects so that I can fulfil the requirements.
Looking forward to your reply.
Yours sincerely,
Kavya Sharma
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 8 lines · Kavya Sharma
Hello Sir,I am Kavya Sharma, an aspiring Outreachy intern.It would be my privilege to be an intern with xenproject.org this winter.I have read about Xen Hypervisor Userspace Tools and I am interested in your project 'golang bindings for libxl'.
Sir,can you please guide me on this and also give some suggestions so that I can work on the bite-sized projects so that I can fulfil the requirements.
Kavya,
Thanks for your interest in the Xen Project! We've actually found that one of the difficult parts of getting going with our project is making sure that you understand how to get your whole system and environment set up. And another thing we want to see is to what degree you can balance figuring things out, finding the answers on the web, and asking for help when you need it.
So with that in mind, we've started experimenting with tasks which don't contribute very much to the project directly, but provide a really solid base of knowledge to do further contributions.
So here's my challenge for you.
-------
OUTCOME
Attached is the very beginnings of a set of golang bindings that I wrote for a project of my own. They contain an implementation of Context.Open() and Context.DomainInfo().
Write a simple go program that will take as an argument a single domain id, and will output something that looks like the output of "xl info [domid]".
That is, if your program was called "dominfo", then the output of "dominfo 0" should look similar to the output of "xl info 0".
Please post a copy of your .go program, along with the results of output both for domain 0, and another running (non-domain-0) domain.
STEPS
1. Set up a system running Linux
If you don't have one, Ubuntu, Fedora, or Debian should all be fine.
2. Download, build, and install the latest development version of Xen. The following page should be useful:
https://wiki.xenproject.org/wiki/Compiling_Xen_From_Source
I would recommend using "make debball" or "make rpmball" over the "make install".
3. You'll need to build an image for at least one guest VM.
There are tons of options here, but one really simple thing would be to follow this HOWTO from a previous OPW intern:
https://umasharma17.wordpress.com/2015/02/13/creating-guests-using-xl-in-xen/
4. Write your go program
The go program will need to Open() the context, then call DomainInfo() on the target domain ID, and output the required info based on "xl list".
libxl.go uses cgo to compile a library againt C. In order for the cgo builder to get the right libraries, you'll at least need to set the CGO_LIBS environmetn variable to include both libyajl and libxl, like this:
export CGO_LIBS="-lyajl -lxenlight"
------
That's it! Remember that the goal of this is to see how well you balance figuring things out on your own vs asking questions. So try to figure things out on your own, but when you run into a bit of difficultly, don't hesitate to ask questions or clarification -- particularly at the beginning.
You can ask questions either here on xen-devel or on the #xendevel or #xen-opw channels on freenode IRC. My nickname is 'gwd'.
Good luck,
-George
package main
/*
#include <libxl.h>
*/
import "C"
import (
"unsafe" "fmt" "time"
)
type Context struct {
ctx *C.libxl_ctx
}
func NewContext() (Ctx *Context, err error) {
Ctx = &Context{}
err = Ctx.Open()
return
}func (Ctx *Context) IsOpen() bool {
return Ctx.ctx != nil
}func (Ctx *Context) Open() (err error) {
ret := C.libxl_ctx_alloc(unsafe.Pointer(&Ctx.ctx), C.LIBXL_VERSION, 0, nil)
if ret != 0 {
err = fmt.Errorf("Allocating libxl context: %d", ret)
}
return
}func (Ctx *Context) Close() (err error) {
ret := C.libxl_ctx_free(unsafe.Pointer(Ctx.ctx)) Ctx.ctx = nil
if ret != 0 {
err = fmt.Errorf("Freeing libxl context: %d", ret)
}
return
}
type Domid uint32
type MemKB uint64
// FIXME: Use the idl to generate types
type Dominfo struct {
// FIXME: uuid
Domid Domid
Running bool
Blocked bool
Paused bool
Shutdown bool
Dying bool
Never_stop bool
Shutdown_reason int32 // FIXME shutdown_reason enumeration
Outstanding_memkb MemKB
Current_memkb MemKB
Shared_memkb MemKB
Paged_memkb MemKB
Max_memkb MemKB
Cpu_time time.Duration
Vcpu_max_id uint32
Vcpu_online uint32
Cpupool uint32
Domain_type int32 //FIXME libxl_domain_type enumeration
}
func (Ctx *Context) DomainInfo(Id Domid) (di *Dominfo, err error) {
if Ctx.ctx == nil {
err = fmt.Errorf("Context not opened") return
}
var cdi C.libxl_dominfo
ret := C.libxl_domain_info(Ctx.ctx, unsafe.Pointer(&cdi), C.uint32_t(Id))
// FIXME: IsDomainNotPresentError
if ret != 0 {
err = fmt.Errorf("libxl_domain_info failed: %d", ret) return
}
// FIXME -- use introspection to make this more robust di = &Dominfo{}
di.Domid = Domid(cdi.domid)
di.Running = bool(cdi.running)
di.Blocked = bool(cdi.blocked)
di.Paused = bool(cdi.paused)
di.Shutdown = bool(cdi.shutdown)
di.Dying = bool(cdi.dying)
di.Never_stop = bool(cdi.never_stop) di.Shutdown_reason = int32(cdi.shutdown_reason) di.Outstanding_memkb = MemKB(cdi.outstanding_memkb) di.Current_memkb = MemKB(cdi.current_memkb) di.Shared_memkb = MemKB(cdi.shared_memkb) di.Paged_memkb = MemKB(cdi.paged_memkb) di.Max_memkb = MemKB(cdi.max_memkb) di.Cpu_time = time.Duration(cdi.cpu_time) di.Vcpu_max_id = uint32(cdi.vcpu_max_id) di.Vcpu_online = uint32(cdi.vcpu_online) di.Cpupool = uint32(cdi.cpupool) di.Domain_type = int32(cdi.domain_type) return
}
func (Ctx *Context) DomainUnpause(Id Domid) (err error) {
if Ctx.ctx == nil {
err = fmt.Errorf("Context not opened")
return
}
ret := C.libxl_domain_unpause(Ctx.ctx, C.uint32_t(Id))
if ret != 0 {
err = fmt.Errorf("libxl_domain_unpause failed: %d", ret)
}
return
}_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 11 lines · George Dunlap
Quoted 8 lines · Kavya Sharma
Hello Sir,I am Kavya Sharma, an aspiring Outreachy intern.It would be my privilege to be an intern with xenproject.org this winter.I have read about Xen Hypervisor Userspace Tools and I am interested in your project 'golang bindings for libxl'.
Sir,can you please guide me on this and also give some suggestions so that I can work on the bite-sized projects so that I can fulfil the requirements.
Kavya,
Hey Kavya,
Just wondering how you're getting on with this, and if you need any help.
If you haven't started, or have decided not to take the project on, no problem; I just wanted to make sure you weren't stuck.
Thanks,
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel