Skip to content

Commit

Permalink
Merge branch 'master' into json_caps
Browse files Browse the repository at this point in the history
  • Loading branch information
mnissler-rivos authored Aug 31, 2023
2 parents 17c0191 + f981913 commit 4686d09
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 32 deletions.
3 changes: 3 additions & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ branches:
- ubuntu-20
- ubuntu-22
- fedora-35
- debian-11
- debian-12
- arch-202307
# Required. Enforce all configured restrictions for administrators. Set to true to enforce required status checks for repository administrators. Set to null to disable.
enforce_admins: true
# Required. Restrict who can push to this branch. Team and user restrictions are only available for organization-owned repositories. Set to null to disable.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
timeout-minutes: 5
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: run-scan
run: |
sudo apt-get update
Expand Down
51 changes: 46 additions & 5 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
timeout-minutes: 10
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: pre-push
run: |
sudo apt-get update
Expand All @@ -17,7 +17,7 @@ jobs:
timeout-minutes: 10
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: pre-push
run: |
sudo apt-get update
Expand All @@ -30,7 +30,7 @@ jobs:
runs-on: ubuntu-latest
container: centos:7
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: pre-push
run: |
# NB: no working flake8
Expand All @@ -43,18 +43,59 @@ jobs:
runs-on: ubuntu-latest
container: fedora:35
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: pre-push
run: |
dnf -y install --releasever=35 \
gcc make clang clang-analyzer json-c-devel libcmocka-devel pciutils \
diffutils valgrind python3-pytest python3-flake8 which \
meson ninja-build
./.github/workflows/pull_request.sh
debian-11:
timeout-minutes: 10
runs-on: ubuntu-20.04
container: debian:11
steps:
- uses: actions/checkout@v3
- name: pre-push
run: |
apt-get update
apt-get -y install build-essential cmake pkg-config libjson-c-dev \
libcmocka-dev clang clang-tools valgrind python3-pytest \
debianutils flake8 meson ninja-build
./.github/workflows/pull_request.sh
debian-12:
timeout-minutes: 10
runs-on: ubuntu-22.04
container: debian:12
steps:
- uses: actions/checkout@v3
- name: pre-push
run: |
apt-get update
apt-get -y install build-essential cmake pkg-config libjson-c-dev \
libcmocka-dev clang clang-tools valgrind python3-pytest \
debianutils flake8 meson ninja-build
./.github/workflows/pull_request.sh
arch-202307:
timeout-minutes: 10
runs-on: ubuntu-latest
container: archlinux:base-20230723.0.166908
steps:
- uses: actions/checkout@v3
- name: pre-push
run: |
# clang expects a newer glibc
pacman -Sy --noconfirm \
base-devel glibc clang json-c cmocka pciutils diffutils valgrind \
python-pytest flake8 meson ninja
# this fixes debuginfod not automatically updating the url
export DEBUGINFOD_URLS="https://debuginfod.archlinux.org"
./.github/workflows/pull_request.sh
spelling:
runs-on: ubuntu-latest
container: vlajos/misspell-fixer
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: run misspell-fixer
run: /misspell-fixer/misspell-fixer -sv .
14 changes: 6 additions & 8 deletions include/vfio-user.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,12 @@ struct vfio_user_header {
uint16_t msg_id;
uint16_t cmd;
uint32_t msg_size;
struct {
uint32_t type : 4;
#define VFIO_USER_F_TYPE_COMMAND 0
#define VFIO_USER_F_TYPE_REPLY 1
uint32_t no_reply : 1;
uint32_t error : 1;
uint32_t resvd : 26;
} flags;
uint32_t flags;
#define VFIO_USER_F_TYPE_MASK (0xf)
#define VFIO_USER_F_TYPE_COMMAND (0x0)
#define VFIO_USER_F_TYPE_REPLY (0x1)
#define VFIO_USER_F_NO_REPLY (0x10)
#define VFIO_USER_F_ERROR (0x20)
uint32_t error_no;
} __attribute__((packed));

