qemu/contrib/libvhost-user/libvhost-user.c
/* A test to see if we have userfault available */
A test to see if we have userfault available
A test to see if we have userfault available
static bool
have_userfault(void)
{
#if defined(__linux__) && defined(__NR_userfaultfd) &&\
        defined(UFFD_FEATURE_MISSING_SHMEM) &&\
        defined(UFFD_FEATURE_MISSING_HUGETLBFS)
    int ufd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK);
    struct uffdio_api api_struct;
    if (ufd < 0) {
        return false;
    }
    api_struct.api = UFFD_API;
    api_struct.features = UFFD_FEATURE_MISSING_SHMEM |
                          UFFD_FEATURE_MISSING_HUGETLBFS;
    if (ioctl(ufd, UFFDIO_API, &api_struct)) {
        close(ufd);
        return false;
    }
    close(ufd);
    return true;
#else
    return false;
#endif
}
static bool have_userfault ( void ) { #if defined ( __linux__ ) && defined ( __NR_userfaultfd ) && defined ( UFFD_FEATURE_MISSING_SHMEM ) && defined ( UFFD_FEATURE_MISSING_HUGETLBFS ) int ufd = syscall ( __NR_userfaultfd , O_CLOEXEC | O_NONBLOCK ) ; struct uffdio_api api_struct ; if ( ufd < 0 ) { return false ; } api_struct . api = UFFD_API ; api_struct . features = UFFD_FEATURE_MISSING_SHMEM | UFFD_FEATURE_MISSING_HUGETLBFS ; if ( ioctl ( ufd , UFFDIO_API , & api_struct ) ) { close ( ufd ) ; return false ; } close ( ufd ) ; return true ; #else return false ; #endif }
A test to see if we have userfault available
A test to see if we have userfault available
/* Now test the kernel we're running on really has the features */