Skip to contentSkip to conversation

*** Introduce a new vhost-user-blk host device to Qemu ***

PATCH Superseded Changpeng Liu 4 participants 14 messages Nov 16, 2017 – Nov 22, 2017 Kbuild

v5 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v5 cover *** Introduce a new vhost-user-blk host device to Qemu ***

Although virtio scsi specification was designed as a replacement for virtio_blk, there are still many users using virtio_blk. Qemu 2.9 introduced a new device vhost user scsi which can process I/O in user space for virtio_scsi, this commit introduces a new vhost user block host device, which can support virtio_blk in Guest OS, and I/O processing in another I/O target.

Due to the limitation for virtio_blk specification, virtio_blk device cannot get block information such as capacity, block size etc via the specification, several new vhost user messages were added to deliver virtio config space information between Qemu and I/O target, VHOST_USER_GET_CONFIG/VHOST_USER_SET_CONFIG messages used for get/set config space from/to I/O target, VHOST_USER_SET_CONFIG_FD was added for event notifier in case the change of virtio config space. Also, those messages can be used for vhost device live migration as well.

V4-v5: add header offset and size for virtio config space.
v3-v4: refactoring the vhost user block example patch based on new libvhost-user library.
v2-v3: add new vhost user message to get/set virtio config space.

Changpeng Liu (4):
vhost-user: add new vhost user messages to support virtio config space
vhost-user-blk: introduce a new vhost-user-blk host device contrib/libvhost-user: enable virtio config space messages contrib/vhost-user-blk: introduce a vhost-user-blk sample application

 .gitignore                              |   1 +
 Makefile                                |   3 +
 Makefile.objs                           |   1 +
 contrib/libvhost-user/libvhost-user.c   |  79 +++++
 contrib/libvhost-user/libvhost-user.h   |  24 +-
 contrib/vhost-user-blk/Makefile.objs    |   1 +
 contrib/vhost-user-blk/vhost-user-blk.c | 536 ++++++++++++++++++++++++++++++++
 default-configs/pci.mak                 |   1 +
 docs/interop/vhost-user.txt             |  39 +++
 hw/block/Makefile.objs                  |   3 +
 hw/block/vhost-user-blk.c               | 356 +++++++++++++++++++++
 hw/virtio/vhost-user.c                  |  98 ++++++
 hw/virtio/vhost.c                       |  63 ++++
 hw/virtio/virtio-pci.c                  |  55 ++++
 hw/virtio/virtio-pci.h                  |  18 ++
 include/hw/virtio/vhost-backend.h       |   8 +
 include/hw/virtio/vhost-user-blk.h      |  42 +++
 include/hw/virtio/vhost.h               |  16 +
 18 files changed, 1343 insertions(+), 1 deletion(-)
 create mode 100644 contrib/vhost-user-blk/Makefile.objs
 create mode 100644 contrib/vhost-user-blk/vhost-user-blk.c
 create mode 100644 hw/block/vhost-user-blk.c
 create mode 100644 include/hw/virtio/vhost-user-blk.h
Signature · 1 line
1.9.3
#1 lore raw

PATCH v5 1/4 vhost-user: add new vhost user messages to support virtio config space

Add VHOST_USER_GET_CONFIG/VHOST_USER_SET_CONFIG messages which can be used for live migration of vhost user devices, also vhost user devices can benefit from the messages to get/set virtio config space from/to the I/O target. For the purpose to support virtio config space change, VHOST_USER_SET_CONFIG_FD message is added as the event notifier in case virtio config space change in the I/O target.

---
 docs/interop/vhost-user.txt       | 39 ++++++++++++++++
 hw/virtio/vhost-user.c            | 98 +++++++++++++++++++++++++++++++++++++++
 hw/virtio/vhost.c                 | 63 +++++++++++++++++++++++++
 include/hw/virtio/vhost-backend.h |  8 ++++
 include/hw/virtio/vhost.h         | 16 +++++++
 5 files changed, 224 insertions(+)
docs/interop/vhost-user.txt +39 -0
index 954771d..1b98388 100644
@@ -116,6 +116,16 @@ Depending on the request type, payload can be:
     - 3: IOTLB invalidate
     - 4: IOTLB access fail
 
+ * Virtio device config space
+   ---------------------------
+   | offset | size | payload |
+   ---------------------------
+
+   Offset: a 32-bit offset of virtio device's configuration space
+   Size: a 32-bit size of configuration space that master wanted to change
+   Payload: a 256-bytes array holding the contents of the virtio
+       device's configuration space
+
 In QEMU the vhost-user message is implemented with the following struct:
 
 typedef struct VhostUserMsg {
@@ -129,6 +139,7 @@ typedef struct VhostUserMsg {
         VhostUserMemory memory;
         VhostUserLog log;
         struct vhost_iotlb_msg iotlb;
+        VhostUserConfig config;
     };
 } QEMU_PACKED VhostUserMsg;
 
@@ -596,6 +607,34 @@ Master message types
       and expect this message once (per VQ) during device configuration
       (ie. before the master starts the VQ).
 
+ * VHOST_USER_GET_CONFIG
+      Id: 24
+      Equivalent ioctl: N/A
+      Master payload: virtio device config space
+
+      Submitted by the vhost-user master to fetch the contents of the virtio
+      device configuration space. The vhost-user master may cache the contents
+      to avoid repeated VHOST_USER_GET_CONFIG calls.
+
+* VHOST_USER_SET_CONFIG
+      Id: 25
+      Equivalent ioctl: N/A
+      Master payload: virtio device config space
+
+      Submitted by the vhost-user master when the Guest changes the virtio
+      device configuration space and also can be used for live migration
+      on the destination host.
+
+* VHOST_USER_SET_CONFIG_FD
+      Id: 26
+      Equivalent ioctl: N/A
+      Master payload: N/A
+
+      Sets the notifier file descriptor, which is passed as ancillary data.
+      The vhost-user slave uses the file descriptor to notify the vhost-user
+      master of changes to the virtio configuration space. The vhost-user
+      master can read the virtio configuration space to get the latest update.
+
 Slave message types
 -------------------
 
hw/virtio/vhost-user.c +98 -0

132 lines not on this page · raw message

hw/virtio/vhost.c +63 -0

75 lines not on this page · raw message

include/hw/virtio/vhost-backend.h +8 -0
index a7a5f22..3ab0b79 100644
@@ -84,6 +84,11 @@ typedef void (*vhost_set_iotlb_callback_op)(struct vhost_dev *dev,
                                            int enabled);
 typedef int (*vhost_send_device_iotlb_msg_op)(struct vhost_dev *dev,
                                               struct vhost_iotlb_msg *imsg);
