From nobody Mon Feb 9 16:52:07 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=1667492576; cv=none; d=zohomail.com; s=zohoarc; b=eyMkzMV802hbu05nyUzmk00pR8/0t4T54YHGILsKge/QeV0lxZh7n+fNumWjOT4e1yiVALFP6Tquz16CWrxkOUVvUQYUYUaIKAtMjPAFJUFZAbCmrGoLCQjjmfWJ+W0j1twMF5cK3kcNWC9kFxbVCj3m2r4eYIsYVT2ds7YD7s4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667492576; 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=Fn86SRcILwviiJ/ZOcnnMuZY0dcSvvXcig/yVJFNeW0=; b=K1jO5vCDQDIVZqgX8UZPgBZMI1pHvDr09co0qdvRyGO++LrNN2UL/DoGB2J1l06+godMyHCPlPx7czr6Hyi+XU7O1KBdlcB3UdRVkotLSqBdtBNmqrIkFCCOP6ehMQWODxepCLbLMaGJx+v/XX2LzmuzlKRdaE59CMEE1zREfZ8= 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 1667492576784946.5973226323998; Thu, 3 Nov 2022 09:22:56 -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-173-VSCShQy4PDq3kGiG3IPhqQ-1; Thu, 03 Nov 2022 12:22:39 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 989883C106AA; Thu, 3 Nov 2022 16:22:26 +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 85C351121331; Thu, 3 Nov 2022 16:22:26 +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 7BE3A1946597; Thu, 3 Nov 2022 16:22:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9A20A1946594 for ; Thu, 3 Nov 2022 16:22:21 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 722801401C22; Thu, 3 Nov 2022 16:22:21 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16FA01401C21 for ; Thu, 3 Nov 2022 16:22:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667492575; 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=Fn86SRcILwviiJ/ZOcnnMuZY0dcSvvXcig/yVJFNeW0=; b=Sn8sHJA0/trq9UFAhBQcnAQzP8yR3xKe2G4iB3OJqAtM40idhrSt+F9I6g0YlAHoobhuJV Sc/kACMzoxjo/n3IUoA3piVRRRbkIdaT29J2aLNxir6DxocFZHZ3ZqJaQ3ZVCznGVGgDlN jkc3qwOnObU74ICvxcN08eLqgnhIrb8= X-MC-Unique: VSCShQy4PDq3kGiG3IPhqQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 10/15] qemu: Assume QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD Date: Thu, 3 Nov 2022 17:22:08 +0100 Message-Id: <65e00a120d1a330eb4e595f4bde72df46a6e16aa.1667490688.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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.3 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: 1667492577079100007 Content-Type: text/plain; charset="utf-8"; x-default="true" Introduced in QEMU's commit of v2.11.0-rc0~95^2~9 the .discard attribute of memory-backend-file is always available for all QEMU versions we support (4.2.0, currently). Therefore, we can assume the capability is always set and thus doesn't need to be checked for. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 15 ++++----------- .../pages-dimm-discard.x86_64-latest.args | 2 +- .../pages-discard-hugepages.x86_64-latest.args | 2 +- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index bcd30ef4f3..395b2e0a8f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3351,17 +3351,10 @@ qemuBuildMemoryBackendProps(virJSONValue **backendP= rops, return -1; =20 if (!mem->nvdimmPath && - discard =3D=3D VIR_TRISTATE_BOOL_YES) { - if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FI= LE_DISCARD)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("this QEMU doesn't support memory discard= ")); - return -1; - } - - if (virJSONValueObjectAdd(&props, - "B:discard-data", true, - NULL) < 0) - return -1; + virJSONValueObjectAdd(&props, + "T:discard-data", discard, + NULL) < 0) { + return -1; } =20 if (qemuBuildMemoryBackendPropsShare(props, memAccess) < 0) diff --git a/tests/qemuxml2argvdata/pages-dimm-discard.x86_64-latest.args b= /tests/qemuxml2argvdata/pages-dimm-discard.x86_64-latest.args index 6324443e93..19ed3928de 100644 --- a/tests/qemuxml2argvdata/pages-dimm-discard.x86_64-latest.args +++ b/tests/qemuxml2argvdata/pages-dimm-discard.x86_64-latest.args @@ -29,7 +29,7 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-fedora/.config \ -no-acpi \ -boot strict=3Don \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ --object '{"qom-type":"memory-backend-file","id":"memdimm0","mem-path":"/de= v/hugepages1G/libvirt/qemu/-1-fedora","prealloc":true,"size":1073741824,"ho= st-nodes":[1,2,3],"policy":"bind"}' \ +-object '{"qom-type":"memory-backend-file","id":"memdimm0","mem-path":"/de= v/hugepages1G/libvirt/qemu/-1-fedora","discard-data":false,"prealloc":true,= "size":1073741824,"host-nodes":[1,2,3],"policy":"bind"}' \ -device '{"driver":"pc-dimm","node":0,"memdev":"memdimm0","id":"dimm0","sl= ot":0}' \ -object '{"qom-type":"memory-backend-file","id":"memdimm1","mem-path":"/va= r/lib/libvirt/qemu/ram/-1-fedora/dimm1","discard-data":true,"share":false,"= size":536870912}' \ -device '{"driver":"pc-dimm","node":0,"memdev":"memdimm1","id":"dimm1","sl= ot":1}' \ diff --git a/tests/qemuxml2argvdata/pages-discard-hugepages.x86_64-latest.a= rgs b/tests/qemuxml2argvdata/pages-discard-hugepages.x86_64-latest.args index 880e0de192..3b03f940f9 100644 --- a/tests/qemuxml2argvdata/pages-discard-hugepages.x86_64-latest.args +++ b/tests/qemuxml2argvdata/pages-discard-hugepages.x86_64-latest.args @@ -16,7 +16,7 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-SomeDummyHugepagesGu= /.config \ -m 1024 \ -overcommit mem-lock=3Doff \ -smp 2,sockets=3D2,cores=3D1,threads=3D1 \ --object '{"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/d= ev/hugepages2M/libvirt/qemu/-1-SomeDummyHugepagesGu","prealloc":true,"size"= :268435456}' \ +-object '{"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/d= ev/hugepages2M/libvirt/qemu/-1-SomeDummyHugepagesGu","discard-data":false,"= prealloc":true,"size":268435456}' \ -numa node,nodeid=3D0,cpus=3D0,memdev=3Dram-node0 \ -object '{"qom-type":"memory-backend-file","id":"ram-node1","mem-path":"/d= ev/hugepages2M/libvirt/qemu/-1-SomeDummyHugepagesGu","discard-data":true,"p= realloc":true,"size":805306368}' \ -numa node,nodeid=3D1,cpus=3D1,memdev=3Dram-node1 \ --=20 2.37.4