From nobody Tue May 21 06:29:08 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=1615833003; cv=none; d=zohomail.com; s=zohoarc; b=m38aQ4Es4Oa0cqhf3iwiOo0Qd/Fefr8Fwbbyui3i4qti8RGn/S6wcu/g056l6gLsMnuham6oajqpwVojr9aLu9Vv8W8kwR0Fvb/xdCNO3hwwftgYg2gEMELExxjQ+3DQOdsFqxHVugNPqLHZ9BSqsi7WT9HxjHBux7fn9Us2uTM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615833003; 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=vK1QZj7k68qjLbqP3k+7SfxOpHyl4uFfCbdCX9CaZwY=; b=bn8k+Vv4oeBUT0ftKw58Evt+ieU+xfeY76YpeDWUVe69JEjEwbhtk3AqBQQBsldOQfSzSaiawVG8XK1S5hb/fFsDSR3EFRmfVSvyqf/Lb3tIFj8Ee8yjZsqSytBdTryr0ZqzuZp0T8JPCQ/CzBaqd4A12rPbB93KtfhtuRveuas= 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 1615833003094167.49171642972033; Mon, 15 Mar 2021 11:30:03 -0700 (PDT) Received: from localhost ([::1]:57988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lLryb-0008Eu-VO for importer@patchew.org; Mon, 15 Mar 2021 14:30:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lLrZF-0002b5-1H; Mon, 15 Mar 2021 14:03:49 -0400 Received: from mail-pl1-f170.google.com ([209.85.214.170]:36080) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lLrZD-0000qY-3p; Mon, 15 Mar 2021 14:03:48 -0400 Received: by mail-pl1-f170.google.com with SMTP id z5so15709996plg.3; Mon, 15 Mar 2021 11:03:46 -0700 (PDT) Received: from localhost.localdomain ([73.93.153.95]) by smtp.gmail.com with ESMTPSA id y194sm14267842pfb.21.2021.03.15.11.03.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Mar 2021 11:03:44 -0700 (PDT) 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=vK1QZj7k68qjLbqP3k+7SfxOpHyl4uFfCbdCX9CaZwY=; b=LwyQIsDx3XXv9qYNiegzB7zTRDtjJCtSx2XpKZsnxepjPCseVC1Hd/LSw/E/UkkN8o JZnH/Kgld7n1tAl77VVSaDsRGo0KrTy8rzR19p4b5X60dDwqzOzOUmBgv61GnVC1FDw+ Pb2rC8yjXPNI0Acf4H7rubFYIvngrXB0FCEyW2fu/7pTZyfxj6vQi09RH7i5FQ9zsmLr HkrC+2U/njXuSZAWhdOC9ylU2gy4aAShFO+6nXfh6Lu5R/rvz5WHZ+j14y5iKtTIox8+ 92tTW9e6MAdX4gQouDP9hdopmsC7lRFMXRK3GEiOYwApHPmyzinEnC9G6wO1LyvzmXY9 9TPA== X-Gm-Message-State: AOAM532IF+tp+cC09R4G42g/qNzAx3IDzn4x2HsYrgVY5Rui0ouuBIFx DMwy1MQg503Fg+pLNTOELLCbAXNquzA= X-Google-Smtp-Source: ABdhPJz18zTTyglW1syFSZf4FXLYNGH9Ec1VO6IW1bseuSrb1chW0JvjBccaLLzI2DfH7svfiZRGrw== X-Received: by 2002:a17:902:a707:b029:e6:52fd:a14d with SMTP id w7-20020a170902a707b02900e652fda14dmr13391282plq.34.1615831425123; Mon, 15 Mar 2021 11:03:45 -0700 (PDT) From: Joelle van Dyne To: qemu-devel@nongnu.org Subject: [PATCH v3 1/4] block: feature detection for host block support Date: Mon, 15 Mar 2021 11:03:38 -0700 Message-Id: <20210315180341.31638-2-j@getutm.app> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210315180341.31638-1-j@getutm.app> References: <20210315180341.31638-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.214.170; envelope-from=osy86github@gmail.com; helo=mail-pl1-f170.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.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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 a7d2dd429d..59c7c56366 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 Tue May 21 06:29:08 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=1615833838; cv=none; d=zohomail.com; s=zohoarc; b=ZVL9hphnkFSxcu8/Cw4BMaPb2Ri2lRBVcZZqBqbWQWnyXntZ6wcrtZ+hyGkLrVR9IhfqXng4sSCAZnEL5tSfztkPiuknCnLVjVS7NZKtWqTxkG9Y/lkNI2pRGvyAnDWUVO73LQSpdEBjmMikxdC2JwTCN6HsAQunYejZ8rSee7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615833838; h=Content-Type: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=Mxj+g6b6U5ElCsYWP8nPrTN3O8eushUcHmHZFOrnJuo=; b=aDpg7WTnTqqQQkIyyyeM1xwNXxNomcmN9hJvBKHtgoYzRR/FqDU5XSO10fRoxwNcRJ3me8QycYqAUIruyTZ299sYYz07SOLEBWh0wkGa8Nvhr3lLcA9heaOXWPgfUqnlxitLeuRVhC5+DMNDscfMxrJCsF7Jdom2w7ngY0rd2ts= 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 161583383844377.34209167979816; Mon, 15 Mar 2021 11:43:58 -0700 (PDT) Received: from localhost ([::1]:47286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lLsC5-0002Qh-8S for importer@patchew.org; Mon, 15 Mar 2021 14:43:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lLrZF-0002bJ-Rl; Mon, 15 Mar 2021 14:03:50 -0400 Received: from mail-pl1-f170.google.com ([209.85.214.170]:37503) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lLrZE-0000r0-5I; Mon, 15 Mar 2021 14:03:49 -0400 Received: by mail-pl1-f170.google.com with SMTP id 30so11138994ple.4; Mon, 15 Mar 2021 11:03:47 -0700 (PDT) Received: from localhost.localdomain ([73.93.153.95]) by smtp.gmail.com with ESMTPSA id y194sm14267842pfb.21.2021.03.15.11.03.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Mar 2021 11:03:46 -0700 (PDT) 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=Mxj+g6b6U5ElCsYWP8nPrTN3O8eushUcHmHZFOrnJuo=; b=TCUZctHZVQZnjqvcCrST69hhASN48l2Rk79HJRZ2h/WhX7HjaUzDlFOWYT2EzmSU0m v6xhwxD7KL4bo/Z3G5EqnApi5KfukcPlk+repkRFv0dAeev0Gwq44lf8KkCi/79I0xaZ Mbf7QoTqvaFaEP6R4Fg5RMbO4xfpMj1PzuhI7f/5TXkcZXv3E5FGOLlFQ6mBq+nUCG9g mWiNqbE94t8hGgsdGvXtO+R/G5uid+t6tEuoWlWp+4TmDhzoEMgSkVuV2dYeuovGDTbK BGE6nBUa2KZzyoag59VPbbb81Y9JhXKQy6QbQOPVlsrCqjVUCsYmbB5Q66C76E4N+y/g +JfA== X-Gm-Message-State: AOAM530JPev5uwRHrxQ3JDmFBeAKEbo3MfHgb6OV8vVnNbpN+XwmE5cU 0Xw2s3PcqT+CeAlVhH0yiCYqhEaLGCg= X-Google-Smtp-Source: ABdhPJwHb1bjLHsnGffyzH0BVf16Tlw4a8u1VPvtfEWZSaRUHs6ZxNktU7s2TZB4UyA51JWJZbgZvA== X-Received: by 2002:a17:903:3053:b029:e6:5cde:bef with SMTP id u19-20020a1709033053b02900e65cde0befmr12525324pla.81.1615831426502; Mon, 15 Mar 2021 11:03:46 -0700 (PDT) From: Joelle van Dyne To: qemu-devel@nongnu.org Subject: [PATCH v3 2/4] block: check for sys/disk.h Date: Mon, 15 Mar 2021 11:03:39 -0700 Message-Id: <20210315180341.31638-3-j@getutm.app> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210315180341.31638-1-j@getutm.app> References: <20210315180341.31638-1-j@getutm.app> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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.214.170; envelope-from=osy86github@gmail.com; helo=mail-pl1-f170.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.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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 , Peter Maydell , "open list:Block layer core" , Max Reitz , Joelle van Dyne , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Some BSD platforms do not have this header. Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 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 59c7c56366..2c01e2494c 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 f377158c42..c9729bdf21 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 Tue May 21 06:29:08 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=1615833227; cv=none; d=zohomail.com; s=zohoarc; b=jFkbqZMCULz7zDQyI2e8P63kBJ0ubm9HeTdo3MM++OYCWc0Thktr7NBTsSuVzMSNbhFsI2FiCjdtE7pKiaF45c+mmNWxdkxj7LubR1PbS7ty8W11sgCPqay1KHnyM5AI3ZAYTTzKExotcOLJR5irjykD4DpHtHVF6vSivInnk+I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615833227; 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=fWWeJn6aLiPnfFIqTJdojW7MYsA8Ah6EYQcBQWFcLVQ=; b=QcXhdCilMb049gfPFpNlJNGDPkAZ/sesM2NhdaA7fmuyTUoGFPkq0oUBXY8lyCpi+qHTtAJzL0blbAUR85h4whIhtBo09zohJOhYGp58s4X8h5Diat1C9pdXIoDt8cNJfbcaRNVYdH9r92evvB8OdsklF6NIZtUR3kJwh1/9Gl8= 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 1615833227518823.8801774861242; Mon, 15 Mar 2021 11:33:47 -0700 (PDT) Received: from localhost ([::1]:39590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lLs2E-0003zB-Cp for importer@patchew.org; Mon, 15 Mar 2021 14:33:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lLrZI-0002d2-3g; Mon, 15 Mar 2021 14:03:52 -0400 Received: from mail-pl1-f180.google.com ([209.85.214.180]:45299) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lLrZG-0000rY-0S; Mon, 15 Mar 2021 14:03:51 -0400 Received: by mail-pl1-f180.google.com with SMTP id u18so15675693plc.12; Mon, 15 Mar 2021 11:03:49 -0700 (PDT) Received: from localhost.localdomain ([73.93.153.95]) by smtp.gmail.com with ESMTPSA id y194sm14267842pfb.21.2021.03.15.11.03.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Mar 2021 11:03:47 -0700 (PDT) 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=fWWeJn6aLiPnfFIqTJdojW7MYsA8Ah6EYQcBQWFcLVQ=; b=hiy41nsQVJZXkF9JB0y7RfL02FSsM/stkuICt8c6kiMQwGlSUBSUmxFOEFFBcnnANT gv/27SkAjOgupckyovj8xSh4gswDuAZm1D9i6GrIIByfmJmn+zJya6QztQcbnSmz6+ON KzhwHeqg1MJx6YMi2Ve8dzB11Qubyz9dzKDpIOmCp9o6jdl0iIuVkRBV/a7FHU7H8eiC oOuvSMD/pfxHLwKM5QDRwu1/6nOB81+0EcTyv5/LOK7sEit6HdSo0VK1asDAV9zG1Qmy Jghszbz6muGxMWe84Z5mpy7h1VOBU310g6xEFnKPwbUXRYTsKyhTMOQ9uDVwuoNHpwlK ig1A== X-Gm-Message-State: AOAM533OOIs+HqrNukGzkyafXhudsuqjHFwrRZZ5jYHID1aQxF8bxfvt 9ltyK1DvQCPGpfeQd71b9FBW2dfkVcY= X-Google-Smtp-Source: ABdhPJwjuNrcZLthjcclIG3nWifYSlAYUhuyCteglbWW6e6l60WWBqXNnQhULkeMlTYBy31/x0uzkQ== X-Received: by 2002:a17:90a:4498:: with SMTP id t24mr324674pjg.78.1615831428023; Mon, 15 Mar 2021 11:03:48 -0700 (PDT) From: Joelle van Dyne To: qemu-devel@nongnu.org Subject: [PATCH v3 3/4] block: detect DKIOCGETBLOCKCOUNT/SIZE before use Date: Mon, 15 Mar 2021 11:03:40 -0700 Message-Id: <20210315180341.31638-4-j@getutm.app> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210315180341.31638-1-j@getutm.app> References: <20210315180341.31638-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.214.180; envelope-from=osy86github@gmail.com; helo=mail-pl1-f180.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.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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 , Peter Maydell , "open list:raw" , Max Reitz , Joelle van Dyne , Warner Losh 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 Reviewed-by: Peter Maydell Signed-off-by: Joelle van Dyne --- block/file-posix.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index d1ab3180ff..2a14b881d0 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2326,8 +2326,11 @@ 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)) + if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size)) { + size =3D 0; + } #elif defined(DIOCGPART) { struct partinfo pi; @@ -2336,9 +2339,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 +2347,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 Tue May 21 06:29:08 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=1615833326; cv=none; d=zohomail.com; s=zohoarc; b=bVefJxi5XiEdzphA9AWanYzLODXwuXPAiwnqgUP65PM5whl7lEj/rWEdn55HQM7tRRESKKaO9NqRGHtRYF2WlvcSwp/p89/7jHEnj7bMqmESZK43/cDElqgbtJGtyQK2WHdaAYqiv1yH3L+6S+EP3mw0mekbPZDt0N99Cnub/a0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615833326; h=Content-Type: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=UlNk3VmiVhHOUjDbi+C6ukV9Ev85CAPrYpeZZndNefY=; b=YW3MLYj7kzCGy7begZQbkjPffPCjq0pHSew4mXlH+eVBaswy5T9OsgaNgZct2brCwBv8MHS3bZMAgGDCFU1Fng0wPMrAPmnM1NG8xEC3KPgs/bJcFnCfOtznwv6RCoqEfn511q0NFtVPaBxQUg6mlcrxTEKeTF160CwiCp0MPPM= 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 1615833326457761.5714430253845; Mon, 15 Mar 2021 11:35:26 -0700 (PDT) Received: from localhost ([::1]:47846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lLs3p-0007Mz-9W for importer@patchew.org; Mon, 15 Mar 2021 14:35:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lLrZI-0002dk-OJ for qemu-devel@nongnu.org; Mon, 15 Mar 2021 14:03:52 -0400 Received: from mail-pj1-f44.google.com ([209.85.216.44]:50782) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lLrZG-0000sL-NC for qemu-devel@nongnu.org; Mon, 15 Mar 2021 14:03:52 -0400 Received: by mail-pj1-f44.google.com with SMTP id gb6so9232225pjb.0 for ; Mon, 15 Mar 2021 11:03:50 -0700 (PDT) Received: from localhost.localdomain ([73.93.153.95]) by smtp.gmail.com with ESMTPSA id y194sm14267842pfb.21.2021.03.15.11.03.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Mar 2021 11:03:48 -0700 (PDT) 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=UlNk3VmiVhHOUjDbi+C6ukV9Ev85CAPrYpeZZndNefY=; b=qloSYuc2xbKKaypI4rMzMmR1JH+5GvSUIgthxhKlUiWErGgr/V7HiJtKw7ZFVFJ4V8 hPrjx75pK1nDnjUM69Ai8FwQzeexDv9LE6NUg45svOdmNTTYpQbS4fpTFV3Amo+yM0hZ DKUFNTPlO8uqh5PwnS32aUj4HAx6LejxU2Ig4XxkIuVsSrISUifYMXclB1BXlKhFCp+Q YsYpY18cogcRBTlNSh3fVtdRpmtUj4xbogHnWyvoD39AmQixftRYgEMPXuJISfNyMuUF AlKGAJrJge2txtcwudQN9CgjZlrG1OLrmvkViH+ShuTfwNOp0SQQWkakN588Rm2If0qL gJvw== X-Gm-Message-State: AOAM530qgejxtdlSeFIIY38OJGUTaLKOvza53kI2sXGa9xQPCoK9sNEE SZrHH+Ck0b2o5XtkZA7VVjSjoso9eag= X-Google-Smtp-Source: ABdhPJz8L417lEoskluSgmA/LuWCbRyJa3yy7gDYvkFHhpxwd1tiSUHCup/Ykfd7QUCJ8DRwSyrs+g== X-Received: by 2002:a17:90a:9f4a:: with SMTP id q10mr281425pjv.113.1615831429193; Mon, 15 Mar 2021 11:03:49 -0700 (PDT) From: Joelle van Dyne To: qemu-devel@nongnu.org Subject: [PATCH v3 4/4] slirp: feature detection for smbd Date: Mon, 15 Mar 2021 11:03:41 -0700 Message-Id: <20210315180341.31638-5-j@getutm.app> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210315180341.31638-1-j@getutm.app> References: <20210315180341.31638-1-j@getutm.app> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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.44; envelope-from=osy86github@gmail.com; helo=mail-pj1-f44.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.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: Samuel Thibault , Jason Wang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joelle van Dyne Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Replace Windows specific macro with a more generic feature detection macro. Allows slirp smb feature to be disabled manually as well. Acked-by: Samuel Thibault Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Joelle van Dyne --- configure | 26 +++++++++++++++++++++++--- meson.build | 2 +- net/slirp.c | 16 ++++++++-------- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/configure b/configure index f7d022a5db..7d765639e6 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 2c01e2494c..7ebaa4d4b0 100644 --- a/meson.build +++ b/meson.build @@ -2437,7 +2437,7 @@ summary_info +=3D {'genisoimage': config_host['= GENISOIMAGE']} if targetos =3D=3D 'windows' and config_host.has_key('CONFIG_GUEST_AGENT') summary_info +=3D {'wixl': wixl.found() ? wixl.full_path() : = false} endif -if slirp_opt !=3D 'disabled' +if slirp_opt !=3D 'disabled' and 'CONFIG_SLIRP_SMBD' in config_host summary_info +=3D {'smbd': config_host['CONFIG_SMBD_COMMAND']} endif summary(summary_info, bool_yn: true, section: 'Host binaries') 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