[PATCH] remote: Fix cached hypervisor type

Jim Fehlig posted 1 patch 4 months, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20231208015619.5831-1-jfehlig@suse.com
src/remote/remote_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] remote: Fix cached hypervisor type
Posted by Jim Fehlig 4 months, 3 weeks ago
Commit 501825011c switched the remote driver to using g_auto, but missed
one case of needing to steal a pointer holding the hypervisor type.
Without it, memory is freed and the output of 'virsh version' has random
output

Compiled against library: libvirt 10.0.0
Using library: libvirt 10.0.0
Using API: ��%�U 10.0.0
Running hypervisor: ��U 8.1.3

Ths change also fixes random SIGABRT from perl processes running
libvirt-tck tests.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
---
 src/remote/remote_driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index c4831db6cd..132d0194c6 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -1408,7 +1408,7 @@ remoteConnectGetType(virConnectPtr conn)
         return NULL;
 
     /* Stash. */
-    return priv->type = ret.type;
+    return priv->type = g_steal_pointer(&ret.type);
 }
 
 static int remoteConnectIsSecure(virConnectPtr conn)
-- 
2.43.0
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [PATCH] remote: Fix cached hypervisor type
Posted by Daniel P. Berrangé 4 months, 3 weeks ago
On Thu, Dec 07, 2023 at 06:56:09PM -0700, Jim Fehlig wrote:
> Commit 501825011c switched the remote driver to using g_auto, but missed
> one case of needing to steal a pointer holding the hypervisor type.
> Without it, memory is freed and the output of 'virsh version' has random
> output

Opps, yeah, this method has the awful design mistake where we need
to return a static pointer too which makes it confusing.

> 
> Compiled against library: libvirt 10.0.0
> Using library: libvirt 10.0.0
> Using API: ��%�U 10.0.0
> Running hypervisor: ��U 8.1.3
> 
> Ths change also fixes random SIGABRT from perl processes running
> libvirt-tck tests.
> 
> Signed-off-by: Jim Fehlig <jfehlig@suse.com>
> ---
>  src/remote/remote_driver.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

> 
> diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
> index c4831db6cd..132d0194c6 100644
> --- a/src/remote/remote_driver.c
> +++ b/src/remote/remote_driver.c
> @@ -1408,7 +1408,7 @@ remoteConnectGetType(virConnectPtr conn)
>          return NULL;
>  
>      /* Stash. */
> -    return priv->type = ret.type;
> +    return priv->type = g_steal_pointer(&ret.type);
>  }
>  
>  static int remoteConnectIsSecure(virConnectPtr conn)
> -- 
> 2.43.0
> _______________________________________________
> Devel mailing list -- devel@lists.libvirt.org
> To unsubscribe send an email to devel-leave@lists.libvirt.org

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org