From patchwork Fri Jan 16 21:09:59 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 2882 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 n0GL7dE2016075 for ; Fri, 16 Jan 2009 13:07:39 -0800 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760855AbZAPVLy (ORCPT ); Fri, 16 Jan 2009 16:11:54 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1761559AbZAPVLy (ORCPT ); Fri, 16 Jan 2009 16:11:54 -0500 Received: from g4t0017.houston.hp.com ([15.201.24.20]:39348 "EHLO g4t0017.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760855AbZAPVLx (ORCPT ); Fri, 16 Jan 2009 16:11:53 -0500 Received: from g1t0039.austin.hp.com (g1t0039.austin.hp.com [16.236.32.45]) by g4t0017.houston.hp.com (Postfix) with ESMTP id 224CA381B5; Fri, 16 Jan 2009 21:11:52 +0000 (UTC) Received: from ldl.fc.hp.com (ldl.fc.hp.com [15.11.146.30]) by g1t0039.austin.hp.com (Postfix) with ESMTP id DF0F2340F5; Fri, 16 Jan 2009 21:11:51 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl.fc.hp.com (Postfix) with ESMTP id 9E09C39C043; Fri, 16 Jan 2009 14:11:51 -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 DKR7UeXdZelD; Fri, 16 Jan 2009 14:11:50 -0700 (MST) Received: from kvm.aw (lart.fc.hp.com [15.11.146.31]) by ldl.fc.hp.com (Postfix) with ESMTP id 5090F39C00D; Fri, 16 Jan 2009 14:11:50 -0700 (MST) From: Alex Williamson Subject: [PATCH 1/7] qemu:virtio-net: Allow setting the MAC address via set_config To: kvm@vger.kernel.org Cc: qemu-devel@nongnu.org, markmc@redhat.com Date: Fri, 16 Jan 2009 14:09:59 -0700 Message-ID: <20090116210959.16725.53460.stgit@kvm.aw> In-Reply-To: <20090116210954.16725.44321.stgit@kvm.aw> References: <20090116210954.16725.44321.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 --- qemu/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/qemu/hw/virtio-net.c b/qemu/hw/virtio-net.c index 6ce2ff5..3767ecc 100644 --- a/qemu/hw/virtio-net.c +++ b/qemu/hw/virtio-net.c @@ -45,7 +45,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; @@ -55,6 +55,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; @@ -437,7 +450,8 @@ PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn) if (!n) return NULL; - 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);