qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] vhost-user-test: added proper TestServer *dest initialization in test_migrate()
@ 2018-06-26 14:18 Emanuele Giuseppe Esposito
  2018-06-27 10:05 ` Laurent Vivier
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Emanuele Giuseppe Esposito @ 2018-06-26 14:18 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Paolo Bonzini, Laurent Vivier,
	Emanuele Giuseppe Esposito

server->bus in _test_server_free() could be NULL, since TestServer *dest in test_migrate() was not properly initialized like TestServer *s.
Added init_virtio_dev(dest) and uninit_virtio_dev(dest), so the fields are properly set and when test_server_free(dest); is called, they can be correctly freed.

The reason for that is init_virtio_dev() calls qpci_init_pc(), that creates a QPCIBusPC * (returned as QPCIBus *), while test_server_free() calls qpci_free_pc(),
that frees the QPCIBus *. Not calling init_virtio_dev() would leave the QPCIBus * of TestServer unset.

Problem came out once I modified  pci-pc.c and pci-pc.h, modifying QPCIBusPC by adding another field before QPCIBus bus. Re-running the tests showed vhost-user-test failing.

Signed-off-by: Emanuele Giuseppe Esposito <esposem@usi.ch>
---
 tests/vhost-user-test.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index bbc8091..4d71d5e 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -545,6 +545,7 @@ static gboolean _test_server_free(TestServer *server)
     g_free(server->mig_path);
 
     g_free(server->chr_name);
+    g_assert(server->bus);
     qpci_free_pc(server->bus);
 
     g_free(server);
@@ -706,6 +707,7 @@ static void test_migrate(void)
     g_free(cmd);
 
     init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
+    init_virtio_dev(dest, 1u << VIRTIO_NET_F_MAC);
     wait_for_fds(s);
     size = get_log_size(s);
     g_assert_cmpint(size, ==, (2 * 1024 * 1024) / (VHOST_LOG_PAGE * 8));
@@ -761,6 +763,7 @@ static void test_migrate(void)
     read_guest_mem_server(dest);
 
     uninit_virtio_dev(s);
+    uninit_virtio_dev(dest);
 
     g_source_destroy(source);
     g_source_unref(source);
-- 
2.7.4

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

* Re: [Qemu-devel] [PATCH] vhost-user-test: added proper TestServer *dest initialization in test_migrate()
  2018-06-26 14:18 [Qemu-devel] [PATCH] vhost-user-test: added proper TestServer *dest initialization in test_migrate() Emanuele Giuseppe Esposito
@ 2018-06-27 10:05 ` Laurent Vivier
  2018-07-15 15:41   ` Paolo Bonzini
  2018-06-28  3:57 ` Philippe Mathieu-Daudé
  2018-07-15 15:40 ` Paolo Bonzini
  2 siblings, 1 reply; 5+ messages in thread
From: Laurent Vivier @ 2018-06-27 10:05 UTC (permalink / raw)
  To: Emanuele Giuseppe Esposito, qemu-devel
  Cc: Marc-André Lureau, Emanuele Giuseppe Esposito, Paolo Bonzini,
	Peter Maydell

On 26/06/2018 16:18, Emanuele Giuseppe Esposito wrote:
> server->bus in _test_server_free() could be NULL, since TestServer *dest in test_migrate() was not properly initialized like TestServer *s.
> Added init_virtio_dev(dest) and uninit_virtio_dev(dest), so the fields are properly set and when test_server_free(dest); is called, they can be correctly freed.
> 
> The reason for that is init_virtio_dev() calls qpci_init_pc(), that creates a QPCIBusPC * (returned as QPCIBus *), while test_server_free() calls qpci_free_pc(),
> that frees the QPCIBus *. Not calling init_virtio_dev() would leave the QPCIBus * of TestServer unset.
> 
> Problem came out once I modified  pci-pc.c and pci-pc.h, modifying QPCIBusPC by adding another field before QPCIBus bus. Re-running the tests showed vhost-user-test failing.
> 
> Signed-off-by: Emanuele Giuseppe Esposito <esposem@usi.ch>

Reviewed-by: Laurent Vivier <lvivier@redhat.com>

I'm wondering if we have to have the same email address in both "From:"
and "Signed-off-by"?

Thanks,
Laurent

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

* Re: [Qemu-devel] [PATCH] vhost-user-test: added proper TestServer *dest initialization in test_migrate()
  2018-06-26 14:18 [Qemu-devel] [PATCH] vhost-user-test: added proper TestServer *dest initialization in test_migrate() Emanuele Giuseppe Esposito
  2018-06-27 10:05 ` Laurent Vivier
