libxl: add PV sound device
cover libxl: add PV sound device
From: Oleksandr Grytsov <[email protected]>
This patch set adds PV sound device support to xl.cfg and xl. See sndif.h for protocol implementation details.
Oleksandr Grytsov (5):
libxl: add PV sound device
libxl: add vsnd list and info
xl: add PV sound condif parser
xl: add vsnd CLI commands
docs: add PV sound device config
docs/man/xl.cfg.pod.5.in | 150 ++++++++ docs/man/xl.pod.1.in | 30 ++ tools/libxl/Makefile | 2 +- tools/libxl/libxl.h | 24 ++ tools/libxl/libxl_create.c | 1 + tools/libxl/libxl_internal.h | 1 + tools/libxl/libxl_types.idl | 83 +++++ tools/libxl/libxl_types_internal.idl | 1 + tools/libxl/libxl_utils.h | 3 + tools/libxl/libxl_vsnd.c | 660 +++++++++++++++++++++++++++++++++++ tools/xl/Makefile | 2 +- tools/xl/xl.h | 3 + tools/xl/xl_cmdtable.c | 15 + tools/xl/xl_parse.c | 250 +++++++++++++ tools/xl/xl_parse.h | 1 + tools/xl/xl_vsnd.c | 203 +++++++++++ 16 files changed, 1427 insertions(+), 2 deletions(-) create mode 100644 tools/libxl/libxl_vsnd.c create mode 100644 tools/xl/xl_vsnd.c
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 1/5 libxl: add PV sound device
From: Oleksandr Grytsov <[email protected]>
Add PV sound device described in sndif.h
--- tools/libxl/Makefile | 2 +- tools/libxl/libxl.h | 14 ++ tools/libxl/libxl_create.c | 1 + tools/libxl/libxl_internal.h | 1 + tools/libxl/libxl_types.idl | 64 ++++++++ tools/libxl/libxl_types_internal.idl | 1 + tools/libxl/libxl_vsnd.c | 307 +++++++++++++++++++++++++++++++++++ 7 files changed, 389 insertions(+), 1 deletion(-) create mode 100644 tools/libxl/libxl_vsnd.c
tools/libxl/Makefile +1 -1
@@ -138,7 +138,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \ libxl_dom_suspend.o libxl_dom_save.o libxl_usb.o \ libxl_vtpm.o libxl_nic.o libxl_disk.o libxl_console.o \ libxl_cpupool.o libxl_mem.o libxl_sched.o libxl_tmem.o \ - libxl_9pfs.o libxl_domain.o libxl_vdispl.o \ + libxl_9pfs.o libxl_domain.o libxl_vdispl.o libxl_vsnd.o \ $(LIBXL_OBJS-y) LIBXL_OBJS += libxl_genid.o LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
tools/libxl/libxl.h +14 -0
@@ -1913,6 +1913,20 @@ int libxl_device_vdispl_getinfo(libxl_ctx *ctx, uint32_t domid, libxl_vdisplinfo *vdisplinfo)LIBXL_EXTERNAL_CALLERS_ONLY ; +/* Virtual sounds */ +int libxl_device_vsnd_add(libxl_ctx *ctx, uint32_t domid, + libxl_device_vsnd *vsnd, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; +int libxl_device_vsnd_remove(libxl_ctx *ctx, uint32_t domid, + libxl_device_vsnd *vsnd, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; +int libxl_device_vsnd_destroy(libxl_ctx *ctx, uint32_t domid, + libxl_device_vsnd *vsnd, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; +/* Keyboard */ int libxl_device_vkb_add (libxl_ctx *ctx,uint32_t domid,libxl_device_vkb *vkb,const libxl_asyncop_how *ao_how)
tools/libxl/libxl_create.c +1 -0
@@ -1449,6 +1449,7 @@ const struct libxl_device_type *device_type_tbl[] = { &libxl__pcidev_devtype, &libxl__dtdev_devtype, &libxl__vdispl_devtype, + &libxl__vsnd_devtype, NULL };
tools/libxl/libxl_internal.h +1 -0
@@ -3575,6 +3575,7 @@ extern const struct libxl_device_type libxl__usbdev_devtype;extern const struct libxl_device_type libxl__pcidev_devtype;extern const struct libxl_device_type libxl__vdispl_devtype;extern const struct libxl_device_type libxl__p9_devtype; +extern const struct libxl_device_type libxl__vsnd_devtype;extern const struct libxl_device_type *device_type_tbl[];
tools/libxl/libxl_types.idl +64 -0
76 lines not on this page · raw message
tools/libxl/libxl_types_internal.idl +1 -0
@@ -27,6 +27,7 @@ libxl__device_kind = Enumeration("device_kind", [ (10, "QUSB"), (11, "9PFS"), (12, "VDISPL"), + (13, "VSND") ]) libxl__console_backend = Enumeration("console_backend", [
tools/libxl/libxl_vsnd.c new file +307 -0
307 lines not on this page · raw message
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 2/5 libxl: add vsnd list and info
In reply to Oleksandr GrytsovFrom: Oleksandr Grytsov <[email protected]>
Add getting vsnd list amd info API
--- tools/libxl/libxl.h | 10 ++ tools/libxl/libxl_types.idl | 19 +++ tools/libxl/libxl_utils.h | 3 + tools/libxl/libxl_vsnd.c | 359 +++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 388 insertions(+), 3 deletions(-)
tools/libxl/libxl.h +10 -0
@@ -1927,6 +1927,16 @@ int libxl_device_vsnd_destroy(libxl_ctx *ctx, uint32_t domid, const libxl_asyncop_how *ao_how)LIBXL_EXTERNAL_CALLERS_ONLY ; +libxl_device_vsnd *libxl_device_vsnd_list (libxl_ctx *ctx, +uint32_t domid,int *num) +LIBXL_EXTERNAL_CALLERS_ONLY ; +void libxl_device_vsnd_list_free(libxl_device_vsnd* list, int num) + LIBXL_EXTERNAL_CALLERS_ONLY; +int libxl_device_vsnd_getinfo(libxl_ctx *ctx, uint32_t domid, + libxl_device_vsnd *vsnd, + libxl_vsndinfo *vsndlinfo) + LIBXL_EXTERNAL_CALLERS_ONLY; +/* Keyboard */ int libxl_device_vkb_add (libxl_ctx *ctx,uint32_t domid,libxl_device_vkb *vkb,const libxl_asyncop_how *ao_how)
tools/libxl/libxl_types.idl +19 -0
@@ -988,6 +988,25 @@ libxl_vdisplinfo = Struct("vdisplinfo", [ ("connectors", Array(libxl_connectorinfo, "num_connectors")) ], dir=DIR_OUT) +libxl_streaminfo = Struct("streaminfo", [ + ("req_evtch", integer), + ("req_rref", integer) + ]) + +libxl_pcminfo = Struct("pcminfo", [ + ("streams", Array(libxl_streaminfo, "num_vsnd_streams")) + ]) + +libxl_vsndinfo = Struct("vsndinfo", [ + ("backend", string), + ("backend_id", uint32), + ("frontend", string), + ("frontend_id", uint32), + ("devid", libxl_devid), + ("state", integer), + ("pcms", Array(libxl_pcminfo, "num_vsnd_pcms")) + ]) + # NUMA node characteristics: size and free are how much memory it has, and how # much of it is free, respectively. dists is an array of distances from this # node to each other node.
tools/libxl/libxl_utils.h +3 -0
@@ -82,6 +82,9 @@ int libxl_devid_to_device_usbctrl(libxl_ctx *ctx, uint32_t domid,int libxl_devid_to_device_vdispl (libxl_ctx *ctx,uint32_t domid,int devid,libxl_device_vdispl *vdispl); +int libxl_devid_to_device_vsnd (libxl_ctx *ctx,uint32_t domid, +int devid,libxl_device_vsnd *vsnd); +int libxl_ctrlport_to_device_usbdev (libxl_ctx *ctx,uint32_t domid,int ctrl,int port,libxl_device_usbdev *usbdev);
tools/libxl/libxl_vsnd.c +356 -3
386 lines not on this page · raw message
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 3/5 xl: add PV sound condif parser
In reply to Oleksandr GrytsovFrom: Oleksandr Grytsov <[email protected]>
Add config parser for virtual sound devices
--- tools/xl/xl_parse.c | 250 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/xl/xl_parse.h | 1 + 2 files changed, 251 insertions(+)
tools/xl/xl_parse.c +250 -0
@@ -851,6 +851,254 @@ out:return rc; } +static int parse_vsnd_params (libxl_vsnd_params *params,char *token) +{ +char *oparg; + +if (MATCH_OPTION ("sample-rates" , token, oparg)) { +int i; +libxl_string_list rates =NULL ; + +split_string_into_string_list (oparg,";" , &rates); + + params->num_sample_rates =libxl_string_list_length (&rates); + params->sample_rates =calloc (params->num_sample_rates, +sizeof (*params->sample_rates)); + +for (i =0 ; i < params->num_sample_rates; i++) { + params->sample_rates[i] =strtoul (rates[i],NULL ,0 ); + } + +libxl_string_list_dispose (&rates); + }else if (MATCH_OPTION ("sample-formats" , token, oparg)) { +int i; +libxl_string_list formats =NULL ; + +split_string_into_string_list (oparg,";" , &formats); + + params->num_sample_formats =libxl_string_list_length (&formats); + params->sample_formats =calloc (params->num_sample_formats, +sizeof (*params->sample_formats)); + +for (i =0 ; i < params->num_sample_formats; i++) { +libxl_vsnd_pcm_format format; + +if (libxl_vsnd_pcm_format_from_string (formats[i], &format)) { +fprintf (stderr,"Invalid pcm format: %s\n" , formats[i]); +exit (EXIT_FAILURE ); + } + + params->sample_formats[i] = format; + } + +libxl_string_list_dispose (&formats); + }else if (MATCH_OPTION ("channels-min" , token, oparg)) { + params->channels_min =strtoul (oparg,NULL ,0 ); + }else if (MATCH_OPTION ("channels-max" , token, oparg)) { + params->channels_max =strtoul (oparg,NULL ,0 ); + }else if (MATCH_OPTION ("buffer-size" , token, oparg)) { + params->buffer_size =strtoul (oparg,NULL ,0 ); + }else { +return 1 ; + } + +return 0 ; +} + +static int parse_vsnd_pcm_stream (libxl_device_vsnd *vsnd,char *param) +{ +if (vsnd->num_vsnd_pcms ==0 ) { +fprintf (stderr,"No vsnd pcm device\n" ); +return -1 ; + } + +libxl_vsnd_pcm *pcm = &vsnd->pcms[vsnd->num_vsnd_pcms -1 ]; + +if (pcm->num_vsnd_streams ==0 ) { +fprintf (stderr,"No vsnd stream\n" ); +return -1 ; + } + +libxl_vsnd_stream *stream = &pcm->streams[pcm->num_vsnd_streams -1 ]; + +if (parse_vsnd_params (&stream->params, param)) { +char *oparg; + +if (MATCH_OPTION ("id" , param, oparg)) { + stream->id =strtoul (oparg,NULL ,0 ); + }else if (MATCH_OPTION ("type" , param, oparg)) { + +if (libxl_vsnd_stream_type_from_string (oparg, &stream->type)) { +fprintf (stderr,"Invalid stream type: %s\n" , oparg); +return -1 ; + } + }else { +fprintf (stderr,"Invalid parameter: %s\n" , param); +return -1 ; + } + } + +return 0 ; +} + +static int parse_vsnd_pcm_param (libxl_device_vsnd *vsnd,char *param) +{ +if (vsnd->num_vsnd_pcms ==0 ) { +fprintf (stderr,"No pcm device\n" ); +return -1 ; + } + +libxl_vsnd_pcm *pcm = &vsnd->pcms[vsnd->num_vsnd_pcms -1 ]; + +if (parse_vsnd_params (&pcm->params, param)) { +char *oparg; + +if (MATCH_OPTION ("name" , param, oparg)) { + pcm->name =strdup (oparg); + }else { +fprintf (stderr,"Invalid parameter: %s\n" , param); +return -1 ; + } + } + +return 0 ; +} + +static int parse_vsnd_card_param (libxl_device_vsnd *vsnd,char *param) +{ +if (parse_vsnd_params (&vsnd->params, param)) { +char *oparg; + +if (MATCH_OPTION ("backend" , param, oparg)) { + vsnd->backend_domname =strdup (oparg); + }else if (MATCH_OPTION ("short-name" , param, oparg)) { + vsnd->short_name =strdup (oparg); + }else if (MATCH_OPTION ("long-name" , param, oparg)) { + vsnd->long_name =strdup (oparg); + }else { +fprintf (stderr,"Invalid parameter: %s\n" , param); +return -1 ; + } + } + +return 0 ; +} + +static int parse_vsnd_create_item (libxl_device_vsnd *vsnd,const char *key) +{ +if (strcasecmp (key,"card" ) ==0 ) { + + }else if (strcasecmp (key,"pcm" ) ==0 ) { +ARRAY_EXTEND_INIT_NODEVID (vsnd->pcms, vsnd->num_vsnd_pcms, + libxl_vsnd_pcm_init); + }else if (strcasecmp (key,"stream" ) ==0 ) { +if (vsnd->num_vsnd_pcms ==0 ) { +ARRAY_EXTEND_INIT_NODEVID (vsnd->pcms, vsnd->num_vsnd_pcms, + libxl_vsnd_pcm_init); + } + +libxl_vsnd_pcm *pcm = &vsnd->pcms[vsnd->num_vsnd_pcms -1 ]; + +ARRAY_EXTEND_INIT_NODEVID (pcm->streams, pcm->num_vsnd_streams, + libxl_vsnd_stream_init); + }else { +fprintf (stderr,"Invalid key: %s\n" , key); +return -1 ; + } + +return 0 ; +} + +int parse_vsnd_item (libxl_device_vsnd *vsnd,const char *spec) +{ +char *buf =strdup (spec); +char *token =strtok (buf,"," ); +char *key =NULL ; +int ret; + +while (token) { +while (*token ==' ' ) token++; + +if (!key) { + key = token; + ret =parse_vsnd_create_item (vsnd, key); +if (ret) goto out; + }else { +if (strcasecmp (key,"card" ) ==0 ) { + ret =parse_vsnd_card_param (vsnd, token); +if (ret) goto out; + }else if (strcasecmp (key,"pcm" ) ==0 ) { + ret =parse_vsnd_pcm_param (vsnd, token); +if (ret) goto out; + }else if (strcasecmp (key,"stream" ) ==0 ) { + ret =parse_vsnd_pcm_stream (vsnd, token); +if (ret) goto out; + } + } + token =strtok (NULL ,"," ); + } + + ret =0 ; + +out: +free (buf); +return ret; +} + +static void parse_vsnd_card_config (const XLU_Config *config, +XLU_ConfigValue *card_value, +libxl_domain_config *d_config) +{ +int ret; + +XLU_ConfigList *card_list; + +// get card + ret =xlu_cfg_value_get_list (config, card_value, &card_list,0 ); + +if (ret) { +fprintf (stderr,"Failed to get vsnd card list: %s\n" ,strerror (ret)); + goto out; + } + +libxl_device_vsnd *vsnd; + + vsnd =ARRAY_EXTEND_INIT (d_config->vsnds, + d_config->num_vsnds, + libxl_device_vsnd_init); + +const char *card_item; +int item =0 ; + +while ((card_item =xlu_cfg_get_listitem (card_list, item++)) !=NULL ) { + ret =parse_vsnd_item (vsnd, card_item); +if (ret) goto out; + } + + ret =0 ; + +out: +if (ret)exit (EXIT_FAILURE ); +} + +static void parse_vsnd_config (const XLU_Config *config, +libxl_domain_config *d_config) +{ +XLU_ConfigList *vsnds; + +if (!xlu_cfg_get_list (config,"vsnd" , &vsnds,0 ,0 )) { +XLU_ConfigValue *card_value; + + d_config->num_vsnds =0 ; + d_config->vsnds =NULL ; + +while ((card_value =xlu_cfg_get_listitem2 (vsnds, d_config->num_vsnds)) + !=NULL ) { +parse_vsnd_card_config (config, card_value, d_config); + } + } +} + void parse_config_data(const char *config_source, const char *config_data, int config_len,
@@ -1564,6 +1812,8 @@ void parse_config_data(const char *config_source, } } +parse_vsnd_config (config, d_config); +if (!xlu_cfg_get_list (config,"channel" , &channels,0 ,0 )) { d_config->num_channels =0 ; d_config->channels =NULL ;
tools/xl/xl_parse.h +1 -0
@@ -34,6 +34,7 @@ int parse_usbdev_config(libxl_device_usbdev *usbdev, char *token);int parse_cpurange (const char *cpu,libxl_bitmap *cpumap);int parse_nic_config (libxl_device_nic *nic,XLU_Config **config,char *token);int parse_vdispl_config (libxl_device_vdispl *vdispl,char *token); +int parse_vsnd_item (libxl_device_vsnd *vsnd,const char *spec);int match_option_size (const char *prefix,size_t len,char *arg,char **argopt);
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 4/5 xl: add vsnd CLI commands
In reply to Oleksandr GrytsovFrom: Oleksandr Grytsov <[email protected]>
Add CLI commands to attach, detach and list virtual sound devices
--- tools/xl/Makefile | 2 +- tools/xl/xl.h | 3 + tools/xl/xl_cmdtable.c | 15 ++++ tools/xl/xl_vsnd.c | 203 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 tools/xl/xl_vsnd.c
tools/xl/Makefile +1 -1
@@ -22,7 +22,7 @@ XL_OBJS += xl_vtpm.o xl_block.o xl_nic.o xl_usb.o XL_OBJS += xl_sched.o xl_pci.o xl_vcpu.o xl_cdrom.o xl_mem.o XL_OBJS += xl_info.o xl_console.o xl_misc.o XL_OBJS += xl_vmcontrol.o xl_saverestore.o xl_migrate.o -XL_OBJS += xl_vdispl.o +XL_OBJS += xl_vdispl.o xl_vsnd.o $(XL_OBJS): CFLAGS += $(CFLAGS_libxentoollog) $(XL_OBJS): CFLAGS += $(CFLAGS_XL)
tools/xl/xl.h +3 -0
@@ -170,6 +170,9 @@ int main_vtpmdetach(int argc, char **argv);int main_vdisplattach (int argc,char **argv);int main_vdispllist (int argc,char **argv);int main_vdispldetach (int argc,char **argv); +int main_vsndattach (int argc,char **argv); +int main_vsndlist (int argc,char **argv); +int main_vsnddetach (int argc,char **argv);int main_usbctrl_attach (int argc,char **argv);int main_usbctrl_detach (int argc,char **argv);int main_usbdev_attach (int argc,char **argv);
tools/xl/xl_cmdtable.c +15 -0
@@ -397,6 +397,21 @@ struct cmd_spec cmd_table[] = {"Destroy a domain's virtual display device" ,"<Domain> <DevId>" , }, + { "vsnd-attach", + &main_vsndattach,1 ,1 , +"Create a new virtual sound device" , +"<Domain> <vsnd-spec-component(s)>..." , + }, + { "vsnd-list", + &main_vsndlist,0 ,0 , +"List virtual display devices for a domain" , +"<Domain(s)>" , + }, + { "vsnd-detach", + &main_vsnddetach,0 ,1 , +"Destroy a domain's virtual sound device" , +"<Domain> <DevId>" , + }, { "uptime", &main_uptime,0 ,0 , "Print uptime for all/some domains",
tools/xl/xl_vsnd.c new file +203 -0
203 lines not on this page · raw message
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 5/5 docs: add PV sound device config
In reply to Oleksandr GrytsovFrom: Oleksandr Grytsov <[email protected]>
Update documentation with virtual sound device
--- docs/man/xl.cfg.pod.5.in | 150 +++++++++++++++++++++++++++++++++++++++++++++++ docs/man/xl.pod.1.in | 30 ++++++++++ 2 files changed, 180 insertions(+)
docs/man/xl.cfg.pod.5.in +150 -0
@@ -1165,6 +1165,156 @@ connectors=id0:1920x1080;id1:800x600;id2:640x480 =back +=item B<vsnd=[ VCARD_SPEC, VCARD_SPEC, ... ]> + +Specifies the virtual sound cards to be provided to the guest. +Each B<VCARD_SPEC> is a list, which has a form of +"[VSND_ITEM_SPEC, VSND_ITEM_SPEC, ... ]" (without the quotes). +The virtual sound card has hierarchical structure. +Every card has a set of PCM devices and streams, each could be individually +configured. + +B<VSND_ITEM_SPEC> describes individual item parameters. +B<VSND_ITEM_SPEC> is a string of comma separated item parameters +headed by item identifier. Each item parameter is C<KEY=VALUE> pair: + +=over 4 + +"identifier, param = value, ...". + +=back + +Identifier shall be one of following values: "CARD", "PCM", "STREAM". +The child item treated as belonging to the previously defined parent +item. + +All parameters are optional. + +There are group of parameters which are common for all items. +This group can be defined at higher level of the hierarchy and be fully or +partially re-used by the underlying layers. These parameters are: + +=over 4 + +* number of channels (min/max) + +* supported sample rates + +* supported sample formats + +=back + +E.g. one can define these values for the whole card, device or stream. +Every underlying layer in turn can re-define some or all of them to better +fit its needs. For example, card may define number of channels to be +in [1; 8] range, and some particular stream may be limited to [1; 2] only. +The rule is that the underlying layer must be a subset of the upper layer +range. + +I<COMMON parameters:> + +=over 4 + +=over 4 + +=item B<sample-rates=RATES> + +List of integer values separated by semicolon: sample-rates=8000;22050;44100 + +=item B<sample-formats=FORMATS> + +List of string values separated by semicolon: sample-formats=s16_le;s8;u32_be + +Supported formats: s8, u8, s16_le, s16_be, u16_le, u16_be, s24_le, s24_be, +u24_le, u24_be, s32_le, s32_be, u32_le, u32_be, float_le, float_be, +float64_le, float64_be, iec958_subframe_le, iec958_subframe_be, +mu_law, a_law, ima_adpcm, mpeg, gsm + +=item B<channels-min=NUMBER> + +The minimum amount of channels. + +=item B<channels-max=NUMBER> + +The maximum amount of channels. + +=item B<buffer-size=NUMBER> + +The maximum size in octets of the buffer to allocate per stream. + +=back + +=back + +I<CARD specification:> + +=over 4 + +=over 4 + +=item B<backend=domain-id> + +Specify the backend domain name or id, defaults to dom0. + +=item B<short-name=STRING> + +Short name of the virtual sound card. + +=item B<short-name=STRING> + +Long name of the virtual sound card. + +=back + +=back + +I<PCM specification:> + +=over 4 + +=over 4 + +=item B<name=STRING> + +Name of the PCM sound device within the virtual sound card. + +=back + +=back + +I<STREAM specification:> + +=over 4 + +=over 4 + +=item B<id=NUMBER> + +Unique stream identifier. + +=item B<type=TYPE> + +Stream type: "p" - playback stream, "c" - capture stream. + +=back + +=back + +I<EXAMPLE:> + + vsnd = [ + ['CARD, short-name=Main, sample-formats=s16_le;s8;u32_be', + 'PCM, name=Main', + 'STREAM, id=0, type=p', + 'STREAM, id=1, type=c, channels-max=2' + ], + ['CARD, short-name=Second', + 'PCM, name=Second, buffer-size=1024', + 'STREAM, id=2, type=p', + 'STREAM, id=3, type=c' + ] + ] + =back =head2 Paravirtualised (PV) Guest Specific Options
docs/man/xl.pod.1.in +30 -0
@@ -1476,6 +1476,36 @@ List virtual displays for a domain. =back +=head2 VSND DEVICES + +=over 4 + +=item B<vsnd-attach> I<domain-id> I<vsnd-item> I<vsnd-item> ... + +Creates a new vsnd device in the domain specified by I<domain-id>. +I<vsnd-item>'s describe the vsnd device to attach, using the same format as the +B<VSND_ITEM_SPEC> string in the domain config file. See L<xl.cfg> for +more information. + +B<EXAMPLE> + +=over 4 + +xl vsnd-attach DomU 'CARD, short-name=Main, sample-formats=s16_le;s8;u32_be' +'PCM, name=Main' 'STREAM, id=0, type=p' 'STREAM, id=1, type=c, channels-max=2' + +=back + +=item B<vsnd-detach> I<domain-id> I<dev-id> + +Removes the vsnd device specified by I<dev-id> from the domain specified by I<domain-id>. + +=item B<vsnd-list> I<domain-id> + +List vsnd devices for a domain. + +=back + =head1 PCI PASS-THROUGH =over 4
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 34 lines · Oleksandr Grytsov
From: Oleksandr Grytsov <[email protected]>
This patch set adds PV sound device support to xl.cfg and xl. See
sndif.hfor protocol implementation details.Oleksandr Grytsov (5):
libxl: add PV sound device
libxl: add vsnd list and info
xl: add PV sound condif parser
xl: add vsnd CLI commands
docs: add PV sound device configdocs/man/xl.cfg.pod.5.in | 150 ++++++++ docs/man/xl.pod.1.in | 30 ++ tools/libxl/Makefile | 2 +- tools/libxl/libxl.h | 24 ++ tools/libxl/libxl_create.c | 1 + tools/libxl/libxl_internal.h | 1 + tools/libxl/libxl_types.idl | 83 +++++ tools/libxl/libxl_types_internal.idl | 1 + tools/libxl/libxl_utils.h | 3 + tools/libxl/libxl_vsnd.c | 660 ++++++++++++++++++++++++++++++ +++++ tools/xl/Makefile | 2 +- tools/xl/xl.h | 3 + tools/xl/xl_cmdtable.c | 15 + tools/xl/xl_parse.c | 250 +++++++++++++ tools/xl/xl_parse.h | 1 + tools/xl/xl_vsnd.c | 203 +++++++++++ 16 files changed, 1427 insertions(+), 2 deletions(-) create mode 100644 tools/libxl/libxl_vsnd.c create mode 100644 tools/xl/xl_vsnd.c
Quoted 4 lines
--
2.7.4
ping
Signature · 2 lines
Best Regards, Oleksandr Grytsov.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 41 lines · Oleksandr Grytsov
Quoted 34 lines · Oleksandr Grytsov
From: Oleksandr Grytsov <[email protected]>
This patch set adds PV sound device support to xl.cfg and xl. See
sndif.hfor protocol implementation details.Oleksandr Grytsov (5):
libxl: add PV sound device
libxl: add vsnd list and info
xl: add PV sound condif parser
xl: add vsnd CLI commands
docs: add PV sound device configdocs/man/xl.cfg.pod.5.in | 150 ++++++++ docs/man/xl.pod.1.in | 30 ++ tools/libxl/Makefile | 2 +- tools/libxl/libxl.h | 24 ++ tools/libxl/libxl_create.c | 1 + tools/libxl/libxl_internal.h | 1 + tools/libxl/libxl_types.idl | 83 +++++ tools/libxl/libxl_types_internal.idl | 1 + tools/libxl/libxl_utils.h | 3 + tools/libxl/libxl_vsnd.c | 660 ++++++++++++++++++++++++++++++ +++++ tools/xl/Makefile | 2 +- tools/xl/xl.h | 3 + tools/xl/xl_cmdtable.c | 15 + tools/xl/xl_parse.c | 250 +++++++++++++ tools/xl/xl_parse.h | 1 + tools/xl/xl_vsnd.c | 203 +++++++++++ 16 files changed, 1427 insertions(+), 2 deletions(-) create mode 100644 tools/libxl/libxl_vsnd.c create mode 100644 tools/xl/xl_vsnd.cQuoted 4 lines
--
2.7.4
Quoted 6 lines
ping
--
Best Regards,
Oleksandr Grytsov.
ping
Signature · 2 lines
Best Regards, Oleksandr Grytsov.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 5 lines · Oleksandr Grytsov
From: Oleksandr Grytsov <[email protected]>
Add PV sound device described in
sndif.hSigned-off-by Oleksandr Grytsov <[email protected]>
[...]
Quoted 15 lines
libxl__console_backend= Enumeration("console_backend", [tools/libxl/libxl_vsnd.c new file +7
-0@@ -0,0 +1,307 @@ +/* +* Copyright (C) 2016 EPAM Systems Inc. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published +* by the Free Software Foundation; version 2.1 only. with the special +* exception on linking described in file LICENSE.
tools/libxl/libxl_vsnd.c line 17
Quoted 10 lines
tools/libxl/libxl_vsnd.c new file +10
-0+* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +*/ + +#include "libxl_internal.h" +#include "xen/io/sndif.h" +
Use <xen/io/sndif.h> -- this is not a local header.
tools/libxl/libxl_vsnd.c line 86
Quoted 12 lines
tools/libxl/libxl_vsnd.c new file +12
-0+ +static unsigned int libxl__rates_to_str_vsnd (char *str,uint32_t *sample_rates, +int num_sample_rates) +{ +unsigned int len; +int i; + + len =0 ; + +if (num_sample_rates ==0 ) { +return len; + }
Coding style.
tools/libxl/libxl_vsnd.c line 90
Quoted 4 lines
tools/libxl/libxl_vsnd.c new file +4
-0+ +for (i =0 ; i < num_sample_rates -1 ; i++) { +if (str) { + len +=sprintf (&str[len],"%u," , sample_rates[i]);
libxl__sprintf(NOGC, ...)
Quoted 14 lines
tools/libxl/libxl_vsnd.c new file +14
-0+ }else { + len +=snprintf (NULL ,0 ,"%u," , sample_rates[i]); + } + } + +if (str) { + len +=sprintf (&str[len],"%u" , sample_rates[i]); + }else { + len +=snprintf (NULL ,0 ,"%u" , sample_rates[i]); + } + +return len; +} +
[...]
tools/libxl/libxl_vsnd.c line 147
Quoted 10 lines
tools/libxl/libxl_vsnd.c new file +10
-0+ +static int libxl__set_params_vsnd (libxl__gc *gc,char *path, +libxl_vsnd_params *params,flexarray_t *front) +{ +char *buffer; +int len; +int rc; + +if (params->sample_rates) { +// calculate required string size;
Coding style.
tools/libxl/libxl_vsnd.c line 159
Quoted 12 lines
tools/libxl/libxl_vsnd.c new file +12
-0+ len =libxl__rates_to_str_vsnd (NULL , params->sample_rates, + params->num_sample_rates); + +if (len) { + buffer =libxl__malloc (gc, len +1 ); + +libxl__rates_to_str_vsnd (buffer, params->sample_rates, + params->num_sample_rates); + rc =flexarray_append_pair (front, +GCSPRINTF ("%s" XENSND_FIELD_SAMPLE_RATES , + path), buffer); +if (rc)return rc;
goto out please.
Please fix these coding style issues throughout this series.j
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/5] libxl: add vsnd list and info
In reply to Oleksandr GrytsovQuoted 5 lines · Oleksandr Grytsov
From: Oleksandr Grytsov <[email protected]>
Add getting vsnd list amd info API
Signed-off-by Oleksandr Grytsov <[email protected]>
Same comments for previous patch apply here, too.
Quoted 8 lines
--- tools/libxl/libxl.h | 10 ++ tools/libxl/libxl_types.idl | 19 +++ tools/libxl/libxl_utils.h | 3 + tools/libxl/libxl_vsnd.c | 359 +++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 388 insertions(+), 3 deletions(-)
[...]
tools/libxl/libxl_vsnd.c static int libxl__device_from_vsnd(libxl__gc *gc, uint32_t domid, · line 51
Quoted 12 lines
tools/libxl/libxl_vsnd.c +12
-0+static int libxl__sample_rates_from_string (libxl__gc *gc,const char *str, +libxl_vsnd_params *params) +{ +char *tmp =libxl__strdup (gc, str); + + params->num_sample_rates =0 ; + params->sample_rates =NULL ; + +char *p =strtok (tmp," ," ); + +while (p !=NULL ) { + params->sample_rates = realloc(params->sample_rates,
libxl__realloc(NOGC, ...)
[...]
tools/libxl/libxl_vsnd.c static int libxl__device_from_vsnd(libxl__gc *gc, uint32_t domid, · line 183
Quoted 5 lines
tools/libxl/libxl_vsnd.c +5
-0+ +static int libxl__pcm_from_xenstore (libxl__gc *gc,const char *path, +libxl_vsnd_pcm *pcm) +{ +libxl_ctx *ctx =libxl__gc_owner (gc);
You can use CTX throughout.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 3/5] xl: add PV sound condif parser
In reply to Oleksandr Grytsovtools/xl/xl_parse.c out: · line 1056
Quoted 9 lines · Oleksandr Grytsov
tools/xl/xl_parse.c +9
-0+static void parse_vsnd_card_config (const XLU_Config *config, +XLU_ConfigValue *card_value, +libxl_domain_config *d_config) +{ +int ret; + +XLU_ConfigList *card_list; + +// get card
Please delete this.
Quoted 6 lines
tools/xl/xl_parse.c +6
-0+ ret =xlu_cfg_value_get_list (config, card_value, &card_list,0 ); + +if (ret) { +fprintf (stderr,"Failed to get vsnd card list: %s\n" ,strerror (ret)); + goto out; + }
tools/xl/xl_parse.c out: · line 1072
Quoted 10 lines
tools/xl/xl_parse.c +10
-0+ +libxl_device_vsnd *vsnd; + + vsnd =ARRAY_EXTEND_INIT (d_config->vsnds, + d_config->num_vsnds, + libxl_device_vsnd_init); + +const char *card_item; +int item =0 ; +
Mixing code and declarations will break.
tools/xl/xl_parse.c out: · line 1082
Quoted 10 lines
tools/xl/xl_parse.c +10
-0+while ((card_item =xlu_cfg_get_listitem (card_list, item++)) !=NULL ) { + ret =parse_vsnd_item (vsnd, card_item); +if (ret) goto out; + } + + ret =0 ; + +out: +if (ret)exit (EXIT_FAILURE ); +}
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 4/5] xl: add vsnd CLI commands
In reply to Oleksandr GrytsovQuoted 5 lines · Oleksandr Grytsov
From: Oleksandr Grytsov <[email protected]>
Add CLI commands to attach, detach and list virtual sound devices
Signed-off-by Oleksandr Grytsov <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 5/5] docs: add PV sound device config
In reply to Oleksandr Grytsovdocs/man/xl.cfg.pod.5.in connectors=id0:1920x1080;id1:800x600;id2:640x480 · line 1267
Quoted 9 lines · Oleksandr Grytsov
+=item B<short-name=STRING>
docs/man/xl.cfg.pod.5.in +8
-0+ +Short name of the virtual sound card. + +=item B<short-name=STRING> + +Long name of the virtual sound card. + +=back
Duplicate short-name=, should be name= ?
Signature · 5 lines
Best Regards, Marek Marczykowski-Górecki Invisible Things Lab A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing?
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 79 lines · Wei Liu
Quoted 5 lines · Oleksandr Grytsov
From: Oleksandr Grytsov <[email protected]>
Add PV sound device described in
sndif.hSigned-off-by Oleksandr Grytsov <[email protected]>[...]
tools/libxl/libxl_vsnd.c line 5
Quoted 13 lines
libxl__console_backend= Enumeration("console_backend", [tools/libxl/libxl_vsnd.c new file +5
-0@@ -0,0 +1,307 @@ +/* +* Copyright (C) 2016 EPAM Systems Inc. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published
tools/libxl/libxl_vsnd.c line 17
Quoted 12 lines
tools/libxl/libxl_vsnd.c new file +12
-0+* by the Free Software Foundation; version 2.1 only. with the special +* exception on linking described in file LICENSE. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +*/ + +#include "libxl_internal.h" +#include "xen/io/sndif.h" +Use <
xen/io/sndif.h> -- this is not a local header.tools/libxl/libxl_vsnd.c line 19
Quoted 2 lines
tools/libxl/libxl_vsnd.c new file +2
-0+ +static unsigned int libxl__rates_to_str_vsnd(char *str, uint32_t
*sample_rates,tools/libxl/libxl_vsnd.c line 86
Quoted 10 lines
tools/libxl/libxl_vsnd.c new file +10
-0+ int num_sample_rates) +{ +unsigned int len; +int i; + + len =0 ; + +if (num_sample_rates ==0 ) { +return len; + }Coding style.
tools/libxl/libxl_vsnd.c line 90
Quoted 4 lines
tools/libxl/libxl_vsnd.c new file +4
-0+ +for (i =0 ; i < num_sample_rates -1 ; i++) { +if (str) { + len +=sprintf (&str[len],"%u," , sample_rates[i]);
libxl__sprintf(NOGC, ...)Quoted 14 lines
tools/libxl/libxl_vsnd.c new file +14
-0+ }else { + len +=snprintf (NULL ,0 ,"%u," , sample_rates[i]); + } + } + +if (str) { + len +=sprintf (&str[len],"%u" , sample_rates[i]); + }else { + len +=snprintf (NULL ,0 ,"%u" , sample_rates[i]); + } + +return len; +} +[...]
tools/libxl/libxl_vsnd.c
Quoted 3 lines
tools/libxl/libxl_vsnd.c new file +3
-0+ +static int libxl__set_params_vsnd(libxl__gc *gc, char *path, + libxl_vsnd_params *params,
flexarray_t*front)
Quoted 9 lines
tools/libxl/libxl_vsnd.c line 147
Quoted 7 lines
tools/libxl/libxl_vsnd.c new file +7
-0+{ +char *buffer; +int len; +int rc; + +if (params->sample_rates) { +// calculate required string size; Coding style.
Sorry, could you specify more precisely what has to be changed in this place?
Quoted 19 lines
tools/libxl/libxl_vsnd.c
Quoted 11 lines
tools/libxl/libxl_vsnd.c new file +10
-0+ len =libxl__rates_to_str_vsnd (NULL , params->sample_rates, + params->num_sample_rates); + +if (len) { + buffer =libxl__malloc (gc, len +1 ); + +libxl__rates_to_str_vsnd (buffer, params->sample_rates, + params->num_sample_rates); + rc = flexarray_append_pair(front, + GCSPRINTF("%s"XENSND_FIELD_
SAMPLE_RATES,tools/libxl/libxl_vsnd.c
Quoted 2 lines
tools/libxl/libxl_vsnd.c new file +2
-0+ path), buffer); +if (rc)return rc;goto out please.
Please fix these coding style issues throughout this series.j
Signature · 2 lines
Best Regards, Oleksandr Grytsov.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 10 lines · Oleksandr Grytsov
Quoted 5 lines
tools/libxl/libxl_vsnd.c line 147
Quoted 3 lines
tools/libxl/libxl_vsnd.c new file +3
-0+ +if (params->sample_rates) { +// calculate required string size; Coding style.
Sorry, could you specify more precisely what has to be changed in this place?
We use /* ... */ for comments.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 53 lines · Wei Liu
Quoted 5 lines · Oleksandr Grytsov
From: Oleksandr Grytsov <[email protected]>
Add PV sound device described in
sndif.hSigned-off-by Oleksandr Grytsov <[email protected]>[...]
tools/libxl/libxl_vsnd.c line 5
Quoted 13 lines
libxl__console_backend= Enumeration("console_backend", [tools/libxl/libxl_vsnd.c new file +5
-0@@ -0,0 +1,307 @@ +/* +* Copyright (C) 2016 EPAM Systems Inc. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published
tools/libxl/libxl_vsnd.c line 17
Quoted 12 lines
tools/libxl/libxl_vsnd.c new file +12
-0+* by the Free Software Foundation; version 2.1 only. with the special +* exception on linking described in file LICENSE. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +*/ + +#include "libxl_internal.h" +#include "xen/io/sndif.h" +Use <
xen/io/sndif.h> -- this is not a local header.tools/libxl/libxl_vsnd.c line 19
Quoted 2 lines
tools/libxl/libxl_vsnd.c new file +2
-0+ +static unsigned int libxl__rates_to_str_vsnd(char *str, uint32_t
*sample_rates,tools/libxl/libxl_vsnd.c line 86
Quoted 10 lines
tools/libxl/libxl_vsnd.c new file +10
-0+ int num_sample_rates) +{ +unsigned int len; +int i; + + len =0 ; + +if (num_sample_rates ==0 ) { +return len; + }Coding style.
Quoted 7 lines
tools/libxl/libxl_vsnd.c line 90
Quoted 4 lines
tools/libxl/libxl_vsnd.c new file +4
-0+ +for (i =0 ; i < num_sample_rates -1 ; i++) { +if (str) { + len +=sprintf (&str[len],"%u," , sample_rates[i]);
libxl__sprintf(NOGC, ...)
I need to increment len here. So libxl__sprintf is not suitable.
Quoted 48 lines
Quoted 15 lines
tools/libxl/libxl_vsnd.c new file +14
-0+ }else { + len +=snprintf (NULL ,0 ,"%u," , sample_rates[i]); + } + } + +if (str) { + len +=sprintf (&str[len],"%u" , sample_rates[i]); + }else { + len +=snprintf (NULL ,0 ,"%u" , sample_rates[i]); + } + +return len; +} +[...]
tools/libxl/libxl_vsnd.c
Quoted 3 lines
tools/libxl/libxl_vsnd.c new file +3
-0+ +static int libxl__set_params_vsnd(libxl__gc *gc, char *path, + libxl_vsnd_params *params,
flexarray_t*front)tools/libxl/libxl_vsnd.c line 147
Quoted 7 lines
tools/libxl/libxl_vsnd.c new file +7
-0+{ +char *buffer; +int len; +int rc; + +if (params->sample_rates) { +// calculate required string size; Coding style.
tools/libxl/libxl_vsnd.c
Quoted 10 lines
tools/libxl/libxl_vsnd.c new file +10
-0+ len =libxl__rates_to_str_vsnd (NULL , params->sample_rates, + params->num_sample_rates); + +if (len) { + buffer =libxl__malloc (gc, len +1 ); + +libxl__rates_to_str_vsnd (buffer, params->sample_rates, + params->num_sample_rates); + rc = flexarray_append_pair(front, + GCSPRINTF("%s"XENSND_FIELD_
SAMPLE_RATES,tools/libxl/libxl_vsnd.c
Quoted 2 lines
tools/libxl/libxl_vsnd.c new file +2
-0+ path), buffer); +if (rc)return rc;goto out please.
Please fix these coding style issues throughout this series.j
Signature · 2 lines
Best Regards, Oleksandr Grytsov.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 5/5] docs: add PV sound device config
In reply to Marek Marczykowski-GóreckiQuoted 23 lines · Marek Marczykowski-Górecki
docs/man/xl.cfg.pod.5.in connectors=id0:1920x1080;id1:800x600;id2:640x480 · line 1267
Quoted 9 lines · Oleksandr Grytsov
+=item B<short-name=STRING>
docs/man/xl.cfg.pod.5.in +8
-0+ +Short name of the virtual sound card. + +=item B<short-name=STRING> + +Long name of the virtual sound card. + +=backDuplicate short-name=, should be name= ?
yes, should be long-name. Thanks.
--
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
Signature · 2 lines
Best Regards, Oleksandr Grytsov.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel