mirror of https://github.com/xemu-project/xemu.git
virtio: avoid leading underscores for helpers
Commit ef546f1275
("virtio: add
feature checking helpers") introduced a helper __virtio_has_feature.
We don't want to use reserved identifiers, though, so let's
rename __virtio_has_feature to virtio_has_feature and virtio_has_feature
to virtio_vdev_has_feature.
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
91176e3105
commit
95129d6fc9
|
@ -731,7 +731,7 @@ static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features,
|
||||||
virtio_add_feature(&features, VIRTIO_BLK_F_GEOMETRY);
|
virtio_add_feature(&features, VIRTIO_BLK_F_GEOMETRY);
|
||||||
virtio_add_feature(&features, VIRTIO_BLK_F_TOPOLOGY);
|
virtio_add_feature(&features, VIRTIO_BLK_F_TOPOLOGY);
|
||||||
virtio_add_feature(&features, VIRTIO_BLK_F_BLK_SIZE);
|
virtio_add_feature(&features, VIRTIO_BLK_F_BLK_SIZE);
|
||||||
if (__virtio_has_feature(features, VIRTIO_F_VERSION_1)) {
|
if (virtio_has_feature(features, VIRTIO_F_VERSION_1)) {
|
||||||
if (s->conf.scsi) {
|
if (s->conf.scsi) {
|
||||||
error_setg(errp, "Please set scsi=off for virtio-blk devices in order to use virtio 1.0");
|
error_setg(errp, "Please set scsi=off for virtio-blk devices in order to use virtio 1.0");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -782,10 +782,11 @@ static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status)
|
||||||
*
|
*
|
||||||
* s->blk would erroneously be placed in writethrough mode.
|
* s->blk would erroneously be placed in writethrough mode.
|
||||||
*/
|
*/
|
||||||
if (!virtio_has_feature(vdev, VIRTIO_BLK_F_CONFIG_WCE)) {
|
if (!virtio_vdev_has_feature(vdev, VIRTIO_BLK_F_CONFIG_WCE)) {
|
||||||
aio_context_acquire(blk_get_aio_context(s->blk));
|
aio_context_acquire(blk_get_aio_context(s->blk));
|
||||||
blk_set_enable_write_cache(s->blk,
|
blk_set_enable_write_cache(s->blk,
|
||||||
virtio_has_feature(vdev, VIRTIO_BLK_F_WCE));
|
virtio_vdev_has_feature(vdev,
|
||||||
|
VIRTIO_BLK_F_WCE));
|
||||||
aio_context_release(blk_get_aio_context(s->blk));
|
aio_context_release(blk_get_aio_context(s->blk));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ static VirtIOSerialPort *find_port_by_name(char *name)
|
||||||
static bool use_multiport(VirtIOSerial *vser)
|
static bool use_multiport(VirtIOSerial *vser)
|
||||||
{
|
{
|
||||||
VirtIODevice *vdev = VIRTIO_DEVICE(vser);
|
VirtIODevice *vdev = VIRTIO_DEVICE(vser);
|
||||||
return virtio_has_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT);
|
return virtio_vdev_has_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t write_to_port(VirtIOSerialPort *port,
|
static size_t write_to_port(VirtIOSerialPort *port,
|
||||||
|
|
|
@ -197,7 +197,7 @@ static int vhost_net_set_vnet_endian(VirtIODevice *dev, NetClientState *peer,
|
||||||
{
|
{
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
if (virtio_has_feature(dev, VIRTIO_F_VERSION_1) ||
|
if (virtio_vdev_has_feature(dev, VIRTIO_F_VERSION_1) ||
|
||||||
(virtio_legacy_is_cross_endian(dev) && !virtio_is_big_endian(dev))) {
|
(virtio_legacy_is_cross_endian(dev) && !virtio_is_big_endian(dev))) {
|
||||||
r = qemu_set_vnet_le(peer, set);
|
r = qemu_set_vnet_le(peer, set);
|
||||||
if (r) {
|
if (r) {
|
||||||
|
|
|
@ -86,8 +86,8 @@ static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config)
|
||||||
|
|
||||||
memcpy(&netcfg, config, n->config_size);
|
memcpy(&netcfg, config, n->config_size);
|
||||||
|
|
||||||
if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_MAC_ADDR) &&
|
if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_MAC_ADDR) &&
|
||||||
!virtio_has_feature(vdev, VIRTIO_F_VERSION_1) &&
|
!virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1) &&
|
||||||
memcmp(netcfg.mac, n->mac, ETH_ALEN)) {
|
memcmp(netcfg.mac, n->mac, ETH_ALEN)) {
|
||||||
memcpy(n->mac, netcfg.mac, ETH_ALEN);
|
memcpy(n->mac, netcfg.mac, ETH_ALEN);
|
||||||
qemu_format_nic_info_str(qemu_get_queue(n->nic), n->mac);
|
qemu_format_nic_info_str(qemu_get_queue(n->nic), n->mac);
|
||||||
|
@ -304,7 +304,7 @@ static RxFilterInfo *virtio_net_query_rxfilter(NetClientState *nc)
|
||||||
info->multicast_table = str_list;
|
info->multicast_table = str_list;
|
||||||
info->vlan_table = get_vlan_table(n);
|
info->vlan_table = get_vlan_table(n);
|
||||||
|
|
||||||
if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VLAN)) {
|
if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VLAN)) {
|
||||||
info->vlan = RX_STATE_ALL;
|
info->vlan = RX_STATE_ALL;
|
||||||
} else if (!info->vlan_table) {
|
} else if (!info->vlan_table) {
|
||||||
info->vlan = RX_STATE_NONE;
|
info->vlan = RX_STATE_NONE;
|
||||||
|
@ -529,13 +529,13 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
virtio_net_set_multiqueue(n,
|
virtio_net_set_multiqueue(n,
|
||||||
__virtio_has_feature(features, VIRTIO_NET_F_MQ));
|
virtio_has_feature(features, VIRTIO_NET_F_MQ));
|
||||||
|
|
||||||
virtio_net_set_mrg_rx_bufs(n,
|
virtio_net_set_mrg_rx_bufs(n,
|
||||||
__virtio_has_feature(features,
|
virtio_has_feature(features,
|
||||||
VIRTIO_NET_F_MRG_RXBUF),
|
VIRTIO_NET_F_MRG_RXBUF),
|
||||||
__virtio_has_feature(features,
|
virtio_has_feature(features,
|
||||||
VIRTIO_F_VERSION_1));
|
VIRTIO_F_VERSION_1));
|
||||||
|
|
||||||
if (n->has_vnet_hdr) {
|
if (n->has_vnet_hdr) {
|
||||||
n->curr_guest_offloads =
|
n->curr_guest_offloads =
|
||||||
|
@ -552,7 +552,7 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features)
|
||||||
vhost_net_ack_features(get_vhost_net(nc->peer), features);
|
vhost_net_ack_features(get_vhost_net(nc->peer), features);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__virtio_has_feature(features, VIRTIO_NET_F_CTRL_VLAN)) {
|
if (virtio_has_feature(features, VIRTIO_NET_F_CTRL_VLAN)) {
|
||||||
memset(n->vlans, 0, MAX_VLAN >> 3);
|
memset(n->vlans, 0, MAX_VLAN >> 3);
|
||||||
} else {
|
} else {
|
||||||
memset(n->vlans, 0xff, MAX_VLAN >> 3);
|
memset(n->vlans, 0xff, MAX_VLAN >> 3);
|
||||||
|
@ -599,7 +599,7 @@ static int virtio_net_handle_offloads(VirtIONet *n, uint8_t cmd,
|
||||||
uint64_t offloads;
|
uint64_t offloads;
|
||||||
size_t s;
|
size_t s;
|
||||||
|
|
||||||
if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {
|
if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {
|
||||||
return VIRTIO_NET_ERR;
|
return VIRTIO_NET_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1449,7 +1449,7 @@ static void virtio_net_save_device(VirtIODevice *vdev, QEMUFile *f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {
|
if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {
|
||||||
qemu_put_be64(f, n->curr_guest_offloads);
|
qemu_put_be64(f, n->curr_guest_offloads);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1475,7 +1475,8 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f,
|
||||||
n->vqs[0].tx_waiting = qemu_get_be32(f);
|
n->vqs[0].tx_waiting = qemu_get_be32(f);
|
||||||
|
|
||||||
virtio_net_set_mrg_rx_bufs(n, qemu_get_be32(f),
|
virtio_net_set_mrg_rx_bufs(n, qemu_get_be32(f),
|
||||||
virtio_has_feature(vdev, VIRTIO_F_VERSION_1));
|
virtio_vdev_has_feature(vdev,
|
||||||
|
VIRTIO_F_VERSION_1));
|
||||||
|
|
||||||
if (version_id >= 3)
|
if (version_id >= 3)
|
||||||
n->status = qemu_get_be16(f);
|
n->status = qemu_get_be16(f);
|
||||||
|
@ -1558,7 +1559,7 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {
|
if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {
|
||||||
n->curr_guest_offloads = qemu_get_be64(f);
|
n->curr_guest_offloads = qemu_get_be64(f);
|
||||||
} else {
|
} else {
|
||||||
n->curr_guest_offloads = virtio_net_supported_guest_offloads(n);
|
n->curr_guest_offloads = virtio_net_supported_guest_offloads(n);
|
||||||
|
@ -1585,8 +1586,8 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f,
|
||||||
qemu_get_subqueue(n->nic, i)->link_down = link_down;
|
qemu_get_subqueue(n->nic, i)->link_down = link_down;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ANNOUNCE) &&
|
if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_GUEST_ANNOUNCE) &&
|
||||||
virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) {
|
virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) {
|
||||||
n->announce_counter = SELF_ANNOUNCE_ROUNDS;
|
n->announce_counter = SELF_ANNOUNCE_ROUNDS;
|
||||||
timer_mod(n->announce_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL));
|
timer_mod(n->announce_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL));
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,7 +145,7 @@ static int virtio_scsi_parse_req(VirtIOSCSIReq *req,
|
||||||
*
|
*
|
||||||
* TODO: always disable this workaround for virtio 1.0 devices.
|
* TODO: always disable this workaround for virtio 1.0 devices.
|
||||||
*/
|
*/
|
||||||
if (!virtio_has_feature(vdev, VIRTIO_F_ANY_LAYOUT)) {
|
if (!virtio_vdev_has_feature(vdev, VIRTIO_F_ANY_LAYOUT)) {
|
||||||
if (req->elem.out_num) {
|
if (req->elem.out_num) {
|
||||||
req_size = req->elem.out_sg[0].iov_len;
|
req_size = req->elem.out_sg[0].iov_len;
|
||||||
}
|
}
|
||||||
|
@ -759,7 +759,7 @@ static void virtio_scsi_change(SCSIBus *bus, SCSIDevice *dev, SCSISense sense)
|
||||||
VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus);
|
VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus);
|
||||||
VirtIODevice *vdev = VIRTIO_DEVICE(s);
|
VirtIODevice *vdev = VIRTIO_DEVICE(s);
|
||||||
|
|
||||||
if (virtio_has_feature(vdev, VIRTIO_SCSI_F_CHANGE) &&
|
if (virtio_vdev_has_feature(vdev, VIRTIO_SCSI_F_CHANGE) &&
|
||||||
dev->type != TYPE_ROM) {
|
dev->type != TYPE_ROM) {
|
||||||
virtio_scsi_push_event(s, dev, VIRTIO_SCSI_T_PARAM_CHANGE,
|
virtio_scsi_push_event(s, dev, VIRTIO_SCSI_T_PARAM_CHANGE,
|
||||||
sense.asc | (sense.ascq << 8));
|
sense.asc | (sense.ascq << 8));
|
||||||
|
@ -783,7 +783,7 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev,
|
||||||
aio_context_release(s->ctx);
|
aio_context_release(s->ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virtio_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) {
|
if (virtio_vdev_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) {
|
||||||
virtio_scsi_push_event(s, sd,
|
virtio_scsi_push_event(s, sd,
|
||||||
VIRTIO_SCSI_T_TRANSPORT_RESET,
|
VIRTIO_SCSI_T_TRANSPORT_RESET,
|
||||||
VIRTIO_SCSI_EVT_RESET_RESCAN);
|
VIRTIO_SCSI_EVT_RESET_RESCAN);
|
||||||
|
@ -797,7 +797,7 @@ static void virtio_scsi_hotunplug(HotplugHandler *hotplug_dev, DeviceState *dev,
|
||||||
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
|
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
|
||||||
SCSIDevice *sd = SCSI_DEVICE(dev);
|
SCSIDevice *sd = SCSI_DEVICE(dev);
|
||||||
|
|
||||||
if (virtio_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) {
|
if (virtio_vdev_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) {
|
||||||
virtio_scsi_push_event(s, sd,
|
virtio_scsi_push_event(s, sd,
|
||||||
VIRTIO_SCSI_T_TRANSPORT_RESET,
|
VIRTIO_SCSI_T_TRANSPORT_RESET,
|
||||||
VIRTIO_SCSI_EVT_RESET_REMOVED);
|
VIRTIO_SCSI_EVT_RESET_REMOVED);
|
||||||
|
|
|
@ -105,7 +105,7 @@ void vring_teardown(Vring *vring, VirtIODevice *vdev, int n)
|
||||||
/* Disable guest->host notifies */
|
/* Disable guest->host notifies */
|
||||||
void vring_disable_notification(VirtIODevice *vdev, Vring *vring)
|
void vring_disable_notification(VirtIODevice *vdev, Vring *vring)
|
||||||
{
|
{
|
||||||
if (!virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) {
|
if (!virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) {
|
||||||
vring_set_used_flags(vdev, vring, VRING_USED_F_NO_NOTIFY);
|
vring_set_used_flags(vdev, vring, VRING_USED_F_NO_NOTIFY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ void vring_disable_notification(VirtIODevice *vdev, Vring *vring)
|
||||||
*/
|
*/
|
||||||
bool vring_enable_notification(VirtIODevice *vdev, Vring *vring)
|
bool vring_enable_notification(VirtIODevice *vdev, Vring *vring)
|
||||||
{
|
{
|
||||||
if (virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) {
|
if (virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) {
|
||||||
vring_avail_event(&vring->vr) = vring->vr.avail->idx;
|
vring_avail_event(&vring->vr) = vring->vr.avail->idx;
|
||||||
} else {
|
} else {
|
||||||
vring_clear_used_flags(vdev, vring, VRING_USED_F_NO_NOTIFY);
|
vring_clear_used_flags(vdev, vring, VRING_USED_F_NO_NOTIFY);
|
||||||
|
@ -135,12 +135,12 @@ bool vring_should_notify(VirtIODevice *vdev, Vring *vring)
|
||||||
* interrupts. */
|
* interrupts. */
|
||||||
smp_mb();
|
smp_mb();
|
||||||
|
|
||||||
if (virtio_has_feature(vdev, VIRTIO_F_NOTIFY_ON_EMPTY) &&
|
if (virtio_vdev_has_feature(vdev, VIRTIO_F_NOTIFY_ON_EMPTY) &&
|
||||||
unlikely(!vring_more_avail(vdev, vring))) {
|
unlikely(!vring_more_avail(vdev, vring))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) {
|
if (!virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) {
|
||||||
return !(vring_get_avail_flags(vdev, vring) &
|
return !(vring_get_avail_flags(vdev, vring) &
|
||||||
VRING_AVAIL_F_NO_INTERRUPT);
|
VRING_AVAIL_F_NO_INTERRUPT);
|
||||||
}
|
}
|
||||||
|
@ -402,7 +402,7 @@ int vring_pop(VirtIODevice *vdev, Vring *vring,
|
||||||
|
|
||||||
/* On success, increment avail index. */
|
/* On success, increment avail index. */
|
||||||
vring->last_avail_idx++;
|
vring->last_avail_idx++;
|
||||||
if (virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) {
|
if (virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) {
|
||||||
vring_avail_event(&vring->vr) =
|
vring_avail_event(&vring->vr) =
|
||||||
virtio_tswap16(vdev, vring->last_avail_idx);
|
virtio_tswap16(vdev, vring->last_avail_idx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -742,7 +742,7 @@ static int vhost_virtqueue_start(struct vhost_dev *dev,
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1) &&
|
if (!virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1) &&
|
||||||
virtio_legacy_is_cross_endian(vdev)) {
|
virtio_legacy_is_cross_endian(vdev)) {
|
||||||
r = vhost_virtqueue_set_vring_endian_legacy(dev,
|
r = vhost_virtqueue_set_vring_endian_legacy(dev,
|
||||||
virtio_is_big_endian(vdev),
|
virtio_is_big_endian(vdev),
|
||||||
|
@ -839,7 +839,7 @@ static void vhost_virtqueue_stop(struct vhost_dev *dev,
|
||||||
/* In the cross-endian case, we need to reset the vring endianness to
|
/* In the cross-endian case, we need to reset the vring endianness to
|
||||||
* native as legacy devices expect so by default.
|
* native as legacy devices expect so by default.
|
||||||
*/
|
*/
|
||||||
if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1) &&
|
if (!virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1) &&
|
||||||
virtio_legacy_is_cross_endian(vdev)) {
|
virtio_legacy_is_cross_endian(vdev)) {
|
||||||
r = vhost_virtqueue_set_vring_endian_legacy(dev,
|
r = vhost_virtqueue_set_vring_endian_legacy(dev,
|
||||||
!virtio_is_big_endian(vdev),
|
!virtio_is_big_endian(vdev),
|
||||||
|
|
|
@ -70,7 +70,7 @@ static inline void reset_stats(VirtIOBalloon *dev)
|
||||||
static bool balloon_stats_supported(const VirtIOBalloon *s)
|
static bool balloon_stats_supported(const VirtIOBalloon *s)
|
||||||
{
|
{
|
||||||
VirtIODevice *vdev = VIRTIO_DEVICE(s);
|
VirtIODevice *vdev = VIRTIO_DEVICE(s);
|
||||||
return virtio_has_feature(vdev, VIRTIO_BALLOON_F_STATS_VQ);
|
return virtio_vdev_has_feature(vdev, VIRTIO_BALLOON_F_STATS_VQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool balloon_stats_enabled(const VirtIOBalloon *s)
|
static bool balloon_stats_enabled(const VirtIOBalloon *s)
|
||||||
|
|
|
@ -220,7 +220,7 @@ static inline void vring_set_avail_event(VirtQueue *vq, uint16_t val)
|
||||||
void virtio_queue_set_notification(VirtQueue *vq, int enable)
|
void virtio_queue_set_notification(VirtQueue *vq, int enable)
|
||||||
{
|
{
|
||||||
vq->notification = enable;
|
vq->notification = enable;
|
||||||
if (virtio_has_feature(vq->vdev, VIRTIO_RING_F_EVENT_IDX)) {
|
if (virtio_vdev_has_feature(vq->vdev, VIRTIO_RING_F_EVENT_IDX)) {
|
||||||
vring_set_avail_event(vq, vring_avail_idx(vq));
|
vring_set_avail_event(vq, vring_avail_idx(vq));
|
||||||
} else if (enable) {
|
} else if (enable) {
|
||||||
vring_used_flags_unset_bit(vq, VRING_USED_F_NO_NOTIFY);
|
vring_used_flags_unset_bit(vq, VRING_USED_F_NO_NOTIFY);
|
||||||
|
@ -471,7 +471,7 @@ int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem)
|
||||||
max = vq->vring.num;
|
max = vq->vring.num;
|
||||||
|
|
||||||
i = head = virtqueue_get_head(vq, vq->last_avail_idx++);
|
i = head = virtqueue_get_head(vq, vq->last_avail_idx++);
|
||||||
if (virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) {
|
if (virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) {
|
||||||
vring_set_avail_event(vq, vq->last_avail_idx);
|
vring_set_avail_event(vq, vq->last_avail_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,7 +560,7 @@ int virtio_set_status(VirtIODevice *vdev, uint8_t val)
|
||||||
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
|
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
|
||||||
trace_virtio_set_status(vdev, val);
|
trace_virtio_set_status(vdev, val);
|
||||||
|
|
||||||
if (virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) {
|
if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
|
||||||
if (!(vdev->status & VIRTIO_CONFIG_S_FEATURES_OK) &&
|
if (!(vdev->status & VIRTIO_CONFIG_S_FEATURES_OK) &&
|
||||||
val & VIRTIO_CONFIG_S_FEATURES_OK) {
|
val & VIRTIO_CONFIG_S_FEATURES_OK) {
|
||||||
int ret = virtio_validate_features(vdev);
|
int ret = virtio_validate_features(vdev);
|
||||||
|
@ -898,7 +898,7 @@ void virtio_queue_set_align(VirtIODevice *vdev, int n, int align)
|
||||||
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
|
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
|
||||||
|
|
||||||
/* virtio-1 compliant devices cannot change the alignment */
|
/* virtio-1 compliant devices cannot change the alignment */
|
||||||
if (virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) {
|
if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
|
||||||
error_report("tried to modify queue alignment for virtio-1 device");
|
error_report("tried to modify queue alignment for virtio-1 device");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -993,12 +993,12 @@ static bool vring_notify(VirtIODevice *vdev, VirtQueue *vq)
|
||||||
/* We need to expose used array entries before checking used event. */
|
/* We need to expose used array entries before checking used event. */
|
||||||
smp_mb();
|
smp_mb();
|
||||||
/* Always notify when queue is empty (when feature acknowledge) */
|
/* Always notify when queue is empty (when feature acknowledge) */
|
||||||
if (virtio_has_feature(vdev, VIRTIO_F_NOTIFY_ON_EMPTY) &&
|
if (virtio_vdev_has_feature(vdev, VIRTIO_F_NOTIFY_ON_EMPTY) &&
|
||||||
!vq->inuse && vring_avail_idx(vq) == vq->last_avail_idx) {
|
!vq->inuse && vring_avail_idx(vq) == vq->last_avail_idx) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) {
|
if (!virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) {
|
||||||
return !(vring_avail_flags(vq) & VRING_AVAIL_F_NO_INTERRUPT);
|
return !(vring_avail_flags(vq) & VRING_AVAIL_F_NO_INTERRUPT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1035,7 +1035,7 @@ static bool virtio_device_endian_needed(void *opaque)
|
||||||
VirtIODevice *vdev = opaque;
|
VirtIODevice *vdev = opaque;
|
||||||
|
|
||||||
assert(vdev->device_endian != VIRTIO_DEVICE_ENDIAN_UNKNOWN);
|
assert(vdev->device_endian != VIRTIO_DEVICE_ENDIAN_UNKNOWN);
|
||||||
if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) {
|
if (!virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
|
||||||
return vdev->device_endian != virtio_default_endian();
|
return vdev->device_endian != virtio_default_endian();
|
||||||
}
|
}
|
||||||
/* Devices conforming to VIRTIO 1.0 or later are always LE. */
|
/* Devices conforming to VIRTIO 1.0 or later are always LE. */
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
static inline bool virtio_access_is_big_endian(VirtIODevice *vdev)
|
static inline bool virtio_access_is_big_endian(VirtIODevice *vdev)
|
||||||
{
|
{
|
||||||
if (virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) {
|
if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
|
||||||
/* Devices conforming to VIRTIO 1.0 or later are always LE. */
|
/* Devices conforming to VIRTIO 1.0 or later are always LE. */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,26 +261,27 @@ static inline void virtio_clear_feature(uint64_t *features, unsigned int fbit)
|
||||||
*features &= ~(1ULL << fbit);
|
*features &= ~(1ULL << fbit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool __virtio_has_feature(uint64_t features, unsigned int fbit)
|
static inline bool virtio_has_feature(uint64_t features, unsigned int fbit)
|
||||||
{
|
{
|
||||||
assert(fbit < 64);
|
assert(fbit < 64);
|
||||||
return !!(features & (1ULL << fbit));
|
return !!(features & (1ULL << fbit));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool virtio_has_feature(VirtIODevice *vdev, unsigned int fbit)
|
static inline bool virtio_vdev_has_feature(VirtIODevice *vdev,
|
||||||
|
unsigned int fbit)
|
||||||
{
|
{
|
||||||
return __virtio_has_feature(vdev->guest_features, fbit);
|
return virtio_has_feature(vdev->guest_features, fbit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool virtio_host_has_feature(VirtIODevice *vdev,
|
static inline bool virtio_host_has_feature(VirtIODevice *vdev,
|
||||||
unsigned int fbit)
|
unsigned int fbit)
|
||||||
{
|
{
|
||||||
return __virtio_has_feature(vdev->host_features, fbit);
|
return virtio_has_feature(vdev->host_features, fbit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool virtio_is_big_endian(VirtIODevice *vdev)
|
static inline bool virtio_is_big_endian(VirtIODevice *vdev)
|
||||||
{
|
{
|
||||||
if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) {
|
if (!virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
|
||||||
assert(vdev->device_endian != VIRTIO_DEVICE_ENDIAN_UNKNOWN);
|
assert(vdev->device_endian != VIRTIO_DEVICE_ENDIAN_UNKNOWN);
|
||||||
return vdev->device_endian == VIRTIO_DEVICE_ENDIAN_BIG;
|
return vdev->device_endian == VIRTIO_DEVICE_ENDIAN_BIG;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue