From nobody Mon Feb 9 16:18:23 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1563330924; cv=none; d=zoho.com; s=zohoarc; b=hAKSyKMc5h/fNz+rURhZWX/b16Tt8WKfS04kZUbqUN+icUSnXBmR9j6plpd6Z5kSzxu4X/Ct0VeKRs5SlrWNNqe2Wte2PVupWePBikzaFhvOg4NYPTuGO6sUF0dJWcZCTGtAnUfwmCJmgPiQ+Oa8jbrLw4fTM+tayzfECQycZmo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563330924; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=VM7YAJwry+wyZ2yuE+WkugvtQMJfdLiPFMhwqCS6SXA=; b=QUUZ0xP3AbBZPUjiVml5/q1W47VUoqhdlKvi3cX5dBvbhXQUjiN5D2gbp2pJal7Wxtxa7Am1ZdXRapR2+DFoRBHM9a7vbnTVBEeNvMlrggiZr3gtHtXztB/B6wq8lsOLsFOSnyk6K7QCjQXytvicN+aBYIQJ7/tuF5EF5m6qD4Y= ARC-Authentication-Results: i=1; mx.zoho.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 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 1563330924726751.4326539116834; Tue, 16 Jul 2019 19:35:24 -0700 (PDT) Received: from localhost ([::1]:53664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnZmt-00079E-41 for importer@patchew.org; Tue, 16 Jul 2019 22:35:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53087) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnZlS-0001S2-6s for qemu-devel@nongnu.org; Tue, 16 Jul 2019 22:33:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hnZlR-0006Hq-5A for qemu-devel@nongnu.org; Tue, 16 Jul 2019 22:33:54 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:39835) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hnZlQ-0006HI-Ud for qemu-devel@nongnu.org; Tue, 16 Jul 2019 22:33:53 -0400 Received: by mail-pg1-x542.google.com with SMTP id u17so10369854pgi.6 for ; Tue, 16 Jul 2019 19:33:52 -0700 (PDT) Received: from n3-021-211.byted.org ([49.7.44.72]) by smtp.gmail.com with ESMTPSA id b1sm20986530pfi.91.2019.07.16.19.33.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jul 2019 19:33:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VM7YAJwry+wyZ2yuE+WkugvtQMJfdLiPFMhwqCS6SXA=; b=AwCpgJ1jy+igCKsUWWOo+oZNqPZgx31GZusSNWrwJpHO6kHb+xE5oWBxgqncc7INiC inryyUtPHeUBUmFWbu5gYzyw3SP2izEyK5UJGnaKMtav26WacuVlVOQCDNhdHvxAUs8J mQIGQ+zfgF26CwZbiPlus1j7Q6qvRz4dr3ow2UW1V+tBJNPcTSRK+gaxyxkw07ILEVgq f3s+9034EVU3MJ5lPIAZW8MQhaWaBwQ68QwD+zgB2RgwofJrD+dKUX9Qalfldtdu6UP5 Vu1DzRlZ3/63CmVHxzTJjX1GSh3G34b1jJYvE9SBYRi2XUz8eFaKf97WlN2CJ4Zr/yS7 E3FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VM7YAJwry+wyZ2yuE+WkugvtQMJfdLiPFMhwqCS6SXA=; b=bdklQZ2JfG3HFT9rjRRLpznTd27flR3bgP5tmCk+rnAJULzqw4STfCZ1pVkatkCfmB 5OazCIYRlbCEoCXVR3yZMRu+kjRN6hcWn+iMHcMaQ0+2JwxjYet3X3xVsR39Pf0YbHp7 77xV/kJhxl9Cmqo7nvBZKZbIhLSskXza11UxzlK5zqv3R9jLfAV/aWKf+ChZLh8/fWO7 OriNyLD7CdP3neoWjgLXr8xJLMQSZLzVcxDCm3Vuoe5zbotOmpvtXfrp5xyLYKBi9RA+ 0fzgs7kdCoDcwazMKZ98or4kiw6lRKBb2N4UICgRcUDJ9cm3kpKosKaaunXT5qTB7xOK wgNA== X-Gm-Message-State: APjAAAWkkyqIJKMKDmUOImZs1CNsdABlkzxRBxuaHJnHC60VEa2cCC9h Sc8dhwWEKQpMxC4c7eSRPbmr4hJ3 X-Google-Smtp-Source: APXvYqx52Lkfej/uv7TQ0xluHXOfs3fh8G8OLSMq4JZQ3RDPh0ms84JK2QeUZUCL3YN4oE4u1L8iDg== X-Received: by 2002:a65:4103:: with SMTP id w3mr25808719pgp.1.1563330831645; Tue, 16 Jul 2019 19:33:51 -0700 (PDT) From: Fei Li To: qemu-devel@nongnu.org, shirley17fei@gmail.com Date: Wed, 17 Jul 2019 10:33:06 +0800 Message-Id: <20190717023310.197246-8-shirley17fei@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190717023310.197246-1-shirley17fei@gmail.com> References: <20190717023310.197246-1-shirley17fei@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH v14 07/11] qemu_thread: supplement error handling for iothread_complete 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: Markus Armbruster , Peter Xu , "Dr . David Alan Gilbert" , Fei Li , Gerd Hoffmann , Stefan Hajnoczi , David Gibson 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