From patchwork Tue Oct 17 14:01:44 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: 734404 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp497689wro; Tue, 17 Oct 2023 07:02:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWNzSU9p+gwSPALmjvGZx63HWf6GQRYhv0C6Y8IAdaixQogSST7OfkWOu1dYwgdk7J9QTw X-Received: by 2002:a05:6102:2ea:b0:457:c982:57f9 with SMTP id j10-20020a05610202ea00b00457c98257f9mr2564061vsj.23.1697551374547; Tue, 17 Oct 2023 07:02:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697551374; cv=none; d=google.com; s=arc-20160816; b=ZYx8ZY+nHcE99xjLpBjNvaidKZSsi88vqqOiBc0HV1cppaL6rZFxaTVznf3AmD4Lj0 wlieMyk0vioZFeyoaj0vChaTBm+7u7Zx5F0n7ujJf7MzJG5qf2wTFXvzOltLJhg9hayz fkYp0C/7s6cTXRi+4kYcrGfELrOP1OFHXKWUnHk9ESeSBLS61MLtuT5Tfw/nUMsfWssQ JsiUVrJHbPTd7b/QJouOHUmrf4FuZ2F8Lj22tzeaDmBUKk+ljfjZrOIwJgyw/Ica+NaI OssLZWwDCDbxWxNfuzpyAZX8/H8lVXeOurXg7gPLa16c2B1qbXegFy2Tn+FD2ClLHloI Tllw== 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=jK9MnOkarN7NF0Qc/XLSYHaYAFfcVhsfbF2N1g/hNuw=; fh=PkQUf9c5shm23GEgSgwIjaGjrTFXVTBGToef+bFaIfM=; b=LpSCaMXas7puraMRNI3+YwqlRd54OsxW3lRXLPEu3vFMTzinO314+6AhvViwMCLYV4 ewNIZTHLlgB5MmS0q18la5V5pupevZE7qkFxL4s4c7keTB8p+ZW4mdI4YWHDU73EQtQi i3+NmwbAUBAXU3K80yva8beXcHTCz7ZBW0UpS8xvvMsTZE2N5AmR6MMDeYi6P/ZDA7uj 4umctYbwzO8M3djlAP+zF2YCrSDPgcFBfXsJDm0woucLV6nZLIqjtubLGuOCYRKFyaZz NJT0joXeH88hYeRQI8KYMnIT6rotsmLIEF/sN5yTD/oiPY/IGCO0D9M1cNCJoQXUJDpV am/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zSdT+W3R; 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 az18-20020a056102285200b00440a6ecd062si117339vsb.338.2023.10.17.07.02.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Oct 2023 07:02:54 -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=zSdT+W3R; 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 1qskeI-000402-BX; Tue, 17 Oct 2023 10:02:18 -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 1qskeD-0003yO-P6 for qemu-devel@nongnu.org; Tue, 17 Oct 2023 10:02:16 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qske4-0008Ko-T8 for qemu-devel@nongnu.org; Tue, 17 Oct 2023 10:02:13 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4056ce55e7eso54919655e9.2 for ; Tue, 17 Oct 2023 07:02:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697551322; x=1698156122; darn=nongnu.org; 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=jK9MnOkarN7NF0Qc/XLSYHaYAFfcVhsfbF2N1g/hNuw=; b=zSdT+W3RXlk8Y+3VgBCP3MsJ/OnvuuLZTZbf33m0UqBVFYinFzWm6xqx6vKB6VfhXd gG+KmKFbIUiNRNOdeQUutJzVOmjxZ7ba+ROV/s0htRUPb5NPdvbQ39sMMIODSIlu/5rW mTUwO+ntSr7ziwNfdqQNZcrLoHSnvWd6xQ4SDOdOTUinTj867TNy34HndKO7fx+oZkj4 wSbFIDxlWYkl/ew3vhaPebKznJv45Hr17BeJ+6hH8v+fXa20RaHa9qF8L1WyhFGjWIww 0tQKRHF40rF+C/QVRDtLqgNAJPgVkNAGXexNxl/dQTuSHPw+TxzBQavNWEI9RlFzGWvh EVKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697551322; x=1698156122; 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=jK9MnOkarN7NF0Qc/XLSYHaYAFfcVhsfbF2N1g/hNuw=; b=Rd32QW7bjr+qRstnaXcQbLDN1mRNVTkOWG2hjcdyG/sDu6LVNKKGckx3u7jiU8DaNS 7LJohEBR2nHYaKV/CLWJ5QkEEXEWf0Grkty+t7Mn6bfQzp+1NH7zj01rhpkZInPf0CyN ROUiHGTYgd74BOk9JYH6kyu6lcmp59U7D2Qh/YwXaNV+bXIe1FDLVsLDQQ7rLzgvWKIW BX0I4amxEra3eP2MMSGmvFjN5bpHHOhRl1rTEYtu/dCMWmjtjzicBuLLeLdRiEIogrQy IbvVXOI9MrTNQS0W/uFanH/MONNN/Kjo+5nroG9Y1w/806GWoi7A+1G3f5HEFo0FPH16 Qq2g== X-Gm-Message-State: AOJu0Yz1uYVVmX/MtDABLbJ7JU3XHLuA2B88Kcq9lHOPwrut9gNIAbbe vFeWhfznRUBSWJiIebHtEhWkv1W8OeNNKwqL3LFhMw== X-Received: by 2002:a5d:6802:0:b0:32d:9a1b:5d79 with SMTP id w2-20020a5d6802000000b0032d9a1b5d79mr1705786wru.33.1697551321681; Tue, 17 Oct 2023 07:02:01 -0700 (PDT) Received: from m1x-phil.lan ([176.172.118.33]) by smtp.gmail.com with ESMTPSA id x5-20020a5d60c5000000b0032179c4a46dsm1730095wrt.100.2023.10.17.07.01.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 17 Oct 2023 07:02:00 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Hanna Reitz , Fam Zheng , qemu-arm@nongnu.org, "Michael S. Tsirkin" , qemu-block@nongnu.org, Kevin Wolf , Jason Wang , Peter Maydell , Raphael Norwitz , "Edgar E. Iglesias" , Alistair Francis , Gerd Hoffmann , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 1/7] hw/virtio/virtio-pmem: Replace impossible check by assertion Date: Tue, 17 Oct 2023 16:01:44 +0200 Message-ID: <20231017140150.44995-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231017140150.44995-1-philmd@linaro.org> References: <20231017140150.44995-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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 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 The get_memory_region() handler is used when (un)plugging the device, which can only occur *after* it is realized. virtio_pmem_realize() ensure the instance can not be realized without 'memdev'. Remove the superfluous check, replacing it by an assertion. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Manos Pitsidianakis --- hw/virtio/virtio-pmem.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hw/virtio/virtio-pmem.c b/hw/virtio/virtio-pmem.c index c3512c2dae..cc24812d2e 100644 --- a/hw/virtio/virtio-pmem.c +++ b/hw/virtio/virtio-pmem.c @@ -147,10 +147,7 @@ static void virtio_pmem_fill_device_info(const VirtIOPMEM *pmem, static MemoryRegion *virtio_pmem_get_memory_region(VirtIOPMEM *pmem, Error **errp) { - if (!pmem->memdev) { - error_setg(errp, "'%s' property must be set", VIRTIO_PMEM_MEMDEV_PROP); - return NULL; - } + assert(pmem->memdev); return &pmem->memdev->mr; }