Skip to contentSkip to conversation

block: Use QDict helpers for --force-share

PATCH Applied Eric Blake 3 participants 3 messages May 15, 2017 – May 16, 2017

lore
Share & tools
lore

Eric Blake

author
#0 lore raw

PATCH 1/1 block: Use QDict helpers for --force-share

Fam's addition of --force-share in commits 459571f7 and 335e9937 were developed prior to the addition of QDict scalar insertion macros, but merged after the general cleanup in commit 46f5ac20. Patch created mechanically by rerunning:

 spatch --sp-file scripts/coccinelle/qobject.cocci \
        --macro-file scripts/cocci-macro-file.h --dir . --in-place

---

This could go in through Markus' qapi tree (since he took the original cleanup), a block maintainer (since it only touches block files), or even the trivial patch queue (since it's so small and mechanical) - I don't care which, as long as we don't drop it!

 qemu-img.c | 7 +++----
 qemu-io.c  | 2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)
qemu-img.c +3 -4
index b506839..60f1784 100644
@@ -296,7 +296,7 @@ static BlockBackend *img_open_opts(const char *optstr,
             error_report("--force-share/-U conflicts with image options");
             return NULL;
         }
-        qdict_put(options, BDRV_OPT_FORCE_SHARE, qbool_from_bool(true));
+        qdict_put_bool(options, BDRV_OPT_FORCE_SHARE, true);
     }
     blk = blk_new_open(NULL, NULL, options, flags, &local_err);
     if (!blk) {
@@ -326,7 +326,7 @@ static BlockBackend *img_open_file(const char *filename,
     }
 
     if (force_share) {
-        qdict_put(options, BDRV_OPT_FORCE_SHARE, qbool_from_bool(true));
+        qdict_put_bool(options, BDRV_OPT_FORCE_SHARE, true);
     }
     blk = blk_new_open(filename, NULL, options, flags, &local_err);
     if (!blk) {
@@ -3156,8 +3156,7 @@ static int img_rebase(int argc, char **argv)
             if (!options) {
                 options = qdict_new();
             }
-            qdict_put(options, BDRV_OPT_FORCE_SHARE,
-                      qbool_from_bool(true));
+            qdict_put_bool(options, BDRV_OPT_FORCE_SHARE, true);
         }
         bdrv_get_backing_filename(bs, backing_name, sizeof(backing_name));
         blk_old_backing = blk_new_open(backing_name, NULL,
qemu-io.c +1 -1
index 34fa8a1..8e38b28 100644
@@ -76,7 +76,7 @@ static int openfile(char *name, int flags, bool writethrough, bool force_share,
             QDECREF(opts);
             return 1;
         }
-        qdict_put(opts, BDRV_OPT_FORCE_SHARE, qbool_from_bool(true));
+        qdict_put_bool(opts, BDRV_OPT_FORCE_SHARE, true);
     }
     qemuio_blk = blk_new_open(name, NULL, opts, flags, &local_err);
     if (!qemuio_blk) {
Signature · 1 line
2.9.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 69 lines · Eric Blake

Fam's addition of --force-share in commits 459571f7 and 335e9937 were developed prior to the addition of QDict scalar insertion macros, but merged after the general cleanup in commit 46f5ac20. Patch created mechanically by rerunning:

 spatch --sp-file scripts/coccinelle/qobject.cocci \
        --macro-file scripts/cocci-macro-file.h --dir . --in-place

---

This could go in through Markus' qapi tree (since he took the original cleanup), a block maintainer (since it only touches block files), or even the trivial patch queue (since it's so small and mechanical) - I don't care which, as long as we don't drop it!

 qemu-img.c | 7 +++----
 qemu-io.c  | 2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)
qemu-img.c +3 -4
index b506839..60f1784 100644
@@ -296,7 +296,7 @@ static BlockBackend *img_open_opts(const char *optstr,
             error_report("--force-share/-U conflicts with image options");
             return NULL;
         }
-        qdict_put(options, BDRV_OPT_FORCE_SHARE, qbool_from_bool(true));
+        qdict_put_bool(options, BDRV_OPT_FORCE_SHARE, true);
     }
     blk = blk_new_open(NULL, NULL, options, flags, &local_err);
     if (!blk) {
@@ -326,7 +326,7 @@ static BlockBackend *img_open_file(const char *filename,
     }
 
     if (force_share) {
-        qdict_put(options, BDRV_OPT_FORCE_SHARE, qbool_from_bool(true));
+        qdict_put_bool(options, BDRV_OPT_FORCE_SHARE, true);
     }
     blk = blk_new_open(filename, NULL, options, flags, &local_err);
     if (!blk) {
@@ -3156,8 +3156,7 @@ static int img_rebase(int argc, char **argv)
             if (!options) {
                 options = qdict_new();
             }
-            qdict_put(options, BDRV_OPT_FORCE_SHARE,
-                      qbool_from_bool(true));
+            qdict_put_bool(options, BDRV_OPT_FORCE_SHARE, true);
         }
         bdrv_get_backing_filename(bs, backing_name, sizeof(backing_name));
         blk_old_backing = blk_new_open(backing_name, NULL,
qemu-io.c +1 -1
index 34fa8a1..8e38b28 100644
@@ -76,7 +76,7 @@ static int openfile(char *name, int flags, bool writethrough, bool force_share,
             QDECREF(opts);
             return 1;
         }
-        qdict_put(opts, BDRV_OPT_FORCE_SHARE, qbool_from_bool(true));
+        qdict_put_bool(opts, BDRV_OPT_FORCE_SHARE, true);
     }
     qemuio_blk = blk_new_open(name, NULL, opts, flags, &local_err);
     if (!qemuio_blk) {
Signature · 1 line
2.9.4
#2 lore raw
In reply to Eric Blake
Quoted 8 lines · Eric Blake

Fam's addition of --force-share in commits 459571f7 and 335e9937 were developed prior to the addition of QDict scalar insertion macros, but merged after the general cleanup in commit 46f5ac20. Patch created mechanically by rerunning:

 spatch --sp-file scripts/coccinelle/qobject.cocci \
        --macro-file scripts/cocci-macro-file.h --dir . --in-place
Quoted 7 lines

---

This could go in through Markus' qapi tree (since he took the original cleanup), a block maintainer (since it only touches block files), or even the trivial patch queue (since it's so small and mechanical) - I don't care which, as long as we don't drop it!

Applied to qapi-next, thanks!