yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
26ba25
From 8c7a6486578c7d3e95ca72d798a3e2a5c3f8c348 Mon Sep 17 00:00:00 2001
26ba25
From: Markus Armbruster <armbru@redhat.com>
26ba25
Date: Mon, 18 Jun 2018 08:43:15 +0200
26ba25
Subject: [PATCH 017/268] block: Add block-specific QDict header
26ba25
26ba25
RH-Author: Markus Armbruster <armbru@redhat.com>
26ba25
Message-id: <20180618084330.30009-9-armbru@redhat.com>
26ba25
Patchwork-id: 80736
26ba25
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 08/23] block: Add block-specific QDict header
26ba25
Bugzilla: 1557995
26ba25
RH-Acked-by: Max Reitz <mreitz@redhat.com>
26ba25
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
26ba25
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
26ba25
26ba25
From: Max Reitz <mreitz@redhat.com>
26ba25
26ba25
There are numerous QDict functions that have been introduced for and are
26ba25
used only by the block layer.  Move their declarations into an own
26ba25
header file to reflect that.
26ba25
26ba25
While qdict_extract_subqdict() is in fact used outside of the block
26ba25
layer (in util/qemu-config.c), it is still a function related very
26ba25
closely to how the block layer works with nested QDicts, namely by
26ba25
sometimes flattening them.  Therefore, its declaration is put into this
26ba25
header as well and util/qemu-config.c includes it with a comment stating
26ba25
exactly which function it needs.
26ba25
26ba25
Suggested-by: Markus Armbruster <armbru@redhat.com>
26ba25
Signed-off-by: Max Reitz <mreitz@redhat.com>
26ba25
Message-Id: <20180509165530.29561-7-mreitz@redhat.com>
26ba25
[Copyright note tweaked, superfluous includes dropped]
26ba25
Signed-off-by: Markus Armbruster <armbru@redhat.com>
26ba25
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
26ba25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26ba25
(cherry picked from commit 609f45ea9507fc1603eaeda7f5066b99beac6721)
26ba25
[Trivial conflict in block/nbd.c resolved]
26ba25
26ba25
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
---
26ba25
 block.c                  |  1 +
26ba25
 block/gluster.c          |  1 +
26ba25
 block/iscsi.c            |  1 +
26ba25
 block/nbd.c              |  1 +
26ba25
 block/nfs.c              |  1 +
26ba25
 block/parallels.c        |  1 +
26ba25
 block/qcow.c             |  1 +
26ba25
 block/qcow2.c            |  1 +
26ba25
 block/qed.c              |  1 +
26ba25
 block/quorum.c           |  1 +
26ba25
 block/rbd.c              |  1 +
26ba25
 block/sheepdog.c         |  1 +
26ba25
 block/snapshot.c         |  1 +
26ba25
 block/ssh.c              |  1 +
26ba25
 block/vhdx.c             |  1 +
26ba25
 block/vpc.c              |  1 +
26ba25
 block/vvfat.c            |  1 +
26ba25
 block/vxhs.c             |  1 +
26ba25
 blockdev.c               |  1 +
26ba25
 include/block/qdict.h    | 32 ++++++++++++++++++++++++++++++++
26ba25
 include/qapi/qmp/qdict.h | 17 -----------------
26ba25
 qobject/qdict.c          |  1 +
26ba25
 tests/check-qdict.c      |  1 +
26ba25
 tests/check-qobject.c    |  1 +
26ba25
 tests/test-replication.c |  1 +
26ba25
 util/qemu-config.c       |  1 +
26ba25
 26 files changed, 56 insertions(+), 17 deletions(-)
26ba25
 create mode 100644 include/block/qdict.h
26ba25
26ba25
diff --git a/block.c b/block.c
26ba25
index 676e57f..3c3e8fd 100644
26ba25
--- a/block.c
26ba25
+++ b/block.c
26ba25
@@ -27,6 +27,7 @@
26ba25
 #include "block/block_int.h"
26ba25
 #include "block/blockjob.h"
