]> xenbits.xensource.com Git - xen.git/commitdiff
tools/libxl: Replace deprecated -soundhw on QEMU command line
authorAnthony PERARD <anthony.perard@citrix.com>
Tue, 11 Oct 2022 12:59:10 +0000 (14:59 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 11 Oct 2022 12:59:10 +0000 (14:59 +0200)
-soundhw is deprecated since 825ff02911c9 ("audio: add soundhw
deprecation notice"), QEMU v5.1, and is been remove for upcoming v7.1
by 039a68373c45 ("introduce -audio as a replacement for -soundhw").

Instead we can just add the sound card with "-device", for most option
that "-soundhw" could handle. "-device" is an option that existed
before QEMU 1.0, and could already be used to add audio hardware.

The list of possible option for libxl's "soundhw" is taken the list
from QEMU 7.0.

The list of options for "soundhw" are listed in order of preference in
the manual. The first three (hda, ac97, es1370) are PCI devices and
easy to test on Linux, and the last four are ISA devices which doesn't
seems to work out of the box on linux.

The sound card 'pcspk' isn't listed even if it used to be accepted by
'-soundhw' because QEMU crash when trying to add it to a Xen domain.
Also, it wouldn't work with "-device" might need to be "-machine
pcspk-audiodev=default" instead.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
master commit: 62ca138c2c052187783aca3957d3f47c4dcfd683
master date: 2022-08-18 09:25:50 +0200

docs/man/xl.cfg.5.pod.in
tools/libs/light/libxl_dm.c
tools/libs/light/libxl_types_internal.idl

index eda1e77ebd06fd153ecd7e93c33a092deed036c4..ab7541f22c3e62f0814f115754064bd5c6512428 100644 (file)
@@ -2545,9 +2545,9 @@ The form serial=DEVICE is also accepted for backwards compatibility.
 
 =item B<soundhw="DEVICE">
 
-Select the virtual sound card to expose to the guest. The valid
-devices are defined by the device model configuration, please see the
-B<qemu(1)> 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<hda>, B<ac97>, B<es1370>, B<adlib>, B<cs4231a>, B<gus>, B<sb16> if there are
+available with the device model QEMU. The default is not to export any sound
 device.
 
 =item B<vkb_device=BOOLEAN>
index 04bf5d85632ec088c79e99efc67eddb5a90859cd..fc264a3a13a6a5a956ea25b7d8d1c4adb507cc71 100644 (file)
@@ -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");
index 3593e21dbb64727fc0e65999cbffb3219b02ecd1..caa08d3229cd5b67b20ad127e2bccc9add227a13 100644 (file)
@@ -55,3 +55,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"),
+    ])