mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-22 21:49:41 +00:00
qemu/qmp: implement function to hotplug vsock-pci
Implement function to hotplug vsocks, vsocks are needed to communicate processes are running inside the VM with processes are running on the host. Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
parent
ff2401825e
commit
f700a97bee
@ -82,6 +82,9 @@ const (
|
|||||||
|
|
||||||
// VirtioSerialPort is the serial port device driver.
|
// VirtioSerialPort is the serial port device driver.
|
||||||
VirtioSerialPort = "virtserialport"
|
VirtioSerialPort = "virtserialport"
|
||||||
|
|
||||||
|
// VHostVSockPCI is the vhost vsock pci driver.
|
||||||
|
VHostVSockPCI = "vhost-vsock-pci"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ObjectType is a string representing a qemu object type.
|
// ObjectType is a string representing a qemu object type.
|
||||||
|
10
qemu/qmp.go
10
qemu/qmp.go
@ -881,3 +881,13 @@ func (q *QMP) ExecHotplugMemory(ctx context.Context, qomtype, id, mempath string
|
|||||||
|
|
||||||
return err
|
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)
|
||||||
|
}
|
||||||
|
@ -945,3 +945,20 @@ func TestExecHotplugMemory(t *testing.T) {
|
|||||||
q.Shutdown()
|
q.Shutdown()
|
||||||
<-disconnectedCh
|
<-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
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user