Patchwork [v2,02/15] virtio-net: move NICConf into virtio_net_conf

login
register
mail settings
Submitter Paolo Bonzini
Date Jan. 2, 2012, 5:59 p.m.
Message ID <1325527166-23898-3-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/133891/
State New
Headers show

Comments

Paolo Bonzini - Jan. 2, 2012, 5:59 p.m.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/s390-virtio-bus.c |    3 +--
 hw/s390-virtio-bus.h |    1 -
 hw/virtio-net.c      |   13 ++++++-------
 hw/virtio-net.h      |    2 ++
 hw/virtio-pci.c      |    3 +--
 hw/virtio-pci.h      |    1 -
 hw/virtio.h          |    3 +--
 7 files changed, 11 insertions(+), 15 deletions(-)

Patch

diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index 0326cfc..80b11e5 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -116,7 +116,7 @@  static int s390_virtio_net_init(VirtIOS390Device *dev)
 {
     VirtIODevice *vdev;
 
-    vdev = virtio_net_init((DeviceState *)dev, &dev->nic, &dev->net);
+    vdev = virtio_net_init((DeviceState *)dev, &dev->net);
     if (!vdev) {
         return -1;
     }
@@ -336,7 +336,6 @@  static VirtIOS390DeviceInfo s390_virtio_net = {
     .qdev.alias = "virtio-net",
     .qdev.size = sizeof(VirtIOS390Device),
     .qdev.props = (Property[]) {
-        DEFINE_NIC_PROPERTIES(VirtIOS390Device, nic),
         DEFINE_VIRTIO_NET_PROPERTIES(VirtIOS390Device, host_features, net),
         DEFINE_PROP_END_OF_LIST(),
     },
diff --git a/hw/s390-virtio-bus.h b/hw/s390-virtio-bus.h
index f1bece7..b10c78b 100644
--- a/hw/s390-virtio-bus.h
+++ b/hw/s390-virtio-bus.h
@@ -43,7 +43,6 @@  typedef struct VirtIOS390Device {
     VirtIODevice *vdev;
     BlockConf block;
     char *block_serial;
-    NICConf nic;
     uint32_t host_features;
     virtio_serial_conf serial;
     virtio_net_conf net;
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 8c2f460..163b6c0 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -992,8 +992,7 @@  static NetClientInfo net_virtio_info = {
     .link_status_changed = virtio_net_set_link_status,
 };
 
-VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf,
-                              virtio_net_conf *net)
+VirtIODevice *virtio_net_init(DeviceState *dev, virtio_net_conf *net)
 {
     VirtIONet *n;
 
@@ -1026,13 +1025,13 @@  VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf,
         n->tx_bh = qemu_bh_new(virtio_net_tx_bh, n);
     }
     n->ctrl_vq = virtio_add_queue(&n->vdev, 64, virtio_net_handle_ctrl);
-    qemu_macaddr_default_if_unset(&conf->macaddr);
-    memcpy(&n->mac[0], &conf->macaddr, sizeof(n->mac));
+    qemu_macaddr_default_if_unset(&net->nic.macaddr);
+    memcpy(&n->mac[0], &net->nic.macaddr, sizeof(n->mac));
     n->status = VIRTIO_NET_S_LINK_UP;
 
-    n->nic = qemu_new_nic(&net_virtio_info, conf, dev->info->name, dev->id, n);
+    n->nic = qemu_new_nic(&net_virtio_info, &net->nic, dev->info->name, dev->id, n);
 
-    qemu_format_nic_info_str(&n->nic->nc, conf->macaddr.a);
+    qemu_format_nic_info_str(&n->nic->nc, net->nic.macaddr.a);
 
     n->tx_waiting = 0;
     n->tx_burst = net->txburst;
@@ -1047,7 +1046,7 @@  VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf,
     register_savevm(dev, "virtio-net", -1, VIRTIO_NET_VM_VERSION,
                     virtio_net_save, virtio_net_load, n);
 
-    add_boot_device_path(conf->bootindex, dev, "/ethernet-phy@0");
+    add_boot_device_path(net->nic.bootindex, dev, "/ethernet-phy@0");
 
     return &n->vdev;
 }
diff --git a/hw/virtio-net.h b/hw/virtio-net.h
index f6faea9..ee55a85 100644
--- a/hw/virtio-net.h
+++ b/hw/virtio-net.h
@@ -58,6 +58,7 @@ 
 
 typedef struct virtio_net_conf
 {
+    NICConf nic;
     uint32_t txtimer;
     int32_t txburst;
     char *tx;
@@ -168,6 +169,7 @@  struct virtio_net_ctrl_mac {
  #define VIRTIO_NET_CTRL_VLAN_DEL             1
 
 #define DEFINE_VIRTIO_NET_PROPERTIES(_state, _features_field, _conf_field) \
+        DEFINE_NIC_PROPERTIES(_state, _conf_field.nic), \
         DEFINE_VIRTIO_COMMON_FEATURES(_state, _features_field), \
         DEFINE_PROP_BIT("csum", _state, _features_field, VIRTIO_NET_F_CSUM, true), \
         DEFINE_PROP_BIT("guest_csum", _state, _features_field, VIRTIO_NET_F_GUEST_CSUM, true), \
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 99a61be..974c68f 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -739,7 +739,7 @@  static int virtio_net_init_pci(PCIDevice *pci_dev)
     VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
     VirtIODevice *vdev;
 
-    vdev = virtio_net_init(&pci_dev->qdev, &proxy->nic, &proxy->net);
+    vdev = virtio_net_init(&pci_dev->qdev, &proxy->net);
 
     vdev->nvectors = proxy->nvectors;
     virtio_init_pci(proxy, vdev);
@@ -818,7 +818,6 @@  static PCIDeviceInfo virtio_info[] = {
                             VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, false),
             DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3),
             DEFINE_VIRTIO_NET_PROPERTIES(VirtIOPCIProxy, host_features, net),
-            DEFINE_NIC_PROPERTIES(VirtIOPCIProxy, nic),
             DEFINE_PROP_END_OF_LIST(),
         },
         .qdev.reset = virtio_pci_reset,
diff --git a/hw/virtio-pci.h b/hw/virtio-pci.h
index 344c22b..e0df6ef 100644
--- a/hw/virtio-pci.h
+++ b/hw/virtio-pci.h
@@ -33,7 +33,6 @@  typedef struct {
     uint32_t nvectors;
     BlockConf block;
     char *block_serial;
-    NICConf nic;
     uint32_t host_features;
 #ifdef CONFIG_LINUX
     V9fsConf fsconf;
diff --git a/hw/virtio.h b/hw/virtio.h
index 25f5564..7303b6c 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -194,8 +194,7 @@  void virtio_bind_device(VirtIODevice *vdev, const VirtIOBindings *binding,
 VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf,
                               char **serial);
 struct virtio_net_conf;
-VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf,
-                              struct virtio_net_conf *net);
+VirtIODevice *virtio_net_init(DeviceState *dev, struct virtio_net_conf *net);
 typedef struct virtio_serial_conf virtio_serial_conf;
 VirtIODevice *virtio_serial_init(DeviceState *dev, virtio_serial_conf *serial);
 VirtIODevice *virtio_balloon_init(DeviceState *dev);