All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Try fixes test-replication.c running on msys2/mingw
@ 2020-09-05 21:10 Yonggang Luo
  2020-09-05 21:10 ` [PATCH 1/2] tests: Trying fixes test-replication.c " Yonggang Luo
  2020-09-05 21:10 ` [PATCH 2/2] block: get file-win32.c handle locking option consistence with file-posix.c Yonggang Luo
  0 siblings, 2 replies; 6+ messages in thread
From: Yonggang Luo @ 2020-09-05 21:10 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, QEMU Block, Stefan Weil, Xie Changlong, Max Reitz,
	Yonggang Luo, Wen Congyang

Still failing
1..13
ok 1 /replication/primary/read
ok 2 /replication/primary/write
ok 3 /replication/primary/start
ok 4 /replication/primary/stop
ok 5 /replication/primary/do_checkpoint
ok 6 /replication/primary/get_error_all
ok 7 /replication/secondary/read
ok 8 /replication/secondary/write
Unexpected error in bdrv_reopen_prepare() at ../block.c:4191:
Block format 'file' used by node '#block4251' does not support reopening files

Yonggang Luo (2):
  tests: Trying fixes test-replication.c on msys2/mingw.
  block: get file-win32.c handle locking option consistence with
    file-posix.c

 block/file-win32.c       | 23 +++++++++++++++++++++--
 tests/test-replication.c | 13 +++++++++----
 2 files changed, 30 insertions(+), 6 deletions(-)

-- 
2.28.0.windows.1



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

* [PATCH 1/2] tests: Trying fixes test-replication.c on msys2/mingw.
  2020-09-05 21:10 [PATCH 0/2] Try fixes test-replication.c running on msys2/mingw Yonggang Luo
@ 2020-09-05 21:10 ` Yonggang Luo
  2020-09-05 21:49   ` Stefan Weil
  2020-09-05 21:10 ` [PATCH 2/2] block: get file-win32.c handle locking option consistence with file-posix.c Yonggang Luo
  1 sibling, 1 reply; 6+ messages in thread
From: Yonggang Luo @ 2020-09-05 21:10 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, QEMU Block, Stefan Weil, Xie Changlong, Max Reitz,
	Yonggang Luo, Wen Congyang

On Windows there is no path like /tmp/s_local_disk.XXXXXX

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 tests/test-replication.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/tests/test-replication.c b/tests/test-replication.c
index 9ab3666a90..3cf544a133 100644
--- a/tests/test-replication.c
+++ b/tests/test-replication.c
@@ -23,14 +23,14 @@
 
 /* primary */
 #define P_ID "primary-id"
-static char p_local_disk[] = "/tmp/p_local_disk.XXXXXX";
+static char p_local_disk[PATH_MAX];
 
 /* secondary */
 #define S_ID "secondary-id"
 #define S_LOCAL_DISK_ID "secondary-local-disk-id"
-static char s_local_disk[] = "/tmp/s_local_disk.XXXXXX";
-static char s_active_disk[] = "/tmp/s_active_disk.XXXXXX";
-static char s_hidden_disk[] = "/tmp/s_hidden_disk.XXXXXX";
+static char s_local_disk[PATH_MAX];
+static char s_active_disk[PATH_MAX];
+static char s_hidden_disk[PATH_MAX];
 
 /* FIXME: steal from blockdev.c */
 QemuOptsList qemu_drive_opts = {
@@ -571,6 +571,11 @@ static void setup_sigabrt_handler(void)
 int main(int argc, char **argv)
 {
     int ret;
+    const char *tmpdir = g_get_tmp_dir();
+    sprintf(p_local_disk, "%s/p_local_disk.XXXXXX", tmpdir);
+    sprintf(s_local_disk, "%s/s_local_disk.XXXXXX", tmpdir);
+    sprintf(s_active_disk, "%s/s_active_disk.XXXXXX", tmpdir);
+    sprintf(s_hidden_disk, "%s/s_hidden_disk.XXXXXX", tmpdir);
     qemu_init_main_loop(&error_fatal);
     bdrv_init();
 
-- 
2.28.0.windows.1



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

* [PATCH 2/2] block: get file-win32.c handle locking option consistence with file-posix.c
  2020-09-05 21:10 [PATCH 0/2] Try fixes test-replication.c running on msys2/mingw Yonggang Luo
  2020-09-05 21:10 ` [PATCH 1/2] tests: Trying fixes test-replication.c " Yonggang Luo
