From 1201a6e29a7f8359588a3b635acbe12697325e66 Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Mon, 9 Sep 2013 14:28:18 +0200
Subject: [PATCH 27/38] QemuOpts: Add qemu_opt_unset()
RH-Author: Kevin Wolf <kwolf@redhat.com>
Message-id: <1378736903-18489-28-git-send-email-kwolf@redhat.com>
Patchwork-id: 54214
O-Subject: [RHEL-7.0 qemu-kvm PATCH 27/32] QemuOpts: Add qemu_opt_unset()
Bugzilla: 1005818
RH-Acked-by: Fam Zheng <famz@redhat.com>
RH-Acked-by: Max Reitz <mreitz@redhat.com>
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
Bugzilla: 1005818
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 0dd6c5266313c861cf36476da86599d368ec41fc)
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
include/qemu/option.h | 1 +
util/qemu-option.c | 14 ++++++++++++++
2 files changed, 15 insertions(+)
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
include/qemu/option.h | 1 +
util/qemu-option.c | 14 ++++++++++++++
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/include/qemu/option.h b/include/qemu/option.h
index bdb6d21..9db74fb 100644
--- a/include/qemu/option.h
+++ b/include/qemu/option.h
@@ -122,6 +122,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 bdfbdb4..37e7640 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -623,6 +623,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)
{
--
1.7.1