From 6239e846b7f64555e328a160a6a8ec2dfbc90629 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 12 Sep 2016 18:23:25 +0200 Subject: [PATCH] qemu: Add a Character Devices slice field to the Config structure Qemu character devices typically allow for sending traffic from the guest to the host by emulating a console, a tty, a serial device for example. Signed-off-by: Samuel Ortiz --- qemu.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/qemu.go b/qemu.go index f7aeb7098..4a6414cac 100644 --- a/qemu.go +++ b/qemu.go @@ -139,6 +139,9 @@ type Config struct { // Devices is a list of devices for qemu to create. Devices []Device + // CharDevices is a list of character devices for qemu to export. + CharDevices []string + // Objects is a list of objects for qemu to create. Objects []Object @@ -237,6 +240,15 @@ func appendDevices(params []string, config Config) []string { return params } +func appendCharDevices(params []string, config Config) []string { + for _, c := range config.CharDevices { + params = append(params, "-chardev") + params = append(params, c) + } + + return params +} + func appendObjects(params []string, config Config) []string { for _, o := range config.Objects { if o.Type != "" { @@ -322,6 +334,7 @@ func LaunchQemu(config Config, logger QMPLog) (string, error) { params = appendCPUModel(params, config) params = appendQMPSocket(params, config) params = appendDevices(params, config) + params = appendCharDevices(params, config) params = appendFilesystemDevices(params, config) params = appendObjects(params, config) params = appendKernel(params, config)