Skip to contentSkip to conversation

virtio: uniform virtio device IDs

RFC PATCH Superseded Tiejun Chen 1 participant 2 messages Feb 6, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 virtio: uniform virtio device IDs

Actually we define these device IDs in virtio standard, so we'd better put them into one common place to manage conveniently. Here I also add VIRTIO_ID_RESERVE according to virtio spec.

---
 hw/9pfs/virtio-9p.h                |  2 --
 include/hw/virtio/virtio-balloon.h |  3 ---
 include/hw/virtio/virtio-blk.h     |  3 ---
 include/hw/virtio/virtio-rng.h     |  3 ---
 include/hw/virtio/virtio-scsi.h    |  3 ---
 include/hw/virtio/virtio-serial.h  |  3 ---
 include/hw/virtio/virtio.h         | 14 ++++++++++++++
 pc-bios/s390-ccw/virtio.h          |  7 -------
 8 files changed, 14 insertions(+), 24 deletions(-)
hw/9pfs/virtio-9p.h +0 -2
index 2c3603a..228e05d 100644
@@ -146,8 +146,6 @@ struct V9fsPDU
 
 /* from Linux's linux/virtio_9p.h */
 
-/* The ID for virtio console */
-#define VIRTIO_ID_9P    9
 #define MAX_REQ         128
 #define MAX_TAG_LEN     32
 
include/hw/virtio/virtio-balloon.h +0 -3
index f863bfe..6e0a775 100644
@@ -24,9 +24,6 @@
 
 /* from Linux's linux/virtio_balloon.h */
 
-/* The ID for virtio_balloon */
-#define VIRTIO_ID_BALLOON 5
-
 /* The feature bitmap for virtio balloon */
 #define VIRTIO_BALLOON_F_MUST_TELL_HOST 0 /* Tell before reclaiming pages */
 #define VIRTIO_BALLOON_F_STATS_VQ 1       /* Memory stats virtqueue */
include/hw/virtio/virtio-blk.h +0 -3
index 4652b70..6ee3e8f 100644
@@ -25,9 +25,6 @@
 
 /* from Linux's linux/virtio_blk.h */
 
-/* The ID for virtio_block */
-#define VIRTIO_ID_BLOCK 2
-
 /* Feature bits */
 #define VIRTIO_BLK_F_BARRIER    0       /* Does host support barriers? */
 #define VIRTIO_BLK_F_SIZE_MAX   1       /* Indicates maximum segment size */
include/hw/virtio/virtio-rng.h +0 -3
index 14e85a5..e2bb6ce 100644
@@ -21,9 +21,6 @@
 #define VIRTIO_RNG_GET_PARENT_CLASS(obj) \
         OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_RNG)
 
