From patchwork Wed May 24 09:37:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 685318 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp150049wrt; Wed, 24 May 2023 02:39:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7X3HPnH8050u/yKM2wO/HS5TjnEjhGQKmkfuomWXfl4PcYbHiVtJM2z+tM+464S2n1nleJ X-Received: by 2002:a05:6214:2526:b0:621:1c72:af3 with SMTP id gg6-20020a056214252600b006211c720af3mr29831115qvb.0.1684921154812; Wed, 24 May 2023 02:39:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684921154; cv=none; d=google.com; s=arc-20160816; b=tL1feoRAHkRCJVq23lRM9pnzYiuYDve0j54Y/2wtofRGOFwYfqq8/sj/9DnkUMqhpc +jJklUiu7VELMmNtXSP2ePp4BLq/Jg7w1IXb7oHqMLxMik7CERoTM5GvzqH4t0ClPYyW GaWpaLnn8rgrE5c92g2RAilDYla/IeDsLz4ll1Vz3Tj1Xmyfc0zLeQImZmCuI2xhUF+Q 6gcrEGsdW+tEiw17yTyIksngZI+Edo+aP3OaYuGroy7Qbo3MSO/E1Yq6PBrUL9JtCX3P aextRvJW1AIKKneKa4SW2VQGi0fj2H/oEuunZqfOH+tu9dDea2+0WB2D8Xr1gnOwr3Qq Am9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sD8LkN6PYocK+4LFobiH3Rbgv5aMaPCfkIOTcADWQcM=; b=eIHMpXFijFQEt4XFpdbJYlSxt9GaxvwcDcmOZt7R6UEiQlqcF1NFMkPLAOIrz6UNP0 hoXL4WD5A8lqcvK7nFZtHDPcWpqgaJG62pyxcwFg8SbZqqeu0sIgYL7qs8+ye7IWyVow 20C1meCj8ACe+m/YdrxhAm6lT6E6zxDD3K84gGjC95SJq2CmoIYvBBmvQOV+o0rM0MHH s2YYdYMVohGjLNjyV4bOru20vElTwbHQqce2dBDjU/V7zmPHDDp1BvAD695p3Am9zNys fbWFpxRy6hsnmSPQ/9RYNDYgA7khV7sFamwUQJO+LdTr5EfeOCC47S7Qsk8GNoRXa5e9 NRjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t5ZS5eHH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ib15-20020a0562141c8f00b005ab0738009dsi6429731qvb.263.2023.05.24.02.39.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 May 2023 02:39:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t5ZS5eHH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q1kx3-00071u-K8; Wed, 24 May 2023 05:38:37 -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 1q1kx1-0006tN-U5 for qemu-devel@nongnu.org; Wed, 24 May 2023 05:38:35 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q1kwz-0006sr-G7 for qemu-devel@nongnu.org; Wed, 24 May 2023 05:38:35 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3f603d4bc5bso8702035e9.3 for ; Wed, 24 May 2023 02:38:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684921111; x=1687513111; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sD8LkN6PYocK+4LFobiH3Rbgv5aMaPCfkIOTcADWQcM=; b=t5ZS5eHH7Za4n9Bz14C1Zm4CppR4RqeHROlfglbpyICimhk6WaMmXbjJo10duj+nXA 3wN1DafWuiueCU5T59SQG4DDMuzjw2/MAqDO/fRIVr5cbQ9Gge9P5prg0dZyIDsna8AZ oSZSHyqX10vODrzBcoDKgggcnum5jpBNtuGlA1RDKn86DDt3jlwJpGzjON+fXq/e/ZO0 8uYzHuyHKzlS+B4Tg30TcMUOhL+NPV+SCWVRAnG4DDKJ7PTyUSt0G1/T/KwEqNI6DyMw rlN2oW120/Y9VbujjsxT9iAPmIbLnIfQVK1jf5q1H7pMNQUj36I3wWltInZX5KDwHPOS fsiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684921111; x=1687513111; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sD8LkN6PYocK+4LFobiH3Rbgv5aMaPCfkIOTcADWQcM=; b=TSf+R3tNSNxywEst3OmMzvnv24IAc2xC+FwYH7V35fy6S928cojNaSzJEwopysGxDE GDixDQs9bDm3mFmqsk3SOuEcAhzJTXjsX2o5fqU5JpmM6XYb2qErajtYklx5Opk8nLS6 1P7LWumCXwwPX/iTrxuhAhjg84ta9xg0r5L3fRE/FrDo1HRejw/r17ZJnQ/4rXYeqXro 9f0RkOKFRnbLmWJScB0HxfwzZ3U+/IiBOM5kcGmEGbncUFtpzSJgj+wgHz9MLHCCUq6V NYBiMGezobXSmWxWLdy98IqJ2P5iyDjbcyl4NO7caCW6wrvEXJnMQbjcmVT8rT/KA44n kxag== X-Gm-Message-State: AC+VfDzxg1SiflDTnmZ5dHSfB6q4d4OVDCM2bfIVMPvkPizdtG0SooMd t43iIzd6RNX9kugqhW5gPp2PjuLNX5O/wxfCiZtgbg== X-Received: by 2002:a05:600c:3655:b0:3f3:f7f0:2203 with SMTP id y21-20020a05600c365500b003f3f7f02203mr11925911wmq.12.1684921111471; Wed, 24 May 2023 02:38:31 -0700 (PDT) Received: from localhost.localdomain (fac34-h02-176-184-31-246.dsl.sta.abo.bbox.fr. [176.184.31.246]) by smtp.gmail.com with ESMTPSA id l5-20020a1c7905000000b003f4289b18a7sm1753181wme.5.2023.05.24.02.38.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 24 May 2023 02:38:30 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Fam Zheng , Thomas Huth , Paolo Bonzini , Eric Farman , Peter Xu , Hanna Reitz , Christian Borntraeger , "Michael S. Tsirkin" , Raphael Norwitz , Ilya Leoshkevich , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Eric Auger , "Gonglei (Arei)" , David Hildenbrand , Stefan Hajnoczi , qemu-s390x@nongnu.org, Cornelia Huck , Halil Pasic , qemu-block@nongnu.org, Kevin Wolf Subject: [PATCH v2 06/10] hw/virtio/virtio-mem: Use qemu_ram_get_fd() helper Date: Wed, 24 May 2023 11:37:40 +0200 Message-Id: <20230524093744.88442-7-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230524093744.88442-1-philmd@linaro.org> References: <20230524093744.88442-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Avoid accessing RAMBlock internals, use the provided qemu_ram_get_fd() getter to get the file descriptor. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: David Hildenbrand Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée --- hw/virtio/virtio-mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index 538b695c29..74e63bd47a 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -135,7 +135,7 @@ static bool virtio_mem_has_shared_zeropage(RAMBlock *rb) * anonymous RAM. In any other case, reading unplugged *can* populate a * fresh page, consuming actual memory. */ - return !qemu_ram_is_shared(rb) && rb->fd < 0 && + return !qemu_ram_is_shared(rb) && qemu_ram_get_fd(rb) < 0 && qemu_ram_pagesize(rb) == qemu_real_host_page_size(); } #endif /* VIRTIO_MEM_HAS_LEGACY_GUESTS */