[libvirt] [PATCH] conf: format only relevant attributes for graphics based on listen type

Pavel Hrdina posted 1 patch 6 years, 12 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/ebbf229f17c1c60b3c86583dde186dae554ecaab.1493203845.git.phrdina@redhat.com
src/conf/domain_conf.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
[libvirt] [PATCH] conf: format only relevant attributes for graphics based on listen type
Posted by Pavel Hrdina 6 years, 12 months ago
This patch changes following output:

    ...
    <graphics type='vnc' port='-1' autoport='yes'>
      <listen type='none'/>
    </graphics>
    ...

into this output:

    ...
    <graphics type='vnc'>
      <listen type='none'/>
    </graphics>
    ...

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 src/conf/domain_conf.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fe9b7c7273..88bcd6c052 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -23297,7 +23297,8 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
             return -1;
         }
 
-        if (glisten->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET) {
+        switch (glisten->type) {
+        case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
             /* To not break migration we shouldn't print the 'socket' attribute
              * if it's auto-generated or if it's based on config option from
              * qemu.conf.  If the socket is provided by user we need to print it
@@ -23307,7 +23308,10 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
                   (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE))) {
                 virBufferEscapeString(buf, " socket='%s'", glisten->socket);
             }
-        } else {
+            break;
+
+        case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS:
+        case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK:
             if (def->data.vnc.port &&
                 (!def->data.vnc.autoport || !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)))
                 virBufferAsprintf(buf, " port='%d'",
@@ -23325,6 +23329,10 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
                 virBufferAsprintf(buf, " websocket='%d'", def->data.vnc.websocket);
 
             virDomainGraphicsListenDefFormatAddr(buf, glisten, flags);
+            break;
+        case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE:
+        case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST:
+            break;
         }
 
         if (def->data.vnc.keymap)
-- 
2.12.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] conf: format only relevant attributes for graphics based on listen type
Posted by John Ferlan 6 years, 12 months ago

On 04/26/2017 06:50 AM, Pavel Hrdina wrote:
> This patch changes following output:
> 
>     ...
>     <graphics type='vnc' port='-1' autoport='yes'>
>       <listen type='none'/>
>     </graphics>
>     ...
> 
> into this output:
> 
>     ...
>     <graphics type='vnc'>
>       <listen type='none'/>
>     </graphics>
>     ...
> 
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  src/conf/domain_conf.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 

ACK

John



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