RE: where are xs APIs defined
[AMD Official Use Only - General] Hello, Thanks for the help. I use Visual Studio Code and somehow it is not able to find. Regards, Jyotirmoy -Original Message- From: Juergen Gross Sent: Tuesday, September 20, 2022 11:19 AM To: SHARMA, JYOTIRMOY ; xen-devel@lists.xenproject.org Cc: Mallela, RaghavendraPrasad (Raghavendra Prasad) Subject: Re: where are xs APIs defined Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
where are xs APIs defined
[AMD Official Use Only - General] Hello, I am looking for the source code where Xenstore access APIs like xs_open(), xs_read() are defined. Please help. Regards, Jyotirmoy
RE: libxl source code
[AMD Official Use Only - General] Adding xen devel Regards, Jyotirmoy From: SHARMA, JYOTIRMOY Sent: Friday, September 9, 2022 3:52 PM To: 'xen-us...@lists.xenproject.org' Subject: libxl source code [AMD Official Use Only - General] Hello, I am looking for the libxl source code to understand how vsnd (PV audio driver) has been implemented. However, if I look into the xen source tree (https://xenbits.xen.org/gitweb/?p=xen.git;a=tree;f=tools;h=9b2efe082223bbf60b41e947ceb4821e98708c02;hb=refs/heads/stable-4.16), I do not see libxl folder. Specifically I am looking for the code which is present in the following patch set: https://lore.kernel.org/all/1509548687-6071-3-git-send-email-al1...@gmail.com/ Can you please help me locate the source files in this patch set? Regards, Jyotirmoy
Re: Enable audio virtualization in Xen
[AMD Official Use Only - General] I am continuously getting following log when I play a file in Dom U: 06.09.22 16:16:38.071 | XenEvtchn | DBG - Notify event channel, port: 76 06.09.22 16:16:38.096 | AlsaPcm | DBG - Frame: 0, bytes: 0, state: 3 06.09.22 16:16:38.096 | RingBuffer | DBG - Send event, port: 32, prod: 704, cons: 704, num event Frame and bytes cannot be 0 for every frame, right? Can this be the issue? What could be the reason for this? Regards, Jyotirmoy
Re: Enable audio virtualization in Xen
[AMD Official Use Only - General] Hi Oleksandr, Thank you for your input. I tried matching the hardware parameter (i.e. buffer size) in the HVM config file, but still no luck with audio from HVM guest. Here is the complete vsnd config: vsnd = [[ 'card, backend=Domain-0, buffer-size=22050, short-name=VCard, long-name=Virtual sound card, sample-rates=8000;11025;16000;22050;32000;44100;48000, sample-formats=s16_le', 'pcm, name=dev1', 'stream, unique-id=alsa, type=P' ]] This is what I see when I play audio in Dom 0: amd@amd-Bilby-RV2:~$ aplay -v ~/SampleAudio/music.wav Playing WAVE '/home/amd/SampleAudio/music.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo ALSA <-> PulseAudio PCM I/O Plugin Its setup is: stream : PLAYBACK access : RW_INTERLEAVED format : S16_LE subformat: STD channels : 2 rate : 44100 exact rate : 44100 (44100/1) msbits : 16 buffer_size : 22050 period_size : 5512 period_time : 125000 tstamp_mode : NONE tstamp_type : GETTIMEOFDAY period_step : 1 avail_min: 5512 period_event : 0 start_threshold : 22050 stop_threshold : 22050 silence_threshold: 0 silence_size : 0 boundary : 6206523236469964800 I have also tried giving buffer-size as 88200 (22050 * 2 channels * 2 bytes per sample), but still there is no audio from HVM guest. What will be the right parameters based on the above aplay information? Below is the information obtained using -dump-hw-params flag. Do I need to change vsnd parameters based on this information? amd@amd-Bilby-RV2:~$ aplay ~/SampleAudio/music.wav --dump-hw-params Playing WAVE '/home/amd/SampleAudio/music.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo HW Params of device "default": ACCESS: RW_INTERLEAVED FORMAT: U8 S16_LE S16_BE S24_LE S24_BE S32_LE S32_BE FLOAT_LE FLOAT_BE MU_LAW A_LAW S24_3LE S24_3BE SUBFORMAT: STD SAMPLE_BITS: [8 32] FRAME_BITS: [8 1024] CHANNELS: [1 32] RATE: [1 384000] PERIOD_TIME: (2 4294967295) PERIOD_SIZE: [1 1398102) PERIOD_BYTES: [128 1398102) PERIODS: [3 1024] BUFFER_TIME: (7 4294967295] BUFFER_SIZE: [3 4194304] BUFFER_BYTES: [384 4194304] TICK_TIME: ALL Added Oleksandr Grytsov for help. Regards, Jyotirmoy
Re: Enable audio virtualization in Xen
[AMD Official Use Only - General] Hi all, Forgot to mention that I am able to play audio from HVM guest with Pulse Audio as back end. Here is the corresponding HVM configuration: vsnd = [[ 'card, backend=Domain-0, buffer-size=65536, short-name=VCard, long-name=Virtual sound card, sample-rates=44100, sample-formats=s16_le', 'pcm, name=dev1', 'stream, unique-id=pulse, type=P' ]] I have used xen front end and snd_be (along with libxenbe) as back end as suggested by Christopher earlier in this thread. Only when I change unique-id=alsa, audio is not working from HVM guest. If anyone has tried ALSA back end (instead of PA), please let me know what I am missing. Regards, Jyotirmoy
Re: Enable audio virtualization in Xen
[AMD Official Use Only - General] Hi Oleksandr, Christopher and others, I am trying to enable audio playback from HVM guest as per discussion above using ALSA as back end. I have compiled and installed libxenbe (https://github.com/xen-troops/libxenbe) and snd_be (https://github.com/xen-troops/snd_be). Following is my vsnd detail in the HVM configuration file: vsnd = [[ 'card, backend=Domain-0, buffer-size=65536, short-name=VCard, long-name=Virtual sound card, sample-rates=44100, sample-formats=s16_le', 'pcm, name=dev1', 'stream, unique-id=alsa, type=P' ]] Here is the virtual card listed in HVM guest: amd@amd-HVM-domU:~$ aplay -l List of PLAYBACK Hardware Devices card 0: vsnd [], device 0: dev1 [Virtual card PCM] Subdevices: 0/1 Subdevice #0: subdevice #0 I am trying to play audio in guest HVM using aplay command: aplay sample.wav. However, I am not able to hear any audio in this case. Please note that if I play the wave file from dom 0 using the same command, audio can be heard. This means that audio is working fine in the dom 0 using default card. Below is the log from snd_be. Has anyone tried ALSA back end before? If yes, can you help me in understanding the issue here? 01.09.22 12:46:37.240 | Main | INF - backend version: v0.2.1-6-gb276 01.09.22 12:46:37.240 | Main | INF - libxenbe version: v0.2.1-11-g2e55-dirty 01.09.22 12:46:37.240 | XenStore | DBG - Create xen store 01.09.22 12:46:37.240 | XenStore | DBG - Read string domid : 0 01.09.22 12:46:37.240 | XenStore | DBG - Read int domid : 0 01.09.22 12:46:37.241 | SndBackend | DBG - Create backend, device: vsnd, dom Id: 0 01.09.22 12:46:37.241 | XenStore | DBG - Start 01.09.22 12:46:37.241 | XenStore | DBG - Set watch: /local/domain/0/backend/vsnd 01.09.22 12:46:37.241 | XenStore | DBG - Watch triggered: /local/domain/0/backend/vsnd 01.09.22 12:46:50.469 | XenStore | DBG - Watch triggered: /local/domain/0/backend/vsnd 01.09.22 12:46:50.470 | XenStore | DBG - Set watch: /local/domain/0/backend/vsnd/1 01.09.22 12:46:50.470 | XenStore | DBG - Watch triggered: /local/domain/0/backend/vsnd 01.09.22 12:46:50.470 | XenStore | DBG - Watch triggered: /local/domain/0/backend/vsnd 01.09.22 12:46:50.471 | XenStore | DBG - Watch triggered: /local/domain/0/backend/vsnd 01.09.22 12:46:50.471 | XenStore | DBG - Watch triggered: /local/domain/0/backend/vsnd 01.09.22 12:46:50.471 | XenStore | DBG - Watch triggered: /local/domain/0/backend/vsnd 01.09.22 12:46:50.472 | XenStore | DBG - Watch triggered: /local/domain/0/backend/vsnd/1 01.09.22 12:46:50.472 | SndBackend | DBG - New frontend found, domid: 1, devid: 0 01.09.22 12:46:50.472 | XenStore | DBG - Create xen store 01.09.22 12:46:50.472 | SndFrontend | DBG - Dom(1/0) Create frontend handler 01.09.22 12:46:50.473 | XenStore| DBG - Read string /local/domain/1/device/vsnd/0/backend : /local/domain/0/backend/vsnd/1/0 01.09.22 12:46:50.473 | SndFrontend | DBG - Frontend path: /local/domain/1/device/vsnd/0 01.09.22 12:46:50.473 | SndFrontend | DBG - Backend path: /local/domain/0/backend/vsnd/1/0 01.09.22 12:46:50.473 | XenStore| DBG - Read string /local/domain/0/backend/vsnd/1/0/state : 1 01.09.22 12:46:50.473 | XenStore| DBG - Read int /local/domain/0/backend/vsnd/1/0/state : 1 01.09.22 12:46:50.473 | SndFrontend | INF - Close 01.09.22 12:46:50.473 | SndFrontend | INF - Dom(1/0) Set backend state to: [Closing] 01.09.22 12:46:50.473 | XenStore| DBG - Write int /local/domain/0/backend/vsnd/1/0/state : 5 01.09.22 12:46:50.473 | XenStore| DBG - Write string /local/domain/0/backend/vsnd/1/0/state : 5 01.09.22 12:46:50.473 | SndFrontend | INF - Dom(1/0) Set backend state to: [Closed] 01.09.22 12:46:50.473 | XenStore| DBG - Write int /local/domain/0/backend/vsnd/1/0/state : 6 01.09.22 12:46:50.474 | XenStore| DBG - Write string /local/domain/0/backend/vsnd/1/0/state : 6 01.09.22 12:46:50.474 | SndFrontend | INF - Dom(1/0) Set backend state to: [Initializing] 01.09.22 12:46:50.474 | XenStore| DBG - Write int /local/domain/0/backend/vsnd/1/0/state : 1 01.09.22 12:46:50.474 | XenStore| DBG - Write string /local/domain/0/backend/vsnd/1/0/state : 1 01.09.22 12:46:50.474 | PulseMainloop | DBG - Init 01.09.22 12:46:50.477 | PulseMainloop | DBG - Context is ready 01.09.22 12:46:50.477 | XenStore | DBG - Set watch: /local/domain/0/backend/vsnd/1/0 01.09.22 12:46:50.477 | XenStore | DBG - Set watch: /local/domain/1/device/vsnd/0/state 01.09.22 12:46:50.478 | XenStore | DBG - Set watch: /local/domain/0/backend/vsnd/1/0/state 01.09.22 12:46:50.478 | XenStore | DBG - Start 01.09.22 12:46:50.478 | XenStore | DBG - Watch triggered: /local/domain/0/backend/vsnd 01.09.22 12:46:50.478 | XenStore | DBG - Watch triggered: /local/domain/1/device/vsnd/0/state 01.09.22 12:46:50.478 | XenStore | DBG - Watch triggered: /local/domain/0/backend/vsnd/1 01.09.22 12:46:50.478 | XenStore | DBG - Read
Re: Enable audio virtualization in Xen
[AMD Official Use Only - General] Hello Christopher, Thank you so much for your reply. I will execute your steps and first try to enable pulse audio as you have mentioned. Later I will try to enable ALSA which is my final requirement. Meanwhile, I was reading up on virtio-snd and found some patches in the internet. However, those patches are not present in the qemu source code (https://gitlab.com/qemu-project/qemu.git). Do you know 1. If virtio-snd front end driver is another option to enable audio in HVM guest with Qemu/ALSA as backend in dom0? 2. If yes, how is it different from xen front end drivers? Also, regarding enabling Xen PV audio front end device drivers, you have mentioned that I need to enable backend using libxenbe and snd_be. Does it mean, in this case, Qemu is not involved in the audio backend? Any pointers to understand this overall architecture (Xen PV audio front end driver/snd_be/qemu/ALSA) will be extremely helpful. Regards, Jyotirmoy
RE: Enable audio virtualization in Xen
[AMD Official Use Only - General] Hi all, Can anyone please help here? Also, how can I make use of the xen front end drivers in a HVM guest? Regards, Jyotirmoy -Original Message- From: SHARMA, JYOTIRMOY Sent: Tuesday, July 26, 2022 4:27 PM To: Christopher Clark Cc: xen-devel@lists.xenproject.org; xen-us...@lists.xenproject.org Subject: RE: Enable audio virtualization in Xen [AMD Official Use Only - General] Hi Christopher, Thank you for the quick response. Please find answers below. >> Does audio playback work OK from your Ubuntu dom0? Yes. >> Do you know which version of Ubuntu you are using? ('cat /etc/lsb-release') Ubuntu 22.04 LTS. >> Do you know which version of Xen you are using? ('xl info' in dom0 should >> help) 4.16.2-pre. >> Do you know which version of Qemu you have installed in dom0? QEMU emulator version 6.1.1. >> Did you build and install Xen from source code, or are you using binary >> packages of Xen and its tools? We built and installed Xen from source code (git clone https://xenbits.xen.org/git-http/xen.git). >> Are you using the xl tools, or libvirt tools for configuring and running >> your guest? -- ie. how do you start your domU VM? We are using xl tools (sudo xl -v create ). >> When your domU is running, please could you run 'ps auxwww' in dom0 and >> obtain the process information about the qemu instance that is running, so >> that we can see what command line arguments have been supplied to it This is the log we get right after booting dom 0: root 723 0.0 0.2 243792 14468 ? Sl 15:51 0:00 /usr/local/lib/xen/bin/qemu-system-i386 -xen-domid 0 -xen-attach -name dom0 -nographic -M xenpv -daemonize -monitor /dev/null -serial /dev/null -parallel /dev/null -pidfile /var/run/xen/qemu-dom0.pid This log is seen after we launch dom U (sudo xl -v create ): root 2152 20.7 2.3 2858204 133496 ? Ssl 15:53 0:09 /usr/local/lib/xen/bin/qemu-system-i386 -xen-domid 1 -no-shutdown -chardev socket,id=libxl-cmd,path=/var/run/xen/qmp-libxl-1,server=on,wait=off -mon chardev=libxl-cmd,mode=control -chardev socket,id=libxenstat-cmd,path=/var/run/xen/qmp-libxenstat-1,server=on,wait=off -mon chardev=libxenstat-cmd,mode=control -nodefaults -no-user-config -name domu-ubuntu.hvm -vnc 127.0.0.1:0,to=99 -display sdl,gl=on -sdl -device virtio-vga-gl -boot order=dc -usb -usbdevice tablet -smp 2,maxcpus=2 -net none -machine xenfv,suppress-vmdesc=on -m 2040 -drive file=/home/amd/u2004_ubuntu.qcow2,if=ide,index=0,media=disk,format=qcow2,cache=writeback >> A little more information about what you're running will help with providing >> guidance here. The xl man page indicates that there is a "soundhw" option in >> the VM configuration file for passing sound hardware configution through to >> qemu, so if you are using the xl toolstack, you could try adding this to the >> config file: soundhw="hda" I tried giving soundhw="hda" option in the hvm config file. However, I do not hear any sound when I play a wave file in dom U. Here is the 'ps auxwww' output after making this change: root 2568 14.8 2.3 2770864 134720 ? Ssl 15:58 0:09 /usr/local/lib/xen/bin/qemu-system-i386 -xen-domid 2 -no-shutdown -chardev socket,id=libxl-cmd,path=/var/run/xen/qmp-libxl-2,server=on,wait=off -mon chardev=libxl-cmd,mode=control -chardev socket,id=libxenstat-cmd,path=/var/run/xen/qmp-libxenstat-2,server=on,wait=off -mon chardev=libxenstat-cmd,mode=control -nodefaults -no-user-config -name domu-ubuntu-audio.hvm -vnc 127.0.0.1:0,to=99 -display sdl,gl=on -sdl -device virtio-vga-gl -boot order=dc -usb -usbdevice tablet -soundhw hda -smp 2,maxcpus=2 -net none -machine xenfv,suppress-vmdesc=on -m 2040 -drive file=/home/amd/u2004_ubuntu.qcow2,if=ide,index=0,media=disk,format=qcow2,cache=writeback Also, I tried giving soundhw="all" in the config file, however this throws following error: libxl: error: libxl_dm.c:3130:device_model_spawn_outcome: Domain 4:domain 4 device model: spawn failed (rc=-3) libxl: error: libxl_dm.c:3350:device_model_postconfig_done: Domain 4:Post DM startup configs failed, rc=-3 libxl: error: libxl_create.c:1867:domcreate_devmodel_started: Domain 4:device model did not start: -3 libxl: error: libxl_aoutils.c:646:libxl__kill_xs_path: Device Model already exited libxl: error: libxl_domain.c:1183:libxl__destroy_domid: Domain 4:Non-existant domain libxl: error: libxl_domain.c:1137:domain_destroy_callback: Domain 4:Unable to destroy guest libxl: error: libxl_domain.c:1064:domain_destroy_cb: Domain 4:Destruction of domain failed Can you please let me know what parameters I should use in the config file to play audio from dom U? Regards, Jyotirmoy -Original Message- From: Christopher Clark Sent: Tuesday, July 26, 2022 2:44 AM To: SHARMA, JYOTIRMOY Cc: xen-devel
RE: Enable audio virtualization in Xen
[AMD Official Use Only - General] Hi Christopher, Thank you for the quick response. Please find answers below. >> Does audio playback work OK from your Ubuntu dom0? Yes. >> Do you know which version of Ubuntu you are using? ('cat /etc/lsb-release') Ubuntu 22.04 LTS. >> Do you know which version of Xen you are using? ('xl info' in dom0 should >> help) 4.16.2-pre. >> Do you know which version of Qemu you have installed in dom0? QEMU emulator version 6.1.1. >> Did you build and install Xen from source code, or are you using binary >> packages of Xen and its tools? We built and installed Xen from source code (git clone https://xenbits.xen.org/git-http/xen.git). >> Are you using the xl tools, or libvirt tools for configuring and running >> your guest? -- ie. how do you start your domU VM? We are using xl tools (sudo xl -v create ). >> When your domU is running, please could you run 'ps auxwww' in dom0 and >> obtain the process information about the qemu instance that is running, so >> that we can see what command line arguments have been supplied to it This is the log we get right after booting dom 0: root 723 0.0 0.2 243792 14468 ? Sl 15:51 0:00 /usr/local/lib/xen/bin/qemu-system-i386 -xen-domid 0 -xen-attach -name dom0 -nographic -M xenpv -daemonize -monitor /dev/null -serial /dev/null -parallel /dev/null -pidfile /var/run/xen/qemu-dom0.pid This log is seen after we launch dom U (sudo xl -v create ): root 2152 20.7 2.3 2858204 133496 ? Ssl 15:53 0:09 /usr/local/lib/xen/bin/qemu-system-i386 -xen-domid 1 -no-shutdown -chardev socket,id=libxl-cmd,path=/var/run/xen/qmp-libxl-1,server=on,wait=off -mon chardev=libxl-cmd,mode=control -chardev socket,id=libxenstat-cmd,path=/var/run/xen/qmp-libxenstat-1,server=on,wait=off -mon chardev=libxenstat-cmd,mode=control -nodefaults -no-user-config -name domu-ubuntu.hvm -vnc 127.0.0.1:0,to=99 -display sdl,gl=on -sdl -device virtio-vga-gl -boot order=dc -usb -usbdevice tablet -smp 2,maxcpus=2 -net none -machine xenfv,suppress-vmdesc=on -m 2040 -drive file=/home/amd/u2004_ubuntu.qcow2,if=ide,index=0,media=disk,format=qcow2,cache=writeback >> A little more information about what you're running will help with providing >> guidance here. The xl man page indicates that there is a "soundhw" option in >> the VM configuration file for passing sound hardware configution through to >> qemu, so if you are using the xl toolstack, you could try adding this to the >> config file: soundhw="hda" I tried giving soundhw="hda" option in the hvm config file. However, I do not hear any sound when I play a wave file in dom U. Here is the 'ps auxwww' output after making this change: root 2568 14.8 2.3 2770864 134720 ? Ssl 15:58 0:09 /usr/local/lib/xen/bin/qemu-system-i386 -xen-domid 2 -no-shutdown -chardev socket,id=libxl-cmd,path=/var/run/xen/qmp-libxl-2,server=on,wait=off -mon chardev=libxl-cmd,mode=control -chardev socket,id=libxenstat-cmd,path=/var/run/xen/qmp-libxenstat-2,server=on,wait=off -mon chardev=libxenstat-cmd,mode=control -nodefaults -no-user-config -name domu-ubuntu-audio.hvm -vnc 127.0.0.1:0,to=99 -display sdl,gl=on -sdl -device virtio-vga-gl -boot order=dc -usb -usbdevice tablet -soundhw hda -smp 2,maxcpus=2 -net none -machine xenfv,suppress-vmdesc=on -m 2040 -drive file=/home/amd/u2004_ubuntu.qcow2,if=ide,index=0,media=disk,format=qcow2,cache=writeback Also, I tried giving soundhw="all" in the config file, however this throws following error: libxl: error: libxl_dm.c:3130:device_model_spawn_outcome: Domain 4:domain 4 device model: spawn failed (rc=-3) libxl: error: libxl_dm.c:3350:device_model_postconfig_done: Domain 4:Post DM startup configs failed, rc=-3 libxl: error: libxl_create.c:1867:domcreate_devmodel_started: Domain 4:device model did not start: -3 libxl: error: libxl_aoutils.c:646:libxl__kill_xs_path: Device Model already exited libxl: error: libxl_domain.c:1183:libxl__destroy_domid: Domain 4:Non-existant domain libxl: error: libxl_domain.c:1137:domain_destroy_callback: Domain 4:Unable to destroy guest libxl: error: libxl_domain.c:1064:domain_destroy_cb: Domain 4:Destruction of domain failed Can you please let me know what parameters I should use in the config file to play audio from dom U? Regards, Jyotirmoy -Original Message- From: Christopher Clark Sent: Tuesday, July 26, 2022 2:44 AM To: SHARMA, JYOTIRMOY Cc: xen-devel@lists.xenproject.org; xen-us...@lists.xenproject.org Subject: Re: Enable audio virtualization in Xen [CAUTION: External Email] On Mon, Jul 25, 2022 at 4:45 AM SHARMA, JYOTIRMOY wrote: > > [AMD Official Use Only - General] > > > Hi all, Hi Jyotirmoy, I have add the xen-users list to CC since this thread may be useful to that forum. > I am using ubuntu as dom 0 and also do
Enable audio virtualization in Xen
[AMD Official Use Only - General] Hi all, I am using ubuntu as dom 0 and also dom U (HVM). I want to play audio from "dom U" Ubuntu. I am new to Xen/virtualization in general. >From various reading I understood that I need to take following approach: 1. Use Xen front end ALSA driver in dom U 2. Use Qemu to connect to the backend ALSA driver in Dom 0 Can you please let me know if this approach is fine? If yes, I have following questions: 1. Do I need to recompile Ubuntu to support Xen front end ALSA driver? Or will Ubuntu iso file already have it enabled? 2. Ho do I configure Qemu to enable backend driver? Regards, Jyotirmoy