[libvirt] [PATCH 10/10] storage: remove virConnectPtr from all backend functions

Peter Krempa pkrempa at redhat.com
Mon Jan 29 10:53:03 UTC 2018


On Fri, Jan 26, 2018 at 13:35:37 +0000, Daniel Berrange wrote:
> Now that we can open connections to the secondary drivers on demand,
> there is no need to pass a virConnectPtr into all the backend
> functions.
> 
> Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
> ---
>  src/storage/storage_backend.h          | 45 ++++++-----------
>  src/storage/storage_backend_disk.c     | 30 +++++-------
>  src/storage/storage_backend_fs.c       | 15 ++----
>  src/storage/storage_backend_gluster.c  |  9 ++--
>  src/storage/storage_backend_iscsi.c    | 12 ++---
>  src/storage/storage_backend_logical.c  | 36 +++++---------
>  src/storage/storage_backend_mpath.c    |  5 +-
>  src/storage/storage_backend_rbd.c      | 24 +++------
>  src/storage/storage_backend_scsi.c     | 46 ++++++++++--------
>  src/storage/storage_backend_sheepdog.c | 33 +++++--------
>  src/storage/storage_backend_vstorage.c | 10 ++--
>  src/storage/storage_backend_zfs.c      | 15 ++----
>  src/storage/storage_driver.c           | 89 +++++++++++++++-------------------
>  src/storage/storage_util.c             | 59 ++++++++--------------
>  src/storage/storage_util.h             | 33 +++++--------
>  tests/storagevolxml2argvtest.c         |  7 +--
>  16 files changed, 179 insertions(+), 289 deletions(-)
> 

[...]

> diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
> index 9347d66384..115df6c847 100644
> --- a/src/storage/storage_backend_scsi.c
> +++ b/src/storage/storage_backend_scsi.c
> @@ -245,20 +245,20 @@ checkName(const char *name)
>   * sysfs tree to get the parent 'scsi_host#' to ensure it matches.
>   */
>  static bool
> -checkParent(virConnectPtr conn,
> -            const char *name,
> +checkParent(const char *name,
>              const char *parent_name)
>  {
>      unsigned int host_num;
>      char *scsi_host_name = NULL;
>      char *vhba_parent = NULL;
>      bool retval = false;
> +    virConnectPtr conn = NULL;
>  
> -    VIR_DEBUG("conn=%p, name=%s, parent_name=%s", conn, name, parent_name);
> +    VIR_DEBUG("name=%s, parent_name=%s", name, parent_name);
>  
> -    /* autostarted pool - assume we're OK */
> +    conn = virConnectOpen(geteuid() == 0 ? "nodedev:///system" : "nodedev:///session");

Apparently we also need a helper for 'nodedev'.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180129/67380bf8/attachment-0001.sig>


More information about the libvir-list mailing list