Skip to content

Commit ca00027

Browse files
committed
fix(host): add audio device for spice driver
1 parent 648f60e commit ca00027

3 files changed

Lines changed: 25 additions & 9 deletions

File tree

pkg/hostman/guestman/desc/desc.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,19 @@ type SGuestRng struct {
266266
type SoundCard struct {
267267
*PCIDevice `json:",omitempty"`
268268
Codec *Codec
269+
Audio *AudioDev
269270
}
270271

271-
type Codec struct {
272+
type AudioDev struct {
272273
Id string
273274
Type string
274-
Cad int
275+
}
276+
277+
type Codec struct {
278+
Id string
279+
Type string
280+
Cad int
281+
AudioDev string
275282
}
276283

277284
type SSpiceDesc struct {

pkg/hostman/guestman/pci.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,14 @@ func (s *SKVMGuestInstance) initSpiceDevices(pciRoot *desc.PCIController) {
531531
spice.IntelHDA = &desc.SoundCard{
532532
PCIDevice: desc.NewPCIDevice(pciRoot.CType, "intel-hda", "sound0"),
533533
Codec: &desc.Codec{
534-
Id: "sound0-codec0",
535-
Type: "hda-duplex",
536-
Cad: 0,
534+
Id: "sound0-codec0",
535+
Type: "hda-duplex",
536+
Cad: 0,
537+
AudioDev: "audio0",
538+
},
539+
Audio: &desc.AudioDev{
540+
Id: "audio0",
541+
Type: "spice",
537542
},
538543
}
539544
var ehciId = "usbspice"

pkg/hostman/guestman/qemu/generate.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,14 @@ func generateSpiceOptions(port uint, spice *desc.SSpiceDesc) []string {
9292
// intel-hda and codec hda-duplex
9393
opts = append(opts, generatePCIDeviceOption(spice.IntelHDA.PCIDevice))
9494
codec := spice.IntelHDA.Codec
95-
opts = append(opts,
96-
fmt.Sprintf("-device %s,id=%s,bus=%s.0,cad=%d",
97-
codec.Type, codec.Id, spice.IntelHDA.Id, codec.Cad),
98-
)
95+
codecOpts := fmt.Sprintf("-device %s,id=%s,bus=%s.0,cad=%d", codec.Type, codec.Id, spice.IntelHDA.Id, codec.Cad)
96+
if spice.IntelHDA.Audio != nil {
97+
opts = append(opts,
98+
fmt.Sprintf("-audiodev %s,id=%s", spice.IntelHDA.Audio.Type, spice.IntelHDA.Audio.Id),
99+
)
100+
codecOpts = fmt.Sprintf("%s,audiodev=%s", codecOpts, spice.IntelHDA.Audio.Id)
101+
}
102+
opts = append(opts, codecOpts)
99103

100104
// serial port
101105
opts = append(opts, generatePCIDeviceOption(spice.VdagentSerial.PCIDevice))

0 commit comments

Comments
 (0)