[PATCH 3/4] conf: add listenNetwork attribute to domain graphics element

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Once it's plugged in, listenNetwork will be an optional replacement
for the "listen" attribute. While listen can be a host name or IP
address, listenNetwork names one of the networks managed by libvirt
(with virNetwork*()/visrh net-*).
---
 docs/schemas/domain.rng |   33 +++++++++++++++++------
 src/conf/domain_conf.c  |   67 +++++++++++++++++++++++++++++++++++++++-------
 src/conf/domain_conf.h  |    3 ++
 3 files changed, 83 insertions(+), 20 deletions(-)

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 65572df..deefe4f 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -1235,9 +1235,14 @@
                 </attribute>
               </optional>
               <optional>
-                <attribute name="listen">
-                  <ref name="addrIPorName"/>
-                </attribute>
+                <choice>
+                  <attribute name="listen">
+                    <ref name="addrIPorName"/>
+                  </attribute>
+                  <attribute name="listenNetwork">
+                    <text/>
+                  </attribute>
+                </choice>
               </optional>
             </group>
             <group>
@@ -1287,9 +1292,14 @@
             </attribute>
           </optional>
           <optional>
-            <attribute name="listen">
-              <ref name="addrIPorName"/>
-            </attribute>
+            <choice>
+              <attribute name="listen">
+                <ref name="addrIPorName"/>
+              </attribute>
+              <attribute name="listenNetwork">
+                <text/>
+              </attribute>
+            </choice>
           </optional>
           <optional>
             <attribute name="passwd">
@@ -1439,9 +1449,14 @@
             </attribute>
           </optional>
           <optional>
-            <attribute name="listen">
-              <ref name="addrIPorName"/>
-            </attribute>
+            <choice>
+              <attribute name="listen">
+                <ref name="addrIPorName"/>
+              </attribute>
+              <attribute name="listenNetwork">
+                <text/>
+              </attribute>
+            </choice>
           </optional>
         </group>
         <group>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f7a2689..eb9224d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -617,6 +617,7 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def)
     switch (def->type) {
     case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
         VIR_FREE(def->data.vnc.listenAddr);
+        VIR_FREE(def->data.vnc.listenNetwork);
         VIR_FREE(def->data.vnc.socket);
         VIR_FREE(def->data.vnc.keymap);
         virDomainGraphicsAuthDefClear(&def->data.vnc.auth);
@@ -629,6 +630,7 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def)
 
     case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
         VIR_FREE(def->data.rdp.listenAddr);
+        VIR_FREE(def->data.rdp.listenNetwork);
         break;
 
     case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
@@ -637,6 +639,7 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def)
 
     case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
         VIR_FREE(def->data.spice.listenAddr);
+        VIR_FREE(def->data.spice.listenNetwork);
         VIR_FREE(def->data.spice.keymap);
         virDomainGraphicsAuthDefClear(&def->data.spice.auth);
         break;
@@ -4031,13 +4034,22 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int flags) {
         }
 
         def->data.vnc.listenAddr = virXMLPropString(node, "listen");
-        def->data.vnc.socket = virXMLPropString(node, "socket");
-        def->data.vnc.keymap = virXMLPropString(node, "keymap");
+        if (def->data.vnc.listenAddr && !def->data.vnc.listenAddr[0])
+            VIR_FREE(def->data.vnc.listenAddr);
 
-        if (def->data.vnc.listenAddr &&
-            !def->data.vnc.listenAddr[0])
+        def->data.vnc.listenNetwork = virXMLPropString(node, "listenNetwork");
+        if (def->data.vnc.listenNetwork && !def->data.vnc.listenNetwork[0])
             VIR_FREE(def->data.vnc.listenAddr);
 
+        if (def->data.vnc.listenAddr && def->data.vnc.listenNetwork) {
+            virDomainReportError(VIR_ERR_INTERNAL_ERROR,
+                                 "%s", _("Both listen and listenNetwork given in graphics element"));
+            goto error;
+        }
+
+        def->data.vnc.socket = virXMLPropString(node, "socket");
+        def->data.vnc.keymap = virXMLPropString(node, "keymap");
+
         if (virDomainGraphicsAuthDefParseXML(node, &def->data.vnc.auth) < 0)
             goto error;
     } else if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) {
@@ -4102,10 +4114,19 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int flags) {
         }
 
         def->data.rdp.listenAddr = virXMLPropString(node, "listen");
