[PATCH] vhost: Fix ioctl # for VHOST_[GS]ET_FORK_FROM_OWNER

Namhyung Kim posted 1 patch 1 month, 2 weeks ago
include/uapi/linux/vhost.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] vhost: Fix ioctl # for VHOST_[GS]ET_FORK_FROM_OWNER
Posted by Namhyung Kim 1 month, 2 weeks ago
The VHOST_[GS]ET_FEATURES_ARRAY ioctl already took 0x83 and it would
result in a build error when the vhost uapi header is used for perf tool
build like below.

  In file included from trace/beauty/ioctl.c:93:
  tools/perf/trace/beauty/generated/ioctl/vhost_virtio_ioctl_array.c: In function ‘ioctl__scnprintf_vhost_virtio_cmd’:
  tools/perf/trace/beauty/generated/ioctl/vhost_virtio_ioctl_array.c:36:18: error: initialized field overwritten [-Werror=override-init]
     36 |         [0x83] = "SET_FORK_FROM_OWNER",
        |                  ^~~~~~~~~~~~~~~~~~~~~
  tools/perf/trace/beauty/generated/ioctl/vhost_virtio_ioctl_array.c:36:18: note: (near initialization for ‘vhost_virtio_ioctl_cmds[131]’)

Fixes: 7d9896e9f6d02d8a ("vhost: Reintroduce kthread API and add mode selection")
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 include/uapi/linux/vhost.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
index 283348b64af9ac59..c57674a6aa0dbbea 100644
--- a/include/uapi/linux/vhost.h
+++ b/include/uapi/linux/vhost.h
@@ -260,7 +260,7 @@
  * When fork_owner is set to VHOST_FORK_OWNER_KTHREAD:
  *   - Vhost will create vhost workers as kernel threads.
  */
-#define VHOST_SET_FORK_FROM_OWNER _IOW(VHOST_VIRTIO, 0x83, __u8)
+#define VHOST_SET_FORK_FROM_OWNER _IOW(VHOST_VIRTIO, 0x84, __u8)
 
 /**
  * VHOST_GET_FORK_OWNER - Get the current fork_owner flag for the vhost device.
@@ -268,6 +268,6 @@
  *
  * @return: An 8-bit value indicating the current thread mode.
  */
-#define VHOST_GET_FORK_FROM_OWNER _IOR(VHOST_VIRTIO, 0x84, __u8)
+#define VHOST_GET_FORK_FROM_OWNER _IOR(VHOST_VIRTIO, 0x85, __u8)
 
 #endif
-- 
2.51.0.rc1.167.g924127e9c0-goog

Re: [PATCH] vhost: Fix ioctl # for VHOST_[GS]ET_FORK_FROM_OWNER
Posted by Michael S. Tsirkin 1 month, 2 weeks ago
On Mon, Aug 18, 2025 at 11:39:57PM -0700, Namhyung Kim wrote:
> The VHOST_[GS]ET_FEATURES_ARRAY ioctl already took 0x83 and it would
> result in a build error when the vhost uapi header is used for perf tool
> build like below.
> 
>   In file included from trace/beauty/ioctl.c:93:
>   tools/perf/trace/beauty/generated/ioctl/vhost_virtio_ioctl_array.c: In function ‘ioctl__scnprintf_vhost_virtio_cmd’:
>   tools/perf/trace/beauty/generated/ioctl/vhost_virtio_ioctl_array.c:36:18: error: initialized field overwritten [-Werror=override-init]
>      36 |         [0x83] = "SET_FORK_FROM_OWNER",
>         |                  ^~~~~~~~~~~~~~~~~~~~~
>   tools/perf/trace/beauty/generated/ioctl/vhost_virtio_ioctl_array.c:36:18: note: (near initialization for ‘vhost_virtio_ioctl_cmds[131]’)
> 
> Fixes: 7d9896e9f6d02d8a ("vhost: Reintroduce kthread API and add mode selection")
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Applied, thanks a lot!

> ---
>  include/uapi/linux/vhost.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
> index 283348b64af9ac59..c57674a6aa0dbbea 100644
> --- a/include/uapi/linux/vhost.h
> +++ b/include/uapi/linux/vhost.h
> @@ -260,7 +260,7 @@
>   * When fork_owner is set to VHOST_FORK_OWNER_KTHREAD:
>   *   - Vhost will create vhost workers as kernel threads.
>   */
> -#define VHOST_SET_FORK_FROM_OWNER _IOW(VHOST_VIRTIO, 0x83, __u8)
> +#define VHOST_SET_FORK_FROM_OWNER _IOW(VHOST_VIRTIO, 0x84, __u8)
>  
>  /**
>   * VHOST_GET_FORK_OWNER - Get the current fork_owner flag for the vhost device.
> @@ -268,6 +268,6 @@
>   *
>   * @return: An 8-bit value indicating the current thread mode.
>   */
> -#define VHOST_GET_FORK_FROM_OWNER _IOR(VHOST_VIRTIO, 0x84, __u8)
> +#define VHOST_GET_FORK_FROM_OWNER _IOR(VHOST_VIRTIO, 0x85, __u8)
>  
>  #endif
> -- 
> 2.51.0.rc1.167.g924127e9c0-goog

Re: [PATCH] vhost: Fix ioctl # for VHOST_[GS]ET_FORK_FROM_OWNER
Posted by Lei Yang 1 month, 2 weeks ago
Tested this patch with virtio-net regression tests, everything works fine.

Tested-by: Lei Yang <leiyang@redhat.com>


On Tue, Aug 19, 2025 at 7:25 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Mon, Aug 18, 2025 at 11:39:57PM -0700, Namhyung Kim wrote:
> > The VHOST_[GS]ET_FEATURES_ARRAY ioctl already took 0x83 and it would
> > result in a build error when the vhost uapi header is used for perf tool
> > build like below.
> >
> >   In file included from trace/beauty/ioctl.c:93:
> >   tools/perf/trace/beauty/generated/ioctl/vhost_virtio_ioctl_array.c: In function ‘ioctl__scnprintf_vhost_virtio_cmd’:
> >   tools/perf/trace/beauty/generated/ioctl/vhost_virtio_ioctl_array.c:36:18: error: initialized field overwritten [-Werror=override-init]
> >      36 |         [0x83] = "SET_FORK_FROM_OWNER",
> >         |                  ^~~~~~~~~~~~~~~~~~~~~
> >   tools/perf/trace/beauty/generated/ioctl/vhost_virtio_ioctl_array.c:36:18: note: (near initialization for ‘vhost_virtio_ioctl_cmds[131]’)
> >
> > Fixes: 7d9896e9f6d02d8a ("vhost: Reintroduce kthread API and add mode selection")
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
>
> Applied, thanks a lot!
>
> > ---
> >  include/uapi/linux/vhost.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
> > index 283348b64af9ac59..c57674a6aa0dbbea 100644
> > --- a/include/uapi/linux/vhost.h
> > +++ b/include/uapi/linux/vhost.h
> > @@ -260,7 +260,7 @@
> >   * When fork_owner is set to VHOST_FORK_OWNER_KTHREAD:
> >   *   - Vhost will create vhost workers as kernel threads.
> >   */
> > -#define VHOST_SET_FORK_FROM_OWNER _IOW(VHOST_VIRTIO, 0x83, __u8)
> > +#define VHOST_SET_FORK_FROM_OWNER _IOW(VHOST_VIRTIO, 0x84, __u8)
> >
> >  /**
> >   * VHOST_GET_FORK_OWNER - Get the current fork_owner flag for the vhost device.
> > @@ -268,6 +268,6 @@
> >   *
> >   * @return: An 8-bit value indicating the current thread mode.
> >   */
> > -#define VHOST_GET_FORK_FROM_OWNER _IOR(VHOST_VIRTIO, 0x84, __u8)
> > +#define VHOST_GET_FORK_FROM_OWNER _IOR(VHOST_VIRTIO, 0x85, __u8)
> >
> >  #endif
> > --
> > 2.51.0.rc1.167.g924127e9c0-goog
>
>