# [SOLVED]Virt-manager, Qemu, no sound in guest VM

## cord

Hello All,

I am trying to install Windows XP as guest in Qemu. Settings were made through Virt-manager's GUI. Config XML is: https://bpaste.net/show/ce2db0251dc7

It looks like everything is working, except for the sound, there's no it. The Log shows this: https://bpaste.net/show/162e031910ca

If I run:

```

$ export QEMU_AUDIO_DRV=alsa

$ qemu-system-x86_64 -drive file=VM.img -m 1G -vga qxl -netdev user,id=vmnic -device rtl8139,netdev=vmnic -usbdevice tablet -soundhw ac97

```

The Sound is present, although with periodical crackling distortion (and windows working is terribly slow).

I would still like to set up the sound through the 'spice'.

```

localhost # emerge -pv qemu virt-manager libvirt spice-gtk

These are the packages that would be merged, in order:

Calculating dependencies... done!

[ebuild   R    ] app-emulation/qemu-2.4.1-r2::gentoo  USE="aio alsa caps curl fdt filecaps jpeg ncurses nls opengl pin-upstream-blobs png sdl sdl2 seccomp spice threads usb usbredir uuid vhost-net vnc xattr -accessibility -bluetooth -debug (-glusterfs) -gtk -gtk2 -infiniband -iscsi -lzo -nfs -numa -pulseaudio -python -rbd -sasl (-selinux) -smartcard -snappy -ssh -static -static-softmmu -static-user -systemtap -tci {-test} -tls -vde -virtfs -vte -xen -xfs" PYTHON_TARGETS="python2_7" QEMU_SOFTMMU_TARGETS="i386 x86_64 -aarch64 -alpha -arm -cris -lm32 -m68k -microblaze -microblazeel -mips -mips64 -mips64el -mipsel -moxie -or32 -ppc -ppc64 -ppcemb -s390x -sh4 -sh4eb -sparc -sparc64 -tricore -unicore32 -xtensa -xtensaeb" QEMU_USER_TARGETS="i386 x86_64 -aarch64 -alpha -arm -armeb -cris -m68k -microblaze -microblazeel -mips -mips64 -mips64el -mipsel -mipsn32 -mipsn32el -or32 -ppc -ppc64 -ppc64abi32 -ppc64le -s390x -sh4 -sh4eb -sparc -sparc32plus -sparc64 -unicore32" 0 KiB

[ebuild   R    ] net-misc/spice-gtk-0.30-r1::gentoo  USE="gstreamer gtk3 introspection python usbredir -dbus -lz4 -policykit -pulseaudio -sasl -smartcard -static-libs -vala -webdav" PYTHON_SINGLE_TARGET="python2_7 -python3_4" PYTHON_TARGETS="python2_7 python3_4" 0 KiB

[ebuild   R    ] app-emulation/virt-manager-1.1.0-r2::gentoo  USE="gtk -debug -gnome-keyring -policykit -sasl" PYTHON_TARGETS="python2_7" 0 KiB

[ebuild   R    ] app-emulation/libvirt-1.2.18-r1:0/1.2.18::gentoo  USE="caps libvirtd macvtap nls qemu udev vepa virt-network (-apparmor) -audit -avahi -firewalld -fuse (-glusterfs) -iscsi -lvm -lxc -nfs -numa -openvz -parted -pcap -phyp -policykit -rbd -sasl (-selinux) -systemd -uml -virtualbox (-wireshark-plugins) -xen" 0 KiB

Total: 4 packages (4 reinstalls), Size of downloads: 0 KiB

localhost #

```

What can you suggest?Last edited by cord on Sat Jan 09, 2016 1:20 pm; edited 1 time in total

----------

## szatox

Thirst thing, you either use virt manager OR you run qemu yourself.

This means, when you launch qemu yourself, it's the command line you pass to it that matters and NOT whatever you set in virt manager (because virt manager is not managing it at this time).

First thing is, in your qemu line parameter "-enable-kvm" is missing. Hardware support for virtualization is disabled by default.

Second thing, after you start your machine from virtual manager you can use ps and grep to find out what the command line from virt manager is. It might provide some additional information in a format easier to read than xml.

Also, you can use lspci and aplay -l (or aplay -L) to find out whether or not the audio device is detected and used by the guest system. Once you know the differences between your and virt's command lines and the results you will likely know where the problem is and perhaps what it is and hopefully how to resolve it  :Smile: 

----------

## cord

 *szatox wrote:*   

> First thing is, in your qemu line parameter "-enable-kvm" is missing. Hardware support for virtualization is disabled by default.
> 
> Second thing, after you start your machine from virtual manager you can use ps and grep to find out what the command line from virt manager is. It might provide some additional information in a format easier to read than xml.
> 
> 

 

Yes, I have showed the log (see above). Second line:

