From nobody Mon Nov 23 04:44:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794399908; cv=none; d=zohomail.com; s=zohoarc; b=fgo1xBAwnyk2fN32O1iY0oAgE/DOCA/SeB53H7JBWuEubzL3CD8Pen8UH9Zy31ujE/foWy87Q3xcN3w8//0L4Igq6coIkVAync19AAjszFOAiIB9GBtoV8bFV1kL3+5u5iNUatYzTQMLCsPW+G2TZ+EgQgvU4i4w0eZGL098Qzc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794399908; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0P+cPyOmWgZpP2DSvVKaKBOdBavTHl09lYIpmkqwzCE=; b=eXXEvMdG37GZleBKAxV3QaCkAUjG66z/PyVKiuokmZUOSXlzMWYjMSS5eqBLEw17dDBQD2rezVZNsxj9hJiMroM1iR8+ATXhENWDsDDaSXUBHFDf2MuVxLKLimCF4eXun1PgmdN5cVQFAx0+c4JWuPQBMgZD8lwUmPxpdjUm/fM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794399908480447.07566606102125; Wed, 11 Nov 2026 04:25:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xR7N4-000331-3E; Wed, 11 Nov 2026 07:24:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xR7Mn-0002zk-M9 for qemu-devel@nongnu.org; Wed, 11 Nov 2026 07:23:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xR7Mk-0000ZT-CG for qemu-devel@nongnu.org; Wed, 11 Nov 2026 07:23:52 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-689-9Kd0SqXhP0m4s02iaT-bxQ-1; Wed, 11 Nov 2026 07:23:46 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EF25C1955D88; Wed, 11 Nov 2026 12:23:44 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.44.22.7]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 975E91800542; Wed, 11 Nov 2026 12:23:44 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 391D721E692D; Wed, 11 Nov 2026 13:23:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794399829; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0P+cPyOmWgZpP2DSvVKaKBOdBavTHl09lYIpmkqwzCE=; b=FyuqsjjNHwvqRMYZSnDtPffsknZ/+cUg9R5rpXgeUu6iF5svHpHe0ci+vYwfCHS5Wf6Ij8 CrxeV1cuF/tzsr8eib1mUjU8VWz5p6i/R+hwg76G0mH4ORTMtMgwu8Twjex/+XcWa5b6TU haisrRydBgFHPpD7QnbFI6d5z09p0PQ= X-MC-Unique: 9Kd0SqXhP0m4s02iaT-bxQ-1 X-Mimecast-MFC-AGG-ID: 9Kd0SqXhP0m4s02iaT-bxQ_1794399825 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: david@kernel.org, imammedo@redhat.com, berrange@redhat.com, peter.maydell@linaro.org Subject: [PATCH 1/7] backends/hostmem: Drop redundant validation of property "size" Date: Wed, 11 Nov 2026 13:23:36 +0100 Message-ID: <20261111122342.634370-2-armbru@redhat.com> In-Reply-To: <20261111122342.634370-1-armbru@redhat.com> References: <20261111122342.634370-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794399910134158500 Content-Type: text/plain; charset="utf-8" Property "size" is mandatory, and its setter host_memory_backend_set_size() rejects value zero. Delete the redundant checks for zero in the .alloc() callbacks. Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Mark Cave-Ayland --- backends/hostmem-epc.c | 5 ----- backends/hostmem-file.c | 4 ---- backends/hostmem-memfd.c | 5 ----- backends/hostmem-ram.c | 5 ----- backends/hostmem-shm.c | 5 ----- 5 files changed, 24 deletions(-) diff --git a/backends/hostmem-epc.c b/backends/hostmem-epc.c index ab20b182331..e1c784249ff 100644 --- a/backends/hostmem-epc.c +++ b/backends/hostmem-epc.c @@ -24,11 +24,6 @@ sgx_epc_backend_memory_alloc(HostMemoryBackend *backend,= Error **errp) uint32_t ram_flags; int fd; =20 - if (!backend->size) { - error_setg(errp, "can't create backend with size 0"); - return false; - } - fd =3D qemu_open("/dev/sgx_vepc", O_RDWR, errp); if (fd < 0) { return false; diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index 6ad9cad0320..08d0382d76f 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -48,10 +48,6 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Er= ror **errp) g_autofree gchar *name =3D NULL; uint32_t ram_flags; =20 - if (!backend->size) { - error_setg(errp, "can't create backend with size 0"); - return false; - } if (!fb->mem_path) { error_setg(errp, "mem-path property not set"); return false; diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c index 46489212a23..11d456e3ebd 100644 --- a/backends/hostmem-memfd.c +++ b/backends/hostmem-memfd.c @@ -49,11 +49,6 @@ memfd_backend_memory_alloc(HostMemoryBackend *backend, E= rror **errp) int fd =3D cpr_find_fd(name, 0); uint32_t ram_flags; =20 - if (!backend->size) { - error_setg(errp, "can't create backend with size 0"); - return false; - } - if (fd >=3D 0) { goto have_fd; } diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c index 6a507fad77c..0ae7b4ae759 100644 --- a/backends/hostmem-ram.c +++ b/backends/hostmem-ram.c @@ -22,11 +22,6 @@ ram_backend_memory_alloc(HostMemoryBackend *backend, Err= or **errp) g_autofree char *name =3D NULL; uint32_t ram_flags; =20 - if (!backend->size) { - error_setg(errp, "can't create backend with size 0"); - return false; - } - name =3D host_memory_backend_get_name(backend); ram_flags =3D backend->share ? RAM_SHARED : RAM_PRIVATE; ram_flags |=3D backend->reserve ? 0 : RAM_NORESERVE; diff --git a/backends/hostmem-shm.c b/backends/hostmem-shm.c index adf60957c3c..0a01c760551 100644 --- a/backends/hostmem-shm.c +++ b/backends/hostmem-shm.c @@ -30,11 +30,6 @@ shm_backend_memory_alloc(HostMemoryBackend *backend, Err= or **errp) uint32_t ram_flags; int fd =3D cpr_find_fd(backend_name, 0); =20 - if (!backend->size) { - error_setg(errp, "can't create shm backend with size 0"); - return false; - } - if (!backend->share) { error_setg(errp, "can't create shm backend with `share=3Doff`"); return false; --=20 2.55.0 From nobody Mon Nov 23 04:44:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794399902; cv=none; d=zohomail.com; s=zohoarc; b=EWrLssIX4jaETqXBQ3gBQtHohZUF8koRDsXpguXF0GaOhulW8Rdpk6eA10SWTHQ5UOlz2BGWdqWz44lYMa/SDbT6k8jLmcx+U+FNVX79Vu8S0w4vnG6rf7WEiayKX7EP0xvMBLsswm7EX73j5h/a39/ZRioOZzonFbOZupLqrTc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794399902; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZwCcB3cX28qoAvoTIzSD810qDfQrOekZQk10YH00LIM=; b=iUOresIF/j6n5Gk2S57uMzBeKq92Ri8y5T6KragkiUzxl+yXfMO4DY1W/7eTQd4XhMcu5IjNXBcYZ8TwlmVsldiieKiMHWs7d8iqbQr/ljF2pBkjB2SkD2UGI5UNd5kC6qlXtLcVLRyUbq6NArdAjltevTydIBwH6C1684uoNio= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794399902589951.5590762136293; Wed, 11 Nov 2026 04:25:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xR7Mq-00030H-La; Wed, 11 Nov 2026 07:23:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xR7Ml-0002zO-K6 for qemu-devel@nongnu.org; Wed, 11 Nov 2026 07:23:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xR7Mk-0000ZS-1r for qemu-devel@nongnu.org; Wed, 11 Nov 2026 07:23:51 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-570-dTFM5mSrOIilBanKqKjpbQ-1; Wed, 11 Nov 2026 07:23:46 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 40D801954105; Wed, 11 Nov 2026 12:23:45 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.44.22.7]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A5B391800545; Wed, 11 Nov 2026 12:23:44 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3DA9D21E6880; Wed, 11 Nov 2026 13:23:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794399829; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZwCcB3cX28qoAvoTIzSD810qDfQrOekZQk10YH00LIM=; b=QEqQoBKdQahBAqGr36vrupu+S7+A0phtOFtAnNSyYbEf9ZdRHmqkGSQuQV/b0fmChIhGWc LW7WEutdPivTIouG9EsUm4VO403inirPFrNNd57+GReZ9qKdrM9nwIhQEFeDkEs31b2U2q pRNhcQuKGJSjbe/aE/tTJYssdHO7W2U= X-MC-Unique: dTFM5mSrOIilBanKqKjpbQ-1 X-Mimecast-MFC-AGG-ID: dTFM5mSrOIilBanKqKjpbQ_1794399825 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: david@kernel.org, imammedo@redhat.com, berrange@redhat.com, peter.maydell@linaro.org Subject: [PATCH 2/7] backends/hostmem-file: Drop useless validation of property "mem-path" Date: Wed, 11 Nov 2026 13:23:37 +0100 Message-ID: <20261111122342.634370-3-armbru@redhat.com> In-Reply-To: <20261111122342.634370-1-armbru@redhat.com> References: <20261111122342.634370-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794399903987158501 Content-Type: text/plain; charset="utf-8" A non-optional string property like "mem-path" cannot be null. Drop the useless check. Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Mark Cave-Ayland --- backends/hostmem-file.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index 08d0382d76f..1e8f8ae6aa8 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -48,11 +48,6 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Er= ror **errp) g_autofree gchar *name =3D NULL; uint32_t ram_flags; =20 - if (!fb->mem_path) { - error_setg(errp, "mem-path property not set"); - return false; - } - switch (fb->rom) { case ON_OFF_AUTO_AUTO: /* Traditionally, opening the file readonly always resulted in ROM= . */ --=20 2.55.0 From nobody Mon Nov 23 04:44:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794399859; cv=none; d=zohomail.com; s=zohoarc; b=OpzTzBKVGTsGPmf9uipwpUfzs9LK3yv1LBjwMmKEEmjvsoaNHj4p+K+n7mtBbLy8LuaDsX/IGxRxkruqi7F2D5CxVWKAqFsg91lnGIoZBuwG1FUL6/a09j0lQrA2l4kqHJvUMPvYtXFdXYVWRSRoqOuVxO7FnnnVs1fBeSdI9iQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794399859; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OYS0n+j2SskWhCisVLijNH4ZXdpdbSunH8tVqWIrrSo=; b=m3HG3o6j0MzYGjlDOM5+u1p7/EraTFxKrRzltB+yqpD3Uzlt+/BB3tCXxa8nmfXK9qc8/CxOOre88n8G3cZKR0KW3/J6uQVZBkIWa3C3FQOc0QaaDfSg17kpUevyyPc+j86efklh4QuWkZH8FPNmcCFeIYbuDnRuJvpj1hmmPT0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179439985976967.68673377499306; Wed, 11 Nov 2026 04:24:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xR7Ms-00030l-TM; Wed, 11 Nov 2026 07:23:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xR7Mn-0002zl-NB for qemu-devel@nongnu.org; Wed, 11 Nov 2026 07:23:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xR7Mk-0000ZQ-Ca for qemu-devel@nongnu.org; Wed, 11 Nov 2026 07:23:52 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-655--v-vlIPyMrmvMM3cob7dJQ-1; Wed, 11 Nov 2026 07:23:45 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F0C52180288A; Wed, 11 Nov 2026 12:23:44 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.44.22.7]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 97A3219634EF; Wed, 11 Nov 2026 12:23:44 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 41D5F21E6882; Wed, 11 Nov 2026 13:23:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794399829; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OYS0n+j2SskWhCisVLijNH4ZXdpdbSunH8tVqWIrrSo=; b=HXL3fAtzgrEj7p6FpdFumCyoMmeVoXBbMvGMbxaaEi+Hmw0GA4iMNzUGJKgR8Nz11xsuMr VpT7nRnpStSUKQn7uXxg9lOegYrCGgBnRKfwNyjdiHZjRkBZaeIwiiSsUMaSFHPDpQpT2J Jl9NWPiHRf4gGgO1oliPYX4lx/iB1yE= X-MC-Unique: -v-vlIPyMrmvMM3cob7dJQ-1 X-Mimecast-MFC-AGG-ID: -v-vlIPyMrmvMM3cob7dJQ_1794399825 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: david@kernel.org, imammedo@redhat.com, berrange@redhat.com, peter.maydell@linaro.org Subject: [PATCH 3/7] backends/hostmem: Improve error reporting when method alloc() fails Date: Wed, 11 Nov 2026 13:23:38 +0100 Message-ID: <20261111122342.634370-4-armbru@redhat.com> In-Reply-To: <20261111122342.634370-1-armbru@redhat.com> References: <20261111122342.634370-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794399861824158500 Content-Type: text/plain; charset="utf-8" When HostMemoryBackend method alloc() fails, the error report isn't always clear. E.g. "-object memory-backend-shm,id=3Dmem0,size=3D1E" fails for me like this: qemu-system-x86_64: unable to map backing store for guest RAM: Cannot a= llocate memory Leaves users guessing which part of the (often lengthy) command line needs fixing. Let's prepend a bit of context: qemu-system-x86_64: can't create memory-backend-shm: unable to map back= ing store for guest RAM: Cannot allocate memory This makes an error message in shm_backend_memory_alloc() partly redundant: qemu-system-x86_64: can't create memory-backend-shm: can't create shm b= ackend with `share=3Doff` Change it to qemu-system-x86_64: can't create memory-backend-shm: backend requires '= share=3Don' Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Mark Cave-Ayland --- backends/hostmem-shm.c | 2 +- backends/hostmem.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/backends/hostmem-shm.c b/backends/hostmem-shm.c index 0a01c760551..d1cba22cbeb 100644 --- a/backends/hostmem-shm.c +++ b/backends/hostmem-shm.c @@ -31,7 +31,7 @@ shm_backend_memory_alloc(HostMemoryBackend *backend, Erro= r **errp) int fd =3D cpr_find_fd(backend_name, 0); =20 if (!backend->share) { - error_setg(errp, "can't create shm backend with `share=3Doff`"); + error_setg(errp, "backend requires 'share=3Don'"); return false; } =20 diff --git a/backends/hostmem.c b/backends/hostmem.c index 173d042be35..1c2a5d42fc5 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -335,6 +335,7 @@ size_t host_memory_backend_pagesize(HostMemoryBackend *= memdev) static void host_memory_backend_memory_complete(UserCreatable *uc, Error **errp) { + ERRP_GUARD(); HostMemoryBackend *backend =3D MEMORY_BACKEND(uc); HostMemoryBackendClass *bc =3D MEMORY_BACKEND_GET_CLASS(uc); void *ptr; @@ -346,6 +347,8 @@ host_memory_backend_memory_complete(UserCreatable *uc, = Error **errp) return; } if (!bc->alloc(backend, errp)) { + error_prepend(errp, "can't create '%s': ", + object_get_typename(OBJECT(uc))); return; } =20 --=20 2.55.0 From nobody Mon Nov 23 04:44:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794399852; cv=none; d=zohomail.com; s=zohoarc; b=O4v4yVsexj9pqfVNBGIQArx2I5IxtCiInS+EhxDTZun19dqb/4cdtwxec3jd7AFSFmlyvCAKYB7oikKaPCNRz1uzVWKJY7yZu29rSvfdsYmxgomkDa3SEwPnmzlQvpvNTP0EzazEs1Cs8nRs14r44n3MBYt01/Bq8/NqyVjAuFM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794399852; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=C3vLRlEciCIlHobsQE7L+mIHGxa0ovifEfqsih4JayE=; b=dUg2Rsuo8FX0i43B7+3zEHMCOkOVVbFcU0l/hXJUYT+PMa469KIvC1rUpQLulVDqMV1gBNWaRU+XUbBll3fcV89bSQAssYbGEAeDPZrKISqwcfF6NP+3J7eqFxNB6JVVHLallzzYhVz13h3iB+ifgxqVF1uv8vXsVZwIZgl0SaU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794399852304321.0809029644014; Wed, 11 Nov 2026 04:24:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xR7Mm-0002zP-LS; Wed, 11 Nov 2026 07:23:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xR7Mk-0002zF-Hk for qemu-devel@nongnu.org; Wed, 11 Nov 2026 07:23:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xR7Mi-0000Z5-Tu for qemu-devel@nongnu.org; Wed, 11 Nov 2026 07:23:50 -0500 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-570-nJs39w55OoSqZodDEYueFg-1; Wed, 11 Nov 2026 07:23:46 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2956C1956042; Wed, 11 Nov 2026 12:23:45 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.44.22.7]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BB1F730000D3; Wed, 11 Nov 2026 12:23:44 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 464C521E6883; Wed, 11 Nov 2026 13:23:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794399827; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C3vLRlEciCIlHobsQE7L+mIHGxa0ovifEfqsih4JayE=; b=Y7VX4/zcHJ1gZK4Zf30YDB8lqRJTx5KYDH75XUEnD892OlmDsjsl41Jtkn/iYdkSj/75YG Ftaj/IHdHTyvdD3Uw6SL1Cz2yFQ5rF5H2gV2Cj72EvF5O5VUdnKcL5vyP2vCmShIkDtvlh hrxUF8cZukmhXRYw50EkgL4nf9PPUVU= X-MC-Unique: nJs39w55OoSqZodDEYueFg-1 X-Mimecast-MFC-AGG-ID: nJs39w55OoSqZodDEYueFg_1794399825 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: david@kernel.org, imammedo@redhat.com, berrange@redhat.com, peter.maydell@linaro.org Subject: [PATCH 4/7] backends/hostmem-epc: Register QOM type unconditionally Date: Wed, 11 Nov 2026 13:23:39 +0100 Message-ID: <20261111122342.634370-5-armbru@redhat.com> In-Reply-To: <20261111122342.634370-1-armbru@redhat.com> References: <20261111122342.634370-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794399854004158500 Content-Type: text/plain; charset="utf-8" The example from docs/system/i386/sgx.rst section "Launching a guest" fails for me like this: $ qemu-system-x86_64 -cpu host,+sgx-provisionkey -object memory-backend= -epc,id=3Dmem1,size=3D64M,prealloc=3Don -M sgx-epc.0.memdev=3Dmem1,sgx-epc.= 0.node=3D0 qemu-system-x86_64: invalid object type: memory-backend-epc Device "sgx-epc" has a link property to a "memory-backend-epc" (SgxEPC member memdev). It's not optional, so we must create a "memory-backend-epc" to be able to create an "sgx-epc". In the test shown above, "sgx-epc" exists, but "memory-backend-epc" does not. The latter doesn't exist for me, because we register QOM type "memory-backend-epc" only when we can open /dev/sgx_vepc read/write, which fails for me. Such conditional registration is unusual and problematic: 1. Management applications use introspection interfaces to find out what a certain QEMU can do. Conditional type registration makes QOM introspection results depend on the condition, which generally makes them valid only for the process that produced them. Undesirable. 2. For user-creatable objects like "memory-backend-epc", it also makes QAPI introspection unreliable: query-qmp-schema claims the type exists (object-add argument @qom-type accepts "memory-backend-epc") even when it doesn't. Conditional registration actually serves no purpose here, because we still have to open /dev/sgx_vepc for real when we create the object, and need and do handle errors then. Register unconditionally. The example now fails to create the object, like this: qemu-system-x86_64: can't create 'memory-backend-epc': Could not open '= /dev/sgx_vepc': No such file or directory Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Mark Cave-Ayland --- backends/hostmem-epc.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/backends/hostmem-epc.c b/backends/hostmem-epc.c index e1c784249ff..bf5aecdfd45 100644 --- a/backends/hostmem-epc.c +++ b/backends/hostmem-epc.c @@ -62,12 +62,7 @@ static const TypeInfo sgx_epc_backed_info =3D { =20 static void register_types(void) { - int fd =3D qemu_open_old("/dev/sgx_vepc", O_RDWR); - if (fd >=3D 0) { - close(fd); - - type_register_static(&sgx_epc_backed_info); - } + type_register_static(&sgx_epc_backed_info); } =20 type_init(register_types); --=20 2.55.0 From nobody Mon Nov 23 04:44:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794399866; cv=none; d=zohomail.com; s=zohoarc; b=ZXYrpACvF9591ZG+8hRKntpuThiLrUG7fV+64V1iw/CCYo1Rywa2wCIS0NKnK8leO2vgPD86K97Ju5PwgknedZdpNn//hl3vBKW70fukkpbgxfoUZDAXCGrB1XZJBHD8iWfZstCJkhwsp7BlIza/HUKGGq8WRGf2GQxHTx26vpw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794399866; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=62srTw2+wEyhFy6oLDYqzbOfVJVthJpFlv/797xXiCQ=; b=E9EEUwXbuy6ayPFrs4IYA4AyRqB7k5vKSKXLSyV6mHF+THrQPif++NWadHfFivGm7Fx/hdeIpIBRCTLf+eR+FXeQnbkJDfCsCAnf6CjKl5+HPqlWpBx+j/wArrjtKf+r/uVLSf+0uVIoGRFvi1bZM+HJ33jbWnvBINT77FBx+Rg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794399866635139.09380694737752; Wed, 11 Nov 2026 04:24:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xR7N3-00032c-VK; Wed, 11 Nov 2026 07:24:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xR7Mq-00030I-9O for qemu-devel@nongnu.org; Wed, 11 Nov 2026 07:23:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xR7Mn-0000aM-FJ for qemu-devel@nongnu.org; Wed, 11 Nov 2026 07:23:54 -0500 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-604-Ch4UfNpTO9W7EMNyXLabhQ-1; Wed, 11 Nov 2026 07:23:48 -0500 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E4F561955E9E; Wed, 11 Nov 2026 12:23:47 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.44.22.7]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A3E7B428; Wed, 11 Nov 2026 12:23:47 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4A4CF21E6884; Wed, 11 Nov 2026 13:23:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794399832; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=62srTw2+wEyhFy6oLDYqzbOfVJVthJpFlv/797xXiCQ=; b=I4agY6rA364L48YDZq8wABcx9NZj1MWymSBe9pi9KxDKIGt374kH0dRV7fUGZp4gmCT5Gc MO8S4+Y6GVHGNWMwKgR8Tde3P57GpoYWU4edzetvwuzeZvyUFPfuaMJ2UM6ebm3EC7F7uo 2Z+Eoh8eFZCzzLgL071x5IbOL9pJg+A= X-MC-Unique: Ch4UfNpTO9W7EMNyXLabhQ-1 X-Mimecast-MFC-AGG-ID: Ch4UfNpTO9W7EMNyXLabhQ_1794399828 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: david@kernel.org, imammedo@redhat.com, berrange@redhat.com, peter.maydell@linaro.org Subject: [PATCH 5/7] backends/hostmem-memfd: Register QOM type unconditionally Date: Wed, 11 Nov 2026 13:23:40 +0100 Message-ID: <20261111122342.634370-6-armbru@redhat.com> In-Reply-To: <20261111122342.634370-1-armbru@redhat.com> References: <20261111122342.634370-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794399867735158501 Content-Type: text/plain; charset="utf-8" We register QOM type "memory-backend-memfd" only when a test of memfd_create() succeeds. Such conditional registration is unusual and problematic: 1. Management applications use introspection interfaces to find out what a certain QEMU can do. Conditional type registration makes QOM introspection results depend on the condition, which generally makes them valid only for the process that produced them. Undesirable. 2. For user-creatable objects like "memory-backend-memfd", it also makes QAPI introspection unreliable: query-qmp-schema claims the type exists (object-add argument @qom-type accepts "memory-backend-memfd") even when it doesn't. Conditional registration actually serves no purpose here, because we still have to memfd_create() for real when we create the object, and need and do handle errors then. Register the type unconditionally. To test, I hacked the qemu_memfd() call to fail. The error for -object memory-backend-memfd,id=3Dmem0,size=3D1m changes from qemu-system-x86_64: invalid object type: memory-backend-memfd to qemu-system-x86_64: can't create 'memory-backend-memfd': failed to crea= te memfd with flags 0x3: Invalid argument Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Mark Cave-Ayland --- backends/hostmem-memfd.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c index 11d456e3ebd..54f84ae331a 100644 --- a/backends/hostmem-memfd.c +++ b/backends/hostmem-memfd.c @@ -223,9 +223,7 @@ static const TypeInfo memfd_backend_info =3D { =20 static void register_types(void) { - if (qemu_memfd_check(MFD_ALLOW_SEALING)) { - type_register_static(&memfd_backend_info); - } + type_register_static(&memfd_backend_info); } =20 type_init(register_types); --=20 2.55.0 From nobody Mon Nov 23 04:44:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794399896; cv=none; d=zohomail.com; s=zohoarc; b=cZ8UVhjWE0s3PceHOLTbDAQGcMNSOp54cfvzXPEm5R7occr5Ak0dMwuHfjaMqzb8D+CKH4nOTF4RcPID2Jj56J4Z7HY2UoswX6pIsrgRbE0kdYuzhZv7+8FT6Y3wKVTYPq8kD3lXmgvo2b9in5U65TU0reZdbA8zzMGmO3xC2tc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794399896; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=s2G0/NvHPW8rwpgqAOqoslL0UPm0eNpV/K/Ju76RfXQ=; b=XMt+wC44hCUcmn10pqO4GjV89jgvH7m6aXmndd3j9gS8KT7HKye4fnXg8TXwPfnEQ4Deb1S7UFdiwkcdK+lU1upwtGvFjvY3GI3RsLvqLkLcjhKdGFC0vX1uvBPOUMlte/n+VdzhOObtzvn9bjzfJpfdZQURJ40eS79XU9RAoC8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794399896168784.95270131035; Wed, 11 Nov 2026 04:24:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xR7N7-00035u-IE; Wed, 11 Nov 2026 07:24:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xR7Mq-00030K-Ak for qemu-devel@nongnu.org; Wed, 11 Nov 2026 07:23:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xR7Mn-0000aD-FE for qemu-devel@nongnu.org; Wed, 11 Nov 2026 07:23:55 -0500 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-665-lFdF2YS5NQuxWQu9uYoRsw-1; Wed, 11 Nov 2026 07:23:48 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CF8281955F11; Wed, 11 Nov 2026 12:23:47 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.44.22.7]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 75D5B30000E8; Wed, 11 Nov 2026 12:23:47 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4E58B21E6885; Wed, 11 Nov 2026 13:23:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794399832; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s2G0/NvHPW8rwpgqAOqoslL0UPm0eNpV/K/Ju76RfXQ=; b=Ms47t+PEDFt1D1Vzzfqpyvv40ARRjhVIhqIPu7j7XLIgTM7h9e+yjMWjG8s4XHBVKJHJqu sqNOKldOTHW0owfBbcuMdCxtvYrRGeMj2f0rED7nKaLSvAukOB4n5wDaHApvyVlVCinn4a DyrMJiN/EP6cBilSOF7PSbwH7d5R0Zk= X-MC-Unique: lFdF2YS5NQuxWQu9uYoRsw-1 X-Mimecast-MFC-AGG-ID: lFdF2YS5NQuxWQu9uYoRsw_1794399827 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: david@kernel.org, imammedo@redhat.com, berrange@redhat.com, peter.maydell@linaro.org Subject: [PATCH 6/7] util/memfd: Improve error message when memfd_create() fails Date: Wed, 11 Nov 2026 13:23:41 +0100 Message-ID: <20261111122342.634370-7-armbru@redhat.com> In-Reply-To: <20261111122342.634370-1-armbru@redhat.com> References: <20261111122342.634370-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794399897929158500 Content-Type: text/plain; charset="utf-8" qemu_memfd_create() reports something like failed to create memfd with flags 0x3: Invalid argument when memfd_create() fails. To make sense of this, you have to understand what flags are, and how to decode them. qemu_memfd_create() computes the flags from @seals and @hugetlb, so show these instead, like this: failed to create memfd with sealing and without huge pages: Invalid arg= ument Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Mark Cave-Ayland --- util/memfd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/memfd.c b/util/memfd.c index 07beab174dc..a398b246600 100644 --- a/util/memfd.c +++ b/util/memfd.c @@ -73,7 +73,10 @@ int qemu_memfd_create(const char *name, size_t size, boo= l hugetlb, mfd =3D memfd_create(name, flags); if (mfd < 0) { error_setg_errno(errp, errno, - "failed to create memfd with flags 0x%x", flags); + "failed to create memfd %s sealing" + " and %s huge pages", + seals ? "with" : "without", + hugetlb ? "with" : "without"); goto err; } =20 --=20 2.55.0 From nobody Mon Nov 23 04:44:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794399910; cv=none; d=zohomail.com; s=zohoarc; b=nVg0Uung48rmsmEMnEsOrjquW0NJzQdPsbxmmJF1NGsfZvccebHvdAhfHmUJuGNeuTXSPuKs63BjxBGamgYBqDlH756FSP5Q6/U7ZWOCbDdipXfTGEF2gl5XefpJ2KmTT+4ahDCI4NYcPG6wnXGe7ZQgQPPUfxvHC9qOpX/AJw0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794399910; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cYeIuHkJq8KVmqRw5LWmD+FFHqEWlzgVfMlQuWH72/4=; b=DcFRwkGvthRK59e1U0kLUNcIQwIQYfjxrdhDk58s0lJq2yxR1xbDNbLU8OzgCoSjIejSd8ksmLyc4f6qQwf4IfFlEI6Bk/AU3w0IGMmH+6dCxfnsHqozgjSm/O/38+1MScveyss2XjMGZgy7cH7GwlD5Z/AxFsX4IQalXWtQ+Qg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794399910955710.077818774752; Wed, 11 Nov 2026 04:25:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xR7Mx-00031v-W8; Wed, 11 Nov 2026 07:24:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xR7Mq-00030J-Ae for qemu-devel@nongnu.org; Wed, 11 Nov 2026 07:23:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xR7Mn-0000aK-FA for qemu-devel@nongnu.org; Wed, 11 Nov 2026 07:23:55 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-660-sS5pvsqDNRSktdh4QG0vqg-1; Wed, 11 Nov 2026 07:23:48 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CE0E41800D98; Wed, 11 Nov 2026 12:23:47 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.44.22.7]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8C99E1800495; Wed, 11 Nov 2026 12:23:47 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5256721E6886; Wed, 11 Nov 2026 13:23:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794399832; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cYeIuHkJq8KVmqRw5LWmD+FFHqEWlzgVfMlQuWH72/4=; b=iXgDrk/PXL90mDY9YO5nEP9w4kSCKKV4Fl6OTB2BgUUAlMD8aEcMQrbmOkt0IzeturARhJ pqyvduLrd8DEpclYtB5fUnEpTQAZW1tSv1FmnzHPxT7smmwNSmIdAlHaTnm+IHLPuyFKuw rKV6G3heoAhN4+yaAtusRqDVZ9NCHJk= X-MC-Unique: sS5pvsqDNRSktdh4QG0vqg-1 X-Mimecast-MFC-AGG-ID: sS5pvsqDNRSktdh4QG0vqg_1794399827 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: david@kernel.org, imammedo@redhat.com, berrange@redhat.com, peter.maydell@linaro.org Subject: [PATCH 7/7] backends/hostmem-memfd: Add huge TLB properties unconditionally Date: Wed, 11 Nov 2026 13:23:42 +0100 Message-ID: <20261111122342.634370-8-armbru@redhat.com> In-Reply-To: <20261111122342.634370-1-armbru@redhat.com> References: <20261111122342.634370-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794399912208158500 Content-Type: text/plain; charset="utf-8" We add class properties "hugetlb" and "hugetlbsize" only when a test of memfd_create() succeeds. Such conditional registration is unusual and can be problematic: 1. Management applications use introspection interfaces to find out what a certain QEMU can do. Conditional property addition makes QOM introspection results depend on the condition, which generally makes them valid only for the process that produced them. Undesirable. 2. For user-creatable objects like "memory-backend-memfd", it also makes QAPI introspection unreliable: query-qmp-schema claims the properties exist (object-add takes arguments @hugetlb and @hugetlbsize when argument @qom-type is "memory-backend-memfd") even when it doesn't. Conditional registration actually serves no purpose here, because we still have to memfd_create() for real when we create the object, and need and do handle errors then. Moreover, we actually KVM ioctl KVM_CREATE_GUEST_MEMFD instead of memfd_create() there when @guest-memfd is on. If the memfd_create() check can fail when the ioctl could still succeed, the condition is counter-productive. Add the properties unconditionally. To test, I hacked the qemu_memfd() call to fail. The error for -object memory-backend-memfd,id=3Dmem0,size=3D1m,hugetlb=3Doff,hugetlbsize= =3D512,seal=3Don changes from qemu-system-x86_64: Property 'memory-backend-memfd.hugetlbsize' not fou= nd to qemu-system-x86_64: can't create 'memory-backend-memfd': failed to crea= te memfd with sealing and without huge pages: Invalid argument Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Mark Cave-Ayland --- backends/hostmem-memfd.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c index 54f84ae331a..b945fc46021 100644 --- a/backends/hostmem-memfd.c +++ b/backends/hostmem-memfd.c @@ -184,20 +184,18 @@ memfd_backend_class_init(ObjectClass *oc, const void = *data) =20 bc->alloc =3D memfd_backend_memory_alloc; =20 - if (qemu_memfd_check(MFD_HUGETLB)) { - object_class_property_add_bool(oc, "hugetlb", - memfd_backend_get_hugetlb, - memfd_backend_set_hugetlb); - object_class_property_set_description(oc, "hugetlb", - "Use huge pages"); - object_class_property_add(oc, "hugetlbsize", "uint64", - &uint64_type_info, - memfd_backend_get_hugetlbsize, - memfd_backend_set_hugetlbsize, - NULL, NULL); - object_class_property_set_description(oc, "hugetlbsize", - "Huge pages size (ex: 2M, 1G= )"); - } + object_class_property_add_bool(oc, "hugetlb", + memfd_backend_get_hugetlb, + memfd_backend_set_hugetlb); + object_class_property_set_description(oc, "hugetlb", + "Use huge pages"); + object_class_property_add(oc, "hugetlbsize", "uint64", + &uint64_type_info, + memfd_backend_get_hugetlbsize, + memfd_backend_set_hugetlbsize, + NULL, NULL); + object_class_property_set_description(oc, "hugetlbsize", + "Huge pages size (ex: 2M, 1G)"); =20 object_class_property_add_enum(oc, "guest-memfd", "OnOffAuto", &OnOffAuto_type_info, --=20 2.55.0