* [PATCH v2 0/4] Disable unsupported features on iOS hosts
@ 2021-03-09 0:27 Joelle van Dyne
2021-03-09 0:27 ` [PATCH v2 1/4] block: feature detection for host block support Joelle van Dyne
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Joelle van Dyne @ 2021-03-09 0:27 UTC (permalink / raw)
To: qemu-devel
These patches disables code that cannot be compiled or run on iOS by adding
feature/header detection at configure time.
v2:
* Broken merge where config_host['CONFIG_SMBD_COMMAND'] was duplicated.
-j
Joelle van Dyne (4):
block: feature detection for host block support
block: check for sys/disk.h
block: detect DKIOCGETBLOCKCOUNT/SIZE before use
slirp: feature detection for smbd
configure | 26 +++++++++++++++++++---
meson.build | 9 ++++++--
qapi/block-core.json | 10 ++++++---
block.c | 2 +-
block/file-posix.c | 51 +++++++++++++++++++++++++-------------------
net/slirp.c | 16 +++++++-------
6 files changed, 75 insertions(+), 39 deletions(-)
--
2.28.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 1/4] block: feature detection for host block support
2021-03-09 0:27 [PATCH v2 0/4] Disable unsupported features on iOS hosts Joelle van Dyne
@ 2021-03-09 0:27 ` Joelle van Dyne
2021-03-09 0:27 ` [PATCH v2 2/4] block: check for sys/disk.h Joelle van Dyne
` (2 subsequent siblings)
3 siblings, 0 replies; 13+ messages in thread
From: Joelle van Dyne @ 2021-03-09 0:27 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, open list:raw, Markus Armbruster, Max Reitz, Joelle van Dyne
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 <j@getutm.app>
---
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 == 'windows'
include_directories: include_directories('.'))
elif targetos == 'darwin'
coref = dependency('appleframeworks', modules: 'CoreFoundation')
- iokit = dependency('appleframeworks', modules: 'IOKit')
+ iokit = dependency('appleframeworks', modules: 'IOKit', required: false)
elif targetos == 'sunos'
socket = [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
+have_host_block_device = (targetos != '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', prefix: '#include <stdlib.h>'))
+config_host_data.set('HAVE_HOST_BLOCK_DEVICE', have_host_block_device)
config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>'))
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' } }
##
@@ -2863,7 +2864,9 @@
{ 'enum': 'BlockdevDriver',
'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs',
'cloop', 'compress', 'copy-on-read', 'dmg', 'file', 'ftp', 'ftps',
- 'gluster', 'host_cdrom', 'host_device', 'http', 'https', 'iscsi',
+ 'gluster', 'host_cdrom',
+ {'name': 'host_device', 'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' },
+ 'http', 'https', 'iscsi',
'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels',
'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"
#if defined(__APPLE__) && (__MACH__)
+#include <sys/ioctl.h>
+#if defined(HAVE_HOST_BLOCK_DEVICE)
#include <paths.h>
#include <sys/param.h>
#include <IOKit/IOKitLib.h>
@@ -52,6 +54,7 @@
//#include <IOKit/storage/IOCDTypes.h>
#include <IOKit/storage/IODVDMedia.h>
#include <CoreFoundation/CoreFoundation.h>
+#endif /* defined(HAVE_HOST_BLOCK_DEVICE) */
#endif
#ifdef __sun__
@@ -181,7 +184,17 @@ typedef struct BDRVRawReopenState {
bool check_cache_dropped;
} BDRVRawReopenState;
-static int fd_open(BlockDriverState *bs);
+static int fd_open(BlockDriverState *bs)
+{
+ BDRVRawState *s = bs->opaque;
+
+ /* this is just to ensure s->fd is sane (its called by io ops) */
+ if (s->fd >= 0) {
+ return 0;
+ }
+ return -EIO;
+}
+
static int64_t raw_getlength(BlockDriverState *bs);
typedef struct RawPosixAIOData {
@@ -3032,6 +3045,7 @@ static BlockStatsSpecific *raw_get_specific_stats(BlockDriverState *bs)
return stats;
}
+#if defined(HAVE_HOST_BLOCK_DEVICE)
static BlockStatsSpecific *hdev_get_specific_stats(BlockDriverState *bs)
{
BlockStatsSpecific *stats = g_new(BlockStatsSpecific, 1);
@@ -3041,6 +3055,7 @@ static BlockStatsSpecific *hdev_get_specific_stats(BlockDriverState *bs)
return stats;
}
+#endif /* HAVE_HOST_BLOCK_DEVICE */
static QemuOptsList raw_create_opts = {
.name = "raw-create-opts",
@@ -3265,6 +3280,8 @@ BlockDriver bdrv_file = {
/***********************************************/
/* host device */
+#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 int req, void *buf)
}
#endif /* linux */
-static int fd_open(BlockDriverState *bs)
-{
- BDRVRawState *s = bs->opaque;
-
- /* this is just to ensure s->fd is sane (its called by io ops) */
- if (s->fd >= 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 = {
};
#endif /* __FreeBSD__ */
+#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 */
}
block_init(bdrv_file_init);
--
2.28.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 2/4] block: check for sys/disk.h
2021-03-09 0:27 [PATCH v2 0/4] Disable unsupported features on iOS hosts Joelle van Dyne
2021-03-09 0:27 ` [PATCH v2 1/4] block: feature detection for host block support Joelle van Dyne
@ 2021-03-09 0:27 ` Joelle van Dyne
2021-03-09 11:25 ` Peter Maydell
2021-03-09 12:09 ` Philippe Mathieu-Daudé
2021-03-09 0:27 ` [PATCH v2 3/4] block: detect DKIOCGETBLOCKCOUNT/SIZE before use Joelle van Dyne
2021-03-09 0:27 ` [PATCH v2 4/4] slirp: feature detection for smbd Joelle van Dyne
3 siblings, 2 replies; 13+ messages in thread
From: Joelle van Dyne @ 2021-03-09 0:27 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Joelle van Dyne, open list:Block layer core, Max Reitz
Some BSD platforms do not have this header.
Signed-off-by: Joelle van Dyne <j@getutm.app>
---
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_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', prefix: '#include <stdlib.h>'))
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'))
config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>'))
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 <sys/ioctl.h>
#include <sys/queue.h>
-#ifndef __DragonFly__
+#if defined(HAVE_SYS_DISK_H)
#include <sys/disk.h>
#endif
#endif
--
2.28.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 3/4] block: detect DKIOCGETBLOCKCOUNT/SIZE before use
2021-03-09 0:27 [PATCH v2 0/4] Disable unsupported features on iOS hosts Joelle van Dyne
2021-03-09 0:27 ` [PATCH v2 1/4] block: feature detection for host block support Joelle van Dyne
2021-03-09 0:27 ` [PATCH v2 2/4] block: check for sys/disk.h Joelle van Dyne
@ 2021-03-09 0:27 ` Joelle van Dyne
2021-03-09 11:31 ` Peter Maydell
2021-03-09 0:27 ` [PATCH v2 4/4] slirp: feature detection for smbd Joelle van Dyne
3 siblings, 1 reply; 13+ messages in thread
From: Joelle van Dyne @ 2021-03-09 0:27 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, open list:raw, Joelle van Dyne, Warner Losh, Max Reitz
iOS hosts do not have these defined so we fallback to the
default behaviour.
Co-authored-by: Warner Losh <imp@bsdimp.com>
Signed-off-by: Joelle van Dyne <j@getutm.app>
---
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 = 0;
#ifdef DIOCGMEDIASIZE
if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size))
+ size = 0;
#elif defined(DIOCGPART)
{
struct partinfo pi;
@@ -2336,9 +2338,7 @@ again:
else
size = 0;
}
- if (size == 0)
-#endif
-#if defined(__APPLE__) && defined(__MACH__)
+#elif defined(DKIOCGETBLOCKCOUNT) && defined(DKIOCGETBLOCKSIZE)
{
uint64_t sectors = 0;
uint32_t sector_size = 0;
@@ -2346,19 +2346,15 @@ again:
if (ioctl(fd, DKIOCGETBLOCKCOUNT, §ors) == 0
&& ioctl(fd, DKIOCGETBLOCKSIZE, §or_size) == 0) {
size = sectors * sector_size;
- } else {
- size = lseek(fd, 0LL, SEEK_END);
- if (size < 0) {
- return -errno;
- }
}
}
-#else
- size = lseek(fd, 0LL, SEEK_END);
+#endif
+ if (size == 0) {
+ size = lseek(fd, 0LL, SEEK_END);
+ }
if (size < 0) {
return -errno;
}
-#endif
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
switch(s->type) {
case FTYPE_CD:
--
2.28.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 4/4] slirp: feature detection for smbd
2021-03-09 0:27 [PATCH v2 0/4] Disable unsupported features on iOS hosts Joelle van Dyne
` (2 preceding siblings ...)
2021-03-09 0:27 ` [PATCH v2 3/4] block: detect DKIOCGETBLOCKCOUNT/SIZE before use Joelle van Dyne
@ 2021-03-09 0:27 ` Joelle van Dyne
2021-03-09 10:10 ` Peter Maydell
` (2 more replies)
3 siblings, 3 replies; 13+ messages in thread
From: Joelle van Dyne @ 2021-03-09 0:27 UTC (permalink / raw)
To: qemu-devel; +Cc: Samuel Thibault, Jason Wang, Joelle van Dyne
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 <j@getutm.app>
---
configure | 26 +++++++++++++++++++++++---
meson.build | 2 +-
net/slirp.c | 16 ++++++++--------
3 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/configure b/configure
index 34fccaa2ba..8335a3e6a0 100755
--- a/configure
+++ b/configure
@@ -465,6 +465,7 @@ fuse_lseek="auto"
multiprocess="auto"
malloc_trim="auto"
+slirp_smbd="auto"
# parse CC options second
for opt do
@@ -834,8 +835,6 @@ do
fi
done
-: ${smbd=${SMBD-/usr/sbin/smbd}}
-
# Default objcc to clang if available, otherwise use CC
if has clang; then
objcc=clang
@@ -1560,6 +1559,10 @@ for opt do
;;
--disable-multiprocess) multiprocess="disabled"
;;
+ --enable-slirp-smbd) slirp_smbd=yes
+ ;;
+ --disable-slirp-smbd) slirp_smbd=no
+ ;;
*)
echo "ERROR: unknown option $opt"
echo "Try '$0 --help' for more information"
@@ -1913,6 +1916,7 @@ disabled with --disable-FEATURE, default is enabled if 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=*) in slirp networking
NOTE: The object files are built at the place where configure is launched
EOF
@@ -5252,6 +5256,19 @@ case "$slirp" in
;;
esac
+# Check for slirp smbd dupport
+: ${smbd=${SMBD-/usr/sbin/smbd}}
+if test "$slirp_smbd" != "no" ; then
+ if test "$mingw32" = "yes" ; then
+ if test "$slirp_smbd" = "yes" ; then
+ error_exit "Host smbd not supported on this platform."
+ fi
+ slirp_smbd=no
+ else
+ slirp_smbd=yes
+ fi
+fi
+
##########################################
# check for usable __NR_keyctl syscall
@@ -5527,7 +5544,10 @@ fi
if test "$guest_agent" = "yes" ; then
echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
fi
-echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
+if test "$slirp_smbd" = "yes" ; then
+ echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak
+ echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
+fi
if test "$vde" = "yes" ; then
echo "CONFIG_VDE=y" >> $config_host_mak
echo "VDE_LIBS=$vde_libs" >> $config_host_mak
diff --git a/meson.build b/meson.build
index ba0db9fa1f..cad70a8fc5 100644
--- a/meson.build
+++ b/meson.build
@@ -2424,7 +2424,7 @@ summary_info += {'genisoimage': config_host['GENISOIMAGE']}
if targetos == 'windows' and config_host.has_key('CONFIG_GUEST_AGENT')
summary_info += {'wixl': wixl.found() ? wixl.full_path() : false}
endif
-if slirp_opt != 'disabled'
+if slirp_opt != 'disabled' and 'CONFIG_SLIRP_SMBD' in config_host
summary_info += {'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"
-#ifndef _WIN32
+#if defined(CONFIG_SLIRP_SMBD)
#include <pwd.h>
#include <sys/wait.h>
#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 =
static int slirp_hostfwd(SlirpState *s, const char *redir_str, Error **errp);
static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **errp);
-#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 char *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 = { .s_addr = 0 };
#endif
NetClientState *nc;
@@ -477,7 +477,7 @@ static int net_slirp_init(NetClientState *peer, const char *model,
return -1;
}
-#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 char *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)
}
-#ifndef _WIN32
+#if defined(CONFIG_SLIRP_SMBD)
/* 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 *exported_dir,
return 0;
}
-#endif /* !defined(_WIN32) */
+#endif /* defined(CONFIG_SLIRP_SMBD) */
static int guestfwd_can_read(void *opaque)
{
--
2.28.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 4/4] slirp: feature detection for smbd
2021-03-09 0:27 ` [PATCH v2 4/4] slirp: feature detection for smbd Joelle van Dyne
@ 2021-03-09 10:10 ` Peter Maydell
2021-03-09 12:12 ` Philippe Mathieu-Daudé
2021-03-09 14:09 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 13+ messages in thread
From: Peter Maydell @ 2021-03-09 10:10 UTC (permalink / raw)
To: Joelle van Dyne; +Cc: Samuel Thibault, Jason Wang, QEMU Developers
On Tue, 9 Mar 2021 at 00:30, Joelle van Dyne <j@getutm.app> wrote:
>
> 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 <j@getutm.app>
> ---
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/4] block: check for sys/disk.h
2021-03-09 0:27 ` [PATCH v2 2/4] block: check for sys/disk.h Joelle van Dyne
@ 2021-03-09 11:25 ` Peter Maydell
2021-03-09 12:09 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 13+ messages in thread
From: Peter Maydell @ 2021-03-09 11:25 UTC (permalink / raw)
To: Joelle van Dyne
Cc: Kevin Wolf, QEMU Developers, open list:Block layer core, Max Reitz
On Tue, 9 Mar 2021 at 00:31, Joelle van Dyne <j@getutm.app> wrote:
>
> Some BSD platforms do not have this header.
>
> Signed-off-by: Joelle van Dyne <j@getutm.app>
> ---
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 3/4] block: detect DKIOCGETBLOCKCOUNT/SIZE before use
2021-03-09 0:27 ` [PATCH v2 3/4] block: detect DKIOCGETBLOCKCOUNT/SIZE before use Joelle van Dyne
@ 2021-03-09 11:31 ` Peter Maydell
0 siblings, 0 replies; 13+ messages in thread
From: Peter Maydell @ 2021-03-09 11:31 UTC (permalink / raw)
To: Joelle van Dyne
Cc: Kevin Wolf, Warner Losh, QEMU Developers, open list:raw, Max Reitz
On Tue, 9 Mar 2021 at 00:30, Joelle van Dyne <j@getutm.app> wrote:
>
> iOS hosts do not have these defined so we fallback to the
> default behaviour.
>
> Co-authored-by: Warner Losh <imp@bsdimp.com>
> Signed-off-by: Joelle van Dyne <j@getutm.app>
> ---
> block/file-posix.c | 18 +++++++-----------
> 1 file changed, 7 insertions(+), 11 deletions(-)
raw_getlength() is a bit of a mess; this certainly seems like
an improvement...
> 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 = 0;
> #ifdef DIOCGMEDIASIZE
> if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size))
> + size = 0;
this if() should have braces {}.
Otherwise
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/4] block: check for sys/disk.h
2021-03-09 0:27 ` [PATCH v2 2/4] block: check for sys/disk.h Joelle van Dyne
2021-03-09 11:25 ` Peter Maydell
@ 2021-03-09 12:09 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-03-09 12:09 UTC (permalink / raw)
To: Joelle van Dyne, qemu-devel
Cc: Kevin Wolf, open list:Block layer core, Max Reitz
On 3/9/21 1:27 AM, Joelle van Dyne wrote:
> Some BSD platforms do not have this header.
>
> Signed-off-by: Joelle van Dyne <j@getutm.app>
> ---
> 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_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', prefix: '#include <stdlib.h>'))
> 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'))
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 4/4] slirp: feature detection for smbd
2021-03-09 0:27 ` [PATCH v2 4/4] slirp: feature detection for smbd Joelle van Dyne
2021-03-09 10:10 ` Peter Maydell
@ 2021-03-09 12:12 ` Philippe Mathieu-Daudé
2021-03-09 14:09 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-03-09 12:12 UTC (permalink / raw)
To: Joelle van Dyne, qemu-devel
Cc: Samuel Thibault, Jason Wang, Miroslav Rezanina, Danilo C. L. de Paula
On 3/9/21 1:27 AM, Joelle van Dyne wrote:
> 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 <j@getutm.app>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> configure | 26 +++++++++++++++++++++++---
> meson.build | 2 +-
> net/slirp.c | 16 ++++++++--------
> 3 files changed, 32 insertions(+), 12 deletions(-)
>
> diff --git a/configure b/configure
> index 34fccaa2ba..8335a3e6a0 100755
> --- a/configure
> +++ b/configure
> @@ -465,6 +465,7 @@ fuse_lseek="auto"
> multiprocess="auto"
>
> malloc_trim="auto"
> +slirp_smbd="auto"
>
> # parse CC options second
> for opt do
> @@ -834,8 +835,6 @@ do
> fi
> done
>
> -: ${smbd=${SMBD-/usr/sbin/smbd}}
> -
> # Default objcc to clang if available, otherwise use CC
> if has clang; then
> objcc=clang
> @@ -1560,6 +1559,10 @@ for opt do
> ;;
> --disable-multiprocess) multiprocess="disabled"
> ;;
> + --enable-slirp-smbd) slirp_smbd=yes
> + ;;
> + --disable-slirp-smbd) slirp_smbd=no
> + ;;
> *)
> echo "ERROR: unknown option $opt"
> echo "Try '$0 --help' for more information"
> @@ -1913,6 +1916,7 @@ disabled with --disable-FEATURE, default is enabled if 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=*) in slirp networking
>
> NOTE: The object files are built at the place where configure is launched
> EOF
> @@ -5252,6 +5256,19 @@ case "$slirp" in
> ;;
> esac
>
> +# Check for slirp smbd dupport
> +: ${smbd=${SMBD-/usr/sbin/smbd}}
> +if test "$slirp_smbd" != "no" ; then
> + if test "$mingw32" = "yes" ; then
> + if test "$slirp_smbd" = "yes" ; then
> + error_exit "Host smbd not supported on this platform."
> + fi
> + slirp_smbd=no
> + else
> + slirp_smbd=yes
> + fi
> +fi
> +
> ##########################################
> # check for usable __NR_keyctl syscall
>
> @@ -5527,7 +5544,10 @@ fi
> if test "$guest_agent" = "yes" ; then
> echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
> fi
> -echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
> +if test "$slirp_smbd" = "yes" ; then
> + echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak
> + echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
> +fi
> if test "$vde" = "yes" ; then
> echo "CONFIG_VDE=y" >> $config_host_mak
> echo "VDE_LIBS=$vde_libs" >> $config_host_mak
> diff --git a/meson.build b/meson.build
> index ba0db9fa1f..cad70a8fc5 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -2424,7 +2424,7 @@ summary_info += {'genisoimage': config_host['GENISOIMAGE']}
> if targetos == 'windows' and config_host.has_key('CONFIG_GUEST_AGENT')
> summary_info += {'wixl': wixl.found() ? wixl.full_path() : false}
> endif
> -if slirp_opt != 'disabled'
> +if slirp_opt != 'disabled' and 'CONFIG_SLIRP_SMBD' in config_host
> summary_info += {'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"
>
>
> -#ifndef _WIN32
> +#if defined(CONFIG_SLIRP_SMBD)
> #include <pwd.h>
> #include <sys/wait.h>
> #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 =
> static int slirp_hostfwd(SlirpState *s, const char *redir_str, Error **errp);
> static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **errp);
>
> -#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 char *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 = { .s_addr = 0 };
> #endif
> NetClientState *nc;
> @@ -477,7 +477,7 @@ static int net_slirp_init(NetClientState *peer, const char *model,
> return -1;
> }
>
> -#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 char *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)
>
> }
>
> -#ifndef _WIN32
> +#if defined(CONFIG_SLIRP_SMBD)
>
> /* 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 *exported_dir,
> return 0;
> }
>
> -#endif /* !defined(_WIN32) */
> +#endif /* defined(CONFIG_SLIRP_SMBD) */
>
> static int guestfwd_can_read(void *opaque)
> {
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 4/4] slirp: feature detection for smbd
2021-03-09 0:27 ` [PATCH v2 4/4] slirp: feature detection for smbd Joelle van Dyne
2021-03-09 10:10 ` Peter Maydell
2021-03-09 12:12 ` Philippe Mathieu-Daudé
@ 2021-03-09 14:09 ` Philippe Mathieu-Daudé
2021-03-09 18:11 ` Joelle van Dyne
2 siblings, 1 reply; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-03-09 14:09 UTC (permalink / raw)
To: Joelle van Dyne, qemu-devel; +Cc: Samuel Thibault, Jason Wang
Hi Joelle,
On 3/9/21 1:27 AM, Joelle van Dyne wrote:
> 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 <j@getutm.app>
> ---
> configure | 26 +++++++++++++++++++++++---
> meson.build | 2 +-
> net/slirp.c | 16 ++++++++--------
> 3 files changed, 32 insertions(+), 12 deletions(-)
Hmm v1 had: Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
did you change something to not include Samuel A-b tag?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 4/4] slirp: feature detection for smbd
2021-03-09 14:09 ` Philippe Mathieu-Daudé
@ 2021-03-09 18:11 ` Joelle van Dyne
2021-03-10 1:13 ` Samuel Thibault
0 siblings, 1 reply; 13+ messages in thread
From: Joelle van Dyne @ 2021-03-09 18:11 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Samuel Thibault, Jason Wang, Joelle van Dyne, QEMU Developers
On Tue, Mar 9, 2021 at 6:09 AM Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>
> Hi Joelle,
>
> On 3/9/21 1:27 AM, Joelle van Dyne wrote:
> > 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 <j@getutm.app>
> > ---
> > configure | 26 +++++++++++++++++++++++---
> > meson.build | 2 +-
> > net/slirp.c | 16 ++++++++--------
> > 3 files changed, 32 insertions(+), 12 deletions(-)
>
> Hmm v1 had: Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> did you change something to not include Samuel A-b tag?
>
Sorry, I must have missed it!
-j
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 4/4] slirp: feature detection for smbd
2021-03-09 18:11 ` Joelle van Dyne
@ 2021-03-10 1:13 ` Samuel Thibault
0 siblings, 0 replies; 13+ messages in thread
From: Samuel Thibault @ 2021-03-10 1:13 UTC (permalink / raw)
To: Joelle van Dyne; +Cc: Jason Wang, Philippe Mathieu-Daudé, QEMU Developers
Joelle van Dyne, le mar. 09 mars 2021 10:11:31 -0800, a ecrit:
> On Tue, Mar 9, 2021 at 6:09 AM Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
> > On 3/9/21 1:27 AM, Joelle van Dyne wrote:
> > > 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 <j@getutm.app>
> > > ---
> > > configure | 26 +++++++++++++++++++++++---
> > > meson.build | 2 +-
> > > net/slirp.c | 16 ++++++++--------
> > > 3 files changed, 32 insertions(+), 12 deletions(-)
> >
> > Hmm v1 had: Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> > did you change something to not include Samuel A-b tag?
>
> Sorry, I must have missed it!
NP :)
Samuel
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2021-03-10 1:14 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-09 0:27 [PATCH v2 0/4] Disable unsupported features on iOS hosts Joelle van Dyne
2021-03-09 0:27 ` [PATCH v2 1/4] block: feature detection for host block support Joelle van Dyne
2021-03-09 0:27 ` [PATCH v2 2/4] block: check for sys/disk.h Joelle van Dyne
2021-03-09 11:25 ` Peter Maydell
2021-03-09 12:09 ` Philippe Mathieu-Daudé
2021-03-09 0:27 ` [PATCH v2 3/4] block: detect DKIOCGETBLOCKCOUNT/SIZE before use Joelle van Dyne
2021-03-09 11:31 ` Peter Maydell
2021-03-09 0:27 ` [PATCH v2 4/4] slirp: feature detection for smbd Joelle van Dyne
2021-03-09 10:10 ` Peter Maydell
2021-03-09 12:12 ` Philippe Mathieu-Daudé
2021-03-09 14:09 ` Philippe Mathieu-Daudé
2021-03-09 18:11 ` Joelle van Dyne
2021-03-10 1:13 ` Samuel Thibault
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.