Patch Cargo.toml files to enable nix "ioctl" feature

The nix "ioctl" feature is used by both the blkio and virtio-driver
crates. Neither of them enables it explicitly and this can lead to a
compilation failure:

  error[E0432]: unresolved imports `nix::ioctl_none`, `nix::ioctl_read`, `nix::ioctl_write_ptr`
    --> virtio-driver/src/transports/vhost_vdpa/vhost_vdpa_kernel.rs:17:15
     |
  17 |     use nix::{ioctl_none, ioctl_read, ioctl_write_ptr, unistd::write};
     |               ^^^^^^^^^^  ^^^^^^^^^^  ^^^^^^^^^^^^^^^ no `ioctl_write_ptr` in the root
     |               |           |
     |               |           no `ioctl_read` in the root
     |               no `ioctl_none` in the root
  error: cannot determine resolution for the macro `ioctl_read`

Fabio Valentini <decathorpe@gmail.com> identified the root cause:

  The "virtio-driver" crate depends on nix v0.24 with "default-features
  = false", however, the code obviously imports items from "nix" that
  are only present if the "ioctl" feature is enabled. This used to work
  "by accident" because some other crate in libblkio's dependency tree
  used to pull in nix v0.24 with default features enabled. This no
  longer seems to be the case (hard to tell what changed, since koschei
  was not enabled).

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Stefan Hajnoczi 2023-04-18 16:20:33 -04:00 committed by Stefan Hajnoczi
parent 18a2b40283
commit ebf92608f5
2 changed files with 27 additions and 1 deletions

View File

@ -0,0 +1,25 @@
diff --git a/blkio/Cargo.toml b/blkio/Cargo.toml
index ca3f24d..4148840 100644
--- a/blkio/Cargo.toml
+++ b/blkio/Cargo.toml
@@ -28,6 +28,6 @@ concat-idents = "1.1"
const-cstr = "0.3"
io-uring = { version = "0.5.10", optional = true }
lazy_static = "1.1"
-nix = { version = "0.24", default-features = false, features = ["event", "feature", "fs", "mman"] }
+nix = { version = "0.24", default-features = false, features = ["event", "feature", "fs", "ioctl", "mman"] }
pci-driver = { version = "0.1.2", default-features = false, optional = true }
virtio-driver = { path = "../virtio-driver", version = "0.4.1", default-features = false, optional = true }
diff --git a/virtio-driver/Cargo.toml b/virtio-driver/Cargo.toml
index 94c18d3..2ba6f63 100644
--- a/virtio-driver/Cargo.toml
+++ b/virtio-driver/Cargo.toml
@@ -17,7 +17,7 @@ _unsafe-op-in-unsafe-fn = []
[dependencies]
bitflags = "1.2"
-nix = { version = "0.24", default-features = false, features = ["event"] }
+nix = { version = "0.24", default-features = false, features = ["event", "ioctl"] }
memmap2 = { version = ">=0.1, <0.6", optional = true }
pci-driver = { version = "0.1.2", default-features = false, optional = true }
virtio-bindings = { version = "0.1", features = ["virtio-v5_0_0"], optional = true }

View File

@ -5,9 +5,10 @@ Version: 1.2.2
Summary: Block device I/O library
Name: libblkio
Release: 4%{?dist}
Release: 5%{?dist}
URL: %{forgeurl}
Source0: %{forgesource}
Patch0: fix-nix-ioctl-feature.patch
License: (Apache-2.0 OR MIT) AND (Apache-2.0 OR BSD-3-Clause) AND MIT AND BSD-3-Clause AND Unicode-DFS-2016
# Basic build requirements.