@ 2020-09-05 21:10 ` Yonggang Luo
  1 sibling, 0 replies; 6+ messages in thread
From: Yonggang Luo @ 2020-09-05 21:10 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, QEMU Block, Stefan Weil, Xie Changlong, Max Reitz,
	Yonggang Luo, Wen Congyang

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 block/file-win32.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/block/file-win32.c b/block/file-win32.c
index ab69bd811a..14e5f5c3b5 100644
--- a/block/file-win32.c
+++ b/block/file-win32.c
@@ -299,6 +299,11 @@ static QemuOptsList raw_runtime_opts = {
             .type = QEMU_OPT_STRING,
             .help = "host AIO implementation (threads, native)",
         },
+        {
+            .name = "locking",
+            .type = QEMU_OPT_STRING,
+            .help = "file locking mode (on/off/auto, default: auto)",
+        },
         { /* end of list */ }
     },
 };
@@ -334,6 +339,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
     const char *filename;
     bool use_aio;
     int ret;
+    OnOffAuto locking;
 
     s->type = FTYPE_FILE;
 
@@ -342,11 +348,24 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
         ret = -EINVAL;
         goto fail;
     }
-
-    if (qdict_get_try_bool(options, "locking", false)) {
+    locking = qapi_enum_parse(&OnOffAuto_lookup,
+                              qemu_opt_get(opts, "locking"),
+                              ON_OFF_AUTO_AUTO, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        ret = -EINVAL;
+        goto fail;
+    }
+    switch (locking) {
+    case ON_OFF_AUTO_ON:
         error_setg(errp, "locking=on is not supported on Windows");
         ret = -EINVAL;
         goto fail;
+    case ON_OFF_AUTO_OFF:
+    case ON_OFF_AUTO_AUTO:
+        break;
+    default:
+        g_assert_not_reached();
     }
 
     filename = qemu_opt_get(opts, "filename");
-- 
2.28.0.windows.1



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

* Re: [PATCH 1/2] tests: Trying fixes test-replication.c on msys2/mingw.
  2020-09-05 21:10 ` [PATCH 1/2] tests: Trying fixes test-replication.c " Yonggang Luo
@ 2020-09-05 21:49   ` Stefan Weil
  2020-09-06 12:13     ` 罗勇刚(Yonggang Luo)
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Weil @ 2020-09-05 21:49 UTC (permalink / raw)
  To: Yonggang Luo, qemu-devel
  Cc: Kevin Wolf, Wen Congyang, Xie Changlong, QEMU Block, Max Reitz

Am 05.09.20 um 23:10 schrieb Yonggang Luo:

