From: Alex Williamson <alex.williamson@hp.com>
To: kvm <kvm@vger.kernel.org>
Cc: qemu-devel <qemu-devel@nongnu.org>, Mark McLoughlin <markmc@redhat.com>
Subject: [PATCH 1/5] virtio-net: Allow setting the MAC address via set_config
Date: Tue, 13 Jan 2009 14:23:49 -0700 [thread overview]
Message-ID: <1231881829.9095.191.camel@bling> (raw)
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);
WARNING: multiple messages have this Message-ID (diff)
From: Alex Williamson <alex.williamson@hp.com>
To: kvm <kvm@vger.kernel.org>
Cc: Mark McLoughlin <markmc@redhat.com>, qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH 1/5] virtio-net: Allow setting the MAC address via set_config
Date: Tue, 13 Jan 2009 14:23:49 -0700 [thread overview]
Message-ID: <1231881829.9095.191.camel@bling> (raw)
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);
next reply other threads:[~2009-01-13 21:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-13 21:23 Alex Williamson [this message]
2009-01-13 21:23 ` [Qemu-devel] [PATCH 1/5] virtio-net: Allow setting the MAC address via set_config 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1231881829.9095.191.camel@bling \
--to=alex.williamson@hp.com \
--cc=kvm@vger.kernel.org \
--cc=markmc@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.