cryptospore / rpms / qemu-kvm

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