Unfortunately that did not help. I also doubt, that the cpu option is
completely overridden, because I removed the cpu tags from libvirt XML
on my first try, which led to a VM crash, because libvirt added
automatically another cpu option.
I did not mention, that I occasionally don’t have any sound at all
(non-reproducible), although speaker-test runs fine and does not display
any error messages. Logging in blindly is not so easy, but it works. I
can see from Mpdroid, that mpd also just plays normally.
I would suspect, that qemu tries somehow to exclusively grab the device,
which is undesired, but shouldn’t be possible due to the nature of dmix.
Other suggestions?
Best regards,
Manuel
The generated qemu command line looks
now like this:
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:/usr/x86_64-pc-linux-gnu/armv7a-hardfloat-linux-gnueabi/gcc-bin/5.4.0
HOME=/root USER=root QEMU_AUDIO_DRV=alsa QEMU_DAC_FIXED_SETTINGS=0 QEMU_DAC_TRY_POLL=0
QEMU_DAC_TIMER_PERIOD=0 QEMU_DAC_BUFFER_SIZE=0 QEMU_DAC_PERIOD_SIZE=0 QEMU_DAC_DEV=dmixed
/usr/bin/qemu-system-x86_64 -name guest=win10,debug-threads=on -S -object
secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-1-win10/master-key.aes
-machine pc-i440fx-2.7,accel=kvm,usb=off,vmport=off,dump-guest-core=off -cpu
host,hv_time,hv_relaxed,hv_vapic,hv_spinlocks=0x1fff -m 6144 -mem-prealloc -mem-path
/var/lib/hugetlbfs/libvirt/qemu/libvirt/qemu -realtime mlock=off -smp
4,sockets=1,cores=4,threads=1 -object iothread,id=iothread1 -object iothread,id=iothread2
-uuid 0427c09b-0d09-4827-82d9-93c64a65bdd8 -display none -no-user-config -nodefaults
-chardev
socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-1-win10/monitor.sock,server,nowait
-mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime,clock=vm -global
kvm-pit.lost_tick_policy=discard -no-hpet -no-reboot -global PIIX4_PM.disable_s3=1 -global
PIIX4_PM.disable_s4=1 -boot menu=off,strict=on -device
nec-usb-xhci,id=usb,bus=pci.0,addr=0x6 -device ahci,id=sata0,bus=pci.0,addr=0x8 -device
virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x5 -drive
if=none,media=cdrom,id=drive-sata0-0-1,readonly=on -device
ide-cd,bus=sata0.1,drive=drive-sata0-0-1,id=sata0-0-1 -drive
file=/mnt/platz/Betriebssystemabbilder/virtio-win-0.1.118.iso,format=raw,if=none,media=cdrom,id=drive-sata0-0-4,readonly=on
-device ide-cd,bus=sata0.4,drive=drive-sata0-0-4,id=sata0-0-4 -drive
file=/dev/genhd/win10,format=raw,if=none,id=drive-virtio-disk2,cache=none,aio=native
-device
virtio-blk-pci,iothread=iothread1,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk2,id=virtio-disk2,bootindex=1
-drive
file=/mnt/platz/QemuMachines/WinPlatz.img,format=raw,if=none,id=drive-virtio-disk3,cache=none,aio=native
-device
virtio-blk-pci,iothread=iothread2,scsi=off,bus=pci.0,addr=0xa,drive=drive-virtio-disk3,id=virtio-disk3
-netdev tap,fd=22,id=hostnet0 -device
rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:95:63:4c,bus=pci.0,addr=0x3 -device
ich9-intel-hda,id=sound0,bus=pci.0,addr=0x9 -device
hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -device
vfio-pci,host=00:02.0,id=hostdev0,bus=pci.0,addr=0x2 -device
usb-host,hostbus=3,hostaddr=4,id=hostdev1,bus=usb.0,port=1 -device
usb-host,hostbus=3,hostaddr=3,id=hostdev2,bus=usb.0,port=2 -device
usb-host,hostbus=3,hostaddr=2,id=hostdev3,bus=usb.0,port=3 -device
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x7 -machine
pc-i440fx-2.7,accel=kvm,usb=off,vmport=off,dump-guest-core=off,kernel_irqchip=on -cpu
host,migratable=no,+invtsc,hv_time,hv_relaxed,hv_vapic,hv_spinlocks=0x1fff -set
device.hostdev0.x-igd-opregion=on -set device.hostdev0.x-igd-gms=5 -msg timestamp=on
Adding also hw params of my Alsa devices:
dmixed
Playing WAVE '/usr/share/sounds/alsa/Noise.wav' : Signed 16 bit Little Endian,
Rate 48000 Hz, Mono
HW Params of device "dmixed":
--------------------
ACCESS: MMAP_INTERLEAVED MMAP_NONINTERLEAVED RW_INTERLEAVED RW_NONINTERLEAVED
FORMAT: S16_LE
SUBFORMAT: STD
SAMPLE_BITS: 16
FRAME_BITS: 32
CHANNELS: 2
RATE: 48000
PERIOD_TIME: (21333 21334)
PERIOD_SIZE: 1024
PERIOD_BYTES: 4096
PERIODS: [2 8]
BUFFER_TIME: (42666 170667)
BUFFER_SIZE: [2048 8192]
BUFFER_BYTES: [8192 32768]
TICK_TIME: ALL
--------------------
aplay: set_params:1239: Channels count non available
Intel PCH:
HW Params of device "hw:PCH":
--------------------
ACCESS: MMAP_INTERLEAVED RW_INTERLEAVED
FORMAT: S16_LE S32_LE
SUBFORMAT: STD
SAMPLE_BITS: [16 32]
FRAME_BITS: [32 256]
CHANNELS: [2 8]
RATE: [44100 192000]
PERIOD_TIME: (20 5944309)
PERIOD_SIZE: [4 262144]
PERIOD_BYTES: [128 8388608]
PERIODS: [2 32]
BUFFER_TIME: (41 11888617)
BUFFER_SIZE: [8 524288]
BUFFER_BYTES: [128 2097152]
TICK_TIME: ALL
--------------------
aplay: set_params:1239: Channels count non available
Fostex HP A4 (in passthrough only slightly distorted); output device
for PCH via S/PDIF
HW Params of device "hw:HPA4":
--------------------
ACCESS: MMAP_INTERLEAVED RW_INTERLEAVED
FORMAT: S32_LE
SUBFORMAT: STD
SAMPLE_BITS: 32
FRAME_BITS: 64
CHANNELS: 2
RATE: [44100 352800]
PERIOD_TIME: [125 1486078)
PERIOD_SIZE: [8 65536]
PERIOD_BYTES: [64 524288]
PERIODS: [2 1024]
BUFFER_TIME: (45 2972155)
BUFFER_SIZE: [16 131072]
BUFFER_BYTES: [128 1048576]
TICK_TIME: ALL
--------------------
aplay: set_params:1233: Sample format non available
Available formats:
- S32_LE
=?UTF-8?Q?=C5=BDilvinas_=C5=BDaltiena?= <zaltys(a)inbox.ru> writes:
Hi,
I found the main reason for sound distortions on my system is guest timer
configuration.
The working one is:
<clock offset="localtime">
<timer name="hypervclock" present="yes"/>
<timer name="hpet" present="no"/>
<timer name="rtc" present="yes" track="guest"
tickpolicy="delay"/>
</clock>
...
<qemu:commandline>a
<qemu:arg value='-machine'/>
<qemu:arg value='kernel_irqchip=on'/>
<qemu:arg value='-cpu'/>
<qemu:arg
value='host,migratable=no,+invtsc,hv_time,+kvm_pv_eoi,hv_relaxed,hv_spinlocks=0x1fff,hv_vendor_id=nv_fuck_you!,kvm=off'/>
</qemu:commandline>
The important part here is "host,migratable=no,+invtsc". It gives guest the
invariant TSC (CPU must support it). This is a bit of a hack. Everything,
except migratable=no, can be configured through proper XML elements,
however +invtsc requires migratable=no, and I don't know a way to pass it
other than using qemu:arg. Note it completely overrides qemus -cpu
parameter created from other tags. Don't paste my qemu:arg of it. Run your
VM without it, check libvirt log, and copy from it what is passed to qemu
as -cpu parameter, then add migratable=no,+invtsc.
2016-12-20 4:41 GMT+02:00 Manuel Ullmann <ullman.alias(a)posteo.de>:
> Hi,
>
> I can’t seem to find a solution for my last VM issue.
> I have distorted sound, when I play the Windows 10 device test
> sound. Only the Windows sound is affected. Mpd of the host is playing just
> fine
> meanwhile. I am using ich9 as emulated card, which is detected and
> installed correctly. The VM is using vfio-igd passthrough, so vnc or
> spice are not used.
> I tried to match the Windows driver configuration, which only supports
> 16 bit output. I have a 24 bit USB headphone amplifier, which does not
> support it (S32_LE only). Trying direct playback on the PCH card jack
> did not help though.
>
> The headphone amplifier is connected via optical Toslink, so there is
> standard snd_hda_intel output used (snd_usb_audio is not involved).
> Passing the USB part through I get much clearer output, but still have
> popping sounds. Googling around, they seem to be quite common on Windows
> 10, although I had it working fine on two bare-metal machines.
>
> I have tried fixed settings matching the ones of the dmixed device
> too. Don’t know, what is polled with enabled poll option. I also tried
> sdl and pulseaudio, which did not help. For the latter not so surprising
> since it is an Alsa pipe. The former was worse.
>
> The goal of this setup is having the same playlist state on both
> systems and using the better audio framework for music playback (Windows
> uses
> too much software layers). Of course the popping sounds on audio device
> passthrough also would be annoying, but that might be a different issue.
>
> Best regards,
> Manuel
>
> used alsa device:
> pcm.dmixed {
> type asym
> playback.pcm {
> # See plugin:dmix at
http://www.alsa-project.org/
> alsa-doc/alsa-lib/pcm_plugins.html
> type dmix
>
> # Don't block other users, e.g. the Timidity midi-player
> daemon
> #
http://www.alsa-project.org/
> alsa-doc/alsa-lib/pcm_plugins.html
> ipc_key_add_uid false
>
> ipc_key 1025
> ipc_perm 0660
> ipc_gid audio
>
> # Don't put the rate here! Otherwise it resets the rate &
> channels set below, as shown by: cat /proc/asound/card0/pcm0p/sub0/
> hw_params
> slave {
> # 2 for stereo, 6 for surround51, 8 for surround71
> channels 2
> pcm {
> format S16_LE
> #format S32_LE
>
> #rate 44100
> rate 48000
>
> #
http://www.alsa-project.org/
> alsa-doc/alsa-lib/pcm_plugins.html
> # Maybe helps
> nonblock true
> type hw
> card "PCH"
> device 0
> subdevice 0
> }
>
> # mplayer2 chooses 1024
> # period_size 512 with buffer_size 16384 stops
> crackling in xmame
> # 320 breaks flash -
https://bbs.archlinux.org/
> viewtopic.php?id=129458
> #period_size 512
> period_size 1024
>
> # 4096 might make sound crackle
> # mplayer2 chooses 8192. Half-Life 2 chooses 16384.
> # If too large, use CONFIG_SND_HDA_PREALLOC_SIZE=
> 2048
> buffer_size 8192
> }
> }
> capture.pcm "schneeball"
> }
>
> libvirt xml snippets:
>
> <sound model='ich9'>
> <address type='pci' domain='0x0000' bus='0x00'
slot='0x09'
> function='0x0'/>
> </sound>
> ...
> <qemu:env name='QEMU_AUDIO_DRV' value='alsa'/>
> <qemu:env name='QEMU_DAC_FIXED_SETTINGS' value='0'/>
> <qemu:env name='QEMU_DAC_TRY_POLL' value='0'/>
> <qemu:env name='QEMU_DAC_TIMER_PERIOD' value='0'/>
> <qemu:env name='QEMU_DAC_BUFFER_SIZE' value='0'/>
> <qemu:env name='QEMU_DAC_PERIOD_SIZE' value='0'/>
> <qemu:env name='QEMU_DAC_DEV' value='dmixed'/>
>
> _______________________________________________
> libvirt-users mailing list
> libvirt-users(a)redhat.com
>
https://www.redhat.com/mailman/listinfo/libvirt-users