From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53522) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WorlT-0004xH-Ov for qemu-devel@nongnu.org; Mon, 26 May 2014 06:04:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WorlO-0004zL-EH for qemu-devel@nongnu.org; Mon, 26 May 2014 06:04:19 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:37619) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WorlO-0004z6-9P for qemu-devel@nongnu.org; Mon, 26 May 2014 06:04:14 -0400 Received: by mail-pa0-f49.google.com with SMTP id lj1so7387776pab.36 for ; Mon, 26 May 2014 03:04:13 -0700 (PDT) From: Jiri Pirko Date: Mon, 26 May 2014 12:04:08 +0200 Message-Id: <1401098648-14717-1-git-send-email-jiri@resnulli.us> Subject: [Qemu-devel] [patch qemu] net: move queue number into NICPeers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: armbru@redhat.com, afaerber@suse.de, aliguori@amazon.com, stefanha@redhat.com, mst@redhat.com It indicates the number of elements in ncs field and makes sense to have int inside NICPeers. Also in parse_netdev we do not need to access container and work with NICPeers only. Signed-off-by: Jiri Pirko --- hw/core/qdev-properties-system.c | 3 +-- hw/net/virtio-net.c | 2 +- include/net/net.h | 2 +- net/net.c | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index 404cf18..3fd592c 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -180,7 +180,6 @@ PropertyInfo qdev_prop_chr = { static int parse_netdev(DeviceState *dev, const char *str, void **ptr) { NICPeers *peers_ptr = (NICPeers *)ptr; - NICConf *conf = container_of(peers_ptr, NICConf, peers); NetClientState **ncs = peers_ptr->ncs; NetClientState *peers[MAX_QUEUE_NUM]; int queues, i = 0; @@ -219,7 +218,7 @@ static int parse_netdev(DeviceState *dev, const char *str, void **ptr) ncs[i]->queue_index = i; } - conf->queues = queues; + peers_ptr->queues = queues; return 0; diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 940a7cf..b4cb277 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1533,7 +1533,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) virtio_init(vdev, "virtio-net", VIRTIO_ID_NET, n->config_size); - n->max_queues = MAX(n->nic_conf.queues, 1); + n->max_queues = MAX(n->nic_conf.peers.queues, 1); n->vqs = g_malloc0(sizeof(VirtIONetQueue) * n->max_queues); n->vqs[0].rx_vq = virtio_add_queue(vdev, 256, virtio_net_handle_rx); n->curr_queues = 1; diff --git a/include/net/net.h b/include/net/net.h index 8166345..8a1db8a 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -24,13 +24,13 @@ struct MACAddr { typedef struct NICPeers { NetClientState *ncs[MAX_QUEUE_NUM]; + int32_t queues; } NICPeers; typedef struct NICConf { MACAddr macaddr; NICPeers peers; int32_t bootindex; - int32_t queues; } NICConf; #define DEFINE_NIC_PROPERTIES(_state, _conf) \ diff --git a/net/net.c b/net/net.c index 0ff2e40..0246818 100644 --- a/net/net.c +++ b/net/net.c @@ -233,7 +233,7 @@ NICState *qemu_new_nic(NetClientInfo *info, { NetClientState **peers = conf->peers.ncs; NICState *nic; - int i, queues = MAX(1, conf->queues); + int i, queues = MAX(1, conf->peers.queues); assert(info->type == NET_CLIENT_OPTIONS_KIND_NIC); assert(info->size >= sizeof(NICState)); @@ -346,7 +346,7 @@ void qemu_del_net_client(NetClientState *nc) void qemu_del_nic(NICState *nic) { - int i, queues = MAX(nic->conf->queues, 1); + int i, queues = MAX(nic->conf->peers.queues, 1); /* If this is a peer NIC and peer has already been deleted, free it now. */ if (nic->peer_deleted) { -- 1.9.0