ublk-cpp v0.0
Loading...
Searching...
No Matches
ublk::daemon Namespace Reference

High-level API for running a ublk daemon. More...

Classes

struct  Options
 Extra options for daemon::run(). More...

Functions

auto setup (int control_fd, ublksrv_ctrl_dev_info *info) noexcept
 Ensure the device described by info has been created and return its current information.
auto configure (int control_fd, uint32_t dev_id, ublk_params *params) noexcept
 Ensure the device has been configured and return its current configuration in params.
auto start (int control_fd, uint32_t dev_id, int32_t daemon_pid) noexcept
 Start the device, served by this daemon, if possible.
template<IoHandler Handler>
auto run (int control_fd, uint32_t dev_id, Handler &handler, Options options) noexcept
 Run the daemon serving a device until it stops.
template<ShmHandler Handler>
auto run_shm_server (int control_fd, uint32_t dev_id, std::string_view path, Handler &handler, uint32_t flags) noexcept
 Run the shared memory buffer registration service over a Unix domain socket (UBLK_F_SHMEM_ZC).

Detailed Description

High-level API for running a ublk daemon.

Function Documentation

◆ configure()

auto ublk::daemon::configure ( int control_fd,
uint32_t dev_id,
ublk_params * params )
inlinenoexcept

Ensure the device has been configured and return its current configuration in params.

Parameters
control_fdThe control file descriptor for the ublk device.
dev_idThe device ID of the ublk device.
paramsConfiguration to apply when the device is not yet configured; on success it is written back with the device's effective parameters.
Returns
sender bool (true if params were applied, false if the device was already configured) on success; std::exception_ptr on failure.

Definition at line 42 of file daemon.hpp.

◆ run()

template<IoHandler Handler>
auto ublk::daemon::run ( int control_fd,
uint32_t dev_id,
Handler & handler,
Options options )
inlinenoexcept

Run the daemon serving a device until it stops.

Parameters
control_fdThe control file descriptor for the ublk device.
dev_idThe device ID of the ublk device.
handlerThe IoHandler used to process requests of all queues.
optionsRuntime options of the per-queue io_uring loops.
Returns
sender () on success, std::exception_ptr on failure.

Definition at line 82 of file daemon.hpp.

◆ run_shm_server()

template<ShmHandler Handler>
auto ublk::daemon::run_shm_server ( int control_fd,
uint32_t dev_id,
std::string_view path,
Handler & handler,
uint32_t flags )
inlinenoexcept

Run the shared memory buffer registration service over a Unix domain socket (UBLK_F_SHMEM_ZC).

Parameters
control_fdThe control file descriptor for the ublk device.
dev_idThe device ID of the ublk device.
pathThe Unix domain socket path to listen on.
handlerThe ShmHandler notified of buffer registration and unregistration.
flagsFlags of the registered buffers (UBLK_SHMEM_BUF_*), e.g. UBLK_SHMEM_BUF_READ_ONLY.
Returns
sender () on success, std::exception_ptr on failure.

Definition at line 102 of file daemon.hpp.

◆ setup()

auto ublk::daemon::setup ( int control_fd,
ublksrv_ctrl_dev_info * info )
inlinenoexcept

Ensure the device described by info has been created and return its current information.

Parameters
control_fdThe control file descriptor for the ublk device.
infoDevice info of the device to ensure exists. If the device already exists, it is updated with the current information.
Returns
sender bool (true if the device was newly created, false if it already existed) on success; std::exception_ptr on failure.

Definition at line 27 of file daemon.hpp.

◆ start()

auto ublk::daemon::start ( int control_fd,
uint32_t dev_id,
int32_t daemon_pid )
inlinenoexcept

Start the device, served by this daemon, if possible.

Parameters
control_fdThe control file descriptor for the ublk device.
dev_idThe device ID of the ublk device.
daemon_pidThe PID of the daemon process serving the device.
Returns
sender () on success, std::exception_ptr on failure.

Definition at line 55 of file daemon.hpp.