QAPI patches patches for 2021-10-29

-----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEENUvIs9frKmtoZ05fOHC0AOuRhlMFAmF8S3USHGFybWJydUBy
 ZWRoYXQuY29tAAoJEDhwtADrkYZTkfQP/34UaR77wfOvemMBCY7CX/AD6KsJTt2v
 /mVJ8kUC+aJdyDa1orhDxLxyvx0YxSUjDUoTVGrb/CO8eM8dL4Lz6jCi1OiBCaBq
 JJAtUduaLDUUfZnKwrvhW0cGZeJ02eqxIKhV/9BFcFSr0fAzZRnF1RwsNBO/AqCr
 082bimWttsBpnNqnbWFK8uZYHMskbPOoXxklIMDM48BJhb6EOdH1/wZpeGdTUMIN
 zBTOynZW52xrDdlngo3UBr+uyDX8mjnwMOmpSa5YgkQselxDK172xZm31VQUMtGz
 S2qNCxxKf4J/wJMLElo0z3nEUUEFrpZzqifO1gsDit4eWexL35BHCdlRbB07iJ/+
 V0wtF2M+KQGhoqLJTvlVlymRAeC3ItHHDgh9qs3nS7w9w13oGuB7xo8Po5PfKpc3
 vT2XBYy8LPHLQ7/82nQGQdXkd1OB/8fwJt0bcPc+UIGAhNrwpSmCoO0ugqU2OD+C
 NJs6R3y1bbJnQGG5f3M/QU/dF0zYVpHv6a+QWFwwV+rc2RAjeeMrSYH+08t1c5+u
 Qh2P8YvgRPQxPmg9Rbqfcxq7CwVs0iZINfjmLwofbqBQUZUAq3phHRtJ9bmGbXkC
 pC4B+d76kefSxqlVNwi95Zg+CCURT8QzamKVlkZ/GNP73+orV9yQvA0aR4J2arLV
 1QVm4jTqAqIo
 =HKnl
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-10-29' into staging

QAPI patches patches for 2021-10-29

# gpg: Signature made Fri 29 Oct 2021 12:28:53 PM PDT
# gpg:                using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
# gpg:                issuer "armbru@redhat.com"
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full]
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>" [full]

* remotes/armbru/tags/pull-qapi-2021-10-29:
  qapi: Extend -compat to set policy for unstable interfaces
  qapi: Factor out compat_policy_input_ok()
  qapi: Generalize enum member policy checking
  qapi: Generalize command policy checking
  qapi: Generalize struct member policy checking
  qapi: Tools for sets of special feature flags in generated code
  qapi: Eliminate QCO_NO_OPTIONS for a slight simplification
  qapi: Mark unstable QMP parts with feature 'unstable'
  qapi: New special feature flag "unstable"

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2021-10-29 19:42:36 -07:00
commit dd61b91c08
30 changed files with 355 additions and 166 deletions

View file

@ -13,10 +13,17 @@
#ifndef QAPI_COMPAT_POLICY_H
#define QAPI_COMPAT_POLICY_H
#include "qapi/error.h"
#include "qapi/qapi-types-compat.h"
extern CompatPolicy compat_policy;
bool compat_policy_input_ok(unsigned special_features,
const CompatPolicy *policy,
ErrorClass error_class,
const char *kind, const char *name,
Error **errp);
/*
* Create a QObject input visitor for @obj for use with QMP
*

View file

@ -21,12 +21,10 @@ typedef void (QmpCommandFunc)(QDict *, QObject **, Error **);
typedef enum QmpCommandOptions
{
QCO_NO_OPTIONS = 0x0,
QCO_NO_SUCCESS_RESP = (1U << 0),
QCO_ALLOW_OOB = (1U << 1),
QCO_ALLOW_PRECONFIG = (1U << 2),
QCO_COROUTINE = (1U << 3),
QCO_DEPRECATED = (1U << 4),
} QmpCommandOptions;
typedef struct QmpCommand
@ -35,6 +33,7 @@ typedef struct QmpCommand
/* Runs in coroutine context if QCO_COROUTINE is set */
QmpCommandFunc *fn;
QmpCommandOptions options;
unsigned special_features;
QTAILQ_ENTRY(QmpCommand) node;
bool enabled;
const char *disable_reason;
@ -43,7 +42,8 @@ typedef struct QmpCommand
typedef QTAILQ_HEAD(QmpCommandList, QmpCommand) QmpCommandList;
void qmp_register_command(QmpCommandList *cmds, const char *name,
QmpCommandFunc *fn, QmpCommandOptions options);
QmpCommandFunc *fn, QmpCommandOptions options,
unsigned special_features);
const QmpCommand *qmp_find_command(const QmpCommandList *cmds,
const char *name);
void qmp_disable_command(QmpCommandList *cmds, const char *name,

View file

@ -11,12 +11,14 @@
#ifndef QAPI_UTIL_H
#define QAPI_UTIL_H
/* QEnumLookup flags */
#define QAPI_ENUM_DEPRECATED 1
typedef enum {
QAPI_DEPRECATED,
QAPI_UNSTABLE,
} QapiSpecialFeature;
typedef struct QEnumLookup {
const char *const *array;
const unsigned char *const flags;
const unsigned char *const special_features;
const int size;
} QEnumLookup;

View file

@ -114,10 +114,12 @@ struct Visitor
void (*optional)(Visitor *v, const char *name, bool *present);
/* Optional */
bool (*deprecated_accept)(Visitor *v, const char *name, Error **errp);
bool (*policy_reject)(Visitor *v, const char *name,
unsigned special_features, Error **errp);
/* Optional */
bool (*deprecated)(Visitor *v, const char *name);
bool (*policy_skip)(Visitor *v, const char *name,
unsigned special_features);
/* Must be set */
VisitorType type;

View file

@ -461,22 +461,31 @@ void visit_end_alternate(Visitor *v, void **obj);
bool visit_optional(Visitor *v, const char *name, bool *present);
/*
* Should we reject deprecated member @name?
* Should we reject member @name due to policy?
*
* @special_features is the member's special features encoded as a
* bitset of QapiSpecialFeature.
*
* @name must not be NULL. This function is only useful between
* visit_start_struct() and visit_end_struct(), since only objects
* have deprecated members.
*/
bool visit_deprecated_accept(Visitor *v, const char *name, Error **errp);
bool visit_policy_reject(Visitor *v, const char *name,
unsigned special_features, Error **errp);
/*
* Should we visit deprecated member @name?
*
* Should we skip member @name due to policy?
*
* @special_features is the member's special features encoded as a
* bitset of QapiSpecialFeature.
*
* @name must not be NULL. This function is only useful between
* visit_start_struct() and visit_end_struct(), since only objects
* have deprecated members.
*/
bool visit_deprecated(Visitor *v, const char *name);
bool visit_policy_skip(Visitor *v, const char *name,
unsigned special_features);
/*
* Set policy for handling deprecated management interfaces.