From nobody Sun Feb 8 18:10:46 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=1682343622; cv=none; d=zohomail.com; s=zohoarc; b=PtZgOff2+gVoeoXGCyiXbkiLlFy2jV1hNuqdAIONeRPTgrqLLhdf9XbUM7rYfxPSnH8eY7TzUuQ4An2kaoYXRy0kqAIZtcbCP2TC35nnm2Q2roGcvE8XaJVwl/NmVw0/e2/y5kppy1szZgTLYA5UPHnSigB3pLGj+OHWUlnb0wo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682343622; 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=+20IWMgUbWBN82oYfDZB85UIosrnNjjhlOZ33gAKhrQ=; b=ddAAJZV4Q6RpvHXR053UV6jz6lN6u1qp3nHpkvrFNDOc2C0WiOiRihOWZdKalSjt8CmP747GR84PAmaFw1jDtfhN4V04nx2xm7wKlDc5GCckpoJ1Y4BNXKNafdMa/tU0H5gGOMR7k/cyKezuVfy6Bd7yhL3QZ44bcamXUK0A71c= 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 1682343622926290.8703332615771; Mon, 24 Apr 2023 06:40:22 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-670-inMUhQztNHC9iB5OiFQ6Rw-1; Mon, 24 Apr 2023 09:40:16 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B7016886066; Mon, 24 Apr 2023 13:40:11 +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 A1CBF4E3C7; Mon, 24 Apr 2023 13:40:11 +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 7CC5F1946589; Mon, 24 Apr 2023 13:40:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 81AFA1946A5E for ; Mon, 24 Apr 2023 13:40:10 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 57B862166B2A; Mon, 24 Apr 2023 13:40:10 +0000 (UTC) Received: from fedora.. (unknown [10.43.2.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id F33122166B29 for ; Mon, 24 Apr 2023 13:40:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682343621; 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=+20IWMgUbWBN82oYfDZB85UIosrnNjjhlOZ33gAKhrQ=; b=gmb0PA4OecBczjOeAcgA+KtXZwGgc+XLh7Wi/CPtNt8BO9Xrd2XocptaTZmtLgSUAsTF4Y vt4PCkHd3WmyI2x1OrIAt1HpJSCSu7ZC2S1KbjCvaqW8YoYFwhq32Z+hhFlhzxamfV1e3S u80nn+14HwxCynuj5bRYLKHqPwNZ7cA= X-MC-Unique: inMUhQztNHC9iB5OiFQ6Rw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCHv2 3/3] qemu: allow forcing emulated maxphysaddr Date: Mon, 24 Apr 2023 15:40:04 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682343623660100003 Treat: as a request not to take the maximum address size from the host. This is useful if QEMU changes the default. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- docs/formatdomain.rst | 3 +- src/qemu/qemu_command.c | 5 ++- src/qemu/qemu_validate.c | 7 ----- ...-phys-bits-emulate-bare.x86_64-latest.args | 13 ++++---- .../cpu-phys-bits-emulate-bare.xml | 20 ++++++++++++ .../cpu-phys-bits-emulate3.err | 1 - .../cpu-phys-bits-emulate3.xml | 20 ------------ tests/qemuxml2argvtest.c | 2 +- ...u-phys-bits-emulate-bare.x86_64-latest.xml | 31 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 10 files changed, 65 insertions(+), 38 deletions(-) create mode 100644 tests/qemuxml2argvdata/cpu-phys-bits-emulate-bare.xml delete mode 100644 tests/qemuxml2argvdata/cpu-phys-bits-emulate3.err delete mode 100644 tests/qemuxml2argvdata/cpu-phys-bits-emulate3.xml create mode 100644 tests/qemuxml2xmloutdata/cpu-phys-bits-emulate-bare.x86= _64-latest.xml diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index f5bbfdc20a..2e8d31dd74 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -1636,7 +1636,8 @@ In case no restrictions need to be put on CPU model a= nd its features, a simpler passed through to the virtual CPUs ``emulate`` The hypervisor will define a specific value for the number of bits - of physical addresses via the ``bits`` attribute, which is mandat= ory. + of physical addresses via the ``bits`` attribute, which is option= al + :since:`since 9.2.0` The number of bits cannot exceed the number of physical address bits supported by the hypervisor. =20 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1d99f8a46a..1356b6e975 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6530,7 +6530,10 @@ qemuBuildCpuCommandLine(virCommand *cmd, break; =20 case VIR_CPU_MAX_PHYS_ADDR_MODE_EMULATE: - virBufferAsprintf(&buf, ",phys-bits=3D%d", addr->bits); + if (addr->bits > 0) + virBufferAsprintf(&buf, ",phys-bits=3D%d", addr->bits); + else + virBufferAddLit(&buf, ",host-phys-bits=3Doff"); break; =20 case VIR_CPU_MAX_PHYS_ADDR_MODE_LAST: diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index fdfb4c6407..da4b9a3b35 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -269,13 +269,6 @@ qemuValidateDomainDefCpu(virQEMUDriver *driver, break; =20 case VIR_CPU_MAX_PHYS_ADDR_MODE_EMULATE: - if (addr->bits =3D=3D -1) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("if using CPU maximum physical address mo= de=3D'%1$s', bits=3D must be specified too"), - virCPUMaxPhysAddrModeTypeToString(VIR_CPU_M= AX_PHYS_ADDR_MODE_EMULATE)); - return -1; - } - if (driver->hostcpu && driver->hostcpu->addr && cpu->addr->bits > driver->hostcpu->addr->bits) { diff --git a/tests/qemuxml2argvdata/cpu-phys-bits-emulate-bare.x86_64-lates= t.args b/tests/qemuxml2argvdata/cpu-phys-bits-emulate-bare.x86_64-latest.ar= gs index 3fa8384ace..28578fac20 100644 --- a/tests/qemuxml2argvdata/cpu-phys-bits-emulate-bare.x86_64-latest.args +++ b/tests/qemuxml2argvdata/cpu-phys-bits-emulate-bare.x86_64-latest.args @@ -1,16 +1,16 @@ LC_ALL=3DC \ PATH=3D/bin \ -HOME=3D/tmp/lib/domain--1-foo \ +HOME=3D/var/lib/libvirt/qemu/domain--1-foo \ USER=3Dtest \ LOGNAME=3Dtest \ -XDG_DATA_HOME=3D/tmp/lib/domain--1-foo/.local/share \ -XDG_CACHE_HOME=3D/tmp/lib/domain--1-foo/.cache \ -XDG_CONFIG_HOME=3D/tmp/lib/domain--1-foo/.config \ +XDG_DATA_HOME=3D/var/lib/libvirt/qemu/domain--1-foo/.local/share \ +XDG_CACHE_HOME=3D/var/lib/libvirt/qemu/domain--1-foo/.cache \ +XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-foo/.config \ /usr/bin/qemu-system-x86_64 \ -name guest=3Dfoo,debug-threads=3Don \ -S \ --object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tm= p/lib/domain--1-foo/master-key.aes"}' \ --machine pc,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dpc.ram \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/va= r/lib/libvirt/qemu/domain--1-foo/master-key.aes"}' \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dpc.ram,acpi= =3Doff \ -accel kvm \ -cpu host,migratable=3Don,host-phys-bits=3Doff \ -m 214 \ @@ -25,7 +25,6 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-foo/.config \ -mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ -rtc base=3Dutc \ -no-shutdown \ --no-acpi \ -boot strict=3Don \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ -audiodev '{"id":"audio1","driver":"none"}' \ diff --git a/tests/qemuxml2argvdata/cpu-phys-bits-emulate-bare.xml b/tests/= qemuxml2argvdata/cpu-phys-bits-emulate-bare.xml new file mode 100644 index 0000000000..30a14894dd --- /dev/null +++ b/tests/qemuxml2argvdata/cpu-phys-bits-emulate-bare.xml @@ -0,0 +1,20 @@ + + foo + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + + + + destroy + restart + destroy + + + diff --git a/tests/qemuxml2argvdata/cpu-phys-bits-emulate3.err b/tests/qemu= xml2argvdata/cpu-phys-bits-emulate3.err deleted file mode 100644 index 5e21998259..0000000000 --- a/tests/qemuxml2argvdata/cpu-phys-bits-emulate3.err +++ /dev/null @@ -1 +0,0 @@ -unsupported configuration: if using CPU maximum physical address mode=3D'e= mulate', bits=3D must be specified too diff --git a/tests/qemuxml2argvdata/cpu-phys-bits-emulate3.xml b/tests/qemu= xml2argvdata/cpu-phys-bits-emulate3.xml deleted file mode 100644 index 30a14894dd..0000000000 --- a/tests/qemuxml2argvdata/cpu-phys-bits-emulate3.xml +++ /dev/null @@ -1,20 +0,0 @@ - - foo - c7a5fdbd-edaf-9455-926a-d65c16db1809 - 219136 - 219136 - 1 - - hvm - - - - - - - destroy - restart - destroy - - - diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 48ddc102f7..270d6fa59e 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2720,9 +2720,9 @@ mymain(void) DO_TEST("cpu-phys-bits-passthrough", QEMU_CAPS_KVM); DO_TEST("cpu-phys-bits-emulate", QEMU_CAPS_KVM); DO_TEST("cpu-phys-bits-emulate2", QEMU_CAPS_KVM); - DO_TEST_PARSE_ERROR("cpu-phys-bits-emulate3", QEMU_CAPS_KVM); DO_TEST_PARSE_ERROR("cpu-phys-bits-passthrough2", QEMU_CAPS_KVM); DO_TEST_CAPS_LATEST("cpu-phys-bits-limit"); + DO_TEST_CAPS_LATEST("cpu-phys-bits-emulate-bare"); =20 DO_TEST_CAPS_VER("sgx-epc", "7.0.0"); =20 diff --git a/tests/qemuxml2xmloutdata/cpu-phys-bits-emulate-bare.x86_64-lat= est.xml b/tests/qemuxml2xmloutdata/cpu-phys-bits-emulate-bare.x86_64-latest= .xml new file mode 100644 index 0000000000..94b3627a46 --- /dev/null +++ b/tests/qemuxml2xmloutdata/cpu-phys-bits-emulate-bare.x86_64-latest.xml @@ -0,0 +1,31 @@ + + foo + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + + + +