qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] tests/qtest/migration: Ignore if socket-address is missing to avoid crash below
@ 2024-03-19 20:48 Het Gala
  2024-03-19 20:48 ` [PATCH 2/2] tests/qtest/migration: Fix typo for vsock in SocketAddress_to_str Het Gala
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Het Gala @ 2024-03-19 20:48 UTC (permalink / raw)
  To: qemu-devel
  Cc: marcandre.lureau, thuth, lvivier, pbonzini, peterx, farosas,
	Het Gala

'object' can return NULL if there is no socket-address, such as with a
file migration. Then the visitor code below fails and the test crashes.

Ignore and return NULL when socket-address is missing in the reply so
we don't break future tests that use a non-socket type.

Suggested-by: Fabiano Rosas <farosas@suse.de>
Signed-off-by: Het Gala <het.gala@nutanix.com>
---
 tests/qtest/migration-helpers.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c
index b2a90469fb..fb7156f09a 100644
--- a/tests/qtest/migration-helpers.c
+++ b/tests/qtest/migration-helpers.c
@@ -90,6 +90,10 @@ static SocketAddress *migrate_get_socket_address(QTestState *who)
     QObject *object;
 
     rsp = migrate_query(who);
+
+    if (!qdict_haskey(rsp, "socket-address")) {
+        return NULL;
+    }
     object = qdict_get(rsp, "socket-address");
 
     iv = qobject_input_visitor_new(object);
-- 
2.22.3



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/2] tests/qtest/migration: Fix typo for vsock in SocketAddress_to_str
  2024-03-19 20:48 [PATCH 1/2] tests/qtest/migration: Ignore if socket-address is missing to avoid crash below Het Gala
@ 2024-03-19 20:48 ` Het Gala
  2024-03-19 21:57   ` Peter Xu
  2024-03-19 20:52 ` [PATCH 1/2] tests/qtest/migration: Ignore if socket-address is missing to avoid crash below Het Gala
  2024-03-19 21:57 ` Peter Xu
  2 siblings, 1 reply; 9+ messages in thread
From: Het Gala @ 2024-03-19 20:48 UTC (permalink / raw)
  To: qemu-devel
  Cc: marcandre.lureau, thuth, lvivier, pbonzini, peterx, farosas,
	Het Gala

Signed-off-by: Het Gala <het.gala@nutanix.com>
---
 tests/qtest/migration-helpers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c
index fb7156f09a..651c6c555a 100644
--- a/tests/qtest/migration-helpers.c
+++ b/tests/qtest/migration-helpers.c
@@ -42,7 +42,7 @@ static char *SocketAddress_to_str(SocketAddress *addr)
     case SOCKET_ADDRESS_TYPE_FD:
         return g_strdup_printf("fd:%s", addr->u.fd.str);
     case SOCKET_ADDRESS_TYPE_VSOCK:
-        return g_strdup_printf("tcp:%s:%s",
+        return g_strdup_printf("vsock:%s:%s",
                                addr->u.vsock.cid,
                                addr->u.vsock.port);
     default:
-- 
2.22.3



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] tests/qtest/migration: Ignore if socket-address is missing to avoid crash below
  2024-03-19 20:48 [PATCH 1/2] tests/qtest/migration: Ignore if socket-address is missing to avoid crash below Het Gala
  2024-03-19 20:48 ` [PATCH 2/2] tests/qtest/migration: Fix typo for vsock in SocketAddress_to_str Het Gala
@ 2024-03-19 20:52 ` Het Gala
  2024-03-19 21:57 ` Peter Xu
  2 siblings, 0 replies; 9+ messages in thread
From: Het Gala @ 2024-03-19 20:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcandre.lureau, thuth, lvivier, pbonzini, peterx, farosas

FYI: This 2 patches are rebased on top of another 
(tests/qtest/migration: Add tests for introducing 'channels' argument in 
migrate QAPIs) series.
Can find the build for both the patches here: 
https://gitlab.com/galahet/Qemu/-/pipelines/1219841944

