libvhost-user: introduce and use vu_has_protocol_feature()
This simplifies the various has_feature() checks, we already have vu_has_feature() but it checks features, not protocol features. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Message-Id: <20190904065021.1360-1-johannes@sipsolutions.net> Reviewed-by: Tiwei Bie <tiwei.bie@intel.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
8726b70b44
commit
eeb39263aa
@ -94,6 +94,11 @@ bool vu_has_feature(VuDev *dev,
|
|||||||
return has_feature(dev->features, fbit);
|
return has_feature(dev->features, fbit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool vu_has_protocol_feature(VuDev *dev, unsigned int fbit)
|
||||||
|
{
|
||||||
|
return has_feature(dev->protocol_features, fbit);
|
||||||
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
vu_request_to_string(unsigned int req)
|
vu_request_to_string(unsigned int req)
|
||||||
{
|
{
|
||||||
@ -951,8 +956,7 @@ vu_check_queue_inflights(VuDev *dev, VuVirtq *vq)
|
|||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if (!has_feature(dev->protocol_features,
|
if (!vu_has_protocol_feature(dev, VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) {
|
||||||
VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1097,8 +1101,7 @@ bool vu_set_queue_host_notifier(VuDev *dev, VuVirtq *vq, int fd,
|
|||||||
|
|
||||||
vmsg.fd_num = fd_num;
|
vmsg.fd_num = fd_num;
|
||||||
|
|
||||||
if (!has_feature(dev->protocol_features,
|
if (!vu_has_protocol_feature(dev, VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD)) {
|
||||||
VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2191,8 +2194,7 @@ vu_queue_map_desc(VuDev *dev, VuVirtq *vq, unsigned int idx, size_t sz)
|
|||||||
static int
|
static int
|
||||||
vu_queue_inflight_get(VuDev *dev, VuVirtq *vq, int desc_idx)
|
vu_queue_inflight_get(VuDev *dev, VuVirtq *vq, int desc_idx)
|
||||||
{
|
{
|
||||||
if (!has_feature(dev->protocol_features,
|
if (!vu_has_protocol_feature(dev, VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) {
|
||||||
VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2209,8 +2211,7 @@ vu_queue_inflight_get(VuDev *dev, VuVirtq *vq, int desc_idx)
|
|||||||
static int
|
static int
|
||||||
vu_queue_inflight_pre_put(VuDev *dev, VuVirtq *vq, int desc_idx)
|
vu_queue_inflight_pre_put(VuDev *dev, VuVirtq *vq, int desc_idx)
|
||||||
{
|
{
|
||||||
if (!has_feature(dev->protocol_features,
|
if (!vu_has_protocol_feature(dev, VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) {
|
||||||
VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2226,8 +2227,7 @@ vu_queue_inflight_pre_put(VuDev *dev, VuVirtq *vq, int desc_idx)
|
|||||||
static int
|
static int
|
||||||
vu_queue_inflight_post_put(VuDev *dev, VuVirtq *vq, int desc_idx)
|
vu_queue_inflight_post_put(VuDev *dev, VuVirtq *vq, int desc_idx)
|
||||||
{
|
{
|
||||||
if (!has_feature(dev->protocol_features,
|
if (!vu_has_protocol_feature(dev, VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) {
|
||||||
VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user