From: Cao jin <caoj.fnst@cn.fujitsu.com>
To: Junkang Fu <fujunkang@gmail.com>
Cc: stefanha@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC]virtio-blk: add disk-name device property
Date: Fri, 30 Dec 2016 15:34:44 +0800 [thread overview]
Message-ID: <58660E14.8000605@cn.fujitsu.com> (raw)
In-Reply-To: <CAP8dc_acqeqpio7fVK4XSAxoH8QaGp9L=S1h2OCCWgrj=Q7VCw@mail.gmail.com>
As I know, this is not a good way to submit a patch. You need to read
the guideline first: http://wiki.qemu.org/Contribute/SubmitAPatch
--
Sincerely,
Cao jin
On 12/30/2016 10:41 AM, Junkang Fu wrote:
>>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
>
>
next prev parent reply other threads:[~2016-12-30 7:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-30 2:41 [Qemu-devel] [RFC]virtio-blk: add disk-name device property Junkang Fu
2016-12-30 7:34 ` Cao jin [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=58660E14.8000605@cn.fujitsu.com \
--to=caoj.fnst@cn.fujitsu.com \
--cc=fujunkang@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.