26ba25
 #include "block/nbd.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "qemu/error-report.h"
26ba25
 #include "module_block.h"
26ba25
 #include "qemu/module.h"
26ba25
diff --git a/block/gluster.c b/block/gluster.c
26ba25
index 55be566..418bb73 100644
26ba25
--- a/block/gluster.c
26ba25
+++ b/block/gluster.c
26ba25
@@ -11,6 +11,7 @@
26ba25
 #include "qemu/osdep.h"
26ba25
 #include <glusterfs/api/glfs.h>
26ba25
 #include "block/block_int.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "qapi/error.h"
26ba25
 #include "qapi/qmp/qdict.h"
26ba25
 #include "qapi/qmp/qerror.h"
26ba25
diff --git a/block/iscsi.c b/block/iscsi.c
26ba25
index 658462b..1705187 100644
26ba25
--- a/block/iscsi.c
26ba25
+++ b/block/iscsi.c
26ba25
@@ -33,6 +33,7 @@
26ba25
 #include "qemu/bitops.h"
26ba25
 #include "qemu/bitmap.h"
26ba25
 #include "block/block_int.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "scsi/constants.h"
26ba25
 #include "qemu/iov.h"
26ba25
 #include "qemu/option.h"
26ba25
diff --git a/block/nbd.c b/block/nbd.c
26ba25
index 3e1693c..f499830 100644
26ba25
--- a/block/nbd.c
26ba25
+++ b/block/nbd.c
26ba25
@@ -28,6 +28,7 @@
26ba25
 
26ba25
 #include "qemu/osdep.h"
26ba25
 #include "block/nbd-client.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "qapi/error.h"
26ba25
 #include "qemu/uri.h"
26ba25
 #include "block/block_int.h"
26ba25
diff --git a/block/nfs.c b/block/nfs.c
26ba25
index 66fddf1..5159ef0 100644
26ba25
--- a/block/nfs.c
26ba25
+++ b/block/nfs.c
26ba25
@@ -29,6 +29,7 @@
26ba25
 #include "qemu/error-report.h"
26ba25
 #include "qapi/error.h"
26ba25
 #include "block/block_int.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "trace.h"
26ba25
 #include "qemu/iov.h"
26ba25
 #include "qemu/option.h"
26ba25
diff --git a/block/parallels.c b/block/parallels.c
26ba25
index 045810d..0ee1f6a 100644
26ba25
--- a/block/parallels.c
26ba25
+++ b/block/parallels.c
26ba25
@@ -31,6 +31,7 @@
26ba25
 #include "qemu/osdep.h"
26ba25
 #include "qapi/error.h"
26ba25
 #include "block/block_int.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "sysemu/block-backend.h"
26ba25
 #include "qemu/module.h"
26ba25
 #include "qemu/option.h"
26ba25
diff --git a/block/qcow.c b/block/qcow.c
26ba25
index 4b2f7db..fb821ad 100644
26ba25
--- a/block/qcow.c
26ba25
+++ b/block/qcow.c
26ba25
@@ -26,6 +26,7 @@
26ba25
 #include "qapi/error.h"
26ba25
 #include "qemu/error-report.h"
26ba25
 #include "block/block_int.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "sysemu/block-backend.h"
26ba25
 #include "qemu/module.h"
26ba25
 #include "qemu/option.h"
26ba25
diff --git a/block/qcow2.c b/block/qcow2.c
26ba25
index 2f36e63..fa9f557 100644
26ba25
--- a/block/qcow2.c
26ba25
+++ b/block/qcow2.c
26ba25
@@ -24,6 +24,7 @@
26ba25
 
26ba25
 #include "qemu/osdep.h"
26ba25
 #include "block/block_int.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "sysemu/block-backend.h"
26ba25
 #include "qemu/module.h"
26ba25
 #include <zlib.h>
26ba25
diff --git a/block/qed.c b/block/qed.c
26ba25
index 1db8eaf..9a8997a 100644
26ba25
--- a/block/qed.c
26ba25
+++ b/block/qed.c
26ba25
@@ -13,6 +13,7 @@
26ba25
  */
