From nobody Tue Oct 22 23:39:05 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1729615870; cv=none; d=zohomail.com; s=zohoarc; b=ci5hhOZUvP/4W1tiYxQzZXIJqdfNDhYxF4DT6r0fH8j9Ptlc7tsFc3k/Bc1uWRgRNsk1WDMKnVT+D9HJLEPNpGjUkV/2n2ioE8ptIa1easMAaBAxSZthGGREY5vOeXNaqDQ92c8VXzQA7rI7tRuJdOywdl544rSD/BSlasa5zsM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729615870; 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=HrwhFD+yJwwRK0vf/7Ph/1BLKTn0dL60XtkUPqjTahc=; b=ZEu2q/bMwoqJ5wRBTmPY/9rnlKqZd2uw3JxewOPxotCTF2FjoCMx5OvU1xpB+m3p4/bAJmISZLLbG24PQAW7eVapFKRsB/FOey+1sX+X8NTgBjG120pFwPefY5ukXFNa9DmWURTFFrt+vdNIOshEdTlL2+CnblboFRX16RnrIx0= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1729615870364197.8843008418795; Tue, 22 Oct 2024 09:51:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3I4d-0000PF-Fw; Tue, 22 Oct 2024 12:49: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 1t3I4a-0000Hv-1H for qemu-devel@nongnu.org; Tue, 22 Oct 2024 12:49:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3I4X-00064a-8j for qemu-devel@nongnu.org; Tue, 22 Oct 2024 12:49:31 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-536-WRJkCBd6NyuXEFf1vxyxyQ-1; Tue, 22 Oct 2024 12:49:16 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0DA2B1956046; Tue, 22 Oct 2024 16:49:15 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.70]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C0C3A1956056; Tue, 22 Oct 2024 16:49:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729615759; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HrwhFD+yJwwRK0vf/7Ph/1BLKTn0dL60XtkUPqjTahc=; b=E0rn3F7hq+7ZFw4p38azUOIKsyUuKYDyU0WXotKPGSuvdgrjcT0xMVqjTzqlVXNM6on4cv eM2x9bDYZB4Na8R6Yh0h7dtVvPXainfDqPWVxCpqCTJmpoeHXDk0dsW5dwzUm0UAZMS/Wd bx5CL4RipIADEryaIRWZnJormXftyhg= X-MC-Unique: WRJkCBd6NyuXEFf1vxyxyQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 1/9] block/gluster: Use g_autofree for string in qemu_gluster_parse_json() Date: Tue, 22 Oct 2024 18:48:55 +0200 Message-ID: <20241022164903.282174-2-kwolf@redhat.com> In-Reply-To: <20241022164903.282174-1-kwolf@redhat.com> References: <20241022164903.282174-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.519, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729615871549116600 From: Peter Maydell In the loop in qemu_gluster_parse_json() we do: char *str =3D NULL; for(...) { str =3D g_strdup_printf(...); ... if (various errors) { goto out; } ... g_free(str); str =3D NULL; } return 0; out: various cleanups; g_free(str); ... return -errno; Coverity correctly complains that the assignment "str =3D NULL" at the end of the loop is unnecessary, because we will either go back to the top of the loop and overwrite it, or else we will exit the loop and then exit the function without ever reading str again. The assignment is there as defensive coding to ensure that str is only non-NULL if it's a live allocation, so this is intentional. We can make Coverity happier and simplify the code here by using g_autofree, since we never need 'str' outside the loop. Resolves: Coverity CID 1527385 Signed-off-by: Peter Maydell Reviewed-by: Kevin Wolf Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-ID: <20241008164708.2966400-2-peter.maydell@linaro.org> Reviewed-by: Richard Henderson Signed-off-by: Kevin Wolf --- block/gluster.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/block/gluster.c b/block/gluster.c index f03d05251e..e9c038042b 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -514,7 +514,6 @@ static int qemu_gluster_parse_json(BlockdevOptionsGlust= er *gconf, SocketAddressList **tail; QDict *backing_options =3D NULL; Error *local_err =3D NULL; - char *str =3D NULL; const char *ptr; int i, type, num_servers; =20 @@ -547,7 +546,8 @@ static int qemu_gluster_parse_json(BlockdevOptionsGlust= er *gconf, tail =3D &gconf->server; =20 for (i =3D 0; i < num_servers; i++) { - str =3D g_strdup_printf(GLUSTER_OPT_SERVER_PATTERN"%d.", i); + g_autofree char *str =3D g_strdup_printf(GLUSTER_OPT_SERVER_PATTER= N"%d.", + i); qdict_extract_subqdict(options, &backing_options, str); =20 /* create opts info from runtime_type_opts list */ @@ -658,8 +658,6 @@ static int qemu_gluster_parse_json(BlockdevOptionsGlust= er *gconf, =20 qobject_unref(backing_options); backing_options =3D NULL; - g_free(str); - str =3D NULL; } =20 return 0; @@ -668,7 +666,6 @@ out: error_propagate(errp, local_err); qapi_free_SocketAddress(gsconf); qemu_opts_del(opts); - g_free(str); qobject_unref(backing_options); errno =3D EINVAL; return -errno; --=20 2.47.0 From nobody Tue Oct 22 23:39:05 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1729615834; cv=none; d=zohomail.com; s=zohoarc; b=d01LLUlVBVJM97DQF+S9DMGWo3YJbmu9ZpSTB/Dmiw4mtYZK/F6tXGTpJ/iUr7ifx/Rq30Ye38VzZIiOigmgCbeLH/W6gnQTdaXGxsL4B7iF5uUGeB9nso3AkueMKud7g6s/HdhVC5AMptTIaDQ5tti4z9sZ5pFz89t5mYwynTU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729615834; h=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=VDoKVxzboEyOZx7JDyIdlXgX6eUiunNnXmtg/ZwTIlk=; b=ITalWestS384DmkfogZavvLiljmWg71PbCaAdjMMqGXj8b6WJKSdOug8ea6e0ckzpSyVKKGSKDojVc7HqKmit17B6p3zA3K6iIGzYqmrFwjHgrVgwzNUNrfx+dKr9EQE6PDHN1z2MHWv2kyo/ZnrkFvLnxnhLnHjFh6TkqluFDM= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1729615834157467.82931439563527; Tue, 22 Oct 2024 09:50:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3I4a-0000Hx-B9; Tue, 22 Oct 2024 12:49: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 1t3I4X-0000GF-IF for qemu-devel@nongnu.org; Tue, 22 Oct 2024 12:49:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3I4R-00064Y-B4 for qemu-devel@nongnu.org; Tue, 22 Oct 2024 12:49:27 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-613-jp-gYhGgONWmZrwZfF9gGQ-1; Tue, 22 Oct 2024 12:49:17 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A59E7195608C; Tue, 22 Oct 2024 16:49:16 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.70]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 745541956056; Tue, 22 Oct 2024 16:49:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729615758; h=from:from:reply-to:subject:subject: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=VDoKVxzboEyOZx7JDyIdlXgX6eUiunNnXmtg/ZwTIlk=; b=f13coFq2pK+lN51b2J3str8kjypkK+h4JwQPM03ZVlDyDh9B6h6f7xuV0drKAvU9asRfQ1 IYLzml8rxhyzrrRegNfSTPulKcbeAg08mdVpDjC2EZhCWISs9bzaPETeKMg25AiF45dN6E gK+t0qpjYzlywBGawCkyKa8dUlo/8js= X-MC-Unique: jp-gYhGgONWmZrwZfF9gGQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 2/9] block/ssh.c: Don't double-check that characters are hex digits Date: Tue, 22 Oct 2024 18:48:56 +0200 Message-ID: <20241022164903.282174-3-kwolf@redhat.com> In-Reply-To: <20241022164903.282174-1-kwolf@redhat.com> References: <20241022164903.282174-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.519, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1.697, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729615835408116600 Content-Type: text/plain; charset="utf-8" From: Peter Maydell In compare_fingerprint() we effectively check whether the characters in the fingerprint are valid hex digits twice: first we do so with qemu_isxdigit(), but then the hex2decimal() function also has a code path where it effectively detects an invalid digit and returns -1. This causes Coverity to complain because it thinks that we might use that -1 value in an expression where it would be an integer overflow. Avoid the double-check of hex digit validity by testing the return values from hex2decimal() rather than doing separate calls to qemu_isxdigit(). Since this means we now use the illegal-character return value from hex2decimal(), rewrite it from "-1" to "UINT_MAX", which has the same effect since the return type is "unsigned" but looks less confusing at the callsites when we detect it with "c0 > 0xf". Resolves: Coverity CID 1547813 Signed-off-by: Peter Maydell Reviewed-by: Kevin Wolf Message-ID: <20241008164708.2966400-3-peter.maydell@linaro.org> Reviewed-by: Richard Henderson Signed-off-by: Kevin Wolf --- block/ssh.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/block/ssh.c b/block/ssh.c index 871e1d4753..9f8140bcb6 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -364,7 +364,7 @@ static unsigned hex2decimal(char ch) return 10 + (ch - 'A'); } =20 - return -1; + return UINT_MAX; } =20 /* Compare the binary fingerprint (hash of host key) with the @@ -376,13 +376,15 @@ static int compare_fingerprint(const unsigned char *f= ingerprint, size_t len, unsigned c; =20 while (len > 0) { + unsigned c0, c1; while (*host_key_check =3D=3D ':') host_key_check++; - if (!qemu_isxdigit(host_key_check[0]) || - !qemu_isxdigit(host_key_check[1])) + c0 =3D hex2decimal(host_key_check[0]); + c1 =3D hex2decimal(host_key_check[1]); + if (c0 > 0xf || c1 > 0xf) { return 1; - c =3D hex2decimal(host_key_check[0]) * 16 + - hex2decimal(host_key_check[1]); + } + c =3D c0 * 16 + c1; if (c - *fingerprint !=3D 0) return c - *fingerprint; fingerprint++; --=20 2.47.0 From nobody Tue Oct 22 23:39:05 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1729615800; cv=none; d=zohomail.com; s=zohoarc; b=b2Ihs2jl0pEppuELsieiiMZ1UPYGVLL4dMi+j8QRNlaj0Es8+jgJ2uwtxHauyxHF55+4mBe30j3HXb6U56NYusQeq4VRG+FrU+GCJenRhTUHOBpqDmN/gGNc9bRMmJUmdBlDxtyfTJcil33AqetVIaUeUmd0u4wtEdu89TGfwtQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729615800; h=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=S0ZiwsCWhMmJcdocwXil0ov8/vtrwY/088vJRb2QPCQ=; b=jxzdLTp3xe4/z2KJtzcHl2WUChMA2W3um19Ml8xHwi4KLR8cOKeGSYshvLyRcmZfOmecZkPxCc3JcFlRx0UTw8RfHlkSOhTSLkOJqS9lVKokzVKVbrsqT5kCg/7PiXxHp9M7gtc1jbra6hmy1NCboxdF6pbfb4uUGKfi9suLmzo= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1729615800400804.556126297265; Tue, 22 Oct 2024 09:50:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3I4c-0000Me-Nl; Tue, 22 Oct 2024 12:49:34 -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 1t3I4a-0000Hw-1H for qemu-devel@nongnu.org; Tue, 22 Oct 2024 12:49:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3I4X-00065E-8W for qemu-devel@nongnu.org; Tue, 22 Oct 2024 12:49:31 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-256-eaeCG3_vPfKwkkCpa8PRIA-1; Tue, 22 Oct 2024 12:49:20 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 926D31955F65; Tue, 22 Oct 2024 16:49:19 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.70]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 199AA1956056; Tue, 22 Oct 2024 16:49:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729615764; h=from:from:reply-to:subject:subject: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=S0ZiwsCWhMmJcdocwXil0ov8/vtrwY/088vJRb2QPCQ=; b=KIUZVatu1fV6QBgV6r1D3qBOJ5jvCf1RxDbClCRJJbHfsaFWJTX10ywfEqyCgZomKDMUYY E1E9HTY3jV8L/uZTBw8+S7dRhBMxYOLd2SkSHOj3pRSyHuNUrquk8ImTz/LM5UXUo4Gaqs wHwbZX8J4GcZ7Gp6dooarUNueFCxXos= X-MC-Unique: eaeCG3_vPfKwkkCpa8PRIA-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 3/9] tests/qemu-iotests/211.out: Update to expect MapEntry 'compressed' field Date: Tue, 22 Oct 2024 18:48:57 +0200 Message-ID: <20241022164903.282174-4-kwolf@redhat.com> In-Reply-To: <20241022164903.282174-1-kwolf@redhat.com> References: <20241022164903.282174-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.519, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729615801365116600 Content-Type: text/plain; charset="utf-8" From: Peter Maydell In commit 52b10c9c0c68e90f in 2023 the QAPI MapEntry struct was updated to add a 'compressed' field. That commit updated a number of iotest expected-output files, but missed 211, which is vdi specific. The result is that ./check -vdi and more specifically ./check -vdi 211 fails because the expected and actual output don't match. Update the reference output. Cc: qemu-stable@nongnu.org Fixes: 52b10c9c0c68e90f ("qemu-img: map: report compressed data blocks") Signed-off-by: Peter Maydell Message-ID: <20241008164708.2966400-4-peter.maydell@linaro.org> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- tests/qemu-iotests/211.out | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/211.out b/tests/qemu-iotests/211.out index f02c75409c..ff9f9a6913 100644 --- a/tests/qemu-iotests/211.out +++ b/tests/qemu-iotests/211.out @@ -17,7 +17,7 @@ file format: IMGFMT virtual size: 128 MiB (134217728 bytes) cluster_size: 1048576 =20 -[{"data": false, "depth": 0, "length": 134217728, "present": true, "start"= : 0, "zero": true}] +[{"compressed": false, "data": false, "depth": 0, "length": 134217728, "pr= esent": true, "start": 0, "zero": true}] =3D=3D=3D Successful image creation (explicit defaults) =3D=3D=3D =20 {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "file", "filename": "TEST_DIR/PID-t.vdi", "size": 0}}} @@ -35,7 +35,7 @@ file format: IMGFMT virtual size: 64 MiB (67108864 bytes) cluster_size: 1048576 =20 -[{"data": false, "depth": 0, "length": 67108864, "present": true, "start":= 0, "zero": true}] +[{"compressed": false, "data": false, "depth": 0, "length": 67108864, "pre= sent": true, "start": 0, "zero": true}] =3D=3D=3D Successful image creation (with non-default options) =3D=3D=3D =20 {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "file", "filename": "TEST_DIR/PID-t.vdi", "size": 0}}} @@ -53,7 +53,7 @@ file format: IMGFMT virtual size: 32 MiB (33554432 bytes) cluster_size: 1048576 =20 -[{"data": true, "depth": 0, "length": 3072, "offset": 1024, "present": tru= e, "start": 0, "zero": false}, {"data": true, "depth": 0, "length": 3355136= 0, "offset": 4096, "present": true, "start": 3072, "zero": true}] +[{"compressed": false, "data": true, "depth": 0, "length": 3072, "offset":= 1024, "present": true, "start": 0, "zero": false}, {"compressed": false, "= data": true, "depth": 0, "length": 33551360, "offset": 4096, "present": tru= e, "start": 3072, "zero": true}] =3D=3D=3D Invalid BlockdevRef =3D=3D=3D =20 {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "vdi", "file": "this doesn't exist", "size": 33554432}}} --=20 2.47.0 From nobody Tue Oct 22 23:39:05 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1729615881; cv=none; d=zohomail.com; s=zohoarc; b=NxaYm3kdM2PAWw3jqruVpddQdqFUCX/hzIRlGsJTmyoDs7kbtn5ayBWY7BDNP+F0+OMKROog6cg7Yy+573627qC2OKlV99N4vt8/sW1/32h8DyYprH+50/0/C0Oo4UXMLJNiknMhr4il2d6zbB5qzb6UlsjiGbemmWsJwdL1qVI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729615881; h=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=0s2NzQAkVXUXjzpQCMdLxQHeBTEoVVx/FCeKoPNe9Qw=; b=V+ZaaJJrHGxf61CmV2btMCOlZ0D3H05jFLxY2vqSmrK1ll1tR1VzxtWRJCVsQ5UuqKDU28Y8uceyP3WsyFcCSJgJdEm2OET6Utg6c/166Kkc21YPA52M4686cB2q9v127eY2uKaRFqqUeplYBbXgdyxwWgbGZ/KXJRB8fbEPCGA= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1729615881864552.8227214438056; Tue, 22 Oct 2024 09:51:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3I4e-0000QX-01; Tue, 22 Oct 2024 12:49:36 -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 1t3I4b-0000KE-5t for qemu-devel@nongnu.org; Tue, 22 Oct 2024 12:49:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3I4X-00065n-9M for qemu-devel@nongnu.org; Tue, 22 Oct 2024 12:49:32 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-10-X46m07fuMb-7huM5XCIdmg-1; Tue, 22 Oct 2024 12:49:23 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 011A419560BA; Tue, 22 Oct 2024 16:49:22 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.70]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D463A1955EA3; Tue, 22 Oct 2024 16:49:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729615767; h=from:from:reply-to:subject:subject: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=0s2NzQAkVXUXjzpQCMdLxQHeBTEoVVx/FCeKoPNe9Qw=; b=a8qJcXMcpAlFAhYrlqQ+y9xFRfghZuI2tOtFdlxsjuUkVDG7Q3nLX490RJXttpTnh8BKjd JWHMgioEeXa3DuNuGeM2GdiZPnRgzKnA+mhc9O5QbU7xGVrJX4VLfUdmolfesA4A84w2Dy 5M8B5yANXX27YOpTYNudFlflPM/Buck= X-MC-Unique: X46m07fuMb-7huM5XCIdmg-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 4/9] block/vdi.c: Make SECTOR_SIZE constant 64-bits Date: Tue, 22 Oct 2024 18:48:58 +0200 Message-ID: <20241022164903.282174-5-kwolf@redhat.com> In-Reply-To: <20241022164903.282174-1-kwolf@redhat.com> References: <20241022164903.282174-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.519, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729615883605116600 Content-Type: text/plain; charset="utf-8" From: Peter Maydell Make the VDI SECTOR_SIZE define be a 64-bit constant; this matches how we define BDRV_SECTOR_SIZE. The benefit is that it means that we don't need to carefully cast to 64-bits when doing operations like "n_sectors * SECTOR_SIZE" to avoid doing a 32x32->32 multiply, which might overflow, and which Coverity and other static analysers tend to warn about. The specific potential overflow Coverity is highlighting is the one at the end of vdi_co_pwritev() where we write out n_sectors sectors to the block map. This is very unlikely to actually overflow, since the block map has 4 bytes per block and the maximum number of blocks in the image must fit into a 32-bit integer. So this commit is not fixing a real-world bug. An inspection of all the places currently using SECTOR_SIZE in the file shows none which care about the change in its type, except for one call to error_setg() which needs the format string adjusting. Resolves: Coverity CID 1508076 Suggested-by: Kevin Wolf Message-ID: <20241008164708.2966400-5-peter.maydell@linaro.org> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/vdi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/vdi.c b/block/vdi.c index 149e15c831..26f7638f1f 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -87,7 +87,7 @@ /* Command line option for static images. */ #define BLOCK_OPT_STATIC "static" =20 -#define SECTOR_SIZE 512 +#define SECTOR_SIZE 512ULL #define DEFAULT_CLUSTER_SIZE 1048576 /* Note: can't use 1 * MiB, because it's passed to stringify() */ =20 @@ -442,7 +442,7 @@ static int vdi_open(BlockDriverState *bs, QDict *option= s, int flags, goto fail; } else if (header.sector_size !=3D SECTOR_SIZE) { error_setg(errp, "unsupported VDI image (sector size %" PRIu32 - " is not %u)", header.sector_size, SECTOR_SIZE); + " is not %llu)", header.sector_size, SECTOR_SIZE); ret =3D -ENOTSUP; goto fail; } else if (header.block_size !=3D DEFAULT_CLUSTER_SIZE) { --=20 2.47.0 From nobody Tue Oct 22 23:39:05 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1729615884; cv=none; d=zohomail.com; s=zohoarc; b=bQvUOGZaUxtNh6Pj+SAzLPUWOE2q1YSwUzFEA8KLRbioj0+Bb72uarJOfmqyKC1THCQlLN5E3C6ndWLCEeQozAeKMiqICyVe3vrrb76EGg5qx0Q/CWbGAT7un0FTwjJv813rDl8DGaxhfIGvYpoBQ4meCL+V5C9Dxzph8WUHHU4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729615884; h=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=pWd8qSFRMUXHBUD1J9oD9i5oR04LJMY81kwu8tgABa4=; b=kj5o9oCkv4PzloBZJMgC5SxIC6/6Z4ofgxjUXIiM34jOP25nsk1yjhoA2wDoz4qKv71pD6KW2zrodblYisrynzqovw5uKo9CJ6zToQr+wMxacX0i64Fg60MhHARTDPLQRfUnxf20J0NlAOybx3J8lwtgxcSGHugZeuNUZcp6CMY= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172961588432821.467538448549476; Tue, 22 Oct 2024 09:51:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3I4e-0000S9-E8; Tue, 22 Oct 2024 12:49:36 -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 1t3I4b-0000L5-EE for qemu-devel@nongnu.org; Tue, 22 Oct 2024 12:49:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3I4Y-00066W-Li for qemu-devel@nongnu.org; Tue, 22 Oct 2024 12:49:33 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-42-32XfN1m5NDGFWcI3zK7F4g-1; Tue, 22 Oct 2024 12:49:26 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8C2F419560BF; Tue, 22 Oct 2024 16:49:23 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.70]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 699B21955EA5; Tue, 22 Oct 2024 16:49:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729615770; h=from:from:reply-to:subject:subject: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=pWd8qSFRMUXHBUD1J9oD9i5oR04LJMY81kwu8tgABa4=; b=NV6d7iEcRBCRSzSxYPjv4oIlL5p6Lkma2QYGVZ6nYomAVwC+GDtYT+d37Zl4VS42uOT+Z4 ytKIzVdJFENAXAe4rsn2gUnCis5IXQfbhib/ZVl/5u5fYahu2Wd7dV7wN0qzAVG6SWH9i7 vh/zFaEMJo2n6irFwar4lx1YCxTHZak= X-MC-Unique: 32XfN1m5NDGFWcI3zK7F4g-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 5/9] iotests/backup-discard-source: convert size variable to be int Date: Tue, 22 Oct 2024 18:48:59 +0200 Message-ID: <20241022164903.282174-6-kwolf@redhat.com> In-Reply-To: <20241022164903.282174-1-kwolf@redhat.com> References: <20241022164903.282174-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.519, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729615885583116600 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Make variable reusable in code for checks. Don't care to change "512 * 1024" invocations as they will be dropped in the next commit. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-ID: <20240620144402.65896-2-vsementsov@yandex-team.ru> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- tests/qemu-iotests/tests/backup-discard-source | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/qemu-iotests/tests/backup-discard-source b/tests/qemu-io= tests/tests/backup-discard-source index 2391b12acd..05fbe5d26b 100755 --- a/tests/qemu-iotests/tests/backup-discard-source +++ b/tests/qemu-iotests/tests/backup-discard-source @@ -28,7 +28,7 @@ from iotests import qemu_img_create, qemu_img_map, qemu_io temp_img =3D os.path.join(iotests.test_dir, 'temp') source_img =3D os.path.join(iotests.test_dir, 'source') target_img =3D os.path.join(iotests.test_dir, 'target') -size =3D '1M' +size =3D 1024 * 1024 =20 =20 def get_actual_size(vm, node_name): @@ -39,9 +39,9 @@ def get_actual_size(vm, node_name): =20 class TestBackup(iotests.QMPTestCase): def setUp(self): - qemu_img_create('-f', iotests.imgfmt, source_img, size) - qemu_img_create('-f', iotests.imgfmt, temp_img, size) - qemu_img_create('-f', iotests.imgfmt, target_img, size) + qemu_img_create('-f', iotests.imgfmt, source_img, str(size)) + qemu_img_create('-f', iotests.imgfmt, temp_img, str(size)) + qemu_img_create('-f', iotests.imgfmt, target_img, str(size)) qemu_io('-c', 'write 0 1M', source_img) =20 self.vm =3D iotests.VM() @@ -98,7 +98,7 @@ class TestBackup(iotests.QMPTestCase): mapping =3D qemu_img_map(temp_img) self.assertEqual(len(mapping), 1) self.assertEqual(mapping[0]['start'], 0) - self.assertEqual(mapping[0]['length'], 1024 * 1024) + self.assertEqual(mapping[0]['length'], size) self.assertEqual(mapping[0]['data'], False) =20 os.remove(temp_img) @@ -125,7 +125,7 @@ class TestBackup(iotests.QMPTestCase): self.assert_qmp(result, 'return', '') =20 # Check that data is written to temporary image - self.assertGreater(get_actual_size(self.vm, 'temp'), 1024 * 1024) + self.assertGreater(get_actual_size(self.vm, 'temp'), size) =20 self.do_backup() =20 --=20 2.47.0 From nobody Tue Oct 22 23:39:05 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1729615793; cv=none; d=zohomail.com; s=zohoarc; b=gXpE8FA0w05VJ2Mby88Uzfbr9+HO2z/atcEgd+NnciOwprGw7JKLkjOgOv8sPXMpPcR0eOLvDyWN2Bcr1FH+wJTU6iRU2bVJVtAGlmsbPntS5iWT2Ai/z059GkHTaEEFCmtDeR4frXMtmXzIJ5GbNS83r3FZzWeYB61McvyF+pI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729615793; h=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=rl0hWf2NeoTp5Fong/EsvdHnc9EM8hnTSIjY+zlizyA=; b=dI4qd8/XivEvI9sTNDlGnG4xwpuKZPnEk//uwwlMUsn/+tk0ihlg5bq7c/niFn5xt4sG2e7emuRu8ApExrkh/Xr/EWzn7gEusUu9VASt/rYagt38j+swMytcjujjT+96/4sauoK4asQ9VHnlxRfliShSn6D8XfkY00TKKOe92zM= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1729615793095590.9346947988018; Tue, 22 Oct 2024 09:49:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3I4h-0000YX-Gm; Tue, 22 Oct 2024 12:49:39 -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 1t3I4b-0000L4-Ey for qemu-devel@nongnu.org; Tue, 22 Oct 2024 12:49:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3I4X-00065x-Jq for qemu-devel@nongnu.org; Tue, 22 Oct 2024 12:49:33 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-75-zkNmY3dsPMOLyiW_5LvZaw-1; Tue, 22 Oct 2024 12:49:27 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 475A11955D92; Tue, 22 Oct 2024 16:49:26 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.70]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 66CD41956056; Tue, 22 Oct 2024 16:49:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729615768; h=from:from:reply-to:subject:subject: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=rl0hWf2NeoTp5Fong/EsvdHnc9EM8hnTSIjY+zlizyA=; b=ERG53exUQN6Zc5mZqfchfn6ACkiCosY2+5hKzW/qRH1lD02bLexLk/PkqZoi8p84IH9LwA yWBAOxoFTzPje97Agp/cQqnU1585e0LlqoLbNhJJnHBnckQIK4q9pkiqsdOOMWx45iM3S4 vY7WlGK8uANrbkonl2lFxpOdFVyRP/M= X-MC-Unique: zkNmY3dsPMOLyiW_5LvZaw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 6/9] iotests/backup-discard-source: don't use actual-size Date: Tue, 22 Oct 2024 18:49:00 +0200 Message-ID: <20241022164903.282174-7-kwolf@redhat.com> In-Reply-To: <20241022164903.282174-1-kwolf@redhat.com> References: <20241022164903.282174-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.519, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1.697, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729615795332116600 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Relying on disk usage is bad thing, and test just doesn't work on XFS. Let's instead add a dirty bitmap to track writes to test image. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-ID: <20240620144402.65896-3-vsementsov@yandex-team.ru> Reviewed-by: Kevin Wolf Tested-by: Kevin Wolf Signed-off-by: Kevin Wolf --- .../qemu-iotests/tests/backup-discard-source | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/tests/qemu-iotests/tests/backup-discard-source b/tests/qemu-io= tests/tests/backup-discard-source index 05fbe5d26b..17fef9c6d3 100755 --- a/tests/qemu-iotests/tests/backup-discard-source +++ b/tests/qemu-iotests/tests/backup-discard-source @@ -31,12 +31,6 @@ target_img =3D os.path.join(iotests.test_dir, 'target') size =3D 1024 * 1024 =20 =20 -def get_actual_size(vm, node_name): - nodes =3D vm.cmd('query-named-block-nodes', flat=3DTrue) - node =3D next(n for n in nodes if n['node-name'] =3D=3D node_name) - return node['image']['actual-size'] - - class TestBackup(iotests.QMPTestCase): def setUp(self): qemu_img_create('-f', iotests.imgfmt, source_img, str(size)) @@ -84,7 +78,12 @@ class TestBackup(iotests.QMPTestCase): } }) =20 - self.assertLess(get_actual_size(self.vm, 'temp'), 512 * 1024) + self.bitmap =3D { + 'node': 'temp', + 'name': 'bitmap0' + } + + self.vm.cmd('block-dirty-bitmap-add', self.bitmap) =20 def tearDown(self): # That should fail, because region is discarded @@ -113,6 +112,13 @@ class TestBackup(iotests.QMPTestCase): =20 self.vm.event_wait(name=3D'BLOCK_JOB_COMPLETED') =20 + def get_bitmap_count(self): + nodes =3D self.vm.cmd('query-named-block-nodes', flat=3DTrue) + temp =3D next(n for n in nodes if n['node-name'] =3D=3D 'temp') + bitmap =3D temp['dirty-bitmaps'][0] + assert bitmap['name'] =3D=3D self.bitmap['name'] + return bitmap['count'] + def test_discard_written(self): """ 1. Guest writes @@ -125,7 +131,7 @@ class TestBackup(iotests.QMPTestCase): self.assert_qmp(result, 'return', '') =20 # Check that data is written to temporary image - self.assertGreater(get_actual_size(self.vm, 'temp'), size) + self.assertEqual(self.get_bitmap_count(), size) =20 self.do_backup() =20 @@ -138,13 +144,18 @@ class TestBackup(iotests.QMPTestCase): """ self.do_backup() =20 + # backup job did discard operation and pollute the bitmap, + # we have to clean the bitmap, to check next write + self.assertEqual(self.get_bitmap_count(), size) + self.vm.cmd('block-dirty-bitmap-clear', self.bitmap) + # Try trigger copy-before-write operation result =3D self.vm.hmp_qemu_io('cbw', 'write 0 1M') self.assert_qmp(result, 'return', '') =20 # Check that data is not written to temporary image, as region # is discarded from copy-before-write process - self.assertLess(get_actual_size(self.vm, 'temp'), 512 * 1024) + self.assertEqual(self.get_bitmap_count(), 0) =20 =20 if __name__ =3D=3D '__main__': --=20 2.47.0 From nobody Tue Oct 22 23:39:05 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1729615873; cv=none; d=zohomail.com; s=zohoarc; b=jHJWdJwrbbnKYBhe+I+CPE+w7G+k3MNAeynncmKyf69VocivMFeoVfG/5hcI3sAJifeBhwJjUgReOqTfdQmUXA/9HiajyO7SgrQosWbt5GzaGegeBIQ5Cb2fejqcC6lDuh06dah2Q+fx+OuBvF3/9pC0eqFcjLbnQzyDlUX4dWE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729615873; h=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=rMpQ5CTt7Zy94AtlruARh6XIoc4CG8eA88qWMFobVeo=; b=AdY0RG6rEl9jkCWtfs9QRRYdEBfavn9+Qk/wHwFM2NLV6I1SBZ9CG0MfHRRxRMKXMk3Qdfq2gwZN3pO/GhCD7seo67hdrGWOox4poeFnZNYGCxggqfGi8zL+4lAQyTk+Jlya6EZY/KIIyXsWI9529j7ZJkvOInzvJQJoZAS5sAM= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172961587316554.895987597170006; Tue, 22 Oct 2024 09:51:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3I4i-0000Zc-OJ; Tue, 22 Oct 2024 12:49:40 -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 1t3I4e-0000Qp-0s for qemu-devel@nongnu.org; Tue, 22 Oct 2024 12:49:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3I4c-00068J-Fl for qemu-devel@nongnu.org; Tue, 22 Oct 2024 12:49:35 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-543-H1zftW-UPXy4Rkr5c4Am8w-1; Tue, 22 Oct 2024 12:49:32 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BA39E1956096; Tue, 22 Oct 2024 16:49:31 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.70]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 256091955E70; Tue, 22 Oct 2024 16:49:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729615773; h=from:from:reply-to:subject:subject: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=rMpQ5CTt7Zy94AtlruARh6XIoc4CG8eA88qWMFobVeo=; b=RaE3jx5WPmDAJAFxzImM8ZmCUduX5yHzfQKsLpyiFjhB3Nr2xtMdwt3wMBl0TPfRZjR4c9 xeG7rU4hcMV8naXL3Ar99x/MKCPc8zg3lPmo7gyudbSmJTDTH9tU8z5tkAbhNUcvElBwOB auGNKKVm07RPuLd86qQckZNG0Js0Qz4= X-MC-Unique: H1zftW-UPXy4Rkr5c4Am8w-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 7/9] qapi: add qom-path to BLOCK_IO_ERROR event Date: Tue, 22 Oct 2024 18:49:01 +0200 Message-ID: <20241022164903.282174-8-kwolf@redhat.com> In-Reply-To: <20241022164903.282174-1-kwolf@redhat.com> References: <20241022164903.282174-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.519, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1.697, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729615873627116600 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy We need something more reliable than "device" (which absent in modern interfaces) and "node-name" (which may absent, and actually don't specify the device, which is a source of error) to make a per-device throttling for the event in the following commit. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-ID: <20241002151806.592469-2-vsementsov@yandex-team.ru> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- qapi/block-core.json | 7 +++++-- block/block-backend.c | 21 +++++++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 2feae8e697..fe63ba6cbf 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -5584,6 +5584,8 @@ # # Emitted when a disk I/O error occurs # +# @qom-path: path to the device object in the QOM tree (since 9.2) +# # @device: device name. This is always present for compatibility # reasons, but it can be empty ("") if the image does not have a # device name associated. @@ -5614,7 +5616,8 @@ # .. qmp-example:: # # <- { "event": "BLOCK_IO_ERROR", -# "data": { "device": "ide0-hd1", +# "data": { "qom-path": "/machine/unattached/device[0]", +# "device": "ide0-hd1", # "node-name": "#block212", # "operation": "write", # "action": "stop", @@ -5622,7 +5625,7 @@ # "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } ## { 'event': 'BLOCK_IO_ERROR', - 'data': { 'device': 'str', '*node-name': 'str', + 'data': { 'qom-path': 'str', 'device': 'str', '*node-name': 'str', 'operation': 'IoOperationType', 'action': 'BlockErrorAction', '*nospace': 'bool', 'reason': 'str' } } diff --git a/block/block-backend.c b/block/block-backend.c index 7bea43bf72..85bcdedcef 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1019,22 +1019,34 @@ DeviceState *blk_get_attached_dev(BlockBackend *blk) return blk->dev; } =20 -/* Return the qdev ID, or if no ID is assigned the QOM path, of the block - * device attached to the BlockBackend. */ -char *blk_get_attached_dev_id(BlockBackend *blk) +static char *blk_get_attached_dev_id_or_path(BlockBackend *blk, bool want_= id) { DeviceState *dev =3D blk->dev; IO_CODE(); =20 if (!dev) { return g_strdup(""); - } else if (dev->id) { + } else if (want_id && dev->id) { return g_strdup(dev->id); } =20 return object_get_canonical_path(OBJECT(dev)) ?: g_strdup(""); } =20 +/* + * Return the qdev ID, or if no ID is assigned the QOM path, of the block + * device attached to the BlockBackend. + */ +char *blk_get_attached_dev_id(BlockBackend *blk) +{ + return blk_get_attached_dev_id_or_path(blk, true); +} + +static char *blk_get_attached_dev_path(BlockBackend *blk) +{ + return blk_get_attached_dev_id_or_path(blk, false); +} + /* * Return the BlockBackend which has the device model @dev attached if it * exists, else null. @@ -2125,6 +2137,7 @@ static void send_qmp_error_event(BlockBackend *blk, =20 optype =3D is_read ? IO_OPERATION_TYPE_READ : IO_OPERATION_TYPE_WRITE; qapi_event_send_block_io_error(blk_name(blk), + blk_get_attached_dev_path(blk), bs ? bdrv_get_node_name(bs) : NULL, opt= ype, action, blk_iostatus_is_enabled(blk), error =3D=3D ENOSPC, strerror(error)); --=20 2.47.0 From nobody Tue Oct 22 23:39:05 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1729615876; cv=none; d=zohomail.com; s=zohoarc; b=Cd2eX7Py9TuTA05rgktx2WqXJmT4UC470LbntZ6veJ4GNjx8hWXDoOT5jdm/qp9gO95QRfVO5h63IIxxQtK9isPKJgUlXhYhOa47OuiAgvk4ONKoz3rXl3ZutaCcBcyMC9RlBE/R4qBAk6yR2WTJUSjYiOlNbqwxmU3KdvOpQhM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729615876; h=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=coP4cMorzzuJPcHDWFKzvM8HkyCGleUbY6fulomVjoI=; b=YhNKreEPj+/nPvxXFOP96fIxtgNreHfXSpP0PVywjNfvFQKWGbEq3k9xSmej/C8kePnJyF9pFDBvjOFffix1CXuVAS6G3osHGZdfx6cFGAOOXKPG55nGW93zlzg9RH7Fq1ER1QrWQkykyKqdPv9IB6LzbZyR9ep0FmZqnoBZRg8= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1729615876494223.5969988576718; Tue, 22 Oct 2024 09:51:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3I4k-0000aX-Lp; Tue, 22 Oct 2024 12:49:42 -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 1t3I4f-0000VP-Kr for qemu-devel@nongnu.org; Tue, 22 Oct 2024 12:49:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3I4e-00068h-3G for qemu-devel@nongnu.org; Tue, 22 Oct 2024 12:49:37 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-t70UviaAO6eUjgRy_pLZnA-1; Tue, 22 Oct 2024 12:49:34 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5038A1955F57; Tue, 22 Oct 2024 16:49:33 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.70]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2DBA11955EA3; Tue, 22 Oct 2024 16:49:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729615775; h=from:from:reply-to:subject:subject: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=coP4cMorzzuJPcHDWFKzvM8HkyCGleUbY6fulomVjoI=; b=eepO61JYahkoC75BgQ226K6FN3GPg7IT6d09nm5ChTrFOh3634/t5yPU2pZ0+814iUDAMm MQGeov5ti3K/hgSJU5NwdbzwI878G8/vIINKE+G0bYT7zKOd/fYNZwr/2PK/V1ghP0UWt9 DkoVTeDBWpeDwP/LqmXt02bGZwmADIY= X-MC-Unique: t70UviaAO6eUjgRy_pLZnA-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 8/9] block-backend: per-device throttling of BLOCK_IO_ERROR reports Date: Tue, 22 Oct 2024 18:49:02 +0200 Message-ID: <20241022164903.282174-9-kwolf@redhat.com> In-Reply-To: <20241022164903.282174-1-kwolf@redhat.com> References: <20241022164903.282174-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.519, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1.697, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729615877582116600 Content-Type: text/plain; charset="utf-8" From: Leonid Kaplan BLOCK_IO_ERROR events comes from guest, so we must throttle them. We still want per-device throttling, so let's use device id as a key. Signed-off-by: Leonid Kaplan Signed-off-by: Vladimir Sementsov-Ogievskiy Message-ID: <20241002151806.592469-3-vsementsov@yandex-team.ru> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- qapi/block-core.json | 2 ++ monitor/monitor.c | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index fe63ba6cbf..fd3bcc1c17 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -5611,6 +5611,8 @@ # .. note:: If action is "stop", a STOP event will eventually follow # the BLOCK_IO_ERROR event. # +# .. note:: This event is rate-limited. +# # Since: 0.13 # # .. qmp-example:: diff --git a/monitor/monitor.c b/monitor/monitor.c index db52a9c7ef..56786c0ccc 100644 --- a/monitor/monitor.c +++ b/monitor/monitor.c @@ -308,6 +308,7 @@ int error_printf_unless_qmp(const char *fmt, ...) static MonitorQAPIEventConf monitor_qapi_event_conf[QAPI_EVENT__MAX] =3D { /* Limit guest-triggerable events to 1 per second */ [QAPI_EVENT_RTC_CHANGE] =3D { 1000 * SCALE_MS }, + [QAPI_EVENT_BLOCK_IO_ERROR] =3D { 1000 * SCALE_MS }, [QAPI_EVENT_WATCHDOG] =3D { 1000 * SCALE_MS }, [QAPI_EVENT_BALLOON_CHANGE] =3D { 1000 * SCALE_MS }, [QAPI_EVENT_QUORUM_REPORT_BAD] =3D { 1000 * SCALE_MS }, @@ -493,7 +494,8 @@ static unsigned int qapi_event_throttle_hash(const void= *key) hash +=3D g_str_hash(qdict_get_str(evstate->data, "node-name")); } =20 - if (evstate->event =3D=3D QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE) { + if (evstate->event =3D=3D QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE || + evstate->event =3D=3D QAPI_EVENT_BLOCK_IO_ERROR) { hash +=3D g_str_hash(qdict_get_str(evstate->data, "qom-path")); } =20 @@ -519,7 +521,8 @@ static gboolean qapi_event_throttle_equal(const void *a= , const void *b) qdict_get_str(evb->data, "node-name")); } =20 - if (eva->event =3D=3D QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE) { + if (eva->event =3D=3D QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE || + eva->event =3D=3D QAPI_EVENT_BLOCK_IO_ERROR) { return !strcmp(qdict_get_str(eva->data, "qom-path"), qdict_get_str(evb->data, "qom-path")); } --=20 2.47.0 From nobody Tue Oct 22 23:39:05 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1729615824; cv=none; d=zohomail.com; s=zohoarc; b=AF5EqdGDt7IN6nyvoybarjGc/ibuJHxgpArjo0CCJDgEeTNyWK/bOadLGxCvQqakE9XOsImLKvDisQKoNLK4Uru1f6eqzLrnwM3fqFMr6Y15VmjpeGLA5l7F1hotj/kD7A1qMzPttJAJpWyaFFt34PZanWByHyp51+uV0B0+pYY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729615824; 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=gBA4X86K7vUY/KWF2IhMYfGN+XFtUzGOJg9HFppn5eo=; b=dkFhLsINWj05vsmJpUJLgLvO2DOWQ1ZoPd9h+IiWPvzn7BeFjxmXFWJH92wxusqwNO78AF+rVxe/TMn0IdfMLvUIYV5whoKFMKkP2aWfLPCO+jCjdH4dNgw/DTUQQ46VBsINlTz1pHTZAG2IP3DMiPM1e/Uzs9XCdR3fSOEk9B4= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1729615824300459.43887546890664; Tue, 22 Oct 2024 09:50:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3I4l-0000bt-7C; Tue, 22 Oct 2024 12:49:43 -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 1t3I4j-0000a1-CI for qemu-devel@nongnu.org; Tue, 22 Oct 2024 12:49:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3I4h-00069z-RC for qemu-devel@nongnu.org; Tue, 22 Oct 2024 12:49:40 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-577-f8T9LYDGMqOMSt0i1JB9cw-1; Tue, 22 Oct 2024 12:49:35 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D980C1955EE6; Tue, 22 Oct 2024 16:49:34 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.70]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B851F1956056; Tue, 22 Oct 2024 16:49:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729615779; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gBA4X86K7vUY/KWF2IhMYfGN+XFtUzGOJg9HFppn5eo=; b=EOO0GS/8oP6QxN1Y3gQEKIPYNp56HtMGc3x6ouP5CC0a8msYXQx1g0DRVn+xNTV3zNXt5W LHliwa9EyoMU4+Ts/0u8oTUo/wkJfmpWTZJxqo3Ldy6wo1WBWeySyzHTVGRZGmPpuVSEoR H/mN4HMh7g0tffT5REssI+HKBlySmJ0= X-MC-Unique: f8T9LYDGMqOMSt0i1JB9cw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 9/9] raw-format: Fix error message for invalid offset/size Date: Tue, 22 Oct 2024 18:49:03 +0200 Message-ID: <20241022164903.282174-10-kwolf@redhat.com> In-Reply-To: <20241022164903.282174-1-kwolf@redhat.com> References: <20241022164903.282174-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.519, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1.697, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729615825384116600 s->offset and s->size are only set at the end of the function and still contain the old values when formatting the error message. Print the parameters with the new values that we actually checked instead. Fixes: 500e2434207d ('raw-format: Split raw_read_options()') Signed-off-by: Kevin Wolf Message-ID: <20240829185527.47152-1-kwolf@redhat.com> Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Hanna Czenczek Signed-off-by: Kevin Wolf --- block/raw-format.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/raw-format.c b/block/raw-format.c index ac7e8495f6..e08526e2ec 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -111,7 +111,7 @@ raw_apply_options(BlockDriverState *bs, BDRVRawState *s= , uint64_t offset, if (offset > real_size) { error_setg(errp, "Offset (%" PRIu64 ") cannot be greater than " "size of the containing file (%" PRId64 ")", - s->offset, real_size); + offset, real_size); return -EINVAL; } =20 @@ -119,7 +119,7 @@ raw_apply_options(BlockDriverState *bs, BDRVRawState *s= , uint64_t offset, error_setg(errp, "The sum of offset (%" PRIu64 ") and size " "(%" PRIu64 ") has to be smaller or equal to the " " actual size of the containing file (%" PRId64 ")", - s->offset, s->size, real_size); + offset, size, real_size); return -EINVAL; } =20 --=20 2.47.0