From nobody Sat Feb 7 05:48:40 2026 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=1636028596; cv=none; d=zohomail.com; s=zohoarc; b=frYtPbbdt36TIUD4Eeh2sqDRFI6EhnU3Wf5Ilm8MH7aQ0/1w5bHhkPjD70lTKp6A/fno/ZCPohKHqz3AJ2aT5EVEnlG36fGE1IbAnj8PBo1bmpFL2nZcJrITmfYsAdnyZ1N4LJ9yzCU6EeE0/GdnOWzk+cBybz2GEQOr9AD0qAc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636028596; 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=9qIug6rTdFRN2HT4gMDksTqRYBoxLhT3E64pZ+741fg=; b=Afvt3QlVzauwYhnzNioZnoTraphBlyl0CvY1lPJeH48vROXl29jCi8N3gjd/LNXDhOeeXz+b/TzwfBKtCg/YGg3GK20NW3fMiamuWojkiyeusUnczbLTUwhhaiABC8+70NkPUJA1mx3Gi3hldquiErBkiJV2S1NL8Y7PGc2ycI8= 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 1636028596619191.18962779513595; Thu, 4 Nov 2021 05:23:16 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-568-4ORU6RC-MRmjTfQ7qZYp3A-1; Thu, 04 Nov 2021 08:23:14 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3062810055C3; Thu, 4 Nov 2021 12:23:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E7546A6C4A; Thu, 4 Nov 2021 12:23:08 +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 5975757DC0; Thu, 4 Nov 2021 12:23:08 +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 1A4CN79D003575 for ; Thu, 4 Nov 2021 08:23:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 19D1757CD2; Thu, 4 Nov 2021 12:23:07 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D7692B060; Thu, 4 Nov 2021 12:23:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636028595; 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=9qIug6rTdFRN2HT4gMDksTqRYBoxLhT3E64pZ+741fg=; b=BEmidiUNR/vB5eDECy9BQCkvTzydCAhxNGHoGCLkIT9bZTuYTYOMzWdrGF3WTb2pQdwbK5 kK0tFftN7Bnj/i2tyUSFn6ZBxrmgE81DZzmMdgGVMcXeORrobwDAA7KpHAIeTXqR/IWxwm FaRrgqwHbg1VAIKkUj0k3JtkLEgdfEk= X-MC-Unique: 4ORU6RC-MRmjTfQ7qZYp3A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/2] qemu: Generate command line for tb-cache feature Date: Thu, 4 Nov 2021 13:22:53 +0100 Message-Id: <2a37dd785e26c65d15aa912d1479143a9ba0cb39.1636028443.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.16 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: 1636028597262100002 Content-Type: text/plain; charset="utf-8" Alright, here's the deal: to enable tb-cache one has to use '-accel tcg,tb-size=3D' which then conflicts with '-machine accel=3Dtcg'. But sure, we can use the old -accel in this specific case. But because of how the tb-size argument is defined in QEMU there's no way for us to have a capability check. The feature was introduced in QEMU commit of v5.0.0-rc0~175^2~62 and is tied to TCG only. Therefore, I think we can live without capability check. Worst case scenario, QEMU fails to start. Resolves: https://gitlab.com/libvirt/libvirt/-/issues/229 Signed-off-by: Michal Privoznik --- src/qemu/qemu_command.c | 14 ++++++- ...efault-cpu-tcg-features.x86_64-latest.args | 40 +++++++++++++++++++ tests/qemuxml2argvtest.c | 1 + 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/x86_64-default-cpu-tcg-features.= x86_64-latest.args diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 45278c7108..7d9cb386fd 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7031,14 +7031,21 @@ qemuBuildMachineCommandLine(virCommand *cmd, virTristateSwitch smm =3D def->features[VIR_DOMAIN_FEATURE_SMM]; virCPUDef *cpu =3D def->cpu; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + unsigned long long tb_cache =3D 0; size_t i; =20 + if (def->features[VIR_DOMAIN_FEATURE_TCG] =3D=3D VIR_TRISTATE_SWITCH_O= N) + tb_cache =3D def->tcg_features->tb_cache; + virCommandAddArg(cmd, "-machine"); virBufferAdd(&buf, def->os.machine, -1); =20 switch ((virDomainVirtType)def->virtType) { case VIR_DOMAIN_VIRT_QEMU: - virBufferAddLit(&buf, ",accel=3Dtcg"); + /* Unfortunately, -machine doesn't accept -accel arguments and the= two + * are mutually exclusive. Don't output accel=3D if we need -accel= . */ + if (tb_cache =3D=3D 0) + virBufferAddLit(&buf, ",accel=3Dtcg"); break; =20 case VIR_DOMAIN_VIRT_KVM: @@ -7288,6 +7295,11 @@ qemuBuildMachineCommandLine(virCommand *cmd, =20 virCommandAddArgBuffer(cmd, &buf); =20 + if (tb_cache > 0) { + virCommandAddArg(cmd, "-accel"); + virCommandAddArgFormat(cmd, "tcg,tb-size=3D%llu", tb_cache >> 10); + } + return 0; } =20 diff --git a/tests/qemuxml2argvdata/x86_64-default-cpu-tcg-features.x86_64-= latest.args b/tests/qemuxml2argvdata/x86_64-default-cpu-tcg-features.x86_64= -latest.args new file mode 100644 index 0000000000..0800ea4294 --- /dev/null +++ b/tests/qemuxml2argvdata/x86_64-default-cpu-tcg-features.x86_64-latest.= args @@ -0,0 +1,40 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-guest \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-guest/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-guest/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-guest/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3Dguest,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tm= p/lib/domain--1-guest/master-key.aes"}' \ +-machine pc-q35-6.2,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dpc.ra= m \ +-accel tcg,tb-size=3D100 \ +-cpu qemu64 \ +-m 4096 \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":4294967296}= ' \ +-overcommit mem-lock=3Doff \ +-smp 4,sockets=3D4,cores=3D1,threads=3D1 \ +-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot strict=3Don \ +-device '{"driver":"pcie-root-port","port":8,"chassis":1,"id":"pci.1","bus= ":"pcie.0","multifunction":true,"addr":"0x1"}' \ +-device '{"driver":"pcie-root-port","port":9,"chassis":2,"id":"pci.2","bus= ":"pcie.0","addr":"0x1.0x1"}' \ +-device '{"driver":"pcie-root-port","port":10,"chassis":3,"id":"pci.3","bu= s":"pcie.0","addr":"0x1.0x2"}' \ +-device '{"driver":"pcie-root-port","port":11,"chassis":4,"id":"pci.4","bu= s":"pcie.0","addr":"0x1.0x3"}' \ +-device '{"driver":"qemu-xhci","id":"usb","bus":"pci.1","addr":"0x0"}' \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/guest.qcow= 2","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}= ' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"qco= w2","file":"libvirt-1-storage"}' \ +-device '{"driver":"virtio-blk-pci","bus":"pci.2","addr":"0x0","drive":"li= bvirt-1-format","id":"virtio-disk0","bootindex":1}' \ +-audiodev id=3Daudio1,driver=3Dnone \ +-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.3","add= r":"0x0"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 1c59395203..56ecc46071 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -3422,6 +3422,7 @@ mymain(void) DO_TEST_CAPS_ARCH_LATEST("x86_64-default-cpu-tcg-pc-4.2", "x86_64"); DO_TEST_CAPS_ARCH_LATEST("x86_64-default-cpu-kvm-q35-4.2", "x86_64"); DO_TEST_CAPS_ARCH_LATEST("x86_64-default-cpu-tcg-q35-4.2", "x86_64"); + DO_TEST_CAPS_ARCH_LATEST("x86_64-default-cpu-tcg-features", "x86_64"); =20 DO_TEST_CAPS_LATEST("virtio-9p-multidevs"); DO_TEST_CAPS_LATEST("virtio-9p-createmode"); --=20 2.32.0