From patchwork Fri Oct 2 19:09:16 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: 525742 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 471B6140D6D for ; Sat, 3 Oct 2015 05:29:50 +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=eIb1Ijj9; dkim-atps=neutral Received: from localhost ([::1]:34637 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi61c-0000m2-3S for incoming@patchwork.ozlabs.org; Fri, 02 Oct 2015 15:29:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33960) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi5in-0007ar-8j for qemu-devel@nongnu.org; Fri, 02 Oct 2015 15:10:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zi5ik-0007BG-Gb for qemu-devel@nongnu.org; Fri, 02 Oct 2015 15:10:21 -0400 Received: from mail-wi0-x22b.google.com ([2a00:1450:400c:c05::22b]:35546) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi5ik-0007B8-Bl for qemu-devel@nongnu.org; Fri, 02 Oct 2015 15:10:18 -0400 Received: by wicge5 with SMTP id ge5so46223801wic.0 for ; Fri, 02 Oct 2015 12:10:17 -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=sjkVdMQ1DjXrsE8Eezq5S3bOmvg1KhG/vgexwo4r1ys=; b=eIb1Ijj9i+XAvl9BommQpniZobk/PFY+6re32C9lC+Rxq/xB9Zmj6sQnHykChwRnQi dIbdENQvL/ugmUVHIxux2zLWDew1oe3NGhmDrbP2KkU/QrPiRq+LvYRk06ku6KjQKfRb 2v9Wz496MS3MJoa6SFfy8Pcfm/F6HmqVvUIFz1fxQoABdmvo26LUswRQbnZLdsPCz3KM ez8B6UKdRHR4Sfwhyzum8fB5rHtLGqHRFl7DEasjuNlQspVX7uRdv0Q+yX0E1cHnG/n5 h2+RyUmPQXfAHaGnnj+lh485V8lpB7CAuGGFH6RxiyO+Ifl8/Qm02J1LjrDCHmiBhkKb 9Pfw== X-Received: by 10.194.112.162 with SMTP id ir2mr20130837wjb.40.1443813017791; Fri, 02 Oct 2015 12:10:17 -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 hd1sm418294wib.5.2015.10.02.12.10.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Oct 2015 12:10:16 -0700 (PDT) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Fri, 2 Oct 2015 21:09:16 +0200 Message-Id: <1443812991-17356-14-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::22b 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 13/48] ivshmem: allocate eventfds in resize_peers() 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 It simplifies a bit the code to allocate the array when setting the number of peers instead of lazily when receiving the first vector. Signed-off-by: Marc-André Lureau Reviewed-by: Claudio Fontana --- hw/misc/ivshmem.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index 6f41960..19640bb 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -437,9 +437,8 @@ static int resize_peers(IVShmemState *s, int new_min_size) s->peers = g_realloc(s->peers, s->nb_peers * sizeof(Peer)); - /* zero out new pointers */ for (j = old_size; j < s->nb_peers; j++) { - s->peers[j].eventfds = NULL; + s->peers[j].eventfds = g_new0(EventNotifier, s->vectors); s->peers[j].nb_eventfds = 0; } @@ -517,8 +516,7 @@ static void ivshmem_read(void *opaque, const uint8_t *buf, int size) if (incoming_fd == -1) { /* if posn is positive and unseen before then this is our posn*/ - if ((incoming_posn >= 0) && - (s->peers[incoming_posn].eventfds == NULL)) { + if (incoming_posn >= 0 && s->vm_id == -1) { /* receive our posn */ s->vm_id = incoming_posn; return; @@ -569,11 +567,6 @@ static void ivshmem_read(void *opaque, const uint8_t *buf, int size) * guests for each VM */ guest_max_eventfd = s->peers[incoming_posn].nb_eventfds; - if (guest_max_eventfd == 0) { - /* one eventfd per MSI vector */ - s->peers[incoming_posn].eventfds = g_new(EventNotifier, s->vectors); - } - /* this is an eventfd for a particular guest VM */ IVSHMEM_DPRINTF("eventfds[%ld][%d] = %d\n", incoming_posn, guest_max_eventfd, incoming_fd);