From patchwork Sun Mar 24 16:52:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: fei X-Patchwork-Id: 1063286 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=126.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.b="oR/HTCcp"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44S3Vs340Bz9sSh for ; Mon, 25 Mar 2019 03:58:13 +1100 (AEDT) Received: from localhost ([127.0.0.1]:58429 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h86Rn-0006nY-9r for incoming@patchwork.ozlabs.org; Sun, 24 Mar 2019 12:58:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h86Qj-0006aG-8D for qemu-devel@nongnu.org; Sun, 24 Mar 2019 12:57:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h86Mh-0005ic-L9 for qemu-devel@nongnu.org; Sun, 24 Mar 2019 12:52:56 -0400 Received: from m50-112.126.com ([123.125.50.112]:38526) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h86Mg-0005hB-Qg for qemu-devel@nongnu.org; Sun, 24 Mar 2019 12:52:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=VM7YAJwry+wyZ2yuE+ WkugvtQMJfdLiPFMhwqCS6SXA=; b=oR/HTCcp866PsIycQvgfHGCHrg4HGFKUZ3 FTWTrFf64R7WLUYf5OYpxfPaLfLMhZ8F+LJ6+QMkpE5f6NF6x9vThaACFcQMuWzS rdCGoxEhZWqxn3qhDuGKcARccn+daKxbjlHfAK/Q/yUvV7Ic5BFtFE6bc2KsLlE0 O4VtLZQUs= Received: from n3-021-211.byted.org (unknown [49.7.44.57]) by smtp6 (Coremail) with SMTP id j9KowABnE7HBtZdcGev0AA--.5136S9; Mon, 25 Mar 2019 00:52:38 +0800 (CST) From: Fei Li To: qemu-devel@nongnu.org, shirley17fei@gmail.com Date: Mon, 25 Mar 2019 00:52:02 +0800 Message-Id: <20190324165206.25766-8-lifei1214@126.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190324165206.25766-1-lifei1214@126.com> References: <20190324165206.25766-1-lifei1214@126.com> X-CM-TRANSID: j9KowABnE7HBtZdcGev0AA--.5136S9 X-Coremail-Antispam: 1Uf129KBjvJXoW7AFyDWr1fKF45Jr15Cr1Dtrb_yoW8urykpr yDC390qr97ZrnFy3yfJa1kZFy5Xr4FqFW7CryFy3WxAw17uan8XrW8Ka4jgFs3Ca4vqrWr ZFZ8KrZ8G398AFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j66wZUUUUU= X-Originating-IP: [49.7.44.57] X-CM-SenderInfo: 5olivxarsrkqqrswhudrp/1tbiaBeBIVpD8K3D9AAAss X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 123.125.50.112 Subject: [Qemu-devel] [PATCH v12 for-4.1 07/11] qemu_thread: supplement error handling for iothread_complete X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , Peter Xu , "Dr . David Alan Gilbert" , Fei Li , Gerd Hoffmann , Stefan Hajnoczi , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Fei Li Utilize the existed errp to propagate the error and do the corresponding cleanup to replace the temporary &error_abort. Cc: Markus Armbruster Cc: Stefan Hajnoczi Cc: Eric Blake Signed-off-by: Fei Li Reviewed-by: Markus Armbruster --- iothread.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/iothread.c b/iothread.c index 2d5a5bfe6c..1ebacaf089 100644 --- a/iothread.c +++ b/iothread.c @@ -166,6 +166,7 @@ static void iothread_complete(UserCreatable *obj, Error **errp) Error *local_error = NULL; IOThread *iothread = IOTHREAD(obj); char *name, *thread_name; + int thread_ok; iothread->stopping = false; iothread->running = true; @@ -188,9 +189,7 @@ static void iothread_complete(UserCreatable *obj, Error **errp) &local_error); if (local_error) { error_propagate(errp, local_error); - aio_context_unref(iothread->ctx); - iothread->ctx = NULL; - return; + goto fail; } /* This assumes we are called from a thread with useful CPU affinity for us @@ -198,16 +197,23 @@ static void iothread_complete(UserCreatable *obj, Error **errp) */ name = object_get_canonical_path_component(OBJECT(obj)); thread_name = g_strdup_printf("IO %s", name); - /* TODO: let the further caller handle the error instead of abort() here */ - qemu_thread_create(&iothread->thread, thread_name, iothread_run, - iothread, QEMU_THREAD_JOINABLE, &error_abort); + thread_ok = qemu_thread_create(&iothread->thread, thread_name, iothread_run, + iothread, QEMU_THREAD_JOINABLE, errp); g_free(thread_name); g_free(name); + if (thread_ok < 0) { + qemu_sem_destroy(&iothread->init_done_sem); + goto fail; + } /* Wait for initialization to complete */ while (iothread->thread_id == -1) { qemu_sem_wait(&iothread->init_done_sem); } + return; +fail: + aio_context_unref(iothread->ctx); + iothread->ctx = NULL; } typedef struct {