Commit graph

113 commits

Author SHA1 Message Date
dependabot[bot]
e10a471c6a Bump rust-vmm-ci from 7931077 to b037be3
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `7931077` to `b037be3`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](7931077cdc...b037be3396)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-01 10:45:50 +02:00
Stefano Garzarella
ec8c220807 Bump virtio-queue from 6013dd9 to 66cda80
Commit 66cda80 ("Update vm-memory requirement from 0.6 to 0.7")
is required to build this crate with vm-memory v0.7

There were API changes since commit 6013dd9, so let's update
code and tests.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2021-10-29 10:29:02 +03:00
dependabot[bot]
fc1ce25e8a Update vm-memory requirement from 0.6 to 0.7
Updates the requirements on [vm-memory](https://github.com/rust-vmm/vm-memory) to permit the latest version.
- [Release notes](https://github.com/rust-vmm/vm-memory/releases)
- [Changelog](https://github.com/rust-vmm/vm-memory/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-vmm/vm-memory/compare/v0.6.0...v0.7.0)

---
updated-dependencies:
- dependency-name: vm-memory
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-29 10:29:02 +03:00
dependabot[bot]
b8dc194926 Bump rust-vmm-ci from 8901e77 to 7931077
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `8901e77` to `7931077`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](8901e77522...7931077cdc)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-18 10:01:20 +03:00
Liu Jiang
6d5fccefc7 epoll: use epoll wrapper from vmm-sys-util
There's a wrapper for epoll from vmm-sys-util, so use the wrapper
instead of the epoll crate directly. It may help to ease dependency
management.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-10-15 21:55:35 +08:00
dependabot[bot]
f22c4af539 Bump rust-vmm-ci from 7f22582 to 68d4dbf
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `7f22582` to `68d4dbf`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](7f22582590...68d4dbf85c)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-11 10:06:07 +03:00
dependabot[bot]
bd6b53348f Bump rust-vmm-ci from f67ef4c to 7f22582
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `f67ef4c` to `7f22582`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](f67ef4c84d...7f22582590)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-28 10:49:19 +03:00
dependabot[bot]
ecfb8467b1 Bump rust-vmm-ci from 1311bfa to f67ef4c
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `1311bfa` to `f67ef4c`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](1311bfa03f...f67ef4c84d)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-24 12:44:32 +02:00
dependabot[bot]
3242b37d32 Update vmm-sys-util requirement from 0.8 to 0.9
Updates the requirements on [vmm-sys-util](https://github.com/rust-vmm/vmm-sys-util) to permit the latest version.
- [Release notes](https://github.com/rust-vmm/vmm-sys-util/releases)
- [Changelog](https://github.com/rust-vmm/vmm-sys-util/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-vmm/vmm-sys-util/compare/v0.8.0...v0.9.0)

---
updated-dependencies:
- dependency-name: vmm-sys-util
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-24 12:01:35 +02:00
Sergio Lopez
17131359eb Reset the Queue on GET_VRING_BASE
According to the vhost-user specs, we should start the vring upon
receiving the first kick, and stop it when we receive GET_VRING_BASE.

Strictly speaking, we should reset the underlying Queue on the first
kick, but it's actually easier to simply do that in GET_VRING_BASE and
be ready in case the guest re-initializes the vring.

Signed-off-by: Sergio Lopez <slp@redhat.com>
2021-09-23 19:43:08 +08:00
Sergio Lopez
4feeb77a20 Register listeners only with both call and kick
The vhost-user protocol doesn't impose an order for the SET_VRING_KICK
and SET_VRING_CALL messages, which implies it's valid to emit the
first before the latter.

With the current code, this means that if the VMM sends SET_VRING_KICK
before SET_VRING_CALL, and the guest has already placed a request into
the vring, we may miss signaling the guest as that request may be
processed before we have an EventFd for "call".

To fix this, delay listener registration until we have an EventFd for
both call and kick, using "VringState::Queue.ready" as an indicator
that the vring has not been initialized yet.

Signed-off-by: Sergio Lopez <slp@redhat.com>
2021-09-23 19:43:08 +08:00
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