@ 2018-06-28  3:57 ` Philippe Mathieu-Daudé
  2018-07-15 15:40 ` Paolo Bonzini
  2 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-28  3:57 UTC (permalink / raw)
  To: Emanuele Giuseppe Esposito, Laurent Vivier
  Cc: qemu-devel, Marc-André Lureau, Emanuele Giuseppe Esposito,
	Paolo Bonzini

Hi Emanuele,

On 06/26/2018 11:18 AM, Emanuele Giuseppe Esposito wrote:
> server->bus in _test_server_free() could be NULL, since TestServer *dest in test_migrate() was not properly initialized like TestServer *s.
> Added init_virtio_dev(dest) and uninit_virtio_dev(dest), so the fields are properly set and when test_server_free(dest); is called, they can be correctly freed.
> 
> The reason for that is init_virtio_dev() calls qpci_init_pc(), that creates a QPCIBusPC * (returned as QPCIBus *), while test_server_free() calls qpci_free_pc(),
> that frees the QPCIBus *. Not calling init_virtio_dev() would leave the QPCIBus * of TestServer unset.

Good finding.

> 
> Problem came out once I modified  pci-pc.c and pci-pc.h, modifying QPCIBusPC by adding another field before QPCIBus bus. Re-running the tests showed vhost-user-test failing.

Please use lines < 80 characters in your commit messages if possible (72
is a good candidate).

> 
> Signed-off-by: Emanuele Giuseppe Esposito <esposem@usi.ch>
> ---
>  tests/vhost-user-test.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
> index bbc8091..4d71d5e 100644
> --- a/tests/vhost-user-test.c
> +++ b/tests/vhost-user-test.c
> @@ -545,6 +545,7 @@ static gboolean _test_server_free(TestServer *server)
>      g_free(server->mig_path);
>  
>      g_free(server->chr_name);
> +    g_assert(server->bus);

Wouldn't this assert be better placed in qpci_free_pc()?

>      qpci_free_pc(server->bus);
>  
>      g_free(server);
> @@ -706,6 +707,7 @@ static void test_migrate(void)
>      g_free(cmd);
>  
>      init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
> +    init_virtio_dev(dest, 1u << VIRTIO_NET_F_MAC);
>      wait_for_fds(s);
>      size = get_log_size(s);
>      g_assert_cmpint(size, ==, (2 * 1024 * 1024) / (VHOST_LOG_PAGE * 8));
> @@ -761,6 +763,7 @@ static void test_migrate(void)
>      read_guest_mem_server(dest);
>  
>      uninit_virtio_dev(s);
> +    uninit_virtio_dev(dest);
>  
>      g_source_destroy(source);
>      g_source_unref(source);
> 

For the virtio part:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Regards,

Phil.

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

* Re: [Qemu-devel] [PATCH] vhost-user-test: added proper TestServer *dest initialization in test_migrate()
  2018-06-26 14:18 [Qemu-devel] [PATCH] vhost-user-test: added proper TestServer *dest initialization in test_migrate() Emanuele Giuseppe Esposito
  2018-06-27 10:05 ` Laurent Vivier
  2018-06-28  3:57 ` Philippe Mathieu-Daudé
