diff --git a/0001-vram-Skip-listing-devices-when-no-platforms-are-foun.patch b/0001-vram-Skip-listing-devices-when-no-platforms-are-foun.patch new file mode 100644 index 0000000..8301565 --- /dev/null +++ b/0001-vram-Skip-listing-devices-when-no-platforms-are-foun.patch @@ -0,0 +1,59 @@ +From cad6894ec6dc18b318d0948fadf5833ecd75cb0f Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Sun, 26 Oct 2025 22:25:10 +0000 +Subject: [PATCH] vram: Skip listing devices when no platforms are found + +In a chroot-type test environment, tests/test-dump-plugin.sh failed +with: + + + nbdkit vram --dump-plugin + nbdkit: error: clGetPlatformIDs: error -1001 (unknown OpenCL error) + +-1001 is the extended error CL_PLATFORM_NOT_FOUND_KHR +--- + plugins/vram/opencl-errors.h | 3 +++ + plugins/vram/vram.c | 7 +++++++ + 2 files changed, 10 insertions(+) + +diff --git a/plugins/vram/opencl-errors.h b/plugins/vram/opencl-errors.h +index b5d185fc..dd6fba92 100644 +--- a/plugins/vram/opencl-errors.h ++++ b/plugins/vram/opencl-errors.h +@@ -101,6 +101,9 @@ opencl_errstr (cl_int err) + case_return_string(CL_INVALID_COMPILER_OPTIONS ); + case_return_string(CL_INVALID_LINKER_OPTIONS ); + case_return_string(CL_INVALID_DEVICE_PARTITION_COUNT ); ++ ++ /* Extended. */ ++ case_return_string(CL_PLATFORM_NOT_FOUND_KHR ); + default: return "unknown OpenCL error"; + } + } +diff --git a/plugins/vram/vram.c b/plugins/vram/vram.c +index 4b391e22..9819f0db 100644 +--- a/plugins/vram/vram.c ++++ b/plugins/vram/vram.c +@@ -41,6 +41,7 @@ + + #define CL_TARGET_OPENCL_VERSION 200 /* OpenCL >= 2.0 */ + #include ++#include + + #define NBDKIT_API_VERSION 2 + #include +@@ -126,6 +127,12 @@ get_all_devices (void) + /* Build the list of all devices from all platforms as a flat list. */ + what = "clGetPlatformIDs"; + r = clGetPlatformIDs (0, NULL, &num_platforms); ++ if (r == CL_PLATFORM_NOT_FOUND_KHR) { ++ /* OpenCL seems to return this when no platform is detected at ++ * all, so just return the empty list in this case. ++ */ ++ return; ++ } + if (r != CL_SUCCESS) goto err; + platform_ids = calloc (num_platforms, sizeof platform_ids[0]); + if (!platform_ids) { +-- +2.47.3 + diff --git a/0002-linuxdisk-Fix-parsing-of-last-line-of-du-command-out.patch b/0002-linuxdisk-Fix-parsing-of-last-line-of-du-command-out.patch new file mode 100644 index 0000000..a85c54f --- /dev/null +++ b/0002-linuxdisk-Fix-parsing-of-last-line-of-du-command-out.patch @@ -0,0 +1,71 @@ +From 01b8e557ce129b2f4677061ba04bbb5ff2a703eb Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Mon, 27 Oct 2025 09:15:47 +0000 +Subject: [PATCH] linuxdisk: Fix parsing of last line of 'du' command output + +A recent change to glibc breaks this code. Previously we could read +the lines of output from the 'du' command until getline(3) returned +EOF, and the 'line' buffer would contain the last line read. However +after this change, glibc now sets line[0] = '\0' in the EOF case, +breaking the last line of output that we wanted to parse. + +https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=33eff78c8b28adc4963987880e10d96761f2a167 + +We also previously didn't handle the unlikely case where 'du' produces +no output at all. Fix both problems here. +--- + plugins/linuxdisk/filesystem.c | 23 ++++++++++++++++++----- + 1 file changed, 18 insertions(+), 5 deletions(-) + +diff --git a/plugins/linuxdisk/filesystem.c b/plugins/linuxdisk/filesystem.c +index 3e4e2f3a..283af61a 100644 +--- a/plugins/linuxdisk/filesystem.c ++++ b/plugins/linuxdisk/filesystem.c +@@ -148,7 +148,7 @@ create_filesystem (struct virtual_disk *disk) + static int64_t + estimate_size (void) + { +- CLEANUP_FREE char *command = NULL, *line = NULL; ++ CLEANUP_FREE char *command = NULL, *line = NULL, *lastline = NULL; + size_t len = 0; + FILE *fp; + int64_t ret; +@@ -177,8 +177,16 @@ estimate_size (void) + + /* Ignore everything up to the last line. */ + len = 0; +- while (getline (&line, &len, fp) != -1) +- /* empty */; ++ while (getline (&line, &len, fp) != -1) { ++ nbdkit_debug ("du: %s", line); ++ free (lastline); ++ lastline = strndup (line, len); ++ if (lastline == NULL) { ++ nbdkit_error ("strndup: %m"); ++ pclose (fp); ++ return -1; ++ } ++ } + if (ferror (fp)) { + nbdkit_error ("getline failed: %m"); + pclose (fp); +@@ -193,9 +201,14 @@ estimate_size (void) + if (exit_status_to_nbd_error (r, "pclose: du") == -1) + return -1; + ++ if (lastline == NULL) { ++ nbdkit_error ("no output from du command"); ++ return -1; ++ } ++ + /* Parse the last line. */ +- if (sscanf (line, "%" SCNi64, &ret) != 1 || ret < 0) { +- nbdkit_error ("could not parse last line of output: %s", line); ++ if (sscanf (lastline, "%" SCNi64, &ret) != 1 || ret < 0) { ++ nbdkit_error ("could not parse last line from du command: %s", lastline); + return -1; + } + +-- +2.47.3 + diff --git a/0003-vram-Skip-listing-devices-when-no-devices-found-in-p.patch b/0003-vram-Skip-listing-devices-when-no-devices-found-in-p.patch new file mode 100644 index 0000000..6932c8d --- /dev/null +++ b/0003-vram-Skip-listing-devices-when-no-devices-found-in-p.patch @@ -0,0 +1,42 @@ +From df5e7d1b6f2cbc3e3adbb85312490b148ad0b2fc Mon Sep 17 00:00:00 2001 +From: Eric Blake +Date: Sun, 26 Oct 2025 22:25:10 +0000 +Subject: [PATCH] vram: Skip listing devices when no devices found in platform + +On my laptop, right after installing clinfo and building vram, +clGetDeviceIDs found an AMD device, but was unable to connect to it +(probably further drivers needed), resulting in: + + + nbdkit vram --dump-plugin + ... + nbdkit: error: clGetDeviceIDs: error -1 (CL_DEVICE_NOT_FOUND) + +Similar to the previous fix when a platform is not available, it is +easy to gracefully handle no devices found in a platform. + +Signed-off-by: Eric Blake +--- + plugins/vram/vram.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/plugins/vram/vram.c b/plugins/vram/vram.c +index 9819f0db..64cfe0fa 100644 +--- a/plugins/vram/vram.c ++++ b/plugins/vram/vram.c +@@ -147,6 +147,13 @@ get_all_devices (void) + what = "clGetDeviceIDs"; + r = clGetDeviceIDs (platform_ids[pl_i], CL_DEVICE_TYPE_ALL, 0, NULL, + &num_devices); ++ if (r == CL_DEVICE_NOT_FOUND) { ++ /* OpenCL seems to return this when the platform is found but ++ * the vendor's library is not configured to access devices ++ * within the platform; skip over this platform. ++ */ ++ continue; ++ } + if (r != CL_SUCCESS) goto err; + free (device_ids); + device_ids = calloc (num_devices, sizeof device_ids[0]); +-- +2.47.3 + diff --git a/0004-Fix-mke2fs-command-line.patch b/0004-Fix-mke2fs-command-line.patch new file mode 100644 index 0000000..82ecd5f --- /dev/null +++ b/0004-Fix-mke2fs-command-line.patch @@ -0,0 +1,41 @@ +From ae9a7cf9167bc35aa7278f55af1049ea4aa871e6 Mon Sep 17 00:00:00 2001 +From: Mykola Ivanets +Date: Wed, 29 Oct 2025 23:53:03 +0200 +Subject: [PATCH] Fix mke2fs command line + +Man page says: + +The file system size is specified by fs-size. If fs-size does not have +a suffix, it is interpreted as power-of-two kilobytes, unless the -b +blocksize option is specified, in which case fs-size is interpreted as +the number of blocksize blocks. If the fs-size is suffixed by 'k', 'm', +'g', 't' (either upper-case or lower-case), then it is interpreted in +power-of-two kilobytes, megabytes, gigabytes, terabytes, etc. If +fs-size is omitted, mke2fs will create the file system based on the +device size. + +We could add '-b 1' parameter and specify fs-size, or just remove +fs-size parameter, in this case mke2fs will create the file system based + on device size. I prefer later option just because it will avoid + duplicating fs-size specification twice (in the previous 'truncate' + command and in 'mke2fs'). +--- + tests/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tests/Makefile.am b/tests/Makefile.am +index 53cc00d1..2a7e9623 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -1895,7 +1895,7 @@ ext2.img: disk test-ext2-exportname.sh + cp $< ext2.img.d/disks/disk.img + echo /disks/disk.img > ext2.img.d/manifest + $(TRUNCATE) -s 2147483648 $@-t +- mke2fs -q -F -t ext4 -d ext2.img.d $@-t 2147483648 ++ mke2fs -q -F -t ext4 -d ext2.img.d $@-t + rm -r ext2.img.d + mv $@-t $@ + +-- +2.47.3 + diff --git a/0005-vram-Fix-trim-command.patch b/0005-vram-Fix-trim-command.patch new file mode 100644 index 0000000..4a13fae --- /dev/null +++ b/0005-vram-Fix-trim-command.patch @@ -0,0 +1,31 @@ +From 258822bde3eb4923b309431c6e4d71932e83932d Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Sat, 1 Nov 2025 09:33:37 +0000 +Subject: [PATCH] vram: Fix trim command + +Fix missing updates in the loop, which caused trim operations to spin +forever. + +Fixes: commit e35fb68748ecd1ebab63308db3c9a6ccca12ebcb +--- + plugins/vram/vram.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/plugins/vram/vram.c b/plugins/vram/vram.c +index 64cfe0fa..63e7d5c7 100644 +--- a/plugins/vram/vram.c ++++ b/plugins/vram/vram.c +@@ -811,6 +811,10 @@ vram_trim (void *handle, uint32_t count, uint64_t offset, uint32_t flags) + /* Aligned body */ + while (count >= BUFFER_SIZE) { + free_buffer (bufnum); ++ ++ count -= BUFFER_SIZE; ++ offset += BUFFER_SIZE; ++ bufnum++; + } + + return 0; +-- +2.47.3 + diff --git a/0006-vram-Link-to-radeontop-1.patch b/0006-vram-Link-to-radeontop-1.patch new file mode 100644 index 0000000..f6dbfcc --- /dev/null +++ b/0006-vram-Link-to-radeontop-1.patch @@ -0,0 +1,26 @@ +From 1c501d5c7162ac41e6e49767cdcb8632d5e6535d Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Sat, 1 Nov 2025 09:34:47 +0000 +Subject: [PATCH] vram: Link to radeontop(1) + +This tool is a top-like tool for AMD Radeon cards, very useful when +observing GPU and Video RAM usage in real time. +--- + plugins/vram/nbdkit-vram-plugin.pod | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/plugins/vram/nbdkit-vram-plugin.pod b/plugins/vram/nbdkit-vram-plugin.pod +index b99eb67f..5363a4ca 100644 +--- a/plugins/vram/nbdkit-vram-plugin.pod ++++ b/plugins/vram/nbdkit-vram-plugin.pod +@@ -158,6 +158,7 @@ L, + L, + L, + L, ++L, + L. + + =head1 AUTHORS +-- +2.47.3 + diff --git a/0007-vram-Obey-trim-FUA-flag-by-calling-vram_flush.patch b/0007-vram-Obey-trim-FUA-flag-by-calling-vram_flush.patch new file mode 100644 index 0000000..2b84f4b --- /dev/null +++ b/0007-vram-Obey-trim-FUA-flag-by-calling-vram_flush.patch @@ -0,0 +1,29 @@ +From af18957aa91b61f627c2a56724b717c2dbdbf001 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Sat, 1 Nov 2025 19:05:01 +0000 +Subject: [PATCH] vram: Obey trim FUA flag by calling vram_flush + +Further fix to the vram trim operation, so now we (kind of) obey the +FUA flag by calling vram_flush. Since vram_flush does nothing right +now, this actually makes no difference. +--- + plugins/vram/vram.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/plugins/vram/vram.c b/plugins/vram/vram.c +index 63e7d5c7..fe8bf60e 100644 +--- a/plugins/vram/vram.c ++++ b/plugins/vram/vram.c +@@ -817,6 +817,9 @@ vram_trim (void *handle, uint32_t count, uint64_t offset, uint32_t flags) + bufnum++; + } + ++ if (flags & NBDKIT_FLAG_FUA && vram_flush (handle, 0) == -1) ++ return -1; ++ + return 0; + } + +-- +2.47.3 + diff --git a/nbdkit.spec b/nbdkit.spec index 813f3f5..f3f55b9 100644 --- a/nbdkit.spec +++ b/nbdkit.spec @@ -54,7 +54,7 @@ %global source_directory 1.45-development Name: nbdkit -Version: 1.45.11 +Version: 1.45.12 Release: 1%{?dist} Summary: NBD server @@ -80,7 +80,13 @@ Source3: copy-patches.sh # https://gitlab.com/nbdkit/nbdkit/-/commits/rhel-10.2/ # Patches. -#(nothing) +Patch0001: 0001-vram-Skip-listing-devices-when-no-platforms-are-foun.patch +Patch0002: 0002-linuxdisk-Fix-parsing-of-last-line-of-du-command-out.patch +Patch0003: 0003-vram-Skip-listing-devices-when-no-devices-found-in-p.patch +Patch0004: 0004-Fix-mke2fs-command-line.patch +Patch0005: 0005-vram-Fix-trim-command.patch +Patch0006: 0006-vram-Link-to-radeontop-1.patch +Patch0007: 0007-vram-Obey-trim-FUA-flag-by-calling-vram_flush.patch # For automatic RPM Provides generation. # See: https://rpm-software-management.github.io/rpm/manual/dependency_generators.html @@ -132,8 +138,11 @@ BuildRequires: pkgconfig(libtorrent-rasterbar) %if 0%{?have_blkio} BuildRequires: pkgconfig(blkio) %endif -BuildRequires: bash-completion %if !0%{?rhel} +BuildRequires: pkgconfig(OpenCL) +%endif +BuildRequires: bash-completion +%if 0%{?fedora} || 0%{?rhel} >= 11 BuildRequires: bash-completion-devel %endif BuildRequires: perl-devel @@ -173,9 +182,11 @@ BuildRequires: /usr/bin/lzip BuildRequires: /usr/bin/nbdcopy BuildRequires: /usr/bin/nbdinfo BuildRequires: /usr/bin/nbdsh +%ifnarch %{ix86} BuildRequires: /usr/bin/qemu-img BuildRequires: /usr/bin/qemu-io BuildRequires: /usr/bin/qemu-nbd +%endif BuildRequires: /usr/sbin/sfdisk %if !0%{?rhel} BuildRequires: /usr/bin/socat @@ -580,6 +591,17 @@ VMware VDDK for accessing VMware disks and servers. %endif +%if !0%{?rhel} +%package vram-plugin +Summary: use GPU Video RAM as a network block device +Requires: %{name}-server%{?_isa} = %{version}-%{release} +Recommends: %{_bindir}/clinfo + +%description vram-plugin +This package contains GPU Video RAM support for %{name}. +%endif + + %package basic-filters Summary: Basic filters for %{name} Requires: %{name}-server%{?_isa} = %{version}-%{release} @@ -860,6 +882,7 @@ export PYTHON=%{__python3} --enable-perl \ --enable-tcl \ --enable-torrent \ + --enable-vram \ --with-ext2 \ --with-iso \ --with-libvirt \ @@ -868,6 +891,7 @@ export PYTHON=%{__python3} --disable-perl \ --disable-tcl \ --disable-torrent \ + --disable-vram \ --without-ext2 \ --without-iso \ --without-libvirt \ @@ -932,6 +956,7 @@ popd --disable-torrent \ --disable-valgrind \ --disable-vddk \ + --disable-vram \ --without-bash-completions \ --without-curl \ --without-ext2 \ @@ -1341,6 +1366,15 @@ fi %endif +%if !0%{?rhel} +%files vram-plugin +%doc README.md +%license LICENSE +%{_libdir}/%{name}/plugins/nbdkit-vram-plugin.so +%{_mandir}/man1/nbdkit-vram-plugin.1* +%endif + + %files basic-filters %doc README.md %license LICENSE @@ -1522,7 +1556,7 @@ fi %files bash-completion %license LICENSE -%if !0%{?rhel} +%if 0%{?fedora} || 0%{?rhel} >= 11 %dir %{bash_completions_dir} %{bash_completions_dir}/nbdkit %else @@ -1560,9 +1594,10 @@ fi %changelog -* Mon Oct 20 2025 Richard W.M. Jones - 1.45.11-1 -- Rebase to nbdkit 1.45.11 +* Wed Nov 05 2025 Richard W.M. Jones - 1.45.12-1 +- Rebase to nbdkit 1.45.12 resolves: RHEL-111242 +- Synchronize spec file with Fedora. - vddk: Don't use FNM_PATHNAME when matching export parameter resolves: RHEL-122755 diff --git a/sources b/sources index c2c660f..5539189 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (nbdkit-1.45.11.tar.gz) = b9ba91cfa7e71c415bbc2cb47dd569ce327d8dd9ec28aca03788984872f0a0fd63296f963436740b504950896082c14768bd823f5605d23b63ea149f87f939f5 -SHA512 (nbdkit-1.45.11.tar.gz.sig) = b964604598d50c319c6f04e8cab487f215f6347588b507fdaf752ac8b0929c2e2975d793fbe1f65bf51107b5e087f5c8836589c01b81753e2dce70f9d2e73ae2 +SHA512 (nbdkit-1.45.12.tar.gz) = a28da3e24c333da5b4b22961078095b1d73bb6c219e7cfae783c301b68d8e755ce839fa15bff6354b44ff7227a91eae6a8e264f3e26b5caff8d27c68905ff01b +SHA512 (nbdkit-1.45.12.tar.gz.sig) = 93c497160f196b1a6144819742cee04b1fad663a148dbc4fd82efe73c9a1aabdcb9c01baa9ec84db17a392ae6cde468736750a878bba3e3c130507890f96a8e5