From patchwork Mon Mar 8 16:54:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 1449255 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Nh/kx5hk; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DvQDV5brXz9sW1 for ; Tue, 9 Mar 2021 04:23:54 +1100 (AEDT) Received: from localhost ([::1]:40358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJJbk-0002Gw-Qm for incoming@patchwork.ozlabs.org; Mon, 08 Mar 2021 12:23:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJJCg-0005ao-OO for qemu-devel@nongnu.org; Mon, 08 Mar 2021 11:58:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52429) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lJJCd-0000S6-6f for qemu-devel@nongnu.org; Mon, 08 Mar 2021 11:57:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615222671; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7uzptcsSpRnK2BA5t93RO71hnGZLwADp8OucKjUMVE0=; b=Nh/kx5hkI8V/iHK6e27QQviYQlauVgWC6f1xxb5ROsUjS5+6MdCwkVQQruNY44MZD2m8D3 e4Ahc4ib4oj/T1TX0YIW0a2rnbgKNS2zijN78b5p5EdtbSbJtHjnuAMp0QkDU/5P+/IKxh QxmhMA9XZMkDO7w6rWf0ShZxoSMTKx4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-469-7qHMRXxuNIahv6BzIWjLKw-1; Mon, 08 Mar 2021 11:57:14 -0500 X-MC-Unique: 7qHMRXxuNIahv6BzIWjLKw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B94481054FA2; Mon, 8 Mar 2021 16:57:13 +0000 (UTC) Received: from merkur.fritz.box (ovpn-112-100.ams2.redhat.com [10.36.112.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D05CE5D9DB; Mon, 8 Mar 2021 16:57:09 +0000 (UTC) From: Kevin Wolf To: qemu-devel@nongnu.org Subject: [PATCH v3 24/30] qemu-nbd: Use user_creatable_process_cmdline() for --object Date: Mon, 8 Mar 2021 17:54:34 +0100 Message-Id: <20210308165440.386489-25-kwolf@redhat.com> In-Reply-To: <20210308165440.386489-1-kwolf@redhat.com> References: <20210308165440.386489-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.251, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, lvivier@redhat.com, thuth@redhat.com, pkrempa@redhat.com, berrange@redhat.com, ehabkost@redhat.com, qemu-block@nongnu.org, libvir-list@redhat.com, jasowang@redhat.com, armbru@redhat.com, mreitz@redhat.com, kraxel@redhat.com, pbonzini@redhat.com, dgilbert@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This switches qemu-nbd from a QemuOpts-based parser for --object to user_creatable_process_cmdline() which uses a keyval parser and enforces the QAPI schema. Apart from being a cleanup, this makes non-scalar properties accessible. Signed-off-by: Kevin Wolf Acked-by: Peter Krempa Reviewed-by: Eric Blake --- qemu-nbd.c | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/qemu-nbd.c b/qemu-nbd.c index b1b9430a8f..93ef4e288f 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -401,24 +401,6 @@ static QemuOptsList file_opts = { }, }; -static QemuOptsList qemu_object_opts = { - .name = "object", - .implied_opt_name = "qom-type", - .head = QTAILQ_HEAD_INITIALIZER(qemu_object_opts.head), - .desc = { - { } - }, -}; - -static bool qemu_nbd_object_print_help(const char *type, QemuOpts *opts) -{ - if (user_creatable_print_help(type, opts)) { - exit(0); - } - return true; -} - - static QCryptoTLSCreds *nbd_get_tls_creds(const char *id, bool list, Error **errp) { @@ -594,7 +576,6 @@ int main(int argc, char **argv) qcrypto_init(&error_fatal); module_call_init(MODULE_INIT_QOM); - qemu_add_opts(&qemu_object_opts); qemu_add_opts(&qemu_trace_opts); qemu_init_exec_dir(argv[0]); @@ -747,14 +728,9 @@ int main(int argc, char **argv) case '?': error_report("Try `%s --help' for more information.", argv[0]); exit(EXIT_FAILURE); - case QEMU_NBD_OPT_OBJECT: { - QemuOpts *opts; - opts = qemu_opts_parse_noisily(&qemu_object_opts, - optarg, true); - if (!opts) { - exit(EXIT_FAILURE); - } - } break; + case QEMU_NBD_OPT_OBJECT: + user_creatable_process_cmdline(optarg); + break; case QEMU_NBD_OPT_TLSCREDS: tlscredsid = optarg; break; @@ -802,10 +778,6 @@ int main(int argc, char **argv) export_name = ""; } - qemu_opts_foreach(&qemu_object_opts, - user_creatable_add_opts_foreach, - qemu_nbd_object_print_help, &error_fatal); - if (!trace_init_backends()) { exit(1); }