All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] virtio-net: Allow setting the MAC address via set_config
@ 2009-01-13 21:23 ` Alex Williamson
  0 siblings, 0 replies; 18+ messages in thread
From: Alex Williamson @ 2009-01-13 21:23 UTC (permalink / raw)
  To: kvm; +Cc: qemu-devel, Mark McLoughlin


Rename get_config for simplicity

Signed-off-by: Alex Williamson <alex.williamson@hp.com>
---

 qemu/hw/virtio-net.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

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);



^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2009-01-18  9:42 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-13 21:23 [PATCH 1/5] virtio-net: Allow setting the MAC address via set_config Alex Williamson
2009-01-13 21:23 ` [Qemu-devel] " Alex Williamson
2009-01-14 10:05 ` Dor Laor
2009-01-14 10:05   ` [Qemu-devel] " Dor Laor
2009-01-14 15:34   ` Alex Williamson
2009-01-14 15:34     ` [Qemu-devel] " Alex Williamson
2009-01-14 16:41     ` Jamie Lokier
2009-01-14 16:41       ` Jamie Lokier
2009-01-14 22:06       ` Dor Laor
2009-01-14 22:14         ` Paul Brook
2009-01-15 13:11           ` Jamie Lokier
2009-01-15 13:11             ` Jamie Lokier
2009-01-15 13:12         ` Jamie Lokier
2009-01-15 13:41           ` Avi Kivity
2009-01-15 13:41             ` Avi Kivity
2009-01-18  9:37           ` Dor Laor
2009-01-18  9:42             ` Avi Kivity
2009-01-14 22:08       ` Dor Laor

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.