[Qemu-devel] [PATCH] tests/ide: Free pcibus when finishing a test

Thomas Huth posted 1 patch 6 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1542121904-17330-1-git-send-email-thuth@redhat.com
Test docker-clang@ubuntu passed
Test checkpatch passed
Test asan passed
Test docker-mingw@fedora passed
Test docker-quick@centos7 passed
tests/ide-test.c | 4 ++++
1 file changed, 4 insertions(+)
[Qemu-devel] [PATCH] tests/ide: Free pcibus when finishing a test
Posted by Thomas Huth 6 years, 11 months ago
Once a test has finished, the pcibus structure should be freed, to
avoid leaking memory and to make sure that the structure is properly
re-initialized when the next test starts.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/ide-test.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/ide-test.c b/tests/ide-test.c
index 33cef61..f0280e6 100644
--- a/tests/ide-test.c
+++ b/tests/ide-test.c
@@ -142,6 +142,10 @@ static void ide_test_start(const char *cmdline_fmt, ...)
 
 static void ide_test_quit(void)
 {
+    if (pcibus) {
+        qpci_free_pc(pcibus);
+        pcibus = NULL;
+    }
     pc_alloc_uninit(guest_malloc);
     guest_malloc = NULL;
     qtest_end();
-- 
1.8.3.1


Re: [Qemu-devel] [PATCH] tests/ide: Free pcibus when finishing a test
Posted by Eric Blake 6 years, 11 months ago
On 11/13/18 9:11 AM, Thomas Huth wrote:
> Once a test has finished, the pcibus structure should be freed, to
> avoid leaking memory and to make sure that the structure is properly
> re-initialized when the next test starts.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   tests/ide-test.c | 4 ++++
>   1 file changed, 4 insertions(+)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> diff --git a/tests/ide-test.c b/tests/ide-test.c
> index 33cef61..f0280e6 100644
> --- a/tests/ide-test.c
> +++ b/tests/ide-test.c
> @@ -142,6 +142,10 @@ static void ide_test_start(const char *cmdline_fmt, ...)
>   
>   static void ide_test_quit(void)
>   {
> +    if (pcibus) {
> +        qpci_free_pc(pcibus);
> +        pcibus = NULL;
> +    }
>       pc_alloc_uninit(guest_malloc);
>       guest_malloc = NULL;
>       qtest_end();
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Re: [Qemu-devel] [PATCH] tests/ide: Free pcibus when finishing a test
Posted by Philippe Mathieu-Daudé 6 years, 11 months ago
On 13/11/18 16:11, Thomas Huth wrote:
> Once a test has finished, the pcibus structure should be freed, to
> avoid leaking memory and to make sure that the structure is properly
> re-initialized when the next test starts.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   tests/ide-test.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/tests/ide-test.c b/tests/ide-test.c
> index 33cef61..f0280e6 100644
> --- a/tests/ide-test.c
> +++ b/tests/ide-test.c
> @@ -142,6 +142,10 @@ static void ide_test_start(const char *cmdline_fmt, ...)
>   
>   static void ide_test_quit(void)
>   {
> +    if (pcibus) {

This check would be cleaner in qpci_free_pc().

> +        qpci_free_pc(pcibus);
> +        pcibus = NULL;

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> +    }
>       pc_alloc_uninit(guest_malloc);
>       guest_malloc = NULL;
>       qtest_end();
> 

Re: [Qemu-devel] [PATCH] tests/ide: Free pcibus when finishing a test
Posted by John Snow 6 years, 11 months ago

On 11/13/18 10:11 AM, Thomas Huth wrote:
> Once a test has finished, the pcibus structure should be freed, to
> avoid leaking memory and to make sure that the structure is properly
> re-initialized when the next test starts.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  tests/ide-test.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tests/ide-test.c b/tests/ide-test.c
> index 33cef61..f0280e6 100644
> --- a/tests/ide-test.c
> +++ b/tests/ide-test.c
> @@ -142,6 +142,10 @@ static void ide_test_start(const char *cmdline_fmt, ...)
>  
>  static void ide_test_quit(void)
>  {
> +    if (pcibus) {
> +        qpci_free_pc(pcibus);
> +        pcibus = NULL;
> +    }
>      pc_alloc_uninit(guest_malloc);
>      guest_malloc = NULL;
>      qtest_end();
> 

Reviewed-by: John Snow <jsnow@redhat.com>

Thanks; I have nothing else queued at the moment, someone else can take
this for now if convenient -- or if I'm being too lazy, let me know and
I'll stage this.

Thanks.