pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/emulators/qemu



Module Name:    pkgsrc
Committed By:   riastradh
Date:           Sat Mar 15 20:19:15 UTC 2025

Modified Files:
        pkgsrc/emulators/qemu: Makefile distinfo options.mk
        pkgsrc/emulators/qemu/patches: patch-meson.build
Added Files:
        pkgsrc/emulators/qemu/patches: patch-fsdev_file-op-9p.h
            patch-fsdev_meson.build patch-hw_9pfs_9p-synth.c
            patch-hw_9pfs_9p-util.h patch-hw_9pfs_9p.c patch-hw_9pfs_9p.h
            patch-hw_9pfs_codir.c patch-hw_9pfs_meson.build

Log Message:
emulators/qemu: New option qemu-virtfs.

Add NetBSD support for qemu-virtfs.  (And pave the way for other BSD
support too.)

Narrow the existing virtfs-proxy-helper option to use
--enable-virtfs-proxy-helper.  I doubt this option has worked in a
long time, because I think virtfs-proxy-helper has been off by
default even with virtfs enabled; maybe we should just delete it.

No functional change intended for default build on non-NetBSD
platforms.

PR pkg/59163: emulators/qemu: missing virtfs option for NetBSD


To generate a diff of this commit:
cvs rdiff -u -r1.371 -r1.372 pkgsrc/emulators/qemu/Makefile
cvs rdiff -u -r1.230 -r1.231 pkgsrc/emulators/qemu/distinfo
cvs rdiff -u -r1.23 -r1.24 pkgsrc/emulators/qemu/options.mk
cvs rdiff -u -r0 -r1.1 pkgsrc/emulators/qemu/patches/patch-fsdev_file-op-9p.h \
    pkgsrc/emulators/qemu/patches/patch-fsdev_meson.build \
    pkgsrc/emulators/qemu/patches/patch-hw_9pfs_9p-synth.c \
    pkgsrc/emulators/qemu/patches/patch-hw_9pfs_9p-util.h \
    pkgsrc/emulators/qemu/patches/patch-hw_9pfs_9p.c \
    pkgsrc/emulators/qemu/patches/patch-hw_9pfs_9p.h \
    pkgsrc/emulators/qemu/patches/patch-hw_9pfs_codir.c \
    pkgsrc/emulators/qemu/patches/patch-hw_9pfs_meson.build
cvs rdiff -u -r1.15 -r1.16 pkgsrc/emulators/qemu/patches/patch-meson.build

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/emulators/qemu/Makefile
diff -u pkgsrc/emulators/qemu/Makefile:1.371 pkgsrc/emulators/qemu/Makefile:1.372
--- pkgsrc/emulators/qemu/Makefile:1.371        Sat Mar 15 20:18:23 2025
+++ pkgsrc/emulators/qemu/Makefile      Sat Mar 15 20:19:15 2025
@@ -1,9 +1,9 @@
-# $NetBSD: Makefile,v 1.371 2025/03/15 20:18:23 riastradh Exp $
+# $NetBSD: Makefile,v 1.372 2025/03/15 20:19:15 riastradh Exp $
 
 .include       "../../emulators/qemu/version.mk"
 
 DISTNAME=      qemu-${QEMU_VERSION}
-PKGREVISION=   3
+PKGREVISION=   4
 CATEGORIES=    emulators
 MASTER_SITES=  https://download.qemu.org/
 EXTRACT_SUFX=  .tar.xz

Index: pkgsrc/emulators/qemu/distinfo
diff -u pkgsrc/emulators/qemu/distinfo:1.230 pkgsrc/emulators/qemu/distinfo:1.231
--- pkgsrc/emulators/qemu/distinfo:1.230        Mon Mar 10 13:46:25 2025
+++ pkgsrc/emulators/qemu/distinfo      Sat Mar 15 20:19:15 2025
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.230 2025/03/10 13:46:25 wiz Exp $
+$NetBSD: distinfo,v 1.231 2025/03/15 20:19:15 riastradh Exp $
 
 BLAKE2s (palcode-clipper-qemu-5.2.0nb8) = d388c896a80c1cc3d4785c8434d6688bbcfd54c28f7252ce550ab162a0bba321
 SHA512 (palcode-clipper-qemu-5.2.0nb8) = 33695d6001d86a19793a92d5e31775607c4dfc9ab9eea019ea6c4d543a2e11e8c07f83cca4934811a13ef829b528737ea37d9d2aaf66cba6f2746d44d2aa0b43
