qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC]virtio-blk: add disk-name device property
@ 2016-12-30  2:41 Junkang Fu
  2016-12-30  7:34 ` Cao jin
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Junkang Fu @ 2016-12-30  2:41 UTC (permalink / raw)
  To: stefanha; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 3929 bytes --]

>From 74e913fc41ea98d1dde692175f1e3fb6729342aa Mon Sep 17 00:00:00 2001
From: "junkang.fjk" <junkang.fjk@alibaba-inc.com>
Date: Wed, 24 Aug 2016 19:36:53 +0800
Subject: [PATCH] virtio-blk: add disk-name device property

Current virtio-blk disk name(ex. /dev/vdb) has nothing to do with the
target dev
name specified in libvirt xml file. For example, we may get disk name
/dev/vdb in
VM while target dev specified in libvirt xml is vdc. This may lead to a
little trouble
to find out the relationship between the disk name in VM and somewhere out
of
VM, for example in the control board of Public cloud service providers. I
suggest
if Qemu could add a VIRTIO_BLK_F_DISK_NAME feature, with
VIRTIO_BLK_F_DISK_NAME
capable Qemu and virtio-blk frontend drivers, disk name in the vm can be
specified
as follows:
        -device virtio-blk-pci,disk-name=vdabc

---
 hw/block/virtio-blk.c                       | 5 +++++
 include/hw/virtio/virtio-blk.h              | 1 +
 include/standard-headers/linux/virtio_blk.h | 6 ++++++
 3 files changed, 12 insertions(+)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 331d766..4039fb9 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -716,6 +716,8 @@ static void virtio_blk_update_config(VirtIODevice
*vdev, uint8_t *config)
     blkcfg.alignment_offset = 0;
     blkcfg.wce = blk_enable_write_cache(s->blk);
     virtio_stw_p(vdev, &blkcfg.num_queues, s->conf.num_queues);
+    if (s->disk_name)
+        strncpy((char *)blkcfg.disk_name, s->disk_name, DISK_NAME_LEN);
     memcpy(config, &blkcfg, sizeof(struct virtio_blk_config));
 }
@@ -740,6 +742,8 @@ static uint64_t virtio_blk_get_features(VirtIODevice
*vdev, uint64_t features,
     virtio_add_feature(&features, VIRTIO_BLK_F_GEOMETRY);
     virtio_add_feature(&features, VIRTIO_BLK_F_TOPOLOGY);
     virtio_add_feature(&features, VIRTIO_BLK_F_BLK_SIZE);
+    virtio_add_feature(&features, VIRTIO_BLK_F_DISK_NAME);
+
     if (virtio_has_feature(features, VIRTIO_F_VERSION_1)) {
         if (s->conf.scsi) {
             error_setg(errp, "Please set scsi=off for virtio-blk devices
in order to use virtio 1.0");
@@ -970,6 +974,7 @@ static Property virtio_blk_properties[] = {
     DEFINE_PROP_BIT("request-merging", VirtIOBlock, conf.request_merging,
0,
                     true),
     DEFINE_PROP_UINT16("num-queues", VirtIOBlock, conf.num_queues, 1),
+    DEFINE_PROP_STRING("disk-name", VirtIOBlock, disk_name),
     DEFINE_PROP_END_OF_LIST(),
 };

diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h
index 180bd8d..003e810 100644
--- a/include/hw/virtio/virtio-blk.h
+++ b/include/hw/virtio/virtio-blk.h
@@ -56,6 +56,7 @@ typedef struct VirtIOBlock {
     bool dataplane_disabled;
     bool dataplane_started;
     struct VirtIOBlockDataPlane *dataplane;
+    char *disk_name;
 } VirtIOBlock;

 typedef struct VirtIOBlockReq {
diff --git a/include/standard-headers/linux/virtio_blk.h
b/include/standard-headers/linux/virtio_blk.h
index ab16ec5..1f5d89d 100644
--- a/include/standard-headers/linux/virtio_blk.h
+++ b/include/standard-headers/linux/virtio_blk.h
@@ -38,6 +38,7 @@
 #define VIRTIO_BLK_F_BLK_SIZE  6   /* Block size of disk is available*/
 #define VIRTIO_BLK_F_TOPOLOGY  10  /* Topology information is available */
 #define VIRTIO_BLK_F_MQ        12  /* support more than one vq */
+#define VIRTIO_BLK_F_DISK_NAME  13      /* specify /dev/xxx name */

 /* Legacy feature bits */
 #ifndef VIRTIO_BLK_NO_LEGACY
@@ -51,6 +52,9 @@

 #define VIRTIO_BLK_ID_BYTES    20  /* ID string length */

+/* micro defined in kernel genhd.h */
+#define DISK_NAME_LEN 32
+
 struct virtio_blk_config {
    /* The capacity (in 512-byte sectors). */
    uint64_t capacity;
@@ -84,6 +88,8 @@ struct virtio_blk_config {

    /* number of vqs, only available when VIRTIO_BLK_F_MQ is set */
    uint16_t num_queues;
+
+   uint8_t disk_name[DISK_NAME_LEN];
 } QEMU_PACKED;

 /*
--
1.9.4

[-- Attachment #2: 0001-virtio-blk-add-disk-name-device-property.patch --]
[-- Type: application/octet-stream, Size: 3913 bytes --]

From 74e913fc41ea98d1dde692175f1e3fb6729342aa Mon Sep 17 00:00:00 2001
From: "junkang.fjk" <junkang.fjk@alibaba-inc.com>
Date: Wed, 24 Aug 2016 19:36:53 +0800
Subject: [PATCH] virtio-blk: add disk-name device property

Current virtio-blk disk name(ex. /dev/vdb) has nothing to do with the target dev
name specified in libvirt xml file. For example, we may get disk name /dev/vdb
in VM while target dev specified in libvirt xml is vdc. This may lead to a little
trouble to find out the relationship between the disk name in VM and somewhere out
of VM, for example in the control board of Public cloud service providers. I suggest
if Qemu could add a VIRTIO_BLK_F_DISK_NAME feature, with VIRTIO_BLK_F_DISK_NAME
capable Qemu and virtio-blk frontend drivers, disk name in the vm can be specified
as follows:
        -device virtio-blk-pci,disk-name=vdabc

---
 hw/block/virtio-blk.c                       | 5 +++++
 include/hw/virtio/virtio-blk.h              | 1 +
 include/standard-headers/linux/virtio_blk.h | 6 ++++++
 3 files changed, 12 insertions(+)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 331d766..4039fb9 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -716,6 +716,8 @@ static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config)
     blkcfg.alignment_offset = 0;
     blkcfg.wce = blk_enable_write_cache(s->blk);
     virtio_stw_p(vdev, &blkcfg.num_queues, s->conf.num_queues);
+    if (s->disk_name)
+        strncpy((char *)blkcfg.disk_name, s->disk_name, DISK_NAME_LEN);
     memcpy(config, &blkcfg, sizeof(struct virtio_blk_config));
 }
 
@@ -740,6 +742,8 @@ static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features,
     virtio_add_feature(&features, VIRTIO_BLK_F_GEOMETRY);
     virtio_add_feature(&features, VIRTIO_BLK_F_TOPOLOGY);
     virtio_add_feature(&features, VIRTIO_BLK_F_BLK_SIZE);
+    virtio_add_feature(&features, VIRTIO_BLK_F_DISK_NAME);
+
     if (virtio_has_feature(features, VIRTIO_F_VERSION_1)) {
         if (s->conf.scsi) {
             error_setg(errp, "Please set scsi=off for virtio-blk devices in order to use virtio 1.0");
@@ -970,6 +974,7 @@ static Property virtio_blk_properties[] = {
     DEFINE_PROP_BIT("request-merging", VirtIOBlock, conf.request_merging, 0,
                     true),
     DEFINE_PROP_UINT16("num-queues", VirtIOBlock, conf.num_queues, 1),
+    DEFINE_PROP_STRING("disk-name", VirtIOBlock, disk_name),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h
index 180bd8d..003e810 100644
--- a/include/hw/virtio/virtio-blk.h
+++ b/include/hw/virtio/virtio-blk.h
@@ -56,6 +56,7 @@ typedef struct VirtIOBlock {
     bool dataplane_disabled;
     bool dataplane_started;
     struct VirtIOBlockDataPlane *dataplane;
+    char *disk_name;
 } VirtIOBlock;
 
 typedef struct VirtIOBlockReq {
diff --git a/include/standard-headers/linux/virtio_blk.h b/include/standard-headers/linux/virtio_blk.h
index ab16ec5..1f5d89d 100644
--- a/include/standard-headers/linux/virtio_blk.h
+++ b/include/standard-headers/linux/virtio_blk.h
@@ -38,6 +38,7 @@
 #define VIRTIO_BLK_F_BLK_SIZE	6	/* Block size of disk is available*/
 #define VIRTIO_BLK_F_TOPOLOGY	10	/* Topology information is available */
 #define VIRTIO_BLK_F_MQ		12	/* support more than one vq */
+#define VIRTIO_BLK_F_DISK_NAME  13      /* specify /dev/xxx name */
 
 /* Legacy feature bits */
 #ifndef VIRTIO_BLK_NO_LEGACY
@@ -51,6 +52,9 @@
 
 #define VIRTIO_BLK_ID_BYTES	20	/* ID string length */
 
+/* micro defined in kernel genhd.h */
+#define DISK_NAME_LEN 32
+
 struct virtio_blk_config {
 	/* The capacity (in 512-byte sectors). */
 	uint64_t capacity;
@@ -84,6 +88,8 @@ struct virtio_blk_config {
 
 	/* number of vqs, only available when VIRTIO_BLK_F_MQ is set */
 	uint16_t num_queues;
+
+	uint8_t disk_name[DISK_NAME_LEN];
 } QEMU_PACKED;
 
 /*
-- 
1.9.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-01-12 14:27 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-30  2:41 [Qemu-devel] [RFC]virtio-blk: add disk-name device property Junkang Fu
2016-12-30  7:34 ` Cao jin
2017-01-05  7:36   ` Junkang Fu
2017-01-03 16:29 ` Stefan Hajnoczi
2017-01-05  7:35   ` Junkang Fu
2017-01-03 16:53 ` Eric Blake
2017-01-04 14:44   ` Stefan Hajnoczi
2017-01-12  1:22     ` Yang Zhang
2017-01-12  2:22       ` Fam Zheng
2017-01-12  7:39         ` Yang Zhang
2017-01-12  8:04           ` Fam Zheng
2017-01-12 14:27         ` Stefan Hajnoczi
2017-01-05  7:34   ` Junkang Fu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).