diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 6d98d73d76..b2901e04cf 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -2555,9 +2555,9 @@ The form serial=DEVICE is also accepted for backwards compatibility. =item B -Select the virtual sound card to expose to the guest. The valid -devices are defined by the device model configuration, please see the -B manpage for details. The default is not to export any sound +Select the virtual sound card to expose to the guest. The valid devices are +B, B, B, B, B, B, B if there are +available with the device model QEMU. The default is not to export any sound device. =item B diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c index 04bf5d8563..fc264a3a13 100644 --- a/tools/libs/light/libxl_dm.c +++ b/tools/libs/light/libxl_dm.c @@ -1204,6 +1204,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, uint64_t ram_size; const char *path, *chardev; bool is_stubdom = libxl_defbool_val(b_info->device_model_stubdomain); + int rc; dm_args = flexarray_make(gc, 16, 1); dm_envs = flexarray_make(gc, 16, 1); @@ -1531,7 +1532,23 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, } } if (b_info->u.hvm.soundhw) { - flexarray_vappend(dm_args, "-soundhw", b_info->u.hvm.soundhw, NULL); + libxl__qemu_soundhw soundhw; + + rc = libxl__qemu_soundhw_from_string(b_info->u.hvm.soundhw, &soundhw); + if (rc) { + LOGD(ERROR, guest_domid, "Unknown soundhw option '%s'", b_info->u.hvm.soundhw); + return ERROR_INVAL; + } + + switch (soundhw) { + case LIBXL__QEMU_SOUNDHW_HDA: + flexarray_vappend(dm_args, "-device", "intel-hda", + "-device", "hda-duplex", NULL); + break; + default: + flexarray_append_pair(dm_args, "-device", + (char*)libxl__qemu_soundhw_to_string(soundhw)); + } } if (!libxl__acpi_defbool_val(b_info)) { flexarray_append(dm_args, "-no-acpi"); diff --git a/tools/libs/light/libxl_types_internal.idl b/tools/libs/light/libxl_types_internal.idl index 8f71980aec..fb0f4f23d7 100644 --- a/tools/libs/light/libxl_types_internal.idl +++ b/tools/libs/light/libxl_types_internal.idl @@ -56,3 +56,13 @@ libxl__device_action = Enumeration("device_action", [ (1, "ADD"), (2, "REMOVE"), ]) + +libxl__qemu_soundhw = Enumeration("qemu_soundhw", [ + (1, "ac97"), + (2, "adlib"), + (3, "cs4231a"), + (4, "es1370"), + (5, "gus"), + (6, "hda"), + (7, "sb16"), + ])