From nobody Mon Feb 9 10:28:02 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 ARC-Seal: i=1; a=rsa-sha256; t=1592317453; cv=none; d=zohomail.com; s=zohoarc; b=PVIk5rXXYLumvcAkzyNQ2Bs4ZzUA/yXrcGsRDX1B0laUf4kNheupxTMdWTV7iSbz6UpveRcbDXoQBgNGP0ljWOPh3Y6WB8mTrY61y2ysoksq8mbgxq6jxXyXP+L5kperJXixHgHU2DVbVaMAcEqxoNH8qNXMbiYVdHKeZVrSzdA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592317453; 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; bh=wsVxcj7mHh7vxJ9uceuL9aJXpHZ9FIzGFrt0QiTuCIs=; b=k6hKy03Hat8fMkGPzsw2qqcl1PEsl2TqhuvzV+isyhDh+91QMpgj+u2VDnLqs3+D3A3r4be8lTy2TzbKb1yGocb7i6ueT6quFTL64O1v/VL0RYv6frrwYyHGpgioeshWFzPJNIH4sh9+Cn2ETEXJOCgcjmaJma4KV5bWgLwigOU= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592317453893837.5691565623279; Tue, 16 Jun 2020 07:24:13 -0700 (PDT) Received: from localhost ([::1]:40676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCVY-0002TH-LI for importer@patchew.org; Tue, 16 Jun 2020 10:24:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCPU-0001oZ-0V; Tue, 16 Jun 2020 10:17:56 -0400 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]:39436) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCPS-0006as-Dq; Tue, 16 Jun 2020 10:17:55 -0400 Received: by mail-ot1-x32a.google.com with SMTP id g5so16040353otg.6; Tue, 16 Jun 2020 07:17:53 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id 94sm4058183otb.47.2020.06.16.07.17.51 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:17:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=wsVxcj7mHh7vxJ9uceuL9aJXpHZ9FIzGFrt0QiTuCIs=; b=GHQLTYnIqkdqWcDxp5+h4DNlNoZ2Dx2hG/6qJ5sWG1T0RAQkKAJ9rgKH7jm9QIVgE1 BaRJMq/Gx1QYMQVX+IGws+JHRsNAr/TtJ74Tqii+qBLcr973vN44R9bhBlRfPDf5bU0N 4V+HcHcK0e0MGjA3IJpEUVjkJKWqPbyr20d4I7tksQiIMqebdWXlM8cMCcT/KR0VIkdh L5lXENcuPjUqjntH4FktK40Tegro3LYfa32mUPVwT9KblAYjFwueS3vOERlvrt/dYtGW 7i2fcOv98hr9NTgKwKRxL5rTt964Mt2NJIH239GNWRWj8uduomjt0ArWDhqRD3ghvJHT 6dfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=wsVxcj7mHh7vxJ9uceuL9aJXpHZ9FIzGFrt0QiTuCIs=; b=r0pp7rzwbJdyqR0AJGO7uX7Cu6pZASU5JVN1RWJDcHEhmFi/LH8JSWD+fk6bf6NPs/ rrJ6tHBbKJBROyPhhB96CVSL9YIa6M6SkPS8FFDUdN6TolkM51zhWJ9RrQxz7qnc1N2v voRSfAx8cq870MBwlXCHMNaKM7C3IPSO50EHS9f3N+0PvlUenH9qEYvY862QzIzk8Evj EMiFOkh6gniSFnVncGUYzG3sfQNePYTvab+3000XT/loOx5GkjoULjc9s1+eDXmnZaqF DldRGTEyM+j5/QlV6pHxHx9OYtAYnOKZ1ZejOuTNs04PwSdK5oqAxNjB+3gwwOrxEaNo J2fA== X-Gm-Message-State: AOAM533CnwNMZBzUDGEh4lXANn1Lvn96yh6jZTH1H9Etc7yOnbra9Pxr wX5uu5Bz41UZndDezXA2jYl5IgVs X-Google-Smtp-Source: ABdhPJzkd61bS8jCe+hRa+KGIYvcT1VY2DH5Dq5QSQWZ5hzPrHoCSj6gqIf33l1Lcalogd98feVmZw== X-Received: by 2002:a05:6830:22f1:: with SMTP id t17mr2655990otc.288.1592317072481; Tue, 16 Jun 2020 07:17:52 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 01/78] block/nbd: extract the common cleanup code Date: Tue, 16 Jun 2020 09:14:30 -0500 Message-Id: <20200616141547.24664-2-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> 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=2607:f8b0:4864:20::32a; envelope-from=flukshun@gmail.com; helo=mail-ot1-x32a.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN 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: Pan Nengyuan , qemu-stable@nongnu.org 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: Pan Nengyuan The BDRVNBDState cleanup code is common in two places, add nbd_clear_bdrvstate() function to do these cleanups. Suggested-by: Stefano Garzarella Signed-off-by: Pan Nengyuan Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <1575517528-44312-2-git-send-email-pannengyuan@huawei.com> Reviewed-by: Eric Blake [eblake: fix compilation error and commit message] Signed-off-by: Eric Blake (cherry picked from commit 7f493662be4045146a8f45119d8834c9088a0ad6) Signed-off-by: Michael Roth --- block/nbd.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/block/nbd.c b/block/nbd.c index 5f18f78a94..6bb6715286 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -94,6 +94,19 @@ typedef struct BDRVNBDState { =20 static int nbd_client_connect(BlockDriverState *bs, Error **errp); =20 +static void nbd_clear_bdrvstate(BDRVNBDState *s) +{ + object_unref(OBJECT(s->tlscreds)); + qapi_free_SocketAddress(s->saddr); + s->saddr =3D NULL; + g_free(s->export); + s->export =3D NULL; + g_free(s->tlscredsid); + s->tlscredsid =3D NULL; + g_free(s->x_dirty_bitmap); + s->x_dirty_bitmap =3D NULL; +} + static void nbd_channel_error(BDRVNBDState *s, int ret) { if (ret =3D=3D -EIO) { @@ -1864,11 +1877,7 @@ static int nbd_process_options(BlockDriverState *bs,= QDict *options, =20 error: if (ret < 0) { - object_unref(OBJECT(s->tlscreds)); - qapi_free_SocketAddress(s->saddr); - g_free(s->export); - g_free(s->tlscredsid); - g_free(s->x_dirty_bitmap); + nbd_clear_bdrvstate(s); } qemu_opts_del(opts); return ret; @@ -1947,12 +1956,7 @@ static void nbd_close(BlockDriverState *bs) BDRVNBDState *s =3D bs->opaque; =20 nbd_client_close(bs); - - object_unref(OBJECT(s->tlscreds)); - qapi_free_SocketAddress(s->saddr); - g_free(s->export); - g_free(s->tlscredsid); - g_free(s->x_dirty_bitmap); + nbd_clear_bdrvstate(s); } =20 static int64_t nbd_getlength(BlockDriverState *bs) --=20 2.17.1