All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tests/9pfs: fix mkdir() being called twice
@ 2022-01-22 19:12 Christian Schoenebeck
  2022-01-22 20:45 ` Christian Schoenebeck
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Christian Schoenebeck @ 2022-01-22 19:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: Greg Kurz, Daniel P. Berrangé, Thomas Huth, Alex Bennée

The 9p test cases use mkdtemp() to create a temporary directory for
running the 'local' 9p tests with real files/dirs. Unlike mktemp()
which only generates a unique file name, mkdtemp() also creates the
directory, therefore the subsequent mkdir() was wrong and caused
errors on some systems.

Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Fixes: 136b7af2 (tests/9pfs: fix test dir for parallel tests)
Reported-by: Daniel P. Berrangé <berrange@redhat.com>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/832
---
 tests/qtest/libqos/virtio-9p.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c
index b4e1143288..ef96ef006a 100644
--- a/tests/qtest/libqos/virtio-9p.c
+++ b/tests/qtest/libqos/virtio-9p.c
@@ -37,31 +37,19 @@ static char *concat_path(const char* a, const char* b)
     return g_build_filename(a, b, NULL);
 }
 
-static void init_local_test_path(void)
+void virtio_9p_create_local_test_dir(void)
 {
+    struct stat st;
     char *pwd = g_get_current_dir();
     char *template = concat_path(pwd, "qtest-9p-local-XXXXXX");
+
     local_test_path = mkdtemp(template);
     if (!local_test_path) {
         g_test_message("mkdtemp('%s') failed: %s", template, strerror(errno));
     }
-    g_assert(local_test_path);
     g_free(pwd);
-}
-
-void virtio_9p_create_local_test_dir(void)
-{
-    struct stat st;
-    int res;
-
-    init_local_test_path();
 
     g_assert(local_test_path != NULL);
-    res = mkdir(local_test_path, 0777);
-    if (res < 0) {
-        g_test_message("mkdir('%s') failed: %s", local_test_path,
-                       strerror(errno));
-    }
 
     /* ensure test directory exists now ... */
     g_assert(stat(local_test_path, &st) == 0);
-- 
2.30.2



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

* Re: [PATCH] tests/9pfs: fix mkdir() being called twice
  2022-01-22 19:12 [PATCH] tests/9pfs: fix mkdir() being called twice Christian Schoenebeck
@ 2022-01-22 20:45 ` Christian Schoenebeck
  2022-01-25 15:12 ` Daniel P. Berrangé
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Christian Schoenebeck @ 2022-01-22 20:45 UTC (permalink / raw)
  To: qemu-devel
  Cc: Greg Kurz, Daniel P . Berrangé, Thomas Huth, Alex Bennée

On Samstag, 22. Januar 2022 20:12:16 CET Christian Schoenebeck wrote:
> The 9p test cases use mkdtemp() to create a temporary directory for
> running the 'local' 9p tests with real files/dirs. Unlike mktemp()
> which only generates a unique file name, mkdtemp() also creates the
> directory, therefore the subsequent mkdir() was wrong and caused
> errors on some systems.
> 
> Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> Fixes: 136b7af2 (tests/9pfs: fix test dir for parallel tests)
> Reported-by: Daniel P. Berrangé <berrange@redhat.com>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/832
> ---
>  tests/qtest/libqos/virtio-9p.c | 18 +++---------------
>  1 file changed, 3 insertions(+), 15 deletions(-)
> 
> diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c
> index b4e1143288..ef96ef006a 100644
> --- a/tests/qtest/libqos/virtio-9p.c
> +++ b/tests/qtest/libqos/virtio-9p.c
> @@ -37,31 +37,19 @@ static char *concat_path(const char* a, const char* b)
>      return g_build_filename(a, b, NULL);
>  }
> 
> -static void init_local_test_path(void)
> +void virtio_9p_create_local_test_dir(void)
>  {
> +    struct stat st;
>      char *pwd = g_get_current_dir();
>      char *template = concat_path(pwd, "qtest-9p-local-XXXXXX");
> +
>      local_test_path = mkdtemp(template);
>      if (!local_test_path) {
>          g_test_message("mkdtemp('%s') failed: %s", template,
> strerror(errno)); }
> -    g_assert(local_test_path);
>      g_free(pwd);
> -}
> -
> -void virtio_9p_create_local_test_dir(void)
> -{
> -    struct stat st;
> -    int res;
> -
> -    init_local_test_path();
> 

Somebody being picky might argue that the cleanup changes above might be split 
as separate patch ...

>      g_assert(local_test_path != NULL);
> -    res = mkdir(local_test_path, 0777);
> -    if (res < 0) {
> -        g_test_message("mkdir('%s') failed: %s", local_test_path,
> -                       strerror(errno));
> -    }

... from the actual fix being this.

If somebody cares, I'll send a v2.

> 
>      /* ensure test directory exists now ... */
>      g_assert(stat(local_test_path, &st) == 0);

Best regards,
Christian Schoenebeck




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

* Re: [PATCH] tests/9pfs: fix mkdir() being called twice
  2022-01-22 19:12 [PATCH] tests/9pfs: fix mkdir() being called twice Christian Schoenebeck
  2022-01-22 20:45 ` Christian Schoenebeck