On 20/03/24 2:18 am, Het Gala wrote:
> 'object' can return NULL if there is no socket-address, such as with a
> file migration. Then the visitor code below fails and the test crashes.
>
> Ignore and return NULL when socket-address is missing in the reply so
> we don't break future tests that use a non-socket type.
>
> Suggested-by: Fabiano Rosas <farosas@suse.de>
> Signed-off-by: Het Gala <het.gala@nutanix.com>
> ---
>   tests/qtest/migration-helpers.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c
> index b2a90469fb..fb7156f09a 100644
> --- a/tests/qtest/migration-helpers.c
> +++ b/tests/qtest/migration-helpers.c
> @@ -90,6 +90,10 @@ static SocketAddress *migrate_get_socket_address(QTestState *who)
>       QObject *object;
>   
>       rsp = migrate_query(who);
> +
> +    if (!qdict_haskey(rsp, "socket-address")) {
> +        return NULL;
> +    }
>       object = qdict_get(rsp, "socket-address");
>   
>       iv = qobject_input_visitor_new(object);
Regards,
Het Gala


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] tests/qtest/migration: Ignore if socket-address is missing to avoid crash below
  2024-03-19 20:48 [PATCH 1/2] tests/qtest/migration: Ignore if socket-address is missing to avoid crash below Het Gala
  2024-03-19 20:48 ` [PATCH 2/2] tests/qtest/migration: Fix typo for vsock in SocketAddress_to_str Het Gala
  2024-03-19 20:52 ` [PATCH 1/2] tests/qtest/migration: Ignore if socket-address is missing to avoid crash below Het Gala
@ 2024-03-19 21:57 ` Peter Xu
  2024-03-20  5:17   ` Het Gala
  2 siblings, 1 reply; 9+ messages in thread
From: Peter Xu @ 2024-03-19 21:57 UTC (permalink / raw)
  To: Het Gala; +Cc: qemu-devel, marcandre.lureau, thuth, lvivier, pbonzini, farosas

On Tue, Mar 19, 2024 at 08:48:39PM +0000, Het Gala wrote:
> 'object' can return NULL if there is no socket-address, such as with a
> file migration. Then the visitor code below fails and the test crashes.
> 
> Ignore and return NULL when socket-address is missing in the reply so
> we don't break future tests that use a non-socket type.

Hmm, this patch isn't as clear to me.  Even if this can return NULL now,
it'll soon crash at some later point, no?

IMHO such patch is more suitable to be included in the same patch where
such new tests will be introduced, then we're addressing some real test
code changes that will work, rather than worrying on what will happen in
the future (and as I mentioned, i don't think it fully resolved that either..)

Thanks,

> 
> Suggested-by: Fabiano Rosas <farosas@suse.de>
> Signed-off-by: Het Gala <het.gala@nutanix.com>
> ---
>  tests/qtest/migration-helpers.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c
> index b2a90469fb..fb7156f09a 100644
> --- a/tests/qtest/migration-helpers.c
> +++ b/tests/qtest/migration-helpers.c
> @@ -90,6 +90,10 @@ static SocketAddress *migrate_get_socket_address(QTestState *who)
>      QObject *object;
>  
>      rsp = migrate_query(who);
> +
> +    if (!qdict_haskey(rsp, "socket-address")) {
> +        return NULL;
> +    }
>      object = qdict_get(rsp, "socket-address");
>  
>      iv = qobject_input_visitor_new(object);
> -- 
> 2.22.3
> 

-- 
Peter Xu



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] tests/qtest/migration: Fix typo for vsock in SocketAddress_to_str
  2024-03-19 20:48 ` [PATCH 2/2] tests/qtest/migration: Fix typo for vsock in SocketAddress_to_str Het Gala
@ 2024-03-19 21:57   ` Peter Xu
  0 siblings, 0 replies; 9+ messages in thread
From: Peter Xu @ 2024-03-19 21:57 UTC (permalink / raw)
  To: Het Gala; +Cc: qemu-devel, marcandre.lureau, thuth, lvivier, pbonzini, farosas

On Tue, Mar 19, 2024 at 08:48:40PM +0000, Het Gala wrote:
> Signed-off-by: Het Gala <het.gala@nutanix.com>
> ---
>  tests/qtest/migration-helpers.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c
> index fb7156f09a..651c6c555a 100644
> --- a/tests/qtest/migration-helpers.c
> +++ b/tests/qtest/migration-helpers.c
> @@ -42,7 +42,7 @@ static char *SocketAddress_to_str(SocketAddress *addr)
>      case SOCKET_ADDRESS_TYPE_FD:
>          return g_strdup_printf("fd:%s", addr->u.fd.str);
>      case SOCKET_ADDRESS_TYPE_VSOCK:
> -        return g_strdup_printf("tcp:%s:%s",
> +        return g_strdup_printf("vsock:%s:%s",
>                                 addr->u.vsock.cid,
>                                 addr->u.vsock.port);
>      default:

Queued for 9.1, thanks.

-- 
Peter Xu



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] tests/qtest/migration: Ignore if socket-address is missing to avoid crash below
  2024-03-19 21:57 ` Peter Xu
@ 2024-03-20  5:17   ` Het Gala
  2024-03-20 13:15     ` Peter Xu
  2024-03-20 13:19     ` Fabiano Rosas
  0 siblings, 2 replies; 9+ messages in thread