@@ -7,14 +7,22 @@ BLAKE2s (qemu-9.2.2.tar.xz) = ad6aa908ac
 SHA512 (qemu-9.2.2.tar.xz) = b010876da9f91da01dbb9e06705a1358d5f062d0fdd4ad5c8cd8ce3fd43adcefcf72a61216eb8d415281f6607b945ce1cfb6b5fc5692ada9163e8f05b7fb5533
 Size (qemu-9.2.2.tar.xz) = 134756816 bytes
 SHA1 (patch-audio_jackaudio.c) = 771c2779e565242a500adc0223ef6b1ae5b2b91f
+SHA1 (patch-fsdev_file-op-9p.h) = d951ea05ec31977e720f6ee02f53f1cd3d7c356e
+SHA1 (patch-fsdev_meson.build) = 918a361056b9808caecf4fbd85f44cfc405a1606
 SHA1 (patch-hw-mips-Kconfig) = c74efac1b5d3a49d141387eb9316617039be737b
 SHA1 (patch-hw-mips-mipssim.c) = c72129c6ad961a62d3f1b443bbf373ee3c900dc0
+SHA1 (patch-hw_9pfs_9p-synth.c) = f6af717a11d1cc7851f6dd388c7030264e1ee772
+SHA1 (patch-hw_9pfs_9p-util.h) = c286ea007f0ca3250442afe45c22dbeac640a077
+SHA1 (patch-hw_9pfs_9p.c) = 05c418eebf501dfbfff686d66d32953a1a41f9ca
+SHA1 (patch-hw_9pfs_9p.h) = 4e2749619d2154f9fb341047aa278371b298e8a4
+SHA1 (patch-hw_9pfs_codir.c) = c065762ee13fdeaef063632f56d9d0ead6b68f61
+SHA1 (patch-hw_9pfs_meson.build) = d6d754fb38b4b0f95bdb8bebbe18e8adad035e26
 SHA1 (patch-hw_mips_meson.build) = 06cc199b3b15add9f5d5ddcd84bf2791f96bd5d3
 SHA1 (patch-hw_net_xilinx__axienet.c) = ebcd2676d64ce6f31e4a8c976d4fdf530ad5e8b7
 SHA1 (patch-hw_rtc_mc146818rtc.c) = cc7a3b28010966b65b7a16db756226ac2669f310
 SHA1 (patch-hw_scsi_scsi-disk.c) = fdbf2f962a6dcb1a115a7f8a5b8790ff9295fb33
 SHA1 (patch-hw_usb_dev-mtp.c) = f148a3ad6d72eb29f85684316af5fb219ddaeb71
-SHA1 (patch-meson.build) = 6b0607903b84c84d26bd5c54f3f0b9e4b256d787
+SHA1 (patch-meson.build) = 8a76d92303efa054b37d46b27d76d0fb75c15133
 SHA1 (patch-qemu-options.hx) = 6cf811ae421db1e8d45f7098bd36733c6dc7d9cf
 SHA1 (patch-roms_u-boot-sam460ex_Makefile) = 3a1bbf19b1422c10ebdd819eb0b711fafc78e2f2
 SHA1 (patch-target_arm_tcg_translate-sve.c) = b5eeb08331e61a16b2cf4b7ab9b668755aa9a04e

Index: pkgsrc/emulators/qemu/options.mk
diff -u pkgsrc/emulators/qemu/options.mk:1.23 pkgsrc/emulators/qemu/options.mk:1.24
--- pkgsrc/emulators/qemu/options.mk:1.23       Tue Feb 20 19:08:39 2024
+++ pkgsrc/emulators/qemu/options.mk    Sat Mar 15 20:19:15 2025
@@ -1,4 +1,4 @@
-# $NetBSD: options.mk,v 1.23 2024/02/20 19:08:39 imil Exp $
+# $NetBSD: options.mk,v 1.24 2025/03/15 20:19:15 riastradh Exp $
 
 PKG_OPTIONS_VAR=       PKG_OPTIONS.qemu
 PKG_SUPPORTED_OPTIONS= debug debug-info gtk3 iscsi jack sdl spice
@@ -10,6 +10,11 @@ PKG_SUGGESTED_OPTIONS+=      iscsi sdl spice
 PKG_SUPPORTED_OPTIONS+=        virtfs-proxy-helper
 .endif
 