@ 2022-01-25 15:12 ` Daniel P. Berrangé
  2022-01-25 15:33 ` Greg Kurz
  2022-01-26 15:29 ` Christian Schoenebeck
  3 siblings, 0 replies; 7+ messages in thread
From: Daniel P. Berrangé @ 2022-01-25 15:12 UTC (permalink / raw)
  To: Christian Schoenebeck
  Cc: Thomas Huth, ?? Alex Bennée, qemu-devel, Greg Kurz

On Sat, Jan 22, 2022 at 08:12:16PM +0100, Christian Schoenebeck wrote:
> The 9p test cases use mkdtemp() to create a temporary directory for
> running the 'local' 9p tests with real files/dirs. Unlike mktemp()
> which only generates a unique file name, mkdtemp() also creates the
> directory, therefore the subsequent mkdir() was wrong and caused
> errors on some systems.
> 
> Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> Fixes: 136b7af2 (tests/9pfs: fix test dir for parallel tests)
> Reported-by: Daniel P. Berrangé <berrange@redhat.com>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/832
> ---
>  tests/qtest/libqos/virtio-9p.c | 18 +++---------------
>  1 file changed, 3 insertions(+), 15 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



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

* Re: [PATCH] tests/9pfs: fix mkdir() being called twice
  2022-01-22 19:12 [PATCH] tests/9pfs: fix mkdir() being called twice Christian Schoenebeck
  2022-01-22 20:45 ` Christian Schoenebeck
  2022-01-25 15:12 ` Daniel P. Berrangé
@ 2022-01-25 15:33 ` Greg Kurz
  2022-01-25 17:51   ` Christian Schoenebeck
  2022-01-26 15:29 ` Christian Schoenebeck
  3 siblings, 1 reply; 7+ messages in thread
From: Greg Kurz @ 2022-01-25 15:33 UTC (permalink / raw)
  To: Christian Schoenebeck
  Cc: Alex Bennée, Thomas Huth, Daniel P. Berrangé, qemu-devel

On Sat, 22 Jan 2022 20:12:16 +0100
Christian Schoenebeck <qemu_oss@crudebyte.com> wrote:

> The 9p test cases use mkdtemp() to create a temporary directory for
> running the 'local' 9p tests with real files/dirs. Unlike mktemp()
> which only generates a unique file name, mkdtemp() also creates the
> directory, therefore the subsequent mkdir() was wrong and caused
> errors on some systems.
> 
> Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> Fixes: 136b7af2 (tests/9pfs: fix test dir for parallel tests)
> Reported-by: Daniel P. Berrangé <berrange@redhat.com>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/832
> ---

Reviewed-by: Greg Kurz <Greg Kurz <groug@kaod.org>

Unrelated, the template pointer is leaked. It looks like g_autofree would
help here. I'll post a follow-up to fix that.

