[libvirt] [PATCH] conf: fix migratable XML for graphics if socket is generated based on config

Pavel Hrdina posted 1 patch 6 years, 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/13190a1e209cf412e3ed4079a84dde5b755e9ddd.1512058458.git.phrdina@redhat.com
src/conf/domain_conf.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
[libvirt] [PATCH] conf: fix migratable XML for graphics if socket is generated based on config
Posted by Pavel Hrdina 6 years, 4 months ago
The graphics code is complex and there are a lot of exceptions and
backward compatible combinations.  One of them is the possibility
to configure "spice_auto_unix_socket" in qemu.conf which will convert
all spice graphics with listen type "address" without any address
specified to listen type "socket" when the guest is started.

We don't format this generated socket into migratable XML to make
migration work with older libvirt.  However, spice has another
exception that if autoport='no' and there is no port configured
it is converted to listen type "none".  Because of this we need
to format autoport='yes' to make sure that the listen type will
be the same as the offline XML.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1511407

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

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b31917dad9..6b35ebf2e9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -25159,6 +25159,18 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
             break;
 
         case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
+            /* If socket is auto-generated based on config option we don't
+             * add any listen element into migratable XML because the original
+             * listen type is "address".
+             * We need to set autoport to make sure that libvirt on destination
+             * will parse it as listen type "address", without autoport it is
+             * parsed as listen type "none". */
+            if ((flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE) &&
+                glisten->fromConfig) {
+                virBufferAddStr(buf, " autoport='yes'");
+            }
+            break;
+
         case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST:
             break;
         }
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] conf: fix migratable XML for graphics if socket is generated based on config
Posted by Jiri Denemark 6 years, 4 months ago
On Thu, Nov 30, 2017 at 17:14:34 +0100, Pavel Hrdina wrote:
> The graphics code is complex and there are a lot of exceptions and
> backward compatible combinations.  One of them is the possibility
> to configure "spice_auto_unix_socket" in qemu.conf which will convert
> all spice graphics with listen type "address" without any address
> specified to listen type "socket" when the guest is started.
> 
> We don't format this generated socket into migratable XML to make
> migration work with older libvirt.  However, spice has another
> exception that if autoport='no' and there is no port configured
> it is converted to listen type "none".  Because of this we need
> to format autoport='yes' to make sure that the listen type will
> be the same as the offline XML.
> 
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1511407

Looks like some areas of our code are even worse than one would be
afraid of :-)

> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  src/conf/domain_conf.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index b31917dad9..6b35ebf2e9 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -25159,6 +25159,18 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
>              break;
>  
>          case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
> +            /* If socket is auto-generated based on config option we don't
> +             * add any listen element into migratable XML because the original
> +             * listen type is "address".
> +             * We need to set autoport to make sure that libvirt on destination
> +             * will parse it as listen type "address", without autoport it is
> +             * parsed as listen type "none". */
> +            if ((flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE) &&
> +                glisten->fromConfig) {
> +                virBufferAddStr(buf, " autoport='yes'");
> +            }
> +            break;
> +
>          case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST:
>              break;
>          }

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>

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