Skip to content

Commit ae1374b

Browse files
Zhu Lingshanmstsirkin
authored andcommitted
vDPA: report virtio-block read-only info to user space
This commit report read-only information of virtio-blk devices to user space. Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com> Message-Id: <20240218185606.13509-10-lingshan.zhu@intel.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent 6bdc784 commit ae1374b

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

drivers/vdpa/vdpa.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,17 @@ vdpa_dev_blk_write_zeroes_config_fill(struct sk_buff *msg, u64 features,
10841084
return 0;
10851085
}
10861086

1087+
static int vdpa_dev_blk_ro_config_fill(struct sk_buff *msg, u64 features)
1088+
{
1089+
u8 ro;
1090+
1091+
ro = ((features & BIT_ULL(VIRTIO_BLK_F_RO)) == 0) ? 0 : 1;
1092+
if (nla_put_u8(msg, VDPA_ATTR_DEV_BLK_CFG_READ_ONLY, ro))
1093+
return -EMSGSIZE;
1094+
1095+
return 0;
1096+
}
1097+
10871098
static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,
10881099
struct sk_buff *msg)
10891100
{
@@ -1122,6 +1133,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,
11221133
if (vdpa_dev_blk_write_zeroes_config_fill(msg, features_device, &config))
11231134
return -EMSGSIZE;
11241135

1136+
if (vdpa_dev_blk_ro_config_fill(msg, features_device))
1137+
return -EMSGSIZE;
1138+
11251139
return 0;
11261140
}
11271141

include/uapi/linux/vdpa.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ enum vdpa_attr {
7070
VDPA_ATTR_DEV_BLK_CFG_DISCARD_SEC_ALIGN,/* u32 */
7171
VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEC, /* u32 */
7272
VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEG, /* u32 */
73+
VDPA_ATTR_DEV_BLK_CFG_READ_ONLY, /* u8 */
7374

7475
/* new attributes must be added above here */
7576
VDPA_ATTR_MAX,

0 commit comments

Comments
 (0)