func (cdev CharDevice) QemuParams(config *Config) []string {
	var cdevParams []string
	var deviceParams []string
	var qemuParams []string
	deviceParams = append(deviceParams, fmt.Sprintf("%s", cdev.Driver))
	if cdev.DisableModern {
		deviceParams = append(deviceParams, ",disable-modern=true")
	}
	if cdev.Bus != "" {
		deviceParams = append(deviceParams, fmt.Sprintf(",bus=%s", cdev.Bus))
	}
	deviceParams = append(deviceParams, fmt.Sprintf(",chardev=%s", cdev.ID))
	deviceParams = append(deviceParams, fmt.Sprintf(",id=%s", cdev.DeviceID))
	if cdev.Name != "" {
		deviceParams = append(deviceParams, fmt.Sprintf(",name=%s", cdev.Name))
	}
	cdevParams = append(cdevParams, string(cdev.Backend))
	cdevParams = append(cdevParams, fmt.Sprintf(",id=%s", cdev.ID))
	if cdev.Backend == Socket {
		cdevParams = append(cdevParams, fmt.Sprintf(",path=%s,server,nowait", cdev.Path))
	} else {
		cdevParams = append(cdevParams, fmt.Sprintf(",path=%s", cdev.Path))
	}
	qemuParams = append(qemuParams, "-device")
	qemuParams = append(qemuParams, strings.Join(deviceParams, ""))
	qemuParams = append(qemuParams, "-chardev")
	qemuParams = append(qemuParams, strings.Join(cdevParams, ""))
	return qemuParams
}
QemuParams returns the qemu parameters built out of this character device.
package qemu
import (
	"bytes"
	"fmt"
	"os"
	"os/exec"
	"strconv"
	"strings"
	"syscall"
	"context"
)
type Machine struct {
	Type string
	Acceleration string
}
type Device interface {
	Valid() bool
	QemuParams(config *Config) []string
}
type DeviceDriver string
const (
	NVDIMM DeviceDriver = "nvdimm"
	Virtio9P = "virtio-9p-pci"
	VirtioNet = "virtio-net"
	VirtioNetPCI = "virtio-net-pci"
	VirtioSerial = "virtio-serial-pci"
	VirtioBlock = "virtio-blk"
	Console = "virtconsole"
	VirtioSerialPort = "virtserialport"
)
type ObjectType string
const (
	MemoryBackendFile ObjectType = "memory-backend-file"
)
type Object struct {
	Driver DeviceDriver
	Type ObjectType
	ID string
	DeviceID string
	MemPath string
	Size uint64
}
func (object Object) Valid() bool {
	switch object.Type {
	case MemoryBackendFile:
		if object.ID == "" || object.MemPath == "" || object.Size == 0 {
			return false
		}
	default:
		return false
	}
	return true
}
func (object Object) QemuParams(config *Config) []string {
	var objectParams []string
	var deviceParams []string
	var qemuParams []string
	deviceParams = append(deviceParams, string(object.Driver))
	deviceParams = append(deviceParams, fmt.Sprintf(",id=%s", object.DeviceID))
	switch object.Type {
	case MemoryBackendFile:
		objectParams = append(objectParams, string(object.Type))
		objectParams = append(objectParams, fmt.Sprintf(",id=%s", object.ID))
		objectParams = append(objectParams, fmt.Sprintf(",mem-path=%s", object.MemPath))
		objectParams = append(objectParams, fmt.Sprintf(",size=%d", object.Size))
		deviceParams = append(deviceParams, fmt.Sprintf(",memdev=%s", object.ID))
	}
	qemuParams = append(qemuParams, "-device")
	qemuParams = append(qemuParams, strings.Join(deviceParams, ""))
	qemuParams = append(qemuParams, "-object")
	qemuParams = append(qemuParams, strings.Join(objectParams, ""))
	return qemuParams
}
type FSDriver string
type SecurityModelType string
const (
	Local FSDriver = "local"
	Handle = "handle"
	Proxy = "proxy"
)
const (
	None SecurityModelType = "none"
	PassThrough = "passthrough"
	MappedXattr = "mapped-xattr"
	MappedFile = "mapped-file"
)
type FSDevice struct {
	Driver DeviceDriver
	FSDriver FSDriver
	ID string
	Path string
	MountTag string
	SecurityModel SecurityModelType
	DisableModern bool
}
func (fsdev FSDevice) Valid() bool {
	if fsdev.ID == "" || fsdev.Path == "" || fsdev.MountTag == "" {
		return false
	}
	return true
}
func (fsdev FSDevice) QemuParams(config *Config) []string {
	var fsParams []string
	var deviceParams []string
	var qemuParams []string
	deviceParams = append(deviceParams, fmt.Sprintf("%s", fsdev.Driver))
	if fsdev.DisableModern {
		deviceParams = append(deviceParams, ",disable-modern=true")
	}
	deviceParams = append(deviceParams, fmt.Sprintf(",fsdev=%s", fsdev.ID))
	deviceParams = append(deviceParams, fmt.Sprintf(",mount_tag=%s", fsdev.MountTag))
	fsParams = append(fsParams, string(fsdev.FSDriver))
	fsParams = append(fsParams, fmt.Sprintf(",id=%s", fsdev.ID))
	fsParams = append(fsParams, fmt.Sprintf(",path=%s", fsdev.Path))
	fsParams = append(fsParams, fmt.Sprintf(",security_model=%s", fsdev.SecurityModel))
	qemuParams = append(qemuParams, "-device")
	qemuParams = append(qemuParams, strings.Join(deviceParams, ""))
	qemuParams = append(qemuParams, "-fsdev")
	qemuParams = append(qemuParams, strings.Join(fsParams, ""))
	return qemuParams
}
type CharDeviceBackend string
const (
	Pipe CharDeviceBackend = "pipe"
	Socket = "socket"
	CharConsole = "console"
	Serial = "serial"
	TTY = "tty"
	PTY = "pty"
)
type CharDevice struct {
	Backend CharDeviceBackend
	Driver DeviceDriver
	Bus string
	DeviceID string
	ID   string
	Path string
	Name string
	DisableModern bool
}
func (cdev CharDevice) Valid() bool {
	if cdev.ID == "" || cdev.Path == "" {
		return false
	}
	return true
}