+.if ${OPSYS} == "Linux" || ${OPSYS} == "Darwin" || ${OPSYS} == "NetBSD"
+PKG_SUPPORTED_OPTIONS+=        qemu-virtfs
+PKG_SUGGESTED_OPTIONS+=        qemu-virtfs
+.endif
+
 .if ${OPSYS} != "Darwin"
 # NetBSD<9.0 does not have EGL support in native X11,
 # so the QEMU OpenGL display driver cannot build.
@@ -80,8 +85,10 @@ CONFIGURE_ARGS+=     --disable-xkbcommon
 # header/development libraries for libcap and libattr must be installed.
 .if ${OPSYS} == "Linux" && !empty(PKG_OPTIONS:Mvirtfs-proxy-helper)
 PLIST.virtfs-proxy-helper=     yes
-CONFIGURE_ARGS+=               --enable-virtfs
-.elif ${OPSYS} == "Darwin"
+CONFIGURE_ARGS+=               --enable-virtfs-proxy-helper
+.endif
+
+.if !empty(PKG_OPTIONS:Mqemu-virtfs)
 CONFIGURE_ARGS+=               --enable-virtfs
 .else
 CONFIGURE_ARGS+=               --disable-virtfs

Index: pkgsrc/emulators/qemu/patches/patch-meson.build
diff -u pkgsrc/emulators/qemu/patches/patch-meson.build:1.15 pkgsrc/emulators/qemu/patches/patch-meson.build:1.16
--- pkgsrc/emulators/qemu/patches/patch-meson.build:1.15        Wed Apr 24 07:20:59 2024
+++ pkgsrc/emulators/qemu/patches/patch-meson.build     Sat Mar 15 20:19:15 2025
@@ -1,12 +1,13 @@
-$NetBSD: patch-meson.build,v 1.15 2024/04/24 07:20:59 adam Exp $
+$NetBSD: patch-meson.build,v 1.16 2025/03/15 20:19:15 riastradh Exp $
 
 * Detect iconv in libc properly for pkgsrc (pkgsrc removes -liconv)
   to fix qemu-system-aarch64 link.
 * Detect curses (non-ncurses{,w} too)
+* Allow building fsdev on non-Linux/Darwin
 
---- meson.build.orig   2024-04-10 17:43:26.000000000 +0000
+--- meson.build.orig   2024-12-10 23:46:36.000000000 +0000
 +++ meson.build
-@@ -1329,7 +1329,7 @@ if have_system and get_option('curses').
+@@ -1471,7 +1471,7 @@ if have_system and get_option('curses').
        has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
      endif
      if has_curses_h
@@ -15,7 +16,7 @@ $NetBSD: patch-meson.build,v 1.15 2024/0
        foreach curses_libname : curses_libname_list
          libcurses = cc.find_library(curses_libname,
                                      required: false)
-@@ -1346,7 +1346,7 @@ if have_system and get_option('curses').
+@@ -1488,7 +1488,7 @@ if have_system and get_option('curses').
      endif
    endif
    if get_option('iconv').allowed()
@@ -24,3 +25,16 @@ $NetBSD: patch-meson.build,v 1.15 2024/0
        # Programs will be linked with glib and this will bring in libiconv on FreeBSD.
        # We need to use libiconv if available because mixing libiconv's headers with
        # the system libc does not work.
