Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Hypervisor: UUID fix for acrn hypevisor
Browse files Browse the repository at this point in the history
This patch adds support for getting the kata UUID from
acrn hypervisor and using these UUID to create a VM.

Fixes: #1785
Signed-off-by: Vijay Dhanraj <[email protected]>
  • Loading branch information
vijaydhanraj committed Sep 24, 2019
1 parent d3f480d commit aa6a16c
Show file tree
Hide file tree
Showing 7 changed files with 305 additions and 106 deletions.
33 changes: 22 additions & 11 deletions cli/kata-check_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
package main

import (
"context"
"fmt"
"io/ioutil"
"strings"
"syscall"
"unsafe"

vc "github.com/kata-containers/runtime/virtcontainers"
"github.com/kata-containers/runtime/virtcontainers/store"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -231,27 +233,36 @@ func acrnIsUsable() error {
return err
}
defer syscall.Close(f)
kataLog.WithField("device", acrnDevice).Info("device available")

fieldLogger := kataLog.WithField("check-type", "full")
acrnInst := vc.Acrn{}
vcStore, err := store.NewVCSandboxStore(context.Background(), "kata-check")
if err != nil {
return err
}

fieldLogger.WithField("device", acrnDevice).Info("device available")
uuidStr, err := acrnInst.GetNextAvailableUUID(vcStore)
if err != nil {
return err
}

createVM := acrn_create_vm{
uuid: [16]uint8{
0xd2, 0x79, 0x54, 0x38, 0x25, 0xd6, 0x11, 0xe8,
0x86, 0x4e, 0xcb, 0x7a, 0x18, 0xb3, 0x46, 0x43,
},
uuid, err := acrnInst.GetACRNUUIDBytes(uuidStr)
if err != nil {
return fmt.Errorf("Converting UUID str to bytes failed, Err:%s", err)
}

var createVM acrn_create_vm
createVM.uuid = uuid

ret, _, errno := syscall.Syscall(syscall.SYS_IOCTL,
uintptr(f),
uintptr(ioctl_ACRN_CREATE_VM),
uintptr(unsafe.Pointer(&createVM)))
if ret != 0 || errno != 0 {
if errno == syscall.EBUSY {
fieldLogger.WithField("reason", "another hypervisor running").Error("cannot create VM")
kataLog.WithField("reason", "another hypervisor running").Error("cannot create VM")
}
fieldLogger.WithFields(logrus.Fields{
kataLog.WithFields(logrus.Fields{
"ret": ret,
"errno": errno,
}).Info("Create VM Error")
Expand All @@ -263,14 +274,14 @@ func acrnIsUsable() error {
uintptr(ioctl_ACRN_DESTROY_VM),
0)
if ret != 0 || errno != 0 {
fieldLogger.WithFields(logrus.Fields{
kataLog.WithFields(logrus.Fields{
"ret": ret,
"errno": errno,
}).Info("Destroy VM Error")
return errno
}

fieldLogger.WithField("feature", "create-vm").Info("feature available")
kataLog.WithField("feature", "create-vm").Info("feature available")

return nil
}
Expand Down
Loading

0 comments on commit aa6a16c

Please sign in to comment.