Skip to content

Commit

Permalink
qemu/qmp: add addr and bus to hotplug vsock devices
Browse files Browse the repository at this point in the history
For machines types based on PCIe like q35, device addr and bus must be specified.
For machines types based on PCI like pc, device addr must be specified and bus
is optional since devices can be hot plugged directly on the root bus.

Signed-off-by: Julio Montes <julio.montes@intel.com>
  • Loading branch information
Julio Montes committed Aug 8, 2018
1 parent 8d626af commit 6851999
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion qemu/qmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -938,12 +938,17 @@ func (q *QMP) ExecHotplugMemory(ctx context.Context, qomtype, id, mempath string
}

// ExecutePCIVSockAdd adds a vhost-vsock-pci bus
func (q *QMP) ExecutePCIVSockAdd(ctx context.Context, id, guestCID, vhostfd string, disableModern bool) error {
func (q *QMP) ExecutePCIVSockAdd(ctx context.Context, id, guestCID, vhostfd, addr, bus string, disableModern bool) error {
args := map[string]interface{}{
"driver": VHostVSockPCI,
"id": id,
"guest-cid": guestCID,
"vhostfd": vhostfd,
"addr": addr,
}

if bus != "" {
args["bus"] = bus
}

if disableModern {
Expand Down
2 changes: 1 addition & 1 deletion qemu/qmp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ func TestExecutePCIVSockAdd(t *testing.T) {
cfg := QMPConfig{Logger: qmpTestLogger{}}
q := startQMPLoop(buf, cfg, connectedCh, disconnectedCh)
checkVersion(t, connectedCh)
err := q.ExecutePCIVSockAdd(context.Background(), "vsock-pci0", "3", "1", true)
err := q.ExecutePCIVSockAdd(context.Background(), "vsock-pci0", "3", "1", "1", "1", true)
if err != nil {
t.Fatalf("Unexpected error %v", err)
}
Expand Down

0 comments on commit 6851999

Please sign in to comment.