From nobody Wed Nov 27 02:24:22 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=1701180646; cv=none; d=zohomail.com; s=zohoarc; b=gX6YUWYbWiLvJpvJ8caqmZVXC9zHaVWvv+JneGJAqcj9TnVMfhp5DtvM/u0/Kpqx25MuU4X+4gagvfJMSzaTa5a+eQOImAny7B2pKN9aeNPOelux/KXBtFq4IYYh7dWcL+YnBkTYvk/9NTHhuJ/IsReCxc73XlY20VWcDWAY8Zc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701180646; 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=75VZKF3VpSA8jjuqtW2b0qAzr8b2di4P7awJi1iKmHk=; b=h5c3e0AVtE2qKCcirdq4xaZ4/9EZaG0dLZ2IPBdh8e7A+AsdU3RHcoj+I9hF5hgG6ZSMGleM+m7aH00hCSZWHV6YLeKXrOfPzFV/JGGoqzDI0OiFU2mY8gssxwCYIARut7tSvwDlMAl8xmr7JASNGktvWvYlarbm1FzvGv1wXlQ= 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 1701180646385782.9813258297089; Tue, 28 Nov 2023 06:10:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r7ymT-0002KT-8V; Tue, 28 Nov 2023 09:09:41 -0500 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 1r7ymP-0002IR-GN for qemu-devel@nongnu.org; Tue, 28 Nov 2023 09:09:37 -0500 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 1r7ymO-0006Tc-2I for qemu-devel@nongnu.org; Tue, 28 Nov 2023 09:09:37 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-245-bK4SgX4xOG2bkaKJYq4Alw-1; Tue, 28 Nov 2023 09:09:32 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id CEE7D811E88; Tue, 28 Nov 2023 14:09:31 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.195.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 212955038; Tue, 28 Nov 2023 14:09:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701180575; 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=75VZKF3VpSA8jjuqtW2b0qAzr8b2di4P7awJi1iKmHk=; b=JVGT3OSSTrFwPEwGTpuJeoEEXhoUPt7mW0uQH7OdFNCqgr/rpiibsKYL3q0w3vyi7CWHpA H0NjuKjekaUDgY+KwDSdQDom3dWJ69F91eKbHiZYWHVPUEPrEt+p0nz5eGTuCCnIsHePyB DwRPHuzPEkzKZPZKteOyDRIV1+yG/Kw= X-MC-Unique: bK4SgX4xOG2bkaKJYq4Alw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 1/4] iotests: fix default machine type detection Date: Tue, 28 Nov 2023 15:09:23 +0100 Message-ID: <20231128140926.106077-2-kwolf@redhat.com> In-Reply-To: <20231128140926.106077-1-kwolf@redhat.com> References: <20231128140926.106077-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1701180647552000003 Content-Type: text/plain; charset="utf-8" From: Andrey Drobyshev The machine type is being detected based on "-M help" output, and we're searching for the line ending with " (default)". However, in downstream one of the machine types s marked as deprecated might become the default, in which case this logic breaks as the line would now end with " (default) (deprecated)". To fix potential issues here, let's relax that requirement and detect the mere presence of " (default)" line instead. Signed-off-by: Andrey Drobyshev Message-ID: <20231122121538.32903-1-andrey.drobyshev@virtuozzo.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- tests/qemu-iotests/testenv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py index e67ebd254b..3ff38f2661 100644 --- a/tests/qemu-iotests/testenv.py +++ b/tests/qemu-iotests/testenv.py @@ -40,7 +40,7 @@ def get_default_machine(qemu_prog: str) -> str: =20 machines =3D outp.split('\n') try: - default_machine =3D next(m for m in machines if m.endswith(' (defa= ult)')) + default_machine =3D next(m for m in machines if ' (default)' in m) except StopIteration: return '' default_machine =3D default_machine.split(' ', 1)[0] --=20 2.43.0 From nobody Wed Nov 27 02:24:22 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=1701180639; cv=none; d=zohomail.com; s=zohoarc; b=NX9ozPk9s6YUZJKsm8vwQ9eJ/RoiDSKG1an2ODzA6zuW2g9UXbpy8JY0GSzvL78p9qg9EG+peGn4Do7dIuGLSlt3tJLNPiV/gTaGP29zYUAuvfOOnFAY8cqADoyxFauvWGraOc/fa3CuIJl9Nm1Pxe5jgCzWQGpgBXsRpxAa1Ow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701180639; 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=y0SLgqUXxE3nfzg7uic379C/SqDnqDo9ankBx/GZ7KI=; b=fFZOZREAr/RFJHgPa20u/F6EEE24rS7A5ccQEKif/L9GE3gmrqrsL1nJL836a3RO1RQXtddMxStx5C4VlhxUeRFq1GcfZl1YkYwQMWB16+dBBU7Vd8nel++W5lwKaY0rCoyIlIoqGKx3iBcusl4cJBSS/PMF+QYeWYo2opwzxQk= 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 1701180639920796.8500430436444; Tue, 28 Nov 2023 06:10:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r7ymZ-0002O6-Vk; Tue, 28 Nov 2023 09:09:48 -0500 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 1r7ymQ-0002JN-Vp for qemu-devel@nongnu.org; Tue, 28 Nov 2023 09:09:40 -0500 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 1r7ymP-0006Tv-37 for qemu-devel@nongnu.org; Tue, 28 Nov 2023 09:09:38 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-616-5rYVZPMhPju11qbdzzdhmw-1; Tue, 28 Nov 2023 09:09:33 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id BB0D33C100AD; Tue, 28 Nov 2023 14:09:32 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.195.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0DEF7502A; Tue, 28 Nov 2023 14:09:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701180576; 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=y0SLgqUXxE3nfzg7uic379C/SqDnqDo9ankBx/GZ7KI=; b=b8ZCimmd6HjGqw2lwTFJNHQr31IBRcvKmbO2cXb7Y4dAGOLSXdlDzL+h30uYpgMOtiHXCt Tp+IFhu+QjK2aXdztkl9kjSBF8YgjTPd3dIiBYlETabsg2CzuuqP9TXwi9St3VIw37xDhN JDGH5MfVLZtXZEDJa5ghpIxQsEet28c= X-MC-Unique: 5rYVZPMhPju11qbdzzdhmw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 2/4] vmdk: Don't corrupt desc file in vmdk_write_cid Date: Tue, 28 Nov 2023 15:09:24 +0100 Message-ID: <20231128140926.106077-3-kwolf@redhat.com> In-Reply-To: <20231128140926.106077-1-kwolf@redhat.com> References: <20231128140926.106077-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, SPF_HELO_NONE=0.001, SPF_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1701180641540000001 Content-Type: text/plain; charset="utf-8" From: Fam Zheng If the text description file is larger than DESC_SIZE, we force the last byte in the buffer to be 0 and write it out. This results in a corruption. Try to allocate a big buffer in this case. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1923 Signed-off-by: Fam Zheng Message-ID: <20231124115654.3239137-1-fam@euphon.net> Reviewed-by: Kevin Wolf Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block/vmdk.c | 28 ++++++++++++++++++++-------- tests/qemu-iotests/059 | 2 ++ tests/qemu-iotests/059.out | 4 ++++ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index d87f6d9aaa..d6971c7067 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -351,29 +351,41 @@ vmdk_write_cid(BlockDriverState *bs, uint32_t cid) BDRVVmdkState *s =3D bs->opaque; int ret =3D 0; =20 - desc =3D g_malloc0(DESC_SIZE); - tmp_desc =3D g_malloc0(DESC_SIZE); - ret =3D bdrv_co_pread(bs->file, s->desc_offset, DESC_SIZE, desc, 0); + size_t desc_buf_size; + + if (s->desc_offset =3D=3D 0) { + desc_buf_size =3D bdrv_getlength(bs->file->bs); + if (desc_buf_size > 16ULL << 20) { + error_report("VMDK description file too big"); + return -EFBIG; + } + } else { + desc_buf_size =3D DESC_SIZE; + } + + desc =3D g_malloc0(desc_buf_size); + tmp_desc =3D g_malloc0(desc_buf_size); + ret =3D bdrv_co_pread(bs->file, s->desc_offset, desc_buf_size, desc, 0= ); if (ret < 0) { goto out; } =20 - desc[DESC_SIZE - 1] =3D '\0'; + desc[desc_buf_size - 1] =3D '\0'; tmp_str =3D strstr(desc, "parentCID"); if (tmp_str =3D=3D NULL) { ret =3D -EINVAL; goto out; } =20 - pstrcpy(tmp_desc, DESC_SIZE, tmp_str); + pstrcpy(tmp_desc, desc_buf_size, tmp_str); p_name =3D strstr(desc, "CID"); if (p_name !=3D NULL) { p_name +=3D sizeof("CID"); - snprintf(p_name, DESC_SIZE - (p_name - desc), "%" PRIx32 "\n", cid= ); - pstrcat(desc, DESC_SIZE, tmp_desc); + snprintf(p_name, desc_buf_size - (p_name - desc), "%" PRIx32 "\n",= cid); + pstrcat(desc, desc_buf_size, tmp_desc); } =20 - ret =3D bdrv_co_pwrite_sync(bs->file, s->desc_offset, DESC_SIZE, desc,= 0); + ret =3D bdrv_co_pwrite_sync(bs->file, s->desc_offset, desc_buf_size, d= esc, 0); =20 out: g_free(desc); diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059 index 2bcb1f7f9c..0634c7bd92 100755 --- a/tests/qemu-iotests/059 +++ b/tests/qemu-iotests/059 @@ -84,6 +84,8 @@ echo echo "=3D=3D=3D Testing big twoGbMaxExtentFlat =3D=3D=3D" _make_test_img -o "subformat=3DtwoGbMaxExtentFlat" 1000G _img_info --format-specific | _filter_img_info --format-specific +$QEMU_IO -c "write 990G 512 -P 89" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "read 990G 512 -P 89" "$TEST_IMG" | _filter_qemu_io _cleanup_test_img =20 echo diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out index 2b83c0c8b6..275ee7c778 100644 --- a/tests/qemu-iotests/059.out +++ b/tests/qemu-iotests/059.out @@ -2032,6 +2032,10 @@ Format specific information: virtual size: 2147483648 filename: TEST_DIR/t-f500.IMGFMT format: FLAT +wrote 512/512 bytes at offset 1063004405760 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 1063004405760 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 =3D=3D=3D Testing malformed VMFS extent description line =3D=3D=3D qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Invalid extent line: RW 1258= 2912 VMFS "dummy.IMGFMT" 1 --=20 2.43.0 From nobody Wed Nov 27 02:24:22 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=1701180669; cv=none; d=zohomail.com; s=zohoarc; b=TpN8JkTieGr3dQagNjAkaHPlQJKJJSC0iSuQTbjM1sP4j2ibawS5WiWawRP+R8QKhGo90SCla5xL2ZveVcOBlrIGAvQUX3FXKdVsHKdqqumQIgQ+VJlnV8y3AApn07bjd67CRIjGQ4lhrkEN5Goi0Q7ZdbN0RFAF/q3BtfMq0NU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701180669; 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=U6xgWI92mvm47z7cP+0hV3lVTV0KhBcC7oLnLh6NowY=; b=DR4d40W8PtXzfInsRIdhamvx9GRAftS5JEWUKqjDSIQDko57YdmpU/YsLeLdw/DAyTBBJS/14aUG6YH+P4XrXfqJJ7esB3c119mmFWu2ieYuXBgLJaEIQu1fVN3cbzSIzVR/va7ONPVyiRYTDdasttdIh+Q/AbxsZpdXX8mPKcs= 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 1701180669536652.8840736041017; Tue, 28 Nov 2023 06:11:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r7ymW-0002Mx-0a; Tue, 28 Nov 2023 09:09:44 -0500 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 1r7ymT-0002KG-3x for qemu-devel@nongnu.org; Tue, 28 Nov 2023 09:09:41 -0500 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 1r7ymR-0006Vs-4X for qemu-devel@nongnu.org; Tue, 28 Nov 2023 09:09:40 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-423-P6OJRBQSPhSEnFD6_btThA-1; Tue, 28 Nov 2023 09:09:33 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id A7A48811E8D; Tue, 28 Nov 2023 14:09:33 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.195.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE62910EA1; Tue, 28 Nov 2023 14:09:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701180578; 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=U6xgWI92mvm47z7cP+0hV3lVTV0KhBcC7oLnLh6NowY=; b=h6YlwiPwuaX0QDJzu78P3b9pbiP25eUMx48RJhulapxCsz4M8H2bnSkVgZ27kCh9ooGiwS zAFQqqLHV/e/wLKGBbhUF1rsvN6X9pkOaq5c11qgyclQm/iT41+0ykMywQPbB2j9Ws0Eu7 8PHtiE93MVPvWWO6dddh+B9zb/m+ORQ= X-MC-Unique: P6OJRBQSPhSEnFD6_btThA-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 3/4] export/vhost-user-blk: Fix consecutive drains Date: Tue, 28 Nov 2023 15:09:25 +0100 Message-ID: <20231128140926.106077-4-kwolf@redhat.com> In-Reply-To: <20231128140926.106077-1-kwolf@redhat.com> References: <20231128140926.106077-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1701180671645000003 Content-Type: text/plain; charset="utf-8" The vhost-user-blk export implement AioContext switches in its drain implementation. This means that on drain_begin, it detaches the server from its AioContext and on drain_end, attaches it again and schedules the server->co_trip coroutine in the updated AioContext. However, nothing guarantees that server->co_trip is even safe to be scheduled. Not only is it unclear that the coroutine is actually in a state where it can be reentered externally without causing problems, but with two consecutive drains, it is possible that the scheduled coroutine didn't have a chance yet to run and trying to schedule an already scheduled coroutine a second time crashes with an assertion failure. Following the model of NBD, this commit makes the vhost-user-blk export shut down server->co_trip during drain so that resuming the export means creating and scheduling a new coroutine, which is always safe. There is one exception: If the drain call didn't poll (for example, this happens in the context of bdrv_graph_wrlock()), then the coroutine didn't have a chance to shut down. However, in this case the AioContext can't have changed; changing the AioContext always involves a polling drain. So in this case we can simply assert that the AioContext is unchanged and just leave the coroutine running or wake it up if it has yielded to wait for the AioContext to be attached again. Fixes: e1054cd4aad03a493a5d1cded7508f7c348205bf Fixes: https://issues.redhat.com/browse/RHEL-1708 Signed-off-by: Kevin Wolf Message-ID: <20231127115755.22846-1-kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- include/qemu/vhost-user-server.h | 1 + block/export/vhost-user-blk-server.c | 9 +++++-- util/vhost-user-server.c | 39 ++++++++++++++++++++++------ 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/include/qemu/vhost-user-server.h b/include/qemu/vhost-user-ser= ver.h index 64ad701015..0417ec0533 100644 --- a/include/qemu/vhost-user-server.h +++ b/include/qemu/vhost-user-server.h @@ -45,6 +45,7 @@ typedef struct { /* Protected by ctx lock */ bool in_qio_channel_yield; bool wait_idle; + bool quiescing; VuDev vu_dev; QIOChannel *ioc; /* The I/O channel with the client */ QIOChannelSocket *sioc; /* The underlying data channel with the client= */ diff --git a/block/export/vhost-user-blk-server.c b/block/export/vhost-user= -blk-server.c index fe2cee3a78..16f48388d3 100644 --- a/block/export/vhost-user-blk-server.c +++ b/block/export/vhost-user-blk-server.c @@ -283,6 +283,7 @@ static void vu_blk_drained_begin(void *opaque) { VuBlkExport *vexp =3D opaque; =20 + vexp->vu_server.quiescing =3D true; vhost_user_server_detach_aio_context(&vexp->vu_server); } =20 @@ -291,19 +292,23 @@ static void vu_blk_drained_end(void *opaque) { VuBlkExport *vexp =3D opaque; =20 + vexp->vu_server.quiescing =3D false; vhost_user_server_attach_aio_context(&vexp->vu_server, vexp->export.ct= x); } =20 /* - * Ensures that bdrv_drained_begin() waits until in-flight requests comple= te. + * Ensures that bdrv_drained_begin() waits until in-flight requests comple= te + * and the server->co_trip coroutine has terminated. It will be restarted = in + * vhost_user_server_attach_aio_context(). * * Called with vexp->export.ctx acquired. */ static bool vu_blk_drained_poll(void *opaque) { VuBlkExport *vexp =3D opaque; + VuServer *server =3D &vexp->vu_server; =20 - return vhost_user_server_has_in_flight(&vexp->vu_server); + return server->co_trip || vhost_user_server_has_in_flight(server); } =20 static const BlockDevOps vu_blk_dev_ops =3D { diff --git a/util/vhost-user-server.c b/util/vhost-user-server.c index 5ccc6d24a0..a9a48fffb8 100644 --- a/util/vhost-user-server.c +++ b/util/vhost-user-server.c @@ -132,8 +132,7 @@ vu_message_read(VuDev *vu_dev, int conn_fd, VhostUserMs= g *vmsg) qio_channel_yield(ioc, G_IO_IN); server->in_qio_channel_yield =3D false; } else { - /* Wait until attached to an AioContext again */ - qemu_coroutine_yield(); + return false; } continue; } else { @@ -201,8 +200,16 @@ static coroutine_fn void vu_client_trip(void *opaque) VuServer *server =3D opaque; VuDev *vu_dev =3D &server->vu_dev; =20 - while (!vu_dev->broken && vu_dispatch(vu_dev)) { - /* Keep running */ + while (!vu_dev->broken) { + if (server->quiescing) { + server->co_trip =3D NULL; + aio_wait_kick(); + return; + } + /* vu_dispatch() returns false if server->ctx went away */ + if (!vu_dispatch(vu_dev) && server->ctx) { + break; + } } =20 if (vhost_user_server_has_in_flight(server)) { @@ -353,8 +360,7 @@ static void vu_accept(QIONetListener *listener, QIOChan= nelSocket *sioc, =20 qio_channel_set_follow_coroutine_ctx(server->ioc, true); =20 - server->co_trip =3D qemu_coroutine_create(vu_client_trip, server); - + /* Attaching the AioContext starts the vu_client_trip coroutine */ aio_context_acquire(server->ctx); vhost_user_server_attach_aio_context(server, server->ctx); aio_context_release(server->ctx); @@ -413,8 +419,25 @@ void vhost_user_server_attach_aio_context(VuServer *se= rver, AioContext *ctx) NULL, NULL, vu_fd_watch); } =20 - assert(!server->in_qio_channel_yield); - aio_co_schedule(ctx, server->co_trip); + if (server->co_trip) { + /* + * The caller didn't fully shut down co_trip (this can happen on + * non-polling drains like in bdrv_graph_wrlock()). This is okay a= s long + * as it no longer tries to shut it down and we're guaranteed to s= till + * be in the same AioContext as before. + * + * co_ctx can still be NULL if we get multiple calls and only just + * scheduled a new coroutine in the else branch. + */ + AioContext *co_ctx =3D qemu_coroutine_get_aio_context(server->co_t= rip); + + assert(!server->quiescing); + assert(!co_ctx || co_ctx =3D=3D ctx); + } else { + server->co_trip =3D qemu_coroutine_create(vu_client_trip, server); + assert(!server->in_qio_channel_yield); + aio_co_schedule(ctx, server->co_trip); + } } =20 /* Called with server->ctx acquired */ --=20 2.43.0 From nobody Wed Nov 27 02:24:22 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=1701180618; cv=none; d=zohomail.com; s=zohoarc; b=PbJN+XSAty2ptPJ+oxJHjIuxMpUUsNXQp3YOpdhYYS76L8OZ3CZC83jhvu5MNTOT2MIAT+pjtoDAMkj64FLsFg7ODoLTJLPi/LUF0MA0usLqMW28mxRZBzGt9QrQj5Hx/488A0heqVqO7KV4biUAjj4TLLqmaNvgM+nCAUuTHZI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701180618; 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=umnPBK3VGu358F8xxkox0fj9KssCnkBOku4pq7Ecm5c=; b=N+ydmmmuRs+blJ5+45JhoJSfmfU2HQULWz7VraWCCQzEKE7E6s+GWZZ3awcg+8IpblqDfIHEZ81hFRTuXAW8dT3RAwM9WxHbyJ4Rn0mVmwtq3Iv6LMAaFxiyGlGV3ON1YSpgWhtDCNhLXycuBXYFfWd1lKbqk42bINuqBi9IB/0= 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 1701180618198135.9293961973152; Tue, 28 Nov 2023 06:10:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r7ymU-0002MG-Ua; Tue, 28 Nov 2023 09:09:43 -0500 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 1r7ymR-0002JO-3j for qemu-devel@nongnu.org; Tue, 28 Nov 2023 09:09:40 -0500 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 1r7ymP-0006U2-Ij for qemu-devel@nongnu.org; Tue, 28 Nov 2023 09:09:38 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-503-xClDPnsiP32GbcxDyIOmLA-1; Tue, 28 Nov 2023 09:09:35 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9B64B8678B1; Tue, 28 Nov 2023 14:09:34 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.195.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD0E3502A; Tue, 28 Nov 2023 14:09:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701180576; 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=umnPBK3VGu358F8xxkox0fj9KssCnkBOku4pq7Ecm5c=; b=GCNJolN+xxykwHUyyHOM7JcHYQbXeDfb9io+QN+8xiUsK21Ojz7a0GH0r4AYsinPPf6TPb GTG4j1ADUxE/uBdiGGgEdk6DyRpDx0oCuc2RGywFHmq06TmfoHZ0yOZ4Q/zc208tVcf9Ww paUgxm/pgE7kr/smDJiML/43pJg6CY0= X-MC-Unique: xClDPnsiP32GbcxDyIOmLA-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 4/4] ide/via: Fix BAR4 value in legacy mode Date: Tue, 28 Nov 2023 15:09:26 +0100 Message-ID: <20231128140926.106077-5-kwolf@redhat.com> In-Reply-To: <20231128140926.106077-1-kwolf@redhat.com> References: <20231128140926.106077-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1701180619484000003 Content-Type: text/plain; charset="utf-8" From: BALATON Zoltan Return default value in legacy mode for BAR4 when unset. This can't be set in reset method because BARs are cleared on reset so we return it instead when BARs are read in legacy mode. This fixes UDMA on amigaone with AmigaOS. Signed-off-by: BALATON Zoltan Message-ID: <20231125140135.AF6A075A4C3@zero.eik.bme.hu> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- hw/ide/via.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/hw/ide/via.c b/hw/ide/via.c index 2d3124ebd7..3f3c484253 100644 --- a/hw/ide/via.c +++ b/hw/ide/via.c @@ -163,14 +163,19 @@ static uint32_t via_ide_cfg_read(PCIDevice *pd, uint3= 2_t addr, int len) uint32_t val =3D pci_default_read_config(pd, addr, len); uint8_t mode =3D pd->config[PCI_CLASS_PROG]; =20 - if ((mode & 0xf) =3D=3D 0xa && ranges_overlap(addr, len, - PCI_BASE_ADDRESS_0, 16)) { - /* BARs always read back zero in legacy mode */ - for (int i =3D addr; i < addr + len; i++) { - if (i >=3D PCI_BASE_ADDRESS_0 && i < PCI_BASE_ADDRESS_0 + 16) { - val &=3D ~(0xffULL << ((i - addr) << 3)); + if ((mode & 0xf) =3D=3D 0xa) { + if (ranges_overlap(addr, len, PCI_BASE_ADDRESS_0, 16)) { + /* BARs 0-3 always read back zero in legacy mode */ + for (int i =3D addr; i < addr + len; i++) { + if (i >=3D PCI_BASE_ADDRESS_0 && i < PCI_BASE_ADDRESS_0 + = 16) { + val &=3D ~(0xffULL << ((i - addr) << 3)); + } } } + if (addr =3D=3D PCI_BASE_ADDRESS_4 && val =3D=3D PCI_BASE_ADDRESS_= SPACE_IO) { + /* BAR4 default value if unset */ + val =3D 0xcc00 | PCI_BASE_ADDRESS_SPACE_IO; + } } =20 return val; --=20 2.43.0