From nobody Thu May 15 06:30:47 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1510667130649419.68358312871044; Tue, 14 Nov 2017 05:45:30 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6C45FC059721; Tue, 14 Nov 2017 13:45:29 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3CB52A2920; Tue, 14 Nov 2017 13:45:29 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E85B01800FC4; Tue, 14 Nov 2017 13:45:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vAEDjOsg001600 for ; Tue, 14 Nov 2017 08:45:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9E8CDD767E; Tue, 14 Nov 2017 13:45:24 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 25D1D8B56F for ; Tue, 14 Nov 2017 13:45:23 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Tue, 14 Nov 2017 14:45:07 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/6] qemu: move QEMU_AUDIO_DRIVER out of graphic into sound X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 14 Nov 2017 13:45:29 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Setting the default audio output depends on specific graphic device but requires having sound device configured as well and it's the sound device that handles the audio. Signed-off-by: Pavel Hrdina Reviewed-by: John Ferlan --- src/qemu/qemu_command.c | 84 +++++++++++++++---= ---- .../qemuxml2argv-clock-france.args | 2 +- 2 files changed, 58 insertions(+), 28 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index eb72db33ba..e1ef1b05fa 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4442,10 +4442,62 @@ qemuBuildSoundCodecStr(virDomainSoundDefPtr sound, } =20 =20 +static void +qemuBuildSoundAudioEnv(virCommandPtr cmd, + const virDomainDef *def, + virQEMUDriverConfigPtr cfg) +{ + if (def->ngraphics =3D=3D 0) { + if (cfg->nogfxAllowHostAudio) + virCommandAddEnvPassBlockSUID(cmd, "QEMU_AUDIO_DRV", NULL); + else + virCommandAddEnvString(cmd, "QEMU_AUDIO_DRV=3Dnone"); + } else { + switch (def->graphics[def->ngraphics - 1]->type) { + case VIR_DOMAIN_GRAPHICS_TYPE_SDL: + /* If using SDL for video, then we should just let it + * use QEMU's host audio drivers, possibly SDL too + * User can set these two before starting libvirtd + */ + virCommandAddEnvPassBlockSUID(cmd, "QEMU_AUDIO_DRV", NULL); + virCommandAddEnvPassBlockSUID(cmd, "SDL_AUDIODRIVER", NULL); + + break; + + case VIR_DOMAIN_GRAPHICS_TYPE_VNC: + /* Unless user requested it, set the audio backend to none, to + * prevent it opening the host OS audio devices, since that ca= uses + * security issues and might not work when using VNC. + */ + if (cfg->vncAllowHostAudio) + virCommandAddEnvPassBlockSUID(cmd, "QEMU_AUDIO_DRV", NULL); + else + virCommandAddEnvString(cmd, "QEMU_AUDIO_DRV=3Dnone"); + + break; + + case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: + /* SPICE includes native support for tunnelling audio, so we + * set the audio backend to point at SPICE's own driver + */ + virCommandAddEnvString(cmd, "QEMU_AUDIO_DRV=3Dspice"); + + break; + + case VIR_DOMAIN_GRAPHICS_TYPE_RDP: + case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP: + case VIR_DOMAIN_GRAPHICS_TYPE_LAST: + break; + } + } +} + + static int qemuBuildSoundCommandLine(virCommandPtr cmd, const virDomainDef *def, - virQEMUCapsPtr qemuCaps) + virQEMUCapsPtr qemuCaps, + virQEMUDriverConfigPtr cfg) { size_t i, j; =20 @@ -4498,6 +4550,9 @@ qemuBuildSoundCommandLine(virCommandPtr cmd, } } } + + qemuBuildSoundAudioEnv(cmd, def, cfg); + return 0; } =20 @@ -7951,15 +8006,6 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigP= tr cfg, if (graphics->data.vnc.keymap) virCommandAddArgList(cmd, "-k", graphics->data.vnc.keymap, NULL); =20 - /* Unless user requested it, set the audio backend to none, to - * prevent it opening the host OS audio devices, since that causes - * security issues and might not work when using VNC. - */ - if (cfg->vncAllowHostAudio) - virCommandAddEnvPassBlockSUID(cmd, "QEMU_AUDIO_DRV", NULL); - else - virCommandAddEnvString(cmd, "QEMU_AUDIO_DRV=3Dnone"); - return 0; =20 error: @@ -8201,10 +8247,6 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfi= gPtr cfg, if (graphics->data.spice.keymap) virCommandAddArgList(cmd, "-k", graphics->data.spice.keymap, NULL); - /* SPICE includes native support for tunnelling audio, so we - * set the audio backend to point at SPICE's own driver - */ - virCommandAddEnvString(cmd, "QEMU_AUDIO_DRV=3Dspice"); =20 return 0; =20 @@ -8235,13 +8277,6 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr = cfg, if (graphics->data.sdl.fullscreen) virCommandAddArg(cmd, "-full-screen"); =20 - /* If using SDL for video, then we should just let it - * use QEMU's host audio drivers, possibly SDL too - * User can set these two before starting libvirtd - */ - virCommandAddEnvPassBlockSUID(cmd, "QEMU_AUDIO_DRV", NULL); - virCommandAddEnvPassBlockSUID(cmd, "SDL_AUDIODRIVER", NULL); - /* New QEMU has this flag to let us explicitly ask for * SDL graphics. This is better than relying on the * default, since the default changes :-( */ @@ -9995,11 +10030,6 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, } else { virCommandAddArg(cmd, "-nographic"); } - - if (cfg->nogfxAllowHostAudio) - virCommandAddEnvPassBlockSUID(cmd, "QEMU_AUDIO_DRV", NULL); - else - virCommandAddEnvString(cmd, "QEMU_AUDIO_DRV=3Dnone"); } =20 /* Disable global config files and default devices */ @@ -10083,7 +10113,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildVideoCommandLine(cmd, def, qemuCaps) < 0) goto error; =20 - if (qemuBuildSoundCommandLine(cmd, def, qemuCaps) < 0) + if (qemuBuildSoundCommandLine(cmd, def, qemuCaps, cfg) < 0) goto error; =20 if (qemuBuildWatchdogCommandLine(cmd, def, qemuCaps) < 0) diff --git a/tests/qemuxml2argvdata/qemuxml2argv-clock-france.args b/tests/= qemuxml2argvdata/qemuxml2argv-clock-france.args index 9bde6d967b..2701179273 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-clock-france.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-clock-france.args @@ -3,8 +3,8 @@ PATH=3D/bin \ HOME=3D/home/test \ USER=3Dtest \ LOGNAME=3Dtest \ -QEMU_AUDIO_DRV=3Dnone \ TZ=3DEurope/Paris \ +QEMU_AUDIO_DRV=3Dnone \ /usr/bin/qemu-system-i686 \ -name QEMUGuest1 \ -S \ --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list