Message ID | 20201019013928.72770-10-j@getutm.app |
---|---|
State | Superseded |
Headers | show |
Series | iOS and Apple Silicon host support | expand |
On 19/10/2020 03.39, Joelle van Dyne wrote: > From: osy <osy86@users.noreply.github.com> That "From:" line looks wrong ... could you please fix the "Author" of your patches / your git config? > macOS 11/iOS 14 added preadv/pwritev APIs. Due to weak linking, configure > will succeed with CONFIG_PREADV even when targeting a lower OS version. We > therefore need to check at run time if we can actually use these APIs. That sounds like the wrong approach to me ... could you please try to fix the check in "configure" instead? E.g. by running compile_prog with "-Werror", so that the test fails if there is no valid prototype available? Thomas
On Mon, Oct 19, 2020 at 1:27 AM Thomas Huth <thuth@redhat.com> wrote: > > On 19/10/2020 03.39, Joelle van Dyne wrote: > > From: osy <osy86@users.noreply.github.com> > > That "From:" line looks wrong ... could you please fix the "Author" of your > patches / your git config? osy wrote the original changes. I joined the UTM project to help bring the changes upstream with permission. However, they have agreed that if required that we can use my name as the author. > > > macOS 11/iOS 14 added preadv/pwritev APIs. Due to weak linking, configure > > will succeed with CONFIG_PREADV even when targeting a lower OS version. We > > therefore need to check at run time if we can actually use these APIs. > > That sounds like the wrong approach to me ... could you please try to fix > the check in "configure" instead? E.g. by running compile_prog with > "-Werror", so that the test fails if there is no valid prototype available? It's not that simple. Xcode 11 and below (supporting macOS 10.15 and below, iOS 13 and below, etc) does not have preadv/pwritev symbols defined and would fail to compile. Xcode 12 (supporting macOS 11 and below, iOS 14 and below, etc) have preadv/pwritev weakly defined so if it runs on, for example, 10.15, it would abort. There is no way to determine at compile time if you can use preadv/pwritev or not when building with Xcode 12. The availability checks are Apple's preferred way to handle this kind of situation (they discourage directly checking if an API exists on a system). -j > > Thomas >
On 20/10/2020 00.20, Joelle van Dyne wrote: > On Mon, Oct 19, 2020 at 1:27 AM Thomas Huth <thuth@redhat.com> wrote: >> >> On 19/10/2020 03.39, Joelle van Dyne wrote: >>> From: osy <osy86@users.noreply.github.com> >> >> That "From:" line looks wrong ... could you please fix the "Author" of your >> patches / your git config? > osy wrote the original changes. I joined the UTM project to help bring > the changes upstream with permission. However, they have agreed that > if required that we can use my name as the author. In any way, that "users.noreply.github.com" does not look like a valid e-mail address and should be replaced. >> >>> macOS 11/iOS 14 added preadv/pwritev APIs. Due to weak linking, configure >>> will succeed with CONFIG_PREADV even when targeting a lower OS version. We >>> therefore need to check at run time if we can actually use these APIs. >> >> That sounds like the wrong approach to me ... could you please try to fix >> the check in "configure" instead? E.g. by running compile_prog with >> "-Werror", so that the test fails if there is no valid prototype available? > It's not that simple. Xcode 11 and below (supporting macOS 10.15 and > below, iOS 13 and below, etc) does not have preadv/pwritev symbols > defined and would fail to compile. Xcode 12 (supporting macOS 11 and > below, iOS 14 and below, etc) have preadv/pwritev weakly defined so if > it runs on, for example, 10.15, it would abort. There is no way to > determine at compile time if you can use preadv/pwritev or not when > building with Xcode 12. The availability checks are Apple's preferred > way to handle this kind of situation (they discourage directly > checking if an API exists on a system). Ok, got it now, thanks for the detailed explanation! Thomas
diff --git a/block/file-posix.c b/block/file-posix.c index cdc73b5f1d..d7482036a3 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1393,12 +1393,24 @@ static bool preadv_present = true; static ssize_t qemu_preadv(int fd, const struct iovec *iov, int nr_iov, off_t offset) { +#ifdef CONFIG_DARWIN /* preadv introduced in macOS 11 */ + if (!__builtin_available(macOS 11, iOS 14, watchOS 7, tvOS 14, *)) { + preadv_present = false; + return -ENOSYS; + } else +#endif return preadv(fd, iov, nr_iov, offset); } static ssize_t qemu_pwritev(int fd, const struct iovec *iov, int nr_iov, off_t offset) { +#ifdef CONFIG_DARWIN /* pwritev introduced in macOS 11 */ + if (!__builtin_available(macOS 11, iOS 14, watchOS 7, tvOS 14, *)) { + preadv_present = false; + return -ENOSYS; + } else +#endif return pwritev(fd, iov, nr_iov, offset); }