-/* The Virtio ID for the virtio rng device */
-#define VIRTIO_ID_RNG    4
-
 struct VirtIORNGConf {
     RngBackend *rng;
     uint64_t max_bytes;
include/hw/virtio/virtio-scsi.h +0 -3
index bf17cc9..9606f43 100644
@@ -29,9 +29,6 @@
         OBJECT_CHECK(VirtIOSCSI, (obj), TYPE_VIRTIO_SCSI)
 
 
-/* The ID for virtio_scsi */
-#define VIRTIO_ID_SCSI  8
-
 /* Feature Bits */
 #define VIRTIO_SCSI_F_INOUT                    0
 #define VIRTIO_SCSI_F_HOTPLUG                  1
include/hw/virtio/virtio-serial.h +0 -3
index 11af978..1dcced6 100644
@@ -20,9 +20,6 @@
 
 /* == Interface shared between the guest kernel and qemu == */
 
-/* The Virtio ID for virtio console / serial ports */
-#define VIRTIO_ID_CONSOLE		3
-
 /* Features supported */
 #define VIRTIO_CONSOLE_F_MULTIPORT	1
 
include/hw/virtio/virtio.h +14 -0
index f24997d..c2d3731 100644
@@ -23,6 +23,20 @@
 #include "hw/virtio/virtio-9p.h"
 #endif
 
+/* from Linux's linux/virtio_ids.h */
+
+#define VIRTIO_ID_RESERVED  0 /* invalid virtio device */
+#define VIRTIO_ID_NET		1 /* virtio net */
+#define VIRTIO_ID_BLOCK		2 /* virtio block */
+#define VIRTIO_ID_CONSOLE	3 /* virtio console */
+#define VIRTIO_ID_RNG		4 /* virtio rng */
+#define VIRTIO_ID_BALLOON	5 /* virtio balloon */
+#define VIRTIO_ID_RPMSG		7 /* virtio remote processor messaging */
+#define VIRTIO_ID_SCSI		8 /* virtio scsi */
+#define VIRTIO_ID_9P		9 /* 9p virtio console */
+#define VIRTIO_ID_RPROC_SERIAL 11 /* virtio remoteproc serial link */
+#define VIRTIO_ID_CAIF	       12 /* Virtio caif */
+
 /* from Linux's linux/virtio_config.h */
 
 /* Status byte for guest to report progress, and synchronize features. */
pc-bios/s390-ccw/virtio.h +0 -7
index c23466b..6713a45 100644
@@ -23,13 +23,6 @@
 /* We've given up on this device. */
 #define VIRTIO_CONFIG_S_FAILED          0x80
 
-enum virtio_dev_type {
-    VIRTIO_ID_NET = 1,
-    VIRTIO_ID_BLOCK = 2,
-    VIRTIO_ID_CONSOLE = 3,
-    VIRTIO_ID_BALLOON = 5,
-};
-
 struct virtio_dev_header {
     enum virtio_dev_type type : 8;
     u8  num_vq;
Signature · 1 line
1.9.1
#1 lore raw

Sorry please ignore this to review another revision.

Thanks
Tiejun

Quoted 143 lines · Tiejun Chen

Actually we define these device IDs in virtio standard, so we'd better put them into one common place to manage conveniently. Here I also add VIRTIO_ID_RESERVE according to virtio spec.

---
  hw/9pfs/virtio-9p.h                |  2 --
  include/hw/virtio/virtio-balloon.h |  3 ---
  include/hw/virtio/virtio-blk.h     |  3 ---
  include/hw/virtio/virtio-rng.h     |  3 ---
  include/hw/virtio/virtio-scsi.h    |  3 ---
  include/hw/virtio/virtio-serial.h  |  3 ---
  include/hw/virtio/virtio.h         | 14 ++++++++++++++
  pc-bios/s390-ccw/virtio.h          |  7 -------
  8 files changed, 14 insertions(+), 24 deletions(-)
hw/9pfs/virtio-9p.h +0 -2
index 2c3603a..228e05d 100644
@@ -146,8 +146,6 @@ struct V9fsPDU
 
  /* from Linux's linux/virtio_9p.h */
 
-/* The ID for virtio console */
-#define VIRTIO_ID_9P    9
  #define MAX_REQ         128
  #define MAX_TAG_LEN     32
 
include/hw/virtio/virtio-balloon.h +0 -3
index f863bfe..6e0a775 100644
@@ -24,9 +24,6 @@
 
  /* from Linux's linux/virtio_balloon.h */
 
-/* The ID for virtio_balloon */
-#define VIRTIO_ID_BALLOON 5
-
  /* The feature bitmap for virtio balloon */
  #define VIRTIO_BALLOON_F_MUST_TELL_HOST 0 /* Tell before reclaiming pages */
  #define VIRTIO_BALLOON_F_STATS_VQ 1       /* Memory stats virtqueue */
include/hw/virtio/virtio-blk.h +0 -3
index 4652b70..6ee3e8f 100644
@@ -25,9 +25,6 @@
 
  /* from Linux's linux/virtio_blk.h */
 
-/* The ID for virtio_block */
-#define VIRTIO_ID_BLOCK 2
-
  /* Feature bits */
  #define VIRTIO_BLK_F_BARRIER    0       /* Does host support barriers? */
  #define VIRTIO_BLK_F_SIZE_MAX   1       /* Indicates maximum segment size */
include/hw/virtio/virtio-rng.h +0 -3
index 14e85a5..e2bb6ce 100644
@@ -21,9 +21,6 @@
  #define VIRTIO_RNG_GET_PARENT_CLASS(obj) \
          OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_RNG)
 
-/* The Virtio ID for the virtio rng device */
-#define VIRTIO_ID_RNG    4
-
  struct VirtIORNGConf {
      RngBackend *rng;
      uint64_t max_bytes;
include/hw/virtio/virtio-scsi.h +0 -3
index bf17cc9..9606f43 100644
@@ -29,9 +29,6 @@
          OBJECT_CHECK(VirtIOSCSI, (obj), TYPE_VIRTIO_SCSI)
 
 
-/* The ID for virtio_scsi */
-#define VIRTIO_ID_SCSI  8
-
  /* Feature Bits */
  #define VIRTIO_SCSI_F_INOUT                    0
  #define VIRTIO_SCSI_F_HOTPLUG                  1
include/hw/virtio/virtio-serial.h +0 -3
index 11af978..1dcced6 100644
@@ -20,9 +20,6 @@
 
  /* == Interface shared between the guest kernel and qemu == */
 
-/* The Virtio ID for virtio console / serial ports */
-#define VIRTIO_ID_CONSOLE		3
-
  /* Features supported */
  #define VIRTIO_CONSOLE_F_MULTIPORT	1
 
include/hw/virtio/virtio.h +14 -0
index f24997d..c2d3731 100644
@@ -23,6 +23,20 @@
  #include "hw/virtio/virtio-9p.h"
  #endif
 
+/* from Linux's linux/virtio_ids.h */
+
+#define VIRTIO_ID_RESERVED  0 /* invalid virtio device */
+#define VIRTIO_ID_NET		1 /* virtio net */
+#define VIRTIO_ID_BLOCK		2 /* virtio block */
+#define VIRTIO_ID_CONSOLE	3 /* virtio console */
+#define VIRTIO_ID_RNG		4 /* virtio rng */
+#define VIRTIO_ID_BALLOON	5 /* virtio balloon */
+#define VIRTIO_ID_RPMSG		7 /* virtio remote processor messaging */
+#define VIRTIO_ID_SCSI		8 /* virtio scsi */
+#define VIRTIO_ID_9P		9 /* 9p virtio console */
+#define VIRTIO_ID_RPROC_SERIAL 11 /* virtio remoteproc serial link */
+#define VIRTIO_ID_CAIF	       12 /* Virtio caif */
+
  /* from Linux's linux/virtio_config.h */
 
  /* Status byte for guest to report progress, and synchronize features. */
pc-bios/s390-ccw/virtio.h +0 -7
index c23466b..6713a45 100644
@@ -23,13 +23,6 @@
  /* We've given up on this device. */
  #define VIRTIO_CONFIG_S_FAILED          0x80
 
-enum virtio_dev_type {
-    VIRTIO_ID_NET = 1,
-    VIRTIO_ID_BLOCK = 2,
-    VIRTIO_ID_CONSOLE = 3,
-    VIRTIO_ID_BALLOON = 5,
-};
-
  struct virtio_dev_header {
      enum virtio_dev_type type : 8;
      u8  num_vq;