Re: [libvirt] [PATCH 10/18] domain_conf: cleanup virDomainGraphicsGetListen

2016-04-08 Thread Ján Tomko
On Mon, Apr 04, 2016 at 03:20:27PM +0200, Pavel Hrdina wrote:
> Removes the check for graphics type, it's not a public API and developer
> know what he's doing and this check makes no sense.  It also removes
> the ability to allocate a new array if there is none.  This was used by
> the virDomainGraphicsListenAdd* functions and isn't used anymore.
> 
> This is now a simple getter with simple check for listens array presence
> and whether the index in out of bounds.
> 
> Signed-off-by: Pavel Hrdina 
> ---
>  src/conf/domain_conf.c   | 29 -
>  src/conf/domain_conf.h   |  2 ++
>  src/libvirt_private.syms |  1 +
>  3 files changed, 11 insertions(+), 21 deletions(-)
> 

ACK

Jan

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 10/18] domain_conf: cleanup virDomainGraphicsGetListen

2016-04-04 Thread Pavel Hrdina
Removes the check for graphics type, it's not a public API and developer
know what he's doing and this check makes no sense.  It also removes
the ability to allocate a new array if there is none.  This was used by
the virDomainGraphicsListenAdd* functions and isn't used anymore.

This is now a simple getter with simple check for listens array presence
and whether the index in out of bounds.

Signed-off-by: Pavel Hrdina 
---
 src/conf/domain_conf.c   | 29 -
 src/conf/domain_conf.h   |  2 ++
 src/libvirt_private.syms |  1 +
 3 files changed, 11 insertions(+), 21 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index abe5d5a..1f6e9f4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -23741,26 +23741,13 @@ 
virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface)
  * type, or NULL if this is an unsuitable type, or the index is out of
  * bounds. If force0 is TRUE, i == 0, and there is no listen array,
  * allocate one with a single item. */
-static virDomainGraphicsListenDefPtr
-virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i, bool force0)
+virDomainGraphicsListenDefPtr
+virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i)
 {
-if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ||
-def->type == VIR_DOMAIN_GRAPHICS_TYPE_RDP ||
-def->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
-
-if (!def->listens && (i == 0) && force0) {
-if (VIR_ALLOC(def->listens) >= 0)
-def->nListens = 1;
-}
-
-if (!def->listens || (def->nListens <= i))
-return NULL;
-
-return >listens[i];
-}
+if (!def->listens || (def->nListens <= i))
+return NULL;
 
-/* it's a type that has no listens array */
-return NULL;
+return >listens[i];
 }
 
 
@@ -23781,7 +23768,7 @@ int
 virDomainGraphicsListenGetType(virDomainGraphicsDefPtr def, size_t i)
 {
 virDomainGraphicsListenDefPtr listenInfo
-= virDomainGraphicsGetListen(def, i, false);
+= virDomainGraphicsGetListen(def, i);
 
 if (!listenInfo)
 return VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE;
@@ -23793,7 +23780,7 @@ const char *
 virDomainGraphicsListenGetAddress(virDomainGraphicsDefPtr def, size_t i)
 {
 virDomainGraphicsListenDefPtr listenInfo
-= virDomainGraphicsGetListen(def, i, false);
+= virDomainGraphicsGetListen(def, i);
 
 /* even a network can have a listen address */
 if (!listenInfo ||
@@ -23832,7 +23819,7 @@ const char *
 virDomainGraphicsListenGetNetwork(virDomainGraphicsDefPtr def, size_t i)
 {
 virDomainGraphicsListenDefPtr listenInfo
-= virDomainGraphicsGetListen(def, i, false);
+= virDomainGraphicsGetListen(def, i);
 
 if (!listenInfo ||
 (listenInfo->type != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK))
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 96e2def..672d8dc 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2811,6 +2811,8 @@ virDomainHostdevRemove(virDomainDefPtr def, size_t i);
 int virDomainHostdevFind(virDomainDefPtr def, virDomainHostdevDefPtr match,
  virDomainHostdevDefPtr *found);
 
+virDomainGraphicsListenDefPtr
+virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i);
 int virDomainGraphicsListenGetType(virDomainGraphicsDefPtr def, size_t i)
 ATTRIBUTE_NONNULL(1);
 const char *virDomainGraphicsListenGetAddress(virDomainGraphicsDefPtr def,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 3c4abd7..b8a8ddc 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -300,6 +300,7 @@ virDomainGetFilesystemForTarget;
 virDomainGraphicsAuthConnectedTypeFromString;
 virDomainGraphicsAuthConnectedTypeToString;
 virDomainGraphicsDefFree;
+virDomainGraphicsGetListen;
 virDomainGraphicsListenAddAddress;
 virDomainGraphicsListenAddNetwork;
 virDomainGraphicsListenGetAddress;
-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list