From nobody Mon May 6 14:02:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622623588; cv=none; d=zohomail.com; s=zohoarc; b=Z/fYozu2vRuvzGeUX1vBOZrBR8ZXY2omkGtRAKXnqCo8XlFaIKXGm6GChohEw8G10HoSGOUI6hrGU1ESSg/27tCaYlrmn9U1h+OkTLJohEdqzY4AmOr29aPFo5BSzzUdxbymrU28Q+qsC7rugYTWiIAYKfMrwQGwiYqL3PrQ/PY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622623588; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=Ijg4/wt9hFDupzN7Cvgmsue7oltWcx0E/HMJj6vlZtE=; b=BfSA6gdH27Njht0qEL38jw3mYP4c9H+83m0OobkDuEo/JzS2X/ITLpYo763LCEC2bL9+rSJp5Q4XArHCjeUTofR+eEAR/bOeP1E+hqDmkbgCmqlbaj7BXPHH2a1CuX1V753rOq+JAqyQ4nWNTaGk+n6H07TGIJtwZJ3und9SS/U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1622623587940247.4072667645995; Wed, 2 Jun 2021 01:46:27 -0700 (PDT) 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-340-IKYIN15APIu0Xj5niVPB1Q-1; Wed, 02 Jun 2021 04:46:23 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E996C180FD66; Wed, 2 Jun 2021 08:46:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AE23A60C0F; Wed, 2 Jun 2021 08:46:16 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CF2AF44A59; Wed, 2 Jun 2021 08:46:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1528kA8F029593 for ; Wed, 2 Jun 2021 04:46:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 75C61E460; Wed, 2 Jun 2021 08:46:10 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.251]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBD83E2F0 for ; Wed, 2 Jun 2021 08:46:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622623585; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Ijg4/wt9hFDupzN7Cvgmsue7oltWcx0E/HMJj6vlZtE=; b=JY/2WLjO/pt359r5Nd+AdFkPhYELu9sLeivb20qI2IMs0zSe4c4MiGEaGEwHY8WjXH+mal rPaQ40Xk2HzGFU2wRhxb+P4HKvHWuxvyKKgTf0NLiF8E90VZYbMrtKmrh+1d0h66Nciy3C BbMSC2trhfpOwiNm+uILeYhDR8CaAo8= X-MC-Unique: IKYIN15APIu0Xj5niVPB1Q-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] storage: Don't overwrite error in virISCSIDirectDisconnect() Date: Wed, 2 Jun 2021 10:46:04 +0200 Message-Id: <89397c4277937f8c71af965e021ac5e7c4f4fe26.1622623550.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The iscsi-direct storage pool backend works merely like this: a connection is established to the target (usually done via virStorageBackendISCSIDirectSetConnection()), intended action is executed (e.g. reporting LUNs, volume wiping), and at the end the connection is closed via virISCSIDirectDisconnect(). The problem is that virISCSIDirectDisconnect() reports its own errors which may overwrite error that occurred during LUN reporting, or volume wiping or whatever. To fix this, use virErrorPreserveLast() + virErrorRestore() combo, which either preserves previously reported error message, or is NOP if there's no error reported. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1797879 Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/storage/storage_backend_iscsi_direct.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/storage/storage_backend_iscsi_direct.c b/src/storage/stora= ge_backend_iscsi_direct.c index 0bff1882b9..e4a14c3fd6 100644 --- a/src/storage/storage_backend_iscsi_direct.c +++ b/src/storage/storage_backend_iscsi_direct.c @@ -391,19 +391,28 @@ virISCSIDirectReportLuns(virStoragePoolObj *pool, static int virISCSIDirectDisconnect(struct iscsi_context *iscsi) { + virErrorPtr orig_err; + int ret =3D -1; + + virErrorPreserveLast(&orig_err); + if (iscsi_logout_sync(iscsi) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to logout: %s"), iscsi_get_error(iscsi)); - return -1; + goto cleanup; } if (iscsi_disconnect(iscsi) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to disconnect: %s"), iscsi_get_error(iscsi)); - return -1; + goto cleanup; } - return 0; + + ret =3D 0; + cleanup: + virErrorRestore(&orig_err); + return ret; } =20 static int --=20 2.31.1