From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LVCpQ-0000uY-JL for qemu-devel@nongnu.org; Thu, 05 Feb 2009 17:36:12 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LVCpO-0000sH-Uh for qemu-devel@nongnu.org; Thu, 05 Feb 2009 17:36:11 -0500 Received: from [199.232.76.173] (port=44145 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LVCpO-0000s4-Oc for qemu-devel@nongnu.org; Thu, 05 Feb 2009 17:36:10 -0500 Received: from savannah.gnu.org ([199.232.41.3]:56495 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LVCpO-0005pc-DV for qemu-devel@nongnu.org; Thu, 05 Feb 2009 17:36:10 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1LVCpN-0000RL-17 for qemu-devel@nongnu.org; Thu, 05 Feb 2009 22:36:09 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1LVCpM-0000RH-Lc for qemu-devel@nongnu.org; Thu, 05 Feb 2009 22:36:08 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Thu, 05 Feb 2009 22:36:08 +0000 Subject: [Qemu-devel] [6534] qemu:virtio-net: Allow setting the MAC address via set_config ( Alex Williamson) Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 6534 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6534 Author: aliguori Date: 2009-02-05 22:36:08 +0000 (Thu, 05 Feb 2009) Log Message: ----------- qemu:virtio-net: Allow setting the MAC address via set_config (Alex Williamson) 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 Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/hw/virtio-net.c Modified: trunk/hw/virtio-net.c =================================================================== --- trunk/hw/virtio-net.c 2009-02-05 22:36:04 UTC (rev 6533) +++ trunk/hw/virtio-net.c 2009-02-05 22:36:08 UTC (rev 6534) @@ -40,7 +40,7 @@ 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 @@ 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 @@ 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);