* [PATCH 1/5][RFC] virtio-net: Allow setting the MAC address via set_config
@ 2009-01-07 17:37 Alex Williamson
2009-01-09 11:38 ` Mark McLoughlin
0 siblings, 1 reply; 3+ messages in thread
From: Alex Williamson @ 2009-01-07 17:37 UTC (permalink / raw)
To: kvm, qemu-devel; +Cc: Mark McLoughlin
virtio-net: Allow setting the MAC address via set_config
Rename get_config for simplicity
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
---
hw/virtio-net.c | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
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);
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);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/5][RFC] virtio-net: Allow setting the MAC address via set_config
2009-01-07 17:37 [PATCH 1/5][RFC] virtio-net: Allow setting the MAC address via set_config Alex Williamson
@ 2009-01-09 11:38 ` Mark McLoughlin
2009-01-09 15:34 ` Alex Williamson
0 siblings, 1 reply; 3+ messages in thread
From: Mark McLoughlin @ 2009-01-09 11:38 UTC (permalink / raw)
To: Alex Williamson; +Cc: kvm, qemu-devel
On Wed, 2009-01-07 at 10:37 -0700, Alex Williamson wrote:
> virtio-net: Allow setting the MAC address via set_config
This will basically never happen with QEMU, right?
We always set the MAC address - even if not supplied on the command line
- and the guest will never override that.
> Rename get_config for simplicity
>
> Signed-off-by: Alex Williamson <alex.williamson@hp.com>
> ---
>
> hw/virtio-net.c | 21 +++++++++++++++++++--
> 1 files changed, 19 insertions(+), 2 deletions(-)
>
> 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)
Yay :-)
> {
> VirtIONet *n = to_virtio_net(vdev);
> 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]);
There's qemu_format_nic_info_str() now.
Cheers,
Mark.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/5][RFC] virtio-net: Allow setting the MAC address via set_config
2009-01-09 11:38 ` Mark McLoughlin
@ 2009-01-09 15:34 ` Alex Williamson
0 siblings, 0 replies; 3+ messages in thread
From: Alex Williamson @ 2009-01-09 15:34 UTC (permalink / raw)
To: Mark McLoughlin; +Cc: kvm, qemu-devel
On Fri, 2009-01-09 at 11:38 +0000, Mark McLoughlin wrote:
> On Wed, 2009-01-07 at 10:37 -0700, Alex Williamson wrote:
> > virtio-net: Allow setting the MAC address via set_config
>
> This will basically never happen with QEMU, right?
>
> We always set the MAC address - even if not supplied on the command line
> - and the guest will never override that.
Right, we always give the guest a MAC, but why will the guest never
override it? That seems like a big assumption.
> > +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]);
>
> There's qemu_format_nic_info_str() now.
Thanks, that will clean it up nicely. Thanks,
Alex
--
Alex Williamson HP Open Source & Linux Org.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-01-09 15:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-07 17:37 [PATCH 1/5][RFC] virtio-net: Allow setting the MAC address via set_config Alex Williamson
2009-01-09 11:38 ` Mark McLoughlin
2009-01-09 15:34 ` Alex Williamson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).