Skip to content

Commit

Permalink
qemu: add vhostfd and disable-modern to vsock hotplug
Browse files Browse the repository at this point in the history
`vhostfd` is used to specify the vhost-vsock device fd, and it holds
the context ID previously opened.

`disable-modern` is to disable the use of "modern" devices, by using virtio 0.9
instead of virtio 1.0. Particularly, this is useful when running the VM in a
nested environment.

Signed-off-by: Julio Montes <julio.montes@intel.com>
  • Loading branch information
Julio Montes committed Aug 2, 2018
1 parent f700a97 commit 84b212f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion qemu/qmp.go
Expand Up @@ -883,11 +883,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 string) error {
func (q *QMP) ExecutePCIVSockAdd(ctx context.Context, id, guestCID, vhostfd string, disableModern bool) error {
args := map[string]interface{}{
"driver": VHostVSockPCI,
"id": id,
"guest-cid": guestCID,
"vhostfd": vhostfd,
}

if disableModern {
args["disable-modern"] = disableModern
}

return q.executeCommand(ctx, "device_add", args, nil)
}
2 changes: 1 addition & 1 deletion qemu/qmp_test.go
Expand Up @@ -955,7 +955,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")
err := q.ExecutePCIVSockAdd(context.Background(), "vsock-pci0", "3", "1", true)
if err != nil {
t.Fatalf("Unexpected error %v", err)
}
Expand Down

0 comments on commit 84b212f

Please sign in to comment.