Commit 0f03eca6065fa6510cc480494d800f938484c7f6
1 parent
9d6271b8
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 <alex.williamson@hp.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6534 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
16 additions
and
2 deletions
hw/virtio-net.c
@@ -40,7 +40,7 @@ static VirtIONet *to_virtio_net(VirtIODevice *vdev) | @@ -40,7 +40,7 @@ static VirtIONet *to_virtio_net(VirtIODevice *vdev) | ||
40 | return (VirtIONet *)vdev; | 40 | return (VirtIONet *)vdev; |
41 | } | 41 | } |
42 | 42 | ||
43 | -static void virtio_net_update_config(VirtIODevice *vdev, uint8_t *config) | 43 | +static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config) |
44 | { | 44 | { |
45 | VirtIONet *n = to_virtio_net(vdev); | 45 | VirtIONet *n = to_virtio_net(vdev); |
46 | struct virtio_net_config netcfg; | 46 | struct virtio_net_config netcfg; |
@@ -50,6 +50,19 @@ static void virtio_net_update_config(VirtIODevice *vdev, uint8_t *config) | @@ -50,6 +50,19 @@ static void virtio_net_update_config(VirtIODevice *vdev, uint8_t *config) | ||
50 | memcpy(config, &netcfg, sizeof(netcfg)); | 50 | memcpy(config, &netcfg, sizeof(netcfg)); |
51 | } | 51 | } |
52 | 52 | ||
53 | +static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config) | ||
54 | +{ | ||
55 | + VirtIONet *n = to_virtio_net(vdev); | ||
56 | + struct virtio_net_config netcfg; | ||
57 | + | ||
58 | + memcpy(&netcfg, config, sizeof(netcfg)); | ||
59 | + | ||
60 | + if (memcmp(netcfg.mac, n->mac, 6)) { | ||
61 | + memcpy(n->mac, netcfg.mac, 6); | ||
62 | + qemu_format_nic_info_str(n->vc, n->mac); | ||
63 | + } | ||
64 | +} | ||
65 | + | ||
53 | static void virtio_net_set_link_status(VLANClientState *vc) | 66 | static void virtio_net_set_link_status(VLANClientState *vc) |
54 | { | 67 | { |
55 | VirtIONet *n = vc->opaque; | 68 | VirtIONet *n = vc->opaque; |
@@ -337,7 +350,8 @@ void virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn) | @@ -337,7 +350,8 @@ void virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn) | ||
337 | if (!n) | 350 | if (!n) |
338 | return; | 351 | return; |
339 | 352 | ||
340 | - n->vdev.get_config = virtio_net_update_config; | 353 | + n->vdev.get_config = virtio_net_get_config; |
354 | + n->vdev.set_config = virtio_net_set_config; | ||
341 | n->vdev.get_features = virtio_net_get_features; | 355 | n->vdev.get_features = virtio_net_get_features; |
342 | n->vdev.set_features = virtio_net_set_features; | 356 | n->vdev.set_features = virtio_net_set_features; |
343 | n->rx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_rx); | 357 | n->rx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_rx); |