render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
c1c534
From a1c433306e79ec6b5c0ca4b3e3243875ccabdeb2 Mon Sep 17 00:00:00 2001
c1c534
Message-Id: <a1c433306e79ec6b5c0ca4b3e3243875ccabdeb2@dist-git>
c1c534
From: Pavel Hrdina <phrdina@redhat.com>
c1c534
Date: Thu, 30 Nov 2017 17:56:41 +0100
c1c534
Subject: [PATCH] conf: fix migratable XML for graphics if socket is generated
c1c534
 based on config
c1c534
c1c534
The graphics code is complex and there are a lot of exceptions and
c1c534
backward compatible combinations.  One of them is the possibility
c1c534
to configure "spice_auto_unix_socket" in qemu.conf which will convert
c1c534
all spice graphics with listen type "address" without any address
c1c534
specified to listen type "socket" when the guest is started.
c1c534
c1c534
We don't format this generated socket into migratable XML to make
c1c534
migration work with older libvirt.  However, spice has another
c1c534
exception that if autoport='no' and there is no port configured
c1c534
it is converted to listen type "none".  Because of this we need
c1c534
to format autoport='yes' to make sure that the listen type will
c1c534
be the same as the offline XML.
c1c534
c1c534
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1511407
c1c534
c1c534
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
c1c534
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c1c534
(cherry picked from commit cb06ea57ad80a964028f22fb49d6ab96648ae741)
c1c534
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c1c534
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c1c534
---
c1c534
 src/conf/domain_conf.c | 12 ++++++++++++
c1c534
 1 file changed, 12 insertions(+)
c1c534
c1c534
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
c1c534
index c58dae197c..ec138ea861 100644
c1c534
--- a/src/conf/domain_conf.c
c1c534
+++ b/src/conf/domain_conf.c
c1c534
@@ -25150,6 +25150,18 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
c1c534
             break;
c1c534
 
c1c534
         case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
c1c534
+            /* If socket is auto-generated based on config option we don't
c1c534
+             * add any listen element into migratable XML because the original
c1c534
+             * listen type is "address".
c1c534
+             * We need to set autoport to make sure that libvirt on destination
c1c534
+             * will parse it as listen type "address", without autoport it is
c1c534
+             * parsed as listen type "none". */
c1c534
+            if ((flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE) &&
c1c534
+                glisten->fromConfig) {
c1c534
+                virBufferAddStr(buf, " autoport='yes'");
c1c534
+            }
c1c534
+            break;
c1c534
+
c1c534
         case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST:
c1c534
             break;
c1c534
         }
c1c534
-- 
c1c534
2.15.1
c1c534