From nobody Tue Oct 7 04:13:57 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=nutanix.com ARC-Seal: i=1; a=rsa-sha256; t=1589891248; cv=none; d=zohomail.com; s=zohoarc; b=j/DP1cYDveM4RODfTD7K2avsdt5h2q+vvFzdjfiW2jAA6lLcRI6G74T/PyyUNnu/yH+aWn3wDnPlZCW7UlhQJu2VSrv3EdO6QaQ44se2IYd4ZkLeyIFNCCTAjCX/RSuaj8SNJ+EjnZnJupqbiQWDkTXj07f96Fty29/WeHQI65g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589891248; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=M6xTVVbhl/MNPl1YAIqUl150kIlTpOqbu4j5fCTP0pQ=; b=GnXUU1xGw29JteoOPJqvdq3q6JVnn8z3b2vGKcNlFDqon4r+2E/gJK9f/mdwV+rc6K62/sfg5kmk6Zjzfd/MVp6bBsDRp6QmbpkngLGuJmd5pwrt4wapPUETPy3rTglYwWww5jQIbe70Gf3urJ6yAbnnd2d3kwMoPsjF2yNnCCo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589891248361764.8227521883858; Tue, 19 May 2020 05:27:28 -0700 (PDT) Received: from localhost ([::1]:45770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jb1LB-0001pL-IV for importer@patchew.org; Tue, 19 May 2020 08:27:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jb1JI-0008Kb-5P for qemu-devel@nongnu.org; Tue, 19 May 2020 08:25:28 -0400 Received: from o1.dev.nutanix.com ([198.21.4.205]:2515) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jb1JH-00035A-4j for qemu-devel@nongnu.org; Tue, 19 May 2020 08:25:27 -0400 Received: by filterdrecv-p3iad2-8ddf98858-xxtk7 with SMTP id filterdrecv-p3iad2-8ddf98858-xxtk7-19-5EC3D034-6C 2020-05-19 12:25:24.920715111 +0000 UTC m=+4706274.792817300 Received: from localhost.localdomain.com (unknown) by ismtpd0002p1lon1.sendgrid.net (SG) with ESMTP id JrnbnvuhSbGAl57yO8u6Zw Tue, 19 May 2020 12:25:24.640 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sendgrid.net; h=from:subject:in-reply-to:references:to:cc:content-type: content-transfer-encoding; s=smtpapi; bh=M6xTVVbhl/MNPl1YAIqUl150kIlTpOqbu4j5fCTP0pQ=; b=q/QuKzfwm4GrziEWq8ojn5G3LHizdJdLQW6piE4YTtRwQksDLLY9TPGg9q4lktrlou5a BO+6W3h44zcq33AIcnomirwHiDROydR6hsgHmAdNM0OO6lywrQH/7Fj9GXWqhOyfCUD1qc Haw8bbPG7t7QA8rdptDad5BysqwG+n/mY= From: Raphael Norwitz Subject: [PATCH v3 01/10] Add helper to populate vhost-user message regions Date: Tue, 19 May 2020 12:25:24 +0000 (UTC) Message-Id: <1588473683-27067-2-git-send-email-raphael.norwitz@nutanix.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1588473683-27067-1-git-send-email-raphael.norwitz@nutanix.com> References: <1588473683-27067-1-git-send-email-raphael.norwitz@nutanix.com> X-SG-EID: =?us-ascii?Q?YCLURHX+pjNDm1i7d69iKyMnQi=2FdvWah9veFa8nllaoUC0ScIWrCgiaWGu43Vg?= =?us-ascii?Q?xFdB4istXUBpN9H93OJgc8zS1BYfxWzbSS+pQZx?= =?us-ascii?Q?4eS3Ew6yLV9Xqja3b7JcYrwD1gaK+Utnj4D+eYE?= =?us-ascii?Q?7Wogs9isKFPnZwmmhtkM0z5j14C7LgkpuUFG624?= =?us-ascii?Q?mrDnbuTzkDbmH2KNicWAichC71+Ogh5VJZufAxM?= =?us-ascii?Q?o6bAwivIeBkHJ3mXk2jOV6=2F9jc+zDbc+Grtlzp3?= =?us-ascii?Q?1ufuyBOs8ZWKHiwv4X+Eg=3D=3D?= To: qemu-devel@nongnu.org, mst@redhat.com, marcandre.lureau@redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.21.4.205; envelope-from=bounces+16159052-3d09-qemu-devel=nongnu.org@sendgrid.net; helo=o1.dev.nutanix.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/19 08:25:15 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: raphael.s.norwitz@gmail.com, marcandre.lureau@gmail.com, Raphael Norwitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When setting vhost-user memory tables, memory region descriptors must be copied from the vhost_dev struct to the vhost-user message. To avoid duplicating code in setting the memory tables, we should use a helper to populate this field. This change adds this helper. Signed-off-by: Raphael Norwitz --- hw/virtio/vhost-user.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index ec21e8f..ee6d1ed 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -407,6 +407,15 @@ static int vhost_user_set_log_base(struct vhost_dev *d= ev, uint64_t base, return 0; } =20 +static void vhost_user_fill_msg_region(VhostUserMemoryRegion *dst, + struct vhost_memory_region *src) +{ + assert(src !=3D NULL && dst !=3D NULL); + dst->userspace_addr =3D src->userspace_addr; + dst->memory_size =3D src->memory_size; + dst->guest_phys_addr =3D src->guest_phys_addr; +} + static int vhost_user_fill_set_mem_table_msg(struct vhost_user *u, struct vhost_dev *dev, VhostUserMsg *msg, @@ -441,12 +450,8 @@ static int vhost_user_fill_set_mem_table_msg(struct vh= ost_user *u, error_report("Failed preparing vhost-user memory table msg= "); return -1; } - msg->payload.memory.regions[*fd_num].userspace_addr =3D - reg->userspace_addr; - msg->payload.memory.regions[*fd_num].memory_size =3D - reg->memory_size; - msg->payload.memory.regions[*fd_num].guest_phys_addr =3D - reg->guest_phys_addr; + vhost_user_fill_msg_region(&msg->payload.memory.regions[*fd_nu= m], + reg); msg->payload.memory.regions[*fd_num].mmap_offset =3D offset; fds[(*fd_num)++] =3D fd; } else if (track_ramblocks) { --=20 1.8.3.1