From nobody Mon Nov 25 02:51:17 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717666437; cv=none; d=zohomail.com; s=zohoarc; b=hAhf7vZddHEMDXt1lY6JPC2FUlCItyrxKD/QQpxCfvozQzXUEYcoS5xKEK+aPhd3vPYlCq7dV7uavODG9Cp9HnYUCwz3nPXsYgk0MVl1CeK0DhEjX0gtE2bWl9HeZSN9sE536NcWXAvzitR8oCRQVyvF25QsCwGTE4Pal6IHxtg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717666437; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From: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=QtmqXwvQtz9AetCc4aSYzY8LISUCeJ1ftIavHc81UjY=; b=TzotOjH72a8yuFSsL4AbecUkzUc7omlaxG9KNhntYV2wYittjYHZLRzlgMszMKxUj/77WV7ssTnNys7+cFihuwsSI1A3r4SEYyq0u6VSziIVZMgZ6/av3JIDEcuYJV707z5I3zxZ2vo+oeUXq9tAVERvxICcfY675Z7GPu5xYpI= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717666437919219.70870703609103; Thu, 6 Jun 2024 02:33:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF9Uv-0000QV-0Y; Thu, 06 Jun 2024 05:33:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF9Ut-0000Pz-Bl for qemu-devel@nongnu.org; Thu, 06 Jun 2024 05:33:27 -0400 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 1sF9Ur-0006s6-Rc for qemu-devel@nongnu.org; Thu, 06 Jun 2024 05:33:27 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-414-bTHahT-ePzKZDidVQnI0WA-1; Thu, 06 Jun 2024 05:33:23 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a68e0faf0e6so37117466b.2 for ; Thu, 06 Jun 2024 02:33:23 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c80581f08sm70705266b.44.2024.06.06.02.33.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 02:33:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717666405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=QtmqXwvQtz9AetCc4aSYzY8LISUCeJ1ftIavHc81UjY=; b=RgEMLil9nUvMq+vFaQNeGNde0Rkhbz1v9L2ADbYWXv4v7V7bk6lAJQo5pP1Hl9L17UpodP GYjjHxR8fEQUimv19OpB6V4+ESYjAqMLXB+vaFcyP8zMgkNf+OK6IJixmU6qqVFYHoEJtT 7YgHKhg3kuOEMX0eqyWCpUkPoJG4xDw= X-MC-Unique: bTHahT-ePzKZDidVQnI0WA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717666400; x=1718271200; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=QtmqXwvQtz9AetCc4aSYzY8LISUCeJ1ftIavHc81UjY=; b=hJeQSU9WEMUk6sl2z8bmYwlk6/gxdd54uSGdo0VeOFrenvRyuDR+Ixj31FPOzJ/IqX WKzAqNWp6dlaDR3dzS/T138ctl+2ymIk9C0xEW9MZIJnmNhIbW0/uXGtSIu9ENoG0XvY ODXDgNmVmwzl0cWeyZBukaxlFsTmCaS0yy0pWiScIPn3ERxnEgYhHs108U3ZZzwwqmpk z50/hdzUChIdLQogldH/G0FzjeOpKE5jOyzwQCdKc4FoAX0YuV1nd0AaLicwSibYqN9O zPNaTSEKpKoCd4oGR7CdTloZUvfIu9EkIilHbmpO9qPmadG9dcwg44fsGBlNfASGMB+S O8GQ== X-Gm-Message-State: AOJu0Yz2WTeMcwo4dV/MmrqyyctEyIAC9qrLOLHbTI0g/LxU6UWJdvDN 3Uoa7ylHHps+vttu/dcjpV9JRHhTr0Qt3q1YO/Y9/uN/4J/Xj8GUrFqmw/KWw/3ckUSdViXO9Jo 8TUkcW9plZcfPZ2+bDQOWdLovIb61OQkN5H6Wq59RDLC7MgWjbxVA3Ik2kviwfdH0J8VDff8o+Z iJ6uF/0C44e+XjF4P/ZEc4MXa9a8m8cYyf39lN X-Received: by 2002:a17:906:5647:b0:a63:3c57:5806 with SMTP id a640c23a62f3a-a699fccb79dmr314612866b.32.1717666400711; Thu, 06 Jun 2024 02:33:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3FO1K/1gPqv5Q3hLoQEHafs7DmuenX4vubjU2LijmwZJ+o19rohKqQ6A8wKl0HdpBcBzxyA== X-Received: by 2002:a17:906:5647:b0:a63:3c57:5806 with SMTP id a640c23a62f3a-a699fccb79dmr314610366b.32.1717666400125; Thu, 06 Jun 2024 02:33:20 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Michal Privoznik Subject: [PATCH] machine, hostmem: improve error messages for unsupported features Date: Thu, 6 Jun 2024 11:33:17 +0200 Message-ID: <20240606093317.2468231-1-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 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: 1717666438732100001 Content-Type: text/plain; charset="utf-8" Detect early unsupported MADV_MERGEABLE and MADV_DONTDUMP, and print a clea= rer error message that points to the deficiency of the host. Cc: Michal Privoznik Signed-off-by: Paolo Bonzini --- backends/hostmem.c | 16 ++++++++++++++++ hw/core/machine.c | 9 +++++++++ 2 files changed, 25 insertions(+) diff --git a/backends/hostmem.c b/backends/hostmem.c index 4d6c69fe4de..584ee160f9c 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -170,6 +170,14 @@ static void host_memory_backend_set_merge(Object *obj,= bool value, Error **errp) { HostMemoryBackend *backend =3D MEMORY_BACKEND(obj); =20 + if (QEMU_MADV_MERGEABLE =3D=3D QEMU_MADV_INVALID) { + if (value) { + error_setg(errp, "Memory merging is not supported on this host= \n"); + } + assert(!backend->merge); + return; + } + if (!host_memory_backend_mr_inited(backend)) { backend->merge =3D value; return; @@ -202,6 +210,14 @@ static void host_memory_backend_set_dump(Object *obj, = bool value, Error **errp) { HostMemoryBackend *backend =3D MEMORY_BACKEND(obj); =20 + if (QEMU_MADV_DONTDUMP =3D=3D QEMU_MADV_INVALID) { + if (!value) { + error_setg(errp, "Dumping guest memory cannot be disabled on t= his host\n"); + } + assert(backend->dump); + return; + } + if (!host_memory_backend_mr_inited(backend)) { backend->dump =3D value; return; diff --git a/hw/core/machine.c b/hw/core/machine.c index c31a672051c..2ac1250f575 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -17,6 +17,7 @@ #include "hw/loader.h" #include "qapi/error.h" #include "qapi/qapi-visit-machine.h" +#include "qemu/madvise.h" #include "qom/object_interfaces.h" #include "sysemu/cpus.h" #include "sysemu/sysemu.h" @@ -427,6 +428,10 @@ static void machine_set_dump_guest_core(Object *obj, b= ool value, Error **errp) { MachineState *ms =3D MACHINE(obj); =20 + if (!value && QEMU_MADV_DONTDUMP =3D=3D QEMU_MADV_INVALID) { + error_setg(errp, "Dumping guest memory cannot be disabled on this = host\n"); + return; + } ms->dump_guest_core =3D value; } =20 @@ -441,6 +446,10 @@ static void machine_set_mem_merge(Object *obj, bool va= lue, Error **errp) { MachineState *ms =3D MACHINE(obj); =20 + if (value && QEMU_MADV_MERGEABLE =3D=3D QEMU_MADV_INVALID) { + error_setg(errp, "Memory merging is not supported on this host\n"); + return; + } ms->mem_merge =3D value; } =20 --=20 2.45.1