From nobody Mon May 20 23:49:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1615186223; cv=none; d=zohomail.com; s=zohoarc; b=MjpO6eyaQfKCDtVXJqLtAlKsdtbg17bQN0vGRNwGAhsxVWE1uXGIiN/iKxl8c9lpQHYXLvFK+SolNpCiYkJ+sSsJASRt5xEn7OaH9u+PdpYtfQ9JpvqNt/QsBtVvFiQDSgiie/Xisw0Y9qCJHRDLLYq8MLnvP66SAyY9iSfP7Sk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615186223; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9WWcwh06/gRzc2Cz5zgitfkX4d70VqHv9apQwwyvZEk=; b=BmnH6u1ACSiF20BeoCiE0349RXF8LrOYWD0bznkJEYHG8seVn8a6KIsO4aheLBzQF7MHJlAROVmxDmujOFuRW7icgLHr9/O6l4JtHj9RebPhgt9BH60uBIyLp7SNjov7Rqjf4lcnTEnE2h/ozmly6hZ6Y1oW1TgrCY4VaY026SI= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1615186223360296.83017210905643; Sun, 7 Mar 2021 22:50:23 -0800 (PST) Received: from localhost ([::1]:44112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJ9ig-0006HX-60 for importer@patchew.org; Mon, 08 Mar 2021 01:50:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJ9gr-0004IZ-3h; Mon, 08 Mar 2021 01:48:29 -0500 Received: from mail-pf1-f175.google.com ([209.85.210.175]:44818) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJ9gp-0007oU-E9; Mon, 08 Mar 2021 01:48:28 -0500 Received: by mail-pf1-f175.google.com with SMTP id t29so6411125pfg.11; Sun, 07 Mar 2021 22:48:26 -0800 (PST) Received: from localhost.localdomain ([73.93.155.14]) by smtp.gmail.com with ESMTPSA id i17sm426943pfq.135.2021.03.07.22.48.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Mar 2021 22:48:25 -0800 (PST) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=9WWcwh06/gRzc2Cz5zgitfkX4d70VqHv9apQwwyvZEk=; b=MXNhrvjv3i9SS3C42SOAQxRwX4WzFbsF6FNC4lLGTCO17eIYhtMkAJhPAVvIrCCRhF Iq+2IkhmSBrmon6XERYvbW3q8O8IMG2OCV0s+GzmFFm/PodrGndt/SsMAseOuHgjCOyI GMk+8IKbOjbd4lE8l2UO5ws6AROgf9mCDwp6w8/DyFzfsvFPgArAkGeMAkchMoJSCP0W NOu+eEW32BEBYUP9rwR3varICOe1Sf6ziGY/InDDXQInklr3GFpxWM3EtXTDwifbf4qh ycnv/h+jiVrok6myCfEKTKBk6sxgHsyzRqVNJxRmVAi6+otbckkHO63LVs1Fu5VRI6Ao xEEg== X-Gm-Message-State: AOAM530tdyGXngSQORz4hRjKftUtYRC1nwVIMMNs6hFcJY4PI/uiiOQk sdKm7YR9U9bJzXORNTge62IHNZkG9jw= X-Google-Smtp-Source: ABdhPJz5GVDmxEMxhQddYsCToWTolMe4E+qiFSfcbUH/rgjjViEfQdneXVJ3OueKZrSySd6FC2/UsA== X-Received: by 2002:a62:2b85:0:b029:1ee:e2a2:cbee with SMTP id r127-20020a622b850000b02901eee2a2cbeemr19159725pfr.78.1615186105541; Sun, 07 Mar 2021 22:48:25 -0800 (PST) From: Joelle van Dyne To: qemu-devel@nongnu.org Subject: [PATCH 1/4] block: feature detection for host block support Date: Sun, 7 Mar 2021 22:48:18 -0800 Message-Id: <20210308064821.81427-2-j@getutm.app> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210308064821.81427-1-j@getutm.app> References: <20210308064821.81427-1-j@getutm.app> MIME-Version: 1.0 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=209.85.210.175; envelope-from=osy86github@gmail.com; helo=mail-pf1-f175.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no 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: Kevin Wolf , "open list:raw" , Markus Armbruster , Max Reitz , Joelle van Dyne Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" On Darwin (iOS), there are no system level APIs for directly accessing host block devices. We detect this at configure time. Signed-off-by: Joelle van Dyne --- meson.build | 6 +++++- qapi/block-core.json | 10 +++++++--- block/file-posix.c | 33 ++++++++++++++++++++++----------- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/meson.build b/meson.build index 81d760d6e8..0e53876f69 100644 --- a/meson.build +++ b/meson.build @@ -181,7 +181,7 @@ if targetos =3D=3D 'windows' include_directories: include_directo= ries('.')) elif targetos =3D=3D 'darwin' coref =3D dependency('appleframeworks', modules: 'CoreFoundation') - iokit =3D dependency('appleframeworks', modules: 'IOKit') + iokit =3D dependency('appleframeworks', modules: 'IOKit', required: fals= e) elif targetos =3D=3D 'sunos' socket =3D [cc.find_library('socket'), cc.find_library('nsl'), @@ -1056,6 +1056,9 @@ if get_option('cfi') add_global_link_arguments(cfi_flags, native: false, language: ['c', 'cpp= ', 'objc']) endif =20 +have_host_block_device =3D (targetos !=3D 'darwin' or + cc.has_header('IOKit/storage/IOMedia.h')) + ################# # config-host.h # ################# @@ -1149,6 +1152,7 @@ config_host_data.set('HAVE_PTY_H', cc.has_header('pty= .h')) config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h')) config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h')) config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', pre= fix: '#include ')) +config_host_data.set('HAVE_HOST_BLOCK_DEVICE', have_host_block_device) =20 config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#= include ')) =20 diff --git a/qapi/block-core.json b/qapi/block-core.json index 9f555d5c1d..0c2cd9e689 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -959,7 +959,8 @@ 'discriminator': 'driver', 'data': { 'file': 'BlockStatsSpecificFile', - 'host_device': 'BlockStatsSpecificFile', + 'host_device': { 'type': 'BlockStatsSpecificFile', + 'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' }, 'nvme': 'BlockStatsSpecificNvme' } } =20 ## @@ -2863,7 +2864,9 @@ { 'enum': 'BlockdevDriver', 'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs', 'cloop', 'compress', 'copy-on-read', 'dmg', 'file', 'ftp', 'ft= ps', - 'gluster', 'host_cdrom', 'host_device', 'http', 'https', 'iscs= i', + 'gluster', 'host_cdrom', + {'name': 'host_device', 'if': 'defined(HAVE_HOST_BLOCK_DEVICE)= ' }, + 'http', 'https', 'iscsi', 'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallel= s', 'preallocate', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd', { 'name': 'replication', 'if': 'defined(CONFIG_REPLICATION)' }, @@ -4066,7 +4069,8 @@ 'ftps': 'BlockdevOptionsCurlFtps', 'gluster': 'BlockdevOptionsGluster', 'host_cdrom': 'BlockdevOptionsFile', - 'host_device':'BlockdevOptionsFile', + 'host_device': { 'type': 'BlockdevOptionsFile', + 'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' }, 'http': 'BlockdevOptionsCurlHttp', 'https': 'BlockdevOptionsCurlHttps', 'iscsi': 'BlockdevOptionsIscsi', diff --git a/block/file-posix.c b/block/file-posix.c index 05079b40ca..d1ab3180ff 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -42,6 +42,8 @@ #include "scsi/constants.h" =20 #if defined(__APPLE__) && (__MACH__) +#include +#if defined(HAVE_HOST_BLOCK_DEVICE) #include #include #include @@ -52,6 +54,7 @@ //#include #include #include +#endif /* defined(HAVE_HOST_BLOCK_DEVICE) */ #endif =20 #ifdef __sun__ @@ -181,7 +184,17 @@ typedef struct BDRVRawReopenState { bool check_cache_dropped; } BDRVRawReopenState; =20 -static int fd_open(BlockDriverState *bs); +static int fd_open(BlockDriverState *bs) +{ + BDRVRawState *s =3D bs->opaque; + + /* this is just to ensure s->fd is sane (its called by io ops) */ + if (s->fd >=3D 0) { + return 0; + } + return -EIO; +} + static int64_t raw_getlength(BlockDriverState *bs); =20 typedef struct RawPosixAIOData { @@ -3032,6 +3045,7 @@ static BlockStatsSpecific *raw_get_specific_stats(Blo= ckDriverState *bs) return stats; } =20 +#if defined(HAVE_HOST_BLOCK_DEVICE) static BlockStatsSpecific *hdev_get_specific_stats(BlockDriverState *bs) { BlockStatsSpecific *stats =3D g_new(BlockStatsSpecific, 1); @@ -3041,6 +3055,7 @@ static BlockStatsSpecific *hdev_get_specific_stats(Bl= ockDriverState *bs) =20 return stats; } +#endif /* HAVE_HOST_BLOCK_DEVICE */ =20 static QemuOptsList raw_create_opts =3D { .name =3D "raw-create-opts", @@ -3265,6 +3280,8 @@ BlockDriver bdrv_file =3D { /***********************************************/ /* host device */ =20 +#if defined(HAVE_HOST_BLOCK_DEVICE) + #if defined(__APPLE__) && defined(__MACH__) static kern_return_t GetBSDPath(io_iterator_t mediaIterator, char *bsdPath, CFIndex maxPathSize, int flags); @@ -3557,16 +3574,6 @@ hdev_co_ioctl(BlockDriverState *bs, unsigned long in= t req, void *buf) } #endif /* linux */ =20 -static int fd_open(BlockDriverState *bs) -{ - BDRVRawState *s =3D bs->opaque; - - /* this is just to ensure s->fd is sane (its called by io ops) */ - if (s->fd >=3D 0) - return 0; - return -EIO; -} - static coroutine_fn int hdev_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes) { @@ -3890,6 +3897,8 @@ static BlockDriver bdrv_host_cdrom =3D { }; #endif /* __FreeBSD__ */ =20 +#endif /* HAVE_HOST_BLOCK_DEVICE */ + static void bdrv_file_init(void) { /* @@ -3897,6 +3906,7 @@ static void bdrv_file_init(void) * registered last will get probed first. */ bdrv_register(&bdrv_file); +#if defined(HAVE_HOST_BLOCK_DEVICE) bdrv_register(&bdrv_host_device); #ifdef __linux__ bdrv_register(&bdrv_host_cdrom); @@ -3904,6 +3914,7 @@ static void bdrv_file_init(void) #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) bdrv_register(&bdrv_host_cdrom); #endif +#endif /* HAVE_HOST_BLOCK_DEVICE */ } =20 block_init(bdrv_file_init); --=20 2.28.0 From nobody Mon May 20 23:49:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1615186304; cv=none; d=zohomail.com; s=zohoarc; b=XO/aSBh8Fn9PLE7VBAJkgnK30tVKw4y3gU21cesTey2t4mks0JMPOu0pa/7uA5bA1J24wbaC2W9AfYFH3ARKw+6NDraVcc9130Z9J3gE/RIJKnirFo00HG0+xPrldzC5b5o1PIKoY1sbzq7rdURQ2WxLhD6Zd9YHlSs4822nPgw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615186304; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QgU+W/R3FIydwYpBsWZV504V0tYBh/ETkHkfv0+pIB0=; b=e8nrTTu7uP6s6gWKPJ6KNmktPunFK6kwBuGw7hZ6qrNXveXj5c1/Og/XuwDvYOJEWbF6+wQkD7em1Ld/lJKDUIF4HV2qQ+mQPA7WzeSBlAvtEA5IqFwR86MLjVDlOC7KzAXmLDU6TvMCXmJNkcXWP/WRSQuHZVatf/mb6lns9G8= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16151863046501006.2536483804229; Sun, 7 Mar 2021 22:51:44 -0800 (PST) Received: from localhost ([::1]:50580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJ9jz-0000Xv-Gq for importer@patchew.org; Mon, 08 Mar 2021 01:51:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJ9gs-0004Jw-1j; Mon, 08 Mar 2021 01:48:30 -0500 Received: from mail-pj1-f50.google.com ([209.85.216.50]:37397) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJ9gq-0007ou-G9; Mon, 08 Mar 2021 01:48:29 -0500 Received: by mail-pj1-f50.google.com with SMTP id x7-20020a17090a2b07b02900c0ea793940so2430437pjc.2; Sun, 07 Mar 2021 22:48:27 -0800 (PST) Received: from localhost.localdomain ([73.93.155.14]) by smtp.gmail.com with ESMTPSA id i17sm426943pfq.135.2021.03.07.22.48.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Mar 2021 22:48:26 -0800 (PST) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=QgU+W/R3FIydwYpBsWZV504V0tYBh/ETkHkfv0+pIB0=; b=k4YiwgtFwx6Rohq/0biVi554Ouq+aNi8GuEA1+eLioK2ajxUdW+rfywwXoeAfMJJqF uGYQDs+lnDrZXdaTTf4z5up60HS481OveTlrwlunX9vlJnD5Fa1PZHfXcO7WtXJMF4s0 GVHl9Vw74mXJk0aX278Ed8wQroTuHtQbPm3mrdR8rHbq6uGkRQdgwxJLYXxlLT0hKgde p/CVbq+UniatphQlfiaVbaNTzPbZYl2NqS2MGN93iVzRBM4DmO0YrXK9jwRauLl/3lN7 Pd99/VpGDEYEjlEcnZNbI6TbN5qA+bBqWuvWXHdR1UhGjUY7+q9B5OOssgb+fgqsFW8q WlqA== X-Gm-Message-State: AOAM532yIgMpvf2BmwPbbFgb+VjfCbGT0Uk2vhQi8cnq8jIUMTFK85hB 1N/xVT0pYQSfgdlySLW5HDE4YjNwFY0= X-Google-Smtp-Source: ABdhPJyhADb4y/ZmujDIyLfgP2uK7Rk8Xob9CFQAzmpdgpb5QO8I+77gqyPVlWKckQ/V8KdEMTPGxg== X-Received: by 2002:a17:902:45:b029:e4:a5b2:ffa4 with SMTP id 63-20020a1709020045b02900e4a5b2ffa4mr19982410pla.18.1615186106631; Sun, 07 Mar 2021 22:48:26 -0800 (PST) From: Joelle van Dyne To: qemu-devel@nongnu.org Subject: [PATCH 2/4] block: check for sys/disk.h Date: Sun, 7 Mar 2021 22:48:19 -0800 Message-Id: <20210308064821.81427-3-j@getutm.app> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210308064821.81427-1-j@getutm.app> References: <20210308064821.81427-1-j@getutm.app> MIME-Version: 1.0 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=209.85.216.50; envelope-from=osy86github@gmail.com; helo=mail-pj1-f50.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no 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: Kevin Wolf , Joelle van Dyne , "open list:Block layer core" , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Some BSD platforms do not have this header. Signed-off-by: Joelle van Dyne --- meson.build | 1 + block.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 0e53876f69..ba0db9fa1f 100644 --- a/meson.build +++ b/meson.build @@ -1153,6 +1153,7 @@ config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_head= er('sys/ioccom.h')) config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h')) config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', pre= fix: '#include ')) config_host_data.set('HAVE_HOST_BLOCK_DEVICE', have_host_block_device) +config_host_data.set('HAVE_SYS_DISK_H', cc.has_header('sys/disk.h')) =20 config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#= include ')) =20 diff --git a/block.c b/block.c index a1f3cecd75..b2705ad225 100644 --- a/block.c +++ b/block.c @@ -54,7 +54,7 @@ #ifdef CONFIG_BSD #include #include -#ifndef __DragonFly__ +#if defined(HAVE_SYS_DISK_H) #include #endif #endif --=20 2.28.0 From nobody Mon May 20 23:49:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1615186237; cv=none; d=zohomail.com; s=zohoarc; b=Z/tMpUlOFrm6GRV05NeNbPpcZOmwdmY7OxeU0CeJFbo13CG5x/CjTy495pgqeHM5/VEKcL/TTOoRsxsueg5fLByXiJ9F2T9JahPOnX3yI+4k8U7aJbDDfLwwkSM+f1UJJ+NFGW1oC7NlNuYYA2y1ms+eFbwzYz+wI/RWD9XDq48= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615186237; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RIP/r3nyG15GF413S6T6+JeyoT6XtJQWSwQR9etpPKM=; b=Ty2JdCsmL6B3c3Pb7TCYaFosYnvcKxJEPqdwKAtXHjo8ltUIv7tFcaAwCfGI9h/7FiGUruCU3JxTVIKg3d9uwy1/9voWJ9ksFc2yiShNloQUYnVMkc8tlNebGkX8V2pNP+mdSzhtilU5RlMZP4H4LArzdnX27XxydY29DfDJRrI= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1615186237224149.89554971018538; Sun, 7 Mar 2021 22:50:37 -0800 (PST) Received: from localhost ([::1]:45526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJ9iu-0006sD-2p for importer@patchew.org; Mon, 08 Mar 2021 01:50:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJ9gs-0004M2-U5; Mon, 08 Mar 2021 01:48:31 -0500 Received: from mail-pj1-f46.google.com ([209.85.216.46]:46773) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJ9gr-0007pi-Fa; Mon, 08 Mar 2021 01:48:30 -0500 Received: by mail-pj1-f46.google.com with SMTP id q6-20020a17090a4306b02900c42a012202so2547324pjg.5; Sun, 07 Mar 2021 22:48:28 -0800 (PST) Received: from localhost.localdomain ([73.93.155.14]) by smtp.gmail.com with ESMTPSA id i17sm426943pfq.135.2021.03.07.22.48.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Mar 2021 22:48:27 -0800 (PST) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=RIP/r3nyG15GF413S6T6+JeyoT6XtJQWSwQR9etpPKM=; b=Mz3iJan40os0zPd0Iq+RxeR+1UjrjEyEnS5MA4kkQoC+vVdjw6hyn4S0OsvsFqfUrD kDXHilj5M1wBXyWadXeFYnB5YcsVgFG6qnKGW6l8OfyxLqyCIxM9oLIqadCL+xk8U20p gJAsSZ3hJdyE7MLLwc4NEC9HupG9af931/ndBCvmzUGPDIl+zf9xss0Ljyyo5+rI4y+l QWyLqrYgJbIhQl4moFxSfAjo3O9/yuNpqINR6V3eO6vcMYLNgMUrxU91d7hvQChFVoet K6h2yzftiQ4pqakq8vUb/8n8ilWvMX4WLgPqsfQIpCgJO9tyAMjY3Mbk5A2sC6FMKCci u2xw== X-Gm-Message-State: AOAM533pORIgHe0XU7JhH/DrD00g8tqzpIbMYqbfplqGM9REcJ+gjGo3 olVGloeRHsUWnV6e1rpy/ti/hp7a5rM= X-Google-Smtp-Source: ABdhPJyYhvPXyyLupgJ6Pcfc7kbd+yv+PRcz9dgNxo2B2iHrc094JOT04cDOAwgU5XYC1EIuGnfIRQ== X-Received: by 2002:a17:90a:400f:: with SMTP id u15mr22906926pjc.80.1615186107749; Sun, 07 Mar 2021 22:48:27 -0800 (PST) From: Joelle van Dyne To: qemu-devel@nongnu.org Subject: [PATCH 3/4] block: detect DKIOCGETBLOCKCOUNT/SIZE before use Date: Sun, 7 Mar 2021 22:48:20 -0800 Message-Id: <20210308064821.81427-4-j@getutm.app> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210308064821.81427-1-j@getutm.app> References: <20210308064821.81427-1-j@getutm.app> MIME-Version: 1.0 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=209.85.216.46; envelope-from=osy86github@gmail.com; helo=mail-pj1-f46.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no 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: Kevin Wolf , "open list:raw" , Joelle van Dyne , Warner Losh , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" iOS hosts do not have these defined so we fallback to the default behaviour. Co-authored-by: Warner Losh Signed-off-by: Joelle van Dyne --- block/file-posix.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index d1ab3180ff..9b6d7ddda3 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2326,8 +2326,10 @@ static int64_t raw_getlength(BlockDriverState *bs) again: #endif if (!fstat(fd, &sb) && (S_IFCHR & sb.st_mode)) { + size =3D 0; #ifdef DIOCGMEDIASIZE if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size)) + size =3D 0; #elif defined(DIOCGPART) { struct partinfo pi; @@ -2336,9 +2338,7 @@ again: else size =3D 0; } - if (size =3D=3D 0) -#endif -#if defined(__APPLE__) && defined(__MACH__) +#elif defined(DKIOCGETBLOCKCOUNT) && defined(DKIOCGETBLOCKSIZE) { uint64_t sectors =3D 0; uint32_t sector_size =3D 0; @@ -2346,19 +2346,15 @@ again: if (ioctl(fd, DKIOCGETBLOCKCOUNT, §ors) =3D=3D 0 && ioctl(fd, DKIOCGETBLOCKSIZE, §or_size) =3D=3D 0) { size =3D sectors * sector_size; - } else { - size =3D lseek(fd, 0LL, SEEK_END); - if (size < 0) { - return -errno; - } } } -#else - size =3D lseek(fd, 0LL, SEEK_END); +#endif + if (size =3D=3D 0) { + size =3D lseek(fd, 0LL, SEEK_END); + } if (size < 0) { return -errno; } -#endif #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) switch(s->type) { case FTYPE_CD: --=20 2.28.0 From nobody Mon May 20 23:49:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1615186269; cv=none; d=zohomail.com; s=zohoarc; b=hj2E1wMct5VmRRjUKStu+cwkaz7HpfYboCpBrmVF4JNKujXdqttwPXW4OwOswW7EExgZ2nxxv45AJK0KMvKq2XYUXsLHyMA0TEjSDasIbRvZVLivUO1IAd8dIfe4ZHTCYecnZJVtqa6A8CuSgSTSTxMdeKqMiB5zL8kKII6ik9Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615186269; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Xs2a0UjVEYDl/dxavkg+TRIMqJe8RB7eDD2ADiudMXg=; b=oLZBYAs9AzzkMhO4kRPXqm85QxV06aQ9TeeZ6mmdd/N3rIi0GXqvzFO0JKoCwMo1+EdYuxgrMhXBWUimxjtit9zd7Ahp3HnNLXsckB12JgqBsmeWmUHJZhDZmXLaElcgHssAcX4yGVUQqNYZe9RTiNZi0yA2LpWm386CN0jPs3M= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1615186269959471.4816663051872; Sun, 7 Mar 2021 22:51:09 -0800 (PST) Received: from localhost ([::1]:48448 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJ9jQ-00086l-Su for importer@patchew.org; Mon, 08 Mar 2021 01:51:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJ9gu-0004OQ-5t for qemu-devel@nongnu.org; Mon, 08 Mar 2021 01:48:32 -0500 Received: from mail-pg1-f177.google.com ([209.85.215.177]:33928) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJ9gs-0007qF-Bu for qemu-devel@nongnu.org; Mon, 08 Mar 2021 01:48:31 -0500 Received: by mail-pg1-f177.google.com with SMTP id l2so5808445pgb.1 for ; Sun, 07 Mar 2021 22:48:29 -0800 (PST) Received: from localhost.localdomain ([73.93.155.14]) by smtp.gmail.com with ESMTPSA id i17sm426943pfq.135.2021.03.07.22.48.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Mar 2021 22:48:28 -0800 (PST) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Xs2a0UjVEYDl/dxavkg+TRIMqJe8RB7eDD2ADiudMXg=; b=F34rbbQklUa7Zmj+JFrptfQMzEY7QkKPcFIv9arK8bXjx11atr9gKH5KWkMnMcaKXW U2Kik4OcvvtLOTuY2Q6t8iG4Qf2Ans+MsFmHyRhTfx5e41R8Ma2zzs6NV1Yl+8EopVW/ Qbbsn/0VxBpntuVhUVyYWS9mx7muH3cgYrMo2dnXY5VAEz9I8Hi37cnn1+bdBb9eHCeG /cr3UjKADMBAok4WMFsZ8fI5MEbrK/gNukPdguURNVaZ5pCkl9datjzYlNdmhZ6xZfry KN9qHozcS6RCUVHr5znEVrd7HYlUxImPooYKFeNsDmbrxsZVcSFe9bxFHyP1K8EWMkDW EoGA== X-Gm-Message-State: AOAM531a7EF0VETZ//COg1LU6O/lCROXYr41YQH+MQ5FrQ0Ma1YBB51q i1L8tp/NblKp5T50nVQpo5wlx6lAY2c= X-Google-Smtp-Source: ABdhPJyv0YQm6d9ZG3kwCTTC9E1RynZXc31IPNIHk9DnvT3x6f1E8nRC0u0tZ3jMaINxwtGYtIbMdA== X-Received: by 2002:a05:6a00:8d0:b029:1b6:3581:4f41 with SMTP id s16-20020a056a0008d0b02901b635814f41mr19368917pfu.56.1615186108781; Sun, 07 Mar 2021 22:48:28 -0800 (PST) From: Joelle van Dyne To: qemu-devel@nongnu.org Subject: [PATCH 4/4] slirp: feature detection for smbd Date: Sun, 7 Mar 2021 22:48:21 -0800 Message-Id: <20210308064821.81427-5-j@getutm.app> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210308064821.81427-1-j@getutm.app> References: <20210308064821.81427-1-j@getutm.app> MIME-Version: 1.0 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=209.85.215.177; envelope-from=osy86github@gmail.com; helo=mail-pg1-f177.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no 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: Samuel Thibault , Jason Wang , Joelle van Dyne Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Replace Windows specific macro with a more generic feature detection macro. Allows slirp smb feature to be disabled manually as well. Signed-off-by: Joelle van Dyne Acked-by: Samuel Thibault --- configure | 26 +++++++++++++++++++++++--- meson.build | 3 +++ net/slirp.c | 16 ++++++++-------- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/configure b/configure index 34fccaa2ba..8335a3e6a0 100755 --- a/configure +++ b/configure @@ -465,6 +465,7 @@ fuse_lseek=3D"auto" multiprocess=3D"auto" =20 malloc_trim=3D"auto" +slirp_smbd=3D"auto" =20 # parse CC options second for opt do @@ -834,8 +835,6 @@ do fi done =20 -: ${smbd=3D${SMBD-/usr/sbin/smbd}} - # Default objcc to clang if available, otherwise use CC if has clang; then objcc=3Dclang @@ -1560,6 +1559,10 @@ for opt do ;; --disable-multiprocess) multiprocess=3D"disabled" ;; + --enable-slirp-smbd) slirp_smbd=3Dyes + ;; + --disable-slirp-smbd) slirp_smbd=3Dno + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -1913,6 +1916,7 @@ disabled with --disable-FEATURE, default is enabled i= f available fuse FUSE block device export fuse-lseek SEEK_HOLE/SEEK_DATA support for FUSE exports multiprocess Out of process device emulation support + slirp-smbd use smbd (at path --smbd=3D*) in slirp networking =20 NOTE: The object files are built at the place where configure is launched EOF @@ -5252,6 +5256,19 @@ case "$slirp" in ;; esac =20 +# Check for slirp smbd dupport +: ${smbd=3D${SMBD-/usr/sbin/smbd}} +if test "$slirp_smbd" !=3D "no" ; then + if test "$mingw32" =3D "yes" ; then + if test "$slirp_smbd" =3D "yes" ; then + error_exit "Host smbd not supported on this platform." + fi + slirp_smbd=3Dno + else + slirp_smbd=3Dyes + fi +fi + ########################################## # check for usable __NR_keyctl syscall =20 @@ -5527,7 +5544,10 @@ fi if test "$guest_agent" =3D "yes" ; then echo "CONFIG_GUEST_AGENT=3Dy" >> $config_host_mak fi -echo "CONFIG_SMBD_COMMAND=3D\"$smbd\"" >> $config_host_mak +if test "$slirp_smbd" =3D "yes" ; then + echo "CONFIG_SLIRP_SMBD=3Dy" >> $config_host_mak + echo "CONFIG_SMBD_COMMAND=3D\"$smbd\"" >> $config_host_mak +fi if test "$vde" =3D "yes" ; then echo "CONFIG_VDE=3Dy" >> $config_host_mak echo "VDE_LIBS=3D$vde_libs" >> $config_host_mak diff --git a/meson.build b/meson.build index ba0db9fa1f..773ce512c7 100644 --- a/meson.build +++ b/meson.build @@ -2629,6 +2629,9 @@ summary_info +=3D {'pixman': pixman.found(= )} summary_info +=3D {'VTE support': config_host.has_key('CONFIG_VTE')} # TODO: add back version summary_info +=3D {'slirp support': slirp_opt =3D=3D 'disabled' ? fals= e : slirp_opt} +if slirp_opt !=3D 'disabled' and 'CONFIG_SLIRP_SMBD' in config_host + summary_info +=3D {'smbd': config_host['CONFIG_SMBD_COMMAND']} +endif summary_info +=3D {'libtasn1': config_host.has_key('CONFIG_TASN1'= )} summary_info +=3D {'PAM': config_host.has_key('CONFIG_AUTH_P= AM')} summary_info +=3D {'iconv support': iconv.found()} diff --git a/net/slirp.c b/net/slirp.c index be914c0be0..b3ded2aac1 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -27,7 +27,7 @@ #include "net/slirp.h" =20 =20 -#ifndef _WIN32 +#if defined(CONFIG_SLIRP_SMBD) #include #include #endif @@ -90,7 +90,7 @@ typedef struct SlirpState { Slirp *slirp; Notifier poll_notifier; Notifier exit_notifier; -#ifndef _WIN32 +#if defined(CONFIG_SLIRP_SMBD) gchar *smb_dir; #endif GSList *fwd; @@ -103,7 +103,7 @@ static QTAILQ_HEAD(, SlirpState) slirp_stacks =3D static int slirp_hostfwd(SlirpState *s, const char *redir_str, Error **err= p); static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **e= rrp); =20 -#ifndef _WIN32 +#if defined(CONFIG_SLIRP_SMBD) static int slirp_smb(SlirpState *s, const char *exported_dir, struct in_addr vserver_addr, Error **errp); static void slirp_smb_cleanup(SlirpState *s); @@ -367,7 +367,7 @@ static int net_slirp_init(NetClientState *peer, const c= har *model, struct in6_addr ip6_prefix; struct in6_addr ip6_host; struct in6_addr ip6_dns; -#ifndef _WIN32 +#if defined(CONFIG_SLIRP_SMBD) struct in_addr smbsrv =3D { .s_addr =3D 0 }; #endif NetClientState *nc; @@ -477,7 +477,7 @@ static int net_slirp_init(NetClientState *peer, const c= har *model, return -1; } =20 -#ifndef _WIN32 +#if defined(CONFIG_SLIRP_SMBD) if (vsmbserver && !inet_aton(vsmbserver, &smbsrv)) { error_setg(errp, "Failed to parse SMB address"); return -1; @@ -592,7 +592,7 @@ static int net_slirp_init(NetClientState *peer, const c= har *model, } } } -#ifndef _WIN32 +#if defined(CONFIG_SLIRP_SMBD) if (smb_export) { if (slirp_smb(s, smb_export, smbsrv, errp) < 0) { goto error; @@ -784,7 +784,7 @@ void hmp_hostfwd_add(Monitor *mon, const QDict *qdict) =20 } =20 -#ifndef _WIN32 +#if defined(CONFIG_SLIRP_SMBD) =20 /* automatic user mode samba server configuration */ static void slirp_smb_cleanup(SlirpState *s) @@ -899,7 +899,7 @@ static int slirp_smb(SlirpState* s, const char *exporte= d_dir, return 0; } =20 -#endif /* !defined(_WIN32) */ +#endif /* defined(CONFIG_SLIRP_SMBD) */ =20 static int guestfwd_can_read(void *opaque) { --=20 2.28.0