From patchwork Fri Oct 2 19:09:19 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: 525753 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 8E6CE1402F0 for ; Sat, 3 Oct 2015 05:35:21 +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=RqJSKrCz; dkim-atps=neutral Received: from localhost ([::1]:34702 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi66x-00020j-GP for incoming@patchwork.ozlabs.org; Fri, 02 Oct 2015 15:35:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34000) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi5iq-0007bI-KU for qemu-devel@nongnu.org; Fri, 02 Oct 2015 15:10:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zi5ip-0007CM-LU for qemu-devel@nongnu.org; Fri, 02 Oct 2015 15:10:24 -0400 Received: from mail-wi0-x231.google.com ([2a00:1450:400c:c05::231]:35558) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi5ip-0007CG-FP for qemu-devel@nongnu.org; Fri, 02 Oct 2015 15:10:23 -0400 Received: by wicge5 with SMTP id ge5so46226491wic.0 for ; Fri, 02 Oct 2015 12:10:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=4ySdRmh5P70wxHXfk5VfoIgz1Rkkl5RZyvbhuxBGMWw=; b=RqJSKrCzCYPA6CCmg9D76C53vitftQFECDdJgcy273HH7w74seKTEttFLz9B+i1Rkx CRueC5mhupwUurxGXiICbhk5X3u4OL3Pqwq/AXZgVNHoqUZ3uLkHuKNO8SeDe6tg3PnO umulK1USD0lq31nDLUBZXF6oxcN8a908Jtnc0hfsUaz8pSi4ODNB+Z/jcthcagn5R0cP 4xn25rbqD8vihkeNr8bSggWFEGFiXdJi4wKIqMQVBhlD9u51xFlSe48okh8qhja/r/f2 iDz90IFqOT4n1tLcUtJLWg9byRCQm1KXip0hlJPiOFU7ueui+EK+XsZLadW1lSuVsOOY 7Yng== X-Received: by 10.194.190.113 with SMTP id gp17mr9122397wjc.24.1443813022950; Fri, 02 Oct 2015 12:10:22 -0700 (PDT) Received: from localhost (bne75-h02-31-39-163-232.dsl.sta.abo.bbox.fr. [31.39.163.232]) by smtp.gmail.com with ESMTPSA id he3sm12688615wjc.48.2015.10.02.12.10.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Oct 2015 12:10:22 -0700 (PDT) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Fri, 2 Oct 2015 21:09:19 +0200 Message-Id: <1443812991-17356-17-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443812991-17356-1-git-send-email-marcandre.lureau@redhat.com> References: <1443812991-17356-1-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::231 Cc: drjones@redhat.com, claudio.fontana@huawei.com, stefanha@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , pbonzini@redhat.com, cam@cs.ualberta.ca Subject: [Qemu-devel] [PATCH v5 16/48] 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 From: Marc-André Lureau 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 Reviewed-by: Claudio Fontana --- 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 0716deb..c4c130d 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 {