From patchwork Wed Sep 23 14:27:35 2015 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: 521717 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 099B014012C for ; Thu, 24 Sep 2015 00:29:44 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=eZI9ssux; dkim-atps=neutral Received: from localhost ([::1]:48162 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zel3G-0006rm-1d for incoming@patchwork.ozlabs.org; Wed, 23 Sep 2015 10:29:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zel0a-00027a-IS for qemu-devel@nongnu.org; Wed, 23 Sep 2015 10:26:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zel0X-0005ue-Db for qemu-devel@nongnu.org; Wed, 23 Sep 2015 10:26:56 -0400 Received: from mail-wi0-x22b.google.com ([2a00:1450:400c:c05::22b]:34297) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zel0X-0005uF-3Z for qemu-devel@nongnu.org; Wed, 23 Sep 2015 10:26:53 -0400 Received: by wicfx3 with SMTP id fx3so241181069wic.1 for ; Wed, 23 Sep 2015 07:26:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=MgjwOKbN7tJ+PP+m23bYpU34hwgRApg7C6C65+jNEYQ=; b=eZI9ssuxk/luDPIP72aJJAHnc7mW4o56nDucs48RxPiT1+853wF2mfKQCLF3tdclTH KB71rWSH5DRtJM5Bh3fsA5/ogm65PLR+PQlzC4rCR11cqUifTphABtw6ZN6BpZzosY0D 5uheJLib9b1PfKqzZPMJ9+dOR3fCsgmqp9iu9hUxYdnq5U1fBFIhDkXflHGOxOdDJzKP bfCqUpFjZ4ec6vDhTmwar1pyHym5f+idjhsAp8QRsfGVy+Irx7mqOpm2fBwHEFONE3Ty G+D4oX14fcFzBdNDK64Ds9aVWCYial6IpFDA48f5+hycJeLtjBeZBnIcTQYtEpRyR27W YaIA== X-Received: by 10.180.8.232 with SMTP id u8mr1292622wia.26.1443018412524; Wed, 23 Sep 2015 07:26:52 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (94-21-30-197.pool.digikabel.hu. [94.21.30.197]) by smtp.gmail.com with ESMTPSA id fv13sm662088wic.7.2015.09.23.07.26.51 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 23 Sep 2015 07:26:52 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Wed, 23 Sep 2015 16:27:35 +0200 Message-Id: <067336e7b88509a56d5c681ce73eb1d6d8696e6e.1443017811.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.5.2 In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22b Cc: Jason Wang , Markus Armbruster Subject: [Qemu-devel] [PATCH v2 2/3] qapi: change NetLegacy into a flat union 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 This is required to keep backward compatibility while applying the proposed changes to OptsVisitor in the next commit. Strictly speaking this change breaks QMP compatibility, but since this struct is only used by the (legacy) -net option, it's not a problem. (The command line syntax doesn't change.) Signed-off-by: Kővágó, Zoltán --- net/net.c | 47 +++++++++++++++++++++++------------------------ qapi-schema.json | 29 +++++++++++++++++++++-------- 2 files changed, 44 insertions(+), 32 deletions(-) diff --git a/net/net.c b/net/net.c index 69456b2..8ae1cd8 100644 --- a/net/net.c +++ b/net/net.c @@ -931,55 +931,54 @@ static int net_client_init1(const void *object, bool is_netdev, Error **errp) } } else { const NetLegacy *net = object; - const NetClientOptions *opts = net->opts; legacy.id = net->id; netdev = &legacy; /* missing optional values have been initialized to "all bits zero" */ name = net->has_id ? net->id : net->name; /* Map the old options to the new flat type */ - switch (opts->type) { - case NET_CLIENT_OPTIONS_KIND_NONE: + switch (net->type) { + case NET_CLIENT_DRIVER_LEGACY_NONE: return 0; /* nothing to do */ - case NET_CLIENT_OPTIONS_KIND_NIC: + case NET_CLIENT_DRIVER_LEGACY_NIC: legacy.type = NET_CLIENT_DRIVER_NIC; - legacy.nic = opts->nic; + legacy.nic = net->nic; break; - case NET_CLIENT_OPTIONS_KIND_USER: + case NET_CLIENT_DRIVER_LEGACY_USER: legacy.type = NET_CLIENT_DRIVER_USER; - legacy.user = opts->user; + legacy.user = net->user; break; - case NET_CLIENT_OPTIONS_KIND_TAP: + case NET_CLIENT_DRIVER_LEGACY_TAP: legacy.type = NET_CLIENT_DRIVER_TAP; - legacy.tap = opts->tap; + legacy.tap = net->tap; break; - case NET_CLIENT_OPTIONS_KIND_L2TPV3: + case NET_CLIENT_DRIVER_LEGACY_L2TPV3: legacy.type = NET_CLIENT_DRIVER_L2TPV3; - legacy.l2tpv3 = opts->l2tpv3; + legacy.l2tpv3 = net->l2tpv3; break; - case NET_CLIENT_OPTIONS_KIND_SOCKET: + case NET_CLIENT_DRIVER_LEGACY_SOCKET: legacy.type = NET_CLIENT_DRIVER_SOCKET; - legacy.socket = opts->socket; + legacy.socket = net->socket; break; - case NET_CLIENT_OPTIONS_KIND_VDE: + case NET_CLIENT_DRIVER_LEGACY_VDE: legacy.type = NET_CLIENT_DRIVER_VDE; - legacy.vde = opts->vde; + legacy.vde = net->vde; break; - case NET_CLIENT_OPTIONS_KIND_DUMP: + case NET_CLIENT_DRIVER_LEGACY_DUMP: legacy.type = NET_CLIENT_DRIVER_DUMP; - legacy.dump = opts->dump; + legacy.dump = net->dump; break; - case NET_CLIENT_OPTIONS_KIND_BRIDGE: + case NET_CLIENT_DRIVER_LEGACY_BRIDGE: legacy.type = NET_CLIENT_DRIVER_BRIDGE; - legacy.bridge = opts->bridge; + legacy.bridge = net->bridge; break; - case NET_CLIENT_OPTIONS_KIND_NETMAP: + case NET_CLIENT_DRIVER_LEGACY_NETMAP: legacy.type = NET_CLIENT_DRIVER_NETMAP; - legacy.netmap = opts->netmap; + legacy.netmap = net->netmap; break; - case NET_CLIENT_OPTIONS_KIND_VHOST_USER: + case NET_CLIENT_DRIVER_LEGACY_VHOST_USER: legacy.type = NET_CLIENT_DRIVER_VHOST_USER; - legacy.vhost_user = opts->vhost_user; + legacy.vhost_user = net->vhost_user; break; default: abort(); @@ -994,7 +993,7 @@ static int net_client_init1(const void *object, bool is_netdev, Error **errp) /* Do not add to a vlan if it's a nic with a netdev= parameter. */ if (netdev->type != NET_CLIENT_DRIVER_NIC || - !opts->nic->has_netdev) { + !net->nic->has_netdev) { peer = net_hub_add_port(net->has_vlan ? net->vlan : 0, NULL); } } diff --git a/qapi-schema.json b/qapi-schema.json index 72827f8..4f9946e 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -2531,9 +2531,9 @@ 'vhost-user': 'NetdevVhostUserOptions' } } ## -# @NetLegacy +# @NetLegacyBase # -# Captures the configuration of a network device; legacy. +# Captures the common configuration of a network device, legacy. # # @vlan: #optional vlan number # @@ -2541,25 +2541,38 @@ # # @name: #optional identifier for monitor commands, ignored if @id is present # -# @opts: device type specific properties (legacy) +# @type: specify the driver used for interpreting remaining arguments. # # Since 1.2 ## -{ 'struct': 'NetLegacy', +{ 'struct': 'NetLegacyBase', 'data': { '*vlan': 'int32', '*id': 'str', '*name': 'str', - 'opts': 'NetClientOptions' } } + 'type': 'NetClientDriverLegacy' } } ## -# @NetClientOptions +# @NetClientDriverLegacy # -# Like Netdev, but for use only by the legacy command line options +# Available netdev drivers, legacy. +# +# Since 2.5 +## +{'enum': 'NetClientDriverLegacy', + 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', 'dump', + 'bridge', 'netmap', 'vhost-user' ] } + +## +# @NetLegacy +# +# Captures the configuration of a network device; legacy. # # Since 1.2 ## -{ 'union': 'NetClientOptions', +{ 'union': 'NetLegacy', + 'base': 'NetLegacyBase', + 'discriminator': 'type', 'data': { 'none': 'NetdevNoneOptions', 'nic': 'NetLegacyNicOptions',