[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH COLO-BLOCK v7 04/17] introduce a new API qemu_opts_a
From: |
Wen Congyang |
Subject: |
[Qemu-devel] [PATCH COLO-BLOCK v7 04/17] introduce a new API qemu_opts_absorb_qdict_by_index() |
Date: |
Tue, 30 Jun 2015 11:34:32 +0800 |
Signed-off-by: Wen Congyang <address@hidden>
Signed-off-by: zhanghailiang <address@hidden>
Signed-off-by: Gonglei <address@hidden>
---
include/qemu/option.h | 2 ++
util/qemu-option.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+)
diff --git a/include/qemu/option.h b/include/qemu/option.h
index 57e51c9..725a781 100644
--- a/include/qemu/option.h
+++ b/include/qemu/option.h
@@ -129,6 +129,8 @@ QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const
QDict *qdict,
Error **errp);
QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict);
void qemu_opts_absorb_qdict(QemuOpts *opts, QDict *qdict, Error **errp);
+void qemu_opts_absorb_qdict_by_index(QemuOpts *opts, QDict *qdict,
+ const char *index, Error **errp);
typedef int (*qemu_opts_loopfunc)(void *opaque, QemuOpts *opts, Error **errp);
int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func,
diff --git a/util/qemu-option.c b/util/qemu-option.c
index efe9d27..a93a269 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -1021,6 +1021,50 @@ void qemu_opts_absorb_qdict(QemuOpts *opts, QDict
*qdict, Error **errp)
}
/*
+ * Adds all QDict entries to the QemuOpts that can be added and removes them
+ * from the QDict. The key starts with "%index." in the %qdict. When this
+ * function returns, the QDict contains only those entries that couldn't be
+ * added to the QemuOpts.
+ */
+void qemu_opts_absorb_qdict_by_index(QemuOpts *opts, QDict *qdict,
+ const char *index, Error **errp)
+{
+ const QDictEntry *entry, *next;
+ const char *key;
+ int len = strlen(index);
+
+ entry = qdict_first(qdict);
+
+ while (entry != NULL) {
+ Error *local_err = NULL;
+ OptsFromQDictState state = {
+ .errp = &local_err,
+ .opts = opts,
+ };
+
+ next = qdict_next(qdict, entry);
+ if (strncmp(entry->key, index, len) || *(entry->key + len) != '.') {
+ entry = next;
+ continue;
+ }
+
+ key = entry->key + len + 1;
+
+ if (find_desc_by_name(opts->list->desc, key)) {
+ qemu_opts_from_qdict_1(key, entry->value, &state);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ } else {
+ qdict_del(qdict, entry->key);
+ }
+ }
+
+ entry = next;
+ }
+}
+
+/*
* Convert from QemuOpts to QDict.
* The QDict values are of type QString.
* TODO We'll want to use types appropriate for opt->desc->type, but
--
2.4.3
- [Qemu-devel] [PATCH COLO-BLOCK v7 00/17] Block replication for continuous checkpoints, Wen Congyang, 2015/06/29
- [Qemu-devel] [PATCH COLO-BLOCK v7 01/17] Add new block driver interface to add/delete a BDS's child, Wen Congyang, 2015/06/29
- [Qemu-devel] [PATCH COLO-BLOCK v7 04/17] introduce a new API qemu_opts_absorb_qdict_by_index(),
Wen Congyang <=
- [Qemu-devel] [PATCH COLO-BLOCK v7 03/17] hmp: add monitor command to add/remove a child, Wen Congyang, 2015/06/29
- [Qemu-devel] [PATCH COLO-BLOCK v7 05/17] quorum: allow ignoring child errors, Wen Congyang, 2015/06/29
- [Qemu-devel] [PATCH COLO-BLOCK v7 06/17] introduce a new API to enable/disable attach device model, Wen Congyang, 2015/06/29
- [Qemu-devel] [PATCH COLO-BLOCK v7 08/17] block: make bdrv_put_ref_bh_schedule() as a public API, Wen Congyang, 2015/06/29
- [Qemu-devel] [PATCH COLO-BLOCK v7 07/17] introduce a new API to check if blk is attached, Wen Congyang, 2015/06/29
- [Qemu-devel] [PATCH COLO-BLOCK v7 09/17] Backup: clear all bitmap when doing block checkpoint, Wen Congyang, 2015/06/29
- [Qemu-devel] [PATCH COLO-BLOCK v7 11/17] Allow creating backup jobs when opening BDS, Wen Congyang, 2015/06/29
- [Qemu-devel] [PATCH COLO-BLOCK v7 10/17] allow writing to the backing file, Wen Congyang, 2015/06/29
- [Qemu-devel] [PATCH COLO-BLOCK v7 12/17] block: Allow references for backing files, Wen Congyang, 2015/06/29
- [Qemu-devel] [PATCH COLO-BLOCK v7 13/17] docs: block replication's description, Wen Congyang, 2015/06/29