From nobody Sun Feb 8 13:17:03 2026 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=1614963734; cv=none; d=zohomail.com; s=zohoarc; b=lL8Ed1/lvTY1hGANtScMjaZhTx3Q1uOwPo6YTwq+1u/9rqDrv4L6LGYTNH+BBPCbul5wSdIK4+j3b3E2dVhgLsaJdIEEDhrcnuE+S3YC8Nt0LngWIzyx6Rg+O//jtsR5Kt2V3gR4j92aqqOyp+3/xgrG6vhx5w/mNQ756ld61vU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614963734; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KTUNf04tOzpcWpXc4wf9J05gsm72Ok+ofJxI7k/ZDsk=; b=Y6qOTOlxaAZKx/WlPpO9erUS9x2Ic1vV0+mJGUB3N8cfhdbUWo8hwCy2JkjN49tWLUgjeoa+kQvKd/czS7udCRsSQb4FezNAKGWrAlodKeZ4JMefnUrzgmHcj2JU+KBu655r8DT6USmahSt20+U8ewozEa3bXGW993bsvBseIfw= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614963734338645.7018153234927; Fri, 5 Mar 2021 09:02:14 -0800 (PST) Received: from localhost ([::1]:52864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIDq9-00047v-6E for importer@patchew.org; Fri, 05 Mar 2021 12:02:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkB-0006rn-P1 for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37961) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDjz-0007Ad-Kk for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:03 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-159-GbtkGA1kMwiW_iHUEuxKmA-1; Fri, 05 Mar 2021 11:55:43 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 938C210AE80C; Fri, 5 Mar 2021 16:55:08 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84E4D60BF3; Fri, 5 Mar 2021 16:55:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963350; 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=KTUNf04tOzpcWpXc4wf9J05gsm72Ok+ofJxI7k/ZDsk=; b=QnXoepn5ENF8etjwiETnNfHKJzAtC9WWc+BDwoGUt6sdGEpCIbQKW0E4vXXw67eV6/x20w gV0JQrtnhuHAba9GlwW1PyZs+V8RNvtwfgk7QksS0KikBidAJP7K9FSBtfYgYYJFzhsywn IlWlfz8p4ZIAAQ/egAFJOiz+6L87Ur4= X-MC-Unique: GbtkGA1kMwiW_iHUEuxKmA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 01/31] iotests: Drop deprecated 'props' from object-add Date: Fri, 5 Mar 2021 17:54:24 +0100 Message-Id: <20210305165454.356840-2-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Alberto Garcia Signed-off-by: Alberto Garcia Message-Id: <20210222115737.2993-1-berto@igalia.com> Signed-off-by: Kevin Wolf --- tests/qemu-iotests/087 | 8 ++------ tests/qemu-iotests/184 | 18 ++++++------------ tests/qemu-iotests/218 | 2 +- tests/qemu-iotests/235 | 2 +- tests/qemu-iotests/245 | 4 ++-- tests/qemu-iotests/258 | 6 +++--- tests/qemu-iotests/258.out | 4 ++-- tests/qemu-iotests/295 | 2 +- tests/qemu-iotests/296 | 2 +- 9 files changed, 19 insertions(+), 29 deletions(-) diff --git a/tests/qemu-iotests/087 b/tests/qemu-iotests/087 index edd43f1a28..d8e0e384cd 100755 --- a/tests/qemu-iotests/087 +++ b/tests/qemu-iotests/087 @@ -143,9 +143,7 @@ run_qemu < (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614963923537376.20547150659036; Fri, 5 Mar 2021 09:05:23 -0800 (PST) Received: from localhost ([::1]:35676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIDtC-0000Dj-9k for importer@patchew.org; Fri, 05 Mar 2021 12:05:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:32836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkJ-0006x5-DF for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:54315) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDk5-0007D4-D5 for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:11 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-26-xdhXLvHRMQqUuf4vtqXwVg-1; Fri, 05 Mar 2021 11:55:52 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EF87F100A44A; Fri, 5 Mar 2021 16:55:09 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id E36D960BF3; Fri, 5 Mar 2021 16:55:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963356; 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=u8cF/Y9bJGN1pFXWJcC+07N6YgIYnq/uce0/xddGQWY=; b=b7iV/BP25K0YDpksq0ZLn2rsMWsceyxwYr440S6KqHnYHNXpJ7gKOTBoQZkxoRuYYberKL 729DE/jQx9jVA08HhqJlfJibs0syKBIqPvQJprlFqzaZykwf5UH3aYReMh9V+j2Ty9BmuZ kIPLC4MQXicQj4G0gzjF7vmZuBJAUn0= X-MC-Unique: xdhXLvHRMQqUuf4vtqXwVg-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 02/31] backup: Remove nodes from job in .clean() Date: Fri, 5 Mar 2021 17:54:25 +0100 Message-Id: <20210305165454.356840-3-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz The block job holds a reference to the backup-top node (because it is passed as the main job BDS to block_job_create()). Therefore, bdrv_backup_top_drop() cannot delete the backup-top node (replacing it by its child does not affect the job parent, because that has .stay_at_node set). That is a problem, because all of its I/O functions assume the BlockCopyState (s->bcs) to be valid and that it has a filtered child; but after bdrv_backup_top_drop(), neither of those things are true. It does not make sense to add new parents to backup-top after backup_clean(), so we should detach it from the job before bdrv_backup_top_drop(). Because there is no function to do that for a single node, just detach all of the job's nodes -- the job does not do anything past backup_clean() anyway. Signed-off-by: Max Reitz Message-Id: <20210219153348.41861-2-mreitz@redhat.com> Signed-off-by: Kevin Wolf --- block/backup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/backup.c b/block/backup.c index 94e6dcd72e..6cf2f974aa 100644 --- a/block/backup.c +++ b/block/backup.c @@ -103,6 +103,7 @@ static void backup_abort(Job *job) static void backup_clean(Job *job) { BackupBlockJob *s =3D container_of(job, BackupBlockJob, common.job); + block_job_remove_all_bdrv(&s->common); bdrv_backup_top_drop(s->backup_top); } =20 --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614964671; cv=none; d=zohomail.com; s=zohoarc; b=PyK4rUGlAOG8OJbK/dwwLtkK90o1FOo2SndQEKgZzV1BYQccqUJx4LUr+Yx/RlF856uh5HzhzO+EhybHYl6W1isbfi7D+dPilBwvMtc5VeytN1MulN9J+X97FXMouccKYVr3nQOjRUsUUCMOuR1GVoDi1o8Jj4zF4sIJXwP7Nf4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614964671; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3Z2AuwW/9GaMnMEUouEm1irTTlYSgTpDzabvvMAMFtI=; b=Cd71i84S9UyNJqEOKP5+AX1zK7IiBSPhSYIAipnlhFJZ4D1oxzMxjnUICSsmabIml+w0IGi85DBABL4mobjvQvQcTziHSarO+xyfrFV28n07fjY2QXtfCHwTDMx6oMpj0GsALzYdWsdC0KIk3A5Aao2Y/2TNYSNXDHHcszRTbDA= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614964671886494.5515945852486; Fri, 5 Mar 2021 09:17:51 -0800 (PST) Received: from localhost ([::1]:42326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIE5G-00076X-ME for importer@patchew.org; Fri, 05 Mar 2021 12:17:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkT-0007Bt-Eu for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:36474) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDkB-0007Du-3z for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:21 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-212-nSDxR5OTNJitZN52Rs1f5A-1; Fri, 05 Mar 2021 11:55:55 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 59DCE18BEF9F; Fri, 5 Mar 2021 16:55:11 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C32B60BF3; Fri, 5 Mar 2021 16:55:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963357; 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=3Z2AuwW/9GaMnMEUouEm1irTTlYSgTpDzabvvMAMFtI=; b=HNk9dnn4Nt332sl+YdEdx88PXwUxM5CpVVhAzdpB527Mlb2+ksjjWbk5sBHXoqcN4fe0z9 UDvZXXWbe0oDZepuymCvpKBnoNOIsqspPUEZtvMFp0Ntq5tyiUxaVRZT1imq1ftsYEJsMe 8ayjl+niQ+WcDmoGDVd58S67I7boOTk= X-MC-Unique: nSDxR5OTNJitZN52Rs1f5A-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 03/31] backup-top: Refuse I/O in inactive state Date: Fri, 5 Mar 2021 17:54:26 +0100 Message-Id: <20210305165454.356840-4-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz When the backup-top node transitions from active to inactive in bdrv_backup_top_drop(), the BlockCopyState is freed and the filtered child is removed, so the node effectively becomes unusable. However, noone told its I/O functions this, so they will happily continue accessing bs->backing and s->bcs. Prevent that by aborting early when s->active is false. (After the preceding patch, the node should be gone after bdrv_backup_top_drop(), so this should largely be a theoretical problem. But still, better to be safe than sorry, and also I think it just makes sense to check s->active in the I/O functions.) Signed-off-by: Max Reitz Message-Id: <20210219153348.41861-3-mreitz@redhat.com> Signed-off-by: Kevin Wolf --- block/backup-top.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/block/backup-top.c b/block/backup-top.c index d1253e1aa6..589e8b651d 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -45,6 +45,12 @@ static coroutine_fn int backup_top_co_preadv( BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { + BDRVBackupTopState *s =3D bs->opaque; + + if (!s->active) { + return -EIO; + } + return bdrv_co_preadv(bs->backing, offset, bytes, qiov, flags); } =20 @@ -54,6 +60,10 @@ static coroutine_fn int backup_top_cbw(BlockDriverState = *bs, uint64_t offset, BDRVBackupTopState *s =3D bs->opaque; uint64_t off, end; =20 + if (!s->active) { + return -EIO; + } + if (flags & BDRV_REQ_WRITE_UNCHANGED) { return 0; } --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614965808; cv=none; d=zohomail.com; s=zohoarc; b=NdScm2nwX38zdg8f6pMXL74AKMOiK0uMn6khE+fHOZ/D/rLoecfQ2akPEKw+CDn2hGRSlLeWm8+96n3WSHkA6nELZklC/B5aEqB7AIRuUNefVb+H/U36VX5HC7av6ehvvyuBYyZR1tj4Aw+RxjExoTyTS0JFW6i/DJu5qu154wU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614965808; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oF8YlkSDTqj1j0zSuv57lYD7kD5PI2sTe4nITEofa84=; b=nGmCmr8FkO12xF/hSRh5E1rzUWdMPooRL/bMZ8hJiCA8mXxginfvwQY8oLWi6p8KczfhphDdfzu2aGIAUG/DixrT1q6tAsCuMLSzSRrt1sPh8FiVLHNOc0+Omy1MOuY0T5JqOTAtwivZ2XqHlLyM3tZSENpn/RtKkJ3d+Iw2GqQ= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614965808980216.698668824224; Fri, 5 Mar 2021 09:36:48 -0800 (PST) Received: from localhost ([::1]:38606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIENb-0005M0-Ue for importer@patchew.org; Fri, 05 Mar 2021 12:36:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkV-0007Id-QD for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40586) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDkB-0007FX-9R for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:23 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-435-2FXFEIiSMZKtXe_w2ZRfWg-1; Fri, 05 Mar 2021 11:55:55 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B942A8018B3; Fri, 5 Mar 2021 16:55:12 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA2ED60C43; Fri, 5 Mar 2021 16:55:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963359; 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=oF8YlkSDTqj1j0zSuv57lYD7kD5PI2sTe4nITEofa84=; b=U/a/Y5qYS0fYKe9VJufaRTb1LWPtf7MUYR64Q3hDUesO9RKwAb5ZAlsvBwHznpef9PZu7h e8to6XlOoKyO4yQDmyPHgq1Dk3r72vdRABCjqE8VA0eg7ZKrZCZ0KdCezOyQbTAg+MmUca Cq2kzqXa+hTSZ5bZL2v0ENtleacS4w8= X-MC-Unique: 2FXFEIiSMZKtXe_w2ZRfWg-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 04/31] iotests/283: Check that finalize drops backup-top Date: Fri, 5 Mar 2021 17:54:27 +0100 Message-Id: <20210305165454.356840-5-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Without any of HEAD^ or HEAD^^ applied, qemu will most likely crash on the qemu-io invocation, for a variety of immediate reasons. The underlying problem is generally a use-after-free access into backup-top's BlockCopyState. With only HEAD^ applied, qemu-io will run into an EIO (which is not capture by the output, but you can see that the qemu-io invocation will be accepted (i.e., qemu-io will run) in contrast to the reference output, where the node name cannot be found), and qemu will then crash in query-named-block-nodes: bdrv_get_allocated_file_size() detects backup-top to be a filter and passes the request through to its child. However, after bdrv_backup_top_drop(), that child is NULL, so the recursive call crashes. With HEAD^^ applied, this test should pass. Signed-off-by: Max Reitz Message-Id: <20210219153348.41861-4-mreitz@redhat.com> Signed-off-by: Kevin Wolf --- tests/qemu-iotests/283 | 53 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/283.out | 15 +++++++++++ 2 files changed, 68 insertions(+) diff --git a/tests/qemu-iotests/283 b/tests/qemu-iotests/283 index 79643e375b..010c22f0a2 100755 --- a/tests/qemu-iotests/283 +++ b/tests/qemu-iotests/283 @@ -97,3 +97,56 @@ vm.qmp_log('blockdev-add', **{ vm.qmp_log('blockdev-backup', sync=3D'full', device=3D'source', target=3D'= target') =20 vm.shutdown() + + +print('\n=3D=3D=3D backup-top should be gone after job-finalize =3D=3D=3D\= n') + +# Check that the backup-top node is gone after job-finalize. +# +# During finalization, the node becomes inactive and can no longer +# function. If it is still present, new parents might be attached, and +# there would be no meaningful way to handle their I/O requests. + +vm =3D iotests.VM() +vm.launch() + +vm.qmp_log('blockdev-add', **{ + 'node-name': 'source', + 'driver': 'null-co', +}) + +vm.qmp_log('blockdev-add', **{ + 'node-name': 'target', + 'driver': 'null-co', +}) + +vm.qmp_log('blockdev-backup', + job_id=3D'backup', + device=3D'source', + target=3D'target', + sync=3D'full', + filter_node_name=3D'backup-filter', + auto_finalize=3DFalse, + auto_dismiss=3DFalse) + +vm.event_wait('BLOCK_JOB_PENDING', 5.0) + +# The backup-top filter should still be present prior to finalization +assert vm.node_info('backup-filter') is not None + +vm.qmp_log('job-finalize', id=3D'backup') +vm.event_wait('BLOCK_JOB_COMPLETED', 5.0) + +# The filter should be gone now. Check that by trying to access it +# with qemu-io (which will most likely crash qemu if it is still +# there.). +vm.qmp_log('human-monitor-command', + command_line=3D'qemu-io backup-filter "write 0 1M"') + +# (Also, do an explicit check.) +assert vm.node_info('backup-filter') is None + +vm.qmp_log('job-dismiss', id=3D'backup') +vm.event_wait('JOB_STATUS_CHANGE', 5.0, {'data': {'status': 'null'}}) + +vm.shutdown() diff --git a/tests/qemu-iotests/283.out b/tests/qemu-iotests/283.out index d8cff22cc1..7e9cd9a7d4 100644 --- a/tests/qemu-iotests/283.out +++ b/tests/qemu-iotests/283.out @@ -6,3 +6,18 @@ {"return": {}} {"execute": "blockdev-backup", "arguments": {"device": "source", "sync": "= full", "target": "target"}} {"error": {"class": "GenericError", "desc": "Cannot set permissions for ba= ckup-top filter: Conflicts with use by other as 'image', which uses 'write'= on base"}} + +=3D=3D=3D backup-top should be gone after job-finalize =3D=3D=3D + +{"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name"= : "source"}} +{"return": {}} +{"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name"= : "target"}} +{"return": {}} +{"execute": "blockdev-backup", "arguments": {"auto-dismiss": false, "auto-= finalize": false, "device": "source", "filter-node-name": "backup-filter", = "job-id": "backup", "sync": "full", "target": "target"}} +{"return": {}} +{"execute": "job-finalize", "arguments": {"id": "backup"}} +{"return": {}} +{"execute": "human-monitor-command", "arguments": {"command-line": "qemu-i= o backup-filter \"write 0 1M\""}} +{"return": "Error: Cannot find device=3D nor node_name=3Dbackup-filter\r\n= "} +{"execute": "job-dismiss", "arguments": {"id": "backup"}} +{"return": {}} --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614964385; cv=none; d=zohomail.com; s=zohoarc; b=H/UpVrb1Ef7Ik+njPDeIqH47UHZPbyZRlP5tDWp/Qd8DgJCFK+7GvM+akQ/f3GDVqqqLENSXLK/5XSdi2iaCUoAo9Il7rNuHHo2B1tmfYqH1pBOCVX1CKR4mNQeY2++Z/6qt3Z/tEA4UgW9jeDQ378vwAiD5uW5TsxR+yI5YmH8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614964385; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VF98KSzLbmqEjHnWVEXHrpPBNZqP8dKQmGu7jqXOY2M=; b=m4jlK4YQrI0NjxIOEh1am3IizIpE7ImNG9EFM4JZke2eb2UwUi29dkNzfM2LHpRwRNcfxKPZQV3YrG6kncfmESywz/7ZM8Ms346ec9VhfGJWJgo5JcyC76mAFZ3U+0ZVOSD6RvegPw7clU+Z0aXnk+Wj37jcwAdO/Nc0roBDG/c= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614964385134766.5269884834062; Fri, 5 Mar 2021 09:13:05 -0800 (PST) Received: from localhost ([::1]:35314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIE0d-0003mc-Ps for importer@patchew.org; Fri, 05 Mar 2021 12:13:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:32786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkH-0006tZ-1r for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:38739) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDk5-0007CX-3n for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:08 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-254-qVaeBIEmM_qt5ViBwg5HDQ-1; Fri, 05 Mar 2021 11:55:52 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 23C24100A44D; Fri, 5 Mar 2021 16:55:14 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 143A960BF3; Fri, 5 Mar 2021 16:55:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963356; 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=VF98KSzLbmqEjHnWVEXHrpPBNZqP8dKQmGu7jqXOY2M=; b=FfinuYpN8n54oV/tAOrdlMR9U8I3tv05u5n+xgift8jtRx0yE9tOGj+iCe4yenAm2cXeMD YSmnhYwV3puu4XDNr3mXiM303WZWGD4vvvcxaB6QMJx/TwHoa73TzimRytPX2r2eGCunjc Jepys13DVY8ZThUUJ6rIzQIWSquUmKg= X-MC-Unique: qVaeBIEmM_qt5ViBwg5HDQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 05/31] iotests: Fix up python style in 300 Date: Fri, 5 Mar 2021 17:54:28 +0100 Message-Id: <20210305165454.356840-6-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Eric Blake Break some long lines, and relax our type hints to be more generic to any JSON, in order to more easily permit the additional JSON depth now possible in migration parameters. Detected by iotest 297. Fixes: ca4bfec41d56 (qemu-iotests: 300: Add test case for modifying persistence of bitmap) Reported-by: Kevin Wolf Signed-off-by: Eric Blake Message-Id: <20210215220518.1745469-1-eblake@redhat.com> Reviewed-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Kevin Wolf --- tests/qemu-iotests/300 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/qemu-iotests/300 b/tests/qemu-iotests/300 index 63036f6a6e..adb9276297 100755 --- a/tests/qemu-iotests/300 +++ b/tests/qemu-iotests/300 @@ -22,7 +22,7 @@ import os import random import re -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional =20 import iotests =20 @@ -30,7 +30,7 @@ import iotests # pylint: disable=3Dwrong-import-order import qemu =20 -BlockBitmapMapping =3D List[Dict[str, Union[str, List[Dict[str, str]]]]] +BlockBitmapMapping =3D List[Dict[str, object]] =20 mig_sock =3D os.path.join(iotests.sock_dir, 'mig_sock') =20 @@ -602,7 +602,8 @@ class TestCrossAliasMigration(TestDirtyBitmapMigration): =20 class TestAliasTransformMigration(TestDirtyBitmapMigration): """ - Tests the 'transform' option which modifies bitmap persistence on migr= ation. + Tests the 'transform' option which modifies bitmap persistence on + migration. """ =20 src_node_name =3D 'node-a' @@ -674,7 +675,8 @@ class TestAliasTransformMigration(TestDirtyBitmapMigrat= ion): bitmaps =3D self.vm_b.query_bitmaps() =20 for node in bitmaps: - bitmaps[node] =3D sorted(((bmap['name'], bmap['persistent']) f= or bmap in bitmaps[node])) + bitmaps[node] =3D sorted(((bmap['name'], bmap['persistent']) + for bmap in bitmaps[node])) =20 self.assertEqual(bitmaps, {'node-a': [('bmap-a', True), ('bmap-b', False)], --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614963521; cv=none; d=zohomail.com; s=zohoarc; b=Fyko8VEjyhVGI/gCde9soIXuz8zquJOzPlVMY0lReu9CHsY7DNwLvDZJYsPjB72DvUpuqYN/dOL471IL0Stn2zPNxAHFgzq6JYFA5RZND1mjWq7KdgRox5+6qE6MQYvDrWC9SOXcuhP/cxudjNEHeNE5klIrFBonL+UGknrOCCc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614963521; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=I+24Wp5v0/ql1DcefmbkDRn1VATYhE49R2ywNT9QU2c=; b=DtXlP41mkjnYLERDM26ucK2Ls1SAsjWOhxc/wE5v+cSGNRUhEBBssBSG9tbl4aPHh9KrtIHgBM5OuqSQCOdl++NxEaQ0+OQ5MtmqykNJRLaB3v4nmROpheccDOVG/a8TQJrmnMkf6Y0d5JUqCDxCWnXX3EnCKJ0N1yGq3hyigR0= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614963521647453.4458927179445; Fri, 5 Mar 2021 08:58:41 -0800 (PST) Received: from localhost ([::1]:44666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIDmi-0000SF-Ip for importer@patchew.org; Fri, 05 Mar 2021 11:58:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDk3-0006oL-Ki for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:55:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:40037) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDjx-00078g-D0 for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:55:55 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-258-Dncz_u7jMd6q7oiv4f28dw-1; Fri, 05 Mar 2021 11:55:44 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7D5111005584; Fri, 5 Mar 2021 16:55:15 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 714AE60BF3; Fri, 5 Mar 2021 16:55:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963346; 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=I+24Wp5v0/ql1DcefmbkDRn1VATYhE49R2ywNT9QU2c=; b=bzoRx6/Xixz4Hqwuzuo60IVLuypQgkCrL54Up7Ff8k6Q6GV1dp9LS8E91/NJdbl2N3blpl CTmuoPIvgt+i4puUl652oFF0QLf6RrBNjklTHyAEbOeggwMof9ioUeUaTVRUUnBGYzhAJF n3GAPaUCRBf2zVva4VI6vTaLkgigtY0= X-MC-Unique: Dncz_u7jMd6q7oiv4f28dw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 06/31] blockjob: report a better error message Date: Fri, 5 Mar 2021 17:54:29 +0100 Message-Id: <20210305165454.356840-7-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Stefano Garzarella When a block job fails, we report strerror(-job->job.ret) error message, also if the job set an error object. Let's report a better error message using error_get_pretty(job->job.err). If an error object was not set, strerror(-job->ret) is used as fallback, as explained in include/qemu/job.h: typedef struct Job { ... /** * Error object for a failed job. * If job->ret is nonzero and an error object was not set, it will be s= et * to strerror(-job->ret) during job_completed. */ Error *err; } In block_job_query() there can be a transient where 'job.err' is not set by a scheduled bottom half. In that case we use strerror(-job->ret) as it was before. Suggested-by: Kevin Wolf Signed-off-by: Stefano Garzarella Message-Id: <20210225103633.76746-1-sgarzare@redhat.com> Signed-off-by: Kevin Wolf --- blockjob.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/blockjob.c b/blockjob.c index f2feff051d..ef968017a2 100644 --- a/blockjob.c +++ b/blockjob.c @@ -318,8 +318,12 @@ BlockJobInfo *block_job_query(BlockJob *job, Error **e= rrp) info->status =3D job->job.status; info->auto_finalize =3D job->job.auto_finalize; info->auto_dismiss =3D job->job.auto_dismiss; - info->has_error =3D job->job.ret !=3D 0; - info->error =3D job->job.ret ? g_strdup(strerror(-job->job.ret)) := NULL; + if (job->job.ret) { + info->has_error =3D true; + info->error =3D job->job.err ? + g_strdup(error_get_pretty(job->job.err)) : + g_strdup(strerror(-job->job.ret)); + } return info; } =20 @@ -356,7 +360,7 @@ static void block_job_event_completed(Notifier *n, void= *opaque) } =20 if (job->job.ret < 0) { - msg =3D strerror(-job->job.ret); + msg =3D error_get_pretty(job->job.err); } =20 qapi_event_send_block_job_completed(job_type(&job->job), --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614965265; cv=none; d=zohomail.com; s=zohoarc; b=DflcesVbmN1Nhp0igT1t1kw66xtWX20tr59viuV+tQJF9NBabb0YbSUSV9+eLD9VYQ30QtAHDxyQzTrQh98J8plzwpu7etvajtuj3svf0qMZGIo0nW3Rwfl4DdALqXexA0W1qdNW9CTOllKCXkdSh9ELjqReVkjvEWlN8pQDNKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614965265; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0vpflH6yvCbbjvYemxj6XwuA+ujoiicVqSNFqQCZjGg=; b=QZhW6s7WFZ6gg6pax0Rkvbr6vkUItv78lW6tNsI80pfq+sTWTvkGLNXn9zGeJ0H7snoQBsDi9L833K32UbYgXNjSIfyFccuLMJCC73OmsDeb2cR5GMzjGyMasc5m7xx9DPneRRjTB6HChEsVEF08oFcPBz7+NN9nz8UMX5SCVFU= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614965265188892.7925711003425; Fri, 5 Mar 2021 09:27:45 -0800 (PST) Received: from localhost ([::1]:41352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIEEo-00036k-80 for importer@patchew.org; Fri, 05 Mar 2021 12:27:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33162) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkY-0007PY-93 for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:38249) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDkB-0007EG-9w for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:25 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-318-1oAdDyxwP963jQYcIxnndA-1; Fri, 05 Mar 2021 11:55:56 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EA20218C0267; Fri, 5 Mar 2021 16:55:16 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD20760BF3; Fri, 5 Mar 2021 16:55:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963358; 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=0vpflH6yvCbbjvYemxj6XwuA+ujoiicVqSNFqQCZjGg=; b=YVUja3VyoPHYbtojdJ9gHRW4Y7vJbxNzlgwQO2lS6vgz3E5NBTVe6NQyD48TJMVPjzE2yq 47KpWbTo8ZyoGI/1O+pkcbTfsRdSNEPECKu9jYFOLWEj07kDu1iGvZ+P1e5Mx35i7fB+82 xD6U0FNlIKbadRY8R+Dp5VyKAgxL7pU= X-MC-Unique: 1oAdDyxwP963jQYcIxnndA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 07/31] storage-daemon: report unexpected arguments on the fly Date: Fri, 5 Mar 2021 17:54:30 +0100 Message-Id: <20210305165454.356840-8-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini If the first character of optstring is '-', then each nonoption argv element is handled as if it were the argument of an option with character code 1. This removes the reordering of the argv array, and enables usage of loc_set_cmdline to provide better error messages. Signed-off-by: Paolo Bonzini Message-Id: <20210301152844.291799-2-pbonzini@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- storage-daemon/qemu-storage-daemon.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-sto= rage-daemon.c index 9021a46b3a..b7e1b90fb1 100644 --- a/storage-daemon/qemu-storage-daemon.c +++ b/storage-daemon/qemu-storage-daemon.c @@ -174,7 +174,7 @@ static void process_options(int argc, char *argv[]) * they are given on the command lines. This means that things must be * defined first before they can be referenced in another option. */ - while ((c =3D getopt_long(argc, argv, "hT:V", long_options, NULL)) != =3D -1) { + while ((c =3D getopt_long(argc, argv, "-hT:V", long_options, NULL)) != =3D -1) { switch (c) { case '?': exit(EXIT_FAILURE); @@ -275,14 +275,13 @@ static void process_options(int argc, char *argv[]) qobject_unref(args); break; } + case 1: + error_report("Unexpected argument: %s", optarg); + exit(EXIT_FAILURE); default: g_assert_not_reached(); } } - if (optind !=3D argc) { - error_report("Unexpected argument: %s", argv[optind]); - exit(EXIT_FAILURE); - } } =20 int main(int argc, char *argv[]) --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614963866; cv=none; d=zohomail.com; s=zohoarc; b=Cl74KUABnS8Zn6NVXunXgq3c7O4fBakGf7iyE1NoZfhiguCpsSlEXi0QYTSoBtJqrv6hLrD/unHaywL7F10xmwyYCWvYBFSfXWxfkr6XwwwJVstvOr8oovcWBtnrdalFD7OSZuPDPPhaDLIgoA2b51CBMuWCbZgUJq1e6+VuD6E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614963866; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DhbelqwQmlZpgy8qvloipsQdOEZFNllHURq2RU7LLt8=; b=lgieeox/tMUlTeJMxmtmT3Wtwf7ii5w2luZtcyp/szAt8VL80Q1yxMHhP13haqtp7XGZH0GGcPB30TM6GnwAt55r6SA8w/eCHzhPJOvSLNQVq6DSudiDJzXZzsENpxWniMzyG6cUy9BTz0zEJUi0U1lJP9lJgCZ/1Ag4JyGTtvI= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614963866450966.0466668340046; Fri, 5 Mar 2021 09:04:26 -0800 (PST) Received: from localhost ([::1]:33268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIDsH-0007er-DA for importer@patchew.org; Fri, 05 Mar 2021 12:04:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkC-0006rq-1F for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32143) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDjz-00079h-L5 for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:03 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-513-XMun1wSWPXy-BsGYUJx_6g-1; Fri, 05 Mar 2021 11:55:46 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 53D03800426; Fri, 5 Mar 2021 16:55:18 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 475A660BF3; Fri, 5 Mar 2021 16:55:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963348; 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=DhbelqwQmlZpgy8qvloipsQdOEZFNllHURq2RU7LLt8=; b=AtiR84QMmkf++vNIH3WLmvOQXWqALJ9LQzh4LyeZlHG5jkws12EtLR44hP0MA6Ev+P1dJj st3ZoALWY+gUDeZdWgl2S4dBDR8kvmUDLgPc/9Jls0toWzwvZYKdLfhXN0s6Brs0voPOYn OiLtkmRldufPeYu8iwYybgQGksEfBxg= X-MC-Unique: XMun1wSWPXy-BsGYUJx_6g-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 08/31] storage-daemon: include current command line option in the errors Date: Fri, 5 Mar 2021 17:54:31 +0100 Message-Id: <20210305165454.356840-9-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Use the location management facilities that the emulator uses, so that the current command line option appears in the error message. Before: $ storage-daemon/qemu-storage-daemon --nbd key..=3D qemu-storage-daemon: Invalid parameter 'key..' After: $ storage-daemon/qemu-storage-daemon --nbd key..=3D qemu-storage-daemon: --nbd key..=3D: Invalid parameter 'key..' Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini Message-Id: <20210301152844.291799-3-pbonzini@redhat.com> Signed-off-by: Kevin Wolf --- storage-daemon/qemu-storage-daemon.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-sto= rage-daemon.c index b7e1b90fb1..78ddf619d4 100644 --- a/storage-daemon/qemu-storage-daemon.c +++ b/storage-daemon/qemu-storage-daemon.c @@ -152,6 +152,20 @@ static void init_qmp_commands(void) qmp_marshal_qmp_capabilities, QCO_ALLOW_PRECONFIG= ); } =20 +static int getopt_set_loc(int argc, char **argv, const char *optstring, + const struct option *longopts) +{ + int c, save_index; + + optarg =3D NULL; + save_index =3D optind; + c =3D getopt_long(argc, argv, optstring, longopts, NULL); + if (optarg) { + loc_set_cmdline(argv, save_index, MAX(1, optind - save_index)); + } + return c; +} + static void process_options(int argc, char *argv[]) { int c; @@ -174,7 +188,7 @@ static void process_options(int argc, char *argv[]) * they are given on the command lines. This means that things must be * defined first before they can be referenced in another option. */ - while ((c =3D getopt_long(argc, argv, "-hT:V", long_options, NULL)) != =3D -1) { + while ((c =3D getopt_set_loc(argc, argv, "-hT:V", long_options)) !=3D = -1) { switch (c) { case '?': exit(EXIT_FAILURE); @@ -276,12 +290,13 @@ static void process_options(int argc, char *argv[]) break; } case 1: - error_report("Unexpected argument: %s", optarg); + error_report("Unexpected argument"); exit(EXIT_FAILURE); default: g_assert_not_reached(); } } + loc_set_none(); } =20 int main(int argc, char *argv[]) --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614964340; cv=none; d=zohomail.com; s=zohoarc; b=loygveGe24AUK79doNol3y36pcXl6vqBuVkS+Qd0sfuY64gVPalElQ+6hINnIW30UjlILl+Rt0A+4OgaU8MajTiaxD/9zVh+imlUTM4rAEw0lOlm9UrcUM8imO0SpDsZXNF3aKxVIenR8tTzYoQWLpXqMIzmMotl8bKjwV2vY+E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614964340; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iKcXNqoKQ9PlHlaamZu7e42WXZCYcY/ba4R23Tc+J70=; b=VGAmQhpWV4oIZwDcPZ2oMwEL71CXwrVxIjgZ8s1zyS6d78MF1FxiKJwdi8rFaSLRM+obxg5wShdzsAvZHaexmM5pLrxCi41/Z5wzcEBeIZVRls8Q5wO5e4um4hQ64Bvvgye8C9VbeXbWTOlqCMIjXeLP8oJyJZDYc7pM0yM5cAQ= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614964340275116.46526367883075; Fri, 5 Mar 2021 09:12:20 -0800 (PST) Received: from localhost ([::1]:59750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIDzv-0002F3-7g for importer@patchew.org; Fri, 05 Mar 2021 12:12:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:32822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkI-0006vY-Ns for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58808) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDk5-0007Cr-BL for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:10 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-255-2hsxdQ4uPEWemRyYOyPVRw-1; Fri, 05 Mar 2021 11:55:54 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0DFCDF8C4; Fri, 5 Mar 2021 16:55:19 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id A447460BF3; Fri, 5 Mar 2021 16:55:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963356; 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=iKcXNqoKQ9PlHlaamZu7e42WXZCYcY/ba4R23Tc+J70=; b=MmU7ZnyoIQMUDdWlgqh8fNe62kulVDbO9J1ZLfBs/83p+xFgSgqMaNotgCqiS8ufp6SAek /kKHV8Ej3wU0MohKXDtcOoTgR4SHwLtqCQakUZg77H7jEDyTnG6bmAFO0DD0Hs8wBd5HH0 toDZgbLv0RIkmI8n0rXXxNf1BD1wAb0= X-MC-Unique: 2hsxdQ4uPEWemRyYOyPVRw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 09/31] qemu-storage-daemon: add --pidfile option Date: Fri, 5 Mar 2021 17:54:32 +0100 Message-Id: <20210305165454.356840-10-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Daemons often have a --pidfile option where the pid is written to a file so that scripts can stop the daemon by sending a signal. The pid file also acts as a lock to prevent multiple instances of the daemon from launching for a given pid file. QEMU, qemu-nbd, qemu-ga, virtiofsd, and qemu-pr-helper all support the --pidfile option. Add it to qemu-storage-daemon too. Reported-by: Richard W.M. Jones Signed-off-by: Stefan Hajnoczi Message-Id: <20210302142746.170535-1-stefanha@redhat.com> Reviewed-by: Richard W.M. Jones Signed-off-by: Kevin Wolf --- docs/tools/qemu-storage-daemon.rst | 14 +++++++++++ storage-daemon/qemu-storage-daemon.c | 36 ++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/docs/tools/qemu-storage-daemon.rst b/docs/tools/qemu-storage-d= aemon.rst index c05b3d3811..6ce85f2f7d 100644 --- a/docs/tools/qemu-storage-daemon.rst +++ b/docs/tools/qemu-storage-daemon.rst @@ -118,6 +118,20 @@ Standard options: List object properties with ``,help``. See the :manpage:`qemu(1)` manual page for a description of the object properties. =20 +.. option:: --pidfile PATH + + is the path to a file where the daemon writes its pid. This allows scrip= ts to + stop the daemon by sending a signal:: + + $ kill -SIGTERM $( write process ID to a file after startup\n" +"\n" QEMU_HELP_BOTTOM "\n", error_get_progname()); } @@ -126,6 +129,7 @@ enum { OPTION_MONITOR, OPTION_NBD_SERVER, OPTION_OBJECT, + OPTION_PIDFILE, }; =20 extern QemuOptsList qemu_chardev_opts; @@ -178,6 +182,7 @@ static void process_options(int argc, char *argv[]) {"monitor", required_argument, NULL, OPTION_MONITOR}, {"nbd-server", required_argument, NULL, OPTION_NBD_SERVER}, {"object", required_argument, NULL, OPTION_OBJECT}, + {"pidfile", required_argument, NULL, OPTION_PIDFILE}, {"trace", required_argument, NULL, 'T'}, {"version", no_argument, NULL, 'V'}, {0, 0, 0, 0} @@ -289,6 +294,9 @@ static void process_options(int argc, char *argv[]) qobject_unref(args); break; } + case OPTION_PIDFILE: + pid_file =3D optarg; + break; case 1: error_report("Unexpected argument"); exit(EXIT_FAILURE); @@ -299,6 +307,27 @@ static void process_options(int argc, char *argv[]) loc_set_none(); } =20 +static void pid_file_cleanup(void) +{ + unlink(pid_file); +} + +static void pid_file_init(void) +{ + Error *err =3D NULL; + + if (!pid_file) { + return; + } + + if (!qemu_write_pidfile(pid_file, &err)) { + error_reportf_err(err, "cannot create PID file: "); + exit(EXIT_FAILURE); + } + + atexit(pid_file_cleanup); +} + int main(int argc, char *argv[]) { #ifdef CONFIG_POSIX @@ -326,6 +355,13 @@ int main(int argc, char *argv[]) qemu_init_main_loop(&error_fatal); process_options(argc, argv); =20 + /* + * Write the pid file after creating chardevs, exports, and NBD server= s but + * before accepting connections. This ordering is documented. Do not c= hange + * it. + */ + pid_file_init(); + while (!exit_requested) { main_loop_wait(false); } --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614963780; cv=none; d=zohomail.com; s=zohoarc; b=mKdjRSe1W54kFH30uKJ7BvCFRcFrYT8SB+9EFr6NL2eGnIKsj8MheJWLwrSMWqZW8UGHg2fdCW0SOSRVyieVr4is7ZKLa8p+JPk6lbRRCVtgtg1NoDFzYW9VQUWZCk9pNjzPC3veyVOnxOpMXoEeTpQabHmmg4MQc7o5mhdAjNY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614963780; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hNkuWjOrI8SckSnRLnxx+FN4aL9raBAHm2X/LISDeaE=; b=hKUb4vkakqE5mmVtTkB0+cOxY7+ZKhvkV1VCxmxJJVwGkyoeoJVtEqNOUZI56MaABZg/9lRbXO7u/suRgHcvMFGLUvaZKCsgEkIrWV08i0fv17M75y0S2aEiX2L14UKT20mlQEnQsP7G/ESKixDrUUpO/YUtPxKYSn+4o6sHpBs= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614963780056448.34743849022664; Fri, 5 Mar 2021 09:03:00 -0800 (PST) Received: from localhost ([::1]:55646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIDqs-0005Hl-SY for importer@patchew.org; Fri, 05 Mar 2021 12:02:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkD-0006sg-T6 for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:38293) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDjz-0007AB-Bq for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:05 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-298-rJQGhuAxN6CpmPnMHuqXeQ-1; Fri, 05 Mar 2021 11:55:44 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1C03410059D7; Fri, 5 Mar 2021 16:55:21 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BDF460BF3; Fri, 5 Mar 2021 16:55:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963349; 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=hNkuWjOrI8SckSnRLnxx+FN4aL9raBAHm2X/LISDeaE=; b=bbex7f/PMO/gYYtlyFfLeL+wufXkWDifji2/TqeZSzpnAvwZE9+GZ8POeL792QLKF2i4sk wYHk9yJeIQhAKDyNu9P5gDDlo/LgRzAqw5Z+4XOo95JjoFmHlgHAEOmXglDRAUBAEzbQhk /umgZM4c1bVnIHZk1MqHA1pekyrgJ1w= X-MC-Unique: rJQGhuAxN6CpmPnMHuqXeQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 10/31] docs: show how to spawn qemu-storage-daemon with fd passing Date: Fri, 5 Mar 2021 17:54:33 +0100 Message-Id: <20210305165454.356840-11-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Stefan Hajnoczi The QMP monitor, NBD server, and vhost-user-blk export all support file descriptor passing. This is a useful technique because it allows the parent process to spawn and wait for qemu-storage-daemon without busy waiting, which may delay startup due to arbitrary sleep() calls. This Python example is inspired by the test case written for libnbd by Richard W.M. Jones : https://gitlab.com/nbdkit/libnbd/-/commit/89113f484effb0e6c322314ba75c1cbe0= 7a04543 Thanks to Daniel P. Berrang=C3=A9 for suggestions on how to get this working. Now let's document it! Reported-by: Richard W.M. Jones Cc: Kevin Wolf Cc: Daniel P. Berrang=C3=A9 Signed-off-by: Stefan Hajnoczi Message-Id: <20210301172728.135331-2-stefanha@redhat.com> Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Richard W.M. Jones Signed-off-by: Kevin Wolf --- docs/tools/qemu-storage-daemon.rst | 42 ++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/docs/tools/qemu-storage-daemon.rst b/docs/tools/qemu-storage-d= aemon.rst index 6ce85f2f7d..5714794775 100644 --- a/docs/tools/qemu-storage-daemon.rst +++ b/docs/tools/qemu-storage-daemon.rst @@ -101,10 +101,12 @@ Standard options: =20 .. option:: --nbd-server addr.type=3Dinet,addr.host=3D,addr.port=3D<= port>[,tls-creds=3D][,tls-authz=3D][,max-connections=3D] --nbd-server addr.type=3Dunix,addr.path=3D[,tls-creds=3D][,tls= -authz=3D][,max-connections=3D] + --nbd-server addr.type=3Dfd,addr.str=3D[,tls-creds=3D][,tls-auth= z=3D][,max-connections=3D] =20 is a server for NBD exports. Both TCP and UNIX domain sockets are suppor= ted. - TLS encryption can be configured using ``--object`` tls-creds-* and auth= z-* - secrets (see below). + A listen socket can be provided via file descriptor passing (see Examples + below). TLS encryption can be configured using ``--object`` tls-creds-* = and + authz-* secrets (see below). =20 To configure an NBD server on UNIX domain socket path ``/tmp/nbd.sock``:: =20 @@ -141,6 +143,42 @@ QMP commands:: --chardev socket,path=3Dqmp.sock,server=3Don,wait=3Doff,id=3Dchar1 \ --monitor chardev=3Dchar1 =20 +Launch the daemon from Python with a QMP monitor socket using file descrip= tor +passing so there is no need to busy wait for the QMP monitor to become +available:: + + #!/usr/bin/env python3 + import subprocess + import socket + + sock_path =3D '/var/run/qmp.sock' + + with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as listen_sock: + listen_sock.bind(sock_path) + listen_sock.listen() + + fd =3D listen_sock.fileno() + + subprocess.Popen( + ['qemu-storage-daemon', + '--chardev', f'socket,fd=3D{fd},server=3Don,id=3Dchar1', + '--monitor', 'chardev=3Dchar1'], + pass_fds=3D[fd], + ) + + # listen_sock was automatically closed when leaving the 'with' statement + # body. If the daemon process terminated early then the following connec= t() + # will fail with "Connection refused" because no process has the listen + # socket open anymore. Launch errors can be detected this way. + + qmp_sock =3D socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + qmp_sock.connect(sock_path) + ...QMP interaction... + +The same socket spawning approach also works with the ``--nbd-server +addr.type=3Dfd,addr.str=3D`` and ``--export +type=3Dvhost-user-blk,addr.type=3Dfd,addr.str=3D`` options. + Export raw image file ``disk.img`` over NBD UNIX domain socket ``nbd.sock`= `:: =20 $ qemu-storage-daemon \ --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614965627; cv=none; d=zohomail.com; s=zohoarc; b=P+NMyXWTAbQ0nTuz2DRYs9BGM4ib4UcACVm9Glq1mLmA52T2U4osuogqm2CG+0dhxZoDNfr9QM8NxktVZDNrPuH/3EAjLfOj2ehr6rviON6VR1T1UDWGWqAXx7MWVi6zVNmnvg9aNJEPSOG+ZgxnrEW6ECbC29JU/zwvYeUBpLE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614965627; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fkFDSkSOG52uvLLT0GztWJFV+seyxuV6TSvuSDLBo0Q=; b=ihQIP8+GbGhaF03fWADalVTPKtSY8xYwbd6KnjM7eVD6jyxde2iXkrSnEM1m7Iic3JM8fj1HKST56d2qxx65kIqjWJGNY8UUgsYfiVNXxaZ/TFN9/NHq1mHj/l0ZN9zpCxYrEzwVq164ZwqOzkaK55O7UNgxsC7FKQY6rY2DbUU= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614965627200271.83854615341204; Fri, 5 Mar 2021 09:33:47 -0800 (PST) Received: from localhost ([::1]:57494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIEKg-0001RM-76 for importer@patchew.org; Fri, 05 Mar 2021 12:33:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33034) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkS-00078e-6e for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32286) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDkB-0007FU-46 for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:19 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-211-1Sn4U_AYPSWXBRxUojV0_g-1; Fri, 05 Mar 2021 11:55:57 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 77CFF18C026E; Fri, 5 Mar 2021 16:55:22 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 68ABA60BF3; Fri, 5 Mar 2021 16:55:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963359; 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=fkFDSkSOG52uvLLT0GztWJFV+seyxuV6TSvuSDLBo0Q=; b=htEnW+4M6FkuCo4BOLKImariMwGOlaE1puhnw6/9Z/bvw6WU2N+ALb4Yo1qYhwgUp9KNrk SlfjKFE5gblDM6ZMNJdF98gye/Qb0+gAadKl40QyYk/mJgoF3lpbzXETcMaU/q+8eJHPrt zRNGX3mFf1lFcH8C9FUTRoeNgsoTyw4= X-MC-Unique: 1Sn4U_AYPSWXBRxUojV0_g-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 11/31] docs: replace insecure /tmp examples in qsd docs Date: Fri, 5 Mar 2021 17:54:34 +0100 Message-Id: <20210305165454.356840-12-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Stefan Hajnoczi World-writeable directories have security issues. Avoid showing them in the documentation since someone might accidentally use them in situations where they are insecure. There tend to be 3 security problems: 1. Denial of service. An adversary may be able to create the file beforehand, consume all space/inodes, etc to sabotage us. 2. Impersonation. An adversary may be able to create a listen socket and accept incoming connections that were meant for us. 3. Unauthenticated client access. An adversary may be able to connect to us if we did not set the uid/gid and permissions correctly. These can be prevented or mitigated with private /tmp, carefully setting the umask, etc but that requires special action and does not apply to all situations. Just avoid using /tmp in examples. Reported-by: Richard W.M. Jones Reported-by: Daniel P. Berrang=C3=A9 Signed-off-by: Stefan Hajnoczi Message-Id: <20210301172728.135331-3-stefanha@redhat.com> Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Richard W.M. Jones Signed-off-by: Kevin Wolf --- docs/tools/qemu-storage-daemon.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/tools/qemu-storage-daemon.rst b/docs/tools/qemu-storage-d= aemon.rst index 5714794775..fe3042d609 100644 --- a/docs/tools/qemu-storage-daemon.rst +++ b/docs/tools/qemu-storage-daemon.rst @@ -69,7 +69,7 @@ Standard options: a description of character device properties. A common character device definition configures a UNIX domain socket:: =20 - --chardev socket,id=3Dchar1,path=3D/tmp/qmp.sock,server=3Don,wait=3Doff + --chardev socket,id=3Dchar1,path=3D/var/run/qsd-qmp.sock,server=3Don,wai= t=3Doff =20 .. option:: --export [type=3D]nbd,id=3D,node-name=3D[,name= =3D][,writable=3Don|off][,bitmap=3D] --export [type=3D]vhost-user-blk,id=3D,node-name=3D,addr.= type=3Dunix,addr.path=3D[,writable=3Don|off][,logical-block-si= ze=3D][,num-queues=3D] @@ -108,9 +108,10 @@ Standard options: below). TLS encryption can be configured using ``--object`` tls-creds-* = and authz-* secrets (see below). =20 - To configure an NBD server on UNIX domain socket path ``/tmp/nbd.sock``:: + To configure an NBD server on UNIX domain socket path + ``/var/run/qsd-nbd.sock``:: =20 - --nbd-server addr.type=3Dunix,addr.path=3D/tmp/nbd.sock + --nbd-server addr.type=3Dunix,addr.path=3D/var/run/qsd-nbd.sock =20 .. option:: --object help --object ,help --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614964738; cv=none; d=zohomail.com; s=zohoarc; b=BmhACuvegbt9h+XTVP0yCZK2NlJbXlfOawijQIcssPbHuwjQXqicY5PiXhSV0dYYCfSY1fXyUCxIwQ5cEcPICwLicsxO7bByxw1jZ4pCE8tDsqPUScHEq+dgzFlw2R2UsdXyVHf4YCLCB16OlZh/Dp4FhHI2HKPxxJ3udIClh6g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614964738; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=u+gTC2bXiytaJ9NOO0mGe1DEhNjbGqJQ8pY869RL0BU=; b=HT5ar+Ff+twsln6HaThOxvTT0lM0D1IIpdyMqQqANRC3HL8M1xYiEFzFocErsBexsZl1t8OugN8Kfdfhdtw+td8BUXWRbwaTEC4SDpsDe0DN1WhBS4zTgI/bHmOwOgDF8nFSFNx9sQRaB2qVtLkx2xx2zlGcTlTWIBzyThh0cD4= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161496473837842.85722633015041; Fri, 5 Mar 2021 09:18:58 -0800 (PST) Received: from localhost ([::1]:45172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIE6L-0000Zn-3a for importer@patchew.org; Fri, 05 Mar 2021 12:18:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkb-0007XC-2S for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31432) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDkB-0007Fw-CJ for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:28 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-7-e_pAniInN2ePI5TFZvoq9w-1; Fri, 05 Mar 2021 11:55:56 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D3DC5814401; Fri, 5 Mar 2021 16:55:23 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7D2F60BF3; Fri, 5 Mar 2021 16:55:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963360; 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=u+gTC2bXiytaJ9NOO0mGe1DEhNjbGqJQ8pY869RL0BU=; b=YizuBzSfJ3gsecPy7VnpjZ7lbf8QoUwrSWsAAjRndvE6tNSTOJJRojIFgyKR+On2ZfHj2o Nko/mVnh2U+hhGClmZsIr++hTz6dOExeSCM6ifI6UdQFdcSmhJMqzWE5XGBCkeJSrs/i+8 0ZXHuzxNaEBrGiT220YZpSqB0dkVHDM= X-MC-Unique: e_pAniInN2ePI5TFZvoq9w-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 12/31] vhost-user-blk: fix blkcfg->num_queues endianness Date: Fri, 5 Mar 2021 17:54:35 +0100 Message-Id: <20210305165454.356840-13-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Treat the num_queues field as virtio-endian. On big-endian hosts the vhost-user-blk num_queues field was in the wrong endianness. Move the blkcfg.num_queues store operation from realize to vhost_user_blk_update_config() so feature negotiation has finished and we know the endianness of the device. VIRTIO 1.0 devices are little-endian, but in case someone wants to use legacy VIRTIO we support all endianness cases. Cc: qemu-stable@nongnu.org Signed-off-by: Stefan Hajnoczi Reviewed-by: Raphael Norwitz Reviewed-by: Michael S. Tsirkin Message-Id: <20210223144653.811468-2-stefanha@redhat.com> Signed-off-by: Kevin Wolf --- hw/block/vhost-user-blk.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index da4fbf9084..b870a50e6b 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -54,6 +54,9 @@ static void vhost_user_blk_update_config(VirtIODevice *vd= ev, uint8_t *config) { VHostUserBlk *s =3D VHOST_USER_BLK(vdev); =20 + /* Our num_queues overrides the device backend */ + virtio_stw_p(vdev, &s->blkcfg.num_queues, s->num_queues); + memcpy(config, &s->blkcfg, sizeof(struct virtio_blk_config)); } =20 @@ -491,10 +494,6 @@ reconnect: goto reconnect; } =20 - if (s->blkcfg.num_queues !=3D s->num_queues) { - s->blkcfg.num_queues =3D s->num_queues; - } - return; =20 virtio_err: --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614964220; cv=none; d=zohomail.com; s=zohoarc; b=GazjnYXvP6ij+h8wQ/gubHPuu6YBCIrez8M2owHA5Fbm3nDIaOu0N13eWW78lxE5L41/DvHUScBxZo2ZXcGTxYi/HJckIKOJXzr9aloyGmB7T114mJ/YG+UfonCztMF/zvWnxEszJmSNSsjjh/vICTZKnfDObZt5z+Ge4AxKGfE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614964220; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=t3PaHE5X4bFnk6vpSNRntxY4mxkylSkIY96oFEvivRM=; b=EVVvuGa0akQE8y2B9L2pSapAwAeZzhNNa9k27vmUqkbQEvwY8xnin+3H+OzMGch0EoY+fvM49h14XbDxoLt31TzknctL4C4V0SL9DMjrsXl8nKLWrGE9YTeDOWNZOSau8YW0TMX1jl5MBPXt/MCTMFQVeFazl8nP7ITsSrz+oa4= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614964220704127.00810239818452; Fri, 5 Mar 2021 09:10:20 -0800 (PST) Received: from localhost ([::1]:54388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIDxz-00081y-GD for importer@patchew.org; Fri, 05 Mar 2021 12:10:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60968) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkF-0006tQ-IO for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33809) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDk3-0007Ac-Bn for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:07 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-507-H1y6iNpvO-uN-pwK2t-Bww-1; Fri, 05 Mar 2021 11:55:46 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3C16B804330; Fri, 5 Mar 2021 16:55:25 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2FDAD60BF3; Fri, 5 Mar 2021 16:55:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963350; 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=t3PaHE5X4bFnk6vpSNRntxY4mxkylSkIY96oFEvivRM=; b=LOf4t9fBPdjogHxuP9yeau5UBQKmUUyanFLTVazadakYNK4GINBm+5iXcgMk6gMyi+zIny b1kfgOSPxh+j8Ff/ly1buhgZ286oTQ/YaYE2SiXKeW4cJazJYgrxv57CU3aXKSSrzhPRba pwzPXlcullTxpJUt5gx5eP/UVKQMn6M= X-MC-Unique: H1y6iNpvO-uN-pwK2t-Bww-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 13/31] libqtest: add qtest_socket_server() Date: Fri, 5 Mar 2021 17:54:36 +0100 Message-Id: <20210305165454.356840-14-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Add an API that returns a new UNIX domain socket in the listen state. The code for this was already there but only used internally in init_socket(). This new API will be used by vhost-user-blk-test. Signed-off-by: Stefan Hajnoczi Reviewed-by: Thomas Huth Reviewed-by: Wainer dos Santos Moschetta Message-Id: <20210223144653.811468-3-stefanha@redhat.com> Signed-off-by: Kevin Wolf --- tests/qtest/libqos/libqtest.h | 8 +++++++ tests/qtest/libqtest.c | 40 ++++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/tests/qtest/libqos/libqtest.h b/tests/qtest/libqos/libqtest.h index 724f65aa94..e5f1ec590c 100644 --- a/tests/qtest/libqos/libqtest.h +++ b/tests/qtest/libqos/libqtest.h @@ -132,6 +132,14 @@ void qtest_qmp_send(QTestState *s, const char *fmt, ..= .) void qtest_qmp_send_raw(QTestState *s, const char *fmt, ...) GCC_FMT_ATTR(2, 3); =20 +/** + * qtest_socket_server: + * @socket_path: the UNIX domain socket path + * + * Create and return a listen socket file descriptor, or abort on failure. + */ +int qtest_socket_server(const char *socket_path); + /** * qtest_vqmp_fds: * @s: #QTestState instance to operate on. diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index fd043b0570..b19d2ebda0 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -81,24 +81,8 @@ static void qtest_client_set_rx_handler(QTestState *s, Q= TestRecvFn recv); =20 static int init_socket(const char *socket_path) { - struct sockaddr_un addr; - int sock; - int ret; - - sock =3D socket(PF_UNIX, SOCK_STREAM, 0); - g_assert_cmpint(sock, !=3D, -1); - - addr.sun_family =3D AF_UNIX; - snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", socket_path); + int sock =3D qtest_socket_server(socket_path); qemu_set_cloexec(sock); - - do { - ret =3D bind(sock, (struct sockaddr *)&addr, sizeof(addr)); - } while (ret =3D=3D -1 && errno =3D=3D EINTR); - g_assert_cmpint(ret, !=3D, -1); - ret =3D listen(sock, 1); - g_assert_cmpint(ret, !=3D, -1); - return sock; } =20 @@ -638,6 +622,28 @@ QDict *qtest_qmp_receive_dict(QTestState *s) return qmp_fd_receive(s->qmp_fd); } =20 +int qtest_socket_server(const char *socket_path) +{ + struct sockaddr_un addr; + int sock; + int ret; + + sock =3D socket(PF_UNIX, SOCK_STREAM, 0); + g_assert_cmpint(sock, !=3D, -1); + + addr.sun_family =3D AF_UNIX; + snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", socket_path); + + do { + ret =3D bind(sock, (struct sockaddr *)&addr, sizeof(addr)); + } while (ret =3D=3D -1 && errno =3D=3D EINTR); + g_assert_cmpint(ret, !=3D, -1); + ret =3D listen(sock, 1); + g_assert_cmpint(ret, !=3D, -1); + + return sock; +} + /** * Allow users to send a message without waiting for the reply, * in the case that they choose to discard all replies up until --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614966120; cv=none; d=zohomail.com; s=zohoarc; b=EOx5dZ3qu569B16X6a5lS+K2wT8BPgAacfgIDb4Ub78vy1w8/ZXxJDNC2E7Y7re7LTsJmNDgQugBrpG++v1Lt0HhIpgp4APRwi5gLbX3Lidp0KBfi/QjDeOJZWZC6o8KF7D/kbeASnaiyCAkPtuyh15BhxZjjif1rWDUZdQFazw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614966120; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8e52D/2ZXjDcdIEsKV/OpK62L1bLWsj4zhMYxcpUUt8=; b=CFzQDTQrPAK5DxE6keuNIz8wkePwsKJFuHUytMT7Agg2nzpTzQyEbBI9YAl5907ItUe0yUIPbGcmRkSGmhjX5+qCfn17C9/10kU4WHyNWJ2+ETL7w4h9V2VV2ugvWjp3e/DEZ/44nEq6VMwEhwG/Rqo9bxRDn/Zi64S1VKwae8E= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614966120081722.9455907957682; Fri, 5 Mar 2021 09:42:00 -0800 (PST) Received: from localhost ([::1]:56182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIESc-0004Jv-Sq for importer@patchew.org; Fri, 05 Mar 2021 12:41:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33250) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkb-0007YT-H6 for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:46679) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDkB-0007Fn-CH for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:29 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-240-jYpO6Qz-NcShNLX8veXqCA-1; Fri, 05 Mar 2021 11:55:56 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 98BD085EE8B; Fri, 5 Mar 2021 16:55:26 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B4EF60BF3; Fri, 5 Mar 2021 16:55:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963360; 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=8e52D/2ZXjDcdIEsKV/OpK62L1bLWsj4zhMYxcpUUt8=; b=R3Nxww0rxLbsNThP2jVCb5WIaGK2neffCaIuUQjg/a1aC0xShhzpCZDaiUEbM1stHpY6Xu eVR2lXT7Qk9d43cYMaEkJBLxhaQ7z3XYe900FkDmQtBk3IdiFlJmQmDmeYjRFf+5hSaONJ v0QYgD9gbZPnSbpZbbmpfIoPZ98YGrs= X-MC-Unique: jYpO6Qz-NcShNLX8veXqCA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 14/31] libqtest: add qtest_kill_qemu() Date: Fri, 5 Mar 2021 17:54:37 +0100 Message-Id: <20210305165454.356840-15-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Tests that manage multiple processes may wish to kill QEMU before destroying the QTestState. Expose a function to do that. The vhost-user-blk-test testcase will need this. Signed-off-by: Stefan Hajnoczi Reviewed-by: Wainer dos Santos Moschetta Message-Id: <20210223144653.811468-4-stefanha@redhat.com> Signed-off-by: Kevin Wolf --- tests/qtest/libqos/libqtest.h | 11 +++++++++++ tests/qtest/libqtest.c | 7 ++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/qtest/libqos/libqtest.h b/tests/qtest/libqos/libqtest.h index e5f1ec590c..51287b9276 100644 --- a/tests/qtest/libqos/libqtest.h +++ b/tests/qtest/libqos/libqtest.h @@ -74,6 +74,17 @@ QTestState *qtest_init_without_qmp_handshake(const char = *extra_args); */ QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd); =20 +/** + * qtest_kill_qemu: + * @s: #QTestState instance to operate on. + * + * Kill the QEMU process and wait for it to terminate. It is safe to call = this + * function multiple times. Normally qtest_quit() is used instead because = it + * also frees QTestState. Use qtest_kill_qemu() when you just want to kill= QEMU + * and qtest_quit() will be called later. + */ +void qtest_kill_qemu(QTestState *s); + /** * qtest_quit: * @s: #QTestState instance to operate on. diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index b19d2ebda0..2a98de2907 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -133,7 +133,7 @@ void qtest_set_expected_status(QTestState *s, int statu= s) s->expected_status =3D status; } =20 -static void kill_qemu(QTestState *s) +void qtest_kill_qemu(QTestState *s) { pid_t pid =3D s->qemu_pid; int wstatus; @@ -143,6 +143,7 @@ static void kill_qemu(QTestState *s) kill(pid, SIGTERM); TFR(pid =3D waitpid(s->qemu_pid, &s->wstatus, 0)); assert(pid =3D=3D s->qemu_pid); + s->qemu_pid =3D -1; } =20 /* @@ -169,7 +170,7 @@ static void kill_qemu(QTestState *s) =20 static void kill_qemu_hook_func(void *s) { - kill_qemu(s); + qtest_kill_qemu(s); } =20 static void sigabrt_handler(int signo) @@ -373,7 +374,7 @@ void qtest_quit(QTestState *s) /* Uninstall SIGABRT handler on last instance */ cleanup_sigabrt_handler(); =20 - kill_qemu(s); + qtest_kill_qemu(s); close(s->fd); close(s->qmp_fd); g_string_free(s->rx, true); --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614964081; cv=none; d=zohomail.com; s=zohoarc; b=MIfb10JwKHDIwQfZGIPNIyhdDrH2WWkSXkxh3d3mplrWIFt537bHw/3k/p8bzhZ9BrpuCkd1FbcJ2qopxWDs08RlvdWXlHOiGk41jqDtbUVq9Asw55++YqeIe5hikgY/k96p++cCqEcwWvW++xO1gDURhxAMHrzIxzuko2mqwUo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614964081; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=t8yqYXZpSfPDjwjzkzYok73HMHctHeR31FYw9hDW0sk=; b=YIkn3+liM1SVxrruvcbvHqYQY/Sntmp4ULhET0cvaJwjULM3RPguufc+Z+0mqrKHpf+6Q4CSY1tnYNaIZvHVz1+eIJEV3rXYuDGig3hrOAo4lXSHaXyHVJsalBB0rXsBGhJO8E/deIi9VQWuLw4ytKnOdV9g4YOKoLdG2zcp5UE= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614964081573367.4931027331794; Fri, 5 Mar 2021 09:08:01 -0800 (PST) Received: from localhost ([::1]:45876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIDvk-0004VA-5Z for importer@patchew.org; Fri, 05 Mar 2021 12:08:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkC-0006rr-1Q for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:47199) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDjx-00079Y-DL for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:03 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-474-ZTCQox4IO6aXSIjFRYvbWQ-1; Fri, 05 Mar 2021 11:55:46 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0482D80197D; Fri, 5 Mar 2021 16:55:28 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id E9E9260BF3; Fri, 5 Mar 2021 16:55:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963348; 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=t8yqYXZpSfPDjwjzkzYok73HMHctHeR31FYw9hDW0sk=; b=JZG0bqrwrxkzwOLGNWdNFDFTS5cVYZeg7Q9C5AUb506405SnOdnQgGbVxt1vyJihsTiRRG dVM1j1KbNg/oMeSz8MxGE664svBEwhs6JdynjmTyByxL/ysF1vXcSe4MrkQNRjLAwIGEqm 5wGPL3byHM8d2oPJLB4iQSjjU4MhNPo= X-MC-Unique: ZTCQox4IO6aXSIjFRYvbWQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 15/31] libqtest: add qtest_remove_abrt_handler() Date: Fri, 5 Mar 2021 17:54:38 +0100 Message-Id: <20210305165454.356840-16-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Add a function to remove previously-added abrt handler functions. Now that a symmetric pair of add/remove functions exists we can also balance the SIGABRT handler installation. The signal handler was installed each time qtest_add_abrt_handler() was called. Now it is installed when the abrt handler list becomes non-empty and removed again when the list becomes empty. The qtest_remove_abrt_handler() function will be used by vhost-user-blk-test. Signed-off-by: Stefan Hajnoczi Reviewed-by: Wainer dos Santos Moschetta Message-Id: <20210223144653.811468-5-stefanha@redhat.com> Signed-off-by: Kevin Wolf --- tests/qtest/libqos/libqtest.h | 18 ++++++++++++++++++ tests/qtest/libqtest.c | 35 +++++++++++++++++++++++++++++------ 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/tests/qtest/libqos/libqtest.h b/tests/qtest/libqos/libqtest.h index 51287b9276..a68dcd79d4 100644 --- a/tests/qtest/libqos/libqtest.h +++ b/tests/qtest/libqos/libqtest.h @@ -649,8 +649,26 @@ void qtest_add_data_func_full(const char *str, void *d= ata, g_free(path); \ } while (0) =20 +/** + * qtest_add_abrt_handler: + * @fn: Handler function + * @data: Argument that is passed to the handler + * + * Add a handler function that is invoked on SIGABRT. This can be used to + * terminate processes and perform other cleanup. The handler can be remov= ed + * with qtest_remove_abrt_handler(). + */ void qtest_add_abrt_handler(GHookFunc fn, const void *data); =20 +/** + * qtest_remove_abrt_handler: + * @data: Argument previously passed to qtest_add_abrt_handler() + * + * Remove an abrt handler that was previously added with + * qtest_add_abrt_handler(). + */ +void qtest_remove_abrt_handler(void *data); + /** * qtest_qmp_assert_success: * @qts: QTestState instance to operate on diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 2a98de2907..71e359efcd 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -196,15 +196,30 @@ static void cleanup_sigabrt_handler(void) sigaction(SIGABRT, &sigact_old, NULL); } =20 +static bool hook_list_is_empty(GHookList *hook_list) +{ + GHook *hook =3D g_hook_first_valid(hook_list, TRUE); + + if (!hook) { + return false; + } + + g_hook_unref(hook_list, hook); + return true; +} + void qtest_add_abrt_handler(GHookFunc fn, const void *data) { GHook *hook; =20 - /* Only install SIGABRT handler once */ if (!abrt_hooks.is_setup) { g_hook_list_init(&abrt_hooks, sizeof(GHook)); } - setup_sigabrt_handler(); + + /* Only install SIGABRT handler once */ + if (hook_list_is_empty(&abrt_hooks)) { + setup_sigabrt_handler(); + } =20 hook =3D g_hook_alloc(&abrt_hooks); hook->func =3D fn; @@ -213,6 +228,17 @@ void qtest_add_abrt_handler(GHookFunc fn, const void *= data) g_hook_prepend(&abrt_hooks, hook); } =20 +void qtest_remove_abrt_handler(void *data) +{ + GHook *hook =3D g_hook_find_data(&abrt_hooks, TRUE, data); + g_hook_destroy_link(&abrt_hooks, hook); + + /* Uninstall SIGABRT handler on last instance */ + if (hook_list_is_empty(&abrt_hooks)) { + cleanup_sigabrt_handler(); + } +} + static const char *qtest_qemu_binary(void) { const char *qemu_bin; @@ -369,10 +395,7 @@ QTestState *qtest_init_with_serial(const char *extra_a= rgs, int *sock_fd) =20 void qtest_quit(QTestState *s) { - g_hook_destroy_link(&abrt_hooks, g_hook_find_data(&abrt_hooks, TRUE, s= )); - - /* Uninstall SIGABRT handler on last instance */ - cleanup_sigabrt_handler(); + qtest_remove_abrt_handler(s); =20 qtest_kill_qemu(s); close(s->fd); --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614964375; cv=none; d=zohomail.com; s=zohoarc; b=hXWQOgGULMGymoF4hvKEhc1aJXgfMhy2NWdGGXv6KmqoZon/s2rC00muXKuUlJvlkt8WKJBcIyvdz75Z6vWhKB7hYwl+hMSYTY3PBRiElXMkIRmCe34Lq0OAItnmZMoSSnA6J3OC915AFvi604JOC3drApLJvexw3u6wSBluUMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614964375; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=X7Jtl7VOGjedEtZTWhFVw7s8i4ZW4QhVMMmYLi7B8zQ=; b=mm3znIlIhhsAb2Yj0IwVzLuHcRvbIsvO1Vx6wwdj3adnbd4quCl8hCzIOt3lg/bVq4m8oVVRtczrpOneBQt3fIpX6HMsqCCndCsGzZVABDVVS1vpUGF46jobJDeG4ovomLYMhPPNh6CCaIZI3U01qCM9VnZ0hBHNi9lQsGXg7/Q= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614964375006716.1029151716101; Fri, 5 Mar 2021 09:12:55 -0800 (PST) Received: from localhost ([::1]:34674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIE0T-0003Wx-Oh for importer@patchew.org; Fri, 05 Mar 2021 12:12:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkf-0007lA-Jf for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:22309) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDkD-0007I2-5j for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:33 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-258-thoDoFXEPqaSb7EaLD89lw-1; Fri, 05 Mar 2021 11:55:56 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8D12318C0274; Fri, 5 Mar 2021 16:55:29 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57ACB60BF3; Fri, 5 Mar 2021 16:55:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963364; 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=X7Jtl7VOGjedEtZTWhFVw7s8i4ZW4QhVMMmYLi7B8zQ=; b=iLmV+9tgOJHzWLjOTETRb9bt3Vld45QSun1m82o/Ry99tjOflvqwzA0YL+oWl8qkxPbmsY Sfusm8ljcWoE8F+EwmnyVH2xCHMyGhJMmhiOxh71oO5J0srpNZ7NCZooHUnyC04kVgjwgL B84e71nLn2t3WQIxS8tP9eOg1xxQCHg= X-MC-Unique: thoDoFXEPqaSb7EaLD89lw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 16/31] test: new qTest case to test the vhost-user-blk-server Date: Fri, 5 Mar 2021 17:54:39 +0100 Message-Id: <20210305165454.356840-17-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Coiby Xu This test case has the same tests as tests/virtio-blk-test.c except for tests have block_resize. Since the vhost-user-blk export only serves one client one time, two exports are started by qemu-storage-daemon for the hotplug test. Suggested-by: Thomas Huth Signed-off-by: Coiby Xu Signed-off-by: Stefan Hajnoczi Message-Id: <20210223144653.811468-6-stefanha@redhat.com> Signed-off-by: Kevin Wolf --- tests/qtest/libqos/vhost-user-blk.h | 48 ++ tests/qtest/libqos/vhost-user-blk.c | 130 +++++ tests/qtest/vhost-user-blk-test.c | 788 ++++++++++++++++++++++++++++ MAINTAINERS | 2 + tests/qtest/libqos/meson.build | 1 + tests/qtest/meson.build | 4 + 6 files changed, 973 insertions(+) create mode 100644 tests/qtest/libqos/vhost-user-blk.h create mode 100644 tests/qtest/libqos/vhost-user-blk.c create mode 100644 tests/qtest/vhost-user-blk-test.c diff --git a/tests/qtest/libqos/vhost-user-blk.h b/tests/qtest/libqos/vhost= -user-blk.h new file mode 100644 index 0000000000..2a03456a45 --- /dev/null +++ b/tests/qtest/libqos/vhost-user-blk.h @@ -0,0 +1,48 @@ +/* + * libqos driver framework + * + * Based on tests/qtest/libqos/virtio-blk.c + * + * Copyright (c) 2020 Coiby Xu + * + * Copyright (c) 2018 Emanuele Giuseppe Esposito + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + */ + +#ifndef TESTS_LIBQOS_VHOST_USER_BLK_H +#define TESTS_LIBQOS_VHOST_USER_BLK_H + +#include "qgraph.h" +#include "virtio.h" +#include "virtio-pci.h" + +typedef struct QVhostUserBlk QVhostUserBlk; +typedef struct QVhostUserBlkPCI QVhostUserBlkPCI; +typedef struct QVhostUserBlkDevice QVhostUserBlkDevice; + +struct QVhostUserBlk { + QVirtioDevice *vdev; +}; + +struct QVhostUserBlkPCI { + QVirtioPCIDevice pci_vdev; + QVhostUserBlk blk; +}; + +struct QVhostUserBlkDevice { + QOSGraphObject obj; + QVhostUserBlk blk; +}; + +#endif diff --git a/tests/qtest/libqos/vhost-user-blk.c b/tests/qtest/libqos/vhost= -user-blk.c new file mode 100644 index 0000000000..568c3426ed --- /dev/null +++ b/tests/qtest/libqos/vhost-user-blk.c @@ -0,0 +1,130 @@ +/* + * libqos driver framework + * + * Based on tests/qtest/libqos/virtio-blk.c + * + * Copyright (c) 2020 Coiby Xu + * + * Copyright (c) 2018 Emanuele Giuseppe Esposito + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + */ + +#include "qemu/osdep.h" +#include "libqtest.h" +#include "qemu/module.h" +#include "standard-headers/linux/virtio_blk.h" +#include "vhost-user-blk.h" + +#define PCI_SLOT 0x04 +#define PCI_FN 0x00 + +/* virtio-blk-device */ +static void *qvhost_user_blk_get_driver(QVhostUserBlk *v_blk, + const char *interface) +{ + if (!g_strcmp0(interface, "vhost-user-blk")) { + return v_blk; + } + if (!g_strcmp0(interface, "virtio")) { + return v_blk->vdev; + } + + fprintf(stderr, "%s not present in vhost-user-blk-device\n", interface= ); + g_assert_not_reached(); +} + +static void *qvhost_user_blk_device_get_driver(void *object, + const char *interface) +{ + QVhostUserBlkDevice *v_blk =3D object; + return qvhost_user_blk_get_driver(&v_blk->blk, interface); +} + +static void *vhost_user_blk_device_create(void *virtio_dev, + QGuestAllocator *t_alloc, + void *addr) +{ + QVhostUserBlkDevice *vhost_user_blk =3D g_new0(QVhostUserBlkDevice, 1); + QVhostUserBlk *interface =3D &vhost_user_blk->blk; + + interface->vdev =3D virtio_dev; + + vhost_user_blk->obj.get_driver =3D qvhost_user_blk_device_get_driver; + + return &vhost_user_blk->obj; +} + +/* virtio-blk-pci */ +static void *qvhost_user_blk_pci_get_driver(void *object, const char *inte= rface) +{ + QVhostUserBlkPCI *v_blk =3D object; + if (!g_strcmp0(interface, "pci-device")) { + return v_blk->pci_vdev.pdev; + } + return qvhost_user_blk_get_driver(&v_blk->blk, interface); +} + +static void *vhost_user_blk_pci_create(void *pci_bus, QGuestAllocator *t_a= lloc, + void *addr) +{ + QVhostUserBlkPCI *vhost_user_blk =3D g_new0(QVhostUserBlkPCI, 1); + QVhostUserBlk *interface =3D &vhost_user_blk->blk; + QOSGraphObject *obj =3D &vhost_user_blk->pci_vdev.obj; + + virtio_pci_init(&vhost_user_blk->pci_vdev, pci_bus, addr); + interface->vdev =3D &vhost_user_blk->pci_vdev.vdev; + + g_assert_cmphex(interface->vdev->device_type, =3D=3D, VIRTIO_ID_BLOCK); + + obj->get_driver =3D qvhost_user_blk_pci_get_driver; + + return obj; +} + +static void vhost_user_blk_register_nodes(void) +{ + /* + * FIXME: every test using these two nodes needs to setup a + * -drive,id=3Ddrive0 otherwise QEMU is not going to start. + * Therefore, we do not include "produces" edge for virtio + * and pci-device yet. + */ + + char *arg =3D g_strdup_printf("id=3Ddrv0,chardev=3Dchar1,addr=3D%x.%x", + PCI_SLOT, PCI_FN); + + QPCIAddress addr =3D { + .devfn =3D QPCI_DEVFN(PCI_SLOT, PCI_FN), + }; + + QOSGraphEdgeOptions opts =3D { }; + + /* virtio-blk-device */ + /** opts.extra_device_opts =3D "drive=3Ddrive0"; */ + qos_node_create_driver("vhost-user-blk-device", + vhost_user_blk_device_create); + qos_node_consumes("vhost-user-blk-device", "virtio-bus", &opts); + qos_node_produces("vhost-user-blk-device", "vhost-user-blk"); + + /* virtio-blk-pci */ + opts.extra_device_opts =3D arg; + add_qpci_address(&opts, &addr); + qos_node_create_driver("vhost-user-blk-pci", vhost_user_blk_pci_create= ); + qos_node_consumes("vhost-user-blk-pci", "pci-bus", &opts); + qos_node_produces("vhost-user-blk-pci", "vhost-user-blk"); + + g_free(arg); +} + +libqos_init(vhost_user_blk_register_nodes); diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c new file mode 100644 index 0000000000..f0fb09893e --- /dev/null +++ b/tests/qtest/vhost-user-blk-test.c @@ -0,0 +1,788 @@ +/* + * QTest testcase for Vhost-user Block Device + * + * Based on tests/qtest//virtio-blk-test.c + + * Copyright (c) 2014 SUSE LINUX Products GmbH + * Copyright (c) 2014 Marc Mar=C3=AD + * Copyright (c) 2020 Coiby Xu + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "libqtest-single.h" +#include "qemu/bswap.h" +#include "qemu/module.h" +#include "standard-headers/linux/virtio_blk.h" +#include "standard-headers/linux/virtio_pci.h" +#include "libqos/qgraph.h" +#include "libqos/vhost-user-blk.h" +#include "libqos/libqos-pc.h" + +#define TEST_IMAGE_SIZE (64 * 1024 * 1024) +#define QVIRTIO_BLK_TIMEOUT_US (30 * 1000 * 1000) +#define PCI_SLOT_HP 0x06 + +typedef struct { + pid_t pid; +} QemuStorageDaemonState; + +typedef struct QVirtioBlkReq { + uint32_t type; + uint32_t ioprio; + uint64_t sector; + char *data; + uint8_t status; +} QVirtioBlkReq; + +#ifdef HOST_WORDS_BIGENDIAN +static const bool host_is_big_endian =3D true; +#else +static const bool host_is_big_endian; /* false */ +#endif + +static inline void virtio_blk_fix_request(QVirtioDevice *d, QVirtioBlkReq = *req) +{ + if (qvirtio_is_big_endian(d) !=3D host_is_big_endian) { + req->type =3D bswap32(req->type); + req->ioprio =3D bswap32(req->ioprio); + req->sector =3D bswap64(req->sector); + } +} + +static inline void virtio_blk_fix_dwz_hdr(QVirtioDevice *d, + struct virtio_blk_discard_write_zeroes *dwz_hdr) +{ + if (qvirtio_is_big_endian(d) !=3D host_is_big_endian) { + dwz_hdr->sector =3D bswap64(dwz_hdr->sector); + dwz_hdr->num_sectors =3D bswap32(dwz_hdr->num_sectors); + dwz_hdr->flags =3D bswap32(dwz_hdr->flags); + } +} + +static uint64_t virtio_blk_request(QGuestAllocator *alloc, QVirtioDevice *= d, + QVirtioBlkReq *req, uint64_t data_size) +{ + uint64_t addr; + uint8_t status =3D 0xFF; + QTestState *qts =3D global_qtest; + + switch (req->type) { + case VIRTIO_BLK_T_IN: + case VIRTIO_BLK_T_OUT: + g_assert_cmpuint(data_size % 512, =3D=3D, 0); + break; + case VIRTIO_BLK_T_DISCARD: + case VIRTIO_BLK_T_WRITE_ZEROES: + g_assert_cmpuint(data_size % + sizeof(struct virtio_blk_discard_write_zeroes), = =3D=3D, 0); + break; + default: + g_assert_cmpuint(data_size, =3D=3D, 0); + } + + addr =3D guest_alloc(alloc, sizeof(*req) + data_size); + + virtio_blk_fix_request(d, req); + + qtest_memwrite(qts, addr, req, 16); + qtest_memwrite(qts, addr + 16, req->data, data_size); + qtest_memwrite(qts, addr + 16 + data_size, &status, sizeof(status)); + + return addr; +} + +/* Returns the request virtqueue so the caller can perform further tests */ +static QVirtQueue *test_basic(QVirtioDevice *dev, QGuestAllocator *alloc) +{ + QVirtioBlkReq req; + uint64_t req_addr; + uint64_t capacity; + uint64_t features; + uint32_t free_head; + uint8_t status; + char *data; + QTestState *qts =3D global_qtest; + QVirtQueue *vq; + + features =3D qvirtio_get_features(dev); + features =3D features & ~(QVIRTIO_F_BAD_FEATURE | + (1u << VIRTIO_RING_F_INDIRECT_DESC) | + (1u << VIRTIO_RING_F_EVENT_IDX) | + (1u << VIRTIO_BLK_F_SCSI)); + qvirtio_set_features(dev, features); + + capacity =3D qvirtio_config_readq(dev, 0); + g_assert_cmpint(capacity, =3D=3D, TEST_IMAGE_SIZE / 512); + + vq =3D qvirtqueue_setup(dev, alloc, 0); + + qvirtio_set_driver_ok(dev); + + /* Write and read with 3 descriptor layout */ + /* Write request */ + req.type =3D VIRTIO_BLK_T_OUT; + req.ioprio =3D 1; + req.sector =3D 0; + req.data =3D g_malloc0(512); + strcpy(req.data, "TEST"); + + req_addr =3D virtio_blk_request(alloc, dev, &req, 512); + + g_free(req.data); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, false, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + guest_free(alloc, req_addr); + + /* Read request */ + req.type =3D VIRTIO_BLK_T_IN; + req.ioprio =3D 1; + req.sector =3D 0; + req.data =3D g_malloc0(512); + + req_addr =3D virtio_blk_request(alloc, dev, &req, 512); + + g_free(req.data); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, true, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + data =3D g_malloc0(512); + qtest_memread(qts, req_addr + 16, data, 512); + g_assert_cmpstr(data, =3D=3D, "TEST"); + g_free(data); + + guest_free(alloc, req_addr); + + if (features & (1u << VIRTIO_BLK_F_WRITE_ZEROES)) { + struct virtio_blk_discard_write_zeroes dwz_hdr; + void *expected; + + /* + * WRITE_ZEROES request on the same sector of previous test where + * we wrote "TEST". + */ + req.type =3D VIRTIO_BLK_T_WRITE_ZEROES; + req.data =3D (char *) &dwz_hdr; + dwz_hdr.sector =3D 0; + dwz_hdr.num_sectors =3D 1; + dwz_hdr.flags =3D 0; + + virtio_blk_fix_dwz_hdr(dev, &dwz_hdr); + + req_addr =3D virtio_blk_request(alloc, dev, &req, sizeof(dwz_hdr)); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, sizeof(dwz_hdr), false, tru= e); + qvirtqueue_add(qts, vq, req_addr + 16 + sizeof(dwz_hdr), 1, true, + false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 16 + sizeof(dwz_hdr)); + g_assert_cmpint(status, =3D=3D, 0); + + guest_free(alloc, req_addr); + + /* Read request to check if the sector contains all zeroes */ + req.type =3D VIRTIO_BLK_T_IN; + req.ioprio =3D 1; + req.sector =3D 0; + req.data =3D g_malloc0(512); + + req_addr =3D virtio_blk_request(alloc, dev, &req, 512); + + g_free(req.data); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, true, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + data =3D g_malloc(512); + expected =3D g_malloc0(512); + qtest_memread(qts, req_addr + 16, data, 512); + g_assert_cmpmem(data, 512, expected, 512); + g_free(expected); + g_free(data); + + guest_free(alloc, req_addr); + } + + if (features & (1u << VIRTIO_BLK_F_DISCARD)) { + struct virtio_blk_discard_write_zeroes dwz_hdr; + + req.type =3D VIRTIO_BLK_T_DISCARD; + req.data =3D (char *) &dwz_hdr; + dwz_hdr.sector =3D 0; + dwz_hdr.num_sectors =3D 1; + dwz_hdr.flags =3D 0; + + virtio_blk_fix_dwz_hdr(dev, &dwz_hdr); + + req_addr =3D virtio_blk_request(alloc, dev, &req, sizeof(dwz_hdr)); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, sizeof(dwz_hdr), false, tru= e); + qvirtqueue_add(qts, vq, req_addr + 16 + sizeof(dwz_hdr), + 1, true, false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 16 + sizeof(dwz_hdr)); + g_assert_cmpint(status, =3D=3D, 0); + + guest_free(alloc, req_addr); + } + + if (features & (1u << VIRTIO_F_ANY_LAYOUT)) { + /* Write and read with 2 descriptor layout */ + /* Write request */ + req.type =3D VIRTIO_BLK_T_OUT; + req.ioprio =3D 1; + req.sector =3D 1; + req.data =3D g_malloc0(512); + strcpy(req.data, "TEST"); + + req_addr =3D virtio_blk_request(alloc, dev, &req, 512); + + g_free(req.data); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 528, false, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + guest_free(alloc, req_addr); + + /* Read request */ + req.type =3D VIRTIO_BLK_T_IN; + req.ioprio =3D 1; + req.sector =3D 1; + req.data =3D g_malloc0(512); + + req_addr =3D virtio_blk_request(alloc, dev, &req, 512); + + g_free(req.data); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 513, true, false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + data =3D g_malloc0(512); + qtest_memread(qts, req_addr + 16, data, 512); + g_assert_cmpstr(data, =3D=3D, "TEST"); + g_free(data); + + guest_free(alloc, req_addr); + } + + return vq; +} + +static void basic(void *obj, void *data, QGuestAllocator *t_alloc) +{ + QVhostUserBlk *blk_if =3D obj; + QVirtQueue *vq; + + vq =3D test_basic(blk_if->vdev, t_alloc); + qvirtqueue_cleanup(blk_if->vdev->bus, vq, t_alloc); + +} + +static void indirect(void *obj, void *u_data, QGuestAllocator *t_alloc) +{ + QVirtQueue *vq; + QVhostUserBlk *blk_if =3D obj; + QVirtioDevice *dev =3D blk_if->vdev; + QVirtioBlkReq req; + QVRingIndirectDesc *indirect; + uint64_t req_addr; + uint64_t capacity; + uint64_t features; + uint32_t free_head; + uint8_t status; + char *data; + QTestState *qts =3D global_qtest; + + features =3D qvirtio_get_features(dev); + g_assert_cmphex(features & (1u << VIRTIO_RING_F_INDIRECT_DESC), !=3D, = 0); + features =3D features & ~(QVIRTIO_F_BAD_FEATURE | + (1u << VIRTIO_RING_F_EVENT_IDX) | + (1u << VIRTIO_BLK_F_SCSI)); + qvirtio_set_features(dev, features); + + capacity =3D qvirtio_config_readq(dev, 0); + g_assert_cmpint(capacity, =3D=3D, TEST_IMAGE_SIZE / 512); + + vq =3D qvirtqueue_setup(dev, t_alloc, 0); + qvirtio_set_driver_ok(dev); + + /* Write request */ + req.type =3D VIRTIO_BLK_T_OUT; + req.ioprio =3D 1; + req.sector =3D 0; + req.data =3D g_malloc0(512); + strcpy(req.data, "TEST"); + + req_addr =3D virtio_blk_request(t_alloc, dev, &req, 512); + + g_free(req.data); + + indirect =3D qvring_indirect_desc_setup(qts, dev, t_alloc, 2); + qvring_indirect_desc_add(dev, qts, indirect, req_addr, 528, false); + qvring_indirect_desc_add(dev, qts, indirect, req_addr + 528, 1, true); + free_head =3D qvirtqueue_add_indirect(qts, vq, indirect); + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + g_free(indirect); + guest_free(t_alloc, req_addr); + + /* Read request */ + req.type =3D VIRTIO_BLK_T_IN; + req.ioprio =3D 1; + req.sector =3D 0; + req.data =3D g_malloc0(512); + strcpy(req.data, "TEST"); + + req_addr =3D virtio_blk_request(t_alloc, dev, &req, 512); + + g_free(req.data); + + indirect =3D qvring_indirect_desc_setup(qts, dev, t_alloc, 2); + qvring_indirect_desc_add(dev, qts, indirect, req_addr, 16, false); + qvring_indirect_desc_add(dev, qts, indirect, req_addr + 16, 513, true); + free_head =3D qvirtqueue_add_indirect(qts, vq, indirect); + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + data =3D g_malloc0(512); + qtest_memread(qts, req_addr + 16, data, 512); + g_assert_cmpstr(data, =3D=3D, "TEST"); + g_free(data); + + g_free(indirect); + guest_free(t_alloc, req_addr); + qvirtqueue_cleanup(dev->bus, vq, t_alloc); +} + +static void idx(void *obj, void *u_data, QGuestAllocator *t_alloc) +{ + QVirtQueue *vq; + QVhostUserBlkPCI *blk =3D obj; + QVirtioPCIDevice *pdev =3D &blk->pci_vdev; + QVirtioDevice *dev =3D &pdev->vdev; + QVirtioBlkReq req; + uint64_t req_addr; + uint64_t capacity; + uint64_t features; + uint32_t free_head; + uint32_t write_head; + uint32_t desc_idx; + uint8_t status; + char *data; + QOSGraphObject *blk_object =3D obj; + QPCIDevice *pci_dev =3D blk_object->get_driver(blk_object, "pci-device= "); + QTestState *qts =3D global_qtest; + + if (qpci_check_buggy_msi(pci_dev)) { + return; + } + + qpci_msix_enable(pdev->pdev); + qvirtio_pci_set_msix_configuration_vector(pdev, t_alloc, 0); + + features =3D qvirtio_get_features(dev); + features =3D features & ~(QVIRTIO_F_BAD_FEATURE | + (1u << VIRTIO_RING_F_INDIRECT_DESC) | + (1u << VIRTIO_F_NOTIFY_ON_EMPTY) | + (1u << VIRTIO_BLK_F_SCSI)); + qvirtio_set_features(dev, features); + + capacity =3D qvirtio_config_readq(dev, 0); + g_assert_cmpint(capacity, =3D=3D, TEST_IMAGE_SIZE / 512); + + vq =3D qvirtqueue_setup(dev, t_alloc, 0); + qvirtqueue_pci_msix_setup(pdev, (QVirtQueuePCI *)vq, t_alloc, 1); + + qvirtio_set_driver_ok(dev); + + /* Write request */ + req.type =3D VIRTIO_BLK_T_OUT; + req.ioprio =3D 1; + req.sector =3D 0; + req.data =3D g_malloc0(512); + strcpy(req.data, "TEST"); + + req_addr =3D virtio_blk_request(t_alloc, dev, &req, 512); + + g_free(req.data); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, false, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + + /* Write request */ + req.type =3D VIRTIO_BLK_T_OUT; + req.ioprio =3D 1; + req.sector =3D 1; + req.data =3D g_malloc0(512); + strcpy(req.data, "TEST"); + + req_addr =3D virtio_blk_request(t_alloc, dev, &req, 512); + + g_free(req.data); + + /* Notify after processing the third request */ + qvirtqueue_set_used_event(qts, vq, 2); + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, false, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + qvirtqueue_kick(qts, dev, vq, free_head); + write_head =3D free_head; + + /* No notification expected */ + status =3D qvirtio_wait_status_byte_no_isr(qts, dev, + vq, req_addr + 528, + QVIRTIO_BLK_TIMEOUT_US); + g_assert_cmpint(status, =3D=3D, 0); + + guest_free(t_alloc, req_addr); + + /* Read request */ + req.type =3D VIRTIO_BLK_T_IN; + req.ioprio =3D 1; + req.sector =3D 1; + req.data =3D g_malloc0(512); + + req_addr =3D virtio_blk_request(t_alloc, dev, &req, 512); + + g_free(req.data); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, true, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + /* We get just one notification for both requests */ + qvirtio_wait_used_elem(qts, dev, vq, write_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + g_assert(qvirtqueue_get_buf(qts, vq, &desc_idx, NULL)); + g_assert_cmpint(desc_idx, =3D=3D, free_head); + + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + data =3D g_malloc0(512); + qtest_memread(qts, req_addr + 16, data, 512); + g_assert_cmpstr(data, =3D=3D, "TEST"); + g_free(data); + + guest_free(t_alloc, req_addr); + + /* End test */ + qpci_msix_disable(pdev->pdev); + + qvirtqueue_cleanup(dev->bus, vq, t_alloc); +} + +static void pci_hotplug(void *obj, void *data, QGuestAllocator *t_alloc) +{ + QVirtioPCIDevice *dev1 =3D obj; + QVirtioPCIDevice *dev; + QTestState *qts =3D dev1->pdev->bus->qts; + + /* plug secondary disk */ + qtest_qmp_device_add(qts, "vhost-user-blk-pci", "drv1", + "{'addr': %s, 'chardev': 'char2'}", + stringify(PCI_SLOT_HP) ".0"); + + dev =3D virtio_pci_new(dev1->pdev->bus, + &(QPCIAddress) { .devfn =3D QPCI_DEVFN(PCI_SLOT_H= P, 0) + }); + g_assert_nonnull(dev); + g_assert_cmpint(dev->vdev.device_type, =3D=3D, VIRTIO_ID_BLOCK); + qvirtio_pci_device_disable(dev); + qos_object_destroy((QOSGraphObject *)dev); + + /* unplug secondary disk */ + qpci_unplug_acpi_device_test(qts, "drv1", PCI_SLOT_HP); +} + +/* + * Check that setting the vring addr on a non-existent virtqueue does + * not crash. + */ +static void test_nonexistent_virtqueue(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + QVhostUserBlkPCI *blk =3D obj; + QVirtioPCIDevice *pdev =3D &blk->pci_vdev; + QPCIBar bar0; + QPCIDevice *dev; + + dev =3D qpci_device_find(pdev->pdev->bus, QPCI_DEVFN(4, 0)); + g_assert(dev !=3D NULL); + qpci_device_enable(dev); + + bar0 =3D qpci_iomap(dev, 0, NULL); + + qpci_io_writeb(dev, bar0, VIRTIO_PCI_QUEUE_SEL, 2); + qpci_io_writel(dev, bar0, VIRTIO_PCI_QUEUE_PFN, 1); + + g_free(dev); +} + +static const char *qtest_qemu_storage_daemon_binary(void) +{ + const char *qemu_storage_daemon_bin; + + qemu_storage_daemon_bin =3D getenv("QTEST_QEMU_STORAGE_DAEMON_BINARY"); + if (!qemu_storage_daemon_bin) { + fprintf(stderr, "Environment variable " + "QTEST_QEMU_STORAGE_DAEMON_BINARY required\n"); + exit(0); + } + + return qemu_storage_daemon_bin; +} + +/* g_test_queue_destroy() cleanup function for files */ +static void destroy_file(void *path) +{ + unlink(path); + g_free(path); + qos_invalidate_command_line(); +} + +static char *drive_create(void) +{ + int fd, ret; + /** vhost-user-blk won't recognize drive located in /tmp */ + char *t_path =3D g_strdup("qtest.XXXXXX"); + + /** Create a temporary raw image */ + fd =3D mkstemp(t_path); + g_assert_cmpint(fd, >=3D, 0); + ret =3D ftruncate(fd, TEST_IMAGE_SIZE); + g_assert_cmpint(ret, =3D=3D, 0); + close(fd); + + g_test_queue_destroy(destroy_file, t_path); + return t_path; +} + +static char *create_listen_socket(int *fd) +{ + int tmp_fd; + char *path; + + /* No race because our pid makes the path unique */ + path =3D g_strdup_printf("/tmp/qtest-%d-sock.XXXXXX", getpid()); + tmp_fd =3D mkstemp(path); + g_assert_cmpint(tmp_fd, >=3D, 0); + close(tmp_fd); + unlink(path); + + *fd =3D qtest_socket_server(path); + g_test_queue_destroy(destroy_file, path); + return path; +} + +/* + * g_test_queue_destroy() and qtest_add_abrt_handler() cleanup function for + * qemu-storage-daemon. + */ +static void quit_storage_daemon(void *data) +{ + QemuStorageDaemonState *qsd =3D data; + int wstatus; + pid_t pid; + + /* + * If we were invoked as a g_test_queue_destroy() cleanup function we = need + * to remove the abrt handler to avoid being called again if the code = below + * aborts. Also, we must not leave the abrt handler installed after + * cleanup. + */ + qtest_remove_abrt_handler(data); + + /* Before quitting storage-daemon, quit qemu to avoid dubious messages= */ + qtest_kill_qemu(global_qtest); + + kill(qsd->pid, SIGTERM); + pid =3D waitpid(qsd->pid, &wstatus, 0); + g_assert_cmpint(pid, =3D=3D, qsd->pid); + if (!WIFEXITED(wstatus)) { + fprintf(stderr, "%s: expected qemu-storage-daemon to exit\n", + __func__); + abort(); + } + if (WEXITSTATUS(wstatus) !=3D 0) { + fprintf(stderr, "%s: expected qemu-storage-daemon to exit " + "successfully, got %d\n", + __func__, WEXITSTATUS(wstatus)); + abort(); + } + + g_free(data); +} + +static void start_vhost_user_blk(GString *cmd_line, int vus_instances) +{ + const char *vhost_user_blk_bin =3D qtest_qemu_storage_daemon_binary(); + int i; + gchar *img_path; + GString *storage_daemon_command =3D g_string_new(NULL); + QemuStorageDaemonState *qsd; + + g_string_append_printf(storage_daemon_command, + "exec %s ", + vhost_user_blk_bin); + + g_string_append_printf(cmd_line, + " -object memory-backend-memfd,id=3Dmem,size=3D256M,share=3Don= " + " -M memory-backend=3Dmem -m 256M "); + + for (i =3D 0; i < vus_instances; i++) { + int fd; + char *sock_path =3D create_listen_socket(&fd); + + /* create image file */ + img_path =3D drive_create(); + g_string_append_printf(storage_daemon_command, + "--blockdev driver=3Dfile,node-name=3Ddisk%d,filename=3D%s " + "--export type=3Dvhost-user-blk,id=3Ddisk%d,addr.type=3Dunix,a= ddr.path=3D%s," + "node-name=3Ddisk%i,writable=3Don ", + i, img_path, i, sock_path, i); + + g_string_append_printf(cmd_line, "-chardev socket,id=3Dchar%d,path= =3D%s ", + i + 1, sock_path); + } + + g_test_message("starting vhost-user backend: %s", + storage_daemon_command->str); + pid_t pid =3D fork(); + if (pid =3D=3D 0) { + /* + * Close standard file descriptors so tap-driver.pl pipe detects w= hen + * our parent terminates. + */ + close(0); + close(1); + open("/dev/null", O_RDONLY); + open("/dev/null", O_WRONLY); + + execlp("/bin/sh", "sh", "-c", storage_daemon_command->str, NULL); + exit(1); + } + g_string_free(storage_daemon_command, true); + + qsd =3D g_new(QemuStorageDaemonState, 1); + qsd->pid =3D pid; + + /* Make sure qemu-storage-daemon is stopped */ + qtest_add_abrt_handler(quit_storage_daemon, qsd); + g_test_queue_destroy(quit_storage_daemon, qsd); +} + +static void *vhost_user_blk_test_setup(GString *cmd_line, void *arg) +{ + start_vhost_user_blk(cmd_line, 1); + return arg; +} + +/* + * Setup for hotplug. + * + * Since vhost-user server only serves one vhost-user client one time, + * another exprot + * + */ +static void *vhost_user_blk_hotplug_test_setup(GString *cmd_line, void *ar= g) +{ + /* "-chardev socket,id=3Dchar2" is used for pci_hotplug*/ + start_vhost_user_blk(cmd_line, 2); + return arg; +} + +static void register_vhost_user_blk_test(void) +{ + QOSGraphTestOptions opts =3D { + .before =3D vhost_user_blk_test_setup, + }; + + /* + * tests for vhost-user-blk and vhost-user-blk-pci + * The tests are borrowed from tests/virtio-blk-test.c. But some tests + * regarding block_resize don't work for vhost-user-blk. + * vhost-user-blk device doesn't have -drive, so tests containing + * block_resize are also abandoned, + * - config + * - resize + */ + qos_add_test("basic", "vhost-user-blk", basic, &opts); + qos_add_test("indirect", "vhost-user-blk", indirect, &opts); + qos_add_test("idx", "vhost-user-blk-pci", idx, &opts); + qos_add_test("nxvirtq", "vhost-user-blk-pci", + test_nonexistent_virtqueue, &opts); + + opts.before =3D vhost_user_blk_hotplug_test_setup; + qos_add_test("hotplug", "vhost-user-blk-pci", pci_hotplug, &opts); +} + +libqos_init(register_vhost_user_blk_test); diff --git a/MAINTAINERS b/MAINTAINERS index 26c9454823..4249acc62e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3203,6 +3203,8 @@ F: block/export/vhost-user-blk-server.c F: block/export/vhost-user-blk-server.h F: include/qemu/vhost-user-server.h F: tests/qtest/libqos/vhost-user-blk.c +F: tests/qtest/libqos/vhost-user-blk.h +F: tests/qtest/vhost-user-blk-test.c F: util/vhost-user-server.c =20 FUSE block device exports diff --git a/tests/qtest/libqos/meson.build b/tests/qtest/libqos/meson.build index 1cddf5bdaa..1f5c8f1053 100644 --- a/tests/qtest/libqos/meson.build +++ b/tests/qtest/libqos/meson.build @@ -32,6 +32,7 @@ libqos_srcs =3D files('../libqtest.c', 'virtio-9p.c', 'virtio-balloon.c', 'virtio-blk.c', + 'vhost-user-blk.c', 'virtio-mmio.c', 'virtio-net.c', 'virtio-pci.c', diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index ba6ecaed32..1aeaf58d96 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -210,6 +210,9 @@ if have_virtfs qos_test_ss.add(files('virtio-9p-test.c')) endif qos_test_ss.add(when: 'CONFIG_VHOST_USER', if_true: files('vhost-user-test= .c')) +if have_vhost_user_blk_server + qos_test_ss.add(files('vhost-user-blk-test.c')) +endif =20 tpmemu_files =3D ['tpm-emu.c', 'tpm-util.c', 'tpm-tests.c'] =20 @@ -248,6 +251,7 @@ foreach dir : target_dirs endif qtest_env.set('G_TEST_DBUS_DAEMON', meson.source_root() / 'tests/dbus-vm= state-daemon.sh') qtest_env.set('QTEST_QEMU_BINARY', './qemu-system-' + target_base) + qtest_env.set('QTEST_QEMU_STORAGE_DAEMON_BINARY', './storage-daemon/qemu= -storage-daemon') =20 foreach test : target_qtests # Executables are shared across targets, declare them only the first t= ime we --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614963776; cv=none; d=zohomail.com; s=zohoarc; b=kBEPf1m0P8KMwV6f859Aw1N//ia9d1uUy+r3QstofTS1ODsvrUTQY7QdOt9RCra18LwF1758G/0fOMVsEEPDpRwzmY3R7ryTe4siDVyA0doa9Av9bUKRWAg6rz8aAhk8CXYy5S8RMdFE3YK2K0M/V3SObuFkPHwT8+uGc92kVKA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614963776; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pTPBH2dCtN388X/Wnwa0fO66b9FOLPf59TK8XH6wKpM=; b=N+9+YETtucTAZoNMvQXD6gJIsAkz0rQHquKI0XzXPdayuI4qgGQbO5XSs5qJtloF89B3DBLMPQ8pXsR7bhaDyHvvEAYK8q3hJ/wCaJxD12JOIgTcN51KJiyNLxATU3h56ldUNSantH+ux+mXuPBbY1AqDxTPo18RtIFoLnd8C2A= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614963776935868.9016915807712; Fri, 5 Mar 2021 09:02:56 -0800 (PST) Received: from localhost ([::1]:55246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIDqp-000586-Nv for importer@patchew.org; Fri, 05 Mar 2021 12:02:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:32826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkJ-0006wA-3u for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:11 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50637) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDk5-0007Cw-BA for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:10 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-291-h2hgwnkdMZmXLv1Q9yKJng-1; Fri, 05 Mar 2021 11:55:54 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E9E33DF8DB; Fri, 5 Mar 2021 16:55:30 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCE9D60C66; Fri, 5 Mar 2021 16:55:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963356; 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=pTPBH2dCtN388X/Wnwa0fO66b9FOLPf59TK8XH6wKpM=; b=KYwPafuo88HN0DKsQCZQDUjmEFa8N3DlAqpT9SMelAFysIhd6AhWZG9ZbCoXH/vS4masnC 34wSRpsZmYCN6NbVnkuS1R+1rcGfuAR30IBleEDsSwT9ydaWF+2u7M/VrbBLy3ke/hnblO YYFFz3zlU2B8F1huK/w8C4K0f5ErYro= X-MC-Unique: h2hgwnkdMZmXLv1Q9yKJng-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 17/31] tests/qtest: add multi-queue test case to vhost-user-blk-test Date: Fri, 5 Mar 2021 17:54:40 +0100 Message-Id: <20210305165454.356840-18-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Signed-off-by: Stefan Hajnoczi Message-Id: <20210223144653.811468-7-stefanha@redhat.com> Signed-off-by: Kevin Wolf --- tests/qtest/vhost-user-blk-test.c | 81 +++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 5 deletions(-) diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c index f0fb09893e..61beee52d3 100644 --- a/tests/qtest/vhost-user-blk-test.c +++ b/tests/qtest/vhost-user-blk-test.c @@ -563,6 +563,67 @@ static void pci_hotplug(void *obj, void *data, QGuestA= llocator *t_alloc) qpci_unplug_acpi_device_test(qts, "drv1", PCI_SLOT_HP); } =20 +static void multiqueue(void *obj, void *data, QGuestAllocator *t_alloc) +{ + QVirtioPCIDevice *pdev1 =3D obj; + QVirtioDevice *dev1 =3D &pdev1->vdev; + QVirtioPCIDevice *pdev8; + QVirtioDevice *dev8; + QTestState *qts =3D pdev1->pdev->bus->qts; + uint64_t features; + uint16_t num_queues; + + /* + * The primary device has 1 queue and VIRTIO_BLK_F_MQ is not enabled. = The + * VIRTIO specification allows VIRTIO_BLK_F_MQ to be enabled when ther= e is + * only 1 virtqueue, but --device vhost-user-blk-pci doesn't do this (= which + * is also spec-compliant). + */ + features =3D qvirtio_get_features(dev1); + g_assert_cmpint(features & (1u << VIRTIO_BLK_F_MQ), =3D=3D, 0); + features =3D features & ~(QVIRTIO_F_BAD_FEATURE | + (1u << VIRTIO_RING_F_INDIRECT_DESC) | + (1u << VIRTIO_F_NOTIFY_ON_EMPTY) | + (1u << VIRTIO_BLK_F_SCSI)); + qvirtio_set_features(dev1, features); + + /* Hotplug a secondary device with 8 queues */ + qtest_qmp_device_add(qts, "vhost-user-blk-pci", "drv1", + "{'addr': %s, 'chardev': 'char2', 'num-queues': 8= }", + stringify(PCI_SLOT_HP) ".0"); + + pdev8 =3D virtio_pci_new(pdev1->pdev->bus, + &(QPCIAddress) { + .devfn =3D QPCI_DEVFN(PCI_SLOT_HP, 0) + }); + g_assert_nonnull(pdev8); + g_assert_cmpint(pdev8->vdev.device_type, =3D=3D, VIRTIO_ID_BLOCK); + + qos_object_start_hw(&pdev8->obj); + + dev8 =3D &pdev8->vdev; + features =3D qvirtio_get_features(dev8); + g_assert_cmpint(features & (1u << VIRTIO_BLK_F_MQ), + =3D=3D, + (1u << VIRTIO_BLK_F_MQ)); + features =3D features & ~(QVIRTIO_F_BAD_FEATURE | + (1u << VIRTIO_RING_F_INDIRECT_DESC) | + (1u << VIRTIO_F_NOTIFY_ON_EMPTY) | + (1u << VIRTIO_BLK_F_SCSI) | + (1u << VIRTIO_BLK_F_MQ)); + qvirtio_set_features(dev8, features); + + num_queues =3D qvirtio_config_readw(dev8, + offsetof(struct virtio_blk_config, num_queues)); + g_assert_cmpint(num_queues, =3D=3D, 8); + + qvirtio_pci_device_disable(pdev8); + qos_object_destroy(&pdev8->obj); + + /* unplug secondary disk */ + qpci_unplug_acpi_device_test(qts, "drv1", PCI_SLOT_HP); +} + /* * Check that setting the vring addr on a non-existent virtqueue does * not crash. @@ -682,7 +743,8 @@ static void quit_storage_daemon(void *data) g_free(data); } =20 -static void start_vhost_user_blk(GString *cmd_line, int vus_instances) +static void start_vhost_user_blk(GString *cmd_line, int vus_instances, + int num_queues) { const char *vhost_user_blk_bin =3D qtest_qemu_storage_daemon_binary(); int i; @@ -707,8 +769,8 @@ static void start_vhost_user_blk(GString *cmd_line, int= vus_instances) g_string_append_printf(storage_daemon_command, "--blockdev driver=3Dfile,node-name=3Ddisk%d,filename=3D%s " "--export type=3Dvhost-user-blk,id=3Ddisk%d,addr.type=3Dunix,a= ddr.path=3D%s," - "node-name=3Ddisk%i,writable=3Don ", - i, img_path, i, sock_path, i); + "node-name=3Ddisk%i,writable=3Don,num-queues=3D%d ", + i, img_path, i, sock_path, i, num_queues); =20 g_string_append_printf(cmd_line, "-chardev socket,id=3Dchar%d,path= =3D%s ", i + 1, sock_path); @@ -742,7 +804,7 @@ static void start_vhost_user_blk(GString *cmd_line, int= vus_instances) =20 static void *vhost_user_blk_test_setup(GString *cmd_line, void *arg) { - start_vhost_user_blk(cmd_line, 1); + start_vhost_user_blk(cmd_line, 1, 1); return arg; } =20 @@ -756,7 +818,13 @@ static void *vhost_user_blk_test_setup(GString *cmd_li= ne, void *arg) static void *vhost_user_blk_hotplug_test_setup(GString *cmd_line, void *ar= g) { /* "-chardev socket,id=3Dchar2" is used for pci_hotplug*/ - start_vhost_user_blk(cmd_line, 2); + start_vhost_user_blk(cmd_line, 2, 1); + return arg; +} + +static void *vhost_user_blk_multiqueue_test_setup(GString *cmd_line, void = *arg) +{ + start_vhost_user_blk(cmd_line, 2, 8); return arg; } =20 @@ -783,6 +851,9 @@ static void register_vhost_user_blk_test(void) =20 opts.before =3D vhost_user_blk_hotplug_test_setup; qos_add_test("hotplug", "vhost-user-blk-pci", pci_hotplug, &opts); + + opts.before =3D vhost_user_blk_multiqueue_test_setup; + qos_add_test("multiqueue", "vhost-user-blk-pci", multiqueue, &opts); } =20 libqos_init(register_vhost_user_blk_test); --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614965078; cv=none; d=zohomail.com; s=zohoarc; b=bDI1TWB5Ul6hUsodw8QMb+1rRk2pyLSp7rXqTiDy1eQKkBnywNqTaPwolJGbq4Ypt5Tp30kWDHDeYTBg2jikJaJZHiBXZ5Q7VmDOc91TnfvftuO5gFl85XZoLPsMkuAWMNTAGjAf6iL88VR9RB6HcGiUscYE2JBULCTOE/a6c3g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614965078; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HwpQ4G9rUCVn5Vuq90w3hYXqwNDwbwuvrLwMSwG27LY=; b=eC6Hmytr1xluDlf0q2db/PDpDICqkloE48IZmFF0SGgzek+dQQXwgh1TlsD0Ek4KXDPVFZK6jlZtVD5t+avGGXgceG78sjyGBkpR1OPXBxgUgPJvKIYMvQneCnOcACD2dn1oDt13E+g5tp6UR63/FJ4w99J0BRfknUaFfhtwWFw= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614965078301752.3132991732066; Fri, 5 Mar 2021 09:24:38 -0800 (PST) Received: from localhost ([::1]:60998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIEBp-0007do-89 for importer@patchew.org; Fri, 05 Mar 2021 12:24:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkX-0007Ob-Tw for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48578) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDkB-0007DW-As for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:25 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-291-ESm5hrgaN_eXjfyaoRrBtw-1; Fri, 05 Mar 2021 11:55:55 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 591471009C55; Fri, 5 Mar 2021 16:55:32 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C25360C43; Fri, 5 Mar 2021 16:55:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963357; 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=HwpQ4G9rUCVn5Vuq90w3hYXqwNDwbwuvrLwMSwG27LY=; b=fpBRJS3EOS9luYFLS+QU+DKnwEt0x9HTVTc0DUd0kNJxd+BWIVOx7+L6cSf+nutcAlpBsS 2y0yjVdd5ap5JmJS5sQoCtXjo7yv+ZpGdRTn7d6cuextS3B62jMtu7+Dausg8zRZXSeHAd vO2GQP4c9dQXXfixqW44MTs860W9Acg= X-MC-Unique: ESm5hrgaN_eXjfyaoRrBtw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 18/31] block/export: fix blk_size double byteswap Date: Fri, 5 Mar 2021 17:54:41 +0100 Message-Id: <20210305165454.356840-19-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi The config->blk_size field is little-endian. Use the native-endian blk_size variable to avoid double byteswapping. Fixes: 11f60f7eaee2630dd6fa0c3a8c49f792e46c4cf1 ("block/export: make vhost-= user-blk config space little-endian") Signed-off-by: Stefan Hajnoczi Message-Id: <20210223144653.811468-8-stefanha@redhat.com> Signed-off-by: Kevin Wolf --- block/export/vhost-user-blk-server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/export/vhost-user-blk-server.c b/block/export/vhost-user= -blk-server.c index ab2c4d44c4..7aea132f69 100644 --- a/block/export/vhost-user-blk-server.c +++ b/block/export/vhost-user-blk-server.c @@ -356,7 +356,7 @@ vu_blk_initialize_config(BlockDriverState *bs, config->num_queues =3D cpu_to_le16(num_queues); config->max_discard_sectors =3D cpu_to_le32(32768); config->max_discard_seg =3D cpu_to_le32(1); - config->discard_sector_alignment =3D cpu_to_le32(config->blk_size >> 9= ); + config->discard_sector_alignment =3D cpu_to_le32(blk_size >> 9); config->max_write_zeroes_sectors =3D cpu_to_le32(32768); config->max_write_zeroes_seg =3D cpu_to_le32(1); } --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614964063; cv=none; d=zohomail.com; s=zohoarc; b=lKI9AXyjbEJ5+SdOKiZyj+Q92Mhnw/0UjQr6vcbT+TXDvX2ZhXL+qyLCKybYCc/cClJBx6scB4F+scb9uXhN5BG26o0CJB98jqydTF0gCn8jMv1cSViVa2DtOaEOsXA6o2Edwosu3sYpCWaBrtnYRKk7d6NnFFtfAY84miVnIhU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614964063; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eet3n/021fv+L94DuLLb7j/q/JB9sGru4YNamDcBqHo=; b=KbcWN5xulk4a/kgfJtIQ7f45MuJi1RcpEiU0Nkr3kzeqx2xEbKzq9+EIQJbEgaujefY0dGni6cW3XN8Wjhp11fg8u+8j42Q6boKtkByqIiZz2XTnjA1HZZR6Dzgj6YTf0SFp1sAk2+jtGrIHLv2eoGuZRydwmo/+EqOLuD1urjw= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614964063618382.88215904643016; Fri, 5 Mar 2021 09:07:43 -0800 (PST) Received: from localhost ([::1]:44276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIDvS-0003po-Hx for importer@patchew.org; Fri, 05 Mar 2021 12:07:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:32920) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkO-00070s-8o for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49454) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDk7-0007DQ-92 for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:16 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-231-bZPzuGEjOmeHyG1viczPJA-1; Fri, 05 Mar 2021 11:55:55 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BC0ADDF8DF; Fri, 5 Mar 2021 16:55:33 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id A87F360C43; Fri, 5 Mar 2021 16:55:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963357; 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=eet3n/021fv+L94DuLLb7j/q/JB9sGru4YNamDcBqHo=; b=F9XVHRWQpimKrG0MHK654NnznR8l7TDWEIvGBaGUchYKpF7l8ST0LZZxPjzWyKwOiJbAxi 9wb/3Nw7H+Bdlqii7nxc8AFki27xF4dfBdu74qLkjiXruqkXu/7anp2aU1CecIU9qSgoqu 5pM0o9B40t5ToQqjBe9sMrsxMPRGDZg= X-MC-Unique: bZPzuGEjOmeHyG1viczPJA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 19/31] block/export: use VIRTIO_BLK_SECTOR_BITS Date: Fri, 5 Mar 2021 17:54:42 +0100 Message-Id: <20210305165454.356840-20-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Use VIRTIO_BLK_SECTOR_BITS and VIRTIO_BLK_SECTOR_SIZE when dealing with virtio-blk sector numbers. Although the values happen to be the same as BDRV_SECTOR_BITS and BDRV_SECTOR_SIZE, they are conceptually different. This makes it clearer when we are dealing with virtio-blk sector units. Use VIRTIO_BLK_SECTOR_BITS in vu_blk_initialize_config(). Later patches will use it the new constants the virtqueue request processing code path. Suggested-by: Max Reitz Signed-off-by: Stefan Hajnoczi Message-Id: <20210223144653.811468-9-stefanha@redhat.com> Signed-off-by: Kevin Wolf --- block/export/vhost-user-blk-server.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/block/export/vhost-user-blk-server.c b/block/export/vhost-user= -blk-server.c index 7aea132f69..2614a63791 100644 --- a/block/export/vhost-user-blk-server.c +++ b/block/export/vhost-user-blk-server.c @@ -20,6 +20,13 @@ #include "sysemu/block-backend.h" #include "util/block-helpers.h" =20 +/* + * Sector units are 512 bytes regardless of the + * virtio_blk_config->blk_size value. + */ +#define VIRTIO_BLK_SECTOR_BITS 9 +#define VIRTIO_BLK_SECTOR_SIZE (1ull << VIRTIO_BLK_SECTOR_BITS) + enum { VHOST_USER_BLK_NUM_QUEUES_DEFAULT =3D 1, }; @@ -347,7 +354,8 @@ vu_blk_initialize_config(BlockDriverState *bs, uint32_t blk_size, uint16_t num_queues) { - config->capacity =3D cpu_to_le64(bdrv_getlength(bs) >> BDRV_SECTOR_BIT= S); + config->capacity =3D + cpu_to_le64(bdrv_getlength(bs) >> VIRTIO_BLK_SECTOR_BITS); config->blk_size =3D cpu_to_le32(blk_size); config->size_max =3D cpu_to_le32(0); config->seg_max =3D cpu_to_le32(128 - 2); @@ -356,7 +364,8 @@ vu_blk_initialize_config(BlockDriverState *bs, config->num_queues =3D cpu_to_le16(num_queues); config->max_discard_sectors =3D cpu_to_le32(32768); config->max_discard_seg =3D cpu_to_le32(1); - config->discard_sector_alignment =3D cpu_to_le32(blk_size >> 9); + config->discard_sector_alignment =3D + cpu_to_le32(blk_size >> VIRTIO_BLK_SECTOR_BITS); config->max_write_zeroes_sectors =3D cpu_to_le32(32768); config->max_write_zeroes_seg =3D cpu_to_le32(1); } @@ -383,7 +392,7 @@ static int vu_blk_exp_create(BlockExport *exp, BlockExp= ortOptions *opts, if (vu_opts->has_logical_block_size) { logical_block_size =3D vu_opts->logical_block_size; } else { - logical_block_size =3D BDRV_SECTOR_SIZE; + logical_block_size =3D VIRTIO_BLK_SECTOR_SIZE; } check_block_size(exp->id, "logical-block-size", logical_block_size, &local_err); --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614964029; cv=none; d=zohomail.com; s=zohoarc; b=SDX46Nx4KiWdVOQu1dIe6odyax1M0B0oEPnkZwkftcyM7PQgGPQIROXmSENiGJTxzJQw+TIQA+1Vc06PNbN43KPqWU/A8ojBFX5EHdqP+298zLIi5oncPDdkfFAxM0dkRcCPtfnk4yWVzY5jOiOcuaQfomYMB3iK28G7DMHesx4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614964029; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FBSGDxhR8kl8OetMS2DbHF1PkFiO0aTawaBn66KLBdY=; b=j9JQ/rHwQl2ydUqbf+NglYdtwU835HM2DOJrGps6Oox43h3xd0iXUkFCR7QE0RYvZENDHjhcwayaaLIkz9I71jcFJuDEL9Mmz8cVYjqJmtVb1Qh4zNQ4wfqaICK0q3PTFYrzKF+0xmSD6NMQmT46mbRuEoUZTQbBgAgFgghBH94= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614964029281382.47844930914084; Fri, 5 Mar 2021 09:07:09 -0800 (PST) Received: from localhost ([::1]:41810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIDuu-0002q8-8T for importer@patchew.org; Fri, 05 Mar 2021 12:07:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60956) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkE-0006sl-Ro for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:35928) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDk3-00079m-BR for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:06 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-448-w3eR7KHtO6CEaIZQUCna-g-1; Fri, 05 Mar 2021 11:55:44 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 257711005D58; Fri, 5 Mar 2021 16:55:35 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1780260C43; Fri, 5 Mar 2021 16:55:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963349; 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=FBSGDxhR8kl8OetMS2DbHF1PkFiO0aTawaBn66KLBdY=; b=fDP3YYVDkf9nnYMyJxdB7wql7Nu6vjpKvv6EAkLScQF2PztANcPtfzxer8ykiL4uFYRvM2 eItBFoEKd+JbTaoSLb/cX+TX8I+JiR51cyealm+4EFFoRDlaT+4mB9ORQXAhGveZzBYj4t sSTdt4LWlUBGS6WqRz78atzf9VkYRt4= X-MC-Unique: w3eR7KHtO6CEaIZQUCna-g-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 20/31] block/export: fix vhost-user-blk export sector number calculation Date: Fri, 5 Mar 2021 17:54:43 +0100 Message-Id: <20210305165454.356840-21-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi The driver is supposed to honor the blk_size field but the protocol still uses 512-byte sector numbers. It is incorrect to multiply req->sector_num by blk_size. VIRTIO 1.1 5.2.5 Device Initialization says: blk_size can be read to determine the optimal sector size for the driver to use. This does not affect the units used in the protocol (always 512 bytes), but awareness of the correct value can affect performance. Fixes: 3578389bcf76c824a5d82e6586a6f0c71e56f2aa ("block/export: vhost-user = block device backend server") Signed-off-by: Stefan Hajnoczi Message-Id: <20210223144653.811468-10-stefanha@redhat.com> Signed-off-by: Kevin Wolf --- block/export/vhost-user-blk-server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/export/vhost-user-blk-server.c b/block/export/vhost-user= -blk-server.c index 2614a63791..f74796241c 100644 --- a/block/export/vhost-user-blk-server.c +++ b/block/export/vhost-user-blk-server.c @@ -144,7 +144,7 @@ static void coroutine_fn vu_blk_virtio_process_req(void= *opaque) break; } =20 - int64_t offset =3D req->sector_num * vexp->blk_size; + int64_t offset =3D req->sector_num << VIRTIO_BLK_SECTOR_BITS; QEMUIOVector qiov; if (is_write) { qemu_iovec_init_external(&qiov, out_iov, out_num); --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614964766; cv=none; d=zohomail.com; s=zohoarc; b=NOJjClpdlRL01YPEyGMGqh5bC4pvyrEmttYuE7u679yDgCpx51fnsvEvfslXjtv2/yCqIDUVCayweckKDCQSib2FIt8jybgLnKA/pNrFIHh/lizz6sYj4zsKtTorVgq0kq38IZuRJ9ZUgsAS62vcbapoSvEG+m4ViE9QzvwyNiY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614964766; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mNzsHHIx58+QMBheKHkUuCRnL0/BzmGRxjdvJTaEdQU=; b=NQ11l+KGFJdWtkK5mU4S4WfmmkPwnBYaIf99I4ckHq1yCI2N5t+031dAsjhEQnVC1cBzc0EcCWsh8oOmblDiVYWhl9W6ZbEg/ZB5VsAF9l8YblZk4bzz1xNJZGMLs0wtfXMn5Uh1g+JN7GOE60JzV2Igi4rGH+FrSXE4OsYyRhA= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614964766428971.4229880294166; Fri, 5 Mar 2021 09:19:26 -0800 (PST) Received: from localhost ([::1]:48166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIE6n-00028m-9I for importer@patchew.org; Fri, 05 Mar 2021 12:19:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:32954) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkP-00070w-At for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32536) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDk5-0007D7-HK for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:17 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-341-q9fAAlETNOat5CHMZaPVKA-1; Fri, 05 Mar 2021 11:55:54 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7FCF4E4961; Fri, 5 Mar 2021 16:55:36 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 740EF60C43; Fri, 5 Mar 2021 16:55:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963356; 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=mNzsHHIx58+QMBheKHkUuCRnL0/BzmGRxjdvJTaEdQU=; b=Ro8yQuyonebU6Q2IXkEMdHzQvMvirglvQ2XA251pWrDN+XOBxqhoO2Yqxp+S+u1j37F9nU qnJvCDuvF8FWESqaLi0H7L5/kUNQi/1kMab+OuEApJ7WpJzfAijhhsFh+4JftVV7hEdvzj 6gSNQUmOKo7Jk9CoCeVcNshf26imn3A= X-MC-Unique: q9fAAlETNOat5CHMZaPVKA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 21/31] block/export: port virtio-blk discard/write zeroes input validation Date: Fri, 5 Mar 2021 17:54:44 +0100 Message-Id: <20210305165454.356840-22-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Validate discard/write zeroes the same way we do for virtio-blk. Some of these checks are mandated by the VIRTIO specification, others are internal to QEMU. Signed-off-by: Stefan Hajnoczi Message-Id: <20210223144653.811468-11-stefanha@redhat.com> Signed-off-by: Kevin Wolf --- block/export/vhost-user-blk-server.c | 116 +++++++++++++++++++++------ 1 file changed, 93 insertions(+), 23 deletions(-) diff --git a/block/export/vhost-user-blk-server.c b/block/export/vhost-user= -blk-server.c index f74796241c..04044228d4 100644 --- a/block/export/vhost-user-blk-server.c +++ b/block/export/vhost-user-blk-server.c @@ -29,6 +29,8 @@ =20 enum { VHOST_USER_BLK_NUM_QUEUES_DEFAULT =3D 1, + VHOST_USER_BLK_MAX_DISCARD_SECTORS =3D 32768, + VHOST_USER_BLK_MAX_WRITE_ZEROES_SECTORS =3D 32768, }; struct virtio_blk_inhdr { unsigned char status; @@ -65,30 +67,102 @@ static void vu_blk_req_complete(VuBlkReq *req) free(req); } =20 +static bool vu_blk_sect_range_ok(VuBlkExport *vexp, uint64_t sector, + size_t size) +{ + uint64_t nb_sectors =3D size >> BDRV_SECTOR_BITS; + uint64_t total_sectors; + + if (nb_sectors > BDRV_REQUEST_MAX_SECTORS) { + return false; + } + if ((sector << VIRTIO_BLK_SECTOR_BITS) % vexp->blk_size) { + return false; + } + blk_get_geometry(vexp->export.blk, &total_sectors); + if (sector > total_sectors || nb_sectors > total_sectors - sector) { + return false; + } + return true; +} + static int coroutine_fn -vu_blk_discard_write_zeroes(BlockBackend *blk, struct iovec *iov, +vu_blk_discard_write_zeroes(VuBlkExport *vexp, struct iovec *iov, uint32_t iovcnt, uint32_t type) { + BlockBackend *blk =3D vexp->export.blk; struct virtio_blk_discard_write_zeroes desc; - ssize_t size =3D iov_to_buf(iov, iovcnt, 0, &desc, sizeof(desc)); + ssize_t size; + uint64_t sector; + uint32_t num_sectors; + uint32_t max_sectors; + uint32_t flags; + int bytes; + + /* Only one desc is currently supported */ + if (unlikely(iov_size(iov, iovcnt) > sizeof(desc))) { + return VIRTIO_BLK_S_UNSUPP; + } + + size =3D iov_to_buf(iov, iovcnt, 0, &desc, sizeof(desc)); if (unlikely(size !=3D sizeof(desc))) { - error_report("Invalid size %zd, expect %zu", size, sizeof(desc)); - return -EINVAL; + error_report("Invalid size %zd, expected %zu", size, sizeof(desc)); + return VIRTIO_BLK_S_IOERR; } =20 - uint64_t range[2] =3D { le64_to_cpu(desc.sector) << 9, - le32_to_cpu(desc.num_sectors) << 9 }; - if (type =3D=3D VIRTIO_BLK_T_DISCARD) { - if (blk_co_pdiscard(blk, range[0], range[1]) =3D=3D 0) { - return 0; + sector =3D le64_to_cpu(desc.sector); + num_sectors =3D le32_to_cpu(desc.num_sectors); + flags =3D le32_to_cpu(desc.flags); + max_sectors =3D (type =3D=3D VIRTIO_BLK_T_WRITE_ZEROES) ? + VHOST_USER_BLK_MAX_WRITE_ZEROES_SECTORS : + VHOST_USER_BLK_MAX_DISCARD_SECTORS; + + /* This check ensures that 'bytes' fits in an int */ + if (unlikely(num_sectors > max_sectors)) { + return VIRTIO_BLK_S_IOERR; + } + + bytes =3D num_sectors << VIRTIO_BLK_SECTOR_BITS; + + if (unlikely(!vu_blk_sect_range_ok(vexp, sector, bytes))) { + return VIRTIO_BLK_S_IOERR; + } + + /* + * The device MUST set the status byte to VIRTIO_BLK_S_UNSUPP for disc= ard + * and write zeroes commands if any unknown flag is set. + */ + if (unlikely(flags & ~VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP)) { + return VIRTIO_BLK_S_UNSUPP; + } + + if (type =3D=3D VIRTIO_BLK_T_WRITE_ZEROES) { + int blk_flags =3D 0; + + if (flags & VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP) { + blk_flags |=3D BDRV_REQ_MAY_UNMAP; + } + + if (blk_co_pwrite_zeroes(blk, sector << VIRTIO_BLK_SECTOR_BITS, + bytes, blk_flags) =3D=3D 0) { + return VIRTIO_BLK_S_OK; } - } else if (type =3D=3D VIRTIO_BLK_T_WRITE_ZEROES) { - if (blk_co_pwrite_zeroes(blk, range[0], range[1], 0) =3D=3D 0) { - return 0; + } else if (type =3D=3D VIRTIO_BLK_T_DISCARD) { + /* + * The device MUST set the status byte to VIRTIO_BLK_S_UNSUPP for + * discard commands if the unmap flag is set. + */ + if (unlikely(flags & VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP)) { + return VIRTIO_BLK_S_UNSUPP; + } + + if (blk_co_pdiscard(blk, sector << VIRTIO_BLK_SECTOR_BITS, + bytes) =3D=3D 0) { + return VIRTIO_BLK_S_OK; } } =20 - return -EINVAL; + return VIRTIO_BLK_S_IOERR; } =20 static void coroutine_fn vu_blk_virtio_process_req(void *opaque) @@ -177,19 +251,13 @@ static void coroutine_fn vu_blk_virtio_process_req(vo= id *opaque) } case VIRTIO_BLK_T_DISCARD: case VIRTIO_BLK_T_WRITE_ZEROES: { - int rc; - if (!vexp->writable) { req->in->status =3D VIRTIO_BLK_S_IOERR; break; } =20 - rc =3D vu_blk_discard_write_zeroes(blk, &elem->out_sg[1], out_num,= type); - if (rc =3D=3D 0) { - req->in->status =3D VIRTIO_BLK_S_OK; - } else { - req->in->status =3D VIRTIO_BLK_S_IOERR; - } + req->in->status =3D vu_blk_discard_write_zeroes(vexp, out_iov, out= _num, + type); break; } default: @@ -362,11 +430,13 @@ vu_blk_initialize_config(BlockDriverState *bs, config->min_io_size =3D cpu_to_le16(1); config->opt_io_size =3D cpu_to_le32(1); config->num_queues =3D cpu_to_le16(num_queues); - config->max_discard_sectors =3D cpu_to_le32(32768); + config->max_discard_sectors =3D + cpu_to_le32(VHOST_USER_BLK_MAX_DISCARD_SECTORS); config->max_discard_seg =3D cpu_to_le32(1); config->discard_sector_alignment =3D cpu_to_le32(blk_size >> VIRTIO_BLK_SECTOR_BITS); - config->max_write_zeroes_sectors =3D cpu_to_le32(32768); + config->max_write_zeroes_sectors + =3D cpu_to_le32(VHOST_USER_BLK_MAX_WRITE_ZEROES_SECTORS); config->max_write_zeroes_seg =3D cpu_to_le32(1); } =20 --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614964210; cv=none; d=zohomail.com; s=zohoarc; b=C/6VmjwHmti/cLnivCYkw3uFacwco8PkJVyJ+P9Wzlv3vQqbNWN863hUPzr0pHftxUmDRDUiTJIPtYexH67I2w3njzCfqvqaRNVkzVzh9zB+SRJQcWD8SmZqCW+nvqGxCsxqhMjfbTbuEkVodUwLQRiNRd0NSBmjfkZuN22wN34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614964210; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aqDa+16WYOTNX329uXOujH8Fa1ixvbpvcPzu0Z0ug30=; b=koKl++YHA9RH20lT2HbGDirYnijUad2E6JS8OZit/fpCkLEAmmAmf8IZHa3J8sXYzc9vEzjeeX0ltto/i2ryeBX1wBcg9OS/owmasZ+WPgxpLMxVCML/NZc9Z1mNNBn7TL3DxE2mC8BSx+Eq4XerNjyiXwTySHKFPu9t05wQCpI= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16149642106491021.0286081531186; Fri, 5 Mar 2021 09:10:10 -0800 (PST) Received: from localhost ([::1]:53376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIDxp-0007b4-F8 for importer@patchew.org; Fri, 05 Mar 2021 12:10:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkY-0007Qn-OY for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57204) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDkB-0007DO-A2 for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:26 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-98-AXMhS_67Ms-EYN7rWZJKag-1; Fri, 05 Mar 2021 11:55:54 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DCC1C10A2C65; Fri, 5 Mar 2021 16:55:37 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0E1160C43; Fri, 5 Mar 2021 16:55:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963357; 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=aqDa+16WYOTNX329uXOujH8Fa1ixvbpvcPzu0Z0ug30=; b=EcXEbK/zNq4Rr1E1dZoimczDqeL6sAQFvXB37sIq+P3RnhKvHUMlDv+GfHWdT0yjzvh/++ bbw3eeD9dnBWEZgYNiGR4llevFgHyBCtNcEld/M7Do6+e7oa1DDlEk1piqXbKefoO6b3pT JBC97MuyfpGt+ODARUyb0jglpAMekns= X-MC-Unique: AXMhS_67Ms-EYN7rWZJKag-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 22/31] vhost-user-blk-test: test discard/write zeroes invalid inputs Date: Fri, 5 Mar 2021 17:54:45 +0100 Message-Id: <20210305165454.356840-23-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Exercise input validation code paths in block/export/vhost-user-blk-server.c. Signed-off-by: Stefan Hajnoczi Message-Id: <20210223144653.811468-12-stefanha@redhat.com> Signed-off-by: Kevin Wolf --- tests/qtest/vhost-user-blk-test.c | 124 ++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c index 61beee52d3..dc9d7a31ae 100644 --- a/tests/qtest/vhost-user-blk-test.c +++ b/tests/qtest/vhost-user-blk-test.c @@ -94,6 +94,124 @@ static uint64_t virtio_blk_request(QGuestAllocator *all= oc, QVirtioDevice *d, return addr; } =20 +static void test_invalid_discard_write_zeroes(QVirtioDevice *dev, + QGuestAllocator *alloc, + QTestState *qts, + QVirtQueue *vq, + uint32_t type) +{ + QVirtioBlkReq req; + struct virtio_blk_discard_write_zeroes dwz_hdr; + struct virtio_blk_discard_write_zeroes dwz_hdr2[2]; + uint64_t req_addr; + uint32_t free_head; + uint8_t status; + + /* More than one dwz is not supported */ + req.type =3D type; + req.data =3D (char *) dwz_hdr2; + dwz_hdr2[0].sector =3D 0; + dwz_hdr2[0].num_sectors =3D 1; + dwz_hdr2[0].flags =3D 0; + dwz_hdr2[1].sector =3D 1; + dwz_hdr2[1].num_sectors =3D 1; + dwz_hdr2[1].flags =3D 0; + + virtio_blk_fix_dwz_hdr(dev, &dwz_hdr2[0]); + virtio_blk_fix_dwz_hdr(dev, &dwz_hdr2[1]); + + req_addr =3D virtio_blk_request(alloc, dev, &req, sizeof(dwz_hdr2)); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, sizeof(dwz_hdr2), false, true); + qvirtqueue_add(qts, vq, req_addr + 16 + sizeof(dwz_hdr2), 1, true, + false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 16 + sizeof(dwz_hdr2)); + g_assert_cmpint(status, =3D=3D, VIRTIO_BLK_S_UNSUPP); + + guest_free(alloc, req_addr); + + /* num_sectors must be less than config->max_write_zeroes_sectors */ + req.type =3D type; + req.data =3D (char *) &dwz_hdr; + dwz_hdr.sector =3D 0; + dwz_hdr.num_sectors =3D 0xffffffff; + dwz_hdr.flags =3D 0; + + virtio_blk_fix_dwz_hdr(dev, &dwz_hdr); + + req_addr =3D virtio_blk_request(alloc, dev, &req, sizeof(dwz_hdr)); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, sizeof(dwz_hdr), false, true); + qvirtqueue_add(qts, vq, req_addr + 16 + sizeof(dwz_hdr), 1, true, + false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 16 + sizeof(dwz_hdr)); + g_assert_cmpint(status, =3D=3D, VIRTIO_BLK_S_IOERR); + + guest_free(alloc, req_addr); + + /* sector must be less than the device capacity */ + req.type =3D type; + req.data =3D (char *) &dwz_hdr; + dwz_hdr.sector =3D TEST_IMAGE_SIZE / 512 + 1; + dwz_hdr.num_sectors =3D 1; + dwz_hdr.flags =3D 0; + + virtio_blk_fix_dwz_hdr(dev, &dwz_hdr); + + req_addr =3D virtio_blk_request(alloc, dev, &req, sizeof(dwz_hdr)); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, sizeof(dwz_hdr), false, true); + qvirtqueue_add(qts, vq, req_addr + 16 + sizeof(dwz_hdr), 1, true, + false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 16 + sizeof(dwz_hdr)); + g_assert_cmpint(status, =3D=3D, VIRTIO_BLK_S_IOERR); + + guest_free(alloc, req_addr); + + /* reserved flag bits must be zero */ + req.type =3D type; + req.data =3D (char *) &dwz_hdr; + dwz_hdr.sector =3D 0; + dwz_hdr.num_sectors =3D 1; + dwz_hdr.flags =3D ~VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP; + + virtio_blk_fix_dwz_hdr(dev, &dwz_hdr); + + req_addr =3D virtio_blk_request(alloc, dev, &req, sizeof(dwz_hdr)); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, sizeof(dwz_hdr), false, true); + qvirtqueue_add(qts, vq, req_addr + 16 + sizeof(dwz_hdr), 1, true, + false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 16 + sizeof(dwz_hdr)); + g_assert_cmpint(status, =3D=3D, VIRTIO_BLK_S_UNSUPP); + + guest_free(alloc, req_addr); +} + /* Returns the request virtqueue so the caller can perform further tests */ static QVirtQueue *test_basic(QVirtioDevice *dev, QGuestAllocator *alloc) { @@ -235,6 +353,9 @@ static QVirtQueue *test_basic(QVirtioDevice *dev, QGues= tAllocator *alloc) g_free(data); =20 guest_free(alloc, req_addr); + + test_invalid_discard_write_zeroes(dev, alloc, qts, vq, + VIRTIO_BLK_T_WRITE_ZEROES); } =20 if (features & (1u << VIRTIO_BLK_F_DISCARD)) { @@ -263,6 +384,9 @@ static QVirtQueue *test_basic(QVirtioDevice *dev, QGues= tAllocator *alloc) g_assert_cmpint(status, =3D=3D, 0); =20 guest_free(alloc, req_addr); + + test_invalid_discard_write_zeroes(dev, alloc, qts, vq, + VIRTIO_BLK_T_DISCARD); } =20 if (features & (1u << VIRTIO_F_ANY_LAYOUT)) { --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614964854; cv=none; d=zohomail.com; s=zohoarc; b=VXhTNaOgryIhPJhRDoL6meda2ehAMvzvKjSrZZigi/epAGTdpvO79nXT8o4dn1XN5nE7Z6vlYjlt0N0P+nUWqbM1fzkmNEq9eJQpelu/eSVKaRyM3u1aA/laNfatqovfvqCWydn/nHrT8Lp055CPxvuE6Ebpg6ZhBagFaeQL2lw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614964854; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ASTXwOoSK2vmVQ6Qp8CpuGdM9iYJo3SffHQD/ybxTDs=; b=fzx4c8cU73M52klP1J/swxq/DJ9i3r/KcgZaNpBP14BXmQsnud5Fezlled/EBh3GYf8EM8UveMex6DieuheO4cAHK1nRwKAFZm3/IjmsuJzL3yUpqQDGdNEQTFAyGFXifasHiwiKreVW4RNFnEBm+mbjA1lj29Rn6bihMu1Fehc= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161496485411945.166395695102665; Fri, 5 Mar 2021 09:20:54 -0800 (PST) Received: from localhost ([::1]:51646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIE8C-0003ZE-O9 for importer@patchew.org; Fri, 05 Mar 2021 12:20:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33086) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkV-0007Gk-1w for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52726) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDkB-0007E3-8T for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:22 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-98-qWrBzzb4PTmTOStoDgHpiA-1; Fri, 05 Mar 2021 11:55:54 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4419710A2C68; Fri, 5 Mar 2021 16:55:39 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 388E860C43; Fri, 5 Mar 2021 16:55:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963358; 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=ASTXwOoSK2vmVQ6Qp8CpuGdM9iYJo3SffHQD/ybxTDs=; b=EblZuG02siKAmetXG5Eo5TS0RMovGwcYzXN6UHcUQaS0Uh7UyC/jGMmCCrVALb2r4kTisi qen6QdGu8nG7xUJbAT4npAXqaraVKpkEXqcOB2AxMvru0PLFQRBjrc8kwuXNFx85y4mZDL hyXBlu1BJq96tqqwZ0e1s55v0dKqvsA= X-MC-Unique: qWrBzzb4PTmTOStoDgHpiA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 23/31] block/export: port virtio-blk read/write range check Date: Fri, 5 Mar 2021 17:54:46 +0100 Message-Id: <20210305165454.356840-24-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Check that the sector number and byte count are valid. Signed-off-by: Stefan Hajnoczi Message-Id: <20210223144653.811468-13-stefanha@redhat.com> Signed-off-by: Kevin Wolf --- block/export/vhost-user-blk-server.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/block/export/vhost-user-blk-server.c b/block/export/vhost-user= -blk-server.c index 04044228d4..cb5d896b7b 100644 --- a/block/export/vhost-user-blk-server.c +++ b/block/export/vhost-user-blk-server.c @@ -209,6 +209,8 @@ static void coroutine_fn vu_blk_virtio_process_req(void= *opaque) switch (type & ~VIRTIO_BLK_T_BARRIER) { case VIRTIO_BLK_T_IN: case VIRTIO_BLK_T_OUT: { + QEMUIOVector qiov; + int64_t offset; ssize_t ret =3D 0; bool is_write =3D type & VIRTIO_BLK_T_OUT; req->sector_num =3D le64_to_cpu(req->out.sector); @@ -218,13 +220,24 @@ static void coroutine_fn vu_blk_virtio_process_req(vo= id *opaque) break; } =20 - int64_t offset =3D req->sector_num << VIRTIO_BLK_SECTOR_BITS; - QEMUIOVector qiov; if (is_write) { qemu_iovec_init_external(&qiov, out_iov, out_num); - ret =3D blk_co_pwritev(blk, offset, qiov.size, &qiov, 0); } else { qemu_iovec_init_external(&qiov, in_iov, in_num); + } + + if (unlikely(!vu_blk_sect_range_ok(vexp, + req->sector_num, + qiov.size))) { + req->in->status =3D VIRTIO_BLK_S_IOERR; + break; + } + + offset =3D req->sector_num << VIRTIO_BLK_SECTOR_BITS; + + if (is_write) { + ret =3D blk_co_pwritev(blk, offset, qiov.size, &qiov, 0); + } else { ret =3D blk_co_preadv(blk, offset, qiov.size, &qiov, 0); } if (ret >=3D 0) { --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614964068; cv=none; d=zohomail.com; s=zohoarc; b=ae4MuiU96nzBPSaQPubqz33rJ5EWwmx087TzdDGZsXlPDx5lfcCtYLAgqbbW8A+7MUeVeXEO3y/YpqDGeTgGo7bJkchjVI94tCszAkd/mpIE8U0tw8tLia1iIrCI4I6ZQLsq1elN2sWH4timNhh3M/tTymuNFLw7f+s1yLkkcLQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614964068; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+1IcRM5y+74Od8lqtTk4yL9GcZ7XhiSUdItwkOJcgY4=; b=jHmsPKVrTK6MeotKuRvzQBytzQYseAe/Uq+T87rkD0WMVbg27P6FYp6l7A6/nRrHMm5HMMLGYj6PubRYQIcPNHUvFL7T5fZi9TRk1L7fpQz84SrP+BmNfil82sr3KrgIjPr/qyaxaX6aVI1hqWV0fAPD3Nsnw94a8RqbUmDEs80= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614964068208424.9372335612344; Fri, 5 Mar 2021 09:07:48 -0800 (PST) Received: from localhost ([::1]:44780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIDvX-00042W-4N for importer@patchew.org; Fri, 05 Mar 2021 12:07:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkR-00075q-EU for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29140) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDkB-0007FD-3X for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:19 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-341-HbcxL6SnNkuwtAG9C3EyAw-1; Fri, 05 Mar 2021 11:55:54 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A50F5E4964; Fri, 5 Mar 2021 16:55:40 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 94E9F60BF3; Fri, 5 Mar 2021 16:55:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963359; 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=+1IcRM5y+74Od8lqtTk4yL9GcZ7XhiSUdItwkOJcgY4=; b=WuXqy94vgnF115tOl9ii8AAgAYROLt6JPUz7hCAQPbXrHI3XzMXnG+ROYFj2hY2pJcdN5R uuG2ZlnYHoXtENhrfok9ihKZSBPWJz/B4PzdsjG6SsFkREyWngP5NqN8tb52/jQUzuIgjv gQizt0osy1qiIe9uwgSdXuulsdKS3NU= X-MC-Unique: HbcxL6SnNkuwtAG9C3EyAw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 24/31] qcow2-bitmap: make bytes_covered_by_bitmap_cluster() public Date: Fri, 5 Mar 2021 17:54:47 +0100 Message-Id: <20210305165454.356840-25-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Rename bytes_covered_by_bitmap_cluster() to bdrv_dirty_bitmap_serialization_coverage() and make it public. It is needed as we are going to share it with bitmap loading in parallels format. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Reviewed-by: Denis V. Lunev Message-Id: <20210224104707.88430-2-vsementsov@virtuozzo.com> Signed-off-by: Kevin Wolf --- include/block/dirty-bitmap.h | 2 ++ block/dirty-bitmap.c | 13 +++++++++++++ block/qcow2-bitmap.c | 16 ++-------------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h index 36e8da4fc2..f581cf9fd7 100644 --- a/include/block/dirty-bitmap.h +++ b/include/block/dirty-bitmap.h @@ -57,6 +57,8 @@ void bdrv_dirty_iter_free(BdrvDirtyBitmapIter *iter); uint64_t bdrv_dirty_bitmap_serialization_size(const BdrvDirtyBitmap *bitma= p, uint64_t offset, uint64_t by= tes); uint64_t bdrv_dirty_bitmap_serialization_align(const BdrvDirtyBitmap *bitm= ap); +uint64_t bdrv_dirty_bitmap_serialization_coverage(int serialized_chunk_siz= e, + const BdrvDirtyBitmap *bitmap); void bdrv_dirty_bitmap_serialize_part(const BdrvDirtyBitmap *bitmap, uint8_t *buf, uint64_t offset, uint64_t bytes); diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index 9b9cd71238..a0eaa28785 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -726,6 +726,19 @@ uint64_t bdrv_dirty_bitmap_serialization_align(const B= drvDirtyBitmap *bitmap) return hbitmap_serialization_align(bitmap->bitmap); } =20 +/* Return the disk size covered by a chunk of serialized bitmap data. */ +uint64_t bdrv_dirty_bitmap_serialization_coverage(int serialized_chunk_siz= e, + const BdrvDirtyBitmap *b= itmap) +{ + uint64_t granularity =3D bdrv_dirty_bitmap_granularity(bitmap); + uint64_t limit =3D granularity * (serialized_chunk_size << 3); + + assert(QEMU_IS_ALIGNED(limit, + bdrv_dirty_bitmap_serialization_align(bitmap))); + return limit; +} + + void bdrv_dirty_bitmap_serialize_part(const BdrvDirtyBitmap *bitmap, uint8_t *buf, uint64_t offset, uint64_t bytes) diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index 5eef82fa55..42d81c44cd 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -278,18 +278,6 @@ static int free_bitmap_clusters(BlockDriverState *bs, = Qcow2BitmapTable *tb) return 0; } =20 -/* Return the disk size covered by a single qcow2 cluster of bitmap data. = */ -static uint64_t bytes_covered_by_bitmap_cluster(const BDRVQcow2State *s, - const BdrvDirtyBitmap *bit= map) -{ - uint64_t granularity =3D bdrv_dirty_bitmap_granularity(bitmap); - uint64_t limit =3D granularity * (s->cluster_size << 3); - - assert(QEMU_IS_ALIGNED(limit, - bdrv_dirty_bitmap_serialization_align(bitmap))); - return limit; -} - /* load_bitmap_data * @bitmap_table entries must satisfy specification constraints. * @bitmap must be cleared */ @@ -312,7 +300,7 @@ static int load_bitmap_data(BlockDriverState *bs, } =20 buf =3D g_malloc(s->cluster_size); - limit =3D bytes_covered_by_bitmap_cluster(s, bitmap); + limit =3D bdrv_dirty_bitmap_serialization_coverage(s->cluster_size, bi= tmap); for (i =3D 0, offset =3D 0; i < tab_size; ++i, offset +=3D limit) { uint64_t count =3D MIN(bm_size - offset, limit); uint64_t entry =3D bitmap_table[i]; @@ -1303,7 +1291,7 @@ static uint64_t *store_bitmap_data(BlockDriverState *= bs, } =20 buf =3D g_malloc(s->cluster_size); - limit =3D bytes_covered_by_bitmap_cluster(s, bitmap); + limit =3D bdrv_dirty_bitmap_serialization_coverage(s->cluster_size, bi= tmap); assert(DIV_ROUND_UP(bm_size, limit) =3D=3D tb_size); =20 offset =3D 0; --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614965064; cv=none; d=zohomail.com; s=zohoarc; b=PHyrxh34O3Vt2GwznCHN88+bBWuChLwmCepTgujcSpWVcj0rocJg2ukIleUR5BYyCOzFvMp1Ga/AJjMrnigX8JptWxSqBl0T4k0jbM2IELRaXKhqKaGXQPJlrJ/xyZZsmSX1S/1G6roZgDxGG4JGHzKRNQXvel4lDxqYLDE3GUI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614965064; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DsMqEQ84ndUdTctY5ycuDO4t+nQuf19CMdj+3Zxei+U=; b=oEU+Y/jozEAoLlMQ4CrTksLIr6W34TkUkPjnnQWuZo02WmYnDhlielZlECrX30yhDhsEZZZXEk6VCUBHHwp0Hcd49QPBymTZaa/XbRWpas0b4/uoZw2Fm8/CBDs+0amPC2RLCsBR/MhvGLygtImgk2n4EWPsf8/Zbpxw2DevMs0= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614965064466318.5315387596754; Fri, 5 Mar 2021 09:24:24 -0800 (PST) Received: from localhost ([::1]:59924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIEBb-00076r-2e for importer@patchew.org; Fri, 05 Mar 2021 12:24:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:32992) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkQ-000740-Mn for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:55258) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDkA-0007FG-HE for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:18 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-382-EtPP_JJgNtOOWe12-4XFrw-1; Fri, 05 Mar 2021 11:55:56 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0BD43879A1F; Fri, 5 Mar 2021 16:55:42 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id F061960BF3; Fri, 5 Mar 2021 16:55:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963359; 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=DsMqEQ84ndUdTctY5ycuDO4t+nQuf19CMdj+3Zxei+U=; b=Ii9++fD3D8Ba8A4IRMX9BK1DbsabN03pM/GdVBARVMJLIkq+q8QUms4Q4mjm7E/flsEf3S 26g4BZ4uAuaXlDzCW6NY5LLxyIrQ8alF1hAhBOdLpfk7H9exA0fvPOWsUjkm+zF/JCuk9Z OHJUjb1sSZUbW2QA4+AKW2hhGpqefsc= X-MC-Unique: EtPP_JJgNtOOWe12-4XFrw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 25/31] parallels.txt: fix bitmap L1 table description Date: Fri, 5 Mar 2021 17:54:48 +0100 Message-Id: <20210305165454.356840-26-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Actually L1 table entry offset is in 512 bytes sectors. Fix the spec. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210224104707.88430-3-vsementsov@virtuozzo.com> Reviewed-by: Denis V. Lunev Signed-off-by: Kevin Wolf --- docs/interop/parallels.txt | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/docs/interop/parallels.txt b/docs/interop/parallels.txt index f15bf35bd1..bb3fadf369 100644 --- a/docs/interop/parallels.txt +++ b/docs/interop/parallels.txt @@ -208,21 +208,25 @@ of its data area are: 28 - 31: l1_size The number of entries in the L1 table of the bitmap. =20 - variable: l1_table (8 * l1_size bytes) - L1 offset table (in bytes) + variable: L1 offset table (l1_table), size: 8 * l1_size bytes =20 -A dirty bitmap is stored using a one-level structure for the mapping to ho= st -clusters - an L1 table. +The dirty bitmap described by this feature extension is stored in a set of +clusters inside the Parallels image file. The offsets of these clusters are +saved in the L1 offset table specified by the feature extension. Each L1 t= able +entry is a 64 bit integer as described below: =20 -Given an offset in bytes into the bitmap data, the offset in bytes into the -image file can be obtained as follows: +Given an offset in bytes into the bitmap data, corresponding L1 entry is =20 - offset =3D l1_table[offset / cluster_size] + (offset % cluster_size) + l1_table[offset / cluster_size] =20 -If an L1 table entry is 0, the corresponding cluster of the bitmap is assu= med -to be zero. +If an L1 table entry is 0, all bits in the corresponding cluster of the bi= tmap +are assumed to be 0. =20 -If an L1 table entry is 1, the corresponding cluster of the bitmap is assu= med -to have all bits set. +If an L1 table entry is 1, all bits in the corresponding cluster of the bi= tmap +are assumed to be 1. =20 -If an L1 table entry is not 0 or 1, it allocates a cluster from the data a= rea. +If an L1 table entry is not 0 or 1, it contains the corresponding cluster +offset (in 512b sectors). Given an offset in bytes into the bitmap data the +offset in bytes into the image file can be obtained as follows: + + offset =3D l1_table[offset / cluster_size] * 512 + (offset % cluster_s= ize) --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614963928; cv=none; d=zohomail.com; s=zohoarc; b=R9L6qVdsLQM3mX0Ffy+0sbcQnJYqGjSymK3r/GW4aXcfAT7prQIeQgRFo4eTQ9v7uI4tN+sSzkLOYEC1lXb9NcSqEl/gr1QXwZgBW3v7O06ZRweJljPx+jxlrmay94TenUFfQN7nr3uQ/zmi5Y3DszbZY7uJFftdvt5iMxfyB4M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614963928; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IH6cB1FtNJ4X/SFpceFy7ZgDVLT2So77w/rQ8fEUhsE=; b=AvTfFYWyDuexOh2lAo83SKCU2mNPTAzJ7lsbFDdnJJ078k+Xl0FI/hCUrboLCIzE3JSNl7NO8DwNhf1aVsYDIG4IJXk3qwCdSPqlvAhyoVnoU5M52RQ91OuyrQv/lnc4Kh8ev4TN4DN53RC6Fmuv574euJzgqfz8emorOxHzhI8= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614963928518939.9590171245944; Fri, 5 Mar 2021 09:05:28 -0800 (PST) Received: from localhost ([::1]:36134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIDtH-0000Px-Bs for importer@patchew.org; Fri, 05 Mar 2021 12:05:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:32914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkO-00070f-31 for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24705) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDk7-0007EX-8n for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:15 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-573-6QOB4zsMND2sXEkTha7PTA-1; Fri, 05 Mar 2021 11:55:56 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 67DBCE4967; Fri, 5 Mar 2021 16:55:43 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B25B60BF3; Fri, 5 Mar 2021 16:55:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963358; 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=IH6cB1FtNJ4X/SFpceFy7ZgDVLT2So77w/rQ8fEUhsE=; b=bS+uwIIipr0ZUVhpag1TsCSAj9Qa2hq4oOu3o7E73AdsY8jVG0wFkyGAYq67vEItnyf41O CMD+KxmCO+ocIuo9/ZdP+DzZdCTwMQV6CInNYPCN5ROl9A8raAGnHGXtRcVXegkovc+ggM now+OZ+YGNgK6Z0+9ZIoltoQ+ZZ0JaM= X-MC-Unique: 6QOB4zsMND2sXEkTha7PTA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 26/31] block/parallels: BDRVParallelsState: add cluster_size field Date: Fri, 5 Mar 2021 17:54:49 +0100 Message-Id: <20210305165454.356840-27-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy We are going to use it in more places, calculating "s->tracks << BDRV_SECTOR_BITS" doesn't look good. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210224104707.88430-4-vsementsov@virtuozzo.com> Reviewed-by: Denis V. Lunev Signed-off-by: Kevin Wolf --- block/parallels.h | 1 + block/parallels.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/block/parallels.h b/block/parallels.h index 5aa101cfc8..9a9209e320 100644 --- a/block/parallels.h +++ b/block/parallels.h @@ -79,6 +79,7 @@ typedef struct BDRVParallelsState { ParallelsPreallocMode prealloc_mode; =20 unsigned int tracks; + unsigned int cluster_size; =20 unsigned int off_multiplier; Error *migration_blocker; diff --git a/block/parallels.c b/block/parallels.c index 3c22dfdc9d..9594d84978 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -421,7 +421,6 @@ static int coroutine_fn parallels_co_check(BlockDriverS= tate *bs, int ret; uint32_t i; bool flush_bat =3D false; - int cluster_size =3D s->tracks << BDRV_SECTOR_BITS; =20 size =3D bdrv_getlength(bs->file->bs); if (size < 0) { @@ -472,7 +471,7 @@ static int coroutine_fn parallels_co_check(BlockDriverS= tate *bs, high_off =3D off; } =20 - if (prev_off !=3D 0 && (prev_off + cluster_size) !=3D off) { + if (prev_off !=3D 0 && (prev_off + s->cluster_size) !=3D off) { res->bfi.fragmented_clusters++; } prev_off =3D off; @@ -487,10 +486,10 @@ static int coroutine_fn parallels_co_check(BlockDrive= rState *bs, } } =20 - res->image_end_offset =3D high_off + cluster_size; + res->image_end_offset =3D high_off + s->cluster_size; if (size > res->image_end_offset) { int64_t count; - count =3D DIV_ROUND_UP(size - res->image_end_offset, cluster_size); + count =3D DIV_ROUND_UP(size - res->image_end_offset, s->cluster_si= ze); fprintf(stderr, "%s space leaked at the end of the image %" PRId64= "\n", fix & BDRV_FIX_LEAKS ? "Repairing" : "ERROR", size - res->image_end_offset); @@ -771,6 +770,7 @@ static int parallels_open(BlockDriverState *bs, QDict *= options, int flags, ret =3D -EFBIG; goto fail; } + s->cluster_size =3D s->tracks << BDRV_SECTOR_BITS; =20 s->bat_size =3D le32_to_cpu(ph.bat_entries); if (s->bat_size > INT_MAX / sizeof(uint32_t)) { --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614965933; cv=none; d=zohomail.com; s=zohoarc; b=JB6NDfbTzhcXX65/bHLUKaUZNq1FmbpJP7VnqBwlDzwUs0fLjippINZ7ZxhUqW3tkBYtgec6DADkQC/8warYgxndE8aBaWUM4kwaWXR8Om+SSef+EYVAEG0GBTdh2N2NkUVx0ABIXaKngvy9YNbnTBsAdMKll6z4bPX+oVTJMZ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614965933; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AtOzG4OBuh8aPBUp14RhhEBM/wVmtgVX2RBvuZFqbWM=; b=HGRj2OBFzU7Jl+QozglIgY/WWQs9AHOPQr5UFy0B+vJznoe68PYpCxzVf6HvhSRGLdKGuT/r6xtiOnzd92mvmazRAGSXLzxo0OO+vhBn/+ebwdy+OwQz65XDkEYm/neCDM9UkptQgEzK2vgO+C3SzPZbizyZZjrG68+/c/TgPcE= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614965933754136.399627654479; Fri, 5 Mar 2021 09:38:53 -0800 (PST) Received: from localhost ([::1]:47040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIEPc-0000N0-Im for importer@patchew.org; Fri, 05 Mar 2021 12:38:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkW-0007Kd-I8 for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24410) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDkB-0007Fm-93 for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:24 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-21-ZYG-7JsYPwS2h2y8akBamA-1; Fri, 05 Mar 2021 11:55:57 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C5EE518C0285; Fri, 5 Mar 2021 16:55:44 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8C0360BF3; Fri, 5 Mar 2021 16:55:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963360; 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=AtOzG4OBuh8aPBUp14RhhEBM/wVmtgVX2RBvuZFqbWM=; b=byJicvBpYvmCh7y4QLAXEK5ve28L+CAwyguX56eQ9xjkqnawByxv5Ann3hr/D567LBE5cd Zj357DwWUPg9LQgOa0H7PxRt4B5wvrkjzCRhrXJmOjRfuz3Hygr35Q0Zel4V5NW2ZxCDv+ OCwipUdwN94kwgRBlTQ4AQht7RMXbsY= X-MC-Unique: ZYG-7JsYPwS2h2y8akBamA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 27/31] parallels: support bitmap extension for read-only mode Date: Fri, 5 Mar 2021 17:54:50 +0100 Message-Id: <20210305165454.356840-28-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210224104707.88430-5-vsementsov@virtuozzo.com> Reviewed-by: Denis V. Lunev Signed-off-by: Kevin Wolf --- block/parallels.h | 6 +- block/parallels-ext.c | 300 ++++++++++++++++++++++++++++++++++++++++++ block/parallels.c | 18 +++ block/meson.build | 3 +- 4 files changed, 325 insertions(+), 2 deletions(-) create mode 100644 block/parallels-ext.c diff --git a/block/parallels.h b/block/parallels.h index 9a9209e320..f22f43f988 100644 --- a/block/parallels.h +++ b/block/parallels.h @@ -48,7 +48,8 @@ typedef struct ParallelsHeader { uint64_t nb_sectors; uint32_t inuse; uint32_t data_off; - char padding[12]; + uint32_t flags; + uint64_t ext_off; } QEMU_PACKED ParallelsHeader; =20 typedef enum ParallelsPreallocMode { @@ -85,4 +86,7 @@ typedef struct BDRVParallelsState { Error *migration_blocker; } BDRVParallelsState; =20 +int parallels_read_format_extension(BlockDriverState *bs, + int64_t ext_off, Error **errp); + #endif diff --git a/block/parallels-ext.c b/block/parallels-ext.c new file mode 100644 index 0000000000..e0dd0975c6 --- /dev/null +++ b/block/parallels-ext.c @@ -0,0 +1,300 @@ +/* + * Support of Parallels Format Extension. It's a part of Parallels format + * driver. + * + * Copyright (c) 2021 Virtuozzo International GmbH + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "block/block_int.h" +#include "parallels.h" +#include "crypto/hash.h" +#include "qemu/uuid.h" + +#define PARALLELS_FORMAT_EXTENSION_MAGIC 0xAB234CEF23DCEA87ULL + +#define PARALLELS_END_OF_FEATURES_MAGIC 0x0ULL +#define PARALLELS_DIRTY_BITMAP_FEATURE_MAGIC 0x20385FAE252CB34AULL + +typedef struct ParallelsFormatExtensionHeader { + uint64_t magic; /* PARALLELS_FORMAT_EXTENSION_MAGIC */ + uint8_t check_sum[16]; +} QEMU_PACKED ParallelsFormatExtensionHeader; + +typedef struct ParallelsFeatureHeader { + uint64_t magic; + uint64_t flags; + uint32_t data_size; + uint32_t _unused; +} QEMU_PACKED ParallelsFeatureHeader; + +typedef struct ParallelsDirtyBitmapFeature { + uint64_t size; + uint8_t id[16]; + uint32_t granularity; + uint32_t l1_size; + /* L1 table follows */ +} QEMU_PACKED ParallelsDirtyBitmapFeature; + +/* Given L1 table read bitmap data from the image and populate @bitmap */ +static int parallels_load_bitmap_data(BlockDriverState *bs, + const uint64_t *l1_table, + uint32_t l1_size, + BdrvDirtyBitmap *bitmap, + Error **errp) +{ + BDRVParallelsState *s =3D bs->opaque; + int ret =3D 0; + uint64_t offset, limit; + uint64_t bm_size =3D bdrv_dirty_bitmap_size(bitmap); + uint8_t *buf =3D NULL; + uint64_t i, tab_size =3D + DIV_ROUND_UP(bdrv_dirty_bitmap_serialization_size(bitmap, 0, bm_si= ze), + s->cluster_size); + + if (tab_size !=3D l1_size) { + error_setg(errp, "Bitmap table size %" PRIu32 " does not correspon= d " + "to bitmap size and cluster size. Expected %" PRIu64, + l1_size, tab_size); + return -EINVAL; + } + + buf =3D qemu_blockalign(bs, s->cluster_size); + limit =3D bdrv_dirty_bitmap_serialization_coverage(s->cluster_size, bi= tmap); + for (i =3D 0, offset =3D 0; i < tab_size; ++i, offset +=3D limit) { + uint64_t count =3D MIN(bm_size - offset, limit); + uint64_t entry =3D l1_table[i]; + + if (entry =3D=3D 0) { + /* No need to deserialize zeros because @bitmap is cleared. */ + continue; + } + + if (entry =3D=3D 1) { + bdrv_dirty_bitmap_deserialize_ones(bitmap, offset, count, fals= e); + } else { + ret =3D bdrv_pread(bs->file, entry << BDRV_SECTOR_BITS, buf, + s->cluster_size); + if (ret < 0) { + error_setg_errno(errp, -ret, + "Failed to read bitmap data cluster"); + goto finish; + } + bdrv_dirty_bitmap_deserialize_part(bitmap, buf, offset, count, + false); + } + } + ret =3D 0; + + bdrv_dirty_bitmap_deserialize_finish(bitmap); + +finish: + qemu_vfree(buf); + + return ret; +} + +/* + * @data buffer (of @data_size size) is the Dirty bitmaps feature which + * consists of ParallelsDirtyBitmapFeature followed by L1 table. + */ +static BdrvDirtyBitmap *parallels_load_bitmap(BlockDriverState *bs, + uint8_t *data, + size_t data_size, + Error **errp) +{ + int ret; + ParallelsDirtyBitmapFeature bf; + g_autofree uint64_t *l1_table =3D NULL; + BdrvDirtyBitmap *bitmap; + QemuUUID uuid; + char uuidstr[UUID_FMT_LEN + 1]; + int i; + + if (data_size < sizeof(bf)) { + error_setg(errp, "Too small Bitmap Feature area in Parallels Forma= t " + "Extension: %zu bytes, expected at least %zu bytes", + data_size, sizeof(bf)); + return NULL; + } + memcpy(&bf, data, sizeof(bf)); + bf.size =3D le64_to_cpu(bf.size); + bf.granularity =3D le32_to_cpu(bf.granularity) << BDRV_SECTOR_BITS; + bf.l1_size =3D le32_to_cpu(bf.l1_size); + data +=3D sizeof(bf); + data_size -=3D sizeof(bf); + + if (bf.size !=3D bs->total_sectors) { + error_setg(errp, "Bitmap size (in sectors) %" PRId64 " differs fro= m " + "disk size in sectors %" PRId64, bf.size, bs->total_sec= tors); + return NULL; + } + + if (bf.l1_size * sizeof(uint64_t) > data_size) { + error_setg(errp, "Bitmaps feature corrupted: l1 table exceeds " + "extension data_size"); + return NULL; + } + + memcpy(&uuid, bf.id, sizeof(uuid)); + qemu_uuid_unparse(&uuid, uuidstr); + bitmap =3D bdrv_create_dirty_bitmap(bs, bf.granularity, uuidstr, errp); + if (!bitmap) { + return NULL; + } + + l1_table =3D g_new(uint64_t, bf.l1_size); + for (i =3D 0; i < bf.l1_size; i++, data +=3D sizeof(uint64_t)) { + l1_table[i] =3D ldq_le_p(data); + } + + ret =3D parallels_load_bitmap_data(bs, l1_table, bf.l1_size, bitmap, e= rrp); + if (ret < 0) { + bdrv_release_dirty_bitmap(bitmap); + return NULL; + } + + /* We support format extension only for RO parallels images. */ + assert(!(bs->open_flags & BDRV_O_RDWR)); + bdrv_dirty_bitmap_set_readonly(bitmap, true); + + return bitmap; +} + +static int parallels_parse_format_extension(BlockDriverState *bs, + uint8_t *ext_cluster, Error **= errp) +{ + BDRVParallelsState *s =3D bs->opaque; + int ret; + int remaining =3D s->cluster_size; + uint8_t *pos =3D ext_cluster; + ParallelsFormatExtensionHeader eh; + g_autofree uint8_t *hash =3D NULL; + size_t hash_len =3D 0; + GSList *bitmaps =3D NULL, *el; + + memcpy(&eh, pos, sizeof(eh)); + eh.magic =3D le64_to_cpu(eh.magic); + pos +=3D sizeof(eh); + remaining -=3D sizeof(eh); + + if (eh.magic !=3D PARALLELS_FORMAT_EXTENSION_MAGIC) { + error_setg(errp, "Wrong parallels Format Extension magic: 0x%" PRI= x64 + ", expected: 0x%llx", eh.magic, + PARALLELS_FORMAT_EXTENSION_MAGIC); + goto fail; + } + + ret =3D qcrypto_hash_bytes(QCRYPTO_HASH_ALG_MD5, (char *)pos, remainin= g, + &hash, &hash_len, errp); + if (ret < 0) { + goto fail; + } + + if (hash_len !=3D sizeof(eh.check_sum) || + memcmp(hash, eh.check_sum, sizeof(eh.check_sum)) !=3D 0) { + error_setg(errp, "Wrong checksum in Format Extension header. Forma= t " + "extension is corrupted."); + goto fail; + } + + while (true) { + ParallelsFeatureHeader fh; + BdrvDirtyBitmap *bitmap; + + if (remaining < sizeof(fh)) { + error_setg(errp, "Can not read feature header, as remaining by= tes " + "(%d) in Format Extension is less than Feature head= er " + "size (%zu)", remaining, sizeof(fh)); + goto fail; + } + + memcpy(&fh, pos, sizeof(fh)); + pos +=3D sizeof(fh); + remaining -=3D sizeof(fh); + + fh.magic =3D le64_to_cpu(fh.magic); + fh.flags =3D le64_to_cpu(fh.flags); + fh.data_size =3D le32_to_cpu(fh.data_size); + + if (fh.flags) { + error_setg(errp, "Flags for extension feature are unsupported"= ); + goto fail; + } + + if (fh.data_size > remaining) { + error_setg(errp, "Feature data_size exceedes Format Extension " + "cluster"); + goto fail; + } + + switch (fh.magic) { + case PARALLELS_END_OF_FEATURES_MAGIC: + return 0; + + case PARALLELS_DIRTY_BITMAP_FEATURE_MAGIC: + bitmap =3D parallels_load_bitmap(bs, pos, fh.data_size, errp); + if (!bitmap) { + goto fail; + } + bitmaps =3D g_slist_append(bitmaps, bitmap); + break; + + default: + error_setg(errp, "Unknown feature: 0x%" PRIu64, fh.magic); + goto fail; + } + + pos =3D ext_cluster + QEMU_ALIGN_UP(pos + fh.data_size - ext_clust= er, 8); + } + +fail: + for (el =3D bitmaps; el; el =3D el->next) { + bdrv_release_dirty_bitmap(el->data); + } + g_slist_free(bitmaps); + + return -EINVAL; +} + +int parallels_read_format_extension(BlockDriverState *bs, + int64_t ext_off, Error **errp) +{ + BDRVParallelsState *s =3D bs->opaque; + int ret; + uint8_t *ext_cluster =3D qemu_blockalign(bs, s->cluster_size); + + assert(ext_off > 0); + + ret =3D bdrv_pread(bs->file, ext_off, ext_cluster, s->cluster_size); + if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to read Format Extension clus= ter"); + goto out; + } + + ret =3D parallels_parse_format_extension(bs, ext_cluster, errp); + +out: + qemu_vfree(ext_cluster); + + return ret; +} diff --git a/block/parallels.c b/block/parallels.c index 9594d84978..6ebad2a2bb 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -29,6 +29,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/error-report.h" #include "qapi/error.h" #include "block/block_int.h" #include "block/qdict.h" @@ -843,6 +844,23 @@ static int parallels_open(BlockDriverState *bs, QDict = *options, int flags, goto fail_options; } =20 + if (ph.ext_off) { + if (flags & BDRV_O_RDWR) { + /* + * It's unsafe to open image RW if there is an extension (as we + * don't support it). But parallels driver in QEMU historically + * ignores the extension, so print warning and don't care. + */ + warn_report("Format Extension ignored in RW mode"); + } else { + ret =3D parallels_read_format_extension( + bs, le64_to_cpu(ph.ext_off) << BDRV_SECTOR_BITS, errp); + if (ret < 0) { + goto fail; + } + } + } + if ((flags & BDRV_O_RDWR) && !(flags & BDRV_O_INACTIVE)) { s->header->inuse =3D cpu_to_le32(HEADER_INUSE_MAGIC); ret =3D parallels_update_header(bs); diff --git a/block/meson.build b/block/meson.build index eeaefe5809..d21990ec95 100644 --- a/block/meson.build +++ b/block/meson.build @@ -57,7 +57,8 @@ block_ss.add(when: 'CONFIG_QED', if_true: files( 'qed-table.c', 'qed.c', )) -block_ss.add(when: [libxml2, 'CONFIG_PARALLELS'], if_true: files('parallel= s.c')) +block_ss.add(when: [libxml2, 'CONFIG_PARALLELS'], + if_true: files('parallels.c', 'parallels-ext.c')) block_ss.add(when: 'CONFIG_WIN32', if_true: files('file-win32.c', 'win32-a= io.c')) block_ss.add(when: 'CONFIG_POSIX', if_true: [files('file-posix.c'), coref,= iokit]) block_ss.add(when: libiscsi, if_true: files('iscsi-opts.c')) --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614965473; cv=none; d=zohomail.com; s=zohoarc; b=nwnRz/5BgBVIGrqW0BlTjAjLP1dwyYRTtEtKCDtEOCcUjx5Xl1aAS8NBH0R6xz2C8f6T/vzfSatBT7jombq6XDCzSyPcx2T50YbJaWAwZEEUgsZBde1jx0jTm5hstpjyOQG2YmKao7gX1hkn3Ijad+j5MnaWoMTlNH8tdVbfm6s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614965473; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=v/0MTEogR7ncRTYS6FzB/QFMjK8sxVV5NAE6z6ATlr4=; b=YhwnoHKiedJLc9JNGa71+r3i91J0CpJG9odXMpiREOS9g+EpTj6lNyU5qw5eZntoi+0a5jPwbbJT9yuj20kxJ23a+UHCD5g6yI1UKJqGCMxNvSC5FuFZ5/X32qOOa4grnFdj0D2Fod4phf3/J1E0ETsrkm3Xk0tHhopVSlJxrho= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614965473811262.32154703362414; Fri, 5 Mar 2021 09:31:13 -0800 (PST) Received: from localhost ([::1]:48838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIEIC-0006EX-CL for importer@patchew.org; Fri, 05 Mar 2021 12:31:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkR-00075Y-8e for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20318) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDk9-0007FF-E5 for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:18 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-66-4md_E53iPYqpptwW5XN1mA-1; Fri, 05 Mar 2021 11:55:56 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3F78787A82A; Fri, 5 Mar 2021 16:55:46 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 223AC60BF3; Fri, 5 Mar 2021 16:55:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963359; 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=v/0MTEogR7ncRTYS6FzB/QFMjK8sxVV5NAE6z6ATlr4=; b=ANpMPjR0jj5nB4herMwF12Oa9jsBae8zF12hnA/ubhqpWYlAfuAtV5eX3GrDp0WYybUS6Y tS6IWRo7WDXZoD7kF4qOFVoqW3AokPa3nA5HiKBtDLkN5stbgY1Rcz7OJb58BZJCxumcWF tMtmBJsAy5h0+WK22q+jsarjiniaf90= X-MC-Unique: 4md_E53iPYqpptwW5XN1mA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 28/31] iotests.py: add unarchive_sample_image() helper Date: Fri, 5 Mar 2021 17:54:51 +0100 Message-Id: <20210305165454.356840-29-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210224104707.88430-6-vsementsov@virtuozzo.com> Reviewed-by: Denis V. Lunev Signed-off-by: Kevin Wolf --- tests/qemu-iotests/iotests.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 4e758308f2..90d0b62523 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -17,6 +17,7 @@ # =20 import atexit +import bz2 from collections import OrderedDict import faulthandler import io @@ -24,6 +25,7 @@ import logging import os import re +import shutil import signal import struct import subprocess @@ -96,6 +98,14 @@ os.environ.get('IMGKEYSECRET', '') luks_default_key_secret_opt =3D 'key-secret=3Dkeysec0' =20 +sample_img_dir =3D os.environ['SAMPLE_IMG_DIR'] + + +def unarchive_sample_image(sample, fname): + sample_fname =3D os.path.join(sample_img_dir, sample + '.bz2') + with bz2.open(sample_fname) as f_in, open(fname, 'wb') as f_out: + shutil.copyfileobj(f_in, f_out) + =20 def qemu_tool_pipe_and_status(tool: str, args: Sequence[str], connect_stderr: bool =3D True) -> Tuple[str,= int]: --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614964447; cv=none; d=zohomail.com; s=zohoarc; b=VaEQxUUZvp/Yy/uWSeSecOnAYK4JqaC9iSYrN9QstBJLtsWJ6Wz7PXA4stwkBMhtgsd5LxP/C+CIOi1gY4Ud1tzB7ubjFB+YQK4Iao/U5UD+5ijKHT851TV97DCNrwQI7yQ/Xz/p2+SpbbY4PjDHKANBwsXlvaAeixPG39OBQbw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614964447; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cae2kkknNE/C4/3u4UBfwAIUtJ118zHDgw0ox10pAcE=; b=NBmhV47dfx/HhCxrDLS/6VU3bLjvEUKnTqtWl3fc7n1p/U+KWs0Oez2QSfZsJIIe08QGS7X2xl2lQawgVvv4NmXrRK5X6OL6UzaHJpH4ORBfAQzAjslBIwcxErCkpE7DtO6WMCj51B3ggxM+STgNQ0Xu+9MsSvucHZyhAo+IB4I= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614964447496294.2429396657702; Fri, 5 Mar 2021 09:14:07 -0800 (PST) Received: from localhost ([::1]:36318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIE1e-0004Bw-AD for importer@patchew.org; Fri, 05 Mar 2021 12:14:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkZ-0007TC-Pf for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21227) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDkB-0007Fj-BF for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:27 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-419-kmKxu0AUPqCgqbGBIRWt9Q-1; Fri, 05 Mar 2021 11:55:54 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8DE5310A2C73; Fri, 5 Mar 2021 16:55:47 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E44C60BF3; Fri, 5 Mar 2021 16:55:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963360; 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=cae2kkknNE/C4/3u4UBfwAIUtJ118zHDgw0ox10pAcE=; b=XBCWEaEU0Fg5crEZcjLd+ptGGz72qr+H1PqgbokCPWY69KTwtSX92fhlmHFzby+RRtrc4J 2DdgDilaLIJXxa87QGRq85ez2f6WmzRDVstTP6K3EnchqKvFeyY1V6lAINVUaLQj25W10B wJSJS8FqI+UcQ49NDVJY88OgFef5I6Q= X-MC-Unique: kmKxu0AUPqCgqbGBIRWt9Q-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 29/31] iotests: add parallels-read-bitmap test Date: Fri, 5 Mar 2021 17:54:52 +0100 Message-Id: <20210305165454.356840-30-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Test support for reading bitmap from parallels image format. parallels-with-bitmap.bz2 is generated on Virtuozzo by parallels-with-bitmap.sh Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210224104707.88430-7-vsementsov@virtuozzo.com> Reviewed-by: Denis V. Lunev Signed-off-by: Kevin Wolf --- .../sample_images/parallels-with-bitmap.bz2 | Bin 0 -> 203 bytes .../sample_images/parallels-with-bitmap.sh | 51 ++++++++++++++++ .../qemu-iotests/tests/parallels-read-bitmap | 55 ++++++++++++++++++ .../tests/parallels-read-bitmap.out | 6 ++ 4 files changed, 112 insertions(+) create mode 100644 tests/qemu-iotests/sample_images/parallels-with-bitmap.= bz2 create mode 100755 tests/qemu-iotests/sample_images/parallels-with-bitmap.= sh create mode 100755 tests/qemu-iotests/tests/parallels-read-bitmap create mode 100644 tests/qemu-iotests/tests/parallels-read-bitmap.out diff --git a/tests/qemu-iotests/sample_images/parallels-with-bitmap.bz2 b/t= ests/qemu-iotests/sample_images/parallels-with-bitmap.bz2 new file mode 100644 index 0000000000000000000000000000000000000000..54892fd4d01bf743d395bd4f3d8= 96494146ab5a9 GIT binary patch literal 203 zcmV;+05tzXT4*^jL0KkKS@=3D;0bpT+Hf7|^?KmNPH-R Fx`3oHQ9u9y literal 0 HcmV?d00001 diff --git a/tests/qemu-iotests/sample_images/parallels-with-bitmap.sh b/te= sts/qemu-iotests/sample_images/parallels-with-bitmap.sh new file mode 100755 index 0000000000..30615aa6bd --- /dev/null +++ b/tests/qemu-iotests/sample_images/parallels-with-bitmap.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# +# Test parallels load bitmap +# +# Copyright (c) 2021 Virtuozzo International GmbH. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +CT=3Dparallels-with-bitmap-ct +DIR=3D$PWD/parallels-with-bitmap-dir +IMG=3D$DIR/root.hds +XML=3D$DIR/DiskDescriptor.xml +TARGET=3Dparallels-with-bitmap.bz2 + +rm -rf $DIR + +prlctl create $CT --vmtype ct +prlctl set $CT --device-add hdd --image $DIR --recreate --size 2G + +# cleanup the image +qemu-img create -f parallels $IMG 64G + +# create bitmap +prlctl backup $CT + +prlctl set $CT --device-del hdd1 +prlctl destroy $CT + +dev=3D$(ploop mount $XML | sed -n 's/^Adding delta dev=3D\(\/dev\/ploop[0-= 9]\+\).*/\1/p') +dd if=3D/dev/zero of=3D$dev bs=3D64K seek=3D5 count=3D2 oflag=3Ddirect +dd if=3D/dev/zero of=3D$dev bs=3D64K seek=3D30 count=3D1 oflag=3Ddirect +dd if=3D/dev/zero of=3D$dev bs=3D64K seek=3D10 count=3D3 oflag=3Ddirect +ploop umount $XML # bitmap name will be in the output + +bzip2 -z $IMG + +mv $IMG.bz2 $TARGET + +rm -rf $DIR diff --git a/tests/qemu-iotests/tests/parallels-read-bitmap b/tests/qemu-io= tests/tests/parallels-read-bitmap new file mode 100755 index 0000000000..af6b9c5db3 --- /dev/null +++ b/tests/qemu-iotests/tests/parallels-read-bitmap @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +# +# Test parallels load bitmap +# +# Copyright (c) 2021 Virtuozzo International GmbH. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import json +import iotests +from iotests import qemu_nbd_popen, qemu_img_pipe, log, file_path + +iotests.script_initialize(supported_fmts=3D['parallels']) + +nbd_sock =3D file_path('nbd-sock', base_dir=3Diotests.sock_dir) +disk =3D iotests.file_path('disk') +bitmap =3D 'e4f2eed0-37fe-4539-b50b-85d2e7fd235f' +nbd_opts =3D f'driver=3Dnbd,server.type=3Dunix,server.path=3D{nbd_sock}' \ + f',x-dirty-bitmap=3Dqemu:dirty-bitmap:{bitmap}' + + +iotests.unarchive_sample_image('parallels-with-bitmap', disk) + + +with qemu_nbd_popen('--read-only', f'--socket=3D{nbd_sock}', + f'--bitmap=3D{bitmap}', '-f', iotests.imgfmt, disk): + out =3D qemu_img_pipe('map', '--output=3Djson', '--image-opts', nbd_op= ts) + chunks =3D json.loads(out) + cluster =3D 64 * 1024 + + log('dirty clusters (cluster size is 64K):') + for c in chunks: + assert c['start'] % cluster =3D=3D 0 + assert c['length'] % cluster =3D=3D 0 + if c['data']: + continue + + a =3D c['start'] // cluster + b =3D (c['start'] + c['length']) // cluster + if b - a > 1: + log(f'{a}-{b-1}') + else: + log(a) diff --git a/tests/qemu-iotests/tests/parallels-read-bitmap.out b/tests/qem= u-iotests/tests/parallels-read-bitmap.out new file mode 100644 index 0000000000..e8f6bc9e96 --- /dev/null +++ b/tests/qemu-iotests/tests/parallels-read-bitmap.out @@ -0,0 +1,6 @@ +Start NBD server +dirty clusters (cluster size is 64K): +5-6 +10-12 +30 +Kill NBD server --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614964203; cv=none; d=zohomail.com; s=zohoarc; b=Xl1DrRx97MVf//2PXsWyg0VjEfBRa9Kx2pKOws4vTHu3KnHKm1uLkpDZLzy4njwZk8/oz/O5UcNx3teiuR5RIErKAFPIS19mMulifIIM3jf9QYVY8rMslPugoZcscHGW4pYSQQOhNsXj0MFLTkF9WrwAP3OqpqKeWuPe9KBQPb0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614964203; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cnlIWFbLQyxKFXvROBObaSq3Yi+SBJmfZ+CHlarQyW8=; b=aNAZ6TwRhOzHWZOdm3DkZBBZeO89Kc0MFK1D9ZawrY1plSN2ufuD08ksosL7qNGLN3xa6EcAw2O9t+Ezj8JECzf2kYq69yEXI+erzGROfmC3hDIwHto4L7dn7ym7xgENn3PzW8Ke0Z7bcOrvMdon0ZA2wTp/wMIAl6VHv2Gv39s= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614964203739129.51040270131602; Fri, 5 Mar 2021 09:10:03 -0800 (PST) Received: from localhost ([::1]:52732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIDxi-0007KH-Fi for importer@patchew.org; Fri, 05 Mar 2021 12:10:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:32976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkP-00071l-UJ for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:39589) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDkA-0007GC-HP for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:17 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-194-2T3l_-cvM2StZJqPHBtXJA-1; Fri, 05 Mar 2021 11:55:57 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EA4DF881D32; Fri, 5 Mar 2021 16:55:48 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id DDF8360BF3; Fri, 5 Mar 2021 16:55:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963361; 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=cnlIWFbLQyxKFXvROBObaSq3Yi+SBJmfZ+CHlarQyW8=; b=Af3QqgLCfSiOgBL6PYqzXvMXkjG6VYV4fpYYysJG3NqtVnswrB4uliRmwyMKcBKrDbKs+k GaRS3eqVL4hk2p6pNSzWKQEteRZR9YHaW1W9ZXKO9HqDgQDvafNENu59pt8S469arbigAL ipOPy4WXEJu3MjaHKFILxx4C9O5kil8= X-MC-Unique: 2T3l_-cvM2StZJqPHBtXJA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 30/31] MAINTAINERS: update parallels block driver Date: Fri, 5 Mar 2021 17:54:53 +0100 Message-Id: <20210305165454.356840-31-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Add new parallels-ext.c and myself as co-maintainer. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210304095151.19358-1-vsementsov@virtuozzo.com> Reviewed-by: Denis V. Lunev Signed-off-by: Kevin Wolf --- MAINTAINERS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 4249acc62e..81e7c3b5e5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3126,10 +3126,13 @@ F: block/dmg.c parallels M: Stefan Hajnoczi M: Denis V. Lunev +M: Vladimir Sementsov-Ogievskiy L: qemu-block@nongnu.org S: Supported F: block/parallels.c +F: block/parallels-ext.c F: docs/interop/parallels.txt +T: git https://src.openvz.org/scm/~vsementsov/qemu.git parallels =20 qed M: Stefan Hajnoczi --=20 2.29.2 From nobody Sun Feb 8 13:17:03 2026 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=1614965225; cv=none; d=zohomail.com; s=zohoarc; b=J3moxlB0u3+0hik+jstP+G8EyJCsB1zWTPQjd9dP5ZEgvT0f1eBxgTN7GXVF7AeUHSH3vjxem6EoZDYayU2KpFaCqQYX5pjEmVki7CefaRU9TBkCyZYLEgu7fLR397n5eXyukjBh/IdUwBAlY1qDgr+bWpa6OAFz64iW36Iqw/A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614965225; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zj9j1ZEWuOQbTVEd/qkaDGzJknwawVzk2yYlGqA0zL0=; b=edqo0gYXH1eakWj+JunIVoGAnXtC7NOKrnuZiUyHDLAXL/T34MxXbjX0AF4Yn8UtpZuG4IH2uupB/HDGp4z16uLQB4cgXTGO1bGywfr6DveucoeldD7FmkKcvO9f+a6JWfAWNn7pMaKd8tSaxgx14iZyqI1ZZP3VUlemy2d6Mjs= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614965225479280.29499640684276; Fri, 5 Mar 2021 09:27:05 -0800 (PST) Received: from localhost ([::1]:40336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIEEC-0002dQ-Bv for importer@patchew.org; Fri, 05 Mar 2021 12:27:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:32996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIDkQ-00074P-Qz for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44720) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lIDkB-0007G6-2E for qemu-devel@nongnu.org; Fri, 05 Mar 2021 11:56:18 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-481-AfCvh-KcN8C5YnpRO_jr6w-1; Fri, 05 Mar 2021 11:55:56 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6D76FE4975; Fri, 5 Mar 2021 16:55:53 +0000 (UTC) Received: from merkur.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 45E5D60BF3; Fri, 5 Mar 2021 16:55:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614963361; 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=zj9j1ZEWuOQbTVEd/qkaDGzJknwawVzk2yYlGqA0zL0=; b=MdwkqieP/R0vzfEDNG0HGIz+PsaB2j8RAFB7rlU+AZcXJpA0DkvY7RL6t/jee5ZbDaCn37 47hDvYtztVHizDmDrj8XXBudtK7XvMxNMBjR5h//S1xWS9QeCzbENEpW+cQRFSGepG2Lad 030STkfdKN0Z5cZ5z/jgnC1+IvRGZCg= X-MC-Unique: AfCvh-KcN8C5YnpRO_jr6w-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 31/31] docs: qsd: Explain --export nbd,name=... default Date: Fri, 5 Mar 2021 17:54:54 +0100 Message-Id: <20210305165454.356840-32-kwolf@redhat.com> In-Reply-To: <20210305165454.356840-1-kwolf@redhat.com> References: <20210305165454.356840-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The 'name' option for NBD exports is optional. Add a note that the default for the option is the node name (people could otherwise expect that it's the empty string like for qemu-nbd). Signed-off-by: Kevin Wolf Message-Id: <20210305094856.18964-1-kwolf@redhat.com> Reviewed-by: Max Reitz Signed-off-by: Kevin Wolf --- docs/tools/qemu-storage-daemon.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/tools/qemu-storage-daemon.rst b/docs/tools/qemu-storage-d= aemon.rst index fe3042d609..086493ebb3 100644 --- a/docs/tools/qemu-storage-daemon.rst +++ b/docs/tools/qemu-storage-daemon.rst @@ -80,8 +80,9 @@ Standard options: requests for modifying data (the default is off). =20 The ``nbd`` export type requires ``--nbd-server`` (see below). ``name`` = is - the NBD export name. ``bitmap`` is the name of a dirty bitmap reachable = from - the block node, so the NBD client can use NBD_OPT_SET_META_CONTEXT with = the + the NBD export name (if not specified, it defaults to the given + ``node-name``). ``bitmap`` is the name of a dirty bitmap reachable from = the + block node, so the NBD client can use NBD_OPT_SET_META_CONTEXT with the metadata context name "qemu:dirty-bitmap:BITMAP" to inspect the bitmap. =20 The ``vhost-user-blk`` export type takes a vhost-user socket address on = which --=20 2.29.2