```
LC_ALL=C PATH=/bin:/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin HOME=/ USER=root QEMU_AUDIO_DRV=spice /usr/bin/qemu-system-x86_64 -name winxp -S -machine pc-i440fx-2.4,accel=kvm,usb=off -cpu qemu64,hv_time,hv_relaxed,hv_vapic,hv_spinlocks=0x1fff -m 512 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid 49aa0c66-361f-4027-858c-dc5e5dd8bf5a -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/winxp.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime,driftfix=slew -global kvm-pit.lost_tick_policy=discard -no-hpet -no-shutdown -global PIIX4_PM.disable_s3=1 -global PIIX4_PM.disable_s4=1 -boot strict=on -device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x6.0x7 -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x6 -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x6.0x1 -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x6.0x2 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x5 -drive file=/var/lib/libvirt/images/winxp.qcow2,if=none,id=drive-ide0-0-0,format=qcow2 -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 -drive if=none,id=drive-ide0-0-1,readonly=on,format=raw -device ide-cd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 -netdev tap,fd=19,id=hostnet0 -device rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:9c:04:76,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -chardev spicevmc,id=charchannel0,name=vdagent -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=com.redhat.spice.0 -device usb-tablet,id=input0 -spice port=5900,addr=127.0.0.1,disable-ticketing,seamless-migration=on -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vgamem_mb=16,bus=pci.0,addr=0x2 -device AC97,id=sound0,bus=pci.0,addr=0x4 -chardev spicevmc,id=charredir0,name=usbredir -device usb-redir,chardev=charredir0,id=redir0 -chardev spicevmc,id=charredir1,name=usbredir -device usb-redir,chardev=charredir1,id=redir1 -chardev spicevmc,id=charredir2,name=usbredir -device usb-redir,chardev=charredir2,id=redir2 -chardev spicevmc,id=charredir3,name=usbredir -device usb-redir,chardev=charredir3,id=redir3 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x7 -msg timestamp=on

```

So, the Virt-manager doesn't send the "-enable-kvm" option, but 'accel=kvm'. Is that it?

If no, How it will look in XML format (I think, I can add it via 'virsh edit xxx', but it must be XML formatting)?

 *szatox wrote:*   

> 
> 
> Also, you can use lspci and aplay -l (or aplay -L) to find out whether or not the audio device is detected and used by the guest system.

 

The guest system is Windows XP. It does't have lspci/aplay  :Smile: 

But it finds 'AC97' soundcard and even doesn't require special drivers. And I wrote that with Qemu (directly) there can be sound, while the settings inside Windows XP are equal for cases of 'Qemu directly' and 'Virt-manager'.

----------

## Ant P.

"QEMU_AUDIO_DRV=spice" might be your problem. Did you build the virt-manager VNC/Spice viewer with sound support?

----------

## cal22cal

Here is the log which winxp audio is fine in my qemu vm with "spicec"

```
2015-12-23 11:22:50.686+0000: starting up libvirt version: 1.2.21, qemu version: 2.5.0

LC_ALL=C PATH=/bin:/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3 HOME=/root USER=root QEMU_AUDIO_DRV=spice /usr/bin/qemu-system-x86_64 -name winxp -S -machine pc-i440fx-2.3,accel=kvm,usb=off,vmport=off -cpu Nehalem,hv_time,hv_relaxed,hv_vapic,hv_spinlocks=0x1fff -m 1024 -realtime mlock=off -smp 2,sockets=2,cores=1,threads=1 -uuid fffa6c9d-ff9a-413e-a73d-9aec044170a3 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-winxp/monitor.sock,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime,driftfix=slew -global kvm-pit.lost_tick_policy=discard -no-hpet -no-shutdown -global PIIX4_PM.disable_s3=1 -global PIIX4_PM.disable_s4=1 -boot strict=on -device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x6.0x7 -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x6 -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x6.0x1 -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x6.0x2 -device lsi,id=scsi0,bus=pci.0,addr=0x8 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x5 -drive file=/home/all/kvm-disk.images/XP-3G.qcow2,if=none,id=drive-scsi0-0-0,format=qcow2 -device scsi-hd,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0,bootindex=1 -drive if=none,id=drive-ide0-0-1,readonly=on,format=raw -device ide-cd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1,bootindex=2 -drive if=none,id=drive-ide0-1-1,readonly=on,format=raw -device ide-cd,bus=ide.1,unit=1,drive=drive-ide0-1-1,id=ide0-1-1 -netdev tap,fd=19,id=hostnet0,vhost=on,vhostfd=21 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:57:73:fc,bus=pci.0,addr=0x9 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -chardev spicevmc,id=charchannel0,name=vdagent -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=com.redhat.spice.0 -device usb-tablet,id=input0 -spice port=5901,addr=127.0.0.1,disable-ticketing,seamless-migration=on -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vgamem_mb=16,bus=pci.0,addr=0x2 -device AC97,id=sound0,bus=pci.0,addr=0x4 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x7 -msg timestamp=on

char device redirected to /dev/pts/26 (label charserial0)
```

