From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=47171 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OMI7h-0001vG-4M for qemu-devel@nongnu.org; Wed, 09 Jun 2010 06:03:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OMI7f-0004Xg-KE for qemu-devel@nongnu.org; Wed, 09 Jun 2010 06:03:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50246) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OMI7f-0004VD-Bc for qemu-devel@nongnu.org; Wed, 09 Jun 2010 06:02:59 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o59A2wRw004876 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 9 Jun 2010 06:02:58 -0400 Date: Wed, 9 Jun 2010 12:58:20 +0300 From: "Michael S. Tsirkin" Message-ID: <20100609095820.GA5885@redhat.com> References: <356ef9bdde008d695e7c75dd1566222d6160d4b6.1276011638.git.amit.shah@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <356ef9bdde008d695e7c75dd1566222d6160d4b6.1276011638.git.amit.shah@redhat.com> Subject: [Qemu-devel] Re: [PATCH v2] net: Fix hotplug with pci_add List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amit Shah Cc: Markus Armbruster , Gerd Hoffmann , qemu list , Juan Quintela On Tue, Jun 08, 2010 at 09:13:58PM +0530, Amit Shah wrote: > The correct model type wasn't getting added when hotplugging nics with > pci_add. > > Testcase: start VM with default nic type. In the qemu_monitor: > > (qemu) pci_add auto nic model=virtio > > This results in a nic hot-plug of the same nic type as the default. > > This was broken in 5294e2c774f120e10b44652ac143abda356f44eb > > Also changes the behaviour where no .init is defined for a > net_client_type. Previously, 0 was returned, which indicated the init > was successful and that 0 was the index into the nd_tables[] array. > Return -1, indicating unsuccessful init, in such a case. > > Signed-off-by: Amit Shah Acked-by: Michael S. Tsirkin I'll pick this up if no one beats me to it. > --- > Sorry, v1 was a stale patch. > > v2: > - Init 'ret' to -1, fixes compile err and added note in the commit msg > explaining this. > > net.c | 7 +++++-- > 1 files changed, 5 insertions(+), 2 deletions(-) > > diff --git a/net.c b/net.c > index efa8b3d..4cb93ed 100644 > --- a/net.c > +++ b/net.c > @@ -1106,6 +1106,7 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev) > for (i = 0; net_client_types[i].type != NULL; i++) { > if (!strcmp(net_client_types[i].type, type)) { > VLANState *vlan = NULL; > + int ret; > > if (qemu_opts_validate(opts, &net_client_types[i].desc[0]) == -1) { > return -1; > @@ -1118,14 +1119,16 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev) > vlan = qemu_find_vlan(qemu_opt_get_number(opts, "vlan", 0), 1); > } > > + ret = -1; > if (net_client_types[i].init) { > - if (net_client_types[i].init(opts, mon, name, vlan) < 0) { > + ret = net_client_types[i].init(opts, mon, name, vlan); > + if (ret < 0) { > /* TODO push error reporting into init() methods */ > qerror_report(QERR_DEVICE_INIT_FAILED, type); > return -1; > } > } > - return 0; > + return ret; > } > } > > -- > 1.7.0.1 >