-
-        if (def->data.rdp.listenAddr &&
-            !def->data.rdp.listenAddr[0])
+        if (def->data.rdp.listenAddr && !def->data.rdp.listenAddr[0])
             VIR_FREE(def->data.rdp.listenAddr);
+
+        def->data.rdp.listenNetwork = virXMLPropString(node, "listenNetwork");
+        if (def->data.rdp.listenNetwork && !def->data.rdp.listenNetwork[0])
+            VIR_FREE(def->data.rdp.listenNetwork);
+
+        if (def->data.rdp.listenAddr && def->data.rdp.listenNetwork) {
+            virDomainReportError(VIR_ERR_INTERNAL_ERROR,
+                                 "%s", _("Both listen and listenNetwork given in graphics element"));
+            goto error;
+        }
+
     } else if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP) {
         char *fullscreen = virXMLPropString(node, "fullscreen");
 
@@ -4168,12 +4189,21 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int flags) {
         }
 
         def->data.spice.listenAddr = virXMLPropString(node, "listen");
-        def->data.spice.keymap = virXMLPropString(node, "keymap");
-
-        if (def->data.spice.listenAddr &&
-            !def->data.spice.listenAddr[0])
+        if (def->data.spice.listenAddr && !def->data.spice.listenAddr[0])
             VIR_FREE(def->data.spice.listenAddr);
 
+        def->data.spice.listenNetwork = virXMLPropString(node, "listenNetwork");
+        if (def->data.spice.listenNetwork && !def->data.spice.listenNetwork[0])
+            VIR_FREE(def->data.spice.listenNetwork);
+
+        if (def->data.spice.listenAddr && def->data.spice.listenNetwork) {
+            virDomainReportError(VIR_ERR_INTERNAL_ERROR,
+                                 "%s", _("Both listen and listenNetwork given in graphics element"));
+            goto error;
+        }
+
+        def->data.spice.keymap = virXMLPropString(node, "keymap");
+
         if (virDomainGraphicsAuthDefParseXML(node, &def->data.spice.auth) < 0)
             goto error;
 
@@ -9323,6 +9353,11 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
             if (def->data.vnc.listenAddr)
                 virBufferAsprintf(buf, " listen='%s'",
                                   def->data.vnc.listenAddr);
+
+            if (def->data.vnc.listenNetwork) {
+                virBufferAsprintf(buf, " listenNetwork='%s'",
+                                  def->data.vnc.listenNetwork);
+            }
         }
 
         if (def->data.vnc.keymap)
@@ -9364,6 +9399,11 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
         if (def->data.rdp.listenAddr)
             virBufferAsprintf(buf, " listen='%s'", def->data.rdp.listenAddr);
 
+        if (def->data.rdp.listenNetwork) {
+            virBufferAsprintf(buf, " listenNetwork='%s'",
+                              def->data.rdp.listenNetwork);
+        }
+
         break;
 
     case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
@@ -9392,6 +9432,11 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
             virBufferAsprintf(buf, " listen='%s'",
                               def->data.spice.listenAddr);
 
+        if (def->data.spice.listenNetwork) {
+            virBufferAsprintf(buf, " listenNetwork='%s'",
+                              def->data.spice.listenNetwork);
+        }
+
         if (def->data.spice.keymap)
             virBufferEscapeString(buf, " keymap='%s'",
                                   def->data.spice.keymap);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 4ce59d8..3745b27 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -759,6 +759,7 @@ struct _virDomainGraphicsDef {
             int port;
             unsigned int autoport :1;
             char *listenAddr;
+            char *listenNetwork;
             char *keymap;
             char *socket;
             virDomainGraphicsAuthDef auth;
@@ -771,6 +772,7 @@ struct _virDomainGraphicsDef {
         struct {
             int port;
             char *listenAddr;
+            char *listenNetwork;
             unsigned int autoport :1;
             unsigned int replaceUser :1;
             unsigned int multiUser :1;
@@ -783,6 +785,7 @@ struct _virDomainGraphicsDef {
             int port;
             int tlsPort;
             char *listenAddr;
+            char *listenNetwork;
             char *keymap;
             virDomainGraphicsAuthDef auth;
             unsigned int autoport :1;
-- 
1.7.3.4

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


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]