From patchwork Fri Jun 26 14:49:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 488857 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B3301140273 for ; Sat, 27 Jun 2015 00:57:39 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=V//y/kuB; dkim-atps=neutral Received: from localhost ([::1]:60473 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z8V4T-00083s-Ut for incoming@patchwork.ozlabs.org; Fri, 26 Jun 2015 10:57:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57208) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z8Uxi-0004oY-VJ for qemu-devel@nongnu.org; Fri, 26 Jun 2015 10:50:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z8Uxi-0002HD-2G for qemu-devel@nongnu.org; Fri, 26 Jun 2015 10:50:38 -0400 Received: from mail-qc0-x233.google.com ([2607:f8b0:400d:c01::233]:34171) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z8Uxh-0002H7-UZ for qemu-devel@nongnu.org; Fri, 26 Jun 2015 10:50:38 -0400 Received: by qcji3 with SMTP id i3so30008867qcj.1 for ; Fri, 26 Jun 2015 07:50:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=hhoxSBxfocPuggJcXhruB2604JKjHY4mA1MyFfHuTRc=; b=V//y/kuBxi/WarXcSq9Nuyp6DLvCB7dW7UwMC45iC0gwBSmA7Zgy36MxpbB3vz+jOY iMZnGmgTFl5fWBqkcaqqxt1Woszsm94acGdZn3SuvfzuNRaigoGxgWbcj01jCaDhf30R aKpWG+MdFsMRnS20aK81JvmoQSucqfrAYh256AXrN3MXurzM/3Ax8n1WUxAapydK+n0V jtqDEHODrwejh+pE2R/tkyhxIaDwuU9W1aFw4OWMCa914N+cMDWHbd658JpZsmmwI4Zh iZk8sG4Wu5hzVPhJztT2OLCxX2xQSQUefjL64U4OLSQuLa7dbGjfLLzuzwfkaDrFm0sb MPzA== X-Received: by 10.140.84.104 with SMTP id k95mr2714258qgd.45.1435330237548; Fri, 26 Jun 2015 07:50:37 -0700 (PDT) Received: from localhost (bne75-h02-31-39-163-232.dsl.sta.abo.bbox.fr. [31.39.163.232]) by mx.google.com with ESMTPSA id 87sm6936676qkv.22.2015.06.26.07.50.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jun 2015 07:50:36 -0700 (PDT) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 26 Jun 2015 16:49:20 +0200 Message-Id: <1435330185-23248-15-git-send-email-marcandre.lureau@gmail.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1435330185-23248-1-git-send-email-marcandre.lureau@gmail.com> References: <1435330185-23248-1-git-send-email-marcandre.lureau@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c01::233 Cc: cam@cs.ualberta.ca, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , stefanha@redhat.com Subject: [Qemu-devel] [PATCH 14/39] ivshmem: remove max_peer field X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org max_peer isn't really useful, it tracks the maximum received VM id, but that quickly matches nb_peers, the size of the peers array. Since VM come and go, there might be sparse peers so it doesn't help much in general to have this value around. Signed-off-by: Marc-André Lureau --- hw/misc/ivshmem.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index 2c78dee..4958307 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -90,7 +90,6 @@ typedef struct IVShmemState { Peer *peers; int nb_peers; /* how many guests we have space for */ - int max_peer; /* maximum numbered peer */ int vm_id; uint32_t vectors; @@ -200,7 +199,7 @@ static void ivshmem_io_write(void *opaque, hwaddr addr, case DOORBELL: /* check that dest VM ID is reasonable */ - if (dest > s->max_peer) { + if (dest >= s->nb_peers) { IVSHMEM_DPRINTF("Invalid destination VM ID (%d)\n", dest); break; } @@ -574,11 +573,6 @@ static void ivshmem_read(void *opaque, const uint8_t *buf, int size) /* increment count for particular guest */ s->peers[incoming_posn].nb_eventfds++; - /* keep track of the maximum VM ID */ - if (incoming_posn > s->max_peer) { - s->max_peer = incoming_posn; - } - if (incoming_posn == s->vm_id) { s->eventfd_chr[guest_max_eventfd] = create_eventfd_chr_device(s, &s->peers[s->vm_id].eventfds[guest_max_eventfd], @@ -721,8 +715,6 @@ static void pci_ivshmem_realize(PCIDevice *dev, Error **errp) PCI_BASE_ADDRESS_MEM_PREFETCH;; Error *local_err = NULL; - s->max_peer = -1; - if (s->sizearg == NULL) { s->ivshmem_size = 4 << 20; /* 4 MB default */ } else {