Skip to contentSkip to conversation

vhost-user-test: added proper TestServer *dest initialization in test_migrate()

PATCH Applied Emanuele Giuseppe Esposito 4 participants 5 messages Jun 26, 2018 – Jul 15, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost-user-test: added proper TestServer *dest initialization in test_migrate()

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.

---
 tests/vhost-user-test.c | 3 +++
 1 file changed, 3 insertions(+)
tests/vhost-user-test.c +3 -0
index bbc8091..4d71d5e 100644
@@ -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);
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · 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.

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

Thanks,
Laurent

#2 lore raw
Quoted 11 lines · Laurent Vivier
Quoted 9 lines · 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.

Quoted 8 lines

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

Reviewed-by on v1 1/1
#3 lore raw
In reply to Emanuele Giuseppe Esposito

Hi Emanuele,

Quoted 5 lines · 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.

Good finding.

Quoted 2 lines

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

Quoted 11 lines
---
 tests/vhost-user-test.c | 3 +++
 1 file changed, 3 insertions(+)
tests/vhost-user-test.c +0 -0
index bbc8091..4d71d5e 100644

tests/vhost-user-test.c static gboolean _test_server_free(TestServer *server) · line 548

Quoted 4 lines
tests/vhost-user-test.c +1 -0
@@ -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()?

Quoted 13 lines
tests/vhost-user-test.c +1 -0
     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));

tests/vhost-user-test.c static void test_migrate(void) · line 769

Quoted 7 lines
tests/vhost-user-test.c +1 -0
@@ -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:

Regards,

Phil.

#4 lore raw
In reply to Emanuele Giuseppe Esposito
Quoted 35 lines · 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.

---
 tests/vhost-user-test.c | 3 +++
 1 file changed, 3 insertions(+)
tests/vhost-user-test.c +2 -0
index bbc8091..4d71d5e 100644
@@ -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));

tests/vhost-user-test.c static void test_migrate(void) · line 769

Quoted 7 lines
tests/vhost-user-test.c +1 -0
@@ -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