qemu: add vhostfd and disable-modern to vsock hotplug

`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>
This commit is contained in:
Julio Montes 2018-07-20 15:58:31 -05:00
parent f700a97bee
commit 84b212f1b8
2 changed files with 8 additions and 2 deletions

View File

@ -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)
}

View File

@ -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)
}