Can't remember what I have done, though.

One question, have you install the spice-guest-tools in the vm ?

EDIT:-

I use this command to connect to the vm

spicec --hotkeys release-cursor=rctrl -h localhost -p 5901 --title "winxp"

"spicy" will be no sound, since it will use pulseaudio instead of alsa.

----------

## cord

 *Ant P. wrote:*   

> "QEMU_AUDIO_DRV=spice" might be your problem.

 

Agreed, but I would want to use exactly 'spice', because 'alsa' has some threats with permissions (according to comments on the forums).

 *Ant P. wrote:*   

> Did you build the virt-manager VNC/Spice viewer with sound support?

 

These packages:

```

localhost # emerge -pv qemu virt-manager libvirt spice-gtk

These are the packages that would be merged, in order:

Calculating dependencies... done!

[ebuild   R    ] app-emulation/qemu-2.4.1-r2::gentoo  USE="aio alsa caps curl fdt filecaps jpeg ncurses nls opengl pin-upstream-blobs png sdl sdl2 seccomp spice threads usb usbredir uuid vhost-net vnc xattr -accessibility -bluetooth -debug (-glusterfs) -gtk -gtk2 -infiniband -iscsi -lzo -nfs -numa -pulseaudio -python -rbd -sasl (-selinux) -smartcard -snappy -ssh -static -static-softmmu -static-user -systemtap -tci {-test} -tls -vde -virtfs -vte -xen -xfs" PYTHON_TARGETS="python2_7" QEMU_SOFTMMU_TARGETS="i386 x86_64 -aarch64 -alpha -arm -cris -lm32 -m68k -microblaze -microblazeel -mips -mips64 -mips64el -mipsel -moxie -or32 -ppc -ppc64 -ppcemb -s390x -sh4 -sh4eb -sparc -sparc64 -tricore -unicore32 -xtensa -xtensaeb" QEMU_USER_TARGETS="i386 x86_64 -aarch64 -alpha -arm -armeb -cris -m68k -microblaze -microblazeel -mips -mips64 -mips64el -mipsel -mipsn32 -mipsn32el -or32 -ppc -ppc64 -ppc64abi32 -ppc64le -s390x -sh4 -sh4eb -sparc -sparc32plus -sparc64 -unicore32" 0 KiB

[ebuild   R    ] net-misc/spice-gtk-0.30-r1::gentoo  USE="gstreamer gtk3 introspection python usbredir -dbus -lz4 -policykit -pulseaudio -sasl -smartcard -static-libs -vala -webdav" PYTHON_SINGLE_TARGET="python2_7 -python3_4" PYTHON_TARGETS="python2_7 python3_4" 0 KiB

[ebuild   R    ] app-emulation/virt-manager-1.1.0-r2::gentoo  USE="gtk -debug -gnome-keyring -policykit -sasl" PYTHON_TARGETS="python2_7" 0 KiB

[ebuild   R    ] app-emulation/libvirt-1.2.18-r1:0/1.2.18::gentoo  USE="caps libvirtd macvtap nls qemu udev vepa virt-network (-apparmor) -audit -avahi -firewalld -fuse (-glusterfs) -iscsi -lvm -lxc -nfs -numa -openvz -parted -pcap -phyp -policykit -rbd -sasl (-selinux) -systemd -uml -virtualbox (-wireshark-plugins) -xen" 0 KiB

Total: 4 packages (4 reinstalls), Size of downloads: 0 KiB

localhost #

```

or? What?

 *cal22cal wrote:*   

> One question, have you install the spice-guest-tools in the vm ?

 

I have install 'QXL video driver', 'QEMU guest agent' and 'VirtViewer'. I need something else inside Windows XP?

 *cal22cal wrote:*   

> 
> 
> I use this command to connect to the vm
> 
> spicec --hotkeys release-cursor=rctrl -h localhost -p 5901 --title "winxp"
> ...

 

I don't use pulseaudio and I have set virt-manager according to this.

----------

## cal22cal

Can't exactly remember what I have done.

Anyway, 'spicec' no longer exists after updating to net-misc/spice-gtk-0.30-r1 or net-misc/spice-gtk-0.30

Using 'spicec' is the only way that I can get audio from vm guest and host under ALSA.

vnc will get audio, but the host audio will be disabled after the guest had started.

Suggest downgrade spice-gtk in host.

Then connect to vm by 'spicec' instead of virt-viewer.

virt-viewr might work again, though.

----------

## cord

Solved.

https://bugs.gentoo.org/show_bug.cgi?id=571372

----------

