From nobody Mon Feb 9 01:30:50 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601041860; cv=none; d=zohomail.com; s=zohoarc; b=BJK1ccEjDrzGhujUXLBMZ+VuJ6xeqLoK59LIyY4dsQ+cpQcslNY/PAYcdcukdT/bn5hkXB5XOxR6JSM1VCdOQjw56FENMYHNsCdT6HykzmE8oVKPkdsU2M3MUjFi0aEtwvIMjPQYx2lSOkia582+H6WLPTOrNqjKAMyZw4tl2J4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601041860; 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=on72vSdxS28kZfDu2pYVVObQVetDsjIKlZe+QSATkhs=; b=NXN2V/9uDdIY7afl4Br+lr3C4NYoWd3gZ0nQk04W/2BmUCSq33biXEJsIkFmRlo2wTL4+AOXkaMVP0DoQ2/Y1TnTItAvhMZE9pPBmluoSaqup5TWAgF039IEjoBk2oM18gJeoo+EwtAFudyjbQFzVJ4szENONRizvj8eQirNQVU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 160104186000746.73266770875466; Fri, 25 Sep 2020 06:51:00 -0700 (PDT) Received: from localhost ([::1]:40164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLo7m-00044V-M5 for importer@patchew.org; Fri, 25 Sep 2020 09:50:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33324) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLo01-0004lu-6l for qemu-devel@nongnu.org; Fri, 25 Sep 2020 09:42:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22938) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLnzy-0008KK-MI for qemu-devel@nongnu.org; Fri, 25 Sep 2020 09:42:56 -0400 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-289-w7SSzs2WO-GAcofAhYLlLQ-1; Fri, 25 Sep 2020 09:42:50 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A081280732A; Fri, 25 Sep 2020 13:42:49 +0000 (UTC) Received: from localhost (ovpn-115-66.ams2.redhat.com [10.36.115.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4451155786; Fri, 25 Sep 2020 13:42:49 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601041374; 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=on72vSdxS28kZfDu2pYVVObQVetDsjIKlZe+QSATkhs=; b=AJcm78M5LgvZGHyD15S9x2Ifo0/V0V7w2nPg4IQJPxbrNY00PJlY2vgRY22oJn+ZrrbJbc o30VZoFAoLvJtqQlmmtAxL7wI56fJJBki3UWglTWz9A9wfHwMcOcPuRsraM/M16ynOCWfM v0blIEduhRVkHOA0G2IUZ2ezuky0REE= X-MC-Unique: w7SSzs2WO-GAcofAhYLlLQ-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PATCH 4/4] block/export: add BlockExportOptions->iothread member Date: Fri, 25 Sep 2020 14:42:29 +0100 Message-Id: <20200925134229.246169-5-stefanha@redhat.com> In-Reply-To: <20200925134229.246169-1-stefanha@redhat.com> References: <20200925134229.246169-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=stefanha@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=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/25 02:48:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MIME_BASE64_TEXT=1.741, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Kevin Wolf , Laurent Vivier , Thomas Huth , qemu-block@nongnu.org, Markus Armbruster , Coiby Xu , Max Reitz , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Make it possible to specify the iothread where the export will run. Signed-off-by: Stefan Hajnoczi --- Note the x-blockdev-set-iothread QMP command can be used to do the same, but not from the command-line. And it requires sending an additional command. In the long run vhost-user-blk will support per-virtqueue iothread mappings. But for now a single iothread makes sense and most other transports will just use one iothread anyway. --- qapi/block-export.json | 4 ++++ block/export/export.c | 26 +++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/qapi/block-export.json b/qapi/block-export.json index 87ac5117cd..eba6f6eae9 100644 --- a/qapi/block-export.json +++ b/qapi/block-export.json @@ -219,11 +219,15 @@ # export before completion is signalled. (since: 5.2; # default: false) # +# @iothread: The name of the iothread object where the export will run. The +# default is the main loop thread. (since: 5.2) +# # Since: 4.2 ## { 'union': 'BlockExportOptions', 'base': { 'type': 'BlockExportType', 'id': 'str', + '*iothread': 'str', 'node-name': 'str', '*writable': 'bool', '*writethrough': 'bool' }, diff --git a/block/export/export.c b/block/export/export.c index 550897e236..0fb3d76ee3 100644 --- a/block/export/export.c +++ b/block/export/export.c @@ -15,6 +15,7 @@ =20 #include "block/block.h" #include "sysemu/block-backend.h" +#include "sysemu/iothread.h" #include "block/export.h" #include "block/nbd.h" #include "qapi/error.h" @@ -66,7 +67,7 @@ BlockExport *blk_exp_add(BlockExportOptions *export, Erro= r **errp) const BlockExportDriver *drv; BlockExport *exp =3D NULL; BlockDriverState *bs; - BlockBackend *blk; + BlockBackend *blk =3D NULL; AioContext *ctx; uint64_t perm; int ret; @@ -102,6 +103,29 @@ BlockExport *blk_exp_add(BlockExportOptions *export, E= rror **errp) ctx =3D bdrv_get_aio_context(bs); aio_context_acquire(ctx); =20 + if (export->has_iothread) { + IOThread *iothread; + AioContext *new_ctx; + + iothread =3D iothread_by_id(export->iothread); + if (!iothread) { + error_setg(errp, "iothread \"%s\" not found", export->iothread= ); + goto fail; + } + + new_ctx =3D iothread_get_aio_context(iothread); + + ret =3D bdrv_try_set_aio_context(bs, new_ctx, errp); + if (ret !=3D 0) { + goto fail; + } + + aio_context_release(ctx); + aio_context_acquire(new_ctx); + + ctx =3D new_ctx; + } + /* * Block exports are used for non-shared storage migration. Make sure * that BDRV_O_INACTIVE is cleared and the image is ready for write --=20 2.26.2