virtio: assert and ERRLOG for virtio-user dynamic mem allocations
We do not support dynamic memory allocation with the virtio-user library - it results in SET_MEM_TABLE vhost messages for every change which is not supported by the vhost target. Add '-s 256' to vhost fuzz script, to ensure it does not violate the new restriction. This is a follow-on patch for issue #2596. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: If851f53d7d670ac8443f0d9c8f4e3cbe82e0df7c Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14249 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Dong Yi <yidong0635@126.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com> Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
This commit is contained in:
parent
9ffb0497c1
commit
f869197b76
10
CHANGELOG.md
10
CHANGELOG.md
@ -85,6 +85,16 @@ AEN.
|
||||
|
||||
Added new functions: `spdk_hexlify` and `spdk_unhexlify`.
|
||||
|
||||
### virtio
|
||||
|
||||
virtio-vhost-user no longer tries to support dynamic memory allocation. The vhost target does
|
||||
not support the high rate of SET_MEM_TABLE vhost messages that result from dynamic memory
|
||||
allocation, so a virtio-vhost-user device will now present an ERRLOG, assert, and skip the
|
||||
SET_MEM_TABLE vhost message if a memory notification is received outside of the normal device
|
||||
start/stop. Applications using the virtio library in vhost-user mode should now pre-allocate
|
||||
the application's memory using the -s/--mem-size option and use single shared memory file
|
||||
segments using the -g/--single-file-segments option.
|
||||
|
||||
## v22.05
|
||||
|
||||
### sock
|
||||
|
@ -29,6 +29,7 @@ struct virtio_user_dev {
|
||||
uint32_t queue_size;
|
||||
|
||||
uint8_t status;
|
||||
bool is_stopping;
|
||||
char path[PATH_MAX];
|
||||
uint64_t protocol_features;
|
||||
struct vring vrings[SPDK_VIRTIO_MAX_VIRTQUEUES];
|
||||
@ -586,6 +587,18 @@ virtio_user_map_notify(void *cb_ctx, struct spdk_mem_map *map,
|
||||
uint64_t features;
|
||||
int ret;
|
||||
|
||||
/* We do not support dynamic memory allocation with virtio-user. If this is the
|
||||
* initial notification when the device is started, dev->mem_map will be NULL. If
|
||||
* this is the final notification when the device is stopped, dev->is_stopping will
|
||||
* be true. All other cases are unsupported.
|
||||
*/
|
||||
if (dev->mem_map != NULL && !dev->is_stopping) {
|
||||
assert(false);
|
||||
SPDK_ERRLOG("Memory map change with active virtio_user_devs not allowed.\n");
|
||||
SPDK_ERRLOG("Pre-allocate memory for application using -s (mem_size) option.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* We have to resend all mappings anyway, so don't bother with any
|
||||
* page tracking.
|
||||
*/
|
||||
@ -626,6 +639,7 @@ virtio_user_unregister_mem(struct virtio_dev *vdev)
|
||||
{
|
||||
struct virtio_user_dev *dev = vdev->ctx;
|
||||
|
||||
dev->is_stopping = true;
|
||||
spdk_mem_map_free(&dev->mem_map);
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ source "$rootdir/scripts/common.sh"
|
||||
|
||||
VHOST_APP+=(-p 0)
|
||||
FUZZ_RPC_SOCK="/var/tmp/spdk_fuzz.sock"
|
||||
VHOST_FUZZ_APP+=(-r "$FUZZ_RPC_SOCK" -g --wait-for-rpc)
|
||||
VHOST_FUZZ_APP+=(-r "$FUZZ_RPC_SOCK" -g -s 256 --wait-for-rpc)
|
||||
|
||||
vhost_rpc_py="$rootdir/scripts/rpc.py"
|
||||
fuzz_generic_rpc_py="$rootdir/scripts/rpc.py -s $FUZZ_RPC_SOCK"
|
||||
|
Loading…
Reference in New Issue
Block a user