mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 01:03:55 -06:00
vhost: Distinguish errors in vhost_dev_get_config()
Instead of just returning 0/-1 and letting the caller make up a meaningless error message, add an Error parameter to allow reporting the real error and switch to 0/-errno so that different kind of errors can be distinguished in the caller. config_len in vhost_user_get_config() is defined by the device, so if it's larger than VHOST_USER_MAX_CONFIG_SIZE, this is a programming error. Turn the corresponding check into an assertion. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20210609154658.350308-6-kwolf@redhat.com> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
b8da65689a
commit
50de51387f
10 changed files with 46 additions and 32 deletions
|
@ -1562,15 +1562,23 @@ void vhost_ack_features(struct vhost_dev *hdev, const int *feature_bits,
|
|||
}
|
||||
|
||||
int vhost_dev_get_config(struct vhost_dev *hdev, uint8_t *config,
|
||||
uint32_t config_len)
|
||||
uint32_t config_len, Error **errp)
|
||||
{
|
||||
ERRP_GUARD();
|
||||
int ret;
|
||||
|
||||
assert(hdev->vhost_ops);
|
||||
|
||||
if (hdev->vhost_ops->vhost_get_config) {
|
||||
return hdev->vhost_ops->vhost_get_config(hdev, config, config_len);
|
||||
ret = hdev->vhost_ops->vhost_get_config(hdev, config, config_len, errp);
|
||||
if (ret < 0 && !*errp) {
|
||||
error_setg_errno(errp, -ret, "vhost_get_config failed");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
return -1;
|
||||
error_setg(errp, "vhost_get_config not implemented");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
int vhost_dev_set_config(struct vhost_dev *hdev, const uint8_t *data,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue