hw/scsi/vhost-scsi: fix build with older kernel headers
PATCH 1/1 hw/scsi/vhost-scsi: fix build with older kernel headers
From: Quan Sun <[email protected]>
On build hosts with kernel headers older than 6.0, the system's <linux/vhost_types.h> does not define struct vhost_vring_worker or struct vhost_worker_state, causing compilation of vhost-scsi.c to fail:
error: storage size of 'vq_worker' isn't known
Fix by including standard-headers/linux/vhost_types.h before the system's <linux/vhost.h>, matching the existing pattern used in hw/virtio/vhost-backend.c. QEMU's bundled header provides the struct definitions, and its include guard prevents redefinition when the system header pulls in its own vhost_types.h.
--- hw/scsi/vhost-scsi.c | 1 + 1 file changed, 1 insertion(+)
hw/scsi/vhost-scsi.c +1 -0
@@ -15,6 +15,7 @@*/ #include "qemu/osdep.h" +#include "standard-headers/linux/vhost_types.h" #include <linux/vhost.h> #include <sys/ioctl.h> #include "qapi/error.h"
Signature · 1 line
2.43.0
Quoted 9 lines · On Mon, May 25, 2026 at 11:27:30AM -0700, [email protected] wrote:
From: Quan Sun <[email protected]>
On build hosts with kernel headers older than 6.0, the system's <
linux/vhost_types.h> does not define structvhost_vring_workeror structvhost_worker_state, causing compilation ofvhost-scsi.cto fail:error: storage size of '
vq_worker' isn't known
Quoted 7 lines
Fix by including
standard-headers/linux/vhost_types.hbefore the system's <linux/vhost.h>, matching the existing pattern used inhw/virtio/vhost-backend.c. QEMU's bundled header provides the struct definitions, and its include guard prevents redefinition when the system header pulls in its ownvhost_types.h.Signed-off-by Quan Sun <[email protected]>
Hmm. maybe replace linux/vhost.h with standard-headers/linux/vhost.h then?
Quoted 18 lines
--- hw/scsi/vhost-scsi.c | 1 + 1 file changed, 1 insertion(+)hw/scsi/vhost-scsi.c +1
-0@@ -15,6 +15,7 @@*/ #include "qemu/osdep.h" +#include "standard-headers/linux/vhost_types.h" #include <linux/vhost.h> #include <sys/ioctl.h> #include "qapi/error.h" Signature · 1 line
2.43.0
Quoted 13 lines · Michael S. Tsirkin
CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.Quoted 9 lines · On Mon, May 25, 2026 at 11:27:30AM -0700,[email protected] wrote:
From: Quan Sun<[email protected]>
On build hosts with kernel headers older than 6.0, the system's <
linux/vhost_types.h> does not define structvhost_vring_workeror structvhost_worker_state, causing compilation ofvhost-scsi.cto fail:error: storage size of '
vq_worker' isn't known
Quoted 8 lines
Quoted 7 lines
Fix by including
standard-headers/linux/vhost_types.hbefore the system's <linux/vhost.h>, matching the existing pattern used inhw/virtio/vhost-backend.c. QEMU's bundled header provides the struct definitions, and its include guard prevents redefinition when the system header pulls in its ownvhost_types.h.Signed-off-by Quan Sun<[email protected]>Hmm. maybe replace
linux/vhost.hwithstandard-headers/linux/vhost.hthen?
Hi Michael,
It seems there is no standard-headers/linux/vhost.h in QEMU's tree — onlystandard-headers/linux/vhost_types.h. The file linux/vhost.h (the kernel header) is
still needed here for the vhost-scsi specific definitions (struct vhost_scsi_target, VHOST_SCSI_ABI_VERSION). The approach in this patch matches the existing pattern in hw/virtio/vhost-backend.c, which also includes standard-headers/linux/vhost_types.h before linux/vhost.h to get the struct
definitions that may be missing from older host kernel headers.
Thanks,
Quan
Quoted 18 lines
Quoted 18 lines
--- hw/scsi/vhost-scsi.c | 1 + 1 file changed, 1 insertion(+)hw/scsi/vhost-scsi.c +1
-1@@ -15,6 +15,7 @@*/ #include "qemu/osdep.h" +#include "standard-headers/linux/vhost_types.h" #include <linux/vhost.h> #include <sys/ioctl.h> #include "qapi/error.h" --2.43.0
Quoted 36 lines · Quan Sun
Quoted 13 lines · Michael S. Tsirkin
CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.Quoted 9 lines · On Mon, May 25, 2026 at 11:27:30AM -0700,[email protected] wrote:
From: Quan Sun<[email protected]>
On build hosts with kernel headers older than 6.0, the system's <
linux/vhost_types.h> does not define structvhost_vring_workeror structvhost_worker_state, causing compilation ofvhost-scsi.cto fail:error: storage size of '
vq_worker' isn't knownQuoted 8 lines
Quoted 7 lines
Fix by including
standard-headers/linux/vhost_types.hbefore the system's <linux/vhost.h>, matching the existing pattern used inhw/virtio/vhost-backend.c. QEMU's bundled header provides the struct definitions, and its include guard prevents redefinition when the system header pulls in its ownvhost_types.h.Signed-off-by Quan Sun<[email protected]>Hmm. maybe replace
linux/vhost.hwithstandard-headers/linux/vhost.hthen?Hi Michael,
It seems there is no
standard-headers/linux/vhost.hin QEMU's tree — onlystandard-headers/linux/vhost_types.h. The filelinux/vhost.h(the kernel header) is
still needed here for the vhost-scsi specific definitions (structvhost_scsi_target,VHOST_SCSI_ABI_VERSION). The approach in this patch matches the existing pattern inhw/virtio/vhost-backend.c, which also includesstandard-headers/linux/vhost_types.hbeforelinux/vhost.hto get the struct definitions that may be missing from older host kernel headers.
Quoted 3 lines
Thanks,
Quan
Alright.
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
--- hw/scsi/vhost-scsi.c | 1 + 1 file changed, 1 insertion(+)hw/scsi/vhost-scsi.c +1
-1@@ -15,6 +15,7 @@*/ #include "qemu/osdep.h" +#include "standard-headers/linux/vhost_types.h" #include <linux/vhost.h> #include <sys/ioctl.h> #include "qapi/error.h" --2.43.0
Quoted 15 lines · On 25/5/26 20:27, [email protected] wrote:
From: Quan Sun <[email protected]>
On build hosts with kernel headers older than 6.0, the system's <
linux/vhost_types.h> does not define structvhost_vring_workeror structvhost_worker_state, causing compilation ofvhost-scsi.cto fail:error: storage size of '
vq_worker' isn't knownFix by including
standard-headers/linux/vhost_types.hbefore the system's <linux/vhost.h>, matching the existing pattern used inhw/virtio/vhost-backend.c. QEMU's bundled header provides the struct definitions, and its include guard prevents redefinition when the system header pulls in its ownvhost_types.h.
Quoted 4 lines
Signed-off-by Quan Sun <[email protected]>--- hw/scsi/vhost-scsi.c | 1 + 1 file changed, 1 insertion(+)