From patchwork Wed Jan 7 17:37:36 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 1210 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 n07HXc5l024618 for ; Wed, 7 Jan 2009 09:33:38 -0800 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753422AbZAGRhK (ORCPT ); Wed, 7 Jan 2009 12:37:10 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752919AbZAGRhK (ORCPT ); Wed, 7 Jan 2009 12:37:10 -0500 Received: from g4t0014.houston.hp.com ([15.201.24.17]:6227 "EHLO g4t0014.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753422AbZAGRhI (ORCPT ); Wed, 7 Jan 2009 12:37:08 -0500 Received: from g4t0018.houston.hp.com (g4t0018.houston.hp.com [16.234.32.27]) by g4t0014.houston.hp.com (Postfix) with ESMTP id F3C00245A8; Wed, 7 Jan 2009 17:37:07 +0000 (UTC) Received: from ldl.fc.hp.com (ldl.fc.hp.com [15.11.146.30]) by g4t0018.houston.hp.com (Postfix) with ESMTP id DA6CE1001B; Wed, 7 Jan 2009 17:37:07 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl.fc.hp.com (Postfix) with ESMTP id 96ACC39C008; Wed, 7 Jan 2009 10:37:07 -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 gQ+iTOL2iqMY; Wed, 7 Jan 2009 10:37:06 -0700 (MST) Received: from [10.91.73.10] (lart.fc.hp.com [15.11.146.31]) by ldl.fc.hp.com (Postfix) with ESMTP id 572B539C001; Wed, 7 Jan 2009 10:37:06 -0700 (MST) Subject: [PATCH 1/5][RFC] virtio-net: Allow setting the MAC address via set_config From: Alex Williamson To: kvm , qemu-devel Cc: Mark McLoughlin Organization: OSLO R&D Date: Wed, 07 Jan 2009 10:37:36 -0700 Message-Id: <1231349856.7109.80.camel@lappy> 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 virtio-net: Allow setting the MAC address via set_config Rename get_config for simplicity Signed-off-by: Alex Williamson --- hw/virtio-net.c | 21 +++++++++++++++++++-- 1 files changed, 19 insertions(+), 2 deletions(-) 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]); + } +} + static void virtio_net_set_link_status(VLANClientState *vc) { VirtIONet *n = vc->opaque; @@ -326,7 +342,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); -- 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 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) { VirtIONet *n = to_virtio_net(vdev);