+typedef int (*vhost_set_config_op)(struct vhost_dev *dev, const uint8_t *config,
+                                   uint32_t offset, uint32_t size);
+typedef int (*vhost_get_config_op)(struct vhost_dev *dev, uint8_t *config,
+                                   size_t config_len);
+typedef int (*vhost_set_config_fd_op)(struct vhost_dev *dev, int fd);
 
 typedef struct VhostOps {
     VhostBackendType backend_type;
@@ -118,6 +123,9 @@ typedef struct VhostOps {
     vhost_vsock_set_running_op vhost_vsock_set_running;
     vhost_set_iotlb_callback_op vhost_set_iotlb_callback;
     vhost_send_device_iotlb_msg_op vhost_send_device_iotlb_msg;
+    vhost_get_config_op vhost_get_config;
+    vhost_set_config_op vhost_set_config;
+    vhost_set_config_fd_op vhost_set_config_fd;
 } VhostOps;
 
 extern const VhostOps user_ops;
include/hw/virtio/vhost.h +16 -0
index 467dc77..593056d 100644
@@ -46,6 +46,12 @@ struct vhost_iommu {
     QLIST_ENTRY(vhost_iommu) iommu_next;
 };
 
+typedef struct VhostDevConfigOps {
+    /* Vhost device config space changed callback
+     */
+    void (*vhost_dev_config_notifier)(struct vhost_dev *dev);
+} VhostDevConfigOps;
+
 struct vhost_memory;
 struct vhost_dev {
     VirtIODevice *vdev;
@@ -76,6 +82,8 @@ struct vhost_dev {
     QLIST_ENTRY(vhost_dev) entry;
     QLIST_HEAD(, vhost_iommu) iommu_list;
     IOMMUNotifier n;
+    EventNotifier config_notifier;
+    const VhostDevConfigOps *config_ops;
 };
 
 int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
@@ -106,4 +114,12 @@ int vhost_net_set_backend(struct vhost_dev *hdev,
                           struct vhost_vring_file *file);
 
 int vhost_device_iotlb_miss(struct vhost_dev *dev, uint64_t iova, int write);
+int vhost_dev_get_config(struct vhost_dev *dev, uint8_t *config,
+                         size_t config_len);
+int vhost_dev_set_config(struct vhost_dev *dev, const uint8_t *config,
+                         uint32_t offset, uint32_t size);
+/* notifier callback in case vhost device config space changed
+ */
+int vhost_dev_set_config_notifier(struct vhost_dev *dev,
+                                  const VhostDevConfigOps *ops);
 #endif
Signature · 1 line
1.9.3
#2 lore raw

Re: [Qemu-devel] [PATCH v5 1/4] vhost-user: add new vhost user messages to support virtio config space

Quoted 21 lines · Changpeng Liu

Add VHOST_USER_GET_CONFIG/VHOST_USER_SET_CONFIG messages which can be used for live migration of vhost user devices, also vhost user devices can benefit from the messages to get/set virtio config space from/to the I/O target. For the purpose to support virtio config space change, VHOST_USER_SET_CONFIG_FD message is added as the event notifier in case virtio config space change in the I/O target.

---
 docs/interop/vhost-user.txt       | 39 ++++++++++++++++
 hw/virtio/vhost-user.c            | 98 +++++++++++++++++++++++++++++++++++++++
 hw/virtio/vhost.c                 | 63 +++++++++++++++++++++++++
 include/hw/virtio/vhost-backend.h |  8 ++++
 include/hw/virtio/vhost.h         | 16 +++++++
 5 files changed, 224 insertions(+)
docs/interop/vhost-user.txt +0 -0
index 954771d..1b98388 100644

docs/interop/vhost-user.txt Depending on the request type, payload can be: · line 124

Quoted 9 lines
docs/interop/vhost-user.txt +6 -0
@@ -116,6 +116,16 @@ Depending on the request type, payload can be:
     - 3: IOTLB invalidate
     - 4: IOTLB access fail
 
+ * Virtio device config space
+   ---------------------------
+   | offset | size | payload |
+   ---------------------------
+
+   Offset: a 32-bit offset of virtio device's configuration space

s/of/in the/

docs/interop/vhost-user.txt Depending on the request type, payload can be: · line 125

Quoted 1 line
docs/interop/vhost-user.txt +1 -0
+   Size: a 32-bit size of configuration space that master wanted to change

Is this also used for GET_CONFIG? If yes, I suggest "a 32-bit configuration space access size in bytes".

Please mention that Size must be <= 256 bytes.

docs/interop/vhost-user.txt Depending on the request type, payload can be: · line 127

Quoted 2 lines
docs/interop/vhost-user.txt +2 -0
+   Payload: a 256-bytes array holding the contents of the virtio
+       device's configuration space

What about bytes outside the [offset, offset+size) range? I guess they must be 0 and are ignored by the master/slave.

Would it be cleaner to make Payload a variable-sized field with Size bytes? That way it's not necessary to transfer 0s and memcpy() a subset of the payload array.

Quoted 23 lines
docs/interop/vhost-user.txt +9 -0
+
 In QEMU the vhost-user message is implemented with the following struct:
 
 typedef struct VhostUserMsg {
@@ -129,6 +139,7 @@ typedef struct VhostUserMsg {
         VhostUserMemory memory;
         VhostUserLog log;
         struct vhost_iotlb_msg iotlb;
+        VhostUserConfig config;
     };
 } QEMU_PACKED VhostUserMsg;
 
@@ -596,6 +607,34 @@ Master message types
       and expect this message once (per VQ) during device configuration
       (ie. before the master starts the VQ).
 
+ * VHOST_USER_GET_CONFIG
+      Id: 24
+      Equivalent ioctl: N/A
+      Master payload: virtio device config space
+
+      Submitted by the vhost-user master to fetch the contents of the virtio
+      device configuration space. The vhost-user master may cache the contents

docs/interop/vhost-user.txt Master message types · line 626

Quoted 10 lines
docs/interop/vhost-user.txt +10 -0
+      to avoid repeated VHOST_USER_GET_CONFIG calls.
+
+* VHOST_USER_SET_CONFIG
+      Id: 25
+      Equivalent ioctl: N/A
+      Master payload: virtio device config space
+
+      Submitted by the vhost-user master when the Guest changes the virtio
+      device configuration space and also can be used for live migration
+      on the destination host.

There might be security issues if the vhost slave cannot tell whether SET_CONFIG is coming from the guest driver or from the master process (live migration). Typically certain fields are read-only for the guest driver. Maybe those fields need to be set by the master after live migration.

One way to solve this is adding a flags field to the message. A special flag can be used for live migration so the slave knows that this SET_CONFIG message is allowed to write to read-only fields.

It's also worth documenting that slaves MUST NOT accept SET_CONFIG for read-only configuration space fields unless the live migration bit is set. Hopefully this will remind implementors to think through the security issues.

#3 lore raw

Re: [Qemu-devel] [PATCH v5 1/4] vhost-user: add new vhost user messages to support virtio config space

Quoted 91 lines · Stefan Hajnoczi
Quoted 21 lines · Changpeng Liu

Add VHOST_USER_GET_CONFIG/VHOST_USER_SET_CONFIG messages which can be used for live migration of vhost user devices, also vhost user devices can benefit from the messages to get/set virtio config space from/to the I/O target. For the purpose to support virtio config space change, VHOST_USER_SET_CONFIG_FD message is added as the event notifier in case virtio config space change in the I/O target.

---
 docs/interop/vhost-user.txt       | 39 ++++++++++++++++
 hw/virtio/vhost-user.c            | 98 +++++++++++++++++++++++++++++++++++++++
 hw/virtio/vhost.c                 | 63 +++++++++++++++++++++++++
 include/hw/virtio/vhost-backend.h |  8 ++++
 include/hw/virtio/vhost.h         | 16 +++++++
 5 files changed, 224 insertions(+)
docs/interop/vhost-user.txt +0 -0
index 954771d..1b98388 100644

docs/interop/vhost-user.txt Depending on the request type, payload can be: · line 124

Quoted 9 lines
docs/interop/vhost-user.txt +6 -0
@@ -116,6 +116,16 @@ Depending on the request type, payload can be:
     - 3: IOTLB invalidate
     - 4: IOTLB access fail
 
+ * Virtio device config space
+   ---------------------------
+   | offset | size | payload |
+   ---------------------------
+
+   Offset: a 32-bit offset of virtio device's configuration space

s/of/in the/

docs/interop/vhost-user.txt Depending on the request type, payload can be: · line 125

Quoted 1 line
docs/interop/vhost-user.txt +1 -0
+   Size: a 32-bit size of configuration space that master wanted to change

Is this also used for GET_CONFIG? If yes, I suggest "a 32-bit configuration space access size in bytes".

Please mention that Size must be <= 256 bytes.

docs/interop/vhost-user.txt Depending on the request type, payload can be: · line 127

Quoted 2 lines
docs/interop/vhost-user.txt +2 -0
+   Payload: a 256-bytes array holding the contents of the virtio
+       device's configuration space

What about bytes outside the [offset, offset+size) range? I guess they must be 0 and are ignored by the master/slave.

Would it be cleaner to make Payload a variable-sized field with Size bytes? That way it's not necessary to transfer 0s and memcpy() a subset of the payload array.

Quoted 23 lines
docs/interop/vhost-user.txt +9 -0
+
 In QEMU the vhost-user message is implemented with the following struct:
 
 typedef struct VhostUserMsg {
@@ -129,6 +139,7 @@ typedef struct VhostUserMsg {
         VhostUserMemory memory;
         VhostUserLog log;
         struct vhost_iotlb_msg iotlb;
+        VhostUserConfig config;
     };
 } QEMU_PACKED VhostUserMsg;
 
@@ -596,6 +607,34 @@ Master message types
       and expect this message once (per VQ) during device configuration
       (ie. before the master starts the VQ).
 
+ * VHOST_USER_GET_CONFIG
+      Id: 24
+      Equivalent ioctl: N/A
+      Master payload: virtio device config space
+
+      Submitted by the vhost-user master to fetch the contents of the virtio
+      device configuration space. The vhost-user master may cache the contents

docs/interop/vhost-user.txt Master message types · line 626

Quoted 10 lines
docs/interop/vhost-user.txt +10 -0
+      to avoid repeated VHOST_USER_GET_CONFIG calls.
+
+* VHOST_USER_SET_CONFIG
+      Id: 25
+      Equivalent ioctl: N/A
+      Master payload: virtio device config space
+
+      Submitted by the vhost-user master when the Guest changes the virtio
+      device configuration space and also can be used for live migration
+      on the destination host.

There might be security issues if the vhost slave cannot tell whether SET_CONFIG is coming from the guest driver or from the master process (live migration). Typically certain fields are read-only for the guest driver. Maybe those fields need to be set by the master after live migration.

Quoted 8 lines

One way to solve this is adding a flags field to the message. A special flag can be used for live migration so the slave knows that this SET_CONFIG message is allowed to write to read-only fields.

It's also worth documenting that slaves MUST NOT accept SET_CONFIG for read-only configuration space fields unless the live migration bit is set. Hopefully this will remind implementors to think through the security issues.

Live migrations is supposed to be migrating guest writeable state too. If you mean migrating RO fields like size, then
I don't think it's a good idea to reuse SET_CONFIG for that. SET_CONFIG should obey exactly the virtio semantics.

And I agree, it should say that slave must treat it as a write, and get config as a read according to virtio semantics.

If someone needs to pass configuration from qemu to slave, let's add specific messages with precisely defined semantics.

Which reminds me.

virtio 1 changed endian-ness for config.

I think we should specify it's all virtio 1 format, and just disallow vhost blk for virtio 0 guests.

Signature · 1 line
MST
#4 lore raw

Re: [Qemu-devel] [PATCH v5 1/4] vhost-user: add new vhost user messages to support virtio config space

Quoted 10 lines · Michael S. Tsirkin

Live migrations is supposed to be migrating guest writeable state too. If you mean migrating RO fields like size, then
I don't think it's a good idea to reuse SET_CONFIG for that. SET_CONFIG should obey exactly the virtio semantics.

And I agree, it should say that slave must treat it as a write, and get config as a read according to virtio semantics.

If someone needs to pass configuration from qemu to slave, let's add specific messages with precisely defined semantics.

Fair enough, but I'd add nevertheless a 32-bit flags field to both GET_CONFIG and SET_CONFIG, and document that the slave MUST check that it is zero and otherwise fail.

Paolo

#5 lore raw

Re: [Qemu-devel] [PATCH v5 1/4] vhost-user: add new vhost user messages to support virtio config space

Quoted 9 lines · Paolo Bonzini
Quoted 8 lines · Michael S. Tsirkin

Live migrations is supposed to be migrating guest writeable state too. If you mean migrating RO fields like size, then
I don't think it's a good idea to reuse SET_CONFIG for that. SET_CONFIG should obey exactly the virtio semantics.

And I agree, it should say that slave must treat it as a write, and get config as a read according to virtio semantics.

Quoted 8 lines
Quoted 2 lines

If someone needs to pass configuration from qemu to slave, let's add specific messages with precisely defined semantics.

Fair enough, but I'd add nevertheless a 32-bit flags field to both GET_CONFIG and SET_CONFIG, and document that the slave MUST check that it is zero and otherwise fail.

Paolo

We generally just use protocol feature bits for extensions. But I have no problem with reserved padding if desired which seems to be what's described here.

Signature · 1 line
MST
#6 lore raw

Re: [Qemu-devel] [PATCH v5 1/4] vhost-user: add new vhost user messages to support virtio config space

Quoted 7 lines · Michael S. Tsirkin
Quoted 3 lines

Fair enough, but I'd add nevertheless a 32-bit flags field to both GET_CONFIG and SET_CONFIG, and document that the slave MUST check that it is zero and otherwise fail.

We generally just use protocol feature bits for extensions. But I have no problem with reserved padding if desired which seems to be what's described here.

Correct, you would still have a protocol feature bit, but the format would be less susceptible to struct size changes which can simplify the implementation a bit.

Paolo

#7 lore raw

Re: [Qemu-devel] [PATCH v5 1/4] vhost-user: add new vhost user messages to support virtio config space

In reply to Paolo Bonzini
Quoted 21 lines

-----Original Message-----
From: Paolo Bonzini [mailto:[email protected]]
Sent: Tuesday, November 21, 2017 8:16 AM
To: Michael S. Tsirkin <[email protected]>; Stefan Hajnoczi <[email protected]>
Cc: Liu, Changpeng <[email protected]>; [email protected]; [email protected]; [email protected]; Harris, James R <[email protected]>
Subject: Re: [PATCH v5 1/4] vhost-user: add new vhost user messages to support virtio config space

Quoted 8 lines · Michael S. Tsirkin

Live migrations is supposed to be migrating guest writeable state too. If you mean migrating RO fields like size, then
I don't think it's a good idea to reuse SET_CONFIG for that. SET_CONFIG should obey exactly the virtio semantics.

And I agree, it should say that slave must treat it as a write, and get config as a read according to virtio semantics.

Quoted 6 lines
Quoted 2 lines

If someone needs to pass configuration from qemu to slave, let's add specific messages with precisely defined semantics.

Fair enough, but I'd add nevertheless a 32-bit flags field to both GET_CONFIG and SET_CONFIG, and document that the slave MUST check that it is zero and otherwise fail.

Ok.

Quoted 2 lines

Paolo

#8 lore raw

Re: [Qemu-devel] [PATCH v5 1/4] vhost-user: add new vhost user messages to support virtio config space

In reply to Michael S. Tsirkin
Quoted 126 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Tuesday, November 21, 2017 4:45 AM
To: Stefan Hajnoczi <[email protected]>
Cc: Liu, Changpeng <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Harris, James R <[email protected]>
Subject: Re: [PATCH v5 1/4] vhost-user: add new vhost user messages to support virtio config space

Quoted 2 lines · Stefan Hajnoczi
Quoted 1 line · Changpeng Liu

Add VHOST_USER_GET_CONFIG/VHOST_USER_SET_CONFIG messages which

can be

Quoted 10 lines
Quoted 10 lines

used for live migration of vhost user devices, also vhost user devices can benefit from the messages to get/set virtio config space from/to the I/O target. For the purpose to support virtio config space change, VHOST_USER_SET_CONFIG_FD message is added as the event notifier in case virtio config space change in the I/O target.

---
 docs/interop/vhost-user.txt       | 39 ++++++++++++++++
 hw/virtio/vhost-user.c            | 98

+++++++++++++++++++++++++++++++++++++++

Quoted 79 lines
Quoted 10 lines
 hw/virtio/vhost.c                 | 63 +++++++++++++++++++++++++
 include/hw/virtio/vhost-backend.h |  8 ++++
 include/hw/virtio/vhost.h         | 16 +++++++
 5 files changed, 224 insertions(+)
docs/interop/vhost-user.txt +0 -0
index 954771d..1b98388 100644

docs/interop/vhost-user.txt Depending on the request type, payload can be: · line 124

Quoted 9 lines
docs/interop/vhost-user.txt +6 -0
@@ -116,6 +116,16 @@ Depending on the request type, payload can be:
     - 3: IOTLB invalidate
     - 4: IOTLB access fail
 
+ * Virtio device config space
+   ---------------------------
+   | offset | size | payload |
+   ---------------------------
+
+   Offset: a 32-bit offset of virtio device's configuration space

s/of/in the/

docs/interop/vhost-user.txt Depending on the request type, payload can be: · line 125

Quoted 1 line
docs/interop/vhost-user.txt +1 -0
+   Size: a 32-bit size of configuration space that master wanted to change

Is this also used for GET_CONFIG? If yes, I suggest "a 32-bit configuration space access size in bytes".

Please mention that Size must be <= 256 bytes.

docs/interop/vhost-user.txt Depending on the request type, payload can be: · line 127

Quoted 2 lines
docs/interop/vhost-user.txt +2 -0
+   Payload: a 256-bytes array holding the contents of the virtio
+       device's configuration space

What about bytes outside the [offset, offset+size) range? I guess they must be 0 and are ignored by the master/slave.

Would it be cleaner to make Payload a variable-sized field with Size bytes? That way it's not necessary to transfer 0s and memcpy() a subset of the payload array.

Quoted 23 lines
docs/interop/vhost-user.txt +9 -0
+
 In QEMU the vhost-user message is implemented with the following struct:
 
 typedef struct VhostUserMsg {
@@ -129,6 +139,7 @@ typedef struct VhostUserMsg {
         VhostUserMemory memory;
         VhostUserLog log;
         struct vhost_iotlb_msg iotlb;
+        VhostUserConfig config;
     };
 } QEMU_PACKED VhostUserMsg;
 
@@ -596,6 +607,34 @@ Master message types
       and expect this message once (per VQ) during device configuration
       (ie. before the master starts the VQ).
 
+ * VHOST_USER_GET_CONFIG
+      Id: 24
+      Equivalent ioctl: N/A
+      Master payload: virtio device config space
+
+      Submitted by the vhost-user master to fetch the contents of the virtio
+      device configuration space. The vhost-user master may cache the contents

docs/interop/vhost-user.txt Master message types · line 626

Quoted 10 lines
docs/interop/vhost-user.txt +10 -0
+      to avoid repeated VHOST_USER_GET_CONFIG calls.
+
+* VHOST_USER_SET_CONFIG
+      Id: 25
+      Equivalent ioctl: N/A
+      Master payload: virtio device config space
+
+      Submitted by the vhost-user master when the Guest changes the virtio
+      device configuration space and also can be used for live migration
+      on the destination host.

There might be security issues if the vhost slave cannot tell whether SET_CONFIG is coming from the guest driver or from the master process (live migration). Typically certain fields are read-only for the guest driver. Maybe those fields need to be set by the master after live migration.

Quoted 8 lines

One way to solve this is adding a flags field to the message. A special flag can be used for live migration so the slave knows that this SET_CONFIG message is allowed to write to read-only fields.

It's also worth documenting that slaves MUST NOT accept SET_CONFIG for read-only configuration space fields unless the live migration bit is set. Hopefully this will remind implementors to think through the security issues.

Live migrations is supposed to be migrating guest writeable state too. If you mean migrating RO fields like size, then
I don't think it's a good idea to reuse SET_CONFIG for that. SET_CONFIG should obey exactly the virtio semantics.

And I agree, it should say that slave must treat it as a write, and get config as a read according to virtio semantics.

If someone needs to pass configuration from qemu to slave, let's add specific messages with precisely defined semantics.

Quoted 6 lines

Which reminds me.

virtio 1 changed endian-ness for config.

I think we should specify it's all virtio 1 format, and just disallow vhost blk for virtio 0 guests.

Will add the limitation to this txt file.

Quoted 3 lines

--
MST

#9 lore raw

Re: [Qemu-devel] [PATCH v5 1/4] vhost-user: add new vhost user messages to support virtio config space

In reply to Stefan Hajnoczi
Quoted 47 lines

-----Original Message-----
From: Stefan Hajnoczi [mailto:[email protected]]
Sent: Tuesday, November 21, 2017 12:27 AM
To: Liu, Changpeng <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Harris, James R <[email protected]>
Subject: Re: [PATCH v5 1/4] vhost-user: add new vhost user messages to support virtio config space

Quoted 1 line · Changpeng Liu

Add VHOST_USER_GET_CONFIG/VHOST_USER_SET_CONFIG messages which can

be

Quoted 20 lines

used for live migration of vhost user devices, also vhost user devices can benefit from the messages to get/set virtio config space from/to the I/O target. For the purpose to support virtio config space change, VHOST_USER_SET_CONFIG_FD message is added as the event notifier in case virtio config space change in the I/O target.

---
 docs/interop/vhost-user.txt       | 39 ++++++++++++++++
 hw/virtio/vhost-user.c            | 98 +++++++++++++++++++++++++++++++++++++++
 hw/virtio/vhost.c                 | 63 +++++++++++++++++++++++++
 include/hw/virtio/vhost-backend.h |  8 ++++
 include/hw/virtio/vhost.h         | 16 +++++++
 5 files changed, 224 insertions(+)
docs/interop/vhost-user.txt +0 -0
index 954771d..1b98388 100644

docs/interop/vhost-user.txt Depending on the request type, payload can be: · line 124

Quoted 9 lines
docs/interop/vhost-user.txt +6 -0
@@ -116,6 +116,16 @@ Depending on the request type, payload can be:
     - 3: IOTLB invalidate
     - 4: IOTLB access fail
 
+ * Virtio device config space
+   ---------------------------
+   | offset | size | payload |
+   ---------------------------
+
+   Offset: a 32-bit offset of virtio device's configuration space

s/of/in the/

Quoted 4 lines

docs/interop/vhost-user.txt Depending on the request type, payload can be: · line 125

Quoted 1 line
docs/interop/vhost-user.txt +1 -0
+   Size: a 32-bit size of configuration space that master wanted to change

Is this also used for GET_CONFIG? If yes, I suggest "a 32-bit configuration space access size in bytes".

ok.

Quoted 6 lines

Please mention that Size must be <= 256 bytes.

docs/interop/vhost-user.txt Depending on the request type, payload can be: · line 127

Quoted 2 lines
docs/interop/vhost-user.txt +2 -0
+   Payload: a 256-bytes array holding the contents of the virtio
+       device's configuration space
Quoted 6 lines

What about bytes outside the [offset, offset+size) range? I guess they must be 0 and are ignored by the master/slave.

Would it be cleaner to make Payload a variable-sized field with Size bytes? That way it's not necessary to transfer 0s and memcpy() a subset of the payload array.

sounds good, but for vhost-blk driver it can call get_config for the whole virtio_blk_config space.

Quoted 41 lines
Quoted 24 lines
docs/interop/vhost-user.txt +9 -0
+
 In QEMU the vhost-user message is implemented with the following struct:
 
 typedef struct VhostUserMsg {
@@ -129,6 +139,7 @@ typedef struct VhostUserMsg {
         VhostUserMemory memory;
         VhostUserLog log;
         struct vhost_iotlb_msg iotlb;
+        VhostUserConfig config;
     };
 } QEMU_PACKED VhostUserMsg;
 
@@ -596,6 +607,34 @@ Master message types
       and expect this message once (per VQ) during device configuration
       (ie. before the master starts the VQ).
 
+ * VHOST_USER_GET_CONFIG
+      Id: 24
+      Equivalent ioctl: N/A
+      Master payload: virtio device config space
+
+      Submitted by the vhost-user master to fetch the contents of the virtio
+      device configuration space. The vhost-user master may cache the contents

docs/interop/vhost-user.txt Master message types · line 626

Quoted 10 lines
docs/interop/vhost-user.txt +10 -0
+      to avoid repeated VHOST_USER_GET_CONFIG calls.
+
+* VHOST_USER_SET_CONFIG
+      Id: 25
+      Equivalent ioctl: N/A
+      Master payload: virtio device config space
+
+      Submitted by the vhost-user master when the Guest changes the virtio
+      device configuration space and also can be used for live migration
+      on the destination host.

There might be security issues if the vhost slave cannot tell whether SET_CONFIG is coming from the guest driver or from the master process (live migration). Typically certain fields are read-only for the guest driver. Maybe those fields need to be set by the master after live migration.

Quoted 4 lines

One way to solve this is adding a flags field to the message. A special flag can be used for live migration so the slave knows that this SET_CONFIG message is allowed to write to read-only fields.

Ok.

Quoted 4 lines

It's also worth documenting that slaves MUST NOT accept SET_CONFIG for read-only configuration space fields unless the live migration bit is set. Hopefully this will remind implementors to think through the security issues.

#10 lore raw

Re: [Qemu-devel] [PATCH v5 1/4] vhost-user: add new vhost user messages to support virtio config space

In reply to Changpeng Liu
Quoted 21 lines · Changpeng Liu

Add VHOST_USER_GET_CONFIG/VHOST_USER_SET_CONFIG messages which can be used for live migration of vhost user devices, also vhost user devices can benefit from the messages to get/set virtio config space from/to the I/O target. For the purpose to support virtio config space change, VHOST_USER_SET_CONFIG_FD message is added as the event notifier in case virtio config space change in the I/O target.

---
 docs/interop/vhost-user.txt       | 39 ++++++++++++++++
 hw/virtio/vhost-user.c            | 98 +++++++++++++++++++++++++++++++++++++++
 hw/virtio/vhost.c                 | 63 +++++++++++++++++++++++++
 include/hw/virtio/vhost-backend.h |  8 ++++
 include/hw/virtio/vhost.h         | 16 +++++++
 5 files changed, 224 insertions(+)
docs/interop/vhost-user.txt +0 -0
index 954771d..1b98388 100644

docs/interop/vhost-user.txt Depending on the request type, payload can be: · line 125

Quoted 10 lines
docs/interop/vhost-user.txt +7 -0
@@ -116,6 +116,16 @@ Depending on the request type, payload can be:
     - 3: IOTLB invalidate
     - 4: IOTLB access fail
 
+ * Virtio device config space
+   ---------------------------
+   | offset | size | payload |
+   ---------------------------
+
+   Offset: a 32-bit offset of virtio device's configuration space
+   Size: a 32-bit size of configuration space that master wanted to change

I guess only legal values here are 1-256? But also see below. Also, we already know the structure size.

docs/interop/vhost-user.txt Depending on the request type, payload can be: · line 128

Quoted 3 lines
docs/interop/vhost-user.txt +3 -0
+   Payload: a 256-bytes array holding the contents of the virtio
+       device's configuration space
+

Why not *size* bytes? These are not performance critical but still, why waste cycles.

docs/interop/vhost-user.txt Depending on the request type, payload can be: · line 131

Quoted 3 lines
docs/interop/vhost-user.txt +0 -0
 In QEMU the vhost-user message is implemented with the following struct:
 
 typedef struct VhostUserMsg {

Virtio spec says:
For device configuration access, the driver MUST use 8-bit wide accesses for 8-bit wide fields, 16-bit wide and aligned accesses for 16-bit wide fields and 32-bit wide and aligned accesses for 32-bit and 64-bit wide fields. For 64-bit fields, the driver MAY access each of the high and low 32-bit parts of the field independently.

So if these commands mirror guest accesses, they are always 1,2,4 or 8 bytes, and aligned.

Signature · 1 line
MST
#11 lore raw

PATCH v5 2/4 vhost-user-blk: introduce a new vhost-user-blk host device

In reply to Changpeng Liu

This commit introduces a new vhost-user device for block, it uses a chardev to connect with the backend, same with Qemu virito-blk device, Guest OS still uses the virtio-blk frontend driver.

To use it, start Qemu with command line like this:

qemu-system-x86_64 \
    -chardev socket,id=char0,path=/path/vhost.socket \
    -device vhost-user-blk-pci,chardev=char0,num-queues=2, \
            bootindex=2... \

Users can use different parameters for num-queues and bootindex.

Different with exist Qemu virtio-blk host device, it makes more easy for users to implement their own I/O processing logic, such as all user space I/O stack against hardware block device. It uses the new vhost messages(VHOST_USER_GET_CONFIG) to get block virtio config information from backend process.

---
 default-configs/pci.mak            |   1 +
 hw/block/Makefile.objs             |   3 +
 hw/block/vhost-user-blk.c          | 356 +++++++++++++++++++++++++++++++++++++
 hw/virtio/virtio-pci.c             |  55 ++++++
 hw/virtio/virtio-pci.h             |  18 ++
 include/hw/virtio/vhost-user-blk.h |  42 +++++
 6 files changed, 475 insertions(+)
 create mode 100644 hw/block/vhost-user-blk.c
 create mode 100644 include/hw/virtio/vhost-user-blk.h
default-configs/pci.mak +1 -0
index e514bde..49a0f28 100644
@@ -43,3 +43,4 @@ CONFIG_VGA_PCI=y
 CONFIG_IVSHMEM_DEVICE=$(CONFIG_IVSHMEM)
 CONFIG_ROCKER=y
 CONFIG_VHOST_USER_SCSI=$(call land,$(CONFIG_VHOST_USER),$(CONFIG_LINUX))
+CONFIG_VHOST_USER_BLK=$(call land,$(CONFIG_VHOST_USER),$(CONFIG_LINUX))
hw/block/Makefile.objs +3 -0
index e0ed980..4c19a58 100644
@@ -13,3 +13,6 @@ obj-$(CONFIG_SH4) += tc58128.o
 
 obj-$(CONFIG_VIRTIO) += virtio-blk.o
 obj-$(CONFIG_VIRTIO) += dataplane/
+ifeq ($(CONFIG_VIRTIO),y)
+obj-$(CONFIG_VHOST_USER_BLK) += vhost-user-blk.o
+endif
hw/block/vhost-user-blk.c new file +356 -0

356 lines not on this page · raw message

hw/virtio/virtio-pci.c +55 -0

67 lines not on this page · raw message

hw/virtio/virtio-pci.h +18 -0
index 12d3a90..813082b 100644
@@ -27,6 +27,9 @@
 #include "hw/virtio/virtio-gpu.h"
 #include "hw/virtio/virtio-crypto.h"
 #include "hw/virtio/vhost-user-scsi.h"
+#if defined(CONFIG_VHOST_USER) && defined(CONFIG_LINUX)
+#include "hw/virtio/vhost-user-blk.h"
+#endif
 
 #ifdef CONFIG_VIRTFS
 #include "hw/9pfs/virtio-9p.h"
@@ -46,6 +49,7 @@ typedef struct VirtIOSerialPCI VirtIOSerialPCI;
 typedef struct VirtIONetPCI VirtIONetPCI;
 typedef struct VHostSCSIPCI VHostSCSIPCI;
 typedef struct VHostUserSCSIPCI VHostUserSCSIPCI;
+typedef struct VHostUserBlkPCI VHostUserBlkPCI;
 typedef struct VirtIORngPCI VirtIORngPCI;
 typedef struct VirtIOInputPCI VirtIOInputPCI;
 typedef struct VirtIOInputHIDPCI VirtIOInputHIDPCI;
@@ -244,6 +248,20 @@ struct VHostUserSCSIPCI {
     VHostUserSCSI vdev;
 };
 
+#if defined(CONFIG_VHOST_USER) && defined(CONFIG_LINUX)
+/*
+ * vhost-user-blk-pci: This extends VirtioPCIProxy.
+ */
+#define TYPE_VHOST_USER_BLK_PCI "vhost-user-blk-pci"
+#define VHOST_USER_BLK_PCI(obj) \
+        OBJECT_CHECK(VHostUserBlkPCI, (obj), TYPE_VHOST_USER_BLK_PCI)
+
+struct VHostUserBlkPCI {
+    VirtIOPCIProxy parent_obj;
+    VHostUserBlk vdev;
+};
+#endif
+
 /*
  * virtio-blk-pci: This extends VirtioPCIProxy.
  */
include/hw/virtio/vhost-user-blk.h new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
1.9.3
#12 lore raw

PATCH v5 3/4 contrib/libvhost-user: enable virtio config space messages

In reply to Changpeng Liu

Enable VHOST_USER_GET_CONFIG/VHOST_USER_SET_CONFIG/VHOST_USER_SET_CONFIG_FD messages in libvhost-user library, users can implement their own I/O target based on the library. This enable the virtio config space delivered between Qemu host device and the I/O target, also event notifier is added in case of virtio config space changed.

---
 contrib/libvhost-user/libvhost-user.c | 79 +++++++++++++++++++++++++++++++++++
 contrib/libvhost-user/libvhost-user.h | 24 ++++++++++-
 2 files changed, 102 insertions(+), 1 deletion(-)
contrib/libvhost-user/libvhost-user.c +79 -0
index f409bd3..16fc4f2 100644
@@ -84,6 +84,9 @@ vu_request_to_string(unsigned int req)
         REQ(VHOST_USER_SET_SLAVE_REQ_FD),
         REQ(VHOST_USER_IOTLB_MSG),
         REQ(VHOST_USER_SET_VRING_ENDIAN),
+        REQ(VHOST_USER_GET_CONFIG),
+        REQ(VHOST_USER_SET_CONFIG),
+        REQ(VHOST_USER_SET_CONFIG_FD),
         REQ(VHOST_USER_MAX),
     };
 #undef REQ
@@ -798,6 +801,69 @@ vu_set_slave_req_fd(VuDev *dev, VhostUserMsg *vmsg)
 }
 
 static bool
+vu_get_config(VuDev *dev, VhostUserMsg *vmsg)
+{
+    int ret = -1;
+
+    if (dev->iface->get_config) {
+        ret = dev->iface->get_config(dev, vmsg->payload.config.region,
+                                     sizeof(vmsg->payload.config.region));
+    }
+
+    if (ret) {
+        /* resize to zero to indicate an error to master */
+        vmsg->size = 0;
+    }
+
+    return true;
+}
+
+static bool
+vu_set_config(VuDev *dev, VhostUserMsg *vmsg)
+{
+    int ret = -1;
+    bool reply_supported = !!(dev->protocol_features &
+                             (1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK));
+
+    if (dev->iface->set_config) {
+        ret = dev->iface->set_config(dev, vmsg->payload.config.region,
+                                     vmsg->payload.config.offset,
+                                     vmsg->payload.config.size);
+    }
+
+    vmsg->size = sizeof(vmsg->payload.u64);
+    if (!ret) {
+        vmsg->payload.u64 = 0;
+    } else {
+        /* indicate an error in case reply supported */
+        vmsg->payload.u64 = 1;
+    }
+
+    if (reply_supported) {
+        return true;
+    }
+
+    return false;
+}
+
+static bool
+vu_set_config_fd(VuDev *dev, VhostUserMsg *vmsg)
+{
+   if (vmsg->fd_num != 1) {
+        vu_panic(dev, "Invalid config_fd message");
+        return false;
+    }
+
+    if (dev->config_fd != -1) {
+        close(dev->config_fd);
+    }
+    dev->config_fd = vmsg->fds[0];
+    DPRINT("Got config_fd: %d\n", vmsg->fds[0]);
+
+    return false;
+}
+
+static bool
 vu_process_message(VuDev *dev, VhostUserMsg *vmsg)
 {
     int do_reply = 0;
@@ -862,6 +928,12 @@ vu_process_message(VuDev *dev, VhostUserMsg *vmsg)
         return vu_set_vring_enable_exec(dev, vmsg);
     case VHOST_USER_SET_SLAVE_REQ_FD:
         return vu_set_slave_req_fd(dev, vmsg);
+    case VHOST_USER_GET_CONFIG:
+        return vu_get_config(dev, vmsg);
+    case VHOST_USER_SET_CONFIG:
+        return vu_set_config(dev, vmsg);
+    case VHOST_USER_SET_CONFIG_FD:
+        return vu_set_config_fd(dev, vmsg);
     case VHOST_USER_NONE:
         break;
     default:
@@ -940,6 +1012,11 @@ vu_deinit(VuDev *dev)
         dev->slave_fd = -1;
     }
 
+    if (dev->config_fd != -1) {
+        close(dev->config_fd);
+        dev->config_fd = -1;
+    }
+
     if (dev->sock != -1) {
         close(dev->sock);
     }
@@ -970,6 +1047,8 @@ vu_init(VuDev *dev,
     dev->iface = iface;
     dev->log_call_fd = -1;
     dev->slave_fd = -1;
+    dev->config_fd = -1;
+
     for (i = 0; i < VHOST_MAX_NR_VIRTQUEUE; i++) {
         dev->vq[i] = (VuVirtq) {
             .call_fd = -1, .kick_fd = -1, .err_fd = -1,
contrib/libvhost-user/libvhost-user.h +23 -1
index 2f5864b..0d1f674 100644
@@ -30,6 +30,11 @@
 
 #define VHOST_MEMORY_MAX_NREGIONS 8
 
+/*
+ * Maximum size of virtio device config space
+ */
+#define VHOST_USER_MAX_CONFIG_SIZE 256
+
 enum VhostUserProtocolFeature {
     VHOST_USER_PROTOCOL_F_MQ = 0,
     VHOST_USER_PROTOCOL_F_LOG_SHMFD = 1,
@@ -38,7 +43,6 @@ enum VhostUserProtocolFeature {
     VHOST_USER_PROTOCOL_F_NET_MTU = 4,
     VHOST_USER_PROTOCOL_F_SLAVE_REQ = 5,
     VHOST_USER_PROTOCOL_F_CROSS_ENDIAN = 6,
-
     VHOST_USER_PROTOCOL_F_MAX
 };
 
@@ -69,6 +73,9 @@ typedef enum VhostUserRequest {
     VHOST_USER_SET_SLAVE_REQ_FD = 21,
     VHOST_USER_IOTLB_MSG = 22,
     VHOST_USER_SET_VRING_ENDIAN = 23,
+    VHOST_USER_GET_CONFIG = 24,
+    VHOST_USER_SET_CONFIG = 25,
+    VHOST_USER_SET_CONFIG_FD = 26,
     VHOST_USER_MAX
 } VhostUserRequest;
 
@@ -90,6 +97,12 @@ typedef struct VhostUserLog {
     uint64_t mmap_offset;
 } VhostUserLog;
 
+typedef struct VhostUserConfig {
+    uint32_t offset;
+    uint32_t size;
+    uint8_t region[VHOST_USER_MAX_CONFIG_SIZE];
+} VhostUserConfig;
+
 #if defined(_WIN32)
 # define VU_PACKED __attribute__((gcc_struct, packed))
 #else
@@ -112,6 +125,7 @@ typedef struct VhostUserMsg {
         struct vhost_vring_addr addr;
         VhostUserMemory memory;
         VhostUserLog log;
+        VhostUserConfig config;
     } payload;
 
     int fds[VHOST_MEMORY_MAX_NREGIONS];
@@ -140,6 +154,9 @@ typedef int (*vu_process_msg_cb) (VuDev *dev, VhostUserMsg *vmsg,
                                   int *do_reply);
 typedef void (*vu_queue_set_started_cb) (VuDev *dev, int qidx, bool started);
 typedef bool (*vu_queue_is_processed_in_order_cb) (VuDev *dev, int qidx);
+typedef int (*vu_get_config_cb) (VuDev *dev, uint8_t *config, size_t len);
+typedef int (*vu_set_config_cb) (VuDev *dev, const uint8_t *config,
+                                 uint32_t offset, uint32_t size);
 
 typedef struct VuDevIface {
     /* called by VHOST_USER_GET_FEATURES to get the features bitmask */
@@ -162,6 +179,10 @@ typedef struct VuDevIface {
      * on unmanaged exit/crash.
      */
     vu_queue_is_processed_in_order_cb queue_is_processed_in_order;
+    /* get the config space of the device */
+    vu_get_config_cb get_config;
+    /* set the config space of the device */
+    vu_set_config_cb set_config;
 } VuDevIface;
 
 typedef void (*vu_queue_handler_cb) (VuDev *dev, int qidx);
@@ -227,6 +248,7 @@ struct VuDev {
     VuVirtq vq[VHOST_MAX_NR_VIRTQUEUE];
     int log_call_fd;
     int slave_fd;
+    int config_fd;
     uint64_t log_size;
     uint8_t *log_table;
     uint64_t features;
Signature · 1 line
1.9.3
#13 lore raw

PATCH v5 4/4 contrib/vhost-user-blk: introduce a vhost-user-blk sample application

In reply to Changpeng Liu

This commit introcudes a vhost-user-blk backend device, it uses UNIX domain socket to communicate with Qemu. The vhost-user-blk sample application should be used with Qemu vhost-user-blk-pci device.

To use it, complie with:
make vhost-user-blk

and start like this:
vhost-user-blk -b /dev/sdb -s /path/vhost.socket

---
 .gitignore                              |   1 +
 Makefile                                |   3 +
 Makefile.objs                           |   1 +
 contrib/vhost-user-blk/Makefile.objs    |   1 +
 contrib/vhost-user-blk/vhost-user-blk.c | 536 ++++++++++++++++++++++++++++++++
 5 files changed, 542 insertions(+)
 create mode 100644 contrib/vhost-user-blk/Makefile.objs
 create mode 100644 contrib/vhost-user-blk/vhost-user-blk.c
.gitignore +1 -0
index 588769b..495f854 100644
@@ -55,6 +55,7 @@
 /scsi/qemu-pr-helper
 /vscclient
 /vhost-user-scsi
+/vhost-user-blk
 /fsdev/virtfs-proxy-helper
 *.tmp
 *.[1-9]
Makefile +3 -0
index d2e31d9..0cfb0f1 100644
@@ -327,6 +327,7 @@ dummy := $(call unnest-vars,, \
                 ivshmem-server-obj-y \
                 libvhost-user-obj-y \
                 vhost-user-scsi-obj-y \
+                vhost-user-blk-obj-y \
                 qga-vss-dll-obj-y \
                 block-obj-y \
                 block-obj-m \
@@ -558,6 +559,8 @@ ivshmem-server$(EXESUF): $(ivshmem-server-obj-y) $(COMMON_LDADDS)
 endif
 vhost-user-scsi$(EXESUF): $(vhost-user-scsi-obj-y) libvhost-user.a
 	$(call LINK, $^)
+vhost-user-blk$(EXESUF): $(vhost-user-blk-obj-y) libvhost-user.a
+	$(call LINK, $^)
 
 module_block.h: $(SRC_PATH)/scripts/modules/module_block.py config-host.mak
 	$(call quiet-command,$(PYTHON) $< $@ \
Makefile.objs +1 -0
index 285c6f3..ae9aef7 100644
@@ -115,6 +115,7 @@ libvhost-user-obj-y = contrib/libvhost-user/
 vhost-user-scsi.o-cflags := $(LIBISCSI_CFLAGS)
 vhost-user-scsi.o-libs := $(LIBISCSI_LIBS)
 vhost-user-scsi-obj-y = contrib/vhost-user-scsi/
+vhost-user-blk-obj-y = contrib/vhost-user-blk/
 
 ######################################################################
 trace-events-subdirs =
contrib/vhost-user-blk/Makefile.objs new file +1 -0
new file mode 100644
index 0000000..72e2cdc
@@ -0,0 +1 @@
+vhost-user-blk-obj-y = vhost-user-blk.o
contrib/vhost-user-blk/vhost-user-blk.c new file +536 -0

536 lines not on this page · raw message

Signature · 1 line
1.9.3