]> xenbits.xensource.com Git - libvirt.git/commitdiff
domain_conf: cleanup virDomainGraphicsGetListen
authorPavel Hrdina <phrdina@redhat.com>
Sun, 10 Apr 2016 16:57:12 +0000 (18:57 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Wed, 13 Apr 2016 08:43:49 +0000 (10:43 +0200)
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 <phrdina@redhat.com>
src/conf/domain_conf.c
src/conf/domain_conf.h
src/libvirt_private.syms

index dbe77845899d6df90d11160264f41b803e4b82f1..98a5162cbea0f3c9c22763a5cd6794e2fa43e84e 100644 (file)
@@ -23700,26 +23700,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 &def->listens[i];
-    }
+    if (!def->listens || (def->nListens <= i))
+        return NULL;
 
-    /* it's a type that has no listens array */
-    return NULL;
+    return &def->listens[i];
 }
 
 
@@ -23740,7 +23727,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;
@@ -23752,7 +23739,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 ||
@@ -23790,7 +23777,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))
index e4c38c271bcc9e3b22eed4636d789d1265942bbf..bbef0ed894f09ec6636384d7de87b85b85618820 100644 (file)
@@ -2812,6 +2812,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,
index dce43667b4cf15861fc59b833d2793485b543f9b..f81c5d4e2e39ffd4e105d87ef88a867f120005bd 100644 (file)
@@ -300,6 +300,7 @@ virDomainGetFilesystemForTarget;
 virDomainGraphicsAuthConnectedTypeFromString;
 virDomainGraphicsAuthConnectedTypeToString;
 virDomainGraphicsDefFree;
+virDomainGraphicsGetListen;
 virDomainGraphicsListenAppendAddress;
 virDomainGraphicsListenGetAddress;
 virDomainGraphicsListenGetNetwork;