From nobody Thu May 2 09:05:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1601555555; cv=none; d=zohomail.com; s=zohoarc; b=cxa+M+eThVjv53R9y+pzRduecyo9fNZlr7RBKQlCcr1xehOF6tY91bwwT6G9+uAV8jngIk93ZU1h2xrGoZXb/rDYdMLcjd+kTq5QhFFcOyydUzIiDpJbO/gNu4ytR0qzuZxWJJ6d7HnF3G7eoRbVOeIL7ejNbkGww/KOVqxmHks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601555555; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=ccbzqSwG4JMwGM7/jDRsE4fqPXnF9PgQPTT1Ljz8UdM=; b=QcYDN/DljMVYfSd9IaidO1eR0mIEJtKgo69y0R69VKSMBQeGXzADRR2Zgxf9puGrne5iPzdop6smYvM0QmzQd1Vu/5c8bDNyxc5zR0v54+kO+5p8m3lmf6UgRt6UarTQRciFLa0j+rcAkBmDdoKkVVIbdrEkHlIycpl4FLzjJHY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 160155555587341.096516929344034; Thu, 1 Oct 2020 05:32:35 -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-262-DAEFATEkOfuphqR1bNlJ8g-1; Thu, 01 Oct 2020 08:32:32 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CFD03100738B; Thu, 1 Oct 2020 12:32:26 +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 7F19A73687; Thu, 1 Oct 2020 12:32:26 +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 4B336181A06B; Thu, 1 Oct 2020 12:32:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 091CCNNh011038 for ; Thu, 1 Oct 2020 08:12:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id BB5F72026F94; Thu, 1 Oct 2020 12:12:23 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B6513201E75E for ; Thu, 1 Oct 2020 12:12:21 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4B340858290 for ; Thu, 1 Oct 2020 12:12:21 +0000 (UTC) Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-149-CYBK_AAdMRKtZU-ycSo3Gw-1; Thu, 01 Oct 2020 08:12:18 -0400 Received: by mail-wm1-f51.google.com with SMTP id y15so2813070wmi.0 for ; Thu, 01 Oct 2020 05:12:18 -0700 (PDT) Received: from localhost.localdomain (tho74-h02-176-149-196-190.dsl.sta.abo.bbox.fr. [176.149.196.190]) by smtp.gmail.com with ESMTPSA id n4sm8785636wrp.61.2020.10.01.05.12.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 05:12:16 -0700 (PDT) X-MC-Unique: DAEFATEkOfuphqR1bNlJ8g-1 X-MC-Unique: CYBK_AAdMRKtZU-ycSo3Gw-1 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:mime-version :content-transfer-encoding; bh=ccbzqSwG4JMwGM7/jDRsE4fqPXnF9PgQPTT1Ljz8UdM=; b=PmJ8anA0JrtUj+jsyOl6RuKQ1O+AgYxecp2yZbSxlNDokn2yf/P0Vs+iOKHqeR6BGY 0HdTIMdKMl8xUW5NAiEdGSEZThzQ+ixViwukFMF1y/XRQjoitOchjvJwOQ7mMuscTzg6 2abwiQDKKNm0aSNHVDSuiSghdxOH2yxYNNlO/NPDQjoPxzkCjfzOhmT4WOaoxQKfoPzC hv72cb+bdwJIMF0DVFoieN6gge4ZI0KrNurRoeXNVadnWN8Zzus0IcF36sjmOAPOK0ZD 7EwKKazsaeSz8fcbP3mkHr50GD/pooJInC+pcWfrwSQH2c81xVOfqHUIXVKljdbmCMF7 grmQ== X-Gm-Message-State: AOAM530k+Si+iEj797yram3FQU8eOltemXSKzXl+ms6pN83t6grAdqZv uBrY/NA+agV9g2JxvGRNNrCL7QDSb20= X-Google-Smtp-Source: ABdhPJykjQC+L+6tbw6adOcixIj9pEUZi3gqZdvUxkcTH9z0OSuvoMmruYcO0Cr8S9TtfeOAHrU7RA== X-Received: by 2002:a05:600c:2f8f:: with SMTP id t15mr8486946wmn.41.1601554336668; Thu, 01 Oct 2020 05:12:16 -0700 (PDT) From: rodolpheche To: libvir-list@redhat.com Subject: [rust PATCH] add list_volumes function Date: Thu, 1 Oct 2020 14:11:41 +0200 Message-Id: <20201001121141.61693-1-rodolphe.chaigneau@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Thu, 01 Oct 2020 08:28:52 -0400 Cc: rodolpheche , sferdjaoui@juniper.net 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.13 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 Content-Type: text/plain; charset="utf-8" --- src/storage_pool.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/storage_pool.rs b/src/storage_pool.rs index 96258f0..ad0a51a 100644 --- a/src/storage_pool.rs +++ b/src/storage_pool.rs @@ -18,7 +18,7 @@ =20 extern crate libc; =20 -use std::str; +use std::{ptr, str}; =20 use connect::sys::virConnectPtr; use storage_vol::sys::virStorageVolPtr; @@ -101,6 +101,11 @@ extern "C" { info: sys::virStoragePoolInfoPtr, ) -> libc::c_int; fn virStoragePoolNumOfVolumes(ptr: sys::virStoragePoolPtr) -> libc::c_= int; + fn virStoragePoolListVolumes( + ptr: sys::virStoragePoolPtr, + names: *mut *mut libc::c_char, + maxnames: libc::c_int, + ) -> libc::c_int; } =20 pub type StoragePoolXMLFlags =3D self::libc::c_uint; @@ -276,6 +281,22 @@ impl StoragePool { } } =20 + pub fn list_volumes(&self) -> Result, Error> { + unsafe { + let mut names: [*mut libc::c_char; 1024] =3D [ptr::null_mut();= 1024]; + let size =3D virStoragePoolListVolumes(self.as_ptr(), names.as= _mut_ptr(), 1024); + if size =3D=3D -1 { + return Err(Error::new()); + } + + let mut array: Vec =3D Vec::new(); + for x in 0..size as usize { + array.push(c_chars_to_string!(names[x])); + } + return Ok(array); + } + } + pub fn get_uuid_string(&self) -> Result { unsafe { let mut uuid: [libc::c_char; 37] =3D [0; 37]; --=20 2.28.0