>  tests/qtest/libqos/virtio-9p.c | 18 +++---------------
>  1 file changed, 3 insertions(+), 15 deletions(-)
> 
> diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c
> index b4e1143288..ef96ef006a 100644
> --- a/tests/qtest/libqos/virtio-9p.c
> +++ b/tests/qtest/libqos/virtio-9p.c
> @@ -37,31 +37,19 @@ static char *concat_path(const char* a, const char* b)
>      return g_build_filename(a, b, NULL);
>  }
>  
> -static void init_local_test_path(void)
> +void virtio_9p_create_local_test_dir(void)
>  {
> +    struct stat st;
>      char *pwd = g_get_current_dir();
>      char *template = concat_path(pwd, "qtest-9p-local-XXXXXX");
> +
>      local_test_path = mkdtemp(template);
>      if (!local_test_path) {
>          g_test_message("mkdtemp('%s') failed: %s", template, strerror(errno));
>      }
> -    g_assert(local_test_path);
>      g_free(pwd);
> -}
> -
> -void virtio_9p_create_local_test_dir(void)
> -{
> -    struct stat st;
> -    int res;
> -
> -    init_local_test_path();
>  
>      g_assert(local_test_path != NULL);
> -    res = mkdir(local_test_path, 0777);
> -    if (res < 0) {
> -        g_test_message("mkdir('%s') failed: %s", local_test_path,
> -                       strerror(errno));
> -    }
>  
>      /* ensure test directory exists now ... */
>      g_assert(stat(local_test_path, &st) == 0);



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

* Re: [PATCH] tests/9pfs: fix mkdir() being called twice
  2022-01-25 15:33 ` Greg Kurz
@ 2022-01-25 17:51   ` Christian Schoenebeck
  2022-01-26 10:22     ` Greg Kurz
  0 siblings, 1 reply; 7+ messages in thread
From: Christian Schoenebeck @ 2022-01-25 17:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Greg Kurz, Alex Bennée, Thomas Huth, Daniel P. Berrangé

On Dienstag, 25. Januar 2022 16:33:46 CET Greg Kurz wrote:
> On Sat, 22 Jan 2022 20:12:16 +0100
> 
> Christian Schoenebeck <qemu_oss@crudebyte.com> wrote:
> > The 9p test cases use mkdtemp() to create a temporary directory for
> > running the 'local' 9p tests with real files/dirs. Unlike mktemp()
> > which only generates a unique file name, mkdtemp() also creates the
> > directory, therefore the subsequent mkdir() was wrong and caused
> > errors on some systems.
> > 
> > Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> > Fixes: 136b7af2 (tests/9pfs: fix test dir for parallel tests)
> > Reported-by: Daniel P. Berrangé <berrange@redhat.com>
> > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/832
> > ---
> 
> Reviewed-by: Greg Kurz <Greg Kurz <groug@kaod.org>

Hey, a live sign. :)

> Unrelated, the template pointer is leaked. It looks like g_autofree would
> help here. I'll post a follow-up to fix that.

This man knows what I like to read!

Best regards,
Christian Schoenebeck




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

* Re: [PATCH] tests/9pfs: fix mkdir() being called twice
  2022-01-25 17:51   ` Christian Schoenebeck
@ 2022-01-26 10:22     ` Greg Kurz
  0 siblings, 0 replies; 7+ messages in thread
From: Greg Kurz @ 2022-01-26 10:22 UTC (permalink / raw)
  To: Christian Schoenebeck
  Cc: Daniel P. Berrangé, Thomas Huth, Alex Bennée, qemu-devel

On Tue, 25 Jan 2022 18:51:54 +0100
Christian Schoenebeck <qemu_oss@crudebyte.com> wrote:

> On Dienstag, 25. Januar 2022 16:33:46 CET Greg Kurz wrote:
> > On Sat, 22 Jan 2022 20:12:16 +0100
> > 
> > Christian Schoenebeck <qemu_oss@crudebyte.com> wrote:
> > > The 9p test cases use mkdtemp() to create a temporary directory for
> > > running the 'local' 9p tests with real files/dirs. Unlike mktemp()
> > > which only generates a unique file name, mkdtemp() also creates the
> > > directory, therefore the subsequent mkdir() was wrong and caused
> > > errors on some systems.
> > > 
> > > Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> > > Fixes: 136b7af2 (tests/9pfs: fix test dir for parallel tests)
> > > Reported-by: Daniel P. Berrangé <berrange@redhat.com>
> > > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/832
> > > ---
> > 
> > Reviewed-by: Greg Kurz <Greg Kurz <groug@kaod.org>
> 
> Hey, a live sign. :)
> 

Yeah... My current engagement with kata containers doesn't leave me
much time to do anything else and I just had covid ;-)

> > Unrelated, the template pointer is leaked. It looks like g_autofree would
> > help here. I'll post a follow-up to fix that.
> 
> This man knows what I like to read!
> 

Heh :-)

> Best regards,
> Christian Schoenebeck
> 
> 



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

* Re: [PATCH] tests/9pfs: fix mkdir() being called twice
  2022-01-22 19:12 [PATCH] tests/9pfs: fix mkdir() being called twice Christian Schoenebeck
                   ` (2 preceding siblings ...)
  2022-01-25 15:33 ` Greg Kurz
@ 2022-01-26 15:29 ` Christian Schoenebeck
  3 siblings, 0 replies; 7+ messages in thread
From: Christian Schoenebeck @ 2022-01-26 15:29 UTC (permalink / raw)
  To: qemu-devel
  Cc: Greg Kurz, Daniel P. Berrangé, Thomas Huth, Alex Bennée

On Samstag, 22. Januar 2022 20:12:16 CET Christian Schoenebeck wrote:
> The 9p test cases use mkdtemp() to create a temporary directory for
> running the 'local' 9p tests with real files/dirs. Unlike mktemp()
> which only generates a unique file name, mkdtemp() also creates the
> directory, therefore the subsequent mkdir() was wrong and caused
> errors on some systems.
> 
> Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> Fixes: 136b7af2 (tests/9pfs: fix test dir for parallel tests)
> Reported-by: Daniel P. Berrangé <berrange@redhat.com>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/832
> ---
>  tests/qtest/libqos/virtio-9p.c | 18 +++---------------
>  1 file changed, 3 insertions(+), 15 deletions(-)

Queued on 9p.next:
https://github.com/cschoenebeck/qemu/commits/9p.next

Thanks!

Best regards,
Christian Schoenebeck




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

end of thread, other threads:[~2022-01-26 15:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-22 19:12 [PATCH] tests/9pfs: fix mkdir() being called twice Christian Schoenebeck
2022-01-22 20:45 ` Christian Schoenebeck
2022-01-25 15:12 ` Daniel P. Berrangé
2022-01-25 15:33 ` Greg Kurz
2022-01-25 17:51   ` Christian Schoenebeck
2022-01-26 10:22     ` Greg Kurz
2022-01-26 15:29 ` Christian Schoenebeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.