Skip to content

Commit

Permalink
work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud Tournier committed Feb 14, 2020
1 parent 0ca8909 commit 1b34d3b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
8 changes: 4 additions & 4 deletions samples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ call-rust:
@echo
@echo Calling multiply function implemented in Rust without wasi, result of the multiplication is found in the result field
../my-own-cluster call rust-multiply -start_function rustMultiply 4 3 | jq
curl -k $(SERVER_PUBLIC_URL)/watchdog
curl -k $(SERVER_PUBLIC_URL)/watchdog/
#my-own-cluster call watchdog-backend -start_function getStatus | jq -r '.output' | base64 -d | jq
curl -s -k $(SERVER_PUBLIC_URL)/watchdog/status
#curl -s -k -X POST $(SERVER_PUBLIC_URL)/watchdog/status -H "content-type: application/json" -d '{"name":"backup-daemon","message":"all data backuped"}'
#curl -s -k -X POST $(SERVER_PUBLIC_URL)/watchdog/status -H "content-type: application/json" -d '{"name":"home-light-1","message":"everything ok"}'
curl -s -k $(SERVER_PUBLIC_URL)/watchdog/status | jq
curl -s -k -X POST $(SERVER_PUBLIC_URL)/watchdog/status -H "content-type: application/json" -d '{"name":"backup-daemon","message":"all data backuped"}'
curl -s -k -X POST $(SERVER_PUBLIC_URL)/watchdog/status -H "content-type: application/json" -d '{"name":"home-light-1","message":"everything ok"}'

call-interop:
@echo Calling 'interop' DIRECT mode, result is processed in the C code that calls Rust code
Expand Down
1 change: 1 addition & 0 deletions src/golang.org/x/sys
Submodule sys added at 12a6c2
13 changes: 7 additions & 6 deletions src/my-own-cluster/kvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,29 @@ func CreateVM() (int, error) {
//Note that with those, no need to pass an unsafe pointer. (see https://github.com/golang/sys/blob/master/unix/ioctl.go)

//Check version
version, err := C.ioctl(devkvm, C.KVM_GET_API_VERSION, 0)
if err != nil || version != 12 {
version, err := unix.IoctlGetInt(devkvm, C.KVM_GET_API_VERSION)
if err != nil {
return -1, err
}

fmt.Printf("KVM version: %d\n", version)

//Create vm
vmFd, err := C.ioctl(devkvm, C.KVM_CREATE_VCPU, 0)
vmFd, err := unix.IoctlGetInt(devkvm, C.KVM_CREATE_VCPU)
if err != nil {
return -1, err
}
defer unix.Close(vmFd)

//Return it all
return vmFd, nil
}

//CreateNewCell makes a new vCPU and memory band in a VM and packs it all tightly
func CreateNewCell(vmFd int) (*Cell, error) {
return nil, nil
}

func main() {

func TestKVM() {
vm, err := CreateVM()
fmt.Println(vm)
fmt.Println(err)
Expand Down
4 changes: 4 additions & 0 deletions src/my-own-cluster/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ func main() {
CliPlugFunction(verbs)
break

case "kvm_test":
TestKVM()
break

default:
fmt.Printf("No argument received !\n")
printHelp()
Expand Down
10 changes: 4 additions & 6 deletions src/my-own-cluster/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,14 +454,14 @@ func initControlRouting(server *WebServer) {
}

func initRouting(server *WebServer) {
fmt.Println("files:")
for path, techID := range server.orchestrator.GetUploadedFiles() {
server.router.GET(path, server.makeHandler(handlerGetGeneric))
fmt.Printf(" %s => %s\n", path, techID)
}

fmt.Println("functions:")
for spec, pluggedFunction := range server.orchestrator.GetPluggedFunctions() {
if strings.HasPrefix(spec, "get/") {
} else if strings.HasPrefix(spec, "post/") {
}
fmt.Printf(" %s => %s::%s\n", spec, pluggedFunction.Name, pluggedFunction.StartFunction)
}

// replies to non-api requests
Expand Down Expand Up @@ -498,8 +498,6 @@ func StartWebServer(port int, controlPort int, workingDir string, orchestrator *
}

initControlRouting(server)

// for each plugged function and uploaded file, add a handler
initRouting(server)

endSignal := make(chan bool, 1)
Expand Down
1 change: 1 addition & 0 deletions update-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ go get -u github.com/jteeuwen/go-bindata/...
go get github.com/julienschmidt/httprouter
go get github.com/syndtr/goleveldb/leveldb
go get github.com/ltearno/go-wasm3
go get golang.org/x/sys/unix

exit 0

0 comments on commit 1b34d3b

Please sign in to comment.