> On Windows there is no path like /tmp/s_local_disk.XXXXXX
>
> Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> ---
>  tests/test-replication.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/tests/test-replication.c b/tests/test-replication.c
> index 9ab3666a90..3cf544a133 100644
> --- a/tests/test-replication.c
> +++ b/tests/test-replication.c
> @@ -23,14 +23,14 @@
>  
>  /* primary */
>  #define P_ID "primary-id"
> -static char p_local_disk[] = "/tmp/p_local_disk.XXXXXX";
> +static char p_local_disk[PATH_MAX];
>  
>  /* secondary */
>  #define S_ID "secondary-id"
>  #define S_LOCAL_DISK_ID "secondary-local-disk-id"
> -static char s_local_disk[] = "/tmp/s_local_disk.XXXXXX";
> -static char s_active_disk[] = "/tmp/s_active_disk.XXXXXX";
> -static char s_hidden_disk[] = "/tmp/s_hidden_disk.XXXXXX";
> +static char s_local_disk[PATH_MAX];
> +static char s_active_disk[PATH_MAX];
> +static char s_hidden_disk[PATH_MAX];
>  
>  /* FIXME: steal from blockdev.c */
>  QemuOptsList qemu_drive_opts = {
> @@ -571,6 +571,11 @@ static void setup_sigabrt_handler(void)
>  int main(int argc, char **argv)
>  {
>      int ret;
> +    const char *tmpdir = g_get_tmp_dir();
> +    sprintf(p_local_disk, "%s/p_local_disk.XXXXXX", tmpdir);
> +    sprintf(s_local_disk, "%s/s_local_disk.XXXXXX", tmpdir);
> +    sprintf(s_active_disk, "%s/s_active_disk.XXXXXX", tmpdir);
> +    sprintf(s_hidden_disk, "%s/s_hidden_disk.XXXXXX", tmpdir);
>      qemu_init_main_loop(&error_fatal);
>      bdrv_init();
>  


Maybe it is possible to use get_tmp_filename() (which could be
simplified by using g_get_tmp_dir).

And please use snprintf instead of sprintf. I am afraid that a path can
be longer than PATH_MAX, even if the tmpdir path is normally rather short.

You could also allocate the different filenames dynamically instead of
limiting them to PATH_MAX characters.

Regards

Stefan Weil




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

* Re: [PATCH 1/2] tests: Trying fixes test-replication.c on msys2/mingw.
  2020-09-05 21:49   ` Stefan Weil
@ 2020-09-06 12:13     ` 罗勇刚(Yonggang Luo)
  2020-09-07  9:24       ` Daniel P. Berrangé
  0 siblings, 1 reply; 6+ messages in thread
From: 罗勇刚(Yonggang Luo) @ 2020-09-06 12:13 UTC (permalink / raw)
  To: Stefan Weil
  Cc: Kevin Wolf, QEMU Block, Wen Congyang, Xie Changlong, qemu-level,
	Max Reitz

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

On Sun, Sep 6, 2020 at 5:49 AM Stefan Weil <sw@weilnetz.de> wrote:

> Am 05.09.20 um 23:10 schrieb Yonggang Luo:
>
> > On Windows there is no path like /tmp/s_local_disk.XXXXXX
> >
> > Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> > ---
> >  tests/test-replication.c | 13 +++++++++----
> >  1 file changed, 9 insertions(+), 4 deletions(-)
> >
> > diff --git a/tests/test-replication.c b/tests/test-replication.c
> > index 9ab3666a90..3cf544a133 100644
> > --- a/tests/test-replication.c
> > +++ b/tests/test-replication.c
> > @@ -23,14 +23,14 @@
> >
> >  /* primary */
> >  #define P_ID "primary-id"
> > -static char p_local_disk[] = "/tmp/p_local_disk.XXXXXX";
> > +static char p_local_disk[PATH_MAX];
> >
> >  /* secondary */
> >  #define S_ID "secondary-id"
> >  #define S_LOCAL_DISK_ID "secondary-local-disk-id"
> > -static char s_local_disk[] = "/tmp/s_local_disk.XXXXXX";
> > -static char s_active_disk[] = "/tmp/s_active_disk.XXXXXX";
> > -static char s_hidden_disk[] = "/tmp/s_hidden_disk.XXXXXX";
> > +static char s_local_disk[PATH_MAX];
> > +static char s_active_disk[PATH_MAX];
> > +static char s_hidden_disk[PATH_MAX];
> >
> >  /* FIXME: steal from blockdev.c */
> >  QemuOptsList qemu_drive_opts = {
> > @@ -571,6 +571,11 @@ static void setup_sigabrt_handler(void)
> >  int main(int argc, char **argv)
> >  {
> >      int ret;
> > +    const char *tmpdir = g_get_tmp_dir();
> > +    sprintf(p_local_disk, "%s/p_local_disk.XXXXXX", tmpdir);
> > +    sprintf(s_local_disk, "%s/s_local_disk.XXXXXX", tmpdir);
> > +    sprintf(s_active_disk, "%s/s_active_disk.XXXXXX", tmpdir);
> > +    sprintf(s_hidden_disk, "%s/s_hidden_disk.XXXXXX", tmpdir);
> >      qemu_init_main_loop(&error_fatal);
> >      bdrv_init();
> >
>
>
> Maybe it is possible to use get_tmp_filename() (which could be
> simplified by using g_get_tmp_dir).
>
What  does get_tmp_filename mean? I didn't understand

>
> And please use snprintf instead of sprintf. I am afraid that a path can
> be longer than PATH_MAX, even if the tmpdir path is normally rather short.
>
 OK, I'll use  snprintf

>
> You could also allocate the different filenames dynamically instead of
> limiting them to PATH_MAX characters.
>
as a test, it's too complicated,

>
> Regards
>
> Stefan Weil
>
>
>

-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo

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

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

* Re: [PATCH 1/2] tests: Trying fixes test-replication.c on msys2/mingw.
  2020-09-06 12:13     ` 罗勇刚(Yonggang Luo)
@ 2020-09-07  9:24       ` Daniel P. Berrangé
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel P. Berrangé @ 2020-09-07  9:24 UTC (permalink / raw)
  To: 罗勇刚(Yonggang Luo)
  Cc: Kevin Wolf, QEMU Block, Stefan Weil, Xie Changlong, qemu-level,
	Max Reitz, Wen Congyang

On Sun, Sep 06, 2020 at 08:13:19PM +0800, 罗勇刚(Yonggang Luo) wrote:
> On Sun, Sep 6, 2020 at 5:49 AM Stefan Weil <sw@weilnetz.de> wrote:
> 
> > Am 05.09.20 um 23:10 schrieb Yonggang Luo:
> >
> > > On Windows there is no path like /tmp/s_local_disk.XXXXXX
> > >
> > > Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> > > ---
> > >  tests/test-replication.c | 13 +++++++++----
> > >  1 file changed, 9 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/tests/test-replication.c b/tests/test-replication.c
> > > index 9ab3666a90..3cf544a133 100644
> > > --- a/tests/test-replication.c
> > > +++ b/tests/test-replication.c
> > > @@ -23,14 +23,14 @@
> > >
> > >  /* primary */
> > >  #define P_ID "primary-id"
> > > -static char p_local_disk[] = "/tmp/p_local_disk.XXXXXX";
> > > +static char p_local_disk[PATH_MAX];
> > >
> > >  /* secondary */
> > >  #define S_ID "secondary-id"
> > >  #define S_LOCAL_DISK_ID "secondary-local-disk-id"
> > > -static char s_local_disk[] = "/tmp/s_local_disk.XXXXXX";
> > > -static char s_active_disk[] = "/tmp/s_active_disk.XXXXXX";
> > > -static char s_hidden_disk[] = "/tmp/s_hidden_disk.XXXXXX";
> > > +static char s_local_disk[PATH_MAX];
> > > +static char s_active_disk[PATH_MAX];
> > > +static char s_hidden_disk[PATH_MAX];
> > >
> > >  /* FIXME: steal from blockdev.c */
> > >  QemuOptsList qemu_drive_opts = {
> > > @@ -571,6 +571,11 @@ static void setup_sigabrt_handler(void)
> > >  int main(int argc, char **argv)
> > >  {
> > >      int ret;
> > > +    const char *tmpdir = g_get_tmp_dir();
> > > +    sprintf(p_local_disk, "%s/p_local_disk.XXXXXX", tmpdir);
> > > +    sprintf(s_local_disk, "%s/s_local_disk.XXXXXX", tmpdir);
> > > +    sprintf(s_active_disk, "%s/s_active_disk.XXXXXX", tmpdir);
> > > +    sprintf(s_hidden_disk, "%s/s_hidden_disk.XXXXXX", tmpdir);
> > >      qemu_init_main_loop(&error_fatal);
> > >      bdrv_init();
> > >
> >
> >
> > Maybe it is possible to use get_tmp_filename() (which could be
> > simplified by using g_get_tmp_dir).
> >
> What  does get_tmp_filename mean? I didn't understand
> 
> >
> > And please use snprintf instead of sprintf. I am afraid that a path can
> > be longer than PATH_MAX, even if the tmpdir path is normally rather short.
> >
>  OK, I'll use  snprintf
> 
> >
> > You could also allocate the different filenames dynamically instead of
> > limiting them to PATH_MAX characters.
> >
> as a test, it's too complicated,

I really isn't hard to replace sprintf() with g_strdup_printf() and
then g_free() at the end of the test.


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] 6+ messages in thread

end of thread, other threads:[~2020-09-07  9:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-05 21:10 [PATCH 0/2] Try fixes test-replication.c running on msys2/mingw Yonggang Luo
2020-09-05 21:10 ` [PATCH 1/2] tests: Trying fixes test-replication.c " Yonggang Luo
2020-09-05 21:49   ` Stefan Weil
2020-09-06 12:13     ` 罗勇刚(Yonggang Luo)
2020-09-07  9:24       ` Daniel P. Berrangé
2020-09-05 21:10 ` [PATCH 2/2] block: get file-win32.c handle locking option consistence with file-posix.c Yonggang Luo

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.