Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions hypervisor/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ type VolumeUnmounted struct {
}

type BlockdevInsertedEvent struct {
Name string
SourceType string //image or volume
DeviceName string
ScsiId int
ScsiAddr string // pass scsi addr to hyperstart
}

Expand Down
10 changes: 2 additions & 8 deletions hypervisor/libvirt/libvirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -907,9 +907,6 @@ func scsiId2Addr(id int) (int, int, error) {
}

func (lc *LibvirtContext) AddDisk(ctx *hypervisor.VmContext, sourceType string, blockInfo *hypervisor.DiskDescriptor, result chan<- hypervisor.VmEvent) {
name := blockInfo.Name
id := blockInfo.ScsiId

if lc.domain == nil {
glog.Error("Cannot find domain")
result <- &hypervisor.DeviceFailed{
Expand Down Expand Up @@ -945,12 +942,9 @@ func (lc *LibvirtContext) AddDisk(ctx *hypervisor.VmContext, sourceType string,
}
return
}
target, unit, err := scsiId2Addr(id)
target, unit, err := scsiId2Addr(blockInfo.ScsiId)
result <- &hypervisor.BlockdevInsertedEvent{
Name: name,
SourceType: sourceType,
DeviceName: scsiId2Name(id),
ScsiId: id,
DeviceName: scsiId2Name(blockInfo.ScsiId),
ScsiAddr: fmt.Sprintf("%d:%d", target, unit),
}
}
Expand Down
3 changes: 1 addition & 2 deletions hypervisor/qemu/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ func (qc *QemuContext) Pause(ctx *hypervisor.VmContext, pause bool) error {
}

func (qc *QemuContext) AddDisk(ctx *hypervisor.VmContext, sourceType string, blockInfo *hypervisor.DiskDescriptor, result chan<- hypervisor.VmEvent) {
name := blockInfo.Name
filename := blockInfo.Filename
format := blockInfo.Format
id := blockInfo.ScsiId
Expand All @@ -247,7 +246,7 @@ func (qc *QemuContext) AddDisk(ctx *hypervisor.VmContext, sourceType string, blo
}
}

newDiskAddSession(ctx, qc, name, sourceType, filename, format, id, result)
newDiskAddSession(ctx, qc, filename, format, id, result)
}

func (qc *QemuContext) RemoveDisk(ctx *hypervisor.VmContext, blockInfo *hypervisor.DiskDescriptor, callback hypervisor.VmEvent, result chan<- hypervisor.VmEvent) {
Expand Down
7 changes: 4 additions & 3 deletions hypervisor/qemu/qmp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package qemu

import (
"encoding/json"
"github.com/hyperhq/runv/hypervisor"
"net"
"testing"
"time"

"github.com/hyperhq/runv/hypervisor"
)

func TestMessageParse(t *testing.T) {
Expand Down Expand Up @@ -261,7 +262,7 @@ func TestQmpDiskSession(t *testing.T) {
}

info := msg.(*hypervisor.BlockdevInsertedEvent)
t.Log("got block device", info.Name, info.SourceType, info.DeviceName)
t.Log("got block device", info.DeviceName)
}

func TestQmpFailOnce(t *testing.T) {
Expand Down Expand Up @@ -306,7 +307,7 @@ func TestQmpFailOnce(t *testing.T) {
}

info := msg.(*hypervisor.BlockdevInsertedEvent)
t.Log("got block device", info.Name, info.SourceType, info.DeviceName)
t.Log("got block device", info.DeviceName)
}

func TestQmpKeepFail(t *testing.T) {
Expand Down
5 changes: 1 addition & 4 deletions hypervisor/qemu/qmp_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func defaultRespond(result chan<- hypervisor.VmEvent, callback hypervisor.VmEven
}
}

func newDiskAddSession(ctx *hypervisor.VmContext, qc *QemuContext, name, sourceType, filename, format string, id int, result chan<- hypervisor.VmEvent) {
func newDiskAddSession(ctx *hypervisor.VmContext, qc *QemuContext, filename, format string, id int, result chan<- hypervisor.VmEvent) {
commands := make([]*QmpCommand, 2)
commands[0] = &QmpCommand{
Execute: "human-monitor-command",
Expand All @@ -53,10 +53,7 @@ func newDiskAddSession(ctx *hypervisor.VmContext, qc *QemuContext, name, sourceT
qc.qmp <- &QmpSession{
commands: commands,
respond: defaultRespond(result, &hypervisor.BlockdevInsertedEvent{
Name: name,
SourceType: sourceType,
DeviceName: devName,
ScsiId: id,
}),
}
}
Expand Down
6 changes: 0 additions & 6 deletions hypervisor/vbox/vbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,7 @@ func (vc *VBoxContext) AddDisk(ctx *hypervisor.VmContext, sourceType string, blo
}
devName := scsiId2Name(id)
callback := &hypervisor.BlockdevInsertedEvent{
Name: name,
SourceType: sourceType,
DeviceName: devName,
ScsiId: id,
}

glog.V(1).Infof("Disk %s (%s) add succeeded", name, filename)
Expand Down Expand Up @@ -461,10 +458,7 @@ func (vc *VBoxContext) LazyAddDisk(ctx *hypervisor.VmContext, name, sourceType,
}
devName := scsiId2Name(id)
callback := &hypervisor.BlockdevInsertedEvent{
Name: name,
SourceType: sourceType,
DeviceName: devName,
ScsiId: id,
}
vc.mediums = append(vc.mediums, medium)
vc.callbacks = append(vc.callbacks, callback)
Expand Down
8 changes: 2 additions & 6 deletions hypervisor/xen/xen.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,11 @@ func (xc *XenContext) Stats(ctx *hypervisor.VmContext) (*types.PodStats, error)
func (xc *XenContext) Close() {}

func (xc *XenContext) AddDisk(ctx *hypervisor.VmContext, sourceType string, blockInfo *hypervisor.DiskDescriptor, result chan<- hypervisor.VmEvent) {
name := blockInfo.Name
filename := blockInfo.Filename
format := blockInfo.Format
id := blockInfo.ScsiId

go diskRoutine(true, xc, ctx, name, sourceType, filename, format, id, nil, result)
go diskRoutine(true, xc, ctx, sourceType, filename, format, id, nil, result)
}

func (xc *XenContext) RemoveDisk(ctx *hypervisor.VmContext, blockInfo *hypervisor.DiskDescriptor, callback hypervisor.VmEvent, result chan<- hypervisor.VmEvent) {
Expand Down Expand Up @@ -305,7 +304,7 @@ func (xd *XenDriver) SupportVmSocket() bool {
}

func diskRoutine(add bool, xc *XenContext, ctx *hypervisor.VmContext,
name, sourceType, filename, format string, id int, callback hypervisor.VmEvent, result chan<- hypervisor.VmEvent) {
sourceType, filename, format string, id int, callback hypervisor.VmEvent, result chan<- hypervisor.VmEvent) {
backend := LIBXL_DISK_BACKEND_TAP
if strings.HasPrefix(filename, "/dev/") {
backend = LIBXL_DISK_BACKEND_PHY
Expand All @@ -321,10 +320,7 @@ func diskRoutine(add bool, xc *XenContext, ctx *hypervisor.VmContext,
if add {
res = HyperxlDiskAdd(xc.driver.Ctx, uint32(xc.domId), filename, devName, LibxlDiskBackend(backend), LibxlDiskFormat(dfmt))
callback = &hypervisor.BlockdevInsertedEvent{
Name: name,
SourceType: sourceType,
DeviceName: devName,
ScsiId: id,
}
} else {
op = "remove"
Expand Down