From nobody Mon Apr 29 06:26:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1635261676; cv=none; d=zohomail.com; s=zohoarc; b=VCjV2FnieVdP8m64glA3KLl1OtnJEGU5ym7oT0Ceyl81UzSq2iQdOcaWe6bMJrpYmirCTwcBEA9I6FVqJZ2Dj+qd4jSqDd4XPy42pk7lfbG8oOMziR0AwCpI5IZqdwnrXYity9s15e3qUTfTEFBLCQL+HApdqyhbi3UYKJgp97Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635261676; 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=tLXtC5UOrRV0SgOJTSRJ5GYuxj/xBMm+XtTE86SZ15k=; b=bXZLHq3ACbxUz5tIADk2p0HRvJENDhyKAt4pfFJraTBoGN6pVCiQ7kPMtD+RQm6yp2//OHtd6Yg+JtaPYD3yEn2ZR0xffLtFw8ZmNzIjRc3iJ0xaWIpLy5lxZqpJBxRR2ZVkjaqG4894lA0R6oRUfX5QTzDJ0QGjaqJXHBBaZzY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1635261676787350.3121743089231; Tue, 26 Oct 2021 08:21:16 -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-301-tSU4nYYJMgaBIJtwf7fw2g-1; Tue, 26 Oct 2021 11:21:13 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C8092112A0A1; Tue, 26 Oct 2021 15:21:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C821B69217; Tue, 26 Oct 2021 15:21:05 +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 3DA741806D04; Tue, 26 Oct 2021 15:21:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19QFL1fs002126 for ; Tue, 26 Oct 2021 11:21:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7D2145F4E0; Tue, 26 Oct 2021 15:21:01 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.43.2.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id 040965D6BA for ; Tue, 26 Oct 2021 15:20:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635261675; 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=tLXtC5UOrRV0SgOJTSRJ5GYuxj/xBMm+XtTE86SZ15k=; b=hm0FI3enqQSdDF6dHd84RzlWf5DHCTyPMOmHGaS4o67Psm8VB3G/qgBuJDIxfrLszkD/U4 rmb7L4JZs7dWpf55OMVWFonwIxI+TmfBgbPqG2Zl2wM/vop7w+60ZAQgbEw9aGB9hN2uIZ 4NNWGtJQyHNk/nN9XGhEQlElAvfY5Oo= X-MC-Unique: tSU4nYYJMgaBIJtwf7fw2g-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2] qemu_block: Refactor qemuBlockExportAddNBD() Date: Tue, 26 Oct 2021 17:19:37 +0200 Message-Id: <92cb238f200c4ee37b78a486d10d20d69520606a.1635261472.git.khanicov@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.11 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) X-ZM-MESSAGEID: 1635261678020100001 Content-Type: text/plain; charset="utf-8" This is v2 of: https://listman.redhat.com/archives/libvir-list/2021-October= /msg01035.html Diff to v1: * negation of 'if' with switched body (proposed by Peter) Signed-off-by: Kristina Hanicova --- src/qemu/qemu_block.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 34fdec2c4b..b8e70f6a83 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3592,28 +3592,21 @@ qemuBlockExportAddNBD(virDomainObj *vm, const char *bitmap) { qemuDomainObjPrivate *priv =3D vm->privateData; + g_autoptr(virJSONValue) nbdprops =3D NULL; + const char *bitmaps[2] =3D { bitmap, NULL }; =20 - if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) { - if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCK_EXPORT_ADD)) { - g_autoptr(virJSONValue) nbdprops =3D NULL; - const char *bitmaps[2] =3D { bitmap, NULL }; + /* older qemu versions didn't support configuring the exportname and + * took the 'drivealias' as the export name */ + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) + return qemuMonitorNBDServerAdd(priv->mon, drivealias, NULL, writab= le, NULL); =20 - if (!(nbdprops =3D qemuBlockExportGetNBDProps(src->nodeformat, - exportname, - writable, - bitmaps))) - return -1; + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCK_EXPORT_ADD)) + return qemuMonitorNBDServerAdd(priv->mon, src->nodeformat, + exportname, writable, bitmap); =20 - return qemuMonitorBlockExportAdd(priv->mon, &nbdprops); - } else { - return qemuMonitorNBDServerAdd(priv->mon, src->nodeformat, - exportname, writable, bitmap); - } - } else { - /* older qemu versions didn't support configuring the exportname a= nd - * took the 'drivealias' as the export name */ - return qemuMonitorNBDServerAdd(priv->mon, drivealias, NULL, writab= le, NULL); - } + if (!(nbdprops =3D qemuBlockExportGetNBDProps(src->nodeformat, exportn= ame, + writable, bitmaps))) + return -1; =20 - return 0; + return qemuMonitorBlockExportAdd(priv->mon, &nbdprops); } --=20 2.31.1