From nobody Wed Nov 5 20:18:39 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537776935401280.3851525498367; Mon, 24 Sep 2018 01:15:35 -0700 (PDT) Received: from localhost ([::1]:44007 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g4M1d-0001Jk-32 for importer@patchew.org; Mon, 24 Sep 2018 04:15:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58389) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g4M0p-0000y6-8A for qemu-devel@nongnu.org; Mon, 24 Sep 2018 04:14:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g4M0l-0002ii-8l for qemu-devel@nongnu.org; Mon, 24 Sep 2018 04:14:35 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:44443) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g4M0k-0002i9-Vz for qemu-devel@nongnu.org; Mon, 24 Sep 2018 04:14:31 -0400 Received: by mail-pf1-x443.google.com with SMTP id k21-v6so8693740pff.11 for ; Mon, 24 Sep 2018 01:14:30 -0700 (PDT) Received: from localhost.localdomain ([104.132.146.110]) by smtp.gmail.com with ESMTPSA id l85-v6sm59146640pfk.34.2018.09.24.01.14.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Sep 2018 01:14:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=JDEqT1ePwwVW4WJfH6qGRNun3CdgvDlP9cAaW1zTOII=; b=RCMiXnFoqec90YfowEll5UdBBVFyf8fB8w630TWz4s3ArOzvdCpryctmwxcNiH0RpV mNyakPpPO0dZ4LFzaAtWK3H2LRhVWkDCb/Mxbrrr7c2XCxTXEhcCVH5Nb6qgTRvxEHJi VdpElrf9hh0FQEU4f/1Rifn1269+zit7dCsqViL4vriMB+oya3VXXYXrZ3Wtb6b1atVz LnQnnmAmEz5eTBRWO+xx/BcD+Bqqa18DlfiUbjQ4Ta/gbFW7O9FnwQUhh3Cc0lH3VO24 EeX/93f8FEfmZQKUkkEE86tsh9Tj7wT2/CbcNHFhe40bAXOSTQd5hbNFw7lJ3fIzdK0U Xehw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=JDEqT1ePwwVW4WJfH6qGRNun3CdgvDlP9cAaW1zTOII=; b=TOM2NPo5XGCW25axRCK/+En7cVjFQp737/Ib3Qfoix3rERU9OGRvWYrKo72Crp1NL7 k/q/Jvpfp8z5RcBUAzh82rsjKTmgNuW6H+ohLvxlswFn30NOO0ts7DHMiH+6b3iIllVW zTpB2ds2SfMlCSOFkozV106Sj57dWgR9PfZaphQujzrfukaIAwfMDAcTWsMZ0Dst7GbB L2J4C8CiQge+aX06Vz1ATIwHc2qhuGgokYgkjHYs7xMsxepHingAkvhNWZBzyj1HuHoi 40Gxn6MTL9BkfUba13wumpHnS0fWaenCKeZuoRQ3198kT2557B8xu+uhJphwwJbfu0yK r/ag== X-Gm-Message-State: ABuFfojy6EVHv95aEH496wkh5/f2QD0A2r3Hjr8HYzlWEH7BEXoV5f/q UDa7KMCPqBKDFYp3YhywUxbMrPur+8k= X-Google-Smtp-Source: ACcGV62THkn0z9AFM4TCl1pWafbFkb+M7I9mUjRJIXZWxNWqpBRkjApWLHythCwU4pwMYxMZYQEBGw== X-Received: by 2002:a63:8a41:: with SMTP id y62-v6mr8473896pgd.420.1537776869211; Mon, 24 Sep 2018 01:14:29 -0700 (PDT) From: hikarupsp@gmail.com To: qemu-devel@nongnu.org Date: Mon, 24 Sep 2018 17:13:03 +0900 Message-Id: <20180924081304.19475-1-hikarupsp@gmail.com> X-Mailer: git-send-email 2.15.2 (Apple Git-101.1) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [PATCH] hostmem-file: make available memory-backend-file on macOS hosts X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Peter Crosthwaite , Hikaru Nishida , Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Hikaru Nishida Before this change, memory-backend-file object is invalid for macOS hosts because hostmem-file.c is compiled only on Linux hosts. However, macOS hosts can support memory-backend-file object in the same way as on Linux hosts. This patch makes hostmem-file.c and related functions to be compiled on macOS hosts as well to make available memory-backend-file on macOS. Signed-off-by: Hikaru Nishida --- backends/Makefile.objs | 1 + backends/hostmem-file.c | 2 +- exec.c | 4 ++-- include/exec/memory.h | 2 +- memory.c | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/backends/Makefile.objs b/backends/Makefile.objs index ad7c0325ed..a0558a21d9 100644 --- a/backends/Makefile.objs +++ b/backends/Makefile.objs @@ -5,6 +5,7 @@ common-obj-$(CONFIG_TPM) +=3D tpm.o =20 common-obj-y +=3D hostmem.o hostmem-ram.o common-obj-$(CONFIG_LINUX) +=3D hostmem-file.o +common-obj-$(CONFIG_DARWIN) +=3D hostmem-file.o =20 common-obj-y +=3D cryptodev.o common-obj-y +=3D cryptodev-builtin.o diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index 2476dcb435..e12ec9538a 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -51,7 +51,7 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Err= or **errp) error_setg(errp, "mem-path property not set"); return; } -#ifndef CONFIG_LINUX +#if !defined(CONFIG_LINUX) && !defined(CONFIG_DARWIN) error_setg(errp, "-mem-path not supported on this host"); #else if (!host_memory_backend_mr_inited(backend)) { diff --git a/exec.c b/exec.c index 6826c8337d..602da77fb8 100644 --- a/exec.c +++ b/exec.c @@ -1734,7 +1734,7 @@ long qemu_getrampagesize(void) } #endif =20 -#ifdef __linux__ +#if defined(CONFIG_LINUX) || defined(CONFIG_DARWIN) static int64_t get_file_size(int fd) { int64_t size =3D lseek(fd, 0, SEEK_END); @@ -2230,7 +2230,7 @@ static void ram_block_add(RAMBlock *new_block, Error = **errp, bool shared) } } =20 -#ifdef __linux__ +#if defined(CONFIG_LINUX) || defined(CONFIG_DARWIN) RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr, uint32_t ram_flags, int fd, Error **errp) diff --git a/include/exec/memory.h b/include/exec/memory.h index eb4f2fb249..86d6696306 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -633,7 +633,7 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr, uint64_t length, void *host), Error **errp); -#ifdef __linux__ +#if defined(CONFIG_LINUX) || defined(CONFIG_DARWIN) =20 /** * memory_region_init_ram_from_file: Initialize RAM memory region with a diff --git a/memory.c b/memory.c index 9b73892768..88422c3cac 100644 --- a/memory.c +++ b/memory.c @@ -1545,7 +1545,7 @@ void memory_region_init_resizeable_ram(MemoryRegion *= mr, mr->dirty_log_mask =3D tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0; } =20 -#ifdef __linux__ +#if defined(CONFIG_LINUX) || defined(CONFIG_DARWIN) void memory_region_init_ram_from_file(MemoryRegion *mr, struct Object *owner, const char *name, --=20 2.15.2 (Apple Git-101.1)