From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dor Laor Subject: Re: [PATCH 1/5] virtio-net: Allow setting the MAC address via set_config Date: Wed, 14 Jan 2009 12:05:05 +0200 Message-ID: <496DB8D1.2070101@redhat.com> References: <1231881829.9095.191.camel@bling> Reply-To: dlaor@redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm , qemu-devel , Mark McLoughlin To: Alex Williamson Return-path: Received: from mx2.redhat.com ([66.187.237.31]:35837 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754637AbZANKEu (ORCPT ); Wed, 14 Jan 2009 05:04:50 -0500 In-Reply-To: <1231881829.9095.191.camel@bling> Sender: kvm-owner@vger.kernel.org List-ID: Alex Williamson wrote: > Rename get_config for simplicity > > Signed-off-by: Alex Williamson > --- > > qemu/hw/virtio-net.c | 18 ++++++++++++++++-- > 1 files changed, 16 insertions(+), 2 deletions(-) > > diff --git a/qemu/hw/virtio-net.c b/qemu/hw/virtio-net.c > index 1f9dc16..e9b3d46 100644 > --- a/qemu/hw/virtio-net.c > +++ b/qemu/hw/virtio-net.c > @@ -42,7 +42,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) > { > VirtIONet *n = to_virtio_net(vdev); > struct virtio_net_config netcfg; > @@ -51,6 +51,19 @@ 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); > + qemu_format_nic_info_str(n->vc, n->mac); > + } > +} > + > What if the guest will chose the host's mac? Thinking about it, I don't think we should test that. A concerned host mgmt app can add ebtables roles for such a case. Maybe we can optionally allow/deny it?