From patchwork Tue Feb 3 19:29:43 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 5289 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n13JWaCP031927 for ; Tue, 3 Feb 2009 19:32:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752269AbZBCTce (ORCPT ); Tue, 3 Feb 2009 14:32:34 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752326AbZBCTce (ORCPT ); Tue, 3 Feb 2009 14:32:34 -0500 Received: from g4t0015.houston.hp.com ([15.201.24.18]:36941 "EHLO g4t0015.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752254AbZBCTcd (ORCPT ); Tue, 3 Feb 2009 14:32:33 -0500 Received: from g5t0030.atlanta.hp.com (g5t0030.atlanta.hp.com [16.228.8.142]) by g4t0015.houston.hp.com (Postfix) with ESMTP id 4C61D809D; Tue, 3 Feb 2009 19:32:33 +0000 (UTC) Received: from ldl.fc.hp.com (ldl.fc.hp.com [15.11.146.30]) by g5t0030.atlanta.hp.com (Postfix) with ESMTP id 001C824036; Tue, 3 Feb 2009 19:32:32 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl.fc.hp.com (Postfix) with ESMTP id 7F2D539C043; Tue, 3 Feb 2009 12:32:32 -0700 (MST) X-Virus-Scanned: Debian amavisd-new at ldl.fc.hp.com Received: from ldl.fc.hp.com ([127.0.0.1]) by localhost (ldl.fc.hp.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LgGC5V57qOSo; Tue, 3 Feb 2009 12:32:31 -0700 (MST) Received: from kvm.aw (lart.fc.hp.com [15.11.146.31]) by ldl.fc.hp.com (Postfix) with ESMTP id 9F97B39C00D; Tue, 3 Feb 2009 12:32:31 -0700 (MST) From: Alex Williamson Subject: [PATCH v2 2/8] qemu:virtio-net: Allow setting the MAC address via set_config To: anthony@codemonkey.ws, qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, markmc@redhat.com Date: Tue, 03 Feb 2009 12:29:43 -0700 Message-ID: <20090203192943.19598.77587.stgit@kvm.aw> In-Reply-To: <20090203192932.19598.50925.stgit@kvm.aw> References: <20090203192932.19598.50925.stgit@kvm.aw> User-Agent: StGIT/0.14.2 MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Allow the guest to write to the MAC address config space and update the network info string when it does. Rename get_config for symmetry. Signed-off-by: Alex Williamson Acked-by: Mark McLoughlin --- hw/virtio-net.c | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-) -- 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 2eb52b8..105daa9 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -40,7 +40,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; @@ -50,6 +50,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); + } +} + static void virtio_net_set_link_status(VLANClientState *vc) { VirtIONet *n = vc->opaque; @@ -337,7 +350,8 @@ void virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn) if (!n) return; - n->vdev.get_config = virtio_net_update_config; + n->vdev.get_config = virtio_net_get_config; + n->vdev.set_config = virtio_net_set_config; n->vdev.get_features = virtio_net_get_features; n->vdev.set_features = virtio_net_set_features; n->rx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_rx);