Patchwork [12/18] QemuOpts: Add qemu_opt_unset()

login
register
mail settings
Submitter Kevin Wolf
Date July 23, 2013, 1:03 p.m.
Message ID <1374584606-5615-13-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/261091/
State New
Headers show

Comments

Kevin Wolf - July 23, 2013, 1:03 p.m.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 include/qemu/option.h |  1 +
 util/qemu-option.c    | 14 ++++++++++++++
 2 files changed, 15 insertions(+)
Eric Blake - July 26, 2013, 4:04 p.m.
On 07/23/2013 07:03 AM, Kevin Wolf wrote:
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  include/qemu/option.h |  1 +
>  util/qemu-option.c    | 14 ++++++++++++++
>  2 files changed, 15 insertions(+)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

Patch

diff --git a/include/qemu/option.h b/include/qemu/option.h
index a83c700..13f5e72 100644
--- a/include/qemu/option.h
+++ b/include/qemu/option.h
@@ -120,6 +120,7 @@  bool qemu_opt_has_help_opt(QemuOpts *opts);
 bool qemu_opt_get_bool(QemuOpts *opts, const char *name, bool defval);
 uint64_t qemu_opt_get_number(QemuOpts *opts, const char *name, uint64_t defval);
 uint64_t qemu_opt_get_size(QemuOpts *opts, const char *name, uint64_t defval);
+int qemu_opt_unset(QemuOpts *opts, const char *name);
 int qemu_opt_set(QemuOpts *opts, const char *name, const char *value);
 void qemu_opt_set_err(QemuOpts *opts, const char *name, const char *value,
                       Error **errp);
diff --git a/util/qemu-option.c b/util/qemu-option.c
index e0ef426..5d686c8 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -593,6 +593,20 @@  static const QemuOptDesc *find_desc_by_name(const QemuOptDesc *desc,
     return NULL;
 }
 
+int qemu_opt_unset(QemuOpts *opts, const char *name)
+{
+    QemuOpt *opt = qemu_opt_find(opts, name);
+
+    assert(opts_accepts_any(opts));
+
+    if (opt == NULL) {
+        return -1;
+    } else {
+        qemu_opt_del(opt);
+        return 0;
+    }
+}
+
 static void opt_set(QemuOpts *opts, const char *name, const char *value,
                     bool prepend, Error **errp)
 {