Hermes 0.7.0
Linux game streaming host
Loading...
Searching...
No Matches
card_broker.cpp File Reference

Client for the privileged Hermes-KMS card broker. More...

#include "card_broker.h"
#include <array>
#include <cerrno>
#include <chrono>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <vector>
#include <fcntl.h>
#include <poll.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/un.h>
#include <unistd.h>
#include "src/logging.h"
#include "src/utility.h"
Include dependency graph for card_broker.cpp:

Go to the source code of this file.

Functions

bool VDISPLAY::card_broker::available ()
 Whether a broker socket is there to talk to.
std::optional< card_t > VDISPLAY::card_broker::create (std::optional< uid_t > session_account_uid=std::nullopt)
 Ask for a new card on a private DRM seat.
bool VDISPLAY::card_broker::remove (const std::string &name)
 Remove a card this user created. Removal is a hot-unplug, so a compositor still holding the card sees ENODEV rather than a device disappearing under it.
int VDISPLAY::card_broker::sweep ()
 Remove every card this user still holds, and report how many went.

Detailed Description

Client for the privileged Hermes-KMS card broker.

Definition in file card_broker.cpp.

Function Documentation

◆ available()

bool VDISPLAY::card_broker::available ( )

Whether a broker socket is there to talk to.

False on every host that has not installed and enabled the broker, which is the normal case; callers fall back to the statically configured pool.

Definition at line 225 of file card_broker.cpp.

◆ create()

std::optional< card_t > VDISPLAY::card_broker::create ( std::optional< uid_t > session_account_uid = std::nullopt)

Ask for a new card on a private DRM seat.

The broker picks the session index, because that index is what the driver's udev rules turn into a seat and its seatd instance: two cards sharing one would share a seat. Fails when the caller's uid is not in the broker's allow file, when it already holds as many cards as it may, or when every private seat is in use.

Parameters
session_account_uidWhen set, the card belongs to that uid - a Hermes session account, which the broker verifies - instead of to the caller. An isolated session's compositor runs as hermes-sNN, and the driver's udev rules hand the card's device nodes to its access_uid, so a card made for the host user is one the session could never open.

Definition at line 230 of file card_broker.cpp.

◆ remove()

bool VDISPLAY::card_broker::remove ( const std::string & name)

Remove a card this user created. Removal is a hot-unplug, so a compositor still holding the card sees ENODEV rather than a device disappearing under it.

Definition at line 249 of file card_broker.cpp.

◆ sweep()

int VDISPLAY::card_broker::sweep ( )

Remove every card this user still holds, and report how many went.

Cards outlive the process that asked for one, so a Hermes that died without removing its own would strand a card and its private seat. Sweeping at startup - when this Hermes owns none by definition - is what collects them.

Definition at line 256 of file card_broker.cpp.