rust-vmm / virtio-bindings

This crate is now part of the vm-virtio workspace: https://github.com/rust-vmm/vm-virtio
Apache License 2.0
15 stars 8 forks source link

Why are the generic defines included in the device bindings? #4

Open stsquad opened 3 years ago

stsquad commented 3 years ago

Specifically I'm thinking of the following:

pub const VIRTIO_ID_NET: u32 = 1;
pub const VIRTIO_ID_BLOCK: u32 = 2;
pub const VIRTIO_ID_CONSOLE: u32 = 3;
pub const VIRTIO_ID_RNG: u32 = 4;
pub const VIRTIO_ID_BALLOON: u32 = 5;
pub const VIRTIO_ID_RPMSG: u32 = 7;
pub const VIRTIO_ID_SCSI: u32 = 8;
pub const VIRTIO_ID_9P: u32 = 9;
pub const VIRTIO_ID_RPROC_SERIAL: u32 = 11;
pub const VIRTIO_ID_CAIF: u32 = 12;
pub const VIRTIO_ID_GPU: u32 = 16;
pub const VIRTIO_ID_INPUT: u32 = 18;
pub const VIRTIO_ID_VSOCK: u32 = 19;
pub const VIRTIO_ID_CRYPTO: u32 = 20;
pub const VIRTIO_CONFIG_S_ACKNOWLEDGE: u32 = 1;
pub const VIRTIO_CONFIG_S_DRIVER: u32 = 2;
pub const VIRTIO_CONFIG_S_DRIVER_OK: u32 = 4;
pub const VIRTIO_CONFIG_S_FEATURES_OK: u32 = 8;
pub const VIRTIO_CONFIG_S_NEEDS_RESET: u32 = 64;
pub const VIRTIO_CONFIG_S_FAILED: u32 = 128;
pub const VIRTIO_TRANSPORT_F_START: u32 = 28;
pub const VIRTIO_TRANSPORT_F_END: u32 = 38;
pub const VIRTIO_F_NOTIFY_ON_EMPTY: u32 = 24;
pub const VIRTIO_F_ANY_LAYOUT: u32 = 27;
pub const VIRTIO_F_VERSION_1: u32 = 32;
pub const VIRTIO_F_IOMMU_PLATFORM: u32 = 33;
pub const VIRTIO_F_RING_PACKED: u32 = 34;
pub const VIRTIO_F_ORDER_PLATFORM: u32 = 36;
pub const VIRTIO_F_SR_IOV: u32 = 37;

which should probably be in there own module (or possibly the vring module)? Thoughts?

alexandruag commented 3 years ago

Yeah, so I don't know about all of these off the top of my head, but I can recognize some as values defined by the standard, which don't have to be consumed/exported as bindings. The biggest reason why they aren't in their own modules is (generally speaking) because those modules don't exist yet upstream, but we're working on device bits and parts as well and hopefully things will start appearing.

jiangliu commented 2 years ago

We face the same issue in vhost-user-backend crate too, may be some consts related to virtio transport may be moved/redefined in vm-virtio/virtio-queue.