From: Het Gala @ 2024-03-20  5:17 UTC (permalink / raw)
  To: Peter Xu; +Cc: qemu-devel, marcandre.lureau, thuth, lvivier, pbonzini, farosas

[-- Attachment #1: Type: text/plain, Size: 1795 bytes --]


On 20/03/24 3:27 am, Peter Xu wrote:
> On Tue, Mar 19, 2024 at 08:48:39PM +0000, Het Gala wrote:
>> 'object' can return NULL if there is no socket-address, such as with a
>> file migration. Then the visitor code below fails and the test crashes.
>>
>> Ignore and return NULL when socket-address is missing in the reply so
>> we don't break future tests that use a non-socket type.
> Hmm, this patch isn't as clear to me.  Even if this can return NULL now,
> it'll soon crash at some later point, no?
It won't crash IMO, the next function SocketAddress_to_str for a non-socket
type would return an proper error ?
> IMHO such patch is more suitable to be included in the same patch where
> such new tests will be introduced, then we're addressing some real test
> code changes that will work, rather than worrying on what will happen in
> the future (and as I mentioned, i don't think it fully resolved that either..)
>
> Thanks,
Maybe, Fabiano can pick this patch, and add along file migration qtests 
patch ?
>> Suggested-by: Fabiano Rosas<farosas@suse.de>
>> Signed-off-by: Het Gala<het.gala@nutanix.com>
>> ---
>>   tests/qtest/migration-helpers.c | 4 ++++
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c
>> index b2a90469fb..fb7156f09a 100644
>> --- a/tests/qtest/migration-helpers.c
>> +++ b/tests/qtest/migration-helpers.c
>> @@ -90,6 +90,10 @@ static SocketAddress *migrate_get_socket_address(QTestState *who)
>>       QObject *object;
>>   
>>       rsp = migrate_query(who);
>> +
>> +    if (!qdict_haskey(rsp, "socket-address")) {
>> +        return NULL;
>> +    }
>>       object = qdict_get(rsp, "socket-address");
>>   
>>       iv = qobject_input_visitor_new(object);
>> -- 
>> 2.22.3
>>
Regards,
Het Gala

[-- Attachment #2: Type: text/html, Size: 2884 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] tests/qtest/migration: Ignore if socket-address is missing to avoid crash below
  2024-03-20  5:17   ` Het Gala
@ 2024-03-20 13:15     ` Peter Xu
  2024-03-20 13:19     ` Fabiano Rosas
  1 sibling, 0 replies; 9+ messages in thread
From: Peter Xu @ 2024-03-20 13:15 UTC (permalink / raw)
  To: Het Gala; +Cc: qemu-devel, marcandre.lureau, thuth, lvivier, pbonzini, farosas

On Wed, Mar 20, 2024 at 10:47:18AM +0530, Het Gala wrote:
> It won't crash IMO, the next function SocketAddress_to_str for a non-socket
> type would return an proper error ?

Both SocketAddress_to_str() and SocketAddress_to_qdict() will crash with a
NULL pointer passed in right now.

Thanks,

-- 
Peter Xu



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] tests/qtest/migration: Ignore if socket-address is missing to avoid crash below
  2024-03-20  5:17   ` Het Gala
  2024-03-20 13:15     ` Peter Xu
@ 2024-03-20 13:19     ` Fabiano Rosas
  2024-03-20 14:01       ` Het Gala
  1 sibling, 1 reply; 9+ messages in thread
From: Fabiano Rosas @ 2024-03-20 13:19 UTC (permalink / raw)
  To: Het Gala, Peter Xu; +Cc: qemu-devel, marcandre.lureau, thuth, lvivier, pbonzini

Het Gala <het.gala@nutanix.com> writes:

> On 20/03/24 3:27 am, Peter Xu wrote:
>> On Tue, Mar 19, 2024 at 08:48:39PM +0000, Het Gala wrote:
>>> 'object' can return NULL if there is no socket-address, such as with a
>>> file migration. Then the visitor code below fails and the test crashes.
>>>
>>> Ignore and return NULL when socket-address is missing in the reply so
>>> we don't break future tests that use a non-socket type.
>> Hmm, this patch isn't as clear to me.  Even if this can return NULL now,
>> it'll soon crash at some later point, no?
> It won't crash IMO, the next function SocketAddress_to_str for a non-socket
> type would return an proper error ?
>> IMHO such patch is more suitable to be included in the same patch where
>> such new tests will be introduced, then we're addressing some real test
>> code changes that will work, rather than worrying on what will happen in
>> the future (and as I mentioned, i don't think it fully resolved that either..)
>>
>> Thanks,
> Maybe, Fabiano can pick this patch, and add along file migration qtests 
> patch ?

Yep.

>>> Suggested-by: Fabiano Rosas<farosas@suse.de>
>>> Signed-off-by: Het Gala<het.gala@nutanix.com>
>>> ---
>>>   tests/qtest/migration-helpers.c | 4 ++++
>>>   1 file changed, 4 insertions(+)
>>>
>>> diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c
>>> index b2a90469fb..fb7156f09a 100644
>>> --- a/tests/qtest/migration-helpers.c
>>> +++ b/tests/qtest/migration-helpers.c
>>> @@ -90,6 +90,10 @@ static SocketAddress *migrate_get_socket_address(QTestState *who)
>>>       QObject *object;
>>>   
>>>       rsp = migrate_query(who);
>>> +
>>> +    if (!qdict_haskey(rsp, "socket-address")) {
>>> +        return NULL;
>>> +    }
>>>       object = qdict_get(rsp, "socket-address");
>>>   
>>>       iv = qobject_input_visitor_new(object);
>>> -- 
>>> 2.22.3
>>>
> Regards,
> Het Gala


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] tests/qtest/migration: Ignore if socket-address is missing to avoid crash below
  2024-03-20 13:19     ` Fabiano Rosas
@ 2024-03-20 14:01       ` Het Gala
  0 siblings, 0 replies; 9+ messages in thread
From: Het Gala @ 2024-03-20 14:01 UTC (permalink / raw)
  To: Fabiano Rosas, Peter Xu
  Cc: qemu-devel, marcandre.lureau, thuth, lvivier, pbonzini

[-- Attachment #1: Type: text/plain, Size: 1603 bytes --]


On 20/03/24 6:49 pm, Fabiano Rosas wrote:
> Het Gala<het.gala@nutanix.com>  writes:
>
>> On 20/03/24 3:27 am, Peter Xu wrote:
>>> On Tue, Mar 19, 2024 at 08:48:39PM +0000, Het Gala wrote:
>>>> 'object' can return NULL if there is no socket-address, such as with a
>>>> file migration. Then the visitor code below fails and the test crashes.
>>>>
>>>> Ignore and return NULL when socket-address is missing in the reply so
>>>> we don't break future tests that use a non-socket type.
>>> Hmm, this patch isn't as clear to me.  Even if this can return NULL now,
>>> it'll soon crash at some later point, no?
>> It won't crash IMO, the next function SocketAddress_to_str for a non-socket
>> type would return an proper error ?
>>> IMHO such patch is more suitable to be included in the same patch where
>>> such new tests will be introduced, then we're addressing some real test
>>> code changes that will work, rather than worrying on what will happen in
>>> the future (and as I mentioned, i don't think it fully resolved that either..)
>>>
>>> Thanks,
>> Maybe, Fabiano can pick this patch, and add along file migration qtests
>> patch ?
> Yep.
Thanks
>>>> @@ -90,6 +90,10 @@ static SocketAddress *migrate_get_socket_address(QTestState *who)
>>>>        QObject *object;
>>>>    
>>>>        rsp = migrate_query(who);
>>>> +
>>>> +    if (!qdict_haskey(rsp, "socket-address")) {
>>>> +        return NULL;
>>>> +    }
>>>>        object = qdict_get(rsp, "socket-address");
>>>>    
>>>>        iv = qobject_input_visitor_new(object);
>>>> -- 
>>>> 2.22.3
>>>>
>> Regards,
>> Het Gala

Regards,
Het Gala

[-- Attachment #2: Type: text/html, Size: 3030 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-03-20 14:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-19 20:48 [PATCH 1/2] tests/qtest/migration: Ignore if socket-address is missing to avoid crash below Het Gala
2024-03-19 20:48 ` [PATCH 2/2] tests/qtest/migration: Fix typo for vsock in SocketAddress_to_str Het Gala
2024-03-19 21:57   ` Peter Xu
2024-03-19 20:52 ` [PATCH 1/2] tests/qtest/migration: Ignore if socket-address is missing to avoid crash below Het Gala
2024-03-19 21:57 ` Peter Xu
2024-03-20  5:17   ` Het Gala
2024-03-20 13:15     ` Peter Xu
2024-03-20 13:19     ` Fabiano Rosas
2024-03-20 14:01       ` Het Gala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).