qemu/qmp: implement function to hotplug character devices

implement function to hotplug character devices using as backend
unix sockets, binding a character device with a serial port allows
the communnication between processes running in the guest with
processes running in the host.

Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
Julio Montes
2018-08-03 08:01:05 -05:00
parent 1c5466db3d
commit ca46f21f3f
2 changed files with 40 additions and 0 deletions

View File

@@ -1040,3 +1040,20 @@ func TestExecuteGetFdD(t *testing.T) {
q.Shutdown()
<-disconnectedCh
}
// Checks chardev-add unix socket
func TestExecuteCharDevUnixSocketAdd(t *testing.T) {
connectedCh := make(chan *QMPVersion)
disconnectedCh := make(chan struct{})
buf := newQMPTestCommandBuffer(t)
buf.AddCommand("chardev-add", nil, "return", nil)
cfg := QMPConfig{Logger: qmpTestLogger{}}
q := startQMPLoop(buf, cfg, connectedCh, disconnectedCh)
checkVersion(t, connectedCh)
err := q.ExecuteCharDevUnixSocketAdd(context.Background(), "foo", "foo.sock", false, true)
if err != nil {
t.Fatalf("Unexpected error %v", err)
}
q.Shutdown()
<-disconnectedCh
}