From patchwork Tue Jan 13 21:23:49 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 2221 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 n0DLKkor012171 for ; Tue, 13 Jan 2009 13:20:47 -0800 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753621AbZAMVYN (ORCPT ); Tue, 13 Jan 2009 16:24:13 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753540AbZAMVYN (ORCPT ); Tue, 13 Jan 2009 16:24:13 -0500 Received: from g5t0008.atlanta.hp.com ([15.192.0.45]:26445 "EHLO g5t0008.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753621AbZAMVYL (ORCPT ); Tue, 13 Jan 2009 16:24:11 -0500 Received: from g5t0030.atlanta.hp.com (g5t0030.atlanta.hp.com [16.228.8.142]) by g5t0008.atlanta.hp.com (Postfix) with ESMTP id 0BB8624136; Tue, 13 Jan 2009 21:24:11 +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 B15172400F; Tue, 13 Jan 2009 21:23:55 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl.fc.hp.com (Postfix) with ESMTP id 4F9ED39C07A; Tue, 13 Jan 2009 14:23:55 -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 kIOSFN7j+uBO; Tue, 13 Jan 2009 14:23:54 -0700 (MST) Received: from [192.168.1.60] (squirrel.fc.hp.com [15.11.146.57]) by ldl.fc.hp.com (Postfix) with ESMTP id 89E3639C003; Tue, 13 Jan 2009 14:23:53 -0700 (MST) Subject: [PATCH 1/5] virtio-net: Allow setting the MAC address via set_config From: Alex Williamson To: kvm Cc: qemu-devel , Mark McLoughlin Organization: HP OSLO R&D Date: Tue, 13 Jan 2009 14:23:49 -0700 Message-Id: <1231881829.9095.191.camel@bling> Mime-Version: 1.0 X-Mailer: Evolution 2.24.2 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Rename get_config for simplicity 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 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); + } +} + static uint32_t virtio_net_get_features(VirtIODevice *vdev) { uint32_t features = (1 << VIRTIO_NET_F_MAC); @@ -405,7 +418,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);