@ 2018-07-15 15:40 ` Paolo Bonzini
  2 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2018-07-15 15:40 UTC (permalink / raw)
  To: Emanuele Giuseppe Esposito, qemu-devel
  Cc: Marc-André Lureau, Laurent Vivier,
	Emanuele Giuseppe Esposito

On 26/06/2018 16:18, Emanuele Giuseppe Esposito wrote:
> server->bus in _test_server_free() could be NULL, since TestServer *dest in test_migrate() was not properly initialized like TestServer *s.
> Added init_virtio_dev(dest) and uninit_virtio_dev(dest), so the fields are properly set and when test_server_free(dest); is called, they can be correctly freed.
> 
> The reason for that is init_virtio_dev() calls qpci_init_pc(), that creates a QPCIBusPC * (returned as QPCIBus *), while test_server_free() calls qpci_free_pc(),
> that frees the QPCIBus *. Not calling init_virtio_dev() would leave the QPCIBus * of TestServer unset.
> 
> Problem came out once I modified  pci-pc.c and pci-pc.h, modifying QPCIBusPC by adding another field before QPCIBus bus. Re-running the tests showed vhost-user-test failing.
> 
> Signed-off-by: Emanuele Giuseppe Esposito <esposem@usi.ch>
> ---
>  tests/vhost-user-test.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
> index bbc8091..4d71d5e 100644
> --- a/tests/vhost-user-test.c
> +++ b/tests/vhost-user-test.c
> @@ -545,6 +545,7 @@ static gboolean _test_server_free(TestServer *server)
>      g_free(server->mig_path);
>  
>      g_free(server->chr_name);
> +    g_assert(server->bus);
>      qpci_free_pc(server->bus);
>  
>      g_free(server);
> @@ -706,6 +707,7 @@ static void test_migrate(void)
>      g_free(cmd);
>  
>      init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC);
> +    init_virtio_dev(dest, 1u << VIRTIO_NET_F_MAC);
>      wait_for_fds(s);
>      size = get_log_size(s);
>      g_assert_cmpint(size, ==, (2 * 1024 * 1024) / (VHOST_LOG_PAGE * 8));
> @@ -761,6 +763,7 @@ static void test_migrate(void)
>      read_guest_mem_server(dest);
>  
>      uninit_virtio_dev(s);
> +    uninit_virtio_dev(dest);
>  
>      g_source_destroy(source);
>      g_source_unref(source);
> 

Queued for 3.0, thanks.

Paolo

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

* Re: [Qemu-devel] [PATCH] vhost-user-test: added proper TestServer *dest initialization in test_migrate()
  2018-06-27 10:05 ` Laurent Vivier
@ 2018-07-15 15:41   ` Paolo Bonzini
  0 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2018-07-15 15:41 UTC (permalink / raw)
  To: Laurent Vivier, Emanuele Giuseppe Esposito, qemu-devel
  Cc: Marc-André Lureau, Emanuele Giuseppe Esposito, Peter Maydell

On 27/06/2018 12:05, Laurent Vivier wrote:
> On 26/06/2018 16:18, Emanuele Giuseppe Esposito wrote:
>> server->bus in _test_server_free() could be NULL, since TestServer *dest in test_migrate() was not properly initialized like TestServer *s.
>> Added init_virtio_dev(dest) and uninit_virtio_dev(dest), so the fields are properly set and when test_server_free(dest); is called, they can be correctly freed.
>>
>> The reason for that is init_virtio_dev() calls qpci_init_pc(), that creates a QPCIBusPC * (returned as QPCIBus *), while test_server_free() calls qpci_free_pc(),
>> that frees the QPCIBus *. Not calling init_virtio_dev() would leave the QPCIBus * of TestServer unset.
>>
>> Problem came out once I modified  pci-pc.c and pci-pc.h, modifying QPCIBusPC by adding another field before QPCIBus bus. Re-running the tests showed vhost-user-test failing.
>>
>> Signed-off-by: Emanuele Giuseppe Esposito <esposem@usi.ch>
> 
> Reviewed-by: Laurent Vivier <lvivier@redhat.com>
> 
> I'm wondering if we have to have the same email address in both "From:"
> and "Signed-off-by"?
> 
> Thanks,
> Laurent
> 

Yes, it's better.  I have adjusted the Signed-off-by line.

Thanks,

Paolo

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

end of thread, other threads:[~2018-07-15 15:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-26 14:18 [Qemu-devel] [PATCH] vhost-user-test: added proper TestServer *dest initialization in test_migrate() Emanuele Giuseppe Esposito
2018-06-27 10:05 ` Laurent Vivier
2018-07-15 15:41   ` Paolo Bonzini
2018-06-28  3:57 ` Philippe Mathieu-Daudé
2018-07-15 15:40 ` Paolo Bonzini

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).