From nobody Sat Feb 7 18:51:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15529116312281022.3457020232116; Mon, 18 Mar 2019 05:20:31 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EE2EF308428C; Mon, 18 Mar 2019 12:20:28 +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 744645D75C; Mon, 18 Mar 2019 12:20:28 +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 8F34E3D388; Mon, 18 Mar 2019 12:20:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2ICKOXU014291 for ; Mon, 18 Mar 2019 08:20:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 85579600C5; Mon, 18 Mar 2019 12:20:24 +0000 (UTC) Received: from dhcp-16-102.lcy.redhat.com (unknown [10.42.16.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id F32CE600C2; Mon, 18 Mar 2019 12:20:23 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 18 Mar 2019 12:20:18 +0000 Message-Id: <20190318122018.9715-3-berrange@redhat.com> In-Reply-To: <20190318122018.9715-1-berrange@redhat.com> References: <20190318122018.9715-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] storage: add support for new rbd_list2 method 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 18 Mar 2019 12:20:29 +0000 (UTC) The rbd_list method has been deprecated in Ceph >=3D 14.0.0 in favour of the new rbd_list2 method which populates an array of structs. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: J=C3=A1n Tomko --- m4/virt-storage-rbd.m4 | 1 + src/storage/storage_backend_rbd.c | 32 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/m4/virt-storage-rbd.m4 b/m4/virt-storage-rbd.m4 index 17e2115309..f3d9d04908 100644 --- a/m4/virt-storage-rbd.m4 +++ b/m4/virt-storage-rbd.m4 @@ -33,6 +33,7 @@ AC_DEFUN([LIBVIRT_STORAGE_CHECK_RBD], [ old_LIBS=3D"$LIBS" LIBS=3D"$LIBS $LIBRBD_LIBS" AC_CHECK_FUNCS([rbd_get_features],[],[LIBRBD_FOUND=3Dno]) + AC_CHECK_FUNCS([rbd_list2]) LIBS=3D"$old_LIBS" fi =20 diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index 24ddbc8f69..b6f2785390 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -572,6 +572,33 @@ virStorageBackendRBDGetVolNames(virStorageBackendRBDSt= atePtr ptr) char **names =3D NULL; size_t nnames =3D 0; int ret; +#ifdef HAVE_RBD_LIST2 + rbd_image_spec_t *images =3D NULL; + size_t nimages =3D 16; + size_t i; + + while (true) { + if (VIR_ALLOC_N(images, nimages) < 0) + goto error; + + ret =3D rbd_list2(ptr->ioctx, images, &nimages); + if (ret >=3D 0) + break; + if (ret !=3D -ERANGE) { + virReportSystemError(-ret, "%s", _("Unable to list RBD images"= )); + goto error; + } + } + + if (VIR_ALLOC_N(names, nimages + 1) < 0) + goto error; + nnames =3D nimages; + + for (i =3D 0; i < nimages; i++) { + names[i] =3D images->name; + images->name =3D NULL; + } +#else /* ! HAVE_RBD_LIST2 */ size_t max_size =3D 1024; VIR_AUTOFREE(char *) namebuf =3D NULL; const char *name; @@ -607,11 +634,16 @@ virStorageBackendRBDGetVolNames(virStorageBackendRBDS= tatePtr ptr) =20 if (VIR_EXPAND_N(names, nnames, 1) < 0) goto error; +#endif /* ! HAVE_RBD_LIST2 */ =20 return names; =20 error: virStringListFreeCount(names, nnames); +#ifdef HAVE_RBD_LIST2 + rbd_image_spec_list_cleanup(images, nimages); + VIR_FREE(images); +#endif /* ! HAVE_RBD_LIST2 */ return NULL; } =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list