Expand Down
2 changes: 1 addition & 1 deletion lib/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ log_dirty_bitmap(vfu_ctx_t *vfu_ctx, dma_memory_region_t *region,
size_t i;
size_t count;
for (i = 0, count = 0; i < size; i++) {
count += __builtin_popcount(bitmap[i]);
count += __builtin_popcount((uint8_t)bitmap[i]);
}
vfu_log(vfu_ctx, LOG_DEBUG, "dirty pages: get [%p, %p), %zu dirty pages",
region->info.iova.iov_base, iov_end(&region->info.iova),
Expand Down
4 changes: 2 additions & 2 deletions lib/libvfio-user.c
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ do_reply(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg, int reply_errno)
assert(vfu_ctx != NULL);
assert(msg != NULL);

if (msg->hdr.flags.no_reply) {
if (msg->hdr.flags & VFIO_USER_F_NO_REPLY) {
/*
* A failed client request is not a failure of handle_request() itself.
*/
Expand Down Expand Up @@ -1283,7 +1283,7 @@ get_request_header(vfu_ctx_t *vfu_ctx, vfu_msg_t **msgp)
static bool
is_valid_header(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg)
{
if (msg->hdr.flags.type != VFIO_USER_F_TYPE_COMMAND) {
if ((msg->hdr.flags & VFIO_USER_F_TYPE_MASK) != VFIO_USER_F_TYPE_COMMAND) {
vfu_log(vfu_ctx, LOG_ERR, "msg%#hx: not a command req",
msg->hdr.msg_id);
return false;
Expand Down
12 changes: 6 additions & 6 deletions lib/tran_pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ tran_pipe_send_iovec(int fd, uint16_t msg_id, bool is_reply,
}

if (is_reply) {
hdr.flags.type = VFIO_USER_F_TYPE_REPLY;
hdr.flags |= VFIO_USER_F_TYPE_REPLY;
hdr.cmd = cmd;
if (err != 0) {
hdr.flags.error = 1U;
hdr.flags |= VFIO_USER_F_ERROR;
hdr.error_no = err;
}
} else {
hdr.cmd = cmd;
hdr.flags.type = VFIO_USER_F_TYPE_COMMAND;
hdr.flags |= VFIO_USER_F_TYPE_COMMAND;
}

iovecs[0].iov_base = &hdr;
Expand Down Expand Up @@ -131,18 +131,18 @@ tran_pipe_recv(int fd, struct vfio_user_header *hdr, bool is_reply,
return ERROR_INT(EPROTO);
}

if (hdr->flags.type != VFIO_USER_F_TYPE_REPLY) {
if ((hdr->flags & VFIO_USER_F_TYPE_MASK) != VFIO_USER_F_TYPE_REPLY) {
return ERROR_INT(EINVAL);
}

if (hdr->flags.error == 1U) {
if (hdr->flags & VFIO_USER_F_ERROR) {
if (hdr->error_no <= 0) {
hdr->error_no = EINVAL;
}
return ERROR_INT(hdr->error_no);
}
} else {
if (hdr->flags.type != VFIO_USER_F_TYPE_COMMAND) {
if ((hdr->flags & VFIO_USER_F_TYPE_MASK) != VFIO_USER_F_TYPE_COMMAND) {
return ERROR_INT(EINVAL);
}
if (msg_id != NULL) {
Expand Down
12 changes: 6 additions & 6 deletions lib/tran_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ tran_sock_send_iovec(int sock, uint16_t msg_id, bool is_reply,
memset(&msg, 0, sizeof(msg));

if (is_reply) {
hdr.flags.type = VFIO_USER_F_TYPE_REPLY;
hdr.flags |= VFIO_USER_F_TYPE_REPLY;
hdr.cmd = cmd;
if (err != 0) {
hdr.flags.error = 1U;
hdr.flags |= VFIO_USER_F_ERROR;
hdr.error_no = err;
}
} else {
hdr.cmd = cmd;
hdr.flags.type = VFIO_USER_F_TYPE_COMMAND;
hdr.flags |= VFIO_USER_F_TYPE_COMMAND;
}

iovecs[0].iov_base = &hdr;
Expand Down Expand Up @@ -211,18 +211,18 @@ tran_sock_recv_fds(int sock, struct vfio_user_header *hdr, bool is_reply,
return ERROR_INT(EPROTO);
}

if (hdr->flags.type != VFIO_USER_F_TYPE_REPLY) {
if ((hdr->flags & VFIO_USER_F_TYPE_MASK) != VFIO_USER_F_TYPE_REPLY) {
return ERROR_INT(EINVAL);
}

if (hdr->flags.error == 1U) {
if (hdr->flags & VFIO_USER_F_ERROR) {
if (hdr->error_no <= 0) {
hdr->error_no = EINVAL;
}
return ERROR_INT(hdr->error_no);
}
} else {
if (hdr->flags.type != VFIO_USER_F_TYPE_COMMAND) {
if ((hdr->flags & VFIO_USER_F_TYPE_MASK) != VFIO_USER_F_TYPE_COMMAND) {
return ERROR_INT(EINVAL);
}
if (msg_id != NULL) {
Expand Down
4 changes: 2 additions & 2 deletions test/py/libvfio_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class iovec_t(Structure):
]

def __eq__(self, other):
if type(self) != type(other):
if type(self) is not type(other):
return False
return self.iov_base == other.iov_base \
and self.iov_len == other.iov_len
Expand Down Expand Up @@ -491,7 +491,7 @@ class vfu_dma_info_t(Structure):
]

def __eq__(self, other):
if type(self) != type(other):
if type(self) is not type(other):
return False
return self.iova == other.iova \
and self.vaddr == other.vaddr \
Expand Down
2 changes: 1 addition & 1 deletion test/unit-tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ setup(void **state UNUSED)

memset(&msg, 0, sizeof(msg));

msg.hdr.flags.type = VFIO_USER_F_TYPE_COMMAND;
msg.hdr.flags |= VFIO_USER_F_TYPE_COMMAND;
msg.hdr.msg_size = sizeof(msg.hdr);

fds[0] = fds[1] = -1;
Expand Down

0 comments on commit 4686d09

Please sign in to comment.