26ba25
 
26ba25
 #include "qemu/osdep.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "qapi/error.h"
26ba25
 #include "qemu/timer.h"
26ba25
 #include "qemu/bswap.h"
26ba25
diff --git a/block/quorum.c b/block/quorum.c
26ba25
index a5051da..f1f39ba 100644
26ba25
--- a/block/quorum.c
26ba25
+++ b/block/quorum.c
26ba25
@@ -17,6 +17,7 @@
26ba25
 #include "qemu/cutils.h"
26ba25
 #include "qemu/option.h"
26ba25
 #include "block/block_int.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "qapi/error.h"
26ba25
 #include "qapi/qapi-events-block.h"
26ba25
 #include "qapi/qmp/qdict.h"
26ba25
diff --git a/block/rbd.c b/block/rbd.c
26ba25
index 2842c0e..e695cf2 100644
26ba25
--- a/block/rbd.c
26ba25
+++ b/block/rbd.c
26ba25
@@ -18,6 +18,7 @@
26ba25
 #include "qemu/error-report.h"
26ba25
 #include "qemu/option.h"
26ba25
 #include "block/block_int.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "crypto/secret.h"
26ba25
 #include "qemu/cutils.h"
26ba25
 #include "qapi/qmp/qstring.h"
26ba25
diff --git a/block/sheepdog.c b/block/sheepdog.c
26ba25
index 07529f4..fd3876f 100644
26ba25
--- a/block/sheepdog.c
26ba25
+++ b/block/sheepdog.c
26ba25
@@ -24,6 +24,7 @@
26ba25
 #include "qemu/option.h"
26ba25
 #include "qemu/sockets.h"
26ba25
 #include "block/block_int.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "sysemu/block-backend.h"
26ba25
 #include "qemu/bitops.h"
26ba25
 #include "qemu/cutils.h"
26ba25
diff --git a/block/snapshot.c b/block/snapshot.c
26ba25
index 2953d96..f9903bc 100644
26ba25
--- a/block/snapshot.c
26ba25
+++ b/block/snapshot.c
26ba25
@@ -25,6 +25,7 @@
26ba25
 #include "qemu/osdep.h"
26ba25
 #include "block/snapshot.h"
26ba25
 #include "block/block_int.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "qapi/error.h"
26ba25
 #include "qapi/qmp/qdict.h"
26ba25
 #include "qapi/qmp/qerror.h"
26ba25
diff --git a/block/ssh.c b/block/ssh.c
26ba25
index 412a1bf..5931064 100644
26ba25
--- a/block/ssh.c
26ba25
+++ b/block/ssh.c
26ba25
@@ -28,6 +28,7 @@
26ba25
 #include <libssh2_sftp.h>
26ba25
 
26ba25
 #include "block/block_int.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "qapi/error.h"
26ba25
 #include "qemu/error-report.h"
26ba25
 #include "qemu/option.h"
26ba25
diff --git a/block/vhdx.c b/block/vhdx.c
26ba25
index c3a4220..26c05aa 100644
26ba25
--- a/block/vhdx.c
26ba25
+++ b/block/vhdx.c
26ba25
@@ -18,6 +18,7 @@
26ba25
 #include "qemu/osdep.h"
26ba25
 #include "qapi/error.h"
26ba25
 #include "block/block_int.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "sysemu/block-backend.h"
26ba25
 #include "qemu/module.h"
26ba25
 #include "qemu/option.h"
26ba25
diff --git a/block/vpc.c b/block/vpc.c
26ba25
index 0ebfcd3..41c8c98 100644
26ba25
--- a/block/vpc.c
26ba25
+++ b/block/vpc.c
26ba25
@@ -26,6 +26,7 @@
26ba25
 #include "qemu/osdep.h"
26ba25
 #include "qapi/error.h"
26ba25
 #include "block/block_int.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "sysemu/block-backend.h"
26ba25
 #include "qemu/module.h"
