From nobody Tue Feb 10 14:33:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.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=126.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1553448386516268.25609480587934; Sun, 24 Mar 2019 10:26:26 -0700 (PDT) Received: from localhost ([127.0.0.1]:58800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h86t5-0005hx-Hz for importer@patchew.org; Sun, 24 Mar 2019 13:26:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h86oq-0002CA-TJ for qemu-devel@nongnu.org; Sun, 24 Mar 2019 13:22:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h86op-0000M7-PQ for qemu-devel@nongnu.org; Sun, 24 Mar 2019 13:22:00 -0400 Received: from m15-112.126.com ([220.181.15.112]:50646) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h86oo-0000JO-S6 for qemu-devel@nongnu.org; Sun, 24 Mar 2019 13:21:59 -0400 Received: from localhost.localdomain (unknown [1.202.123.222]) by smtp2 (Coremail) with SMTP id DMmowABHfEGxvJdcvRevCA--.55336S9; Mon, 25 Mar 2019 01:21:56 +0800 (CST) 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=PzVerq376zTnLEXwyTmxVzaatiuuOhhnUz K3MwpFPUeUDt/hT32thTWqoHd65Rybo5kokKHOyYI4r7vc+z2Ho97AoPzKjJz1Zj IpzX8gXri8YKKAlmXtGpYNqD9KUVgA4/R3356A+Rd+Y7jTRkvDP8jgjmF4XOvCwB ZAM7nsiXg= From: Fei Li To: qemu-devel@nongnu.org Date: Mon, 25 Mar 2019 01:21:44 +0800 Message-Id: <20190324172148.3566-8-lifei1214@126.com> X-Mailer: git-send-email 2.17.2 (Apple Git-113) In-Reply-To: <20190324172148.3566-1-lifei1214@126.com> References: <20190324172148.3566-1-lifei1214@126.com> X-CM-TRANSID: DMmowABHfEGxvJdcvRevCA--.55336S9 X-Coremail-Antispam: 1Uf129KBjvJXoW7AFyDWr1fKF45Jr15Cr1Dtrb_yoW8urykpr yDC390qr97ZrnFy3yfJa1kZFy5Xr4FqFW7CryFy3WxAw17uan8XrW8Ka4jgFs3Ca4vqrWr ZFZ8KrZ8G398AFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jt_-PUUUUU= X-Originating-IP: [1.202.123.222] X-CM-SenderInfo: 5olivxarsrkqqrswhudrp/1tbiaBSBIVpD8K4BwwAAsZ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.15.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: lifei1214@126.com, Fei Li , Markus Armbruster , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 =3D NULL; IOThread *iothread =3D IOTHREAD(obj); char *name, *thread_name; + int thread_ok; =20 iothread->stopping =3D false; iothread->running =3D 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 =3D NULL; - return; + goto fail; } =20 /* This assumes we are called from a thread with useful CPU affinity f= or us @@ -198,16 +197,23 @@ static void iothread_complete(UserCreatable *obj, Err= or **errp) */ name =3D object_get_canonical_path_component(OBJECT(obj)); thread_name =3D g_strdup_printf("IO %s", name); - /* TODO: let the further caller handle the error instead of abort() he= re */ - qemu_thread_create(&iothread->thread, thread_name, iothread_run, - iothread, QEMU_THREAD_JOINABLE, &error_abort); + thread_ok =3D qemu_thread_create(&iothread->thread, thread_name, iothr= ead_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; + } =20 /* Wait for initialization to complete */ while (iothread->thread_id =3D=3D -1) { qemu_sem_wait(&iothread->init_done_sem); } + return; +fail: + aio_context_unref(iothread->ctx); + iothread->ctx =3D NULL; } =20 typedef struct { --=20 2.11.0