+@@ -2318,9 +2318,9 @@ dbus_display = get_option('dbus_display'
+   .allowed()
+ 
+ have_virtfs = get_option('virtfs') \
+-    .require(host_os == 'linux' or host_os == 'darwin',
+-             error_message: 'virtio-9p (virtfs) requires Linux or macOS') \
+-    .require(host_os == 'linux' or cc.has_function('pthread_fchdir_np'),
++    .require(host_os == 'linux' or host_os == 'darwin' or host_os == 'netbsd',
++             error_message: 'virtio-9p (virtfs) requires Linux, macOS, or NetBSD') \
++    .require(host_os != 'darwin' or cc.has_function('pthread_fchdir_np'),
+              error_message: 'virtio-9p (virtfs) on macOS requires the presence of pthread_fchdir_np') \
+     .require(host_os == 'darwin' or libattr.found(),
+              error_message: 'virtio-9p (virtfs) on Linux requires libattr-devel') \

Added files:

Index: pkgsrc/emulators/qemu/patches/patch-fsdev_file-op-9p.h
diff -u /dev/null pkgsrc/emulators/qemu/patches/patch-fsdev_file-op-9p.h:1.1
--- /dev/null   Sat Mar 15 20:19:15 2025
+++ pkgsrc/emulators/qemu/patches/patch-fsdev_file-op-9p.h      Sat Mar 15 20:19:15 2025
@@ -0,0 +1,18 @@
+$NetBSD: patch-fsdev_file-op-9p.h,v 1.1 2025/03/15 20:19:15 riastradh Exp $
+
+Add BSD support for fsdev 9p.
+
+--- fsdev/file-op-9p.h.orig    2024-12-10 23:46:36.000000000 +0000
++++ fsdev/file-op-9p.h
+@@ -26,6 +26,11 @@
+ # include <sys/param.h>
+ # include <sys/mount.h>
+ #endif
++#ifdef __NetBSD__
++# include <sys/statvfs.h>
++# define statfs statvfs
++# define fstatfs fstatvfs
++#endif
+ 
+ #define SM_LOCAL_MODE_BITS    0600
+ #define SM_LOCAL_DIR_MODE_BITS    0700
Index: pkgsrc/emulators/qemu/patches/patch-fsdev_meson.build
diff -u /dev/null pkgsrc/emulators/qemu/patches/patch-fsdev_meson.build:1.1
--- /dev/null   Sat Mar 15 20:19:15 2025
+++ pkgsrc/emulators/qemu/patches/patch-fsdev_meson.build       Sat Mar 15 20:19:15 2025
@@ -0,0 +1,14 @@
+$NetBSD: patch-fsdev_meson.build,v 1.1 2025/03/15 20:19:15 riastradh Exp $
+
+Enable fsdev support on NetBSD.
+
+--- fsdev/meson.build.orig     2024-12-10 23:46:36.000000000 +0000
++++ fsdev/meson.build
+@@ -5,6 +5,6 @@ fsdev_ss.add(when: ['CONFIG_FSDEV_9P'], 
+   '9p-marshal.c',
+   'qemu-fsdev.c',
+ ), if_false: files('qemu-fsdev-dummy.c'))
+-if host_os in ['linux', 'darwin']
++if host_os in ['linux', 'darwin', 'netbsd']
+   system_ss.add_all(fsdev_ss)
+ endif
Index: pkgsrc/emulators/qemu/patches/patch-hw_9pfs_9p-synth.c
diff -u /dev/null pkgsrc/emulators/qemu/patches/patch-hw_9pfs_9p-synth.c:1.1
--- /dev/null   Sat Mar 15 20:19:15 2025
+++ pkgsrc/emulators/qemu/patches/patch-hw_9pfs_9p-synth.c      Sat Mar 15 20:19:15 2025
@@ -0,0 +1,30 @@
+$NetBSD: patch-hw_9pfs_9p-synth.c,v 1.1 2025/03/15 20:19:15 riastradh Exp $
+
+Add BSD support for fsdev 9p.
+
+--- hw/9pfs/9p-synth.c.orig    2024-12-10 23:46:36.000000000 +0000
++++ hw/9pfs/9p-synth.c
+@@ -230,7 +230,7 @@ static void synth_direntry(V9fsSynthNode
+     entry->d_ino = node->attr->inode;
+ #ifdef CONFIG_DARWIN
+     entry->d_seekoff = off + 1;
+-#else
++#elif defined CONFIG_LINUX
+     entry->d_off = off + 1;
+ #endif
+ }
+@@ -433,11 +433,13 @@ static int synth_fsync(FsContext *ctx, i
+ static int synth_statfs(FsContext *s, V9fsPath *fs_path,
+                              struct statfs *stbuf)
+ {
++#ifndef __NetBSD__
+     stbuf->f_type = 0xABCD;
++#endif
+     stbuf->f_bsize = 512;
+     stbuf->f_blocks = 0;
+     stbuf->f_files = synth_node_count;
+-#ifndef CONFIG_DARWIN
++#ifdef CONFIG_LINUX
+     stbuf->f_namelen = NAME_MAX;
+ #endif
+     return 0;
Index: pkgsrc/emulators/qemu/patches/patch-hw_9pfs_9p-util.h
diff -u /dev/null pkgsrc/emulators/qemu/patches/patch-hw_9pfs_9p-util.h:1.1
--- /dev/null   Sat Mar 15 20:19:15 2025
+++ pkgsrc/emulators/qemu/patches/patch-hw_9pfs_9p-util.h       Sat Mar 15 20:19:15 2025
@@ -0,0 +1,337 @@
+$NetBSD: patch-hw_9pfs_9p-util.h,v 1.1 2025/03/15 20:19:15 riastradh Exp $
+
+Add BSD support for fsdev 9p.
+
+--- hw/9pfs/9p-util.h.orig     2025-02-24 14:36:36.000000000 +0000
++++ hw/9pfs/9p-util.h
+@@ -84,6 +84,298 @@ static inline int errno_to_dotl(int err)
+     } else if (err == EOPNOTSUPP) {
+         err = 95; /* ==EOPNOTSUPP on Linux */
+     }
++#elif defined(CONFIG_BSD)
++    switch (err) {
++        /* linux uapi/asm-generic/errno-base.h */
++    case EPERM:
++        return 1;
++    case ENOENT:
++        return 2;
++    case ESRCH:
++        return 3;
++    case EINTR:
++        return 4;
++    case EIO:
++        return 5;
++    case ENXIO:
++        return 6;
++    case E2BIG:
++        return 7;
++    case ENOEXEC:
++        return 8;
++    case EBADF:
++        return 9;
++    case ECHILD:
++        return 10;
++    case EAGAIN:
++        return 11;
++    case ENOMEM:
++        return 12;
++    case EACCES:
++        return 13;
++    case EFAULT:
++        return 14;
++    case ENOTBLK:
++        return 15;
++    case EBUSY:
++        return 16;
++    case EEXIST:
++        return 17;
++    case EXDEV:
++        return 18;
++    case ENODEV:
++        return 19;
++    case ENOTDIR:
++        return 20;
++    case EISDIR:
++        return 21;
++    case EINVAL:
++        return 22;
++    case ENFILE:
++        return 23;
++    case EMFILE:
++        return 24;
++    case ENOTTY:
++        return 25;
++    case ETXTBSY:
++        return 26;
++    case EFBIG:
++        return 27;
++    case ENOSPC:
++        return 28;
++    case ESPIPE:
++        return 29;
++    case EROFS:
++        return 30;
++    case EMLINK:
++        return 31;
++    case EPIPE:
++        return 32;
++    case EDOM:
++        return 33;
++    case ERANGE:
++        return 34;
++        /* linux uapi/asm-generic/errno.h */
++    case EDEADLK:
++        return 35;
++    case ENAMETOOLONG:
++        return 36;
++    case ENOLCK:
++        return 37;
++    case ENOSYS:
++        return 38;
++    case ENOTEMPTY:
++        return 39;
++    case ELOOP:
++        return 40;
++    case ENOMSG:
++        return 41;
++    case EIDRM:
++        return 43;
++# if 0
++    case ECHRNG:
++        return 44;
++    case EL2NSYNC:
++        return 45;
++    case EL3HLT:
++        return 46;
++    case EL3RST:
++        return 47;
++    case ELNRNG:
++        return 48;
++    case EUNATCH:
++        return 49;
++    case ENOCSI:
++        return 50;
++    case EL2HLT:
++        return 51;
++    case EBADE:
++        return 52;
++    case EBADR:
++        return 53;
++    case EXFULL:
++        return 54;
++    case ENOANO:
++        return 55;
++    case EBADRQC:
++        return 56;
++    case EBADSLT:
++        return 57;
++    case EBFONT:
++        return 58;
++# endif
++    case ENOSTR:
++        return 60;
++    case ENODATA:
++        return 61;
++    case ETIME:
++        return 62;
++    case ENOSR:
++        return 63;
++# if 0
++    case ENONET:
++        return 64;
++    case ENOPKG:
++        return 65;
++# endif
++    case ENOLINK:
++        return 66;
++# if 0
++    case EADV:
++        return 67;
++    case ESRMNT:
++        return 68;
++    case ECOMM:
++        return 69;
++# endif
++    case EPROTO:
++        return 70;
++    case EMULTIHOP:
++        return 71;
++# if 0
++    case EDOTDOT:
++        return 72;
++# endif
++    case EBADMSG:
++        return 73;
++    case EOVERFLOW:
++        return 74;
++# if 0
++    case ENOTUNIQ:
++        return 75;
++    case EBADFD:                /* Note: not EBADF */
++        return 77;
++    case EREMCHG:
++        return 78;
++    case ELIBACC:
++        return 79;
++    case ELIBBAD:
++        return 80;
++    case ELIBSCN:
++        return 81;
++    case ELIBMAX:
++        return 82;
++    case ELIBEXEC:
++        return 83;
++#endif
++    case EILSEQ:
++        return 84;
++#if 0
++    case ERESTART:              /* XXX not the same thing */
++        return 85;
++#endif
++#if 0
++    case ESTRPIPE:
++        return 86;
++#endif
++    case EUSERS:
++        return 87;
++    case ENOTSOCK:
++        return 88;
++    case EDESTADDRREQ:
++        return 89;
++    case EMSGSIZE:
++        return 90;
++    case EPROTOTYPE:
++        return 91;
++    case ENOPROTOOPT:
++        return 92;
++    case EPROTONOSUPPORT:
++        return 93;
++    case ESOCKTNOSUPPORT:
++        return 94;
++    case EOPNOTSUPP:
++        return 95;
++    case EPFNOSUPPORT:
++        return 96;
++    case EAFNOSUPPORT:
++        return 97;
++    case EADDRINUSE:
++        return 98;
++    case EADDRNOTAVAIL:
++        return 99;
++    case ENETDOWN:
++        return 100;
++    case ENETUNREACH:
++        return 101;
++    case ENETRESET:
++        return 102;
++    case ECONNABORTED:
++        return 103;
++    case ECONNRESET:
++        return 104;
++    case ENOBUFS:
++        return 105;
++    case EISCONN:
++        return 106;
++    case ENOTCONN:
++        return 107;
++    case ESHUTDOWN:
++        return 108;
++    case ETOOMANYREFS:
++        return 109;
++    case ETIMEDOUT:
++        return 110;
++    case ECONNREFUSED:
++        return 111;
++    case EHOSTDOWN:
++        return 112;
++    case EHOSTUNREACH:
++        return 113;
++    case EALREADY:
++        return 114;
++    case EINPROGRESS:
++        return 115;
++    case ESTALE:
++        return 116;
++# if 0
++    case EUCLEAN:
++        return 117;
++    case ENOTNAM:
++        return 118;
++    case ENAVAIL:
++        return 119;
++    case EISNAM:
++        return 120;
++    case EREMOTEIO:
++        return 121;
++# endif
++    case EDQUOT:
++        return 122;
++# if 0
++    case ENOMEDIUM:
++        return 123;
++    case EMEDIUMTYPE:
++        return 124;
++# endif
++    case ECANCELED:
++        return 125;
++# if 0
++    case ENOKEY:
++        return 126;
++    case EKEYEXPIRED:
++        return 127;
++    case EKEYREVOKED:
++        return 128;
++    case EKEYREJECTED:
++        return 129;
++    case EOWNERDEAD:
++        return 130;
++    case ENOTRECOVERABLE:
++        return 131;
++    case ERFKILL:
++        return 132;
++    case EHWPOISON:
++        return 133;
++# endif
++        /* extras */
++    case ENOTSUP:
++        return EOPNOTSUPP;
++    case ENOATTR:
++        return ENODATA;
++    default:
++        return EIO;
++    }
+ #else
+ #error Missing errno translation to Linux for this host system
+ #endif
+@@ -154,13 +446,13 @@ static inline int openat_file(int dirfd,
+ {
+     int fd, serrno, ret;
+ 
+-#ifndef CONFIG_DARWIN
++#ifdef O_NOATIME
+ again:
+ #endif
+     fd = qemu_openat(dirfd, name, flags | O_NOFOLLOW | O_NOCTTY | O_NONBLOCK,
+                      mode);
+     if (fd == -1) {
+-#ifndef CONFIG_DARWIN
++#ifdef O_NOATIME
+         if (errno == EPERM && (flags & O_NOATIME)) {
+             /*
+              * The client passed O_NOATIME but we lack permissions to honor it.
+@@ -216,6 +508,7 @@ ssize_t fremovexattrat_nofollow(int dirf
+  * so ensure it is manually injected earlier and call here when
+  * needed.
+  */
++#if defined(CONFIG_LINUX) || defined(CONFIG_DARWIN)
+ static inline off_t qemu_dirent_off(struct dirent *dent)
+ {
+ #ifdef CONFIG_DARWIN
+@@ -224,6 +517,7 @@ static inline off_t qemu_dirent_off(stru
+     return dent->d_off;
+ #endif
+ }
++#endif
+ 
+ /**
+  * qemu_dirent_dup() - Duplicate directory entry @dent.
Index: pkgsrc/emulators/qemu/patches/patch-hw_9pfs_9p.c
diff -u /dev/null pkgsrc/emulators/qemu/patches/patch-hw_9pfs_9p.c:1.1
--- /dev/null   Sat Mar 15 20:19:15 2025
+++ pkgsrc/emulators/qemu/patches/patch-hw_9pfs_9p.c    Sat Mar 15 20:19:15 2025
@@ -0,0 +1,93 @@
+$NetBSD: patch-hw_9pfs_9p.c,v 1.1 2025/03/15 20:19:15 riastradh Exp $
+
+Add BSD support for fsdev 9p.
+
+--- hw/9pfs/9p.c.orig  2024-12-10 23:46:36.000000000 +0000
++++ hw/9pfs/9p.c
+@@ -136,8 +136,10 @@ static int dotl_to_open_flags(int flags)
+         { P9_DOTL_NONBLOCK, O_NONBLOCK } ,
+         { P9_DOTL_DSYNC, O_DSYNC },
+         { P9_DOTL_FASYNC, FASYNC },
+-#ifndef CONFIG_DARWIN
++#ifdef O_NOATIME
+         { P9_DOTL_NOATIME, O_NOATIME },
++#endif
++#ifndef CONFIG_DARWIN
+         /*
+          *  On Darwin, we could map to F_NOCACHE, which is
+          *  similar, but doesn't quite have the same
+@@ -2293,6 +2295,13 @@ static int coroutine_fn v9fs_do_readdir_
+         if (err || !dent) {
+             break;
+         }
++#if !defined(CONFIG_LINUX) && !defined(CONFIG_DARWIN)
++        const off_t next_dir_pos = v9fs_co_telldir(pdu, fidp);
++        if (next_dir_pos < 0) {
++            err = next_dir_pos;
++            break;
++        }
++#endif
+         err = v9fs_co_name_to_path(pdu, &fidp->path, dent->d_name, &path);
+         if (err < 0) {
+             break;
+@@ -2329,7 +2338,11 @@ static int coroutine_fn v9fs_do_readdir_
+         count += len;
+         v9fs_stat_free(&v9stat);
+         v9fs_path_free(&path);
++#if !defined(CONFIG_LINUX) && !defined(CONFIG_DARWIN)
++        saved_dir_pos = next_dir_pos;
++#else
+         saved_dir_pos = qemu_dirent_off(dent);
++#endif
+     }
+ 
+     v9fs_readdir_unlock(&fidp->fs.dir);
+@@ -2530,7 +2543,11 @@ static int coroutine_fn v9fs_do_readdir(
+             qid.version = 0;
+         }
+ 
++#if !defined(CONFIG_LINUX) && !defined(CONFIG_DARWIN)
++        off = e->dirent_off;
++#else
+         off = qemu_dirent_off(dent);
++#endif
+         v9fs_string_init(&name);
+         v9fs_string_sprintf(&name, "%s", dent->d_name);
+ 
+@@ -3575,7 +3592,11 @@ static int v9fs_fill_statfs(V9fsState *s
+     if (!bsize_factor) {
+         bsize_factor = 1;
+     }
++#ifdef __NetBSD__
++    f_type  = 0;                /* XXX struct statvfs::f_type? (fstypename?) */
++#else
+     f_type  = stbuf->f_type;
++#endif
+     f_bsize = stbuf->f_bsize;
+     f_bsize *= bsize_factor;
+     /*
+@@ -3592,10 +3613,14 @@ static int v9fs_fill_statfs(V9fsState *s
+     fsid_val = (unsigned int)stbuf->f_fsid.val[0] |
+                (unsigned long long)stbuf->f_fsid.val[1] << 32;
+     f_namelen = NAME_MAX;
+-#else
++#elif defined CONFIG_LINUX
+     fsid_val = (unsigned int) stbuf->f_fsid.__val[0] |
+                (unsigned long long)stbuf->f_fsid.__val[1] << 32;
+     f_namelen = stbuf->f_namelen;
++#elif defined __NetBSD__
++    fsid_val = (unsigned int) stbuf->f_fsidx.__fsid_val[0] |
++               (unsigned long long)stbuf->f_fsidx.__fsid_val[1] << 32;
++    f_namelen = NAME_MAX;
+ #endif
+ 
+     return pdu_marshal(pdu, offset, "ddqqqqqqd",
+@@ -3966,7 +3991,7 @@ out_nofid:
+     v9fs_string_free(&name);
+ }
+ 
+-#if defined(CONFIG_LINUX)
++#if defined(CONFIG_LINUX) || defined(__NetBSD__)
+ /* Currently, only Linux has XATTR_SIZE_MAX */
+ #define P9_XATTR_SIZE_MAX XATTR_SIZE_MAX
+ #elif defined(CONFIG_DARWIN)
Index: pkgsrc/emulators/qemu/patches/patch-hw_9pfs_9p.h
diff -u /dev/null pkgsrc/emulators/qemu/patches/patch-hw_9pfs_9p.h:1.1
--- /dev/null   Sat Mar 15 20:19:15 2025
+++ pkgsrc/emulators/qemu/patches/patch-hw_9pfs_9p.h    Sat Mar 15 20:19:15 2025
@@ -0,0 +1,16 @@
+$NetBSD: patch-hw_9pfs_9p.h,v 1.1 2025/03/15 20:19:15 riastradh Exp $
+
+Add BSD support for fsdev 9p.
+
+--- hw/9pfs/9p.h.orig  2024-12-10 23:46:36.000000000 +0000
++++ hw/9pfs/9p.h
+@@ -238,6 +238,9 @@ static inline void v9fs_readdir_init(P9P
+ typedef struct V9fsDirEnt {
+     /* mandatory (must not be NULL) information for all readdir requests */
+     struct dirent *dent;
++#if !defined(CONFIG_LINUX) && !defined(CONFIG_DARWIN)
++    off_t dirent_off;
++#endif
+     /*
+      * optional (may be NULL): A full stat of each directory entry is just
+      * done if explicitly told to fs driver.
Index: pkgsrc/emulators/qemu/patches/patch-hw_9pfs_codir.c
diff -u /dev/null pkgsrc/emulators/qemu/patches/patch-hw_9pfs_codir.c:1.1
--- /dev/null   Sat Mar 15 20:19:15 2025
+++ pkgsrc/emulators/qemu/patches/patch-hw_9pfs_codir.c Sat Mar 15 20:19:15 2025
@@ -0,0 +1,42 @@
+$NetBSD: patch-hw_9pfs_codir.c,v 1.1 2025/03/15 20:19:15 riastradh Exp $
+
+Add BSD support for fsdev 9p.
+
+--- hw/9pfs/codir.c.orig       2024-12-10 23:46:36.000000000 +0000
++++ hw/9pfs/codir.c
+@@ -122,6 +122,13 @@ do_readdir_many(V9fsPDU *pdu, V9fsFidSta
+         if (err || !dent) {
+             break;
+         }
++#if !defined(CONFIG_LINUX) && !defined(CONFIG_DARWIN)
++        const off_t dirent_off = s->ops->telldir(&s->ctx, &fidp->fs);
++        if (dirent_off < 0) {
++            err = dirent_off;
++            break;
++        }
++#endif
+ 
+         /*
+          * stop this loop as soon as it would exceed the allowed maximum
+@@ -145,6 +152,9 @@ do_readdir_many(V9fsPDU *pdu, V9fsFidSta
+             e = e->next = g_new0(V9fsDirEnt, 1);
+         }
+         e->dent = qemu_dirent_dup(dent);
++#if !defined(CONFIG_LINUX) && !defined(CONFIG_DARWIN)
++        e->dirent_off = dirent_off;
++#endif
+ 
+         /* perform a full stat() for directory entry if requested by caller */
+         if (dostat) {
+@@ -167,7 +177,11 @@ do_readdir_many(V9fsPDU *pdu, V9fsFidSta
+         }
+ 
+         size += len;
++#if !defined(CONFIG_LINUX) && !defined(CONFIG_DARWIN)
++        saved_dir_pos = dirent_off;
++#else
+         saved_dir_pos = qemu_dirent_off(dent);
++#endif
+     }
+ 
+     /* restore (last) saved position */
Index: pkgsrc/emulators/qemu/patches/patch-hw_9pfs_meson.build
diff -u /dev/null pkgsrc/emulators/qemu/patches/patch-hw_9pfs_meson.build:1.1
--- /dev/null   Sat Mar 15 20:19:15 2025
+++ pkgsrc/emulators/qemu/patches/patch-hw_9pfs_meson.build     Sat Mar 15 20:19:15 2025
@@ -0,0 +1,15 @@
+$NetBSD: patch-hw_9pfs_meson.build,v 1.1 2025/03/15 20:19:15 riastradh Exp $
+
+Add BSD support for fsdev 9p.
+
+--- hw/9pfs/meson.build.orig   2024-12-10 23:46:36.000000000 +0000
++++ hw/9pfs/meson.build
+@@ -14,7 +14,7 @@ fs_ss.add(files(
+ ))
+ if host_os == 'darwin'
+   fs_ss.add(files('9p-util-darwin.c'))
+-elif host_os == 'linux'
++elif host_os == 'linux' or host_os == 'netbsd'
+   fs_ss.add(files('9p-util-linux.c'))
+ endif
+ fs_ss.add(when: 'CONFIG_XEN_BUS', if_true: files('xen-9p-backend.c'))



Home | Main Index | Thread Index | Old Index