qemu/qmp: implement function to hotplug serial ports

Implement function to hotplug virtio serial ports, the serial ports
are visible in the guest at the directory /dev/virtio-ports.

Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
Julio Montes
2018-08-03 08:10:44 -05:00
parent ca46f21f3f
commit 80ed88edb1
2 changed files with 31 additions and 0 deletions

View File

@@ -1057,3 +1057,20 @@ func TestExecuteCharDevUnixSocketAdd(t *testing.T) {
q.Shutdown()
<-disconnectedCh
}
// Checks virtio serial port hotplug
func TestExecuteVirtSerialPortAdd(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.ExecuteVirtSerialPortAdd(context.Background(), "foo", "foo.channel", "foo")
if err != nil {
t.Fatalf("Unexpected error %v", err)
}
q.Shutdown()
<-disconnectedCh
}