From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LLFgz-0002TX-HK for qemu-devel@nongnu.org; Fri, 09 Jan 2009 06:38:21 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LLFgw-0002So-Lv for qemu-devel@nongnu.org; Fri, 09 Jan 2009 06:38:20 -0500 Received: from [199.232.76.173] (port=42435 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LLFgw-0002Sl-FJ for qemu-devel@nongnu.org; Fri, 09 Jan 2009 06:38:18 -0500 Received: from mx2.redhat.com ([66.187.237.31]:38933) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LLFgt-0002Dl-Og for qemu-devel@nongnu.org; Fri, 09 Jan 2009 06:38:16 -0500 From: Mark McLoughlin In-Reply-To: <1231349856.7109.80.camel@lappy> References: <1231349856.7109.80.camel@lappy> Content-Type: text/plain Date: Fri, 09 Jan 2009 11:38:09 +0000 Message-Id: <1231501089.4481.76.camel@localhost.localdomain> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 1/5][RFC] virtio-net: Allow setting the MAC address via set_config Reply-To: Mark McLoughlin , qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Williamson Cc: qemu-devel , kvm On Wed, 2009-01-07 at 10:37 -0700, Alex Williamson wrote: > virtio-net: Allow setting the MAC address via set_config This will basically never happen with QEMU, right? We always set the MAC address - even if not supplied on the command line - and the guest will never override that. > Rename get_config for simplicity > > Signed-off-by: Alex Williamson > --- > > hw/virtio-net.c | 21 +++++++++++++++++++-- > 1 files changed, 19 insertions(+), 2 deletions(-) > > diff --git a/hw/virtio-net.c b/hw/virtio-net.c > index 2c41b3e..bfb7510 100644 > --- a/hw/virtio-net.c > +++ b/hw/virtio-net.c > @@ -38,7 +38,7 @@ static VirtIONet *to_virtio_net(VirtIODevice *vdev) > return (VirtIONet *)vdev; > } > > -static void virtio_net_update_config(VirtIODevice *vdev, uint8_t > *config) > +static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config) Yay :-) > { > VirtIONet *n = to_virtio_net(vdev); > struct virtio_net_config netcfg; > @@ -48,6 +48,22 @@ static void virtio_net_update_config(VirtIODevice > *vdev, uint8_t *config) > memcpy(config, &netcfg, sizeof(netcfg)); > } > > +static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t > *config) > +{ > + VirtIONet *n = to_virtio_net(vdev); > + struct virtio_net_config netcfg; > + > + memcpy(&netcfg, config, sizeof(netcfg)); > + > + if (memcmp(netcfg.mac, n->mac, 6)) { > + memcpy(n->mac, netcfg.mac, 6); > + snprintf(n->vc->info_str, sizeof(n->vc->info_str), > + "virtio macaddr=%02x:%02x:%02x:%02x:%02x:%02x", > + n->mac[0], n->mac[1], n->mac[2], > + n->mac[3], n->mac[4], n->mac[5]); There's qemu_format_nic_info_str() now. Cheers, Mark.