Merge pull request #22 from devimc/topic/vsockHotplug

qemu/qmp: implement function to hotplug vsock-pci
This commit is contained in:
Mark Ryan
2018-07-17 09:07:44 +01:00
committed by GitHub
3 changed files with 30 additions and 0 deletions

View File

@@ -82,6 +82,9 @@ const (
// VirtioSerialPort is the serial port device driver.
VirtioSerialPort = "virtserialport"
// VHostVSockPCI is the vhost vsock pci driver.
VHostVSockPCI = "vhost-vsock-pci"
)
// ObjectType is a string representing a qemu object type.

View File

@@ -881,3 +881,13 @@ func (q *QMP) ExecHotplugMemory(ctx context.Context, qomtype, id, mempath string
return err
}
// ExecutePCIVSockAdd adds a vhost-vsock-pci bus
func (q *QMP) ExecutePCIVSockAdd(ctx context.Context, id, guestCID string) error {
args := map[string]interface{}{
"driver": VHostVSockPCI,
"id": id,
"guest-cid": guestCID,
}
return q.executeCommand(ctx, "device_add", args, nil)
}

View File

@@ -945,3 +945,20 @@ func TestExecHotplugMemory(t *testing.T) {
q.Shutdown()
<-disconnectedCh
}
// Checks vsock-pci hotplug
func TestExecutePCIVSockAdd(t *testing.T) {
connectedCh := make(chan *QMPVersion)
disconnectedCh := make(chan struct{})
buf := newQMPTestCommandBuffer(t)
buf.AddCommand("device_add", nil, "return", nil)
cfg := QMPConfig{Logger: qmpTestLogger{}}
q := startQMPLoop(buf, cfg, connectedCh, disconnectedCh)
checkVersion(t, connectedCh)
err := q.ExecutePCIVSockAdd(context.Background(), "vsock-pci0", "3")
if err != nil {
t.Fatalf("Unexpected error %v", err)
}
q.Shutdown()
<-disconnectedCh
}