Re: [libvirt] [RFC PATCH 1/4] driver.h: Add macro VIR_DRV_CONN_CHECK_SERVER
On Mon, Jul 09, 2018 at 08:31:05AM +0200, Peter Krempa wrote: > On Sat, Jul 07, 2018 at 22:06:53 -0300, Marcos Paulo de Souza wrote: > > This new macro will check if the server was passed to connectOpen > > function. Some drivers as esx, hyperv and phyp need a server address to > > connect to. > > > > Signed-off-by: Marcos Paulo de Souza > > --- > > src/driver.h | 9 + > > 1 file changed, 9 insertions(+) > > > > diff --git a/src/driver.h b/src/driver.h > > index 0b1f7a2269..1f9d7fd26b 100644 > > --- a/src/driver.h > > +++ b/src/driver.h > > @@ -60,6 +60,15 @@ typedef enum { > > ((drv)->connectSupportsFeature ? \ > > (drv)->connectSupportsFeature((conn), (feature)) > 0 : 0) > > > > +/* Check if the connection of the driver has filled the server address */ > > +# define VIR_DRV_CONN_CHECK_SERVER \ > > 'conn' should be passed in as an argument. Without that it is less > obvious what is happening here. > > P.S: Yes I'm aware that we have e.g. virCheckFlags that checks the > 'flags' variable in any context, but we don't have to introduce more of > it. > How about to follow Matthias idea, and add a new member to virConnectDriver? (https://www.redhat.com/archives/libvir-list/2018-July/msg00400.html) I am already preparing a new patchset following his idea. -- Thanks, Marcos -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC PATCH 1/4] driver.h: Add macro VIR_DRV_CONN_CHECK_SERVER
On Sat, Jul 07, 2018 at 22:06:53 -0300, Marcos Paulo de Souza wrote: > This new macro will check if the server was passed to connectOpen > function. Some drivers as esx, hyperv and phyp need a server address to > connect to. > > Signed-off-by: Marcos Paulo de Souza > --- > src/driver.h | 9 + > 1 file changed, 9 insertions(+) > > diff --git a/src/driver.h b/src/driver.h > index 0b1f7a2269..1f9d7fd26b 100644 > --- a/src/driver.h > +++ b/src/driver.h > @@ -60,6 +60,15 @@ typedef enum { > ((drv)->connectSupportsFeature ? \ > (drv)->connectSupportsFeature((conn), (feature)) > 0 : 0) > > +/* Check if the connection of the driver has filled the server address */ > +# define VIR_DRV_CONN_CHECK_SERVER \ 'conn' should be passed in as an argument. Without that it is less obvious what is happening here. P.S: Yes I'm aware that we have e.g. virCheckFlags that checks the 'flags' variable in any context, but we don't have to introduce more of it. signature.asc Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [RFC PATCH 1/4] driver.h: Add macro VIR_DRV_CONN_CHECK_SERVER
This new macro will check if the server was passed to connectOpen function. Some drivers as esx, hyperv and phyp need a server address to connect to. Signed-off-by: Marcos Paulo de Souza --- src/driver.h | 9 + 1 file changed, 9 insertions(+) diff --git a/src/driver.h b/src/driver.h index 0b1f7a2269..1f9d7fd26b 100644 --- a/src/driver.h +++ b/src/driver.h @@ -60,6 +60,15 @@ typedef enum { ((drv)->connectSupportsFeature ? \ (drv)->connectSupportsFeature((conn), (feature)) > 0 : 0) +/* Check if the connection of the driver has filled the server address */ +# define VIR_DRV_CONN_CHECK_SERVER \ +do { \ +if (!conn->uri->server) { \ +virReportError(VIR_ERR_INVALID_ARG, "%s", \ + _("URI is missing the server part")); \ +return VIR_DRV_OPEN_ERROR; \ +} \ +} while (0) # define __VIR_DRIVER_H_INCLUDES___ -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list