From nobody Sun May 5 17:48:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642434836; cv=none; d=zohomail.com; s=zohoarc; b=JAvf6r4Ovkc2OdYQthNodnWz0u5F7u8paPWupJCuVuRcxzjoOr7kK8yg8tMBbNzrsQceQyvftCF7ZJ5Frg8ucDwY7QCp0Flbkg8u/16omIOgx1lKGv7EThR1WwgM+Od6x1+Hnf5OKOsSXKOyE2Z3pbHzLCi4cSxsWrOD8zWzZM0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642434836; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=trvVVLiIYMlDOMVrQYZ10n5l0EbQxmAPinGezOlbK8M=; b=la/K/ZKkN/noWzfi0J5ehUMsKuLzw8AylV1jI2uXsKABG4Py0EiZY73kz7cQT/jOQ4VLiaOJiNgBP0/UYeQLBQc9jAH0QGdQpScwetDixhinTVXBqe/zrtUjUr3iZLA7nDLRs+uWzkXCXe1tVWNlG2In+mx/87Hh5di1qEJ716Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1642434836711482.5747057225133; Mon, 17 Jan 2022 07:53:56 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-479-6qOIw6G9NbWvvkv7FuVCQw-1; Mon, 17 Jan 2022 10:53:53 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6C66987498C; Mon, 17 Jan 2022 15:53:27 +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 1815210A48B0; Mon, 17 Jan 2022 15:53:27 +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 C78561806D1C; Mon, 17 Jan 2022 15:53:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20HFooSB002388 for ; Mon, 17 Jan 2022 10:50:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id EFA6210A48B0; Mon, 17 Jan 2022 15:50:50 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.40.195.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5DFED10A48B2 for ; Mon, 17 Jan 2022 15:50:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642434835; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=trvVVLiIYMlDOMVrQYZ10n5l0EbQxmAPinGezOlbK8M=; b=XpFM2ewOS2iTr4No5XK1UogNsOU8epD3nIRJME2UWgerdu3fYxuCR884lrndtd+davC4YG RE6ywSXfNOiDVVDUkLRnbgIPLmJnTaEH/4Bo/9TRZTMh4rsvEebwcPS12c43NYZ8JT/a8s AHiCxw8xkP9IK8IvqQmVvVykX9yKMrI= X-MC-Unique: 6qOIw6G9NbWvvkv7FuVCQw-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 1/2] qemu: Correctly translate QEMU_AUDIO_DRV=wav Date: Mon, 17 Jan 2022 16:50:46 +0100 Message-Id: <20220117155047.119252-2-abologna@redhat.com> In-Reply-To: <20220117155047.119252-1-abologna@redhat.com> References: <20220117155047.119252-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642434838217100001 Content-Type: text/plain; charset="utf-8" This, along with "pa", is the other case where the libvirt and QEMU names do not match. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- src/qemu/qemu_domain.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a8401bac30..1f7d71bf0f 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3496,6 +3496,8 @@ qemuDomainDefSuggestDefaultAudioBackend(virQEMUDriver= *driver, */ if (STREQ(audioenv, "pa")) { *audioBackend =3D VIR_DOMAIN_AUDIO_TYPE_PULSEAUDIO; + } else if (STREQ(audioenv, "wav")) { + *audioBackend =3D VIR_DOMAIN_AUDIO_TYPE_FILE; } else { if (((*audioBackend) =3D virDomainAudioTypeTypeFromString(= audioenv)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, --=20 2.34.1 From nobody Sun May 5 17:48:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642434846; cv=none; d=zohomail.com; s=zohoarc; b=oAjrWjkmYdWbkXKOaNG6+cSMK0hHqqnLngxMPdIeFmBVCbhqBmqjK3clsYbpNWtHPffKp/lnq6n7c/q2Kvbn7n1splVtPWEmzztW/VAKgYwF9iCbnoyc+JKaSSeo/8lR71JKLwl7CHGKEradrE0fhzxOURtUTnZRejfX98ahNgs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642434846; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0SG3aypbZpDEBPzqfIur3uCVHhsA97tqeUHvWUN+u2k=; b=TUm4RO88vFr7Q3HZfFahcHtL9k33iYYPlsxHBuT1WHxPUT28ngEqcfcviiZHV0KTEKx8TAD8QH4EvnROBfWUWXslp8opyBZWlDOuJ0qkAfljWmGaAfnWRRSo5gYw+xle1573XPsZnT6Nxx8a7GymPFS9YEqNeCUiMc13uyuDUDQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1642434846729239.74524430803035; Mon, 17 Jan 2022 07:54:06 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-612-bCOZ7BxiNL-Vh8Nr0G-BeA-1; Mon, 17 Jan 2022 10:53:52 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D728381E4D1; Mon, 17 Jan 2022 15:53:40 +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 B791878AB6; Mon, 17 Jan 2022 15:53:40 +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 828C91806D1D; Mon, 17 Jan 2022 15:53:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20HFop4v002398 for ; Mon, 17 Jan 2022 10:50:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id F005210A48B2; Mon, 17 Jan 2022 15:50:51 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.40.195.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5DE8510A48B0 for ; Mon, 17 Jan 2022 15:50:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642434845; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=0SG3aypbZpDEBPzqfIur3uCVHhsA97tqeUHvWUN+u2k=; b=hKW9Re8NSOkOVqVIYfoXF17TqjdYY6DnNpbPKv0GmxDBJ/cHMJeiED3cQvxB1HfD3U5wY6 2rBiYuJzjPlnLg5IGkmDuTX5KqZ80dhA2BIkUz+5m7pw+sbne3hfbnfYSACWDvLf/pBI5b fEjO/Xo7u0C1Bgd8dojsA3/KaWWrCms= X-MC-Unique: bCOZ7BxiNL-Vh8Nr0G-BeA-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 2/2] qemu: Drop qemuAudioDriver enumeration Date: Mon, 17 Jan 2022 16:50:47 +0100 Message-Id: <20220117155047.119252-3-abologna@redhat.com> In-Reply-To: <20220117155047.119252-1-abologna@redhat.com> References: <20220117155047.119252-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642434848412100003 Content-Type: text/plain; charset="utf-8" This mostly overlaps with virDomainAudioType, but in a couple of cases the string representations are different. Right now we're doing that in a somewhat sketchy way, in that we store values of one enumeration and then convert them to strings using TypeToString() implementation for the other enumeration; when converting from string, we open-code the handling of the special values mentioned above. Drop the second enumeration and introduce two helpers to deal with conversion. Most calling sites don't need to be changed, and one can even be simplified significantly. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- src/qemu/qemu_command.c | 46 +++++++++++++++++++++++++++++------------ src/qemu/qemu_command.h | 3 +++ src/qemu/qemu_domain.c | 18 ++++------------ 3 files changed, 40 insertions(+), 27 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ed9dda4feb..babe21245f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -130,19 +130,39 @@ VIR_ENUM_IMPL(qemuNumaPolicy, "restrictive", ); =20 -VIR_ENUM_DECL(qemuAudioDriver); -VIR_ENUM_IMPL(qemuAudioDriver, - VIR_DOMAIN_AUDIO_TYPE_LAST, - "none", - "alsa", - "coreaudio", - "jack", - "oss", - "pa", - "sdl", - "spice", - "wav", -); + +const char * +qemuAudioDriverTypeToString(virDomainAudioType type) +{ + switch (type) { + case VIR_DOMAIN_AUDIO_TYPE_PULSEAUDIO: + return "pa"; + case VIR_DOMAIN_AUDIO_TYPE_FILE: + return "wav"; + case VIR_DOMAIN_AUDIO_TYPE_NONE: + case VIR_DOMAIN_AUDIO_TYPE_ALSA: + case VIR_DOMAIN_AUDIO_TYPE_COREAUDIO: + case VIR_DOMAIN_AUDIO_TYPE_JACK: + case VIR_DOMAIN_AUDIO_TYPE_OSS: + case VIR_DOMAIN_AUDIO_TYPE_SDL: + case VIR_DOMAIN_AUDIO_TYPE_SPICE: + case VIR_DOMAIN_AUDIO_TYPE_LAST: + break; + } + return virDomainAudioTypeTypeToString(type); +} + + +virDomainAudioType +qemuAudioDriverTypeFromString(const char *str) +{ + if (STREQ(str, "pa")) { + return VIR_DOMAIN_AUDIO_TYPE_PULSEAUDIO; + } else if (STREQ(str, "wav")) { + return VIR_DOMAIN_AUDIO_TYPE_FILE; + } + return virDomainAudioTypeTypeFromString(str); +} =20 =20 static const char * diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index dbdf3a4793..180988fa1a 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -254,3 +254,6 @@ qemuBuildTPMOpenBackendFDs(const char *tpmdev, int *cancelfd) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4) G_GNUC_NO_INLINE; + +const char * qemuAudioDriverTypeToString(virDomainAudioType type); +virDomainAudioType qemuAudioDriverTypeFromString(const char *str); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 1f7d71bf0f..fbe2036556 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3490,20 +3490,10 @@ qemuDomainDefSuggestDefaultAudioBackend(virQEMUDriv= er *driver, if (audioenv =3D=3D NULL) { *addAudio =3D false; } else { - /* - * QEMU audio driver names are mostly the same as - * libvirt XML audio backend names - */ - if (STREQ(audioenv, "pa")) { - *audioBackend =3D VIR_DOMAIN_AUDIO_TYPE_PULSEAUDIO; - } else if (STREQ(audioenv, "wav")) { - *audioBackend =3D VIR_DOMAIN_AUDIO_TYPE_FILE; - } else { - if (((*audioBackend) =3D virDomainAudioTypeTypeFromString(= audioenv)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown QEMU_AUDIO_DRV setting %s"),= audioenv); - return -1; - } + if (((*audioBackend) =3D qemuAudioDriverTypeFromString(audioen= v)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown QEMU_AUDIO_DRV setting %s"), aud= ioenv); + return -1; } } } --=20 2.34.1