26ba25
 #include "qemu/option.h"
26ba25
diff --git a/block/vvfat.c b/block/vvfat.c
26ba25
index 662dca0..4595f33 100644
26ba25
--- a/block/vvfat.c
26ba25
+++ b/block/vvfat.c
26ba25
@@ -27,6 +27,7 @@
26ba25
 #include <dirent.h>
26ba25
 #include "qapi/error.h"
26ba25
 #include "block/block_int.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "qemu/module.h"
26ba25
 #include "qemu/option.h"
26ba25
 #include "qemu/bswap.h"
26ba25
diff --git a/block/vxhs.c b/block/vxhs.c
26ba25
index 96e83d9..25fea7f 100644
26ba25
--- a/block/vxhs.c
26ba25
+++ b/block/vxhs.c
26ba25
@@ -13,6 +13,7 @@
26ba25
 #include <gmodule.h>
26ba25
 #include <sys/param.h>
26ba25
 #include "block/block_int.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "qapi/qmp/qerror.h"
26ba25
 #include "qapi/qmp/qdict.h"
26ba25
 #include "qapi/qmp/qstring.h"
26ba25
diff --git a/blockdev.c b/blockdev.c
26ba25
index 3808b1f..19c04d9 100644
26ba25
--- a/blockdev.c
26ba25
+++ b/blockdev.c
26ba25
@@ -35,6 +35,7 @@
26ba25
 #include "sysemu/blockdev.h"
26ba25
 #include "hw/block/block.h"
26ba25
 #include "block/blockjob.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "block/throttle-groups.h"
26ba25
 #include "monitor/monitor.h"
26ba25
 #include "qemu/error-report.h"
