From patchwork Thu Jul 1 19:21:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 57576 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 55082B70BE for ; Fri, 2 Jul 2010 05:31:08 +1000 (EST) Received: from localhost ([127.0.0.1]:49260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OUPTV-0002Wy-Eu for incoming@patchwork.ozlabs.org; Thu, 01 Jul 2010 15:31:05 -0400 Received: from [140.186.70.92] (port=37635 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OUPL5-0006Tu-AG for qemu-devel@nongnu.org; Thu, 01 Jul 2010 15:22:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OUPKw-0007Jq-Cs for qemu-devel@nongnu.org; Thu, 01 Jul 2010 15:22:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4764) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OUPKw-0007Jc-68 for qemu-devel@nongnu.org; Thu, 01 Jul 2010 15:22:14 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o61JMB7t027231 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 1 Jul 2010 15:22:11 -0400 Received: from localhost (vpn-10-238.rdu.redhat.com [10.11.10.238]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o61JM9IA013671; Thu, 1 Jul 2010 15:22:10 -0400 From: Luiz Capitulino To: aliguori@us.ibm.com Date: Thu, 1 Jul 2010 16:21:34 -0300 Message-Id: <1278012111-26227-7-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1278012111-26227-1-git-send-email-lcapitulino@redhat.com> References: <1278012111-26227-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: qemu-devel@nongnu.org, Yoshiaki Tamura Subject: [Qemu-devel] [PATCH 06/23] net: delete QemuOpts when net_client_init() fails. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Yoshiaki Tamura This fixes the following scenario using QMP. First, put a bogus argument "foo" to "type", which results in an error. {"execute": "netdev_add", "arguments": { "type": "foo", "id": "netdev1" } } Then, call it again with correct argument "user". {"execute": "netdev_add", "arguments": { "type": "user", "id": "netdev1" } } This results in "DuplicatedId" error. Because the first command was invalid, it should be able to reuse the same "id", and the second command should work. Reported-by: Luiz Capitulino Signed-off-by: Yoshiaki Tamura Signed-off-by: Luiz Capitulino --- net.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/net.c b/net.c index 90bd5a9..8ddf872 100644 --- a/net.c +++ b/net.c @@ -1208,6 +1208,10 @@ int do_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret_data) } res = net_client_init(mon, opts, 1); + if (res < 0) { + qemu_opts_del(opts); + } + return res; }