package qemuserver import ( "fmt" "net/url" "os" "path" "syscall" "time" ) type Options struct { QmpAddress string `yaml:"address"` Timeout time.Duration `yaml:"timeout"` Name string `yaml:"name"` Audio AudioOptions `yaml:"audio_options"` Video VideoOptions `yaml:"video_options"` } type AudioOptions struct { Device string `yaml:"device"` BufferSize uint16 `yaml:"buffer_size"` // in bytes } type VideoOptions struct { Height int `yaml:"height"` Width int `yaml:"width"` FPS float32 `yaml:"fps"` } func ExampleOptions() *Options { return &Options{ QmpAddress: (&url.URL{ Scheme: "tcp", Host: "localhost:4444", }).String(), Timeout: time.Duration(30 * time.Second), Name: "ace-qemu", Audio: AudioOptions{ Device: "snd0", BufferSize: 2048, }, Video: VideoOptions{ Height: 768, Width: 1024, FPS: 60, }, } } func (o *Options) MakeFIFO() (string, error) { path := path.Join( os.TempDir(), fmt.Sprintf("%s-%s-audio", o.Name, o.Audio.Device), ) os.Remove(path) return path, syscall.Mkfifo(path, 0600) }