From patchwork Tue Jul 23 13:03:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 261091 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 759512C00CE for ; Tue, 23 Jul 2013 23:43:46 +1000 (EST) Received: from localhost ([::1]:49599 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1cJo-0005ZE-Lt for incoming@patchwork.ozlabs.org; Tue, 23 Jul 2013 09:07:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54472) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1cFz-0000QR-Vu for qemu-devel@nongnu.org; Tue, 23 Jul 2013 09:04:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1cFy-0007V9-BF for qemu-devel@nongnu.org; Tue, 23 Jul 2013 09:03:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:62631) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1cFy-0007V1-2y for qemu-devel@nongnu.org; Tue, 23 Jul 2013 09:03:58 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r6ND3vds005390 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 23 Jul 2013 09:03:57 -0400 Received: from dhcp-200-207.str.redhat.com (ovpn-116-56.ams2.redhat.com [10.36.116.56]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r6ND3U6K008625; Tue, 23 Jul 2013 09:03:55 -0400 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Tue, 23 Jul 2013 15:03:20 +0200 Message-Id: <1374584606-5615-13-git-send-email-kwolf@redhat.com> In-Reply-To: <1374584606-5615-1-git-send-email-kwolf@redhat.com> References: <1374584606-5615-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, armbru@redhat.com, stefanha@redhat.com, lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH 12/18] QemuOpts: Add qemu_opt_unset() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- include/qemu/option.h | 1 + util/qemu-option.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) 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) {