From patchwork Thu Jan 17 06:34:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Kong X-Patchwork-Id: 1995251 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id A4BD8DF2E1 for ; Thu, 17 Jan 2013 06:34:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759144Ab3AQGeP (ORCPT ); Thu, 17 Jan 2013 01:34:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36330 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752604Ab3AQGeO (ORCPT ); Thu, 17 Jan 2013 01:34:14 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0H6Y9Cv028387 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 17 Jan 2013 01:34:09 -0500 Received: from localhost (vpn1-114-52.nay.redhat.com [10.66.114.52]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r0H6Y6fM028951; Thu, 17 Jan 2013 01:34:08 -0500 Date: Thu, 17 Jan 2013 14:34:17 +0800 From: Amos Kong To: "Michael S. Tsirkin" Cc: Stefan Hajnoczi , virtualization@lists.linux-foundation.org, rusty@rustcorp.com.au, kvm@vger.kernel.org Subject: Re: [PATCH] virtio-spec: set mac address by a new vq command Message-ID: <20130117063417.GB12468@t430s.redhat.com> References: <1358321604-11712-1-git-send-email-akong@redhat.com> <20130116091328.GA6931@stefanha-thinkpad.redhat.com> <20130116092223.GC12723@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20130116092223.GC12723@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Wed, Jan 16, 2013 at 11:22:23AM +0200, Michael S. Tsirkin wrote: > On Wed, Jan 16, 2013 at 10:13:28AM +0100, Stefan Hajnoczi wrote: > > On Wed, Jan 16, 2013 at 03:33:24PM +0800, akong@redhat.com wrote: > > > +\change_inserted -1930653948 1358320004 > > > +The command VIRTIO_NET_CTRL_MAC_ADDR_SET is used to set > > > +\begin_inset Quotes eld > > > +\end_inset > > > + > > > +physical > > > +\begin_inset Quotes erd > > > +\end_inset > > > + > > > + address of the network card. > > > > The "physical" address of the network card? That term is not defined > > anywhere in the specification. I will replace it with 'the default MAC address' > > Perhaps it's best to explain that the config space "mac" field and > > VIRTIO_NET_CTRL_MAC_ADDR_SET both set the default MAC address which rx > > filtering accepts. (The MAC table is an additional set of MAC addresses > > which rx filtering accepts.) > > > > It would also be worth explaining that VIRTIO_NET_CTRL_MAC_ADDR_SET is > > atomic whereas the config space "mac" field is not. Therefore, > > VIRTIO_NET_CTRL_MAC_ADDR_SET is preferred, especially while the NIC is > > up. Ok, will send a v2, thanks. > > Stefan > It's probably best to simply make the config space field > read-only if the feature bit is acked. It's reasonable. } --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/hw/virtio-net.c b/hw/virtio-net.c index c18e276..54c5eae 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -93,7 +93,8 @@ static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config) memcpy(&netcfg, config, sizeof(netcfg)); - if (memcmp(netcfg.mac, n->mac, ETH_ALEN)) { + if (!(n->vdev.guest_features >> VIRTIO_NET_F_CTRL_MAC_ADDR & 1) && + memcmp(netcfg.mac, n->mac, ETH_ALEN)) { memcpy(n->mac, netcfg.mac, ETH_ALEN); qemu_format_nic_info_str(&n->nic->nc, n->mac);