Commit graph

102 commits

Author SHA1 Message Date
Sergio Lopez
a577bbc868 vring: Add "get_call" method
Add a "get_call" method to obtain the current value for the call
EventFd.

Signed-off-by: Sergio Lopez <slp@redhat.com>
2021-09-23 19:43:08 +08:00
Sergio Lopez
f4ee3226c0 Cargo: update vhost dependency to v0.2.0
In addition to bringing the features from the new vhost crate, this
fixes the breakage caused by rust-vmm/vmm-sys-util#135

Signed-off-by: Sergio Lopez <slp@redhat.com>
2021-09-23 19:34:47 +08:00
Andreea Florescu
a866ed1d66 update dependabot formatting
Signed-off-by: Andreea Florescu <fandree@amazon.com>
2021-09-10 17:24:49 +03:00
Liu Jiang
70f668a699 doc: refine README.md
Refine README.md, help is needed to improve documentation for
publishing.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-09-09 10:19:50 +02:00
Liu Jiang
f2e38e294a vring: do not take &mut self for VringT
Backend::handle_event() takes an argument of `vrings: &[V]` with
`V: VringT`, so methods of VringT should not take `&mut self`.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-09-09 10:19:50 +02:00
Liu Jiang
e8beb233b5 epoll: refine the way to manage event id
Refine the way to manage epoll event id and simplify interfaces:
- Change VhostUserBackend::exit_event() to return Option<EventFd>
  instead of Option<(EventFd, u16)>.
- Delete VringEpollHandler::exit_event_id.
- Add VringEpollHandler::register_event/unregister_event for internal
  use.
- Make VringEpollHandler::register_listener/unregister_listener() for
  external users only, and 'data` range [0..backend.num_queues()] is
  reserved for queues and exit event.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-09-07 16:32:34 +08:00
