aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorLaurent Vivier <lvivier@redhat.com>2024-12-13 16:48:22 +0100
committerLaurent Vivier <lvivier@redhat.com>2024-12-19 12:07:46 +0100
commit5e62fe3715cb0a216976a6f5e4605b30ec718bd7 (patch)
tree0facf75f54bccdbb73fa4372468f2c444bc20e41
parente5ba8adef71ec53e192373ed1267dc338719dda0 (diff)
downloadpasst-5e62fe3715cb0a216976a6f5e4605b30ec718bd7.tar
passt-5e62fe3715cb0a216976a6f5e4605b30ec718bd7.tar.gz
passt-5e62fe3715cb0a216976a6f5e4605b30ec718bd7.tar.bz2
passt-5e62fe3715cb0a216976a6f5e4605b30ec718bd7.tar.lz
passt-5e62fe3715cb0a216976a6f5e4605b30ec718bd7.tar.xz
passt-5e62fe3715cb0a216976a6f5e4605b30ec718bd7.tar.zst
passt-5e62fe3715cb0a216976a6f5e4605b30ec718bd7.zip
virtio: Use const pointer for vu_dev
We don't modify the structure in some virtio functions. Signed-off-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r--virtio.c14
-rw-r--r--virtio.h2
-rw-r--r--vu_common.c2
-rw-r--r--vu_common.h2
4 files changed, 12 insertions, 8 deletions
diff --git a/virtio.c b/virtio.c
index a76de5e..625bac3 100644
--- a/virtio.c
+++ b/virtio.c
@@ -92,7 +92,8 @@
*
* Return: virtual address in our address space of the guest physical address
*/
-static void *vu_gpa_to_va(struct vu_dev *dev, uint64_t *plen, uint64_t guest_addr)
+static void *vu_gpa_to_va(const struct vu_dev *dev, uint64_t *plen,
+ uint64_t guest_addr)
{
unsigned int i;
@@ -210,7 +211,8 @@ static void virtqueue_get_head(const struct vu_virtq *vq,
*
* Return: -1 if there is an error, 0 otherwise
*/
-static int virtqueue_read_indirect_desc(struct vu_dev *dev, struct vring_desc *desc,
+static int virtqueue_read_indirect_desc(const struct vu_dev *dev,
+ struct vring_desc *desc,
uint64_t addr, size_t len)
{
uint64_t read_len;
@@ -390,7 +392,7 @@ static inline void vring_set_avail_event(const struct vu_virtq *vq,
*
* Return: false on error, true otherwise
*/
-static bool virtqueue_map_desc(struct vu_dev *dev,
+static bool virtqueue_map_desc(const struct vu_dev *dev,
unsigned int *p_num_sg, struct iovec *iov,
unsigned int max_num_sg,
uint64_t pa, size_t sz)
@@ -426,7 +428,8 @@ static bool virtqueue_map_desc(struct vu_dev *dev,
*
* Return: -1 if there is an error, 0 otherwise
*/
-static int vu_queue_map_desc(struct vu_dev *dev, struct vu_virtq *vq, unsigned int idx,
+static int vu_queue_map_desc(const struct vu_dev *dev,
+ struct vu_virtq *vq, unsigned int idx,
struct vu_virtq_element *elem)
{
const struct vring_desc *desc = vq->vring.desc;
@@ -504,7 +507,8 @@ static int vu_queue_map_desc(struct vu_dev *dev, struct vu_virtq *vq, unsigned i
*
* Return: -1 if there is an error, 0 otherwise
*/
-int vu_queue_pop(struct vu_dev *dev, struct vu_virtq *vq, struct vu_virtq_element *elem)
+int vu_queue_pop(const struct vu_dev *dev, struct vu_virtq *vq,
+ struct vu_virtq_element *elem)
{
unsigned int head;
int ret;
diff --git a/virtio.h b/virtio.h
index 6410d60..0af259d 100644
--- a/virtio.h
+++ b/virtio.h
@@ -170,7 +170,7 @@ static inline bool vu_has_protocol_feature(const struct vu_dev *vdev,
bool vu_queue_empty(struct vu_virtq *vq);
void vu_queue_notify(const struct vu_dev *dev, struct vu_virtq *vq);
-int vu_queue_pop(struct vu_dev *dev, struct vu_virtq *vq,
+int vu_queue_pop(const struct vu_dev *dev, struct vu_virtq *vq,
struct vu_virtq_element *elem);
void vu_queue_detach_element(struct vu_virtq *vq);
void vu_queue_unpop(struct vu_virtq *vq);
diff --git a/vu_common.c b/vu_common.c
index 299b5a3..6d365be 100644
--- a/vu_common.c
+++ b/vu_common.c
@@ -73,7 +73,7 @@ void vu_init_elem(struct vu_virtq_element *elem, struct iovec *iov, int elem_cnt
*
* Return: number of elements used to contain the frame
*/
-int vu_collect(struct vu_dev *vdev, struct vu_virtq *vq,
+int vu_collect(const struct vu_dev *vdev, struct vu_virtq *vq,
struct vu_virtq_element *elem, int max_elem,
size_t size, size_t *frame_size)
{
diff --git a/vu_common.h b/vu_common.h
index 901d972..bd70faf 100644
--- a/vu_common.h
+++ b/vu_common.h
@@ -46,7 +46,7 @@ static inline void vu_set_element(struct vu_virtq_element *elem,
void vu_init_elem(struct vu_virtq_element *elem, struct iovec *iov,
int elem_cnt);
-int vu_collect(struct vu_dev *vdev, struct vu_virtq *vq,
+int vu_collect(const struct vu_dev *vdev, struct vu_virtq *vq,
struct vu_virtq_element *elem, int max_elem, size_t size,
size_t *frame_size);
void vu_set_vnethdr(const struct vu_dev *vdev,