[libvirt] [libvirt PATCH v2 1/4] domain_conf: split out virBlkioDevice and virDomainBlkiotune definitions

Michal Privoznik mprivozn at redhat.com
Wed Sep 12 13:20:10 UTC 2018


On 09/12/2018 10:57 AM, Fabiano Fidêncio wrote:
> Let's move those to their own newly created files
> (src/util/virblkio.{c,h}) as this will help us to easily start sharing
> the cgroup code that's duplicated between QEMU and LXC.
> 
> Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
> ---
>  src/Makefile.am          |  1 +
>  src/conf/domain_conf.c   | 11 +--------
>  src/conf/domain_conf.h   | 27 ++-------------------
>  src/util/Makefile.inc.am |  2 ++
>  src/util/virblkio.c      | 37 ++++++++++++++++++++++++++++
>  src/util/virblkio.h      | 52 ++++++++++++++++++++++++++++++++++++++++
>  6 files changed, 95 insertions(+), 35 deletions(-)
>  create mode 100644 src/util/virblkio.c
>  create mode 100644 src/util/virblkio.h
> 
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 2a3ed0d42d..926085ff2d 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -671,6 +671,7 @@ libvirt_setuid_rpc_client_la_SOURCES = \
>  		util/viratomic.c \
>  		util/viratomic.h \
>  		util/virbitmap.c \
> +		util/virblkio.c \
>  		util/virbuffer.c \
>  		util/vircgroup.c \
>  		util/vircommand.c \

This is not needed. setuid_rpc_client is trying to be very minimalistic
library which is then statically linked to virt-login-shell. The aim is
to have something small, thus auditable and yet capable of talking to
libvirtd through RPC.

> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 7e14cea128..6ce50f712a 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -59,6 +59,7 @@
>  #include "virnetdevmacvlan.h"
>  #include "virhostdev.h"
>  #include "virmdev.h"
> +#include "virblkio.h"
>  
>  #define VIR_FROM_THIS VIR_FROM_DOMAIN
>  
> @@ -1205,16 +1206,6 @@ virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt)
>  }
>  
>  
> -void
> -virBlkioDeviceArrayClear(virBlkioDevicePtr devices,
> -                         int ndevices)
> -{
> -    size_t i;
> -
> -    for (i = 0; i < ndevices; i++)
> -        VIR_FREE(devices[i].path);
> -}
> -
>  /**
>   * virDomainBlkioDeviceParseXML
>   *
> diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
> index e30a4b2fe7..e9e6b6d6c4 100644
> --- a/src/conf/domain_conf.h
> +++ b/src/conf/domain_conf.h
> @@ -57,6 +57,7 @@
>  # include "virtypedparam.h"
>  # include "virsavecookie.h"
>  # include "virresctrl.h"
> +# include "virblkio.h"
>  
>  /* forward declarations of all device types, required by
>   * virDomainDeviceDef
> @@ -2084,17 +2085,6 @@ struct _virDomainClockDef {
>  };
>  
>  
> -typedef struct _virBlkioDevice virBlkioDevice;
> -typedef virBlkioDevice *virBlkioDevicePtr;
> -struct _virBlkioDevice {
> -    char *path;
> -    unsigned int weight;
> -    unsigned int riops;
> -    unsigned int wiops;
> -    unsigned long long rbps;
> -    unsigned long long wbps;
> -};
> -
>  typedef enum {
>      VIR_DOMAIN_RNG_MODEL_VIRTIO,
>  
> @@ -2184,9 +2174,6 @@ struct _virDomainPanicDef {
>  };
>  
>  
> -void virBlkioDeviceArrayClear(virBlkioDevicePtr deviceWeights,
> -                              int ndevices);
> -
>  typedef struct _virDomainResourceDef virDomainResourceDef;
>  typedef virDomainResourceDef *virDomainResourceDefPtr;
>  struct _virDomainResourceDef {
> @@ -2260,16 +2247,6 @@ struct _virDomainVcpuDef {
>      virObjectPtr privateData;
>  };
>  
> -typedef struct _virDomainBlkiotune virDomainBlkiotune;
> -typedef virDomainBlkiotune *virDomainBlkiotunePtr;
> -
> -struct _virDomainBlkiotune {
> -    unsigned int weight;
> -
> -    size_t ndevices;
> -    virBlkioDevicePtr devices;
> -};
> -
>  typedef struct _virDomainMemtune virDomainMemtune;
>  typedef virDomainMemtune *virDomainMemtunePtr;
>  
> @@ -2402,7 +2379,7 @@ struct _virDomainDef {
>      char *title;
>      char *description;
>  
> -    virDomainBlkiotune blkio;
> +    virBlkioTune blkio;
>      virDomainMemtune mem;
>  
>      virDomainVcpuDefPtr *vcpus;
> diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am
> index a22265606c..13f415b23c 100644
> --- a/src/util/Makefile.inc.am
> +++ b/src/util/Makefile.inc.am
> @@ -17,6 +17,8 @@ UTIL_SOURCES = \
>  	util/virauthconfig.h \
>  	util/virbitmap.c \
>  	util/virbitmap.h \
> +	util/virblkio.c \
> +	util/virblkio.h \
>  	util/virbuffer.c \
>  	util/virbuffer.h \
>  	util/virperf.c \
> diff --git a/src/util/virblkio.c b/src/util/virblkio.c
> new file mode 100644
> index 0000000000..9711077ee8
> --- /dev/null
> +++ b/src/util/virblkio.c
> @@ -0,0 +1,37 @@
> +/*
> + * virblkio.c: Block IO helpers
> + *
> + * Copyright (C) 2018 Red Hat, Inc.
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library.  If not, see
> + * <http://www.gnu.org/licenses/>.
> + *
> + * Authors:
> + *  Fabiano Fidêncio <fidencio at redhat.com>
> + */
> +
> +#include <config.h>
> +
> +#include "viralloc.h"
> +#include "virblkio.h"
> +
> +void
> +virBlkioDeviceArrayClear(virBlkioDevicePtr devices,
> +                         int ndevices)
> +{
> +    size_t i;
> +
> +    for (i = 0; i < ndevices; i++)
> +        VIR_FREE(devices[i].path);
> +}
> diff --git a/src/util/virblkio.h b/src/util/virblkio.h
> new file mode 100644
> index 0000000000..dcaeaaf1f0
> --- /dev/null
> +++ b/src/util/virblkio.h
> @@ -0,0 +1,52 @@
> +/*
> + * virblkio.h: Block IO definitions and helpers
> + *
> + * Copyright (C) 2018 Red Hat, Inc.
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library.  If not, see
> + * <http://www.gnu.org/licenses/>.
> + *
> + * Author: Fabiano Fidêncio <fidencio at redhat.com>
> + */
> +
> +#ifndef __VIR_BLKIO_H__
> +# define __VIR_BLKIO_H__
> +
> +#include "virutil.h"

Oops. You need to install cppi ;-)
The same problem is in 2/4.

> +
> +typedef struct _virBlkioDevice virBlkioDevice;
> +typedef virBlkioDevice *virBlkioDevicePtr;
> +struct _virBlkioDevice {
> +    char *path;
> +    unsigned int weight;
> +    unsigned int riops;
> +    unsigned int wiops;
> +    unsigned long long rbps;
> +    unsigned long long wbps;
> +};
> +
> +
> +typedef struct _virBlkioTune virBlkioTune;
> +typedef virBlkioTune *virBlkioTunePtr;
> +struct _virBlkioTune {
> +    unsigned int weight;
> +
> +    size_t ndevices;
> +    virBlkioDevicePtr devices;
> +};
> +
> +void virBlkioDeviceArrayClear(virBlkioDevicePtr deviceWeights,
> +                              int ndevices);
> +
> +#endif /* __VIR_BLKIO_H__ */
> 

You need to invent a new section to src/libvirt_private.syms so that
this symbol is correctly exported.

The rest of the patches looks okay.

Michal




More information about the libvir-list mailing list