26ba25
diff --git a/include/block/qdict.h b/include/block/qdict.h
26ba25
new file mode 100644
26ba25
index 0000000..71c037a
26ba25
--- /dev/null
26ba25
+++ b/include/block/qdict.h
26ba25
@@ -0,0 +1,32 @@
26ba25
+/*
26ba25
+ * Special QDict functions used by the block layer
26ba25
+ *
26ba25
+ * Copyright (c) 2013-2018 Red Hat, Inc.
26ba25
+ *
26ba25
+ * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
26ba25
+ * See the COPYING.LIB file in the top-level directory.
26ba25
+ */
26ba25
+
26ba25
+#ifndef BLOCK_QDICT_H
26ba25
+#define BLOCK_QDICT_H
26ba25
+
26ba25
+#include "qapi/qmp/qdict.h"
26ba25
+
26ba25
+void qdict_copy_default(QDict *dst, QDict *src, const char *key);
26ba25
+void qdict_set_default_str(QDict *dst, const char *key, const char *val);
26ba25
+
26ba25
+void qdict_join(QDict *dest, QDict *src, bool overwrite);
26ba25
+
26ba25
+void qdict_extract_subqdict(QDict *src, QDict **dst, const char *start);
26ba25
+void qdict_array_split(QDict *src, QList **dst);
26ba25
+int qdict_array_entries(QDict *src, const char *subqdict);
26ba25
+QObject *qdict_crumple(const QDict *src, Error **errp);
26ba25
+void qdict_flatten(QDict *qdict);
26ba25
+
26ba25
+typedef struct QDictRenames {
26ba25
+    const char *from;
26ba25
+    const char *to;
26ba25
+} QDictRenames;
26ba25
+bool qdict_rename_keys(QDict *qdict, const QDictRenames *renames, Error **errp);
26ba25
+
26ba25
+#endif
26ba25
diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h
26ba25
index 921a28d..7f3ec10 100644
26ba25
--- a/include/qapi/qmp/qdict.h
26ba25
+++ b/include/qapi/qmp/qdict.h
26ba25
@@ -67,23 +67,6 @@ int64_t qdict_get_try_int(const QDict *qdict, const char *key,
26ba25
 bool qdict_get_try_bool(const QDict *qdict, const char *key, bool def_value);
26ba25
 const char *qdict_get_try_str(const QDict *qdict, const char *key);
26ba25
 
26ba25
-void qdict_copy_default(QDict *dst, QDict *src, const char *key);
26ba25
-void qdict_set_default_str(QDict *dst, const char *key, const char *val);
26ba25
-
26ba25
 QDict *qdict_clone_shallow(const QDict *src);
26ba25
-void qdict_flatten(QDict *qdict);
26ba25
-
26ba25
-void qdict_extract_subqdict(QDict *src, QDict **dst, const char *start);
26ba25
-void qdict_array_split(QDict *src, QList **dst);
26ba25
-int qdict_array_entries(QDict *src, const char *subqdict);
26ba25
-QObject *qdict_crumple(const QDict *src, Error **errp);
26ba25
-
26ba25
-void qdict_join(QDict *dest, QDict *src, bool overwrite);
26ba25
-
26ba25
-typedef struct QDictRenames {
26ba25
-    const char *from;
26ba25
-    const char *to;
26ba25
-} QDictRenames;
26ba25
-bool qdict_rename_keys(QDict *qdict, const QDictRenames *renames, Error **errp);
26ba25
 
26ba25
 #endif /* QDICT_H */
26ba25
diff --git a/qobject/qdict.c b/qobject/qdict.c
26ba25
index 22800ee..0554c64 100644
26ba25
--- a/qobject/qdict.c
26ba25
+++ b/qobject/qdict.c
26ba25
@@ -11,6 +11,7 @@
26ba25
  */
26ba25
 
26ba25
 #include "qemu/osdep.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "qapi/qmp/qnum.h"
26ba25
 #include "qapi/qmp/qdict.h"
26ba25
 #include "qapi/qmp/qbool.h"
26ba25
diff --git a/tests/check-qdict.c b/tests/check-qdict.c
26ba25
index eba5d35..93e2112 100644
26ba25
--- a/tests/check-qdict.c
26ba25
+++ b/tests/check-qdict.c
26ba25
@@ -11,6 +11,7 @@
26ba25
  */
26ba25
 
26ba25
 #include "qemu/osdep.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "qapi/qmp/qdict.h"
26ba25
 #include "qapi/qmp/qlist.h"
26ba25
 #include "qapi/qmp/qnum.h"
26ba25
diff --git a/tests/check-qobject.c b/tests/check-qobject.c
26ba25
index 5cb08fc..16ccbde 100644
26ba25
--- a/tests/check-qobject.c
26ba25
+++ b/tests/check-qobject.c
26ba25
@@ -8,6 +8,7 @@
26ba25
  */
26ba25
 
26ba25
 #include "qemu/osdep.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "qapi/qmp/qbool.h"
26ba25
 #include "qapi/qmp/qdict.h"
26ba25
 #include "qapi/qmp/qlist.h"
26ba25
diff --git a/tests/test-replication.c b/tests/test-replication.c
26ba25
index 68c0d04..c8165ae 100644
26ba25
--- a/tests/test-replication.c
26ba25
+++ b/tests/test-replication.c
26ba25
@@ -15,6 +15,7 @@
26ba25
 #include "qemu/option.h"
26ba25
 #include "replication.h"
26ba25
 #include "block/block_int.h"
26ba25
+#include "block/qdict.h"
26ba25
 #include "sysemu/block-backend.h"
26ba25
 
26ba25
 #define IMG_SIZE (64 * 1024 * 1024)
26ba25
diff --git a/util/qemu-config.c b/util/qemu-config.c
26ba25
index 14d8402..9d2e278 100644
26ba25
--- a/util/qemu-config.c
26ba25
+++ b/util/qemu-config.c
26ba25
@@ -1,4 +1,5 @@
26ba25
 #include "qemu/osdep.h"
26ba25
+#include "block/qdict.h" /* for qdict_extract_subqdict() */
26ba25
 #include "qapi/error.h"
26ba25
 #include "qapi/qapi-commands-misc.h"
26ba25
 #include "qapi/qmp/qdict.h"
26ba25
-- 
26ba25
1.8.3.1
26ba25