From nobody Sun Nov 24 11:10:34 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 ARC-Seal: i=1; a=rsa-sha256; t=1724393765; cv=none; d=zohomail.com; s=zohoarc; b=HbIvY5JYV0bfUCdPkM2H1mIcLq8eREVbbSP1afvUZPWnc7Id3OJENahsMTnlVsh6bCeHYkRw4Bf11hHjsxcNWx5exHd7eLo9m4eoa363kf/ZOYGPSRAH0/HeU9/J9PB35raVo4JxYzkILh+e/VlH7dOPB7fvybX+6xp0I4leImE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724393765; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Mkj9QVgkoZ/zBUH6wc7gaGhuVa7cH6Hj+4496VYmMzM=; b=U1ACEJvdPGyvV40WJf5S8AvgBDuO1IgfSGRMWDDIU38pXTWpoAL+9JY+9XfHq2nfM7xpVdQ7yqT3srw9BSzthsSZXaiJ79fvzyX3FuY5hyrcqyCzwVM91ZSAW9uZCi+kE4z9VGkaWpJhqmEzulr7D2wUp8e5mac64n7AMpjaDCk= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1724393765102464.6346183672781; Thu, 22 Aug 2024 23:16:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1shNYD-0001zL-Dm; Fri, 23 Aug 2024 02:13:33 -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 1shNYC-0001vV-G0 for qemu-devel@nongnu.org; Fri, 23 Aug 2024 02:13:32 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1shNYB-00036S-0I for qemu-devel@nongnu.org; Fri, 23 Aug 2024 02:13:32 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-7142a30e3bdso1844971b3a.0 for ; Thu, 22 Aug 2024 23:13:30 -0700 (PDT) Received: from localhost ([157.82.207.23]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-7cd9ac97f5fsm2338485a12.11.2024.08.22.23.13.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Aug 2024 23:13:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1724393610; x=1724998410; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Mkj9QVgkoZ/zBUH6wc7gaGhuVa7cH6Hj+4496VYmMzM=; b=WHdCLbViTbltS9UjB7fi9ES5zDYLAWVBMC50Yb+boWcOFu64u/1KVFniP27w19x3TS 7QKEanhVOWD2Quns3SbV9+Lws+qa01crxcbtCWNjV5KtBDaQ2A38SMXv4B3wC5unfd3p /Do28YTtf0kP/H3tPMF6SzOs5UYODg0ieuqwSo1Int39Z/iG/wFMFDPTLpTIz7drWqvK LggBwxRlkTLQH/Bkrd0i/dyCao6r844FUO7CXEeLs/8e9Umfkb+rC3DK35SgGXAmyTg5 EOeQcmAXrKApKvklkuBiKRgulLgjRoPwdvV0gK8kqC77Tz57icVW7i9Wa9S2Wq+VVooC zpAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724393610; x=1724998410; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Mkj9QVgkoZ/zBUH6wc7gaGhuVa7cH6Hj+4496VYmMzM=; b=cu+yuNVQN0LZSPcXhkw+dvCKzIBT7carjpjXRoqP6DYP4N5FKxzWT6zXlKvNEI5Wta D1KyTj8mkJ3wqVYu1VbL8xQ5Rgt2krm+Vf1qeEu7tNmZztI2gJdIq/JcUfi69d0e1AuR UoAKQD7Z39iLyI0uIIREaiuUY45OqgN5KA+hTAibKMUOsDP4/aa+HEO7ZcT7xYqkb1o0 LhrEYhDNKwOTMumnS7S2JcnRUEB5a3ISPWQFPaKEI7ZbYYu+zFR5zojPTaavpRmGNP7Y nNu+VDEcJGlEdvvptmttNAoCtw957o/l/Aj+K5wIXqT5lLojqIXrR4VjgyYU/fRa12Rv ZAzw== X-Gm-Message-State: AOJu0YweHV8mSIK49l1XbuaSMuD2egu/a9c7SyNAHf8PM3Z4KuhSyAdo dmPJ1pb9PLCDOqP2nr5ceT4ccvcCEev5p7lInN5GWO/5RiexSAd4bqwSwOsjwg4= X-Google-Smtp-Source: AGHT+IEG74UASIaEWHM/rv95T1YlnQlPc3vXPFvHAVPLEoDkbH6Ut72Tyj+P65GxySJ22VRewXG1BA== X-Received: by 2002:a05:6a20:c709:b0:1c0:e1a5:9588 with SMTP id adf61e73a8af0-1cc89d29d0bmr2475725637.2.1724393609598; Thu, 22 Aug 2024 23:13:29 -0700 (PDT) From: Akihiko Odaki Date: Fri, 23 Aug 2024 15:13:06 +0900 Subject: [PATCH v4 1/7] migration: Free removed SaveStateEntry MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240823-san-v4-1-a24c6dfa4ceb@daynix.com> References: <20240823-san-v4-0-a24c6dfa4ceb@daynix.com> In-Reply-To: <20240823-san-v4-0-a24c6dfa4ceb@daynix.com> To: Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Yanan Wang , John Snow , BALATON Zoltan , Jiaxun Yang , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Xu , Fabiano Rosas , Paolo Bonzini , David Hildenbrand , Thomas Huth , Laurent Vivier , Peter Maydell Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, qemu-ppc@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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: none client-ip=2607:f8b0:4864:20::430; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x430.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1724393767172116600 This fixes LeakSanitizer warnings. Signed-off-by: Akihiko Odaki Reviewed-by: Peter Xu Reviewed-by: Michael S. Tsirkin --- migration/savevm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/migration/savevm.c b/migration/savevm.c index deb57833f8a8..85958d7b09cd 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -874,6 +874,8 @@ int vmstate_replace_hack_for_ppc(VMStateIf *obj, int in= stance_id, =20 if (se) { savevm_state_handler_remove(se); + g_free(se->compat); + g_free(se); } return vmstate_register(obj, instance_id, vmsd, opaque); } --=20 2.46.0 From nobody Sun Nov 24 11:10:34 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 ARC-Seal: i=1; a=rsa-sha256; t=1724393807; cv=none; d=zohomail.com; s=zohoarc; b=ecYnw3gPUPsq9bJdTzuFyh/cl2u3w7TXWmRpjkZUsxVh9fyQB4g5NB5S1WXb0VHh+XhJV35OsAbUaqBdBrkc7NKAVKYxnN04vHBpvYoOPPny+CxjNFxzW1edBwJpv6fZ1Tm9fFO6mDt9GXiKtzISyomKC1xO6RPfCq9gQVPezho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724393807; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=b4fRw6ya5cnFbQAZ70Uw8BnHXsKEEdwvnI09RO2JZjU=; b=PSYR0+hAKf4gQ14M9geAeCqPQuC6lXphf4sCzpu+TV+wZYjcw9nbkSJl+xWwaSmhsb+XFDfYxFzzOVCXMXLBvueiLzkiCo8XChaR/EwamtpftVLFeH9EAzrMleJdxwEVuIo0+SDm2xkjub+VGsBfYoOQj7l27PfT2uPr/X5qBGA= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172439380726768.51461143483687; Thu, 22 Aug 2024 23:16:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1shNYZ-0002Up-R5; Fri, 23 Aug 2024 02:13:55 -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 1shNYU-0002O0-E0 for qemu-devel@nongnu.org; Fri, 23 Aug 2024 02:13:52 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1shNYH-000378-9c for qemu-devel@nongnu.org; Fri, 23 Aug 2024 02:13:50 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-712603f7ba5so1403527b3a.3 for ; Thu, 22 Aug 2024 23:13:36 -0700 (PDT) Received: from localhost ([157.82.207.23]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2d5eba26377sm5363854a91.32.2024.08.22.23.13.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Aug 2024 23:13:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1724393616; x=1724998416; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=b4fRw6ya5cnFbQAZ70Uw8BnHXsKEEdwvnI09RO2JZjU=; b=dlHtcE0VED/esk8e+YdidFgXWkO4W7WWNGo4SmgANOd/pxSB2zR4j/L+gvnchExWZU YdCSJu0cIwBZv2FCyc2XjeogVZSG4P9eNO4DeXee0ywbumuuGwZdfQQnPeo9CRnWu1ZS 7eSCXHbhXIpTI5JppcTLORuOkPkKDqv+V5fE6k2iMShhyu50+kJ5DwaTKhr6hOWNhCVp BLvm0LRxaGW09H5DMg6P2Dlhk0w8iWuJuVABvd9eIKEGRO2e/7Qlf3AhJJdeDHq6PvUH DCbQ/IfdPoAJ0hPdYK7ak/M6W5XrcfSqXPHjR4nAaVGxQlP/9YwXaUY+2yE1Vr+YTP8z wQcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724393616; x=1724998416; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b4fRw6ya5cnFbQAZ70Uw8BnHXsKEEdwvnI09RO2JZjU=; b=u+QcwN2ptKnHESGovoO2wmLstbgDLfeuyiXJuneG3MrO0zAXY4UK5qL0WAFPOH8AgN 4MGdIIMNCf77XklGlhfDaxqir4ncZBduA8xXwMgPDzsinFqiCDpvkiioPUEoB6pqnsng XeeUhg9dw5ur38CqpJ2GdigUYk8ncpZRVaJzSwtUyjE0faguLnO0x87InK1jwRB+2qlI CyVp7SnSBaZeBNTpSX4YOVXwcqUPH2rZqTfoAt25IBTwK9y5wNsEeC8SyM839tHri5xx biecnc1ZO/v3bGQImgIxZNYrkyK7ilWmyeRvBkRnpfF3Mqo1Pwiy0KQquqGzRfMcIo0/ qJwA== X-Gm-Message-State: AOJu0Yw8zFsLgjyyy+SoYKAIp0VYbIOta0hpq/o+J8AS5AL48q0vpPLh wu2GebC7RNqtirKusA25EctfMPCmgk/oe3dPquGwG0laF1M+kmJncPCiXAC5Nhg= X-Google-Smtp-Source: AGHT+IEqho7w76m6+nPWwV3j9fAGvJFVqKDMS/DQRiOrn+gYlgjQbuDe7q2Ae/okScjoRm2rK6bGHA== X-Received: by 2002:a05:6a21:478b:b0:1ca:da51:6635 with SMTP id adf61e73a8af0-1cc89d29da2mr1717102637.1.1724393615889; Thu, 22 Aug 2024 23:13:35 -0700 (PDT) From: Akihiko Odaki Date: Fri, 23 Aug 2024 15:13:07 +0900 Subject: [PATCH v4 2/7] memory: Do not refer to "memory region's reference count" MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240823-san-v4-2-a24c6dfa4ceb@daynix.com> References: <20240823-san-v4-0-a24c6dfa4ceb@daynix.com> In-Reply-To: <20240823-san-v4-0-a24c6dfa4ceb@daynix.com> To: Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Yanan Wang , John Snow , BALATON Zoltan , Jiaxun Yang , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Xu , Fabiano Rosas , Paolo Bonzini , David Hildenbrand , Thomas Huth , Laurent Vivier , Peter Maydell Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, qemu-ppc@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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: none client-ip=2607:f8b0:4864:20::42c; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42c.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=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 @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1724393809393116600 Now MemoryRegions do have their own reference counts, but they will not be used when their owners are not themselves. However, the documentation of memory_region_ref() says it adds "1 to a memory region's reference count", which is confusing. Avoid referring to "memory region's reference count" and just say: "Add a reference to a memory region". Make a similar change to memory_region_unref() too. Signed-off-by: Akihiko Odaki --- include/exec/memory.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 02f7528ec060..b9f0ad09bfad 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1217,7 +1217,7 @@ void memory_region_init(MemoryRegion *mr, uint64_t size); =20 /** - * memory_region_ref: Add 1 to a memory region's reference count + * memory_region_ref: Add a reference to a memory region * * Whenever memory regions are accessed outside the BQL, they need to be * preserved against hot-unplug. MemoryRegions actually do not have their @@ -1234,7 +1234,7 @@ void memory_region_init(MemoryRegion *mr, void memory_region_ref(MemoryRegion *mr); =20 /** - * memory_region_unref: Remove 1 to a memory region's reference count + * memory_region_unref: Remove a reference to a memory region * * Whenever memory regions are accessed outside the BQL, they need to be * preserved against hot-unplug. MemoryRegions actually do not have their --=20 2.46.0 From nobody Sun Nov 24 11:10:34 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 ARC-Seal: i=1; a=rsa-sha256; t=1724393751; cv=none; d=zohomail.com; s=zohoarc; b=IuilOyH4VM5oO/b91YsmDI+p2n7fNklc1fnqtg3DLLhc8lu18joyS1QlQboCC+tXuZyl0s0QZUAkv5nHqw4B+y5xnE8Mf0DGwbty9w1ze/RUyg7aD5mlmyvZu6tm1kymNGuklhRUQYiXnhpALPfTPs9s/kcowLOGfDxfuGQh2BA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724393751; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0K7RxwRuv9YcnxMw2PosqOuYZUXE/imSqne2Rr+Wijc=; b=OJx2vnqrDv2wBn4NOalKCWPdAcpweKonO+gP0pNIpO8wXq56BgzSM8Ya7Zh5pydmyroH8czaqmvurySFHA/AL0O5SqW+5IpSolUWCrUdVlq8zUXrjujPOyVSNZsqkybYm745pBacsb1PAI4yFC65CSmj/z3D4mDC28NBtIFVWXc= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1724393751452849.5336464794859; Thu, 22 Aug 2024 23:15:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1shNYb-0002cc-K6; Fri, 23 Aug 2024 02:13:57 -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 1shNYY-0002QR-B0 for qemu-devel@nongnu.org; Fri, 23 Aug 2024 02:13:54 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1shNYN-00037j-Hs for qemu-devel@nongnu.org; Fri, 23 Aug 2024 02:13:52 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-2021c03c13aso12241735ad.1 for ; Thu, 22 Aug 2024 23:13:43 -0700 (PDT) Received: from localhost ([157.82.207.23]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-20385566479sm21646755ad.58.2024.08.22.23.13.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Aug 2024 23:13:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1724393622; x=1724998422; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=0K7RxwRuv9YcnxMw2PosqOuYZUXE/imSqne2Rr+Wijc=; b=aFIM2zW9IUGrpVHHauYwa8lcCNcrIbTy9PQcKTSk8yZTicER7rLQaMdaOYGxa6eLpk o/zzb+eVugQBD6/T58wHXJY/CsYScIth7WEs7S9kvQ2mts+qQrgDpCmHWqgr3MSs8rjv tSivx6JMLEzw714LqFOwJ0pV49WOaDHPAQGIZTVHNhjPDHBVa9lrlUSwxkAWlBwBagki jf7fiqOB83bMmc/p1ujejB5chfyOYd+ODw2h7fLr05FRl68vttfYNA8vk2Mk6qYQQtjQ psmE9jBYZGUcyjkkkhPjzZR1LpDTiqB2aFtmxNBvoQRVjYhNaDdBSLzmR8LjZ8qYZBOU ZjqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724393622; x=1724998422; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0K7RxwRuv9YcnxMw2PosqOuYZUXE/imSqne2Rr+Wijc=; b=H8ZTZeW5m/ayRvnodUCuX0yYBqHZW3KVbCNkkZQ0eYdx0Xy/CHlUMBG5uL7VjXbFyW QgZISjRsVPH9KTDztd7PBoSvhhQG/6PxhFdwOsPReFusE30ZweJg/j38rcJB/Aoz3GiG NcXtqYAFk+9f/9gKyIYfFj5BvUwylQAmZS1Wda0cdmD0E5kiHStoAXIppX9vjWKGMsBc E0fOqNYmZgqvTGqBOB7rC99ppftavq+RHL6RIGjXtiABQl1AixHDMRLPNjwbH8jL/nhG zej6B0jdoGQwXfcj5ftfbh5GMHk0sanTH6URCnNbYgeW9G5U/dMsfw1OdW24UzUI0e1t 15vw== X-Gm-Message-State: AOJu0YwXmzs29BW/g3tSv7tuw0X8gBTd906gUnqhCvtt8wAjm1fABtIt sRPr/PeK9ZthGWtoFmzxcVMlh7w/gSdJJ0qi+jCjuQv6LoWSoOj735WjTXj0klQ= X-Google-Smtp-Source: AGHT+IEAngTao5BZsP0x6bDwn8uzYT07K8nnRx/E7okr5ZhVBwjQFP3fKv8hQyXPsvSnEWre4QJ+nA== X-Received: by 2002:a17:902:ecd2:b0:1fa:97ec:3a4 with SMTP id d9443c01a7336-2039c44c05dmr24395855ad.8.1724393622109; Thu, 22 Aug 2024 23:13:42 -0700 (PDT) From: Akihiko Odaki Date: Fri, 23 Aug 2024 15:13:08 +0900 Subject: [PATCH v4 3/7] memory: Refer to docs/devel/memory.rst for "owner" MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240823-san-v4-3-a24c6dfa4ceb@daynix.com> References: <20240823-san-v4-0-a24c6dfa4ceb@daynix.com> In-Reply-To: <20240823-san-v4-0-a24c6dfa4ceb@daynix.com> To: Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Yanan Wang , John Snow , BALATON Zoltan , Jiaxun Yang , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Xu , Fabiano Rosas , Paolo Bonzini , David Hildenbrand , Thomas Huth , Laurent Vivier , Peter Maydell Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, qemu-ppc@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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: none client-ip=2607:f8b0:4864:20::631; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x631.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1724393753122116600 memory_region_ref() and memory_region_unref() used to have their own descriptions of "owner", but they are somewhat out-of-date and misleading. In particular, they say "whenever memory regions are accessed outside the BQL, they need to be preserved against hot-unplug", but protecting against hot-unplug is not mandatory if it is known that they will never be hot-unplugged. They also say "MemoryRegions actually do not have their own reference count", but they actually do. They just will not be used unless their owners are not themselves. Refer to docs/devel/memory.rst as the single source of truth instead of maintaining duplicate descriptions of "owner". Signed-off-by: Akihiko Odaki --- include/exec/memory.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index b9f0ad09bfad..461e42d03491 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1219,15 +1219,8 @@ void memory_region_init(MemoryRegion *mr, /** * memory_region_ref: Add a reference to a memory region * - * Whenever memory regions are accessed outside the BQL, they need to be - * preserved against hot-unplug. MemoryRegions actually do not have their - * own reference count; they piggyback on a QOM object, their "owner". * This function adds a reference to the owner. - * - * All MemoryRegions must have an owner if they can disappear, even if the - * device they belong to operates exclusively under the BQL. This is beca= use - * the region could be returned at any time by memory_region_find, and this - * is usually under guest control. + * See docs/devel/memory.rst to know about owner. * * @mr: the #MemoryRegion */ @@ -1236,10 +1229,8 @@ void memory_region_ref(MemoryRegion *mr); /** * memory_region_unref: Remove a reference to a memory region * - * Whenever memory regions are accessed outside the BQL, they need to be - * preserved against hot-unplug. MemoryRegions actually do not have their - * own reference count; they piggyback on a QOM object, their "owner". * This function removes a reference to the owner and possibly destroys it. + * See docs/devel/memory.rst to know about owner. * * @mr: the #MemoryRegion */ --=20 2.46.0 From nobody Sun Nov 24 11:10:34 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 ARC-Seal: i=1; a=rsa-sha256; t=1724393808; cv=none; d=zohomail.com; s=zohoarc; b=AjZe4+NucoXOntIwPwYNkFjTpebTTsfNS9U5zK8hyddzd/Y1FQR6lvnhk3BRch5qWnsM8XBk2TcEaX0JzcxqHsZbcdIbzoSsmh/XB0q72bV+/qSOIVRURg8C7LvxwIsIxpo03N05OpSKKaMak2mE/Cl5PJuGHitumeEejusPV9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724393808; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YdHplAffMcXcyi9egxfeqIrbdnUVPw/pDkvqxXIV6Fk=; b=MubvUfXRPO3wrWYo9UEVMifx0LeHVQSceEdUbC6GymqjYUf//+KbuSGPdYWp+3XjrNqUDiMguX/vc3h9dQ/7+aPN2qrI7g7mrbGwI4y5bi/VfccAlRQtoX37IFGmsMDlQsfCF2jZFT8ZGlbr75DPQYrPJbh0FC1q7KbgRm45JOQ= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1724393808817965.1144769338035; Thu, 22 Aug 2024 23:16:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1shNYd-0002nI-Rx; Fri, 23 Aug 2024 02:13:59 -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 1shNYc-0002eV-0w for qemu-devel@nongnu.org; Fri, 23 Aug 2024 02:13:58 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1shNYV-00038n-LZ for qemu-devel@nongnu.org; Fri, 23 Aug 2024 02:13:57 -0400 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-2d3d58d6e08so1217728a91.3 for ; Thu, 22 Aug 2024 23:13:49 -0700 (PDT) Received: from localhost ([157.82.207.23]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2d61393fbcbsm3057579a91.22.2024.08.22.23.13.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Aug 2024 23:13:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1724393628; x=1724998428; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=YdHplAffMcXcyi9egxfeqIrbdnUVPw/pDkvqxXIV6Fk=; b=LaS6mr/2/L0gqc4ZRA57xV55f1UmRP6c6jbfJrKzTDCN2dM3B335HRL7OVN0aX0Qtw 02Gggpk/mHEU3+7rHeSHSeXW6qDX6084O/Ekce7kr9eBvOVhoC2chGaNIDKtZbveC8/m gMgzrCAzqzwX1bqqowkcdDg0mYs20zka/lxo4C+1yFNbRWRJ5yEMWBpKvz7rooDmTTVY yC//gPqh1olto06HGuaKyjtdLPOdQmwi97FI4VYwYbyqp4rxM3cTfz5R2ZL4csNYoh1b B7m2ow13hCCT2UyZ3zNCTbPe3JprtbeR9lNS4KHuOrChehOgN6MEZxxUxwmNdEkmLQ2W HHtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724393628; x=1724998428; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YdHplAffMcXcyi9egxfeqIrbdnUVPw/pDkvqxXIV6Fk=; b=P2Vw6/GKwYVkMQTSfDl5twEWlrm1kF30Ns9QlyRGw148dqmJm1K/2N7uvVS9YNbfnN hkgVFDL4lPabjnzFIe/978ASKjXfo5v8fZqdwXFNRlWjdna2yqRt9uPFvx2wCig2ZQWb xCic/8ykIQL5Ji9/3qXj/7W0mMPf44Asgxyi25smIgkWFl9IukS0ZodoMBGXs2p8yF5q dnUqJT3xXl0pPll3Ci2ti/2LH9PY/VnRy1Da5R0ay46mtJielY8USMU1rKdJiDpaoHqf zSfe1OwrIjndra79XD6bHSuojPOe+lgyRC3qHnGL4sn+7ccfkWfVI8a9p0mAA1/eb25K wtXg== X-Gm-Message-State: AOJu0Yxme3Q7MTvy6rHQlqNMCU4oZVhx/Xt6zhogJbE9DqkkUgJkcaua wkSXAlDCiaZFBqFOoqDpwHbB+G9lxj0ru2yh85+7O7JAz7kIbMXV+ydSnKgpifA= X-Google-Smtp-Source: AGHT+IFzJ10oTRUyLJrWB5ipu7tvGZB9L6IX1t4YpN1zznxvJDoxVqCckhwL5Q+Xwak+DQuAoYo6Pg== X-Received: by 2002:a17:90a:c002:b0:2cb:e429:f525 with SMTP id 98e67ed59e1d1-2d646d2bbdfmr1123154a91.33.1724393628209; Thu, 22 Aug 2024 23:13:48 -0700 (PDT) From: Akihiko Odaki Date: Fri, 23 Aug 2024 15:13:09 +0900 Subject: [PATCH v4 4/7] memory: Clarify that owner may be missing MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240823-san-v4-4-a24c6dfa4ceb@daynix.com> References: <20240823-san-v4-0-a24c6dfa4ceb@daynix.com> In-Reply-To: <20240823-san-v4-0-a24c6dfa4ceb@daynix.com> To: Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Yanan Wang , John Snow , BALATON Zoltan , Jiaxun Yang , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Xu , Fabiano Rosas , Paolo Bonzini , David Hildenbrand , Thomas Huth , Laurent Vivier , Peter Maydell Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, qemu-ppc@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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: none client-ip=2607:f8b0:4864:20::1034; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1034.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1724393809384116600 A memory region may not have an owner, and memory_region_ref() and memory_region_unref() do nothing for such. Signed-off-by: Akihiko Odaki --- include/exec/memory.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 461e42d03491..d79415a3b159 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1219,7 +1219,7 @@ void memory_region_init(MemoryRegion *mr, /** * memory_region_ref: Add a reference to a memory region * - * This function adds a reference to the owner. + * This function adds a reference to the owner if present. * See docs/devel/memory.rst to know about owner. * * @mr: the #MemoryRegion @@ -1229,8 +1229,8 @@ void memory_region_ref(MemoryRegion *mr); /** * memory_region_unref: Remove a reference to a memory region * - * This function removes a reference to the owner and possibly destroys it. - * See docs/devel/memory.rst to know about owner. + * This function removes a reference to the owner and possibly destroys it= if + * present. See docs/devel/memory.rst to know about owner. * * @mr: the #MemoryRegion */ --=20 2.46.0 From nobody Sun Nov 24 11:10:34 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 ARC-Seal: i=1; a=rsa-sha256; t=1724393740; cv=none; d=zohomail.com; s=zohoarc; b=JrSnNGWpqnFUo6D8faRB98IpZD9qVEV7UhcpBjovna/4XQtvWlW+UQFe/yJrLYd5/BREfp6B0Ve2lBXRQK3DgICj9jQp5/F2t1mRRXG+RE8a7i+hZb+01IIMm4oIBeKnxNe4CLHz16o85gonSgsFD49ojVlhI4HSuPrrBNfCmiw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724393740; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZgDoeEKExDSUUkKhA562XJclNi5ZhOHvZQVGrzBwI+A=; b=nPesAUNTZ2Wqk1UgO5l+eLWDI35uwpW7ge93DqLGVAuDVzX5K+kIfaI0CvR0Jy82dqQ+fq7AxcxOrhBlqx0bYaTFspPTURF3FCZa2u8xOSTlIaKfWDOepCDSvbjvwYaCZJGsLfIS24Zgv5nLiL+r9kUo9mIu+Kgh6+4KpP7p8TI= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172439374005711.009069710423432; Thu, 22 Aug 2024 23:15:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1shNYf-0002wI-TS; Fri, 23 Aug 2024 02:14:01 -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 1shNYc-0002hI-H9 for qemu-devel@nongnu.org; Fri, 23 Aug 2024 02:13:58 -0400 Received: from mail-yw1-x112d.google.com ([2607:f8b0:4864:20::112d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1shNYZ-0003A9-MJ for qemu-devel@nongnu.org; Fri, 23 Aug 2024 02:13:58 -0400 Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-6b47ff8a59aso13788887b3.2 for ; Thu, 22 Aug 2024 23:13:55 -0700 (PDT) Received: from localhost ([157.82.207.23]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-714342316e8sm2406058b3a.16.2024.08.22.23.13.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Aug 2024 23:13:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1724393634; x=1724998434; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ZgDoeEKExDSUUkKhA562XJclNi5ZhOHvZQVGrzBwI+A=; b=0CjR7ZFUMrdwM+EQfvY1BmqX2JlVw3e6JNbgP6/gMuwvRsYzHEZgUYJMyxslQ+JlQ7 FV0WcoqX7cyHQzVCFSiUDywnAU+hV7ozmsBTB6ET/ZgR+AOcpHowW1YzD6/pUIJBQJYT CO3n2m3/N0gokYF4HyTFex1erXhvmKQ/DQq3ASIMyvw2BJLxYYp7CApj5kWih/jVCZeg vV0+Bpq2KHBRm1I/2q0aI5l4e1D1V/2mvr/0Zj7Zu5P8iY9FRlBF1TQl3BzZWREoOWHp WT4s+2uWZzfUCkDDeoGQa36xIjcpQfXziwk0f33sEHZcShkWeqtczxHVhAK2dT1iSeuj MhAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724393634; x=1724998434; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZgDoeEKExDSUUkKhA562XJclNi5ZhOHvZQVGrzBwI+A=; b=TTj5u9m3dsUDp8+IDlCu3Nj19sh5atrMmWeo9leOD9CYJ35BxUQTot8CLxE8msmc91 WvwkvRO0jNMDjFdHLL/hnzrwfVeOK1RrIaX4+l+f6V1eBdyeFZHb+W28KyJ/ocIrgy3F g5YSALct36tZc9GLWPLhM6IHohURisVMUlVkVX1VfBIAC/ZasM+kjFKG5pWriCvz36Qn mlFrfFyvXjb8qd1tecNlQYH4dT9/znC095Dd1FpeMx1t7Tjbs7FTOxSEofkuxohCqQeM BxuoxMiO0iKPrp+Mgkoy87z/wF0a0sxlyZzgI8GeqvnBpSN1HX+0h+2tzZYZZ23iAtDQ vTEw== X-Gm-Message-State: AOJu0YwnWgnC703KuXDJGabT7Xlp7k2+ucOItJXgWlM7tSU5T6Nj0IGQ 2DGMz/45pqObLegSgfdR2VF9uvs+0gK/j9SyLVYl0vu/7jgO3Up6q+mdKxmPusY= X-Google-Smtp-Source: AGHT+IGuj1gFQTuDEsrNan7a7imNn/Sl/n8Bp2+X8RKJ6f6S0gWckt8yw2CT52Rt7ce2oK1y4+9S6Q== X-Received: by 2002:a05:690c:18:b0:64a:d5fd:f19f with SMTP id 00721157ae682-6c625a4ca3bmr14298007b3.18.1724393634631; Thu, 22 Aug 2024 23:13:54 -0700 (PDT) From: Akihiko Odaki Date: Fri, 23 Aug 2024 15:13:10 +0900 Subject: [PATCH v4 5/7] memory: Clarify owner must not call memory_region_ref() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240823-san-v4-5-a24c6dfa4ceb@daynix.com> References: <20240823-san-v4-0-a24c6dfa4ceb@daynix.com> In-Reply-To: <20240823-san-v4-0-a24c6dfa4ceb@daynix.com> To: Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Yanan Wang , John Snow , BALATON Zoltan , Jiaxun Yang , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Xu , Fabiano Rosas , Paolo Bonzini , David Hildenbrand , Thomas Huth , Laurent Vivier , Peter Maydell Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, qemu-ppc@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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: none client-ip=2607:f8b0:4864:20::112d; envelope-from=akihiko.odaki@daynix.com; helo=mail-yw1-x112d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1724393741059116600 Signed-off-by: Akihiko Odaki --- include/exec/memory.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index d79415a3b159..6698e9d05eab 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1220,6 +1220,7 @@ void memory_region_init(MemoryRegion *mr, * memory_region_ref: Add a reference to a memory region * * This function adds a reference to the owner if present. + * The owner must not call this function as it results in a circular refer= ence. * See docs/devel/memory.rst to know about owner. * * @mr: the #MemoryRegion --=20 2.46.0 From nobody Sun Nov 24 11:10:34 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 ARC-Seal: i=1; a=rsa-sha256; t=1724393675; cv=none; d=zohomail.com; s=zohoarc; b=JuBZVVb/bi+V5dWqb/EBpK75OfL2vBymYsNE3usZ6PWmSOo/byB0W/adBrgFkUyM4YMDRfPAxVxtWSPJLUGNTIdXj7AzVhhwrmjcRSTPWm7Bz3YRXBbWABBcLA5p+W74xqUbS9oe8R9/U2u/G91084LikBkkouI/jLobJddC+zY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724393675; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TqGUJw12uTAbvh8M71+t9HGKJ1QBUKeYyyQ+O3KoOC0=; b=CsSOSwITyKz2WdqdAd4X8CXYRxBwF+3NvyRFZj5zSrEWbrNpgIaXZuhFHiFL9iRMY7XJ21Z0eI5vARe+rI+5ZjO/rRC/ndhyygYBaGBEcbzPf5lANFURbfBw7A91jfGi7kAPgBQ/S8yn6nrgpI+7AtROfAtqm3aV84wH5f9E3Gs= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1724393675983725.3092809762636; Thu, 22 Aug 2024 23:14:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1shNYk-0003J5-SR; Fri, 23 Aug 2024 02:14:06 -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 1shNYj-0003BR-0s for qemu-devel@nongnu.org; Fri, 23 Aug 2024 02:14:05 -0400 Received: from mail-oa1-x33.google.com ([2001:4860:4864:20::33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1shNYg-0003Bq-Fd for qemu-devel@nongnu.org; Fri, 23 Aug 2024 02:14:04 -0400 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-273cf9bbb3eso977683fac.1 for ; Thu, 22 Aug 2024 23:14:02 -0700 (PDT) Received: from localhost ([157.82.207.23]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-71434335fe1sm2302862b3a.200.2024.08.22.23.13.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Aug 2024 23:14:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1724393641; x=1724998441; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=TqGUJw12uTAbvh8M71+t9HGKJ1QBUKeYyyQ+O3KoOC0=; b=iq4lraWW0+JKVzVOGOjeFPScRb2883/QCyZJvhlo5c+6q+wDiJueZWzoKkgT2fklXG Z+3gQTUSnd6Hyqf5l+vWNWCX82rHDpjnperHnLnTsqpTS6/R8wH3p9UB+NOmk6QU6vXz JzDteJJ0ajK56vbR+gENxcxlG4P7xFWq9AHKFCHd17jaUXn7+ejRv8SUh4ScwfpYsO4B cBcBOvfUgHh0PN52R0v2uTHKayPWhUyCEZYSeO5nC0gfx2gh556F2Arx/c9+XVdhhzWo Z22OLiTLLlDRGbCQqwakXVgEDL7EP5Mk1X6qqYiFc0Y9VNcK3537dFFGtfN2WKRHk6x2 PHiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724393641; x=1724998441; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TqGUJw12uTAbvh8M71+t9HGKJ1QBUKeYyyQ+O3KoOC0=; b=A4E5/VlNTA8ZTubCbTTpWteSu7cpdwen0ZewwCJlp5Wn5x5BsiyrV5yf2AH3kELa2U emUXDGNX5GL+FKuUR7eWegrhnEIUKtLdmp+rUkJ0bUmQOGsL1tEpGKCiriINbDFpCT3z 0R/vDrocHqeqe9YcwYXt9DqUTwoCNWlBEQB1vKmiNlJL8SB7hhLxBcCRaU4OtNBmisc0 p+iFBvWLJ4wbxA2rsfWEMfv8O1OaliOBVwTDprXCxYLDbgtQSrOU540nnhNY9p/DW6wM F7m6aRaj+4y8XY5kD5BWEmFLy/RYE7SDGmzGDp7LAeIPiB2E502GEplUvvrokFfxPTvQ wpng== X-Gm-Message-State: AOJu0YwZNnyxmfsQgTGJmad1vyDW34+aXqOEHP5vzQ8o/sH/XjvUbajs b9Eeywo42KCS11x0GkJKEUmtaO5XIaiRWSKrAZJ4rdJu6c+NsYcuWsHYxfmV89c= X-Google-Smtp-Source: AGHT+IHAfk6dVYsonq3Hlwrg808+TTvRceTk+pc5LzEGFXYQT7ovRTiKEte4g/HUA21ToYZjiMQeOQ== X-Received: by 2002:a05:6870:5587:b0:270:129f:8e65 with SMTP id 586e51a60fabf-273e66589c9mr1134333fac.34.1724393641047; Thu, 22 Aug 2024 23:14:01 -0700 (PDT) From: Akihiko Odaki Date: Fri, 23 Aug 2024 15:13:11 +0900 Subject: [PATCH v4 6/7] memory: Do not create circular reference with subregion MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240823-san-v4-6-a24c6dfa4ceb@daynix.com> References: <20240823-san-v4-0-a24c6dfa4ceb@daynix.com> In-Reply-To: <20240823-san-v4-0-a24c6dfa4ceb@daynix.com> To: Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Yanan Wang , John Snow , BALATON Zoltan , Jiaxun Yang , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Xu , Fabiano Rosas , Paolo Bonzini , David Hildenbrand , Thomas Huth , Laurent Vivier , Peter Maydell Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, qemu-ppc@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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: none client-ip=2001:4860:4864:20::33; envelope-from=akihiko.odaki@daynix.com; helo=mail-oa1-x33.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1724393676895116600 memory_region_update_container_subregions() used to call memory_region_ref(), which creates a reference to the owner of the subregion, on behalf of the owner of the container. This results in a circular reference if the subregion and container have the same owner. memory_region_ref() creates a reference to the owner instead of the memory region to match the lifetime of the owner and memory region. We do not need such a hack if the subregion and container have the same owner because the owner will be alive as long as the container is. Therefore, create a reference to the subregion itself instead ot its owner in such a case; the reference to the subregion is still necessary to ensure that the subregion gets finalized after the container. Signed-off-by: Akihiko Odaki --- system/memory.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/system/memory.c b/system/memory.c index 5e6eb459d5de..e4d3e9d1f427 100644 --- a/system/memory.c +++ b/system/memory.c @@ -2612,7 +2612,9 @@ static void memory_region_update_container_subregions= (MemoryRegion *subregion) =20 memory_region_transaction_begin(); =20 - memory_region_ref(subregion); + object_ref(mr->owner =3D=3D subregion->owner ? + OBJECT(subregion) : subregion->owner); + QTAILQ_FOREACH(other, &mr->subregions, subregions_link) { if (subregion->priority >=3D other->priority) { QTAILQ_INSERT_BEFORE(other, subregion, subregions_link); @@ -2670,7 +2672,9 @@ void memory_region_del_subregion(MemoryRegion *mr, assert(alias->mapped_via_alias >=3D 0); } QTAILQ_REMOVE(&mr->subregions, subregion, subregions_link); - memory_region_unref(subregion); + object_unref(mr->owner =3D=3D subregion->owner ? + OBJECT(subregion) : subregion->owner); + memory_region_update_pending |=3D mr->enabled && subregion->enabled; memory_region_transaction_commit(); } --=20 2.46.0 From nobody Sun Nov 24 11:10:34 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 ARC-Seal: i=1; a=rsa-sha256; t=1724393669; cv=none; d=zohomail.com; s=zohoarc; b=aBUh8+hBbd5Hrw2NZGGghjVcLgqTfF4gxj9FdAx7ehMW5hUOJypAgwiwQQSVGOTycs5rC64i4sgqm9I3vJhs8kW6NY2jZYmp0mjz0y9+wX7Ozm6QqvNiXuJzOf04fV5U+rOqoFt5lNpoZa4hkS9edaO4n8Jqk0nbHjbdJdccOV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724393669; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TCWqBNLN76lvDt02Z9O72XGpvlEOCWgTyfhqZXKjDaw=; b=MQ7wJNxHDyRyGEqoeBNSEEOsLG/03Wa2HAmEDQQ/wEawNUtkckVm9CtREDi+vKkZ8/mzO+BYpCNS0ORUfvTzc3492fi4KN3QiVjisDWOCKbpdV3WO9dc/NxfchsjGxpO2ZNIAlMHR41giM4R8jSZlD3ydH+Dk01jH6Q0ExSMJ+A= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1724393669668642.170452714711; Thu, 22 Aug 2024 23:14:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1shNYq-0003dR-V7; Fri, 23 Aug 2024 02:14:12 -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 1shNYo-0003Yt-QU for qemu-devel@nongnu.org; Fri, 23 Aug 2024 02:14:10 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1shNYn-0003DT-60 for qemu-devel@nongnu.org; Fri, 23 Aug 2024 02:14:10 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-7141b04e7a3so1343288b3a.3 for ; Thu, 22 Aug 2024 23:14:08 -0700 (PDT) Received: from localhost ([157.82.207.23]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-7143431052bsm2316219b3a.181.2024.08.22.23.14.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Aug 2024 23:14:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1724393647; x=1724998447; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=TCWqBNLN76lvDt02Z9O72XGpvlEOCWgTyfhqZXKjDaw=; b=tkEQIl/8nJAQAZb9O3Q84H+Ds+tyJ4rlz4/GAyLSCeA8o8SpeL66vShDQzudPIPXSi zBFHxXHzSjuhhwTzQBQqSJ4Q6JZ8xQKpGWGEZYz5hixUWETWfgPm9BFUejQ0M6LsRtuH tH35Dmm58QdQayVCTV3WDZfMR7DDcRbSG4Ws3mhqE6ZnOQ+sFFLs1r2VWIPNGOrFBkcQ 4jkTmicKJPD0xjVcN9aVfP5A4oghLqm7tXoFxuIrv1WcZXT/S8I5m3BmErNIL9lDULwv xe0RkHVVatItEO7PtuKqfKjyYU/Uv6s1z7wnQN5JgS999bSBvwOcxQ6OeZR5QYbO31LJ fnsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724393647; x=1724998447; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TCWqBNLN76lvDt02Z9O72XGpvlEOCWgTyfhqZXKjDaw=; b=i4ZL2FxpUrzDlKKHVEVmOk+5GbFS8ftnPPr20hHUtBrxlstmJvU5RxktY6b1Vcx0fV DhyQn+/sydjKHdw6zu+GnNNmUtXYLHJxb5kXjbpWmBHjgw6fHVsAD629H0Iyl2agllRX FwViusBEaWnvifhniUPZYCmteyT7R8MDh/InjBMprfDtNDW3j3i8I3h0YoDVshfh+pui OEmv9ZS6tJ/ZW06lub5dxJIeL2b2O7aK/Z6BKoara0FZWza6rcuZzT9Kixo+rtwmpw8E uusyRUY4M8ZIXkbN/GVdA8Qb1dxCVIBzwurL3PxscnaTJq/lHRLcdwQv3nnFMAptVkVG WIWw== X-Gm-Message-State: AOJu0YwVtGuOBCWLz3nZ4bFmzpMndRtqlmamrlvOrxcem9FIJ+4zJH5c KKQyZbVpeyRubeUxi0N0mQLQmax0jC31pyZSyKMHQana+js/MZUhgYRQs8ArAJM= X-Google-Smtp-Source: AGHT+IHQAQTjyHnSxviZgtgI0vIuOZfZH2ixcOe5Tj2LMg+WQaj65xPn4VkB/GO1BZ89fiRkpEeF7A== X-Received: by 2002:a05:6a00:1a8e:b0:710:4d08:e094 with SMTP id d2e1a72fcca58-7144573cd07mr1253784b3a.2.1724393647393; Thu, 22 Aug 2024 23:14:07 -0700 (PDT) From: Akihiko Odaki Date: Fri, 23 Aug 2024 15:13:12 +0900 Subject: [PATCH v4 7/7] tests/qtest: Delete previous boot file MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240823-san-v4-7-a24c6dfa4ceb@daynix.com> References: <20240823-san-v4-0-a24c6dfa4ceb@daynix.com> In-Reply-To: <20240823-san-v4-0-a24c6dfa4ceb@daynix.com> To: Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Yanan Wang , John Snow , BALATON Zoltan , Jiaxun Yang , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Alexey Kardashevskiy , "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Xu , Fabiano Rosas , Paolo Bonzini , David Hildenbrand , Thomas Huth , Laurent Vivier , Peter Maydell Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, qemu-ppc@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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: none client-ip=2607:f8b0:4864:20::42b; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1724393670942116600 A test run may create boot files several times. Delete the previous boot file before creating a new one. Signed-off-by: Akihiko Odaki Reviewed-by: Michael S. Tsirkin Acked-by: Thomas Huth --- tests/qtest/migration-test.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 70b606b88864..6c06100d91e2 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -144,12 +144,23 @@ static char *bootpath; #include "tests/migration/ppc64/a-b-kernel.h" #include "tests/migration/s390x/a-b-bios.h" =20 +static void bootfile_delete(void) +{ + unlink(bootpath); + g_free(bootpath); + bootpath =3D NULL; +} + static void bootfile_create(char *dir, bool suspend_me) { const char *arch =3D qtest_get_arch(); unsigned char *content; size_t len; =20 + if (bootpath) { + bootfile_delete(); + } + bootpath =3D g_strdup_printf("%s/bootsect", dir); if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { /* the assembled x86 boot sector should be exactly one sector larg= e */ @@ -177,13 +188,6 @@ static void bootfile_create(char *dir, bool suspend_me) fclose(bootfile); } =20 -static void bootfile_delete(void) -{ - unlink(bootpath); - g_free(bootpath); - bootpath =3D NULL; -} - /* * Wait for some output in the serial output file, * we get an 'A' followed by an endless string of 'B's --=20 2.46.0