From patchwork Wed Sep 4 12:43:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabiano Rosas X-Patchwork-Id: 825316 Delivered-To: patch@linaro.org Received: by 2002:adf:e246:0:b0:367:895a:4699 with SMTP id bl6csp147966wrb; Wed, 4 Sep 2024 05:47:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUyNsfQxrcBLIlwVnAupNA4GEzYLQK5TZTUXzhodXU4M/+5GODJTlXhLYC3OzeFFN87UPM2Ug==@linaro.org X-Google-Smtp-Source: AGHT+IG9VlpL+5l+4k3AUgx3zByuwasXDG1tnDwmJ9fc/0PDcOKllRbwAsB5xg8oye/8qlr5iri/ X-Received: by 2002:a05:622a:2519:b0:44f:fef0:70c7 with SMTP id d75a77b69052e-45696663d67mr238003191cf.44.1725454059805; Wed, 04 Sep 2024 05:47:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725454059; cv=none; d=google.com; s=arc-20160816; b=Jc77+OUyOghZcNAB0Y04Roo3cC1Zo9s0HkIEqDroqb/tdfESo89gt7blU/eNvUm1N8 ZjlKaBO54jKLm7k24lI002c4Qd5i/2PdpVjA10U7B6yAd5Huh5wtZrsk3izsi5E9WqRk 3biOH9iHCoJrTeiADUbiTe0RHlf7oR28r7i3c2f1U241phZs1FUyBGBlzxKwEMsOKBaB 1q7X7HxVKa7MlR1OotpwQzT+IgnKx7zhwwNgZcP76Yr1X+vf7n4Zyps+3C1Fx1za/zy7 Z9bty37u3w7HHmB9gcGqNyK8PzFIWHlJicwt8Wo1FYfnb5YrJPwKslFeNu7yl5EUuSlP cUmQ== 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:dkim-signature:dkim-signature:dkim-signature; bh=h8BaQiVelmckmlwaMiq3JJV9tWP+l6Wiavo1PrlqEfw=; fh=B7TvqVu3QfrFtXBZmPusoZHN6MTmUKJDm6MsLx3bAoo=; b=bVs83VQM7c9W10RwlTDBPNR7Xm+9vJ6rKVhmozH9iSHXsIhNHCcLZpAgcWIwCaMUGn lZR/clMFaZLrQRKITFpoofxUCWel8x2pcpmVCjE4hVooT176fsAf+0nlLcfJi2vD19qe HuFqs0jV1gcYH9M1+rAwrxiQ+Js2QDZYKdaLyeCzk0WrrrBlONJeCUQ3GcZYfeCCYBFS uwu0MxYxQccTbaTDKR7OlvPvW4apBQkqW2bKV+G9o8vrJoJEEBkhHstUSNpA4wqck2Fs ASBfXy/q/jYtY/9zCSPK03xXDlMw8SJQTSJ3aC/RljmATsOOeq+zDYqXhq8HOndY4k2g Zrkg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=TXMwhzjc; dkim=neutral (no key) header.i=@nongnu.org header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=sHloRYph; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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=suse.de Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-456859b8696si143316251cf.778.2024.09.04.05.47.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Sep 2024 05:47:39 -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=@suse.de header.s=susede2_rsa header.b=TXMwhzjc; dkim=neutral (no key) header.i=@nongnu.org header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=sHloRYph; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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=suse.de Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slpNA-0003OI-7y; Wed, 04 Sep 2024 08:44:32 -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 1slpN8-0003Ha-Hg for qemu-devel@nongnu.org; Wed, 04 Sep 2024 08:44:30 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1slpN6-0005QW-Rn for qemu-devel@nongnu.org; Wed, 04 Sep 2024 08:44:30 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6DFE6219FF; Wed, 4 Sep 2024 12:44:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1725453867; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h8BaQiVelmckmlwaMiq3JJV9tWP+l6Wiavo1PrlqEfw=; b=TXMwhzjc6XjAnKmQWevCL9x7gsVm2nJkZ1mPlNnuL/Bb9LxhPkfpZuMU65r0gTUyZ2Y0/J CASTTx1emWxVelEFKYTM578Nknr3Gf5Ila9et4HWYATmZI3zIaXAUDKRrUJGEemJ7iYkPr 1OMACx+ai6KHXNgvZxZSX31aMiAICwI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1725453867; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h8BaQiVelmckmlwaMiq3JJV9tWP+l6Wiavo1PrlqEfw=; b=w9HCwqbdpgXzirw/4eef7ZeqXWDvkeyTr+YhJ16IfQje4C1sORCwwlnK7PXAluEii7A2yu 1I74HcJlADDIrhDQ== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=sHloRYph; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="slt3SS/x" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1725453866; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h8BaQiVelmckmlwaMiq3JJV9tWP+l6Wiavo1PrlqEfw=; b=sHloRYphbcPcSKqiucih/yLSUL36w/BhSkj2ll+Drz7CYdY+4s17bctErs09S4Y1g0sGnr h/payUctl4j0P6CQF99VFJVa8DK8q0qrvXPFpOMBRkvBkyjWV3UAV7IxvVHSamU8xGeAa1 V9N8SrRPC9me3WSqvbFybnxgIazJH7k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1725453866; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h8BaQiVelmckmlwaMiq3JJV9tWP+l6Wiavo1PrlqEfw=; b=slt3SS/xGT0eN2SRZjmTlV1Id1gj9yhgikuZce9b9GxLfQl9OB50J6XXm+UzW0MkGzbRlw yikVVqlXrEycq4BQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 10AF0139D2; Wed, 4 Sep 2024 12:44:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id qL0SMihW2GZuVQAAD6G6ig (envelope-from ); Wed, 04 Sep 2024 12:44:24 +0000 From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Richard Henderson , Peter Maydell Subject: [PULL 03/34] tests/qtest/migration-test: Fix bootfile cleanup handling Date: Wed, 4 Sep 2024 09:43:46 -0300 Message-Id: <20240904124417.14565-4-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240904124417.14565-1-farosas@suse.de> References: <20240904124417.14565-1-farosas@suse.de> MIME-Version: 1.0 X-Rspamd-Queue-Id: 6DFE6219FF X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,suse.de:email,linaro.org:email]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; DWL_DNSWL_BLOCKED(0.00)[suse.de:dkim]; RCPT_COUNT_THREE(0.00)[4]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Peter Maydell If you invoke the migration-test binary in such a way that it doesn't run any tests, then we never call bootfile_create(), and at the end of main() bootfile_delete() will try to unlink(NULL), which is not valid. This can happen if for instance you tell the test binary to run a subset of tests that turns out to be empty, like this: (cd build/asan && QTEST_QEMU_BINARY=./qemu-system-x86_64 ./tests/qtest/migration-test --tap -k -p bang) # random seed: R02S6501b289ff8ced4231ba452c3a87bc6f # Skipping test: userfaultfd not available 1..0 ../../tests/qtest/migration-test.c:182:12: runtime error: null pointer passed as argument 1, which is declared to never be null /usr/include/unistd.h:858:48: note: nonnull attribute specified here Handle this by making bootfile_delete() not needing to do anything because bootfile_create() was never called. Signed-off-by: Peter Maydell Reviewed-by: Fabiano Rosas [fixed conflict with aee07f2563] Signed-off-by: Fabiano Rosas --- tests/qtest/migration-test.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 334b63cbaa..37ef99c980 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -145,6 +145,9 @@ static char *bootpath; static void bootfile_delete(void) { + if (!bootpath) { + return; + } unlink(bootpath); g_free(bootpath); bootpath = NULL; @@ -156,10 +159,7 @@ static void bootfile_create(char *dir, bool suspend_me) unsigned char *content; size_t len; - if (bootpath) { - bootfile_delete(); - } - + bootfile_delete(); bootpath = g_strdup_printf("%s/bootsect", dir); if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { /* the assembled x86 boot sector should be exactly one sector large */