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.al...@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@redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-users
_______________________________________________ libvirt-users mailing list libvirt-users@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-users