From patchwork Wed Oct 11 02:36:27 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: 731916 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp180988wrv; Tue, 10 Oct 2023 19:37:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgDDmk00FPueL72FkDQWkbAfXJKEZwm4zbUNwB0HVcyQa5iq2d96lqZSuKEThgYqLClLRV X-Received: by 2002:a0c:b3db:0:b0:659:180c:38a0 with SMTP id b27-20020a0cb3db000000b00659180c38a0mr18604616qvf.7.1696991864318; Tue, 10 Oct 2023 19:37:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696991864; cv=none; d=google.com; s=arc-20160816; b=DTyyf0ymnZ8fV8SRweMFNDHgPo2zkeqMOvNTJ5ad4Bxpc32lceGp9vKYzH/aKomm5o 8UA0MeL5D4vzvQmGWe8IGroyXU6ItePaIM8zifkAlmQ3ITxgli0FGFKUD7MPAhoJfPVR xUVPaN69cXgQUaSwMMlrMHX5lEom/b0WN0CtkbbihkJcc6AOa/sPC9nrSWti4c55CMkt c65OfN4hZdHLSJI9wDyUM20ePU/rZcdZaTaz8sMjD4UhyMqoMeRHR1AaRt1ljMFD9gd6 01CpdcZixor/jhr7060y+oaxxpTnGTWYrAKz+mg/YOSGdEz4bAPOkQ1BDP6l6wngqGf5 dC9A== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=WxeHwpHbPHjqlbqI9btv605RsAT7uivuI4CIajlOLdw=; fh=8U+9cX3AxYYsw2InK4Dem8HxtTe2VEqwKkJ6DgOUOyM=; b=OyhHaXYq3hxXQ6oeZ/kEkPRDEdSONzXNLko5yhlIVCHkXT60Ok44pGPN76paWAq4bD jfsx7T6rdrtyxWStdPyqAd4i4sc8tmrCaEudmqziZQTRMDyVmVO3B9iK61KFcaWd9L0t 1JA+4X9t6iE9f9X57a1BrPSvv8PAuXR0ZD2m+V56UEiZYKC+J0dmyMd7/detFlZfbMb6 c1/PMNV56eJomikHoc9a3w7+KSGxTT/3V+SXLNbB8Ph/c0phAAYoVzpNBg3tBu6pI/M6 BYG+i+u+p5F3ScrnUbPR15li9LKhvz4nUOHerpSbEj8uV32wVp8k0B1fCwX8JNWDsqcF 67yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Viy/noHD"; 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 d5-20020a0ce445000000b0065b0b4fd579si8450335qvm.461.2023.10.10.19.37.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Oct 2023 19:37:44 -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="Viy/noHD"; 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 1qqP5P-00084z-Gx; Tue, 10 Oct 2023 22:36:35 -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 1qqP5N-00084V-Hn for qemu-devel@nongnu.org; Tue, 10 Oct 2023 22:36:33 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qqP5M-0003Q0-1K for qemu-devel@nongnu.org; Tue, 10 Oct 2023 22:36:33 -0400 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-9b974955474so1058393166b.1 for ; Tue, 10 Oct 2023 19:36:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696991790; x=1697596590; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=WxeHwpHbPHjqlbqI9btv605RsAT7uivuI4CIajlOLdw=; b=Viy/noHDjzqVfBdLuDrQxBQC22Rc+TT4MaNzcIC1bJv7yOOl8CjvReHiGFAbaar2vs L8DmeNo7vfebefcPy4Id0+CNBpDhRr4ujua7wU1vWAmfqKv5oIHbGcsmdjCd0NODEHcQ M7Vby2dCzKsyIwnr3AQor0UtaoeV0plNEJEfzvYE9jSl2lkwJm/xSJysxEIX0862d+Ge M3HEx1ESmXCZWjU7JToATZuier/aI9BVo2VDrQbGrGGmxm84fYbEzpRL40uHtD9bh5yV FLDpVefaQURp4gqCM/ynsYGBw7XukiFoyHLbb5IwLH4mlTGWRfOpeu4xbhe8Fl/G3USg /tuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696991790; x=1697596590; 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=WxeHwpHbPHjqlbqI9btv605RsAT7uivuI4CIajlOLdw=; b=mhsF6KnyimBoIeI/gtLrluDNhejP4wUZM2kV0Ih+WAnzKZ+EnG7w4/Fmv0/MaA2OpG yB7MJXvhjQIUROAZtigkmB8NGgtraD5UgcHB/pUxlpKXi4UB4UzuGHyAMTy5gWkR3HO9 hkO/8O9egKf7QCaW3mzXZWHyICP9U5X8fay5e8QD+S+DSG/wtUsJfBJKumg155E6MEle pFx75+SAL6s0WiXajpaKGE1UJjcP2BtAGyKn7QstTreirJNEpy+bw1bjv1TRTOc+5EEz mscW2ps/0P9dew2iW59FUeUItT3un8ysa26vG0MzkZj+6sr+YMT/HdrLwTIPC0ffg4AH 6tXg== X-Gm-Message-State: AOJu0YwkvEIr9AfYfauRLrfo1sDyaxX6l8Zs9PeNbK3e2ynQJ234ipe5 yoI9NwDqJzu5DQMxvMsUtmn4ryWqeMCAKhYCUzC9ig== X-Received: by 2002:a17:906:20da:b0:9ae:4eb9:e09b with SMTP id c26-20020a17090620da00b009ae4eb9e09bmr17988232ejc.27.1696991789707; Tue, 10 Oct 2023 19:36:29 -0700 (PDT) Received: from m1x-phil.lan (mdq11-h01-176-173-161-48.dsl.sta.abo.bbox.fr. [176.173.161.48]) by smtp.gmail.com with ESMTPSA id d21-20020a17090648d500b00997d76981e0sm9065963ejt.208.2023.10.10.19.36.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 10 Oct 2023 19:36:29 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Leonardo Bras , Markus Armbruster , Juan Quintela , Peter Xu , Fabiano Rosas , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2] migration: Use g_autofree to simplify ram_dirty_bitmap_reload() Date: Wed, 11 Oct 2023 04:36:27 +0200 Message-ID: <20231011023627.86691-1-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=philmd@linaro.org; helo=mail-ej1-x62d.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=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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Juan Quintela --- Based-on: v2: Do use g_autofree... --- migration/ram.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 982fbbeee1..a0e2ef4f1c 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4164,11 +4164,11 @@ bool ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *block, Error **errp) { /* from_dst_file is always valid because we're within rp_thread */ QEMUFile *file = s->rp_state.from_dst_file; - unsigned long *le_bitmap, nbits = block->used_length >> TARGET_PAGE_BITS; + g_autofree unsigned long *le_bitmap = NULL; + unsigned long nbits = block->used_length >> TARGET_PAGE_BITS; uint64_t local_size = DIV_ROUND_UP(nbits, 8); uint64_t size, end_mark; RAMState *rs = ram_state; - bool result = false; trace_ram_dirty_bitmap_reload_begin(block->idstr); @@ -4193,7 +4193,7 @@ bool ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *block, Error **errp) if (size != local_size) { error_setg(errp, "ramblock '%s' bitmap size mismatch (0x%"PRIx64 " != 0x%"PRIx64")", block->idstr, size, local_size); - goto out; + return false; } size = qemu_get_buffer(file, (uint8_t *)le_bitmap, local_size); @@ -4203,13 +4203,13 @@ bool ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *block, Error **errp) error_setg(errp, "read bitmap failed for ramblock '%s': " "(size 0x%"PRIx64", got: 0x%"PRIx64")", block->idstr, local_size, size); - goto out; + return false; } if (end_mark != RAMBLOCK_RECV_BITMAP_ENDING) { error_setg(errp, "ramblock '%s' end mark incorrect: 0x%"PRIx64, block->idstr, end_mark); - goto out; + return false; } /* @@ -4241,10 +4241,7 @@ bool ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *block, Error **errp) */ migration_rp_kick(s); - result = true; -out: - g_free(le_bitmap); - return result; + return true; } static int ram_resume_prepare(MigrationState *s, void *opaque)