From patchwork Sun Dec 23 20:51:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?UTF-8?B?Wm9sdMOhbiBLxZF2w6Fnw7M=?= X-Patchwork-Id: 1018135 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=208.118.235.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="uMgx7Iev"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43NFym6V0hz9sDL for ; Mon, 24 Dec 2018 08:35:28 +1100 (AEDT) Received: from localhost ([127.0.0.1]:42139 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gbAkr-0007Nr-0W for incoming@patchwork.ozlabs.org; Sun, 23 Dec 2018 15:53:45 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52014) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gbAjh-0007Jg-Hm for qemu-devel@nongnu.org; Sun, 23 Dec 2018 15:52:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gbAjg-0001PV-Nb for qemu-devel@nongnu.org; Sun, 23 Dec 2018 15:52:33 -0500 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:33256) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gbAjg-0001Jv-Hn for qemu-devel@nongnu.org; Sun, 23 Dec 2018 15:52:32 -0500 Received: by mail-wm1-x341.google.com with SMTP id r24so18059286wmh.0 for ; Sun, 23 Dec 2018 12:52:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vQbAxA17LBqG3YNdc2WxogxuczEivFcvaHHUcCjdIPs=; b=uMgx7IevqX/mnftLxPx5nZy3TYuFe1tMvhF7ro18go8ezDcx6Z0+14PNQOnoDRVCNz LSnwRiBJVKh/Sdzpg+GTzMAryM0uvw1qZFio4HSV+LBu+VxdLVjoQruW0VSUzTl4Vyn5 6yG4NoKORcdRCitrLt8Wcqlxd9CiI0AIYYqvui7qSRk2PIP2/s/Tv+Xc8RG/5FVScQkO r118iz2/ufNOtamXOvrfcYnfkiXZalWHQ17ObBfTEiQHbBPq7EAgn9GcymTYZR0OAMK1 iEKu/C8TGl1ctZ2qRzk4SnGKGwuzwMyZgWV7y+fafS+9Mnsm8vS3UXEI/mAysP3WMLAh uQxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vQbAxA17LBqG3YNdc2WxogxuczEivFcvaHHUcCjdIPs=; b=XnNCRJgf0ICxShjm3B8qr6nTxptHG71qe+HYxZ8PzZAjCV3tbwvTlxYiVr7vuWlojw BD3yOqlSDVrCsQt1OdDyb/06c4wcZQ/MwxVZmYXPoSsNaOqijW3DaYolDVa3bal3+gXS K9iEfUTsfHSqcZxmGRc29U8oW8IYfM/+GafLJMf1f4bzvDkAMNpyGBcd2Oz/n9qU+ehK luHk2rwD/jncna1cSgJXr+W4FeJ7K5pVE2fKYFnmxamqMwtrciDzADQYxxgdYvQ9G4vK Ao7KcEsvonpoKiUFWEbT+v5Y7eD9BgYSdyxcMp2cYH1CPGlyDC4+czcchGkNVOtkv6Su qesg== X-Gm-Message-State: AA+aEWbeOUn7AaBjLdsPlVwoyx+KDm89IMax0BaRtZacFHygX5bkJy79 tOgB4E8KchXQLyHPQEfgqm3Oe/LU X-Google-Smtp-Source: AFSGD/Xtt6FdkCdL3MrgqpAKCMxxrf8QKiXWsZYgbFL3as7QS5x3KdVn4AzB4PzwcJztpZYf9b5YSA== X-Received: by 2002:a1c:864f:: with SMTP id i76mr9909558wmd.83.1545598351091; Sun, 23 Dec 2018 12:52:31 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-24a3-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:24a3::5]) by smtp.gmail.com with ESMTPSA id g198sm25456920wmd.23.2018.12.23.12.52.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Dec 2018 12:52:30 -0800 (PST) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?utf-8?b?S8WRdsOhZ8OzLCBab2x0w6Fu?= To: qemu-devel@nongnu.org Date: Sun, 23 Dec 2018 21:51:37 +0100 Message-Id: <5ffd8b7b6fefbc3c2c4fb074f3083ffbdc946d20.1545598229.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 Subject: [Qemu-devel] [PATCH v2 01/52] qapi: support alternates in OptsVisitor X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , Gerd Hoffmann , Markus Armbruster Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" They are required for flat unions (you still have to allocate the structs). Signed-off-by: Kővágó, Zoltán --- include/qapi/opts-visitor.h | 7 +++---- qapi/opts-visitor.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/include/qapi/opts-visitor.h b/include/qapi/opts-visitor.h index 9b989e7e08..ca044e3b33 100644 --- a/include/qapi/opts-visitor.h +++ b/include/qapi/opts-visitor.h @@ -29,10 +29,9 @@ typedef struct OptsVisitor OptsVisitor; * - values below INT64_MIN or LLONG_MIN are rejected, * - values above INT64_MAX or LLONG_MAX are rejected. * - * The Opts input visitor does not implement support for visiting QAPI - * alternates, numbers (other than integers), null, or arbitrary - * QTypes. It also requires a non-null list argument to - * visit_start_list(). + * The Opts input visitor does not implement support for visiting numbers + * (other than integers), null, or arbitrary QTypes. It also requires a + * non-null list argument to visit_start_list(). */ Visitor *opts_visitor_new(const QemuOpts *opts); diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c index 324b197495..4af6043b75 100644 --- a/qapi/opts-visitor.c +++ b/qapi/opts-visitor.c @@ -156,6 +156,13 @@ opts_start_struct(Visitor *v, const char *name, void **obj, } } +static void +opts_start_alternate(Visitor *v, const char *name, GenericAlternate **obj, + size_t size, Error **errp) +{ + opts_start_struct(v, name, (void **)obj, size, errp); +} + static void opts_check_struct(Visitor *v, Error **errp) @@ -198,6 +205,12 @@ opts_end_struct(Visitor *v, void **obj) ov->fake_id_opt = NULL; } +static void +opts_end_alternate(Visitor *v, void **obj) +{ + opts_end_struct(v, obj); +} + static GQueue * lookup_distinct(const OptsVisitor *ov, const char *name, Error **errp) @@ -547,6 +560,9 @@ opts_visitor_new(const QemuOpts *opts) ov->visitor.check_struct = &opts_check_struct; ov->visitor.end_struct = &opts_end_struct; + ov->visitor.start_alternate = &opts_start_alternate; + ov->visitor.end_alternate = &opts_end_alternate; + ov->visitor.start_list = &opts_start_list; ov->visitor.next_list = &opts_next_list; ov->visitor.check_list = &opts_check_list;