[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [RFC 4/6] capabilities: introduce console io as a domain capability
On 8/8/23 11:24, Jan Beulich wrote: On 01.08.2023 22:20, Daniel P. Smith wrote:--- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -472,8 +472,8 @@ struct domain #define ROLE_HARDWARE_DOMAIN (1U<<2) #define ROLE_XENSTORE_DOMAIN (1U<<3) uint8_t role; - /* Can this guest access the Xen console? */ - bool is_console; +#define CAP_CONSOLE_IO (1U<<0) + uint8_t capabilities; /* Is this guest being debugged by dom0? */ bool debugger_attached; /* @@ -1146,6 +1146,27 @@ static always_inline bool is_hvm_vcpu(const struct vcpu *v) return is_hvm_domain(v->domain); }+static always_inline bool domain_has_cap(+ const struct domain *d, uint8_t cap) +{ + return d->capabilities & cap; +}What you implement here is effectively domain_has_any_cap(), which I don't think is of much use. At the very least you want to assert that cap is a power of two. But perhaps you rather want the caller to pass in a bit number, not a mask, such that it's obvious that only one thing can be checked at a time. I did this thinking I was going to save keystrokes and encapsulate the check, but I just double checked and it would have only saved one. I will drop this and put the explicit bit checks at all the check sites. +static always_inline bool domain_set_cap( + struct domain *d, uint8_t cap) +{ + switch ( cap ) + { + case CAP_CONSOLE_IO: + d->capabilities |= cap; + break; + default: + return false; + } + + return domain_has_cap(d, cap); +}The "set" operation doesn't need to be an inline function, does it? I guess not, I can move into common/domain.c. v/r, dps
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |