[libvirt] [PATCH] tools: console: Use proper constructor

Roman Bolshakov posted 1 patch 4 years, 8 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20190805160345.25506-1-r.bolshakov@yadro.com
tools/virsh-console.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[libvirt] [PATCH] tools: console: Use proper constructor
Posted by Roman Bolshakov 4 years, 8 months ago
"virsh console" on macOS cannot attach to a domain and it doesn't matter if
it's local or remote domain:
  $ ~ virsh console vm
  Connected to domain vm
  Escape character is ^]
  error: internal error: unable to wait on console condition

The error comes from pthread_cond_wait that fails with EINVAL. The mutex
in the parent is not initialized with pthread_mutex_init and it results
in silent failure of pthead_mutex_lock and the attach failure.

Fixes: 98361cc3b95 ("tools: console: make console virLockableObject")
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
---
 tools/virsh-console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/virsh-console.c b/tools/virsh-console.c
index 826a4afcb2..e16f841e57 100644
--- a/tools/virsh-console.c
+++ b/tools/virsh-console.c
@@ -367,7 +367,7 @@ virConsoleNew(void)
     if (virConsoleInitialize() < 0)
         return NULL;
 
-    if (!(con = virObjectNew(virConsoleClass)))
+    if (!(con = virObjectLockableNew(virConsoleClass)))
         return NULL;
 
     if (virCondInit(&con->cond) < 0) {
-- 
2.20.1 (Apple Git-117)

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] tools: console: Use proper constructor
Posted by Michal Prívozník 4 years, 8 months ago
On 8/5/19 6:03 PM, Roman Bolshakov wrote:
> "virsh console" on macOS cannot attach to a domain and it doesn't matter if
> it's local or remote domain:
>   $ ~ virsh console vm
>   Connected to domain vm
>   Escape character is ^]
>   error: internal error: unable to wait on console condition
> 
> The error comes from pthread_cond_wait that fails with EINVAL. The mutex
> in the parent is not initialized with pthread_mutex_init and it results
> in silent failure of pthead_mutex_lock and the attach failure.
> 
> Fixes: 98361cc3b95 ("tools: console: make console virLockableObject")
> Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
> ---
>  tools/virsh-console.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Ooops, ACKed and pushed.

Michal

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