From nobody Sun Feb 8 18:19:21 2026 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=1687781626; cv=none; d=zohomail.com; s=zohoarc; b=jR//bqwAJ1pKpojxEXn4QWLvJ+gdJMusgacVOyHFRYopbUX5RX7Zv0uD9oIvAdR+f67nPwVF2pVH+oyqgmlXm/4pzuy18vD3u5hnwnS55JKL3apwFyPVIUNqvf2rAxcnLLgq3zMw7yHsI9OcabDreQerB8tjgY/2rtrNuJxhp7c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687781626; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=n4sJceyycvDfTK705PlVjpBIm2PGXBYNypFFX+kj4zg=; b=YNn3AOp8xz1hEEm0ygneEAAPkuKTTgjWKDe0V3oCQw+Bf2WIHTw1Y80pjr78seC9luBtj+opdhZ5rTQiFmMziIKMIrxw2KSeUFFrrUG3W3v+lStMs/vO0xzOBqao/qzKKkQUEzFSw/FwO1ti9AF+V8GfzH6v8tIHdQT1vQVrjt8= 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 1687781626496841.7712750030561; Mon, 26 Jun 2023 05:13:46 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-41-LfGCsMpNOQiGA4dJeHhHBg-1; Mon, 26 Jun 2023 08:13:42 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B47301C068CE; Mon, 26 Jun 2023 12:13:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 192E3140EBB8; Mon, 26 Jun 2023 12:13:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E7A271946588; Mon, 26 Jun 2023 12:13:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4E2281946587 for ; Mon, 26 Jun 2023 12:13:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3FD2940C6CD1; Mon, 26 Jun 2023 12:13:31 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id DBB3840C6CCD for ; Mon, 26 Jun 2023 12:13:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687781625; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=n4sJceyycvDfTK705PlVjpBIm2PGXBYNypFFX+kj4zg=; b=RJAYfQo/Y2n1HhRRMUfltkzUd/q0xuIgc/FD/w3Qtgwub7emb9sZM4qoSYjGSiBRivcjMR ZggJiekzqRMmcYaxhQP4Y6EFZi9qE9g+QAmxCl4/KLCyIu93N6m0PVZjJEoRGz9TguOW9F WAzp9rpwVnLV9kiffScIfEQFp2MCTaU= X-MC-Unique: LfGCsMpNOQiGA4dJeHhHBg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] qemu: Adapt to new way of specifying PC speaker Date: Mon, 26 Jun 2023 14:13:29 +0200 Message-Id: <903ca99537c61717245ffb4d21136b5fc5cf9d71.1687781602.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: 1687781628093100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Historically, the way to set PC speaker for a guest was to pass: -soundhw pcspk but as of QEMU commit v5.1.0-rc0~28^2~3 this is deprecated and we should use: -machine pcspk-audiodev=3D$id instead. The old way was then removed in commit v7.1.0-rc0~99^2~3. Now, ideally we would have a capability selecting whether we talk to a QEMU that understands the new way or not. But it's not that simple - the machine attribute is just an alias to the .audiodev=3D attribute of 'isa-pcspk' object and both are created in pc_machine_initfn() function, i.e. not then the PC_MACHINE() class is initialized, but when it's instantiated. IOW, it's not possible for us to query whether we're dealing with older or newer QEMU. But given that the newer version is supported since v5.1.0 and the minimal version we require is v4.2.0 (i.e. there are two releases which don't understand the newer cmd line) and how frequently this feature is (un-)used (the issue was reported after ~1 year since it stopped working), I believe we can live without any capability and just use the newer cmd line unconditionally. Resolves: https://gitlab.com/libvirt/libvirt/-/issues/490 Signed-off-by: Michal Privoznik Reviewed-by: Kristina Hanicova --- src/qemu/qemu_command.c | 57 ++++++++++++------- .../sound-device.x86_64-4.2.0.args | 3 +- .../sound-device.x86_64-latest.args | 3 +- 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a19902988c..3b0b162b8b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4477,31 +4477,30 @@ qemuBuildSoundCommandLine(virCommand *cmd, for (i =3D 0; i < def->nsounds; i++) { virDomainSoundDef *sound =3D def->sounds[i]; =20 - /* Sadly pcspk device doesn't use -device syntax. Fortunately - * we don't need to set any PCI address on it, so we don't - * mind too much */ - if (sound->model =3D=3D VIR_DOMAIN_SOUND_MODEL_PCSPK) { - virCommandAddArgList(cmd, "-soundhw", "pcspk", NULL); - } else { - if (qemuCommandAddExtDevice(cmd, &sound->info, def, qemuCaps) = < 0) - return -1; + /* Sadly pcspk device doesn't use -device syntax. And it + * was handled already in qemuBuildMachineCommandLine(). + */ + if (sound->model =3D=3D VIR_DOMAIN_SOUND_MODEL_PCSPK) + continue; =20 - if (qemuBuildSoundDevCmd(cmd, def, sound, qemuCaps) < 0) - return -1; + if (qemuCommandAddExtDevice(cmd, &sound->info, def, qemuCaps) < 0) + return -1; =20 - if (virDomainSoundModelSupportsCodecs(sound)) { - for (j =3D 0; j < sound->ncodecs; j++) { - if (qemuBuildSoundCodecCmd(cmd, def, sound, sound->cod= ecs[j], - qemuCaps) < 0) - return -1; - } + if (qemuBuildSoundDevCmd(cmd, def, sound, qemuCaps) < 0) + return -1; =20 - if (j =3D=3D 0) { - virDomainSoundCodecDef codec =3D { VIR_DOMAIN_SOUND_CO= DEC_TYPE_DUPLEX, 0 }; + if (virDomainSoundModelSupportsCodecs(sound)) { + for (j =3D 0; j < sound->ncodecs; j++) { + if (qemuBuildSoundCodecCmd(cmd, def, sound, sound->codecs[= j], + qemuCaps) < 0) + return -1; + } =20 - if (qemuBuildSoundCodecCmd(cmd, def, sound, &codec, qe= muCaps) < 0) - return -1; - } + if (j =3D=3D 0) { + virDomainSoundCodecDef codec =3D { VIR_DOMAIN_SOUND_CODEC_= TYPE_DUPLEX, 0 }; + + if (qemuBuildSoundCodecCmd(cmd, def, sound, &codec, qemuCa= ps) < 0) + return -1; } } } @@ -7029,6 +7028,22 @@ qemuBuildMachineCommandLine(virCommand *cmd, } } =20 + /* PC speaker is a bit different than the rest of sound cards + * which is handled in qemuBuildSoundCommandLine(). */ + for (i =3D 0; i < def->nsounds; i++) { + const virDomainSoundDef *sound =3D def->sounds[i]; + g_autofree char *audioid =3D NULL; + + if (sound->model !=3D VIR_DOMAIN_SOUND_MODEL_PCSPK) + continue; + + if (!(audioid =3D qemuGetAudioIDString(def, sound->audioId))) + return -1; + + virBufferAsprintf(&buf, ",pcspk-audiodev=3D%s", audioid); + break; + } + qemuBuildMachineACPI(&buf, def, qemuCaps); =20 virCommandAddArgBuffer(cmd, &buf); diff --git a/tests/qemuxml2argvdata/sound-device.x86_64-4.2.0.args b/tests/= qemuxml2argvdata/sound-device.x86_64-4.2.0.args index b2a5afd8c8..1e3cc9eaa2 100644 --- a/tests/qemuxml2argvdata/sound-device.x86_64-4.2.0.args +++ b/tests/qemuxml2argvdata/sound-device.x86_64-4.2.0.args @@ -10,7 +10,7 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGue= st1/.config \ -name guest=3DQEMUGuest1,debug-threads=3Don \ -S \ -object secret,id=3DmasterKey0,format=3Draw,file=3D/var/lib/libvirt/qemu/d= omain--1-QEMUGuest1/master-key.aes \ --machine pc-i440fx-4.2,usb=3Doff,dump-guest-core=3Doff \ +-machine pc-i440fx-4.2,usb=3Doff,dump-guest-core=3Doff,pcspk-audiodev=3Dau= dio1 \ -accel tcg \ -cpu qemu64 \ -m 214 \ @@ -28,7 +28,6 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGue= st1/.config \ -boot strict=3Don \ -device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ -audiodev '{"id":"audio1","driver":"none"}' \ --soundhw pcspk \ -device ES1370,id=3Dsound1,audiodev=3Daudio1,bus=3Dpci.0,addr=3D0x2 \ -device sb16,id=3Dsound2,audiodev=3Daudio1 \ -device AC97,id=3Dsound3,audiodev=3Daudio1,bus=3Dpci.0,addr=3D0x3 \ diff --git a/tests/qemuxml2argvdata/sound-device.x86_64-latest.args b/tests= /qemuxml2argvdata/sound-device.x86_64-latest.args index e0a2f21b31..7c90c1271c 100644 --- a/tests/qemuxml2argvdata/sound-device.x86_64-latest.args +++ b/tests/qemuxml2argvdata/sound-device.x86_64-latest.args @@ -10,7 +10,7 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGue= st1/.config \ -name guest=3DQEMUGuest1,debug-threads=3Don \ -S \ -object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/va= r/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}' \ --machine pc,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dpc.ram,acpi= =3Doff \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dpc.ram,pcspk-= audiodev=3Daudio1,acpi=3Doff \ -accel tcg \ -cpu qemu64 \ -m 214 \ @@ -28,7 +28,6 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGue= st1/.config \ -boot strict=3Don \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ -audiodev '{"id":"audio1","driver":"none"}' \ --soundhw pcspk \ -device '{"driver":"ES1370","id":"sound1","audiodev":"audio1","bus":"pci.0= ","addr":"0x2"}' \ -device '{"driver":"sb16","id":"sound2","audiodev":"audio1"}' \ -device '{"driver":"AC97","id":"sound3","audiodev":"audio1","bus":"pci.0",= "addr":"0x3"}' \ --=20 2.39.3