Liu Jiang
5998cea89f vring: add VringT::get_mut()
Add VringT::get_mut() to get exclusive reference to underlying
VringState object, so the clients could avoid repeatedly lock/unlock
when using VringMutex and VringRwLock.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-09-07 16:32:34 +08:00
Liu Jiang
e80fab8d98 vring: add generic parameter for VringT
Enhance VhostUserBackend, VhostUserBackendMut, VringEpollHandler,
VhostUserHandler and VhostUserDaemon to support generic type
`V: VringT', so clients could choose different VringT implementations.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-09-07 16:32:34 +08:00
Liu Jiang
ed929c0cbd vring: introduce trait VringT
Introduce trait VringT, and provide three implementations of it:
VringState, VringMutex, VringRwLock.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-09-07 16:32:34 +08:00
Viresh Kumar
f363fb2b53 dependabot: Allow updating dependencies
Allow crate updates on weekly basis.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2021-09-06 10:03:28 +02:00
Viresh Kumar
f0af5f7fc2 backend: Set rev for virtio-queue
The builds are failing since the remote branch's name is changed to
main from master. Fix it by adding the rev for virtio-queue.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2021-09-03 21:24:22 +08:00
dependabot[bot]
5dde7f196b Bump rust-vmm-ci from 8901e77 to 1311bfa
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `8901e77` to `1311bfa`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](8901e77522...1311bfa03f)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-02 08:50:08 +02:00
Laura Loghin
f57859ea3d
Merge pull request #29 from lauralt/update_ci
rust-vmm-ci update
2021-08-31 11:02:38 +03:00
Laura Loghin
f92701d411 remove coverage_config.json
Signed-off-by: Laura Loghin <lauralg@amazon.com>
2021-08-30 16:00:08 +03:00
dependabot[bot]
156c3a480d Bump rust-vmm-ci from d2ab3c0 to 8901e77
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `d2ab3c0` to `8901e77`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](d2ab3c0908...8901e77522)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-30 15:56:40 +03:00
Sergio Lopez
77bc4174bc
Merge pull request #23 from jiangliu/refactor
Refactor
2021-08-30 14:53:58 +02:00
Liu Jiang
6d04368c46 backend: set default type for VhostUserBackend
Use () as default type for trait VhostUserBackend and
VhostUserBackendMut.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-08-30 17:52:22 +08:00
Liu Jiang
6b685925a1 Add more unit test cases
Add more unit test cases to improve code coverage.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-08-30 17:52:22 +08:00
Liu Jiang
f6b7e49e3f handler: send exit event when destructing
VhostUserHandler waits for all working thread to exit in drop(), but
there's no mechanism to notify the working threads to exit. So add
VhostUserHandler::send_exit_event() to notify working threads to exit.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-08-30 17:52:22 +08:00
Liu Jiang
5dc56732f8 Support guest memory dirty page tracking
Add a generic type parameter `B: Bitmap` to several key structs to
support guest memory dirty page tracking.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-08-30 17:52:21 +08:00
Liu Jiang
ca2b434900 Implement Display for Error
Implement Display for Error, and minor documentation enhancement.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-08-30 17:52:21 +08:00
Liu Jiang
71db23c184 vring: introduce generic parameter type M
Introduce genric type parameter type `M: GuestAddressSpace` for Vring
and VringState.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-08-30 17:52:21 +08:00
Liu Jiang
18db4634f6 vring: formalize Vring interfaces
Move struct Vring to dedicated file vring.rs and formalize interfaces
to access `Vring` objects.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-08-30 17:52:21 +08:00
Liu Jiang
27e29d0c36 Refine documentation and remove unused code
Refine documentation and remove unused code.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-08-30 17:52:21 +08:00
Liu Jiang
bf86c747a7 Refactor VringWorker as VringEpollHandler
Refactor VringWorker as VringEpollHandler and move to event_loop.rs.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-08-30 17:52:21 +08:00
Liu Jiang
e068e3311e Move VhostUserHandler to handler.rs
Move VhostUserHandler to handler.rs to ease maintenance.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-08-30 17:52:21 +08:00
Liu Jiang
cecd4ba565 Refine VhostUserBackend for multi-threading
Refine VhostUserBackend to support interior mutability to better
support multi-threading. The previous version of VhostUserBackend
has been renamed as VhostUserBackendMut, with an implementatio of
    impl<T: VhostUserBackendMut> VhostUserBackend for RwLock<T> {
    }
to ease transition.

The change also improves code readability.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-08-30 17:52:21 +08:00
Liu Jiang
a001824c19 Move trait VhostUserBackend to dedicated file
Move the VhostUserBackend trait to a dedicated file, preparing for
coming changes.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-08-30 17:52:21 +08:00
Liu Jiang
e22aed6d5a Update denpendent crates to latest versions
Update dependent crates to the latest versions:
- vhost v0.1
- vm-memory v0.6
- vmm-sys-util v0.8

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-08-30 17:39:40 +08:00
Jiang Liu
89fa48e000
Merge pull request #28 from stefano-garzarella/codeowners
CODEOWNERS: add stefano-garzarella
2021-08-30 17:33:47 +08:00
Stefano Garzarella
dc2c47d05d CODEOWNERS: add stefano-garzarella
Add myself to CODEOWNERS to help with reviews and maintaining
this code.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2021-08-27 14:00:53 +02:00
Sergio Lopez
1a45bc29d2
Merge pull request #15 from rust-vmm/dependabot/submodules/rust-vmm-ci-d2ab3c0
Bump rust-vmm-ci from `6591890` to `d2ab3c0`
2021-07-20 17:50:25 +02:00
Sergio Lopez
c86ddc01c4
Merge pull request #16 from Gaelan/unbreak
Minimally fix breakage from upstream changes.
2021-07-05 11:11:26 +02:00
Gaelan Steele
2db5f82812 Minimally implement {get,set}_inflight_fd.
This implementation just returns Err(InvalidOperation), which is the
correct response for a backend that hasn't negotiated the inflight
feature. Eventually, it'd be nice if we allowed the backend to
negotiate this feature; harshanavkis@8b44378 and slp@3346318 are two
attempts at this.

This is intended as a simple, bikeshed-free way to get things compiling
again while we decide on, and implement, a way to actually support the
inflight feature.

Signed-off-by: Gaelan Steele <gbs@canishe.com>
2021-06-28 03:19:22 -07:00
Gaelan Steele
b109e4d010 Remove extranous calls to libc::close.
We were explicitly calling libc::close() on fds we were replacing; but
since they were stored as EventFds, which close themselves on drop, this
is unnecessary. Manually closing them is useless at best; at worse, if
there's a race condition and another thread opens an fd between the
manual close and the normal close on drop, we could have closed someone
else's fd.
2021-06-28 03:19:22 -07:00
Gaelan Steele
5b8655cfe3 Update VhostUserSlaveReqHandlerMut impl to take Files, not RawFds.
The new signatures come from an update to the vhost crate.

This commit is intended as a simple, bikeshed-free fix, but I don't
think it's the best way to handle this long-term. See below.

In most cases, we were converting the RawFd into a File anyway, and
the new code is trivial. In a few cases, though, we actually want an
EventFd, which now requires this nasty construction:

unsafe { EventFd::from_raw_fd(file.into_raw_fd())

This is safe--EventFd::from_raw_fd is unsafe becuase it expects to
uniquely own its fd, an invariant File also has--but a little
inelegant.

Ideally, we would either:
- change vmm-sys-util to provide a way to safely create an EventFd
  from a File (this would be trivial; EventFd actually stores its
  fd as a File internally),
- pass around a generic "uniquely owned fd" struct (like that
  proposed by Rust RFC #3128) instead of a File, or
- change vhost to pass us an EventFd instead of a File where
  appropriate (which, in practice, would mean implementing one of the
  previous options in vhost)

Signed-off-by: Gaelan Steele <gbs@canishe.com>
2021-06-28 03:19:22 -07:00
Gaelan Steele
5f82c6b9be Rename vm-virtio to virtio-queue.
The former was split into multiple crates; everything we use is in
virtio-queue.

Signed-off-by: Gaelan Steele <gbs@canishe.com>
2021-06-27 19:50:40 -07:00
dependabot[bot]
51e2cacc3a
Bump rust-vmm-ci from 6591890 to d2ab3c0
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `6591890` to `d2ab3c0`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](6591890ee1...d2ab3c0908)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-23 01:09:30 +00:00
Sergio Lopez
c87e3545e1
Merge pull request #13 from rust-vmm/dependabot/submodules/rust-vmm-ci-6591890
Bump rust-vmm-ci from `24d66cd` to `6591890`
2021-06-17 12:00:34 +02:00
dependabot[bot]
c9f591f393
Bump rust-vmm-ci from 24d66cd to 6591890
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `24d66cd` to `6591890`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](24d66cdae6...6591890ee1)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-15 07:04:29 +00:00
Sergio Lopez
ddc7dd5e9e
Merge pull request #12 from Gaelan/gitignore
Add gitignore file.
2021-05-20 06:53:04 +02:00
Gaelan Steele
815858f135 Add gitignore 2021-05-19 19:36:43 -07:00
dependabot-preview[bot]
06214fc9cc Upgrade to GitHub-native Dependabot 2021-05-11 11:09:00 +03:00
dependabot-preview[bot]
c2757c2861 Bump rust-vmm-ci from ebc7016 to 24d66cd
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `ebc7016` to `24d66cd`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](ebc701641f...24d66cdae6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-16 08:35:49 +00:00
Jiang Liu
ccf16b7c94
Merge pull request #9 from obviyus/enable-ci
Fixes to enable CI
2021-03-15 16:48:50 +08:00
Ayaan Zaidi
b362c785c1 Fix build on aarch64+musl 2021-03-14 09:59:41 +05:30
Ayaan Zaidi
4f31df77bd Add default coverage config for x86_64 2021-03-14 09:59:41 +05:30
Sergio Lopez
2616b68203
Merge pull request #8 from sboeuf/add_mem_reg_vhost_user
vhost_user: Add support for VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS
2021-03-12 14:47:16 +01:00
Sebastien Boeuf
cebfa3cd78 lib: Implement VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS
Relying on latest vhost version, this commit implements
VHOST_USER_GET_MAX_MEM_SLOTS, VHOST_USER_ADD_MEM_REG and
VHOST_USER_REM_MEM_REG commands from the protocol feature
VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS.

VHOST_USER_GET_MAX_MEM_SLOTS provides the maximum amount of memory
slots that can be supported by the vhost-user backend.

VHOST_USER_ADD_MEM_REG lets the frontend provide a new memory region
that must be mapped by the backend.

VHOST_USER_REM_MEM_REG lets the frontend request for the removal of an
existing memory region that must be unmapped by the backend.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-03-12 11:33:57 +01:00
Sebastien Boeuf
cf306dfed9 lib: Simplify the list of mappings
There's no reason to hide the list of mappings behind a structure. We
can instead store the list directly in VhostUserHandler structure.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-03-12 11:33:57 +01:00