Re: [PATCH 2/2] nbd/server: Allow users to adjust handshake limit in QMP

2024-10-02 Thread Markus Armbruster
Vladimir Sementsov-Ogievskiy  writes:

> On 02.10.24 16:49, Markus Armbruster wrote:
>> Eric Blake  writes:
>> 
>>> Although defaulting the handshake limit to 10 seconds was a nice QoI
>>> change to weed out intentionally slow clients, it can interfere with
>>> integration testing done with manual NBD_OPT commands over 'nbdsh
>>> --opt-mode'.  Expose a QMP knob 'handshake-max-secs' to allow the user
>>> to alter the timeout away from the default.
>>>
>>> The parameter name here intentionally matches the spelling of the
>>> constant added in commit fb1c2aaa98, and not the command-line spelling
>>> added in the previous patch for qemu-nbd; that's because in QMP,
>>> longer names serve as good self-documentation, and unlike the command
>>> line, machines don't have problems generating longer spellings.
>>>
>>> Signed-off-by: Eric Blake 

[...]

>> Are we confident we'll never need less than a full second?
>
> Hmm, recent "[PATCH v2] chardev: introduce 'reconnect-ms' and deprecate 
> 'reconnect'" shows that at least sometimes second is not enough precision.
>
> Maybe, using milliseconds consistently for all relatively short time 
> intervals in QAPI would be a good rule?

Ideally, we'd use a single unit for time: nanoseconds.  But we missed
that chance long ago, and now are stuck with a mix of seconds,
milliseconds, microseconds, and nanoseconds.

I think a good rule is to pick the first from this list that will surely
provide all the precision we'll ever need.

In this case, milliseconds should do.




Re: [PATCH 2/2] nbd/server: Allow users to adjust handshake limit in QMP

2024-10-02 Thread Markus Armbruster
Eric Blake  writes:

> Although defaulting the handshake limit to 10 seconds was a nice QoI
> change to weed out intentionally slow clients, it can interfere with
> integration testing done with manual NBD_OPT commands over 'nbdsh
> --opt-mode'.  Expose a QMP knob 'handshake-max-secs' to allow the user
> to alter the timeout away from the default.
>
> The parameter name here intentionally matches the spelling of the
> constant added in commit fb1c2aaa98, and not the command-line spelling
> added in the previous patch for qemu-nbd; that's because in QMP,
> longer names serve as good self-documentation, and unlike the command
> line, machines don't have problems generating longer spellings.
>
> Signed-off-by: Eric Blake 
> ---
>  qapi/block-export.json | 10 ++
>  include/block/nbd.h|  6 +++---
>  block/monitor/block-hmp-cmds.c |  4 ++--
>  blockdev-nbd.c | 26 ++
>  4 files changed, 33 insertions(+), 13 deletions(-)
>
> diff --git a/qapi/block-export.json b/qapi/block-export.json
> index ce33fe378df..c110dd375ad 100644
> --- a/qapi/block-export.json
> +++ b/qapi/block-export.json
> @@ -17,6 +17,10 @@
>  #
>  # @addr: Address on which to listen.
>  #
> +# @handshake-max-secs: Time limit, in seconds, at which a client that
> +# has not completed the negotiation handshake will be disconnected,
> +# or 0 for no limit (since 9.2; default: 10).
> +#
>  # @tls-creds: ID of the TLS credentials object (since 2.6).
>  #
>  # @tls-authz: ID of the QAuthZ authorization object used to validate
> @@ -34,6 +38,7 @@
>  ##
>  { 'struct': 'NbdServerOptions',
>'data': { 'addr': 'SocketAddress',
> +'*handshake-max-secs': 'uint32',
>  '*tls-creds': 'str',
>  '*tls-authz': 'str',
>  '*max-connections': 'uint32' } }
> @@ -52,6 +57,10 @@
>  #
>  # @addr: Address on which to listen.
>  #
> +# @handshake-max-secs: Time limit, in seconds, at which a client that
> +# has not completed the negotiation handshake will be disconnected,
> +# or 0 for no limit (since 9.2; default: 10).
> +#
>  # @tls-creds: ID of the TLS credentials object (since 2.6).
>  #
>  # @tls-authz: ID of the QAuthZ authorization object used to validate
> @@ -72,6 +81,7 @@
>  ##
>  { 'command': 'nbd-server-start',
>'data': { 'addr': 'SocketAddressLegacy',
> +'*handshake-max-secs': 'uint32',
>  '*tls-creds': 'str',
>  '*tls-authz': 'str',
>  '*max-connections': 'uint32' },

Are we confident we'll never need less than a full second?

[...]




Re: [PATCH v3 21/22] qom/object: fix -Werror=maybe-uninitialized

2024-10-02 Thread Markus Armbruster
Marc-André Lureau  writes:

> Hi
>
> On Wed, Oct 2, 2024 at 10:21 AM Markus Armbruster  wrote:

[...]

>> Two ways to fix:
>>
>> 1. Find all callers that don't, and fix them.  Your first hunk is then
>>superfluous.  Your second hunk fixes the one you already found.
>>
>
> Imho, that's not a good API, it's easy to get wrong.
>
>> 2. Change the contract so callers don't have to initialize.  Your second
>>hunk is then superfluous.  The update to the contract is missing.
>>
>
> I prefer that it always set the variable. I also prefer that caller
> initializes variables. So all are good practices imho, even if it's a
> bit redundant.

Since you're doing the work to fix the bug, you get first dibs on how to
fix it :)

[...]




Re: [PATCH v3 21/22] qom/object: fix -Werror=maybe-uninitialized

2024-10-01 Thread Markus Armbruster
marcandre.lur...@redhat.com writes:

> From: Marc-André Lureau 
>
> object_resolve_path_type() didn't always set *ambiguousp.
>
> Signed-off-by: Marc-André Lureau 

Fixes: 81c48dd79655 (hw/i386/acpi: Add object_resolve_type_unambiguous to 
improve modularity)

> ---
>  qom/object.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/qom/object.c b/qom/object.c
> index 28c5b66eab..bdc8a2c666 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -2201,6 +2201,9 @@ Object *object_resolve_path_type(const char *path, 
> const char *typename,
>  }
>  } else {
>  obj = object_resolve_abs_path(object_get_root(), parts + 1, 
> typename);
> +if (ambiguousp) {
> +*ambiguousp = false;
> +}
>  }
>  
>  g_strfreev(parts);
> @@ -2226,7 +2229,7 @@ Object *object_resolve_path_at(Object *parent, const 
> char *path)
>  
>  Object *object_resolve_type_unambiguous(const char *typename, Error **errp)
>  {
> -bool ambig;
> +bool ambig = false;
>  Object *o = object_resolve_path_type("", typename, &ambig);
>  
>  if (ambig) {

Contract:

   /**
* object_resolve_path_type:
* @path: the path to resolve
* @typename: the type to look for.
* @ambiguous: returns true if the path resolution failed because of an
*   ambiguous match
*
* This is similar to object_resolve_path.  However, when looking for a
* partial path only matches that implement the given type are considered.
* This restricts the search and avoids spuriously flagging matches as
* ambiguous.
*
* For both partial and absolute paths, the return value goes through
* a dynamic cast to @typename.  This is important if either the link,
* or the typename itself are of interface types.
*
* Returns: The matched object or NULL on path lookup failure.
*/

Note the parameter is called @ambiguous here, but @ambiguousp in the
definition.  Bad practice.

All the contract promises is that true will be stored in the variable
passed to @ambiguous when the function fails in a certain way.  For that
to work, the variable must be initialized to false.

You found a caller that doesn't: object_resolve_type_unambiguous().
This is a bug.  There might be more.  Impact is not obvious.

Two ways to fix:

1. Find all callers that don't, and fix them.  Your first hunk is then
   superfluous.  Your second hunk fixes the one you already found.

2. Change the contract so callers don't have to initialize.  Your second
   hunk is then superfluous.  The update to the contract is missing.

While there: the contract fails to specify that @ambiguous may be null.
Needs fixing, too.

Same for object_resolve_path().




Re: [PATCH v2] docs: Mark "gluster" support in QEMU as deprecated

2024-09-30 Thread Markus Armbruster
Daniel P. Berrangé  writes:

> On Wed, Sep 25, 2024 at 09:15:14AM +0200, Thomas Huth wrote:
>> According to https://marc.info/?l=fedora-devel-list&m=171934833215726
>> the GlusterFS development effectively ended. Thus mark it as deprecated
>> in QEMU, so we can remove it in a future release if the project does
>> not gain momentum again.
>> 
>> Acked-by: Niels de Vos 
>> Signed-off-by: Thomas Huth 
>> ---
>>  v2: Mark it as deprecated in the QAPI and print a warning once, too
>> 
>>  docs/about/deprecated.rst | 9 +
>>  qapi/block-core.json  | 7 ++-
>>  block/gluster.c   | 2 ++
>>  3 files changed, 17 insertions(+), 1 deletion(-)
>> 
>> diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
>> index ed31d4b0b2..b231aa3948 100644
>> --- a/docs/about/deprecated.rst
>> +++ b/docs/about/deprecated.rst
>> @@ -395,6 +395,15 @@ Specifying the iSCSI password in plain text on the 
>> command line using the
>>  used instead, to refer to a ``--object secret...`` instance that provides
>>  a password via a file, or encrypted.
>>  
>> +``gluster`` backend (since 9.2)
>> +^^^
>> +
>> +According to https://marc.info/?l=fedora-devel-list&m=171934833215726
>> +the GlusterFS development effectively ended. Unless the development
>> +gains momentum again, the QEMU project might remove the gluster backend
>> +in a future release.
>
> I'd suggest the second half of the sentance can be simplified:
>
>", the QEMU project will remove the gluster backend/"
>
> since marking something as deprecated is a stronger than "might".
> We /will/ remove it, unless new informaton comes to light that
> makes us re-evaluate the plans.

Good point.




Re: [PATCH v2] docs: Mark "gluster" support in QEMU as deprecated

2024-09-27 Thread Markus Armbruster
Thomas Huth  writes:

> According to https://marc.info/?l=fedora-devel-list&m=171934833215726
> the GlusterFS development effectively ended. Thus mark it as deprecated
> in QEMU, so we can remove it in a future release if the project does
> not gain momentum again.
>
> Acked-by: Niels de Vos 
> Signed-off-by: Thomas Huth 
> ---
>  v2: Mark it as deprecated in the QAPI and print a warning once, too
>
>  docs/about/deprecated.rst | 9 +
>  qapi/block-core.json  | 7 ++-
>  block/gluster.c   | 2 ++
>  3 files changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
> index ed31d4b0b2..b231aa3948 100644
> --- a/docs/about/deprecated.rst
> +++ b/docs/about/deprecated.rst
> @@ -395,6 +395,15 @@ Specifying the iSCSI password in plain text on the 
> command line using the
>  used instead, to refer to a ``--object secret...`` instance that provides
>  a password via a file, or encrypted.
>  
> +``gluster`` backend (since 9.2)
> +^^^
> +
> +According to https://marc.info/?l=fedora-devel-list&m=171934833215726
> +the GlusterFS development effectively ended. Unless the development
> +gains momentum again, the QEMU project might remove the gluster backend
> +in a future release.
> +
> +
>  Character device options
>  ''''''''''''''''''''''''
>  
> diff --git a/qapi/block-core.json b/qapi/block-core.json
> index 9f6dd59298..cb7cb1c0ed 100644
> --- a/qapi/block-core.json
> +++ b/qapi/block-core.json
> @@ -3187,12 +3187,17 @@
>  #
>  # @snapshot-access: Since 7.0
>  #
> +# Features:
> +#
> +# @deprecated: Member @gluster is deprecated since GlusterFS ceased 
> development

End the sentence with full stop, and wrap the line.  Suggest:

   # @deprecated: Member @gluster is deprecated because GlusterFS
   # development ceased.

> +#
>  # Since: 2.9
>  ##
>  { 'enum': 'BlockdevDriver',
>'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs',
>  'cloop', 'compress', 'copy-before-write', 'copy-on-read', 'dmg',
> -'file', 'snapshot-access', 'ftp', 'ftps', 'gluster',
> +'file', 'snapshot-access', 'ftp', 'ftps',
> +{'name': 'gluster', 'features': [ 'deprecated' ] },
>  {'name': 'host_cdrom', 'if': 'HAVE_HOST_BLOCK_DEVICE' },
>  {'name': 'host_device', 'if': 'HAVE_HOST_BLOCK_DEVICE' },
>  'http', 'https',

I wonder why it's not 'if': 'CONFIG_GLUSTERFS'.  Probably not worth
exploring now.

With the doc comment tidied up:
Acked-by: Markus Armbruster 

[...]




Re: [PATCH 1/2] hw/sd: Remove legacy sd_set_cb()

2024-09-13 Thread Markus Armbruster
Peter Maydell  writes:

> On Fri, 13 Sept 2024 at 09:28, Markus Armbruster  wrote:
>>
>> Peter Maydell  writes:
>>
>> > On Tue, 3 Sept 2024 at 21:04, Philippe Mathieu-Daudé  
>> > wrote:
>> >>
>> >> sd_set_cb() was only used by omap2_mmc_init() which
>> >> got recently removed. Time to remove it. For historical
>> >> background on the me_no_qdev_me_kill_mammoth_with_rocks
>> >> kludge, see commit 007d1dbf72 ("sd: Hide the qdev-but-not-quite
>> >> thing created by sd_init()").
>> >>
>> >> Signed-off-by: Philippe Mathieu-Daudé 

[...]

>> > Should we also remove the sd_init() function in this patch
>> > (or patchset)? It was only used by the omap-mmc, and it's
>> > because we have no uses of it that we can get rid of this kludge.
>>
>> sd_init() is a legacy initialization function for use by non-qdevified
>> callers.  I'd *love* to finally get rid of it.  However, there seems to
>> be a use left in tree even after "[PATCH for-9.2 00/53] arm: Drop
>> deprecated boards": omap_mmc_init(), used by sx1_init() via via
>> omap310_mpu_init().  This is machines sx1 and sx1-v1.
>
> Ah, I hadn't noticed that. I'll have a re-read of this
> patch based on that knowledge...
>
>> Ignorant question: can we deprecate these?
>
> We put them up as candidates when we were deprecating the
> rest of this, but the feedback was that kernel developers
> were still using sx1:
> https://lore.kernel.org/qemu-devel/20240214012749.ga203...@darkstar.musicnaut.iki.fi/
>
> It is indeed a bit of a pity from our end that we couldn't
> drop all of the OMAP code entirely. We might get another
> chance after the next round of kernel machine type culling
> if they drop armv4t.
>
> Once my patchset to drop all these Arm machines has got
> code review and gets into git we can reassess what we
> still have and look at modernising the stuff we've kept.

Makes sense.  Thanks!




Re: [PATCH 1/2] hw/sd: Remove legacy sd_set_cb()

2024-09-13 Thread Markus Armbruster
Peter Maydell  writes:

> On Tue, 3 Sept 2024 at 21:04, Philippe Mathieu-Daudé  
> wrote:
>>
>> sd_set_cb() was only used by omap2_mmc_init() which
>> got recently removed. Time to remove it. For historical
>> background on the me_no_qdev_me_kill_mammoth_with_rocks
>> kludge, see commit 007d1dbf72 ("sd: Hide the qdev-but-not-quite
>> thing created by sd_init()").
>>
>> Signed-off-by: Philippe Mathieu-Daudé 
>> ---
>>  include/hw/sd/sdcard_legacy.h |  1 -
>>  hw/sd/sd.c| 30 --
>>  2 files changed, 4 insertions(+), 27 deletions(-)
>>
>> diff --git a/include/hw/sd/sdcard_legacy.h b/include/hw/sd/sdcard_legacy.h
>> index 0dc3889555..a121232560 100644
>> --- a/include/hw/sd/sdcard_legacy.h
>> +++ b/include/hw/sd/sdcard_legacy.h
>> @@ -36,7 +36,6 @@ SDState *sd_init(BlockBackend *blk, bool is_spi);
>>  int sd_do_command(SDState *card, SDRequest *request, uint8_t *response);
>>  void sd_write_byte(SDState *card, uint8_t value);
>>  uint8_t sd_read_byte(SDState *card);
>> -void sd_set_cb(SDState *card, qemu_irq readonly, qemu_irq insert);
>>
>>  /* sd_enable should not be used -- it is only used on the nseries boards,
>>   * where it is part of a broken implementation of the MMC card slot switch
>> diff --git a/hw/sd/sd.c b/hw/sd/sd.c
>> index a140a32ccd..8a30c61ce0 100644
>> --- a/hw/sd/sd.c
>> +++ b/hw/sd/sd.c
>> @@ -112,10 +112,6 @@ typedef struct SDProto {
>>  struct SDState {
>>  DeviceState parent_obj;
>>
>> -/* If true, created by sd_init() for a non-qdevified caller */
>> -/* TODO purge them with fire */
>> -bool me_no_qdev_me_kill_mammoth_with_rocks;
>> -
>
> Should we also remove the sd_init() function in this patch
> (or patchset)? It was only used by the omap-mmc, and it's
> because we have no uses of it that we can get rid of this kludge.

sd_init() is a legacy initialization function for use by non-qdevified
callers.  I'd *love* to finally get rid of it.  However, there seems to
be a use left in tree even after "[PATCH for-9.2 00/53] arm: Drop
deprecated boards": omap_mmc_init(), used by sx1_init() via via
omap310_mpu_init().  This is machines sx1 and sx1-v1.

Ignorant question: can we deprecate these?




Re: [PATCH 0/2] qapi: Remove some error documentation lint

2024-09-13 Thread Markus Armbruster
Queued.




[PATCH 0/2] qapi: Remove some error documentation lint

2024-09-11 Thread Markus Armbruster
Markus Armbruster (2):
  qapi: Drop "with an explanation" from error descriptions
  qapi/block-core: Drop drive-backup's "Any other error" documentation

 qapi/block-core.json | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

-- 
2.46.0




[PATCH 1/2] qapi: Drop "with an explanation" from error descriptions

2024-09-11 Thread Markus Armbruster
All errors come with an explanation, namely the human-readable error
message in the error response's @desc member.  Drop the redundant
"with an explanation" phrase.

Signed-off-by: Markus Armbruster 
---
 qapi/block-core.json | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/qapi/block-core.json b/qapi/block-core.json
index 9f6dd59298..82f59a7758 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -2299,7 +2299,7 @@
 #
 # Errors:
 # - If @node is not a valid block device or node, DeviceNotFound
-# - If @name is already taken, GenericError with an explanation
+# - If @name is already taken, GenericError
 #
 # Since: 2.4
 #
@@ -2322,7 +2322,7 @@
 #
 # Errors:
 # - If @node is not a valid block device or node, DeviceNotFound
-# - If @name is not found, GenericError with an explanation
+# - If @name is not found, GenericError
 # - if @name is frozen by an operation, GenericError
 #
 # Since: 2.4
@@ -2346,7 +2346,7 @@
 #
 # Errors:
 # - If @node is not a valid block device, DeviceNotFound
-# - If @name is not found, GenericError with an explanation
+# - If @name is not found, GenericError
 #
 # Since: 2.4
 #
@@ -2367,7 +2367,7 @@
 #
 # Errors:
 # - If @node is not a valid block device, DeviceNotFound
-# - If @name is not found, GenericError with an explanation
+# - If @name is not found, GenericError
 #
 # Since: 4.0
 #
@@ -2388,7 +2388,7 @@
 #
 # Errors:
 # - If @node is not a valid block device, DeviceNotFound
-# - If @name is not found, GenericError with an explanation
+# - If @name is not found, GenericError
 #
 # Since: 4.0
 #
@@ -2462,7 +2462,6 @@
 # Errors:
 # - If @node is not a valid block device, DeviceNotFound
 # - If @name is not found or if hashing has failed, GenericError
-#   with an explanation
 #
 # Since: 2.10
 ##
-- 
2.46.0




[PATCH 2/2] qapi/block-core: Drop drive-backup's "Any other error" documentation

2024-09-11 Thread Markus Armbruster
We've always been rather lax about documenting errors.  Many "Errors"
sections are obviously not exhaustive.  Only drive-backup is explicit
about this: "Any other error returns a GenericError".

Not useful.  Drop.

Signed-off-by: Markus Armbruster 
---
 qapi/block-core.json | 1 -
 1 file changed, 1 deletion(-)

diff --git a/qapi/block-core.json b/qapi/block-core.json
index 82f59a7758..485388be32 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1853,7 +1853,6 @@
 #
 # Errors:
 # - If @device does not exist, DeviceNotFound
-# - Any other error returns a GenericError.
 #
 # Since: 1.3
 #
-- 
2.46.0




Re: [PATCH v2 01/19] qapi: Smarter camel_to_upper() to reduce need for 'prefix'

2024-09-04 Thread Markus Armbruster
Daniel P. Berrangé  writes:

> On Wed, Sep 04, 2024 at 01:18:18PM +0200, Markus Armbruster wrote:
>> camel_to_upper() converts its argument from camel case to upper case
>> with '_' between words.  Used for generated enumeration constant
>> prefixes.
>
>
>> 
>> Signed-off-by: Markus Armbruster 
>> Reviewed-by: Daniel P. Berrang?? 
>
> The accent in my name is getting mangled in this series.

Uh-oh!

Checking...  Hmm.  It's correct in git, correct in output of
git-format-patch, correct in the copy I got from git-send-email --bcc
armbru via localhost MTA, and the copy I got from --to
qemu-de...@nongnu.org, correct in lore.kernel.org[*], correct in an mbox
downloaded from patchew.

Could the culprit be on your side?

> IIRC your mail client (git send-email ?) needs to be explicitly
> setting a chardset eg
>
>   Content-type: text/plain; charset=utf8
>
> so that mail clients & intermediate servers know how to interpret
> the 8bit data.
>
> With regards,
> Daniel


[*] 
https://lore.kernel.org/qemu-devel/zthqar7mpd0ut...@redhat.com/T/#m4a7625a47ce94c30ca2ae6d94acd2901e0d0d176




[PATCH v2 00/19] qapi: Reduce use of 'prefix'

2024-09-04 Thread Markus Armbruster
QAPI's 'prefix' feature can make the connection between enumeration
type and its constants less than obvious.  It's best used with
restraint.

We use 'prefix' for a number of reasons:

* To override an ugly default.

* To shorten the prefix.

* To work around name clashes.

This series attacks the first two.  It additionally improves a number
of ugly prefixes we don't override.

PATCH 01 improves the default prefix, and drops 'prefix' where it is
now redundant.  The patch adds temporary 'prefix' to not change
generated code.

PATCH 02-08 revert the temporary 'prefix'.

PATCH 10,17 drop 'prefix' where the default is now better.

PATCH 09,11-15,18,19 rename QAPI types, and drop their 'prefix'.  I'm
prepared to adjust the renames according to maintainers' preference.

PATCH 16 renames a non-QAPI type for consistency.

v2:
* PATCH 01: Fix camel_to_upper() to avoid '__' and leading '_'.
* PATCH 01+07: Actually add a 'prefix' to HmatLBMemoryHierarchy in
  PATCH 01, as the commit message advertizes.  Remove it in PATCH 07,
  and adjust the commit message.
* PATCH 09: Keep pragma documentation-exceptions sorted.
* PATCH 04+09+18: Fix commit message typos.
* PATCH 19: New.

Markus Armbruster (19):
  qapi: Smarter camel_to_upper() to reduce need for 'prefix'
  tests/qapi-schema: Drop temporary 'prefix'
  qapi/block-core: Drop temporary 'prefix'
  qapi/common: Drop temporary 'prefix'
  qapi/crypto: Drop temporary 'prefix'
  qapi/ebpf: Drop temporary 'prefix'
  qapi/machine: Drop temporary 'prefix'
  qapi/ui: Drop temporary 'prefix'
  qapi/machine: Rename CpuS390* to S390Cpu*, and drop 'prefix'
  qapi/crypto: Drop unwanted 'prefix'
  qapi/crypto: Rename QCryptoHashAlgorithm to *Algo, and drop prefix
  qapi/crypto: Rename QCryptoCipherAlgorithm to *Algo, and drop prefix
  qapi/crypto: Rename QCryptoIVGenAlgorithm to *Algo, and drop prefix
  qapi/crypto: Rename QCryptoAkCipherAlgorithm to *Algo, and drop prefix
  qapi/crypto: Rename QCryptoRSAPaddingAlgorithm to *Algo, and drop
prefix
  qapi/crypto: Rename QCryptoAFAlg to QCryptoAFAlgo
  qapi/cryptodev: Drop unwanted 'prefix'
  qapi/cryptodev: Rename QCryptodevBackendAlgType to *Algo, and drop
prefix
  qapi/vfio: Rename VfioMigrationState to Qapi*, and drop prefix

 qapi/block-core.json |   4 +-
 qapi/crypto.json |  56 --
 qapi/cryptodev.json  |   7 +-
 qapi/machine-common.json |   5 +-
 qapi/machine-target.json |  11 +-
 qapi/machine.json|   9 +-
 qapi/migration.json  |   1 +
 qapi/pragma.json |   6 +-
 qapi/ui.json |   1 +
 qapi/vfio.json   |   9 +-
 crypto/afalgpriv.h   |  14 +--
 crypto/akcipherpriv.h|   2 +-
 crypto/blockpriv.h   |   6 +-
 crypto/cipherpriv.h  |   2 +-
 crypto/hashpriv.h|   2 +-
 crypto/hmacpriv.h|   4 +-
 crypto/ivgenpriv.h   |   6 +-
 include/crypto/afsplit.h |   8 +-
 include/crypto/block.h   |   2 +-
 include/crypto/cipher.h  |  18 ++--
 include/crypto/hash.h|  18 ++--
 include/crypto/hmac.h|   6 +-
 include/crypto/ivgen.h   |  30 +++---
 include/crypto/pbkdf.h   |  14 +--
 include/hw/qdev-properties-system.h  |   2 +-
 include/hw/s390x/cpu-topology.h  |   2 +-
 include/sysemu/cryptodev.h   |   2 +-
 target/s390x/cpu.h   |   2 +-
 backends/cryptodev-builtin.c |  52 -
 backends/cryptodev-lkcf.c|  36 +++
 backends/cryptodev-vhost-user.c  |   6 +-
 backends/cryptodev.c |  12 +--
 block.c  |   6 +-
 block/crypto.c   |  10 +-
 block/parallels-ext.c|   2 +-
 block/qcow.c |   2 +-
 block/qcow2.c|  10 +-
 block/quorum.c   |   4 +-
 block/rbd.c  |   4 +-
 crypto/afalg.c   |   8 +-
 crypto/afsplit.c |   6 +-
 crypto/akcipher.c|   2 +-
 crypto/block-luks.c  | 128 +++
 crypto/block-qcow.c  |   6 +-
 crypto/block.c   |   8 +-
 crypto/cipher-afalg.c|  36 +++
 crypto/cipher.c  |  72 ++---
 crypto/hash-afalg.c  |  40

[PATCH v2 05/19] qapi/crypto: Drop temporary 'prefix'

2024-09-04 Thread Markus Armbruster
Recent commit "qapi: Smarter camel_to_upper() to reduce need for
'prefix'" added two temporary 'prefix' to delay changing the generated
code.

Revert them.  This improves QCryptoBlockFormat's generated enumeration
constant prefix from Q_CRYPTO_BLOCK_FORMAT to QCRYPTO_BLOCK_FORMAT,
and QCryptoBlockLUKSKeyslotState's from
Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE to QCRYPTO_BLOCK_LUKS_KEYSLOT_STATE.

Signed-off-by: Markus Armbruster 
Acked-by: Daniel P. Berrangé 
---
 qapi/crypto.json   |  2 --
 block/crypto.c | 10 +-
 block/qcow.c   |  2 +-
 block/qcow2.c  | 10 +-
 crypto/block-luks.c|  4 ++--
 crypto/block.c |  4 ++--
 tests/unit/test-crypto-block.c | 14 +++---
 7 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/qapi/crypto.json b/qapi/crypto.json
index a192641a03..fb00c706b2 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -157,7 +157,6 @@
 # Since: 2.6
 ##
 { 'enum': 'QCryptoBlockFormat',
-  'prefix': 'Q_CRYPTO_BLOCK_FORMAT', # TODO drop
   'data': ['qcow', 'luks']}
 
 ##
@@ -360,7 +359,6 @@
 # Since: 5.1
 ##
 { 'enum': 'QCryptoBlockLUKSKeyslotState',
-  'prefix': 'Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE', # TODO drop
   'data': [ 'active', 'inactive' ] }
 
 ##
diff --git a/block/crypto.c b/block/crypto.c
index 4eed3ffa6a..80b2dba17a 100644
--- a/block/crypto.c
+++ b/block/crypto.c
@@ -682,7 +682,7 @@ err:
 static int block_crypto_probe_luks(const uint8_t *buf,
int buf_size,
const char *filename) {
-return block_crypto_probe_generic(Q_CRYPTO_BLOCK_FORMAT_LUKS,
+return block_crypto_probe_generic(QCRYPTO_BLOCK_FORMAT_LUKS,
   buf, buf_size, filename);
 }
 
@@ -691,7 +691,7 @@ static int block_crypto_open_luks(BlockDriverState *bs,
   int flags,
   Error **errp)
 {
-return block_crypto_open_generic(Q_CRYPTO_BLOCK_FORMAT_LUKS,
+return block_crypto_open_generic(QCRYPTO_BLOCK_FORMAT_LUKS,
  &block_crypto_runtime_opts_luks,
  bs, options, flags, errp);
 }
@@ -724,7 +724,7 @@ block_crypto_co_create_luks(BlockdevCreateOptions 
*create_options, Error **errp)
 }
 
 create_opts = (QCryptoBlockCreateOptions) {
-.format = Q_CRYPTO_BLOCK_FORMAT_LUKS,
+.format = QCRYPTO_BLOCK_FORMAT_LUKS,
 .u.luks = *qapi_BlockdevCreateOptionsLUKS_base(luks_opts),
 };
 
@@ -889,7 +889,7 @@ block_crypto_get_specific_info_luks(BlockDriverState *bs, 
Error **errp)
 if (!info) {
 return NULL;
 }
-assert(info->format == Q_CRYPTO_BLOCK_FORMAT_LUKS);
+assert(info->format == QCRYPTO_BLOCK_FORMAT_LUKS);
 
 spec_info = g_new(ImageInfoSpecific, 1);
 spec_info->type = IMAGE_INFO_SPECIFIC_KIND_LUKS;
@@ -1002,7 +1002,7 @@ coroutine_fn block_crypto_co_amend_luks(BlockDriverState 
*bs,
 QCryptoBlockAmendOptions amend_opts;
 
 amend_opts = (QCryptoBlockAmendOptions) {
-.format = Q_CRYPTO_BLOCK_FORMAT_LUKS,
+.format = QCRYPTO_BLOCK_FORMAT_LUKS,
 .u.luks = *qapi_BlockdevAmendOptionsLUKS_base(&opts->u.luks),
 };
 return block_crypto_amend_options_generic_luks(bs, &amend_opts,
diff --git a/block/qcow.c b/block/qcow.c
index c2f89db055..84d1cca296 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -831,7 +831,7 @@ qcow_co_create(BlockdevCreateOptions *opts, Error **errp)
 }
 
 if (qcow_opts->encrypt &&
-qcow_opts->encrypt->format != Q_CRYPTO_BLOCK_FORMAT_QCOW)
+qcow_opts->encrypt->format != QCRYPTO_BLOCK_FORMAT_QCOW)
 {
 error_setg(errp, "Unsupported encryption format");
 return -EINVAL;
diff --git a/block/qcow2.c b/block/qcow2.c
index 70b19730a3..dd359d241b 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -3214,10 +3214,10 @@ qcow2_set_up_encryption(BlockDriverState *bs,
 int fmt, ret;
 
 switch (cryptoopts->format) {
-case Q_CRYPTO_BLOCK_FORMAT_LUKS:
+case QCRYPTO_BLOCK_FORMAT_LUKS:
 fmt = QCOW_CRYPT_LUKS;
 break;
-case Q_CRYPTO_BLOCK_FORMAT_QCOW:
+case QCRYPTO_BLOCK_FORMAT_QCOW:
 fmt = QCOW_CRYPT_AES;
 break;
 default:
@@ -5306,10 +5306,10 @@ qcow2_get_specific_info(BlockDriverState *bs, Error 
**errp)
 ImageInfoSpecificQCow2Encryption *qencrypt =
 g_new(ImageInfoSpecificQCow2Encryption, 1);
 switch (encrypt_info->format) {
-case Q_CRYPTO_BLOCK_FORMAT_QCOW:
+case QCRYPTO_BLOCK_FORMAT_QCOW:
 qencrypt->format = BLOCKDEV_QCOW2_ENCRYPTION_FORMAT_AES;
 break;
-case 

[PATCH v2 10/19] qapi/crypto: Drop unwanted 'prefix'

2024-09-04 Thread Markus Armbruster
QAPI's 'prefix' feature can make the connection between enumeration
type and its constants less than obvious.  It's best used with
restraint.

QCryptoAkCipherKeyType has a 'prefix' that overrides the generated
enumeration constants' prefix to QCRYPTO_AKCIPHER_KEY_TYPE.

Drop it.  The prefix becomes QCRYPTO_AK_CIPHER_KEY_TYPE.

Signed-off-by: Markus Armbruster 
Acked-by: Daniel P. Berrangé 
---
 qapi/crypto.json|  1 -
 backends/cryptodev-builtin.c|  4 ++--
 backends/cryptodev-lkcf.c   |  6 +++---
 tests/bench/benchmark-crypto-akcipher.c |  2 +-
 tests/unit/test-crypto-akcipher.c   | 28 -
 crypto/akcipher-gcrypt.c.inc|  8 +++
 crypto/akcipher-nettle.c.inc|  8 +++
 crypto/rsakey-builtin.c.inc |  4 ++--
 crypto/rsakey-nettle.c.inc  |  4 ++--
 9 files changed, 32 insertions(+), 33 deletions(-)

diff --git a/qapi/crypto.json b/qapi/crypto.json
index fb00c706b2..b5c25e7cd9 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -609,7 +609,6 @@
 # Since: 7.1
 ##
 { 'enum': 'QCryptoAkCipherKeyType',
-  'prefix': 'QCRYPTO_AKCIPHER_KEY_TYPE',
   'data': ['public', 'private']}
 
 ##
diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c
index 940104ee55..e95af9bb72 100644
--- a/backends/cryptodev-builtin.c
+++ b/backends/cryptodev-builtin.c
@@ -334,11 +334,11 @@ static int cryptodev_builtin_create_akcipher_session(
 
 switch (sess_info->keytype) {
 case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PUBLIC:
-type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC;
+type = QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC;
 break;
 
 case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PRIVATE:
-type = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE;
+type = QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE;
 break;
 
 default:
diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c
index 45aba1ff67..e1ee11a158 100644
--- a/backends/cryptodev-lkcf.c
+++ b/backends/cryptodev-lkcf.c
@@ -322,7 +322,7 @@ static void cryptodev_lkcf_execute_task(CryptoDevLKCFTask 
*task)
  * 2. generally, public key related compution is fast, just compute it with
  * thread-pool.
  */
-if (session->keytype == QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE) {
+if (session->keytype == QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE) {
 if (qcrypto_akcipher_export_p8info(&session->akcipher_opts,
session->key, session->keylen,
&p8info, &p8info_len,
@@ -534,11 +534,11 @@ static int cryptodev_lkcf_create_asym_session(
 
 switch (sess_info->keytype) {
 case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PUBLIC:
-sess->keytype = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC;
+sess->keytype = QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC;
 break;
 
 case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PRIVATE:
-sess->keytype = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE;
+sess->keytype = QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE;
 break;
 
 default:
diff --git a/tests/bench/benchmark-crypto-akcipher.c 
b/tests/bench/benchmark-crypto-akcipher.c
index 5e68cb0a1c..bbc29c9b12 100644
--- a/tests/bench/benchmark-crypto-akcipher.c
+++ b/tests/bench/benchmark-crypto-akcipher.c
@@ -28,7 +28,7 @@ static QCryptoAkCipher *create_rsa_akcipher(const uint8_t 
*priv_key,
 opt.alg = QCRYPTO_AKCIPHER_ALG_RSA;
 opt.u.rsa.padding_alg = padding;
 opt.u.rsa.hash_alg = hash;
-return qcrypto_akcipher_new(&opt, QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE,
+return qcrypto_akcipher_new(&opt, QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE,
 priv_key, keylen, &error_abort);
 }
 
diff --git a/tests/unit/test-crypto-akcipher.c 
b/tests/unit/test-crypto-akcipher.c
index 4f1f4214dd..59bc6f1e69 100644
--- a/tests/unit/test-crypto-akcipher.c
+++ b/tests/unit/test-crypto-akcipher.c
@@ -692,7 +692,7 @@ struct QCryptoAkCipherTestData {
 static QCryptoRSAKeyTestData rsakey_test_data[] = {
 {
 .path = "/crypto/akcipher/rsakey-1024-public",
-.key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC,
+.key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC,
 .key = rsa1024_public_key,
 .keylen = sizeof(rsa1024_public_key),
 .is_valid_key = true,
@@ -700,7 +700,7 @@ static QCryptoRSAKeyTestData rsakey_test_data[] = {
 },
 {
 .path = "/crypto/akcipher/rsakey-1024-private",
-.key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE,
+.key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE,
 .key = rsa1024_private_key,
 .keylen = sizeof(rsa1024_private_key),
 .is_valid_key = true,
@@ -708,7 +708,7 @@ static QCryptoRSAKeyTestData rsakey_test_data[] = {
 },
 {
 .path = "/crypto/akcipher/rsakey

[PATCH v2 13/19] qapi/crypto: Rename QCryptoIVGenAlgorithm to *Algo, and drop prefix

2024-09-04 Thread Markus Armbruster
QAPI's 'prefix' feature can make the connection between enumeration
type and its constants less than obvious.  It's best used with
restraint.

QCryptoIVGenAlgorithm has a 'prefix' that overrides the generated
enumeration constants' prefix to QCRYPTO_IVGEN_ALG.

We could simply drop 'prefix', but then the prefix becomes
QCRYPTO_IV_GEN_ALGORITHM, which is rather long.

We could additionally rename the type to QCryptoIVGenAlg, but I think
the abbreviation "alg" is less than clear.

Rename the type to QCryptoIVGenAlgo instead.  The prefix becomes
QCRYPTO_IV_GEN_ALGO.

Signed-off-by: Markus Armbruster 
Acked-by: Daniel P. Berrangé 
---
 qapi/crypto.json   |  9 -
 crypto/ivgenpriv.h |  2 +-
 include/crypto/ivgen.h | 14 +++---
 crypto/block-luks.c| 16 
 crypto/block-qcow.c|  2 +-
 crypto/ivgen.c | 10 +-
 tests/unit/test-crypto-block.c | 14 +++---
 tests/unit/test-crypto-ivgen.c | 22 +++---
 8 files changed, 44 insertions(+), 45 deletions(-)

diff --git a/qapi/crypto.json b/qapi/crypto.json
index 0591d62f67..3e6a7fb8e5 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -122,7 +122,7 @@
   'data': ['ecb', 'cbc', 'xts', 'ctr']}
 
 ##
-# @QCryptoIVGenAlgorithm:
+# @QCryptoIVGenAlgo:
 #
 # The supported algorithms for generating initialization vectors for
 # full disk encryption.  The 'plain' generator should not be used for
@@ -138,8 +138,7 @@
 #
 # Since: 2.6
 ##
-{ 'enum': 'QCryptoIVGenAlgorithm',
-  'prefix': 'QCRYPTO_IVGEN_ALG',
+{ 'enum': 'QCryptoIVGenAlgo',
   'data': ['plain', 'plain64', 'essiv']}
 
 ##
@@ -226,7 +225,7 @@
   'base': 'QCryptoBlockOptionsLUKS',
   'data': { '*cipher-alg': 'QCryptoCipherAlgo',
 '*cipher-mode': 'QCryptoCipherMode',
-'*ivgen-alg': 'QCryptoIVGenAlgorithm',
+'*ivgen-alg': 'QCryptoIVGenAlgo',
 '*ivgen-hash-alg': 'QCryptoHashAlgo',
 '*hash-alg': 'QCryptoHashAlgo',
 '*iter-time': 'int' }}
@@ -323,7 +322,7 @@
 { 'struct': 'QCryptoBlockInfoLUKS',
   'data': {'cipher-alg': 'QCryptoCipherAlgo',
'cipher-mode': 'QCryptoCipherMode',
-   'ivgen-alg': 'QCryptoIVGenAlgorithm',
+   'ivgen-alg': 'QCryptoIVGenAlgo',
'*ivgen-hash-alg': 'QCryptoHashAlgo',
'hash-alg': 'QCryptoHashAlgo',
'detached-header': 'bool',
diff --git a/crypto/ivgenpriv.h b/crypto/ivgenpriv.h
index ef24c76345..e3388d30be 100644
--- a/crypto/ivgenpriv.h
+++ b/crypto/ivgenpriv.h
@@ -40,7 +40,7 @@ struct QCryptoIVGen {
 QCryptoIVGenDriver *driver;
 void *private;
 
-QCryptoIVGenAlgorithm algorithm;
+QCryptoIVGenAlgo algorithm;
 QCryptoCipherAlgo cipher;
 QCryptoHashAlgo hash;
 };
diff --git a/include/crypto/ivgen.h b/include/crypto/ivgen.h
index b059e332cd..bfa5d28103 100644
--- a/include/crypto/ivgen.h
+++ b/include/crypto/ivgen.h
@@ -44,7 +44,7 @@
  *
  * g_assert((ndata % 512) == 0);
  *
- * QCryptoIVGen *ivgen = qcrypto_ivgen_new(QCRYPTO_IVGEN_ALG_ESSIV,
+ * QCryptoIVGen *ivgen = qcrypto_ivgen_new(QCRYPTO_IV_GEN_ALGO_ESSIV,
  * QCRYPTO_CIPHER_ALGO_AES_128,
  * QCRYPTO_HASH_ALGO_SHA256,
  * key, nkey, errp);
@@ -97,7 +97,7 @@
 
 typedef struct QCryptoIVGen QCryptoIVGen;
 
-/* See also QCryptoIVGenAlgorithm enum in qapi/crypto.json */
+/* See also QCryptoIVGenAlgo enum in qapi/crypto.json */
 
 
 /**
@@ -113,19 +113,19 @@ typedef struct QCryptoIVGen QCryptoIVGen;
  * are required or not depends on the choice of @alg
  * requested.
  *
- * - QCRYPTO_IVGEN_ALG_PLAIN
+ * - QCRYPTO_IV_GEN_ALGO_PLAIN
  *
  * The IVs are generated by the 32-bit truncated sector
  * number. This should never be used for block devices
  * that are larger than 2^32 sectors in size.
  * All the other parameters are unused.
  *
- * - QCRYPTO_IVGEN_ALG_PLAIN64
+ * - QCRYPTO_IV_GEN_ALGO_PLAIN64
  *
  * The IVs are generated by the 64-bit sector number.
  * All the other parameters are unused.
  *
- * - QCRYPTO_IVGEN_ALG_ESSIV:
+ * - QCRYPTO_IV_GEN_ALGO_ESSIV:
  *
  * The IVs are generated by encrypting the 64-bit sector
  * number with a hash of an encryption key. The @cipheralg,
@@ -133,7 +133,7 @@ typedef struct QCryptoIVGen QCryptoIVGen;
  *
  * Returns: a new IV generator, or NULL on error
  */

[PATCH v2 04/19] qapi/common: Drop temporary 'prefix'

2024-09-04 Thread Markus Armbruster
Recent commit "qapi: Smarter camel_to_upper() to reduce need for
'prefix'" added a temporary 'prefix' to delay changing the generated
code.

Revert it.  This improves OffAutoPCIBAR's generated enumeration
constant prefix from OFF_AUTOPCIBAR to OFF_AUTO_PCIBAR.

Signed-off-by: Markus Armbruster 
Reviewed-by: Cédric Le Goater 
---
 qapi/common.json |  1 -
 hw/vfio/pci.c| 10 +-
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/qapi/common.json b/qapi/common.json
index 25726d3113..7558ce5430 100644
--- a/qapi/common.json
+++ b/qapi/common.json
@@ -92,7 +92,6 @@
 # Since: 2.12
 ##
 { 'enum': 'OffAutoPCIBAR',
-  'prefix': 'OFF_AUTOPCIBAR',   # TODO drop
   'data': [ 'off', 'auto', 'bar0', 'bar1', 'bar2', 'bar3', 'bar4', 'bar5' ] }
 
 ##
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 2407720c35..0a99e55247 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -1452,7 +1452,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vdev, 
Error **errp)
 int target_bar = -1;
 size_t msix_sz;
 
-if (!vdev->msix || vdev->msix_relo == OFF_AUTOPCIBAR_OFF) {
+if (!vdev->msix || vdev->msix_relo == OFF_AUTO_PCIBAR_OFF) {
 return true;
 }
 
@@ -1464,7 +1464,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vdev, 
Error **errp)
 /* PCI BARs must be a power of 2 */
 msix_sz = pow2ceil(msix_sz);
 
-if (vdev->msix_relo == OFF_AUTOPCIBAR_AUTO) {
+if (vdev->msix_relo == OFF_AUTO_PCIBAR_AUTO) {
 /*
  * TODO: Lookup table for known devices.
  *
@@ -1479,7 +1479,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vdev, 
Error **errp)
 return false;
 }
 } else {
-target_bar = (int)(vdev->msix_relo - OFF_AUTOPCIBAR_BAR0);
+target_bar = (int)(vdev->msix_relo - OFF_AUTO_PCIBAR_BAR0);
 }
 
 /* I/O port BARs cannot host MSI-X structures */
@@ -1624,7 +1624,7 @@ static bool vfio_msix_early_setup(VFIOPCIDevice *vdev, 
Error **errp)
 } else if (vfio_pci_is(vdev, PCI_VENDOR_ID_BAIDU,
PCI_DEVICE_ID_KUNLUN_VF)) {
 msix->pba_offset = 0xb400;
-} else if (vdev->msix_relo == OFF_AUTOPCIBAR_OFF) {
+} else if (vdev->msix_relo == OFF_AUTO_PCIBAR_OFF) {
 error_setg(errp, "hardware reports invalid configuration, "
"MSIX PBA outside of specified BAR");
 g_free(msix);
@@ -3403,7 +3403,7 @@ static Property vfio_pci_dev_properties[] = {
nv_gpudirect_clique,
qdev_prop_nv_gpudirect_clique, uint8_t),
 DEFINE_PROP_OFF_AUTO_PCIBAR("x-msix-relocation", VFIOPCIDevice, msix_relo,
-OFF_AUTOPCIBAR_OFF),
+OFF_AUTO_PCIBAR_OFF),
 #ifdef CONFIG_IOMMUFD
 DEFINE_PROP_LINK("iommufd", VFIOPCIDevice, vbasedev.iommufd,
  TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *),
-- 
2.46.0




[PATCH v2 03/19] qapi/block-core: Drop temporary 'prefix'

2024-09-04 Thread Markus Armbruster
Recent commit "qapi: Smarter camel_to_upper() to reduce need for
'prefix'" added a temporary 'prefix' to delay changing the generated
code.

Revert it.  This improves XDbgBlockGraphNodeType's generated
enumeration constant prefix from
X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BACKEND to
XDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BACKEND.

Signed-off-by: Markus Armbruster 
---
 qapi/block-core.json | 1 -
 block.c  | 6 +++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/qapi/block-core.json b/qapi/block-core.json
index 452047102a..a7ae2da47b 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -2011,7 +2011,6 @@
 # Since: 4.0
 ##
 { 'enum': 'XDbgBlockGraphNodeType',
-  'prefix': 'X_DBG_BLOCK_GRAPH_NODE_TYPE', # TODO drop
   'data': [ 'block-backend', 'block-job', 'block-driver' ] }
 
 ##
diff --git a/block.c b/block.c
index c317de9eaa..7d90007cae 100644
--- a/block.c
+++ b/block.c
@@ -6351,7 +6351,7 @@ XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **errp)
 if (!*name) {
 name = allocated_name = blk_get_attached_dev_id(blk);
 }
-xdbg_graph_add_node(gr, blk, X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BACKEND,
+xdbg_graph_add_node(gr, blk, XDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BACKEND,
name);
 g_free(allocated_name);
 if (blk_root(blk)) {
@@ -6364,7 +6364,7 @@ XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **errp)
  job = block_job_next_locked(job)) {
 GSList *el;
 
-xdbg_graph_add_node(gr, job, X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_JOB,
+xdbg_graph_add_node(gr, job, XDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_JOB,
 job->job.id);
 for (el = job->nodes; el; el = el->next) {
 xdbg_graph_add_edge(gr, job, (BdrvChild *)el->data);
@@ -6373,7 +6373,7 @@ XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **errp)
 }
 
 QTAILQ_FOREACH(bs, &graph_bdrv_states, node_list) {
-xdbg_graph_add_node(gr, bs, X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_DRIVER,
+xdbg_graph_add_node(gr, bs, XDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_DRIVER,
bs->node_name);
 QLIST_FOREACH(child, &bs->children, next) {
 xdbg_graph_add_edge(gr, bs, child);
-- 
2.46.0




[PATCH v2 12/19] qapi/crypto: Rename QCryptoCipherAlgorithm to *Algo, and drop prefix

2024-09-04 Thread Markus Armbruster
QAPI's 'prefix' feature can make the connection between enumeration
type and its constants less than obvious.  It's best used with
restraint.

QCryptoCipherAlgorithm has a 'prefix' that overrides the generated
enumeration constants' prefix to QCRYPTO_CIPHER_ALG.

We could simply drop 'prefix', but then the prefix becomes
QCRYPTO_CIPHER_ALGORITHM, which is rather long.

We could additionally rename the type to QCryptoCipherAlg, but I think
the abbreviation "alg" is less than clear.

Rename the type to QCryptoCipherAlgo instead.  The prefix becomes
QCRYPTO_CIPHER_ALGO.

Signed-off-by: Markus Armbruster 
Acked-by: Daniel P. Berrangé 
---
 qapi/block-core.json  |  2 +-
 qapi/crypto.json  |  9 ++-
 crypto/blockpriv.h|  4 +-
 crypto/cipherpriv.h   |  2 +-
 crypto/ivgenpriv.h|  2 +-
 include/crypto/cipher.h   | 18 +++---
 include/crypto/ivgen.h| 10 +--
 include/crypto/pbkdf.h|  4 +-
 backends/cryptodev-builtin.c  | 16 ++---
 block/rbd.c   |  4 +-
 crypto/block-luks.c   | 92 +--
 crypto/block-qcow.c   |  4 +-
 crypto/block.c|  2 +-
 crypto/cipher-afalg.c | 24 +++
 crypto/cipher.c   | 72 ++---
 crypto/ivgen.c|  4 +-
 crypto/secret_common.c|  2 +-
 tests/bench/benchmark-crypto-cipher.c | 22 +++
 tests/unit/test-crypto-block.c| 14 ++--
 tests/unit/test-crypto-cipher.c   | 66 +--
 tests/unit/test-crypto-ivgen.c|  8 +--
 ui/vnc.c  |  4 +-
 crypto/cipher-builtin.c.inc   | 18 +++---
 crypto/cipher-gcrypt.c.inc| 56 
 crypto/cipher-gnutls.c.inc| 38 +--
 crypto/cipher-nettle.c.inc| 58 -
 26 files changed, 277 insertions(+), 278 deletions(-)

diff --git a/qapi/block-core.json b/qapi/block-core.json
index a7ae2da47b..9f6dd59298 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -4163,7 +4163,7 @@
 ##
 { 'struct': 'RbdEncryptionCreateOptionsLUKSBase',
   'base': 'RbdEncryptionOptionsLUKSBase',
-  'data': { '*cipher-alg': 'QCryptoCipherAlgorithm' } }
+  'data': { '*cipher-alg': 'QCryptoCipherAlgo' } }
 
 ##
 # @RbdEncryptionOptionsLUKS:
diff --git a/qapi/crypto.json b/qapi/crypto.json
index 68393568cf..0591d62f67 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -62,7 +62,7 @@
   'data': ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd160']}
 
 ##
-# @QCryptoCipherAlgorithm:
+# @QCryptoCipherAlgo:
 #
 # The supported algorithms for content encryption ciphers
 #
@@ -95,8 +95,7 @@
 #
 # Since: 2.6
 ##
-{ 'enum': 'QCryptoCipherAlgorithm',
-  'prefix': 'QCRYPTO_CIPHER_ALG',
+{ 'enum': 'QCryptoCipherAlgo',
   'data': ['aes-128', 'aes-192', 'aes-256',
'des', '3des',
'cast5-128',
@@ -225,7 +224,7 @@
 ##
 { 'struct': 'QCryptoBlockCreateOptionsLUKS',
   'base': 'QCryptoBlockOptionsLUKS',
-  'data': { '*cipher-alg': 'QCryptoCipherAlgorithm',
+  'data': { '*cipher-alg': 'QCryptoCipherAlgo',
 '*cipher-mode': 'QCryptoCipherMode',
 '*ivgen-alg': 'QCryptoIVGenAlgorithm',
 '*ivgen-hash-alg': 'QCryptoHashAlgo',
@@ -322,7 +321,7 @@
 # Since: 2.7
 ##
 { 'struct': 'QCryptoBlockInfoLUKS',
-  'data': {'cipher-alg': 'QCryptoCipherAlgorithm',
+  'data': {'cipher-alg': 'QCryptoCipherAlgo',
'cipher-mode': 'QCryptoCipherMode',
'ivgen-alg': 'QCryptoIVGenAlgorithm',
'*ivgen-hash-alg': 'QCryptoHashAlgo',
diff --git a/crypto/blockpriv.h b/crypto/blockpriv.h
index cf1a66c00d..edf0b3a3d9 100644
--- a/crypto/blockpriv.h
+++ b/crypto/blockpriv.h
@@ -33,7 +33,7 @@ struct QCryptoBlock {
 void *opaque;
 
 /* Cipher parameters */
-QCryptoCipherAlgorithm alg;
+QCryptoCipherAlgo alg;
 QCryptoCipherMode mode;
 uint8_t *key;
 size_t nkey;
@@ -132,7 +132,7 @@ int qcrypto_block_encrypt_helper(QCryptoBlock *block,
  Error **errp);
 
 int qcrypto_block_init_cipher(QCryptoBlock *block,
-  QCryptoCipherAlgorithm alg,
+ 

[PATCH v2 11/19] qapi/crypto: Rename QCryptoHashAlgorithm to *Algo, and drop prefix

2024-09-04 Thread Markus Armbruster
QAPI's 'prefix' feature can make the connection between enumeration
type and its constants less than obvious.  It's best used with
restraint.

QCryptoHashAlgorithm has a 'prefix' that overrides the generated
enumeration constants' prefix to QCRYPTO_HASH_ALG.

We could simply drop 'prefix', but then the prefix becomes
QCRYPTO_HASH_ALGORITHM, which is rather long.

We could additionally rename the type to QCryptoHashAlg, but I think
the abbreviation "alg" is less than clear.

Rename the type to QCryptoHashAlgo instead.  The prefix becomes to
QCRYPTO_HASH_ALGO.

Signed-off-by: Markus Armbruster 
Acked-by: Daniel P. Berrangé 
---
 qapi/crypto.json| 17 +-
 crypto/blockpriv.h  |  2 +-
 crypto/hashpriv.h   |  2 +-
 crypto/hmacpriv.h   |  4 +--
 crypto/ivgenpriv.h  |  2 +-
 include/crypto/afsplit.h|  8 ++---
 include/crypto/block.h  |  2 +-
 include/crypto/hash.h   | 18 +-
 include/crypto/hmac.h   |  6 ++--
 include/crypto/ivgen.h  |  6 ++--
 include/crypto/pbkdf.h  | 10 +++---
 backends/cryptodev-builtin.c|  8 ++---
 backends/cryptodev-lkcf.c   | 10 +++---
 block/parallels-ext.c   |  2 +-
 block/quorum.c  |  4 +--
 crypto/afsplit.c|  6 ++--
 crypto/block-luks.c | 16 -
 crypto/block.c  |  2 +-
 crypto/hash-afalg.c | 26 +++
 crypto/hash-gcrypt.c| 20 +--
 crypto/hash-glib.c  | 20 +--
 crypto/hash-gnutls.c| 20 +--
 crypto/hash-nettle.c| 18 +-
 crypto/hash.c   | 30 -
 crypto/hmac-gcrypt.c| 22 ++---
 crypto/hmac-glib.c  | 22 ++---
 crypto/hmac-gnutls.c| 22 ++---
 crypto/hmac-nettle.c| 22 ++---
 crypto/hmac.c   |  2 +-
 crypto/ivgen.c  |  4 +--
 crypto/pbkdf-gcrypt.c   | 36 ++--
 crypto/pbkdf-gnutls.c   | 36 ++--
 crypto/pbkdf-nettle.c   | 32 +-
 crypto/pbkdf-stub.c |  4 +--
 crypto/pbkdf.c  |  2 +-
 hw/misc/aspeed_hace.c   | 16 -
 io/channel-websock.c|  2 +-
 target/i386/sev.c   |  6 ++--
 tests/bench/benchmark-crypto-akcipher.c | 12 +++
 tests/bench/benchmark-crypto-hash.c | 10 +++---
 tests/bench/benchmark-crypto-hmac.c |  6 ++--
 tests/unit/test-crypto-afsplit.c| 10 +++---
 tests/unit/test-crypto-akcipher.c   |  6 ++--
 tests/unit/test-crypto-block.c  | 16 -
 tests/unit/test-crypto-hash.c   | 42 +++
 tests/unit/test-crypto-hmac.c   | 16 -
 tests/unit/test-crypto-ivgen.c  |  8 ++---
 tests/unit/test-crypto-pbkdf.c  | 44 -
 ui/vnc.c|  2 +-
 util/hbitmap.c  |  2 +-
 crypto/akcipher-gcrypt.c.inc| 14 
 crypto/akcipher-nettle.c.inc| 26 +++
 52 files changed, 350 insertions(+), 351 deletions(-)

diff --git a/qapi/crypto.json b/qapi/crypto.json
index b5c25e7cd9..68393568cf 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -38,7 +38,7 @@
   'data': ['raw', 'base64']}
 
 ##
-# @QCryptoHashAlgorithm:
+# @QCryptoHashAlgo:
 #
 # The supported algorithms for computing content digests
 #
@@ -58,8 +58,7 @@
 #
 # Since: 2.6
 ##
-{ 'enum': 'QCryptoHashAlgorithm',
-  'prefix': 'QCRYPTO_HASH_ALG',
+{ 'enum': 'QCryptoHashAlgo',
   'data': ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd160']}
 
 ##
@@ -229,8 +228,8 @@
   'data': { '*cipher-alg': 'QCryptoCipherAlgorithm',
 '*cipher-mode': 'QCryptoCipherMode',
 '*ivgen-alg': 'QCryptoIVGenAlgorithm',
-'*ivgen-hash-alg': 'QCryptoHashAlgorithm',
-'*hash-alg': 'QCryptoHashAlgorithm',
+'*ivgen-hash-alg': 'QCryptoHashAlgo',
+'*hash-alg': 'QCryptoHashAlgo',
 '*iter-time': 'int' }}
 
 ##
@@ -326,8 +325,8 @@
   'data': {'cipher-alg': 'QCryptoCipherAlgorithm',
  

[PATCH v2 17/19] qapi/cryptodev: Drop unwanted 'prefix'

2024-09-04 Thread Markus Armbruster
QAPI's 'prefix' feature can make the connection between enumeration
type and its constants less than obvious.  It's best used with
restraint.

QCryptodevBackendServiceType has a 'prefix' that overrides the
generated enumeration constants' prefix to QCRYPTODEV_BACKEND_SERVICE.

Drop it.  The prefix becomes QCRYPTODEV_BACKEND_SERVICE_TYPE.

Signed-off-by: Markus Armbruster 
Reviewed-by: Daniel P. Berrangé 
---
 qapi/cryptodev.json |  1 -
 backends/cryptodev-builtin.c|  8 
 backends/cryptodev-lkcf.c   |  2 +-
 backends/cryptodev-vhost-user.c |  6 +++---
 backends/cryptodev.c|  6 +++---
 hw/virtio/virtio-crypto.c   | 10 +-
 6 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/qapi/cryptodev.json b/qapi/cryptodev.json
index 60f8fe8e4a..65abc16842 100644
--- a/qapi/cryptodev.json
+++ b/qapi/cryptodev.json
@@ -31,7 +31,6 @@
 # Since: 8.0
 ##
 { 'enum': 'QCryptodevBackendServiceType',
-  'prefix': 'QCRYPTODEV_BACKEND_SERVICE',
   'data': ['cipher', 'hash', 'mac', 'aead', 'akcipher']}
 
 ##
diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c
index 6f3990481b..170c93a6be 100644
--- a/backends/cryptodev-builtin.c
+++ b/backends/cryptodev-builtin.c
@@ -68,7 +68,7 @@ static void cryptodev_builtin_init_akcipher(CryptoDevBackend 
*backend)
 opts.u.rsa.padding_alg = QCRYPTO_RSA_PADDING_ALGO_RAW;
 if (qcrypto_akcipher_supports(&opts)) {
 backend->conf.crypto_services |=
- (1u << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER);
+ (1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_AKCIPHER);
 backend->conf.akcipher_algo = 1u << VIRTIO_CRYPTO_AKCIPHER_RSA;
 }
 }
@@ -93,9 +93,9 @@ static void cryptodev_builtin_init(
 backend->conf.peers.ccs[0] = cc;
 
 backend->conf.crypto_services =
- 1u << QCRYPTODEV_BACKEND_SERVICE_CIPHER |
- 1u << QCRYPTODEV_BACKEND_SERVICE_HASH |
- 1u << QCRYPTODEV_BACKEND_SERVICE_MAC;
+ 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_CIPHER |
+ 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_HASH |
+ 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_MAC;
 backend->conf.cipher_algo_l = 1u << VIRTIO_CRYPTO_CIPHER_AES_CBC;
 backend->conf.hash_algo = 1u << VIRTIO_CRYPTO_HASH_SHA1;
 /*
diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c
index fde32950f6..0dc4b067f5 100644
--- a/backends/cryptodev-lkcf.c
+++ b/backends/cryptodev-lkcf.c
@@ -230,7 +230,7 @@ static void cryptodev_lkcf_init(CryptoDevBackend *backend, 
Error **errp)
 backend->conf.peers.ccs[0] = cc;
 
 backend->conf.crypto_services =
-1u << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER;
+1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_AKCIPHER;
 backend->conf.akcipher_algo = 1u << VIRTIO_CRYPTO_AKCIPHER_RSA;
 lkcf->running = true;
 
diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-user.c
index c3283ba84a..e33fb78521 100644
--- a/backends/cryptodev-vhost-user.c
+++ b/backends/cryptodev-vhost-user.c
@@ -221,9 +221,9 @@ static void cryptodev_vhost_user_init(
  cryptodev_vhost_user_event, NULL, s, NULL, true);
 
 backend->conf.crypto_services =
- 1u << QCRYPTODEV_BACKEND_SERVICE_CIPHER |
- 1u << QCRYPTODEV_BACKEND_SERVICE_HASH |
- 1u << QCRYPTODEV_BACKEND_SERVICE_MAC;
+ 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_CIPHER |
+ 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_HASH |
+ 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_MAC;
 backend->conf.cipher_algo_l = 1u << VIRTIO_CRYPTO_CIPHER_AES_CBC;
 backend->conf.hash_algo = 1u << VIRTIO_CRYPTO_HASH_SHA1;
 
diff --git a/backends/cryptodev.c b/backends/cryptodev.c
index fff89fd62a..76dfe65904 100644
--- a/backends/cryptodev.c
+++ b/backends/cryptodev.c
@@ -74,7 +74,7 @@ static int qmp_query_cryptodev_foreach(Object *obj, void 
*data)
 
 backend = CRYPTODEV_BACKEND(obj);
 services = backend->conf.crypto_services;
-for (i = 0; i < QCRYPTODEV_BACKEND_SERVICE__MAX; i++) {
+for (i = 0; i < QCRYPTODEV_BACKEND_SERVICE_TYPE__MAX; i++) {
 if (services & (1 << i)) {
 QAPI_LIST_PREPEND(info->service, i);
 }
@@ -424,11 +424,11 @@ cryptodev_backend_complete(UserCreatable *uc, Error 
**errp)
 }
 
 services = backend->conf.crypto_services;
-if (services & (1 << QCRYPTODEV_BACKEND_SERVICE_CIPHER)) {
+if (services & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_C

[PATCH v2 18/19] qapi/cryptodev: Rename QCryptodevBackendAlgType to *Algo, and drop prefix

2024-09-04 Thread Markus Armbruster
QAPI's 'prefix' feature can make the connection between enumeration
type and its constants less than obvious.  It's best used with
restraint.

QCryptodevBackendAlgType has a 'prefix' that overrides the generated
enumeration constants' prefix to QCRYPTODEV_BACKEND_ALG.

We could simply drop 'prefix', but I think the abbreviation "alg" is
less than clear.

Additionally rename the type to QCryptodevBackendAlgoType.  The prefix
becomes QCRYPTODEV_BACKEND_ALGO_TYPE.

Signed-off-by: Markus Armbruster 
Reviewed-by: Daniel P. Berrangé 
---
 qapi/cryptodev.json  |  5 ++---
 include/sysemu/cryptodev.h   |  2 +-
 backends/cryptodev-builtin.c |  6 +++---
 backends/cryptodev-lkcf.c|  4 ++--
 backends/cryptodev.c |  6 +++---
 hw/virtio/virtio-crypto.c| 14 +++---
 6 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/qapi/cryptodev.json b/qapi/cryptodev.json
index 65abc16842..5e417340dc 100644
--- a/qapi/cryptodev.json
+++ b/qapi/cryptodev.json
@@ -9,7 +9,7 @@
 ##
 
 ##
-# @QCryptodevBackendAlgType:
+# @QCryptodevBackendAlgoType:
 #
 # The supported algorithm types of a crypto device.
 #
@@ -19,8 +19,7 @@
 #
 # Since: 8.0
 ##
-{ 'enum': 'QCryptodevBackendAlgType',
-  'prefix': 'QCRYPTODEV_BACKEND_ALG',
+{ 'enum': 'QCryptodevBackendAlgoType',
   'data': ['sym', 'asym']}
 
 ##
diff --git a/include/sysemu/cryptodev.h b/include/sysemu/cryptodev.h
index 96d3998b93..b20822df0d 100644
--- a/include/sysemu/cryptodev.h
+++ b/include/sysemu/cryptodev.h
@@ -178,7 +178,7 @@ typedef struct CryptoDevBackendAsymOpInfo {
 typedef void (*CryptoDevCompletionFunc) (void *opaque, int ret);
 
 typedef struct CryptoDevBackendOpInfo {
-QCryptodevBackendAlgType algtype;
+QCryptodevBackendAlgoType algtype;
 uint32_t op_code;
 uint32_t queue_index;
 CryptoDevCompletionFunc cb;
diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c
index 170c93a6be..b1486be630 100644
--- a/backends/cryptodev-builtin.c
+++ b/backends/cryptodev-builtin.c
@@ -549,7 +549,7 @@ static int cryptodev_builtin_operation(
 CryptoDevBackendBuiltinSession *sess;
 CryptoDevBackendSymOpInfo *sym_op_info;
 CryptoDevBackendAsymOpInfo *asym_op_info;
-QCryptodevBackendAlgType algtype = op_info->algtype;
+QCryptodevBackendAlgoType algtype = op_info->algtype;
 int status = -VIRTIO_CRYPTO_ERR;
 Error *local_error = NULL;
 
@@ -561,11 +561,11 @@ static int cryptodev_builtin_operation(
 }
 
 sess = builtin->sessions[op_info->session_id];
-if (algtype == QCRYPTODEV_BACKEND_ALG_SYM) {
+if (algtype == QCRYPTODEV_BACKEND_ALGO_TYPE_SYM) {
 sym_op_info = op_info->u.sym_op_info;
 status = cryptodev_builtin_sym_operation(sess, sym_op_info,
  &local_error);
-} else if (algtype == QCRYPTODEV_BACKEND_ALG_ASYM) {
+} else if (algtype == QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) {
 asym_op_info = op_info->u.asym_op_info;
 status = cryptodev_builtin_asym_operation(sess, op_info->op_code,
   asym_op_info, &local_error);
diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c
index 0dc4b067f5..38deac0717 100644
--- a/backends/cryptodev-lkcf.c
+++ b/backends/cryptodev-lkcf.c
@@ -474,7 +474,7 @@ static int cryptodev_lkcf_operation(
 CryptoDevBackendLKCF *lkcf =
 CRYPTODEV_BACKEND_LKCF(backend);
 CryptoDevBackendLKCFSession *sess;
-QCryptodevBackendAlgType algtype = op_info->algtype;
+QCryptodevBackendAlgoType algtype = op_info->algtype;
 CryptoDevLKCFTask *task;
 
 if (op_info->session_id >= MAX_SESSIONS ||
@@ -485,7 +485,7 @@ static int cryptodev_lkcf_operation(
 }
 
 sess = lkcf->sess[op_info->session_id];
-if (algtype != QCRYPTODEV_BACKEND_ALG_ASYM) {
+if (algtype != QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) {
 error_report("algtype not supported: %u", algtype);
 return -VIRTIO_CRYPTO_NOTSUPP;
 }
diff --git a/backends/cryptodev.c b/backends/cryptodev.c
index 76dfe65904..d8bd2a1ae6 100644
--- a/backends/cryptodev.c
+++ b/backends/cryptodev.c
@@ -185,10 +185,10 @@ static int cryptodev_backend_operation(
 static int cryptodev_backend_account(CryptoDevBackend *backend,
  CryptoDevBackendOpInfo *op_info)
 {
-enum QCryptodevBackendAlgType algtype = op_info->algtype;
+enum QCryptodevBackendAlgoType algtype = op_info->algtype;
 int len;
 
-if (algtype == QCRYPTODEV_BACKEND_ALG_ASYM) {
+if (algtype == QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) {
 CryptoDevBackendAsymOpInfo *asym_op_info = op_info->u.asym_op_info;
 len = asym_op_info->src_len;
 
@@ -212,7 +212,7 @@ static int cryptodev_backend_account(Cry

[PATCH v2 09/19] qapi/machine: Rename CpuS390* to S390Cpu*, and drop 'prefix'

2024-09-04 Thread Markus Armbruster
QAPI's 'prefix' feature can make the connection between enumeration
type and its constants less than obvious.  It's best used with
restraint.

CpuS390Entitlement has a 'prefix' to change the generated enumeration
constants' prefix from CPU_S390_ENTITLEMENT to S390_CPU_ENTITLEMENT.
Rename the type to S390CpuEntitlement, so that 'prefix' is not needed.

Likewise change CpuS390Polarization to S390CpuPolarization, and
CpuS390State to S390CpuState.

Signed-off-by: Markus Armbruster 
Reviewed-by: Daniel P. Berrangé 
Reviewed-by: Zhao Liu 
Acked-by: Thomas Huth 
---
 qapi/machine-common.json|  5 ++---
 qapi/machine-target.json| 11 +--
 qapi/machine.json   |  9 -
 qapi/pragma.json|  6 +++---
 include/hw/qdev-properties-system.h |  2 +-
 include/hw/s390x/cpu-topology.h |  2 +-
 target/s390x/cpu.h  |  2 +-
 hw/core/qdev-properties-system.c|  6 +++---
 hw/s390x/cpu-topology.c |  6 +++---
 9 files changed, 23 insertions(+), 26 deletions(-)

diff --git a/qapi/machine-common.json b/qapi/machine-common.json
index fa6bd71d12..b64e4895cf 100644
--- a/qapi/machine-common.json
+++ b/qapi/machine-common.json
@@ -9,13 +9,12 @@
 ##
 
 ##
-# @CpuS390Entitlement:
+# @S390CpuEntitlement:
 #
 # An enumeration of CPU entitlements that can be assumed by a virtual
 # S390 CPU
 #
 # Since: 8.2
 ##
-{ 'enum': 'CpuS390Entitlement',
-  'prefix': 'S390_CPU_ENTITLEMENT',
+{ 'enum': 'S390CpuEntitlement',
   'data': [ 'auto', 'low', 'medium', 'high' ] }
diff --git a/qapi/machine-target.json b/qapi/machine-target.json
index 1a394c08f5..541f93eeb7 100644
--- a/qapi/machine-target.json
+++ b/qapi/machine-target.json
@@ -405,15 +405,14 @@
'TARGET_RISCV' ] } }
 
 ##
-# @CpuS390Polarization:
+# @S390CpuPolarization:
 #
 # An enumeration of CPU polarization that can be assumed by a virtual
 # S390 CPU
 #
 # Since: 8.2
 ##
-{ 'enum': 'CpuS390Polarization',
-  'prefix': 'S390_CPU_POLARIZATION',
+{ 'enum': 'S390CpuPolarization',
   'data': [ 'horizontal', 'vertical' ],
   'if': 'TARGET_S390X'
 }
@@ -450,7 +449,7 @@
   '*socket-id': 'uint16',
   '*book-id': 'uint16',
   '*drawer-id': 'uint16',
-  '*entitlement': 'CpuS390Entitlement',
+  '*entitlement': 'S390CpuEntitlement',
   '*dedicated': 'bool'
   },
   'features': [ 'unstable' ],
@@ -488,7 +487,7 @@
 #  "timestamp": { "seconds": 1401385907, "microseconds": 422329 } }
 ##
 { 'event': 'CPU_POLARIZATION_CHANGE',
-  'data': { 'polarization': 'CpuS390Polarization' },
+  'data': { 'polarization': 'S390CpuPolarization' },
   'features': [ 'unstable' ],
   'if': { 'all': [ 'TARGET_S390X', 'CONFIG_KVM' ] }
 }
@@ -503,7 +502,7 @@
 # Since: 8.2
 ##
 { 'struct': 'CpuPolarizationInfo',
-  'data': { 'polarization': 'CpuS390Polarization' },
+  'data': { 'polarization': 'S390CpuPolarization' },
   'if': { 'all': [ 'TARGET_S390X', 'CONFIG_KVM' ] }
 }
 
diff --git a/qapi/machine.json b/qapi/machine.json
index d4317435e7..63a5eb0070 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -41,15 +41,14 @@
  'x86_64', 'xtensa', 'xtensaeb' ] }
 
 ##
-# @CpuS390State:
+# @S390CpuState:
 #
 # An enumeration of cpu states that can be assumed by a virtual S390
 # CPU
 #
 # Since: 2.12
 ##
-{ 'enum': 'CpuS390State',
-  'prefix': 'S390_CPU_STATE',
+{ 'enum': 'S390CpuState',
   'data': [ 'uninitialized', 'stopped', 'check-stop', 'operating', 'load' ] }
 
 ##
@@ -66,9 +65,9 @@
 # Since: 2.12
 ##
 { 'struct': 'CpuInfoS390',
-  'data': { 'cpu-state': 'CpuS390State',
+  'data': { 'cpu-state': 'S390CpuState',
 '*dedicated': 'bool',
-'*entitlement': 'CpuS390Entitlement' } }
+'*entitlement': 'S390CpuEntitlement' } }
 
 ##
 # @CpuInfoFast:
diff --git a/qapi/pragma.json b/qapi/pragma.json
index 59fbe74b8c..fad3a31628 100644
--- a/qapi/pragma.json
+++ b/qapi/pragma.json
@@ -47,9 +47,6 @@
 'BlockdevSnapshotWrapper',
 

[PATCH v2 15/19] qapi/crypto: Rename QCryptoRSAPaddingAlgorithm to *Algo, and drop prefix

2024-09-04 Thread Markus Armbruster
QAPI's 'prefix' feature can make the connection between enumeration
type and its constants less than obvious.  It's best used with
restraint.

QCryptoRSAPaddingAlgorithm has a 'prefix' that overrides the generated
enumeration constants' prefix to QCRYPTO_RSA_PADDING_ALG.

We could simply drop 'prefix', but then the prefix becomes
QCRYPTO_RSA_PADDING_ALGORITHM, which is rather long.

We could additionally rename the type to QCryptoRSAPaddingAlg, but I
think the abbreviation "alg" is less than clear.

Rename the type to QCryptoRSAPaddingAlgo instead.  The prefix becomes
QCRYPTO_RSA_PADDING_ALGO.

Signed-off-by: Markus Armbruster 
Acked-by: Daniel P. Berrangé 
---
 qapi/crypto.json|  9 -
 backends/cryptodev-builtin.c|  6 +++---
 backends/cryptodev-lkcf.c   | 10 +-
 tests/bench/benchmark-crypto-akcipher.c | 12 ++--
 tests/unit/test-crypto-akcipher.c   | 10 +-
 crypto/akcipher-gcrypt.c.inc| 18 +-
 crypto/akcipher-nettle.c.inc| 18 +-
 7 files changed, 41 insertions(+), 42 deletions(-)

diff --git a/qapi/crypto.json b/qapi/crypto.json
index 331d49ebb8..867b09d322 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -608,7 +608,7 @@
   'data': ['public', 'private']}
 
 ##
-# @QCryptoRSAPaddingAlgorithm:
+# @QCryptoRSAPaddingAlgo:
 #
 # The padding algorithm for RSA.
 #
@@ -618,8 +618,7 @@
 #
 # Since: 7.1
 ##
-{ 'enum': 'QCryptoRSAPaddingAlgorithm',
-  'prefix': 'QCRYPTO_RSA_PADDING_ALG',
+{ 'enum': 'QCryptoRSAPaddingAlgo',
   'data': ['raw', 'pkcs1']}
 
 ##
@@ -629,13 +628,13 @@
 #
 # @hash-alg: QCryptoHashAlgo
 #
-# @padding-alg: QCryptoRSAPaddingAlgorithm
+# @padding-alg: QCryptoRSAPaddingAlgo
 #
 # Since: 7.1
 ##
 { 'struct': 'QCryptoAkCipherOptionsRSA',
   'data': { 'hash-alg':'QCryptoHashAlgo',
-'padding-alg': 'QCryptoRSAPaddingAlgorithm'}}
+'padding-alg': 'QCryptoRSAPaddingAlgo'}}
 
 ##
 # @QCryptoAkCipherOptions:
diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c
index d8b64091b6..6f3990481b 100644
--- a/backends/cryptodev-builtin.c
+++ b/backends/cryptodev-builtin.c
@@ -65,7 +65,7 @@ static void cryptodev_builtin_init_akcipher(CryptoDevBackend 
*backend)
 QCryptoAkCipherOptions opts;
 
 opts.alg = QCRYPTO_AK_CIPHER_ALGO_RSA;
-opts.u.rsa.padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW;
+opts.u.rsa.padding_alg = QCRYPTO_RSA_PADDING_ALGO_RAW;
 if (qcrypto_akcipher_supports(&opts)) {
 backend->conf.crypto_services |=
  (1u << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER);
@@ -200,12 +200,12 @@ static int cryptodev_builtin_set_rsa_options(
 return -1;
 }
 opt->hash_alg = hash_alg;
-opt->padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1;
+opt->padding_alg = QCRYPTO_RSA_PADDING_ALGO_PKCS1;
 return 0;
 }
 
 if (virtio_padding_algo == VIRTIO_CRYPTO_RSA_RAW_PADDING) {
-opt->padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW;
+opt->padding_alg = QCRYPTO_RSA_PADDING_ALGO_RAW;
 return 0;
 }
 
diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c
index 6fb6e03d98..fde32950f6 100644
--- a/backends/cryptodev-lkcf.c
+++ b/backends/cryptodev-lkcf.c
@@ -139,14 +139,14 @@ static int 
cryptodev_lkcf_set_op_desc(QCryptoAkCipherOptions *opts,
 }
 
 rsa_opt = &opts->u.rsa;
-if (rsa_opt->padding_alg == QCRYPTO_RSA_PADDING_ALG_PKCS1) {
+if (rsa_opt->padding_alg == QCRYPTO_RSA_PADDING_ALGO_PKCS1) {
 snprintf(key_desc, desc_len, "enc=%s hash=%s",
- QCryptoRSAPaddingAlgorithm_str(rsa_opt->padding_alg),
+ QCryptoRSAPaddingAlgo_str(rsa_opt->padding_alg),
  QCryptoHashAlgo_str(rsa_opt->hash_alg));
 
 } else {
 snprintf(key_desc, desc_len, "enc=%s",
- QCryptoRSAPaddingAlgorithm_str(rsa_opt->padding_alg));
+ QCryptoRSAPaddingAlgo_str(rsa_opt->padding_alg));
 }
 return 0;
 }
@@ -157,7 +157,7 @@ static int cryptodev_lkcf_set_rsa_opt(int 
virtio_padding_alg,
   Error **errp)
 {
 if (virtio_padding_alg == VIRTIO_CRYPTO_RSA_PKCS1_PADDING) {
-opt->padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1;
+opt->padding_alg = QCRYPTO_RSA_PADDING_ALGO_PKCS1;
 
 switch (virtio_hash_alg) {
 case VIRTIO_CRYPTO_RSA_MD5:
@@ -184,7 +184,7 @@ static int cryptodev_lkcf_set_rsa_opt(int 
virtio_padding_alg,
 }
 
 if (virtio_padding_alg == VIRTIO_CRYPTO_RSA_RAW_PADDING) {
-opt->padding_alg = QCRYPTO_RSA_PADD

[PATCH v2 14/19] qapi/crypto: Rename QCryptoAkCipherAlgorithm to *Algo, and drop prefix

2024-09-04 Thread Markus Armbruster
QAPI's 'prefix' feature can make the connection between enumeration
type and its constants less than obvious.  It's best used with
restraint.

QCryptoAkCipherAlgorithm has a 'prefix' that overrides the generated
enumeration constants' prefix to QCRYPTO_AKCIPHER_ALG.

We could simply drop 'prefix', but then the prefix becomes
QCRYPTO_AK_CIPHER_ALGORITHM, which is rather long.

We could additionally rename the type to QCryptoAkCipherAlg, but I
think the abbreviation "alg" is less than clear.

Rename the type to QCryptoAkCipherAlgo instead.  The prefix becomes
QCRYPTO_AK_CIPHER_ALGO.

Signed-off-by: Markus Armbruster 
Acked-by: Daniel P. Berrangé 
---
 qapi/crypto.json|  7 +++
 crypto/akcipherpriv.h   |  2 +-
 backends/cryptodev-builtin.c|  4 ++--
 backends/cryptodev-lkcf.c   |  4 ++--
 crypto/akcipher.c   |  2 +-
 tests/bench/benchmark-crypto-akcipher.c |  2 +-
 tests/unit/test-crypto-akcipher.c   | 10 +-
 crypto/akcipher-gcrypt.c.inc|  4 ++--
 crypto/akcipher-nettle.c.inc|  4 ++--
 9 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/qapi/crypto.json b/qapi/crypto.json
index 3e6a7fb8e5..331d49ebb8 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -586,7 +586,7 @@
 '*sanity-check': 'bool',
 '*passwordid': 'str' } }
 ##
-# @QCryptoAkCipherAlgorithm:
+# @QCryptoAkCipherAlgo:
 #
 # The supported algorithms for asymmetric encryption ciphers
 #
@@ -594,8 +594,7 @@
 #
 # Since: 7.1
 ##
-{ 'enum': 'QCryptoAkCipherAlgorithm',
-  'prefix': 'QCRYPTO_AKCIPHER_ALG',
+{ 'enum': 'QCryptoAkCipherAlgo',
   'data': ['rsa']}
 
 ##
@@ -649,6 +648,6 @@
 # Since: 7.1
 ##
 { 'union': 'QCryptoAkCipherOptions',
-  'base': { 'alg': 'QCryptoAkCipherAlgorithm' },
+  'base': { 'alg': 'QCryptoAkCipherAlgo' },
   'discriminator': 'alg',
   'data': { 'rsa': 'QCryptoAkCipherOptionsRSA' }}
diff --git a/crypto/akcipherpriv.h b/crypto/akcipherpriv.h
index 739f639bcf..3b33e54f08 100644
--- a/crypto/akcipherpriv.h
+++ b/crypto/akcipherpriv.h
@@ -27,7 +27,7 @@
 typedef struct QCryptoAkCipherDriver QCryptoAkCipherDriver;
 
 struct QCryptoAkCipher {
-QCryptoAkCipherAlgorithm alg;
+QCryptoAkCipherAlgo alg;
 QCryptoAkCipherKeyType type;
 int max_plaintext_len;
 int max_ciphertext_len;
diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c
index 2672755661..d8b64091b6 100644
--- a/backends/cryptodev-builtin.c
+++ b/backends/cryptodev-builtin.c
@@ -64,7 +64,7 @@ static void cryptodev_builtin_init_akcipher(CryptoDevBackend 
*backend)
 {
 QCryptoAkCipherOptions opts;
 
-opts.alg = QCRYPTO_AKCIPHER_ALG_RSA;
+opts.alg = QCRYPTO_AK_CIPHER_ALGO_RSA;
 opts.u.rsa.padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW;
 if (qcrypto_akcipher_supports(&opts)) {
 backend->conf.crypto_services |=
@@ -318,7 +318,7 @@ static int cryptodev_builtin_create_akcipher_session(
 
 switch (sess_info->algo) {
 case VIRTIO_CRYPTO_AKCIPHER_RSA:
-opts.alg = QCRYPTO_AKCIPHER_ALG_RSA;
+opts.alg = QCRYPTO_AK_CIPHER_ALGO_RSA;
 if (cryptodev_builtin_set_rsa_options(sess_info->u.rsa.padding_algo,
 sess_info->u.rsa.hash_algo, &opts.u.rsa, errp) != 0) {
 return -1;
diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c
index 6e6012e716..6fb6e03d98 100644
--- a/backends/cryptodev-lkcf.c
+++ b/backends/cryptodev-lkcf.c
@@ -133,7 +133,7 @@ static int 
cryptodev_lkcf_set_op_desc(QCryptoAkCipherOptions *opts,
   Error **errp)
 {
 QCryptoAkCipherOptionsRSA *rsa_opt;
-if (opts->alg != QCRYPTO_AKCIPHER_ALG_RSA) {
+if (opts->alg != QCRYPTO_AK_CIPHER_ALGO_RSA) {
 error_setg(errp, "Unsupported alg: %u", opts->alg);
 return -1;
 }
@@ -518,7 +518,7 @@ static int cryptodev_lkcf_create_asym_session(
 
 switch (sess_info->algo) {
 case VIRTIO_CRYPTO_AKCIPHER_RSA:
-sess->akcipher_opts.alg = QCRYPTO_AKCIPHER_ALG_RSA;
+sess->akcipher_opts.alg = QCRYPTO_AK_CIPHER_ALGO_RSA;
 if (cryptodev_lkcf_set_rsa_opt(
 sess_info->u.rsa.padding_algo, sess_info->u.rsa.hash_algo,
 &sess->akcipher_opts.u.rsa, &local_error) != 0) {
diff --git a/crypto/akcipher.c b/crypto/akcipher.c
index e4bbc6e5f1..0a0576b792 100644
--- a/crypto/akcipher.c
+++ b/crypto/akcipher.c
@@ -115,7 +115,7 @@ int qcrypto_akcipher_export_p8info(const 
QCryptoAkCipherOptions *opts,
Error **errp)
 {
 switch (opts->alg) {
-case QCRYPTO_AK

[PATCH v2 07/19] qapi/machine: Drop temporary 'prefix'

2024-09-04 Thread Markus Armbruster
Recent commit "qapi: Smarter camel_to_upper() to reduce need for
'prefix'" added a temporary 'prefix' to delay changing the generated
code.

Revert it.  This improves HmatLBDataType's generated enumeration
constant prefix from HMATLB_DATA_TYPE to HMAT_LB_DATA_TYPE, and
HmatLBMemoryHierarchy's from HMATLB_MEMORY_HIERARCHY to
HMAT_LB_MEMORY_HIERARCHY.

Signed-off-by: Markus Armbruster 
Reviewed-by: Zhao Liu 
---
 qapi/machine.json| 2 --
 hw/core/numa.c   | 4 ++--
 hw/pci-bridge/cxl_upstream.c | 4 ++--
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/qapi/machine.json b/qapi/machine.json
index 552d1c20e9..d4317435e7 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -686,7 +686,6 @@
 # Since: 5.0
 ##
 { 'enum': 'HmatLBMemoryHierarchy',
-  'prefix': 'HMATLB_MEMORY_HIERARCHY', # TODO drop
   'data': [ 'memory', 'first-level', 'second-level', 'third-level' ] }
 
 ##
@@ -713,7 +712,6 @@
 # Since: 5.0
 ##
 { 'enum': 'HmatLBDataType',
-  'prefix': 'HMATLB_DATA_TYPE', # TODO drop
   'data': [ 'access-latency', 'read-latency', 'write-latency',
 'access-bandwidth', 'read-bandwidth', 'write-bandwidth' ] }
 
diff --git a/hw/core/numa.c b/hw/core/numa.c
index f8ce332cfe..fb81c1ed51 100644
--- a/hw/core/numa.c
+++ b/hw/core/numa.c
@@ -249,7 +249,7 @@ void parse_numa_hmat_lb(NumaState *numa_state, 
NumaHmatLBOptions *node,
 lb_data.initiator = node->initiator;
 lb_data.target = node->target;
 
-if (node->data_type <= HMATLB_DATA_TYPE_WRITE_LATENCY) {
+if (node->data_type <= HMAT_LB_DATA_TYPE_WRITE_LATENCY) {
 /* Input latency data */
 
 if (!node->has_latency) {
@@ -313,7 +313,7 @@ void parse_numa_hmat_lb(NumaState *numa_state, 
NumaHmatLBOptions *node,
 numa_info[node->target].lb_info_provided |= BIT(0);
 }
 lb_data.data = node->latency;
-} else if (node->data_type >= HMATLB_DATA_TYPE_ACCESS_BANDWIDTH) {
+} else if (node->data_type >= HMAT_LB_DATA_TYPE_ACCESS_BANDWIDTH) {
 /* Input bandwidth data */
 if (!node->has_bandwidth) {
 error_setg(errp, "Missing 'bandwidth' option");
diff --git a/hw/pci-bridge/cxl_upstream.c b/hw/pci-bridge/cxl_upstream.c
index e51221a5f3..f3e46f0651 100644
--- a/hw/pci-bridge/cxl_upstream.c
+++ b/hw/pci-bridge/cxl_upstream.c
@@ -234,7 +234,7 @@ static int build_cdat_table(CDATSubHeader ***cdat_table, 
void *priv)
 .type = CDAT_TYPE_SSLBIS,
 .length = sslbis_size,
 },
-.data_type = HMATLB_DATA_TYPE_ACCESS_LATENCY,
+.data_type = HMAT_LB_DATA_TYPE_ACCESS_LATENCY,
 .entry_base_unit = 1,
 },
 };
@@ -254,7 +254,7 @@ static int build_cdat_table(CDATSubHeader ***cdat_table, 
void *priv)
 .type = CDAT_TYPE_SSLBIS,
 .length = sslbis_size,
 },
-.data_type = HMATLB_DATA_TYPE_ACCESS_BANDWIDTH,
+.data_type = HMAT_LB_DATA_TYPE_ACCESS_BANDWIDTH,
 .entry_base_unit = 1024,
 },
 };
-- 
2.46.0




[PATCH v2 06/19] qapi/ebpf: Drop temporary 'prefix'

2024-09-04 Thread Markus Armbruster
Recent commit "qapi: Smarter camel_to_upper() to reduce need for
'prefix'" added a temporary 'prefix' to delay changing the generated
code.

Revert it.  This improves EbpfProgramID's generated enumeration
constant prefix from EBPF_PROGRAMID to EBPF_PROGRAM_ID.

Signed-off-by: Markus Armbruster 
---
 qapi/ebpf.json  | 1 -
 ebpf/ebpf_rss.c | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/qapi/ebpf.json b/qapi/ebpf.json
index 42df548777..db19ae850f 100644
--- a/qapi/ebpf.json
+++ b/qapi/ebpf.json
@@ -42,7 +42,6 @@
 # Since: 9.0
 ##
 { 'enum': 'EbpfProgramID',
-  'prefix': 'EBPF_PROGRAMID',   # TODO drop
   'if': 'CONFIG_EBPF',
   'data': [ { 'name': 'rss' } ] }
 
diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c
index 87f0714910..dcaa80f380 100644
--- a/ebpf/ebpf_rss.c
+++ b/ebpf/ebpf_rss.c
@@ -271,4 +271,4 @@ void ebpf_rss_unload(struct EBPFRSSContext *ctx)
 ctx->map_indirections_table = -1;
 }
 
-ebpf_binary_init(EBPF_PROGRAMID_RSS, rss_bpf__elf_bytes)
+ebpf_binary_init(EBPF_PROGRAM_ID_RSS, rss_bpf__elf_bytes)
-- 
2.46.0




[PATCH v2 16/19] qapi/crypto: Rename QCryptoAFAlg to QCryptoAFAlgo

2024-09-04 Thread Markus Armbruster
For consistency with other types names *Algo.

Signed-off-by: Markus Armbruster 
Acked-by: Daniel P. Berrangé 
---
 crypto/afalgpriv.h| 14 +++---
 crypto/hmacpriv.h |  2 +-
 crypto/afalg.c|  8 
 crypto/cipher-afalg.c | 12 ++--
 crypto/hash-afalg.c   | 14 +++---
 5 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/crypto/afalgpriv.h b/crypto/afalgpriv.h
index 5a2393f1b7..3fdcc0f831 100644
--- a/crypto/afalgpriv.h
+++ b/crypto/afalgpriv.h
@@ -30,9 +30,9 @@
 #define ALG_OPTYPE_LEN 4
 #define ALG_MSGIV_LEN(len) (sizeof(struct af_alg_iv) + (len))
 
-typedef struct QCryptoAFAlg QCryptoAFAlg;
+typedef struct QCryptoAFAlgo QCryptoAFAlgo;
 
-struct QCryptoAFAlg {
+struct QCryptoAFAlgo {
 QCryptoCipher base;
 
 int tfmfd;
@@ -46,22 +46,22 @@ struct QCryptoAFAlg {
  * @type: the type of crypto operation
  * @name: the name of crypto operation
  *
- * Allocate a QCryptoAFAlg object and bind itself to
+ * Allocate a QCryptoAFAlgo object and bind itself to
  * a AF_ALG socket.
  *
  * Returns:
- *  a new QCryptoAFAlg object, or NULL in error.
+ *  a new QCryptoAFAlgo object, or NULL in error.
  */
-QCryptoAFAlg *
+QCryptoAFAlgo *
 qcrypto_afalg_comm_alloc(const char *type, const char *name,
  Error **errp);
 
 /**
  * afalg_comm_free:
- * @afalg: the QCryptoAFAlg object
+ * @afalg: the QCryptoAFAlgo object
  *
  * Free the @afalg.
  */
-void qcrypto_afalg_comm_free(QCryptoAFAlg *afalg);
+void qcrypto_afalg_comm_free(QCryptoAFAlgo *afalg);
 
 #endif
diff --git a/crypto/hmacpriv.h b/crypto/hmacpriv.h
index bd4c498c62..f339596bd9 100644
--- a/crypto/hmacpriv.h
+++ b/crypto/hmacpriv.h
@@ -37,7 +37,7 @@ extern QCryptoHmacDriver qcrypto_hmac_lib_driver;
 
 #include "afalgpriv.h"
 
-QCryptoAFAlg *qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgo alg,
+QCryptoAFAlgo *qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgo alg,
  const uint8_t *key, size_t nkey,
  Error **errp);
 extern QCryptoHmacDriver qcrypto_hmac_afalg_driver;
diff --git a/crypto/afalg.c b/crypto/afalg.c
index 52a491dbb5..246d0679d4 100644
--- a/crypto/afalg.c
+++ b/crypto/afalg.c
@@ -66,13 +66,13 @@ qcrypto_afalg_socket_bind(const char *type, const char 
*name,
 return sbind;
 }
 
-QCryptoAFAlg *
+QCryptoAFAlgo *
 qcrypto_afalg_comm_alloc(const char *type, const char *name,
  Error **errp)
 {
-QCryptoAFAlg *afalg;
+QCryptoAFAlgo *afalg;
 
-afalg = g_new0(QCryptoAFAlg, 1);
+afalg = g_new0(QCryptoAFAlgo, 1);
 /* initialize crypto API socket */
 afalg->opfd = -1;
 afalg->tfmfd = qcrypto_afalg_socket_bind(type, name, errp);
@@ -93,7 +93,7 @@ error:
 return NULL;
 }
 
-void qcrypto_afalg_comm_free(QCryptoAFAlg *afalg)
+void qcrypto_afalg_comm_free(QCryptoAFAlgo *afalg)
 {
 if (!afalg) {
 return;
diff --git a/crypto/cipher-afalg.c b/crypto/cipher-afalg.c
index c08eb7a39b..4980d419c4 100644
--- a/crypto/cipher-afalg.c
+++ b/crypto/cipher-afalg.c
@@ -65,7 +65,7 @@ qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgo alg,
  const uint8_t *key,
  size_t nkey, Error **errp)
 {
-QCryptoAFAlg *afalg;
+QCryptoAFAlgo *afalg;
 size_t expect_niv;
 char *name;
 
@@ -119,7 +119,7 @@ qcrypto_afalg_cipher_setiv(QCryptoCipher *cipher,
const uint8_t *iv,
size_t niv, Error **errp)
 {
-QCryptoAFAlg *afalg = container_of(cipher, QCryptoAFAlg, base);
+QCryptoAFAlgo *afalg = container_of(cipher, QCryptoAFAlgo, base);
 struct af_alg_iv *alg_iv;
 size_t expect_niv;
 
@@ -143,7 +143,7 @@ qcrypto_afalg_cipher_setiv(QCryptoCipher *cipher,
 }
 
 static int
-qcrypto_afalg_cipher_op(QCryptoAFAlg *afalg,
+qcrypto_afalg_cipher_op(QCryptoAFAlgo *afalg,
 const void *in, void *out,
 size_t len, bool do_encrypt,
 Error **errp)
@@ -202,7 +202,7 @@ qcrypto_afalg_cipher_encrypt(QCryptoCipher *cipher,
  const void *in, void *out,
  size_t len, Error **errp)
 {
-QCryptoAFAlg *afalg = container_of(cipher, QCryptoAFAlg, base);
+QCryptoAFAlgo *afalg = container_of(cipher, QCryptoAFAlgo, base);
 
 return qcrypto_afalg_cipher_op(afalg, in, out, len, true, errp);
 }
@@ -212,14 +212,14 @@ qcrypto_afalg_cipher_decrypt(QCryptoCipher *cipher,
  const void *in, void *out,
  size_t len, Error **errp)
 {
-QCryptoAFAlg *afalg = container_of(cipher, QCryptoAFAlg, base);
+QCryptoAFAlgo *afalg = container_of(cipher, QCryptoAFAlgo, base);
 
 return qcrypto_afalg_cipher_op(afalg, in, out, len, false, errp);
 }
 
 static void qcrypto_afalg_comm_ctx_free(QCryptoCipher *cipher)
 {
-QCryptoAFAlg *afalg = container_of(cipher, QC

[PATCH v2 08/19] qapi/ui: Drop temporary 'prefix'

2024-09-04 Thread Markus Armbruster
Recent commit "qapi: Smarter camel_to_upper() to reduce need for
'prefix'" added a temporary 'prefix' to delay changing the generated
code.

Revert it.  This improves DisplayGLMode's generated enumeration
constant prefix from DISPLAYGL_MODE to DISPLAY_GL_MODE.

Signed-off-by: Markus Armbruster 
---
 qapi/ui.json  |  1 -
 system/vl.c   |  2 +-
 ui/dbus.c |  8 
 ui/egl-context.c  |  2 +-
 ui/egl-headless.c |  2 +-
 ui/egl-helpers.c  | 12 ++--
 ui/gtk.c  |  4 ++--
 ui/sdl2-gl.c  |  8 
 ui/sdl2.c |  2 +-
 ui/spice-core.c   |  2 +-
 10 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/qapi/ui.json b/qapi/ui.json
index f61a2b6b65..460a26b981 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1397,7 +1397,6 @@
 # Since: 3.0
 ##
 { 'enum': 'DisplayGLMode',
-  'prefix'  : 'DISPLAYGL_MODE', # TODO drop
   'data': [ 'off', 'on', 'core', 'es' ] }
 
 ##
diff --git a/system/vl.c b/system/vl.c
index 01b8b8e77a..fe547ca47c 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -1971,7 +1971,7 @@ static void qemu_create_early_backends(void)
 
 qemu_console_early_init();
 
-if (dpy.has_gl && dpy.gl != DISPLAYGL_MODE_OFF && display_opengl == 0) {
+if (dpy.has_gl && dpy.gl != DISPLAY_GL_MODE_OFF && display_opengl == 0) {
 #if defined(CONFIG_OPENGL)
 error_report("OpenGL is not supported by display backend '%s'",
  DisplayType_str(dpy.type));
diff --git a/ui/dbus.c b/ui/dbus.c
index e08b5de064..7ecd39e784 100644
--- a/ui/dbus.c
+++ b/ui/dbus.c
@@ -176,7 +176,7 @@ dbus_display_add_console(DBusDisplay *dd, int idx, Error 
**errp)
 assert(con);
 
 if (qemu_console_is_graphic(con) &&
-dd->gl_mode != DISPLAYGL_MODE_OFF) {
+dd->gl_mode != DISPLAY_GL_MODE_OFF) {
 qemu_console_set_display_gl_ctx(con, &dd->glctx);
 }
 
@@ -466,9 +466,9 @@ static const TypeInfo dbus_vc_type_info = {
 static void
 early_dbus_init(DisplayOptions *opts)
 {
-DisplayGLMode mode = opts->has_gl ? opts->gl : DISPLAYGL_MODE_OFF;
+DisplayGLMode mode = opts->has_gl ? opts->gl : DISPLAY_GL_MODE_OFF;
 
-if (mode != DISPLAYGL_MODE_OFF) {
+if (mode != DISPLAY_GL_MODE_OFF) {
 #ifdef CONFIG_OPENGL
 egl_init(opts->u.dbus.rendernode, mode, &error_fatal);
 #else
@@ -482,7 +482,7 @@ early_dbus_init(DisplayOptions *opts)
 static void
 dbus_init(DisplayState *ds, DisplayOptions *opts)
 {
-DisplayGLMode mode = opts->has_gl ? opts->gl : DISPLAYGL_MODE_OFF;
+DisplayGLMode mode = opts->has_gl ? opts->gl : DISPLAY_GL_MODE_OFF;
 
 if (opts->u.dbus.addr && opts->u.dbus.p2p) {
 error_report("dbus: can't accept both addr=X and p2p=yes options");
diff --git a/ui/egl-context.c b/ui/egl-context.c
index 9e0df466f3..aed3e3ba1f 100644
--- a/ui/egl-context.c
+++ b/ui/egl-context.c
@@ -17,7 +17,7 @@ QEMUGLContext qemu_egl_create_context(DisplayGLCtx *dgc,
EGL_CONTEXT_MINOR_VERSION_KHR, params->minor_ver,
EGL_NONE
};
-   bool gles = (qemu_egl_mode == DISPLAYGL_MODE_ES);
+   bool gles = (qemu_egl_mode == DISPLAY_GL_MODE_ES);
 
ctx = eglCreateContext(qemu_egl_display, qemu_egl_config,
   eglGetCurrentContext(),
diff --git a/ui/egl-headless.c b/ui/egl-headless.c
index 6187249c73..1f6b845500 100644
--- a/ui/egl-headless.c
+++ b/ui/egl-headless.c
@@ -207,7 +207,7 @@ static const DisplayGLCtxOps eglctx_ops = {
 
 static void early_egl_headless_init(DisplayOptions *opts)
 {
-DisplayGLMode mode = DISPLAYGL_MODE_ON;
+DisplayGLMode mode = DISPLAY_GL_MODE_ON;
 
 if (opts->has_gl) {
 mode = opts->gl;
diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c
index 99b2ebbe23..81a57fa975 100644
--- a/ui/egl-helpers.c
+++ b/ui/egl-helpers.c
@@ -503,7 +503,7 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy,
 EGLint major, minor;
 EGLBoolean b;
 EGLint n;
-bool gles = (mode == DISPLAYGL_MODE_ES);
+bool gles = (mode == DISPLAY_GL_MODE_ES);
 
 qemu_egl_display = qemu_egl_get_display(dpy, platform);
 if (qemu_egl_display == EGL_NO_DISPLAY) {
@@ -533,7 +533,7 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy,
 return -1;
 }
 
-qemu_egl_mode = gles ? DISPLAYGL_MODE_ES : DISPLAYGL_MODE_CORE;
+qemu_egl_mode = gles ? DISPLAY_GL_MODE_ES : DISPLAY_GL_MODE_CORE;
 return 0;
 }
 
@@ -564,8 +564,8 @@ int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, 
DisplayGLMode mode)
 int qemu_egl_init_dpy_win32(EGLNativeDisplayType dpy, DisplayGLMode mode)
 {
 /* prefer GL ES, as that's what ANGLE supports */
-if (mode == DISPLAYGL_MODE_ON) {
-mode = DISPLAYGL_MODE_ES;
+if (mode == DISPLAY_GL_MODE_ON) {
+mode = DISPLAY_GL_M

[PATCH v2 01/19] qapi: Smarter camel_to_upper() to reduce need for 'prefix'

2024-09-04 Thread Markus Armbruster
Z_LIST_POLICY
QCryptoAkCipherAlgorithmQ_CRYPTO_AK_CIPHER_ALGORITHM
QCRYPTO_AK_CIPHER_ALGORITHM
QCRYPTO_AKCIPHER_ALG
QCryptoAkCipherKeyType  Q_CRYPTO_AK_CIPHER_KEY_TYPE
QCRYPTO_AK_CIPHER_KEY_TYPE
QCRYPTO_AKCIPHER_KEY_TYPE
QCryptoCipherAlgorithm  Q_CRYPTO_CIPHER_ALGORITHM
QCRYPTO_CIPHER_ALGORITHM
QCRYPTO_CIPHER_ALG
QCryptoHashAlgorithmQ_CRYPTO_HASH_ALGORITHM
QCRYPTO_HASH_ALGORITHM
QCRYPTO_HASH_ALG
QCryptoIVGenAlgorithm   Q_CRYPTOIV_GEN_ALGORITHM
QCRYPTO_IV_GEN_ALGORITHM
QCRYPTO_IVGEN_ALG
QCryptoRSAPaddingAlgorithm  Q_CRYPTORSA_PADDING_ALGORITHM
QCRYPTO_RSA_PADDING_ALGORITHM
QCRYPTO_RSA_PADDING_ALG
QCryptodevBackendAlgTypeQ_CRYPTODEV_BACKEND_ALG_TYPE
QCRYPTODEV_BACKEND_ALG_TYPE
QCRYPTODEV_BACKEND_ALG
QCryptodevBackendServiceTypeQ_CRYPTODEV_BACKEND_SERVICE_TYPE
QCRYPTODEV_BACKEND_SERVICE_TYPE
QCRYPTODEV_BACKEND_SERVICE

Subsequent commits will tweak things to remove most of these prefixes.
Only QAUTHZ_LIST_FORMAT and QAUTHZ_LIST_POLICY will remain.

Signed-off-by: Markus Armbruster 
Reviewed-by: Daniel P. Berrangé 
---
 qapi/block-core.json |  3 +-
 qapi/common.json |  1 +
 qapi/crypto.json |  6 ++--
 qapi/cryptodev.json  |  1 -
 qapi/ebpf.json   |  1 +
 qapi/machine.json|  2 ++
 qapi/migration.json  |  1 +
 qapi/ui.json |  2 ++
 scripts/qapi/common.py   | 42 ++--
 scripts/qapi/schema.py   |  2 +-
 tests/qapi-schema/alternate-array.out|  1 -
 tests/qapi-schema/comments.out   |  1 -
 tests/qapi-schema/doc-good.out   |  1 -
 tests/qapi-schema/empty.out  |  1 -
 tests/qapi-schema/include-repetition.out |  1 -
 tests/qapi-schema/include-simple.out |  1 -
 tests/qapi-schema/indented-expr.out  |  1 -
 tests/qapi-schema/qapi-schema-test.json  |  1 +
 tests/qapi-schema/qapi-schema-test.out   |  2 +-
 19 files changed, 38 insertions(+), 33 deletions(-)

diff --git a/qapi/block-core.json b/qapi/block-core.json
index aa40d44f1d..452047102a 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -2011,6 +2011,7 @@
 # Since: 4.0
 ##
 { 'enum': 'XDbgBlockGraphNodeType',
+  'prefix': 'X_DBG_BLOCK_GRAPH_NODE_TYPE', # TODO drop
   'data': [ 'block-backend', 'block-job', 'block-driver' ] }
 
 ##
@@ -3746,7 +3747,7 @@
 #
 # Since: 4.1
 ##
-{ 'enum': 'BlkdebugIOType', 'prefix': 'BLKDEBUG_IO_TYPE',
+{ 'enum': 'BlkdebugIOType',
   'data': [ 'read', 'write', 'write-zeroes', 'discard', 'flush',
 'block-status' ] }
 
diff --git a/qapi/common.json b/qapi/common.json
index 7558ce5430..25726d3113 100644
--- a/qapi/common.json
+++ b/qapi/common.json
@@ -92,6 +92,7 @@
 # Since: 2.12
 ##
 { 'enum': 'OffAutoPCIBAR',
+  'prefix': 'OFF_AUTOPCIBAR',   # TODO drop
   'data': [ 'off', 'auto', 'bar0', 'bar1', 'bar2', 'bar3', 'bar4', 'bar5' ] }
 
 ##
diff --git a/qapi/crypto.json b/qapi/crypto.json
index 97e02dbd59..a192641a03 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -20,7 +20,6 @@
 # Since: 2.5
 ##
 { 'enum': 'QCryptoTLSCredsEndpoint',
-  'prefix': 'QCRYPTO_TLS_CREDS_ENDPOINT',
   'data': ['client', 'server']}
 
 ##
@@ -36,7 +35,6 @@
 # Since: 2.6
 ##
 { 'enum': 'QCryptoSecretFormat',
-  'prefix': 'QCRYPTO_SECRET_FORMAT',
   'data': ['raw', 'base64']}
 
 ##
@@ -123,7 +121,6 @@
 # Since: 2.6
 ##
 { 'enum': 'QCryptoCipherMode',
-  'prefix': 'QCRYPTO_CIPHER_MODE',
   'data': ['ecb', 'cbc', 'xts', 'ctr']}
 
 ##
@@ -160,7 +157,7 @@
 # Since: 2.6
 ##
 { 'enum': 'QCryptoBlockFormat',
-#  'prefix': 'QCRYPTO_BLOCK_FORMAT',
+  'prefix': 'Q_CRYPTO_BLOCK_FORMAT', # TODO drop
   'data': ['qcow

[PATCH v2 19/19] qapi/vfio: Rename VfioMigrationState to Qapi*, and drop prefix

2024-09-04 Thread Markus Armbruster
QAPI's 'prefix' feature can make the connection between enumeration
type and its constants less than obvious.  It's best used with
restraint.

VfioMigrationState has a 'prefix' that overrides the generated
enumeration constants' prefix to QAPI_VFIO_MIGRATION_STATE.

We could simply drop 'prefix', but then the enumeration constants
would look as if they came from kernel header linux/vfio.h.

Rename the type to QapiVfioMigrationState instead, so that 'prefix' is
not needed.

Signed-off-by: Markus Armbruster 
---
 qapi/vfio.json  | 9 -
 hw/vfio/migration.c | 2 +-
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/qapi/vfio.json b/qapi/vfio.json
index eccca82068..b53b7caecd 100644
--- a/qapi/vfio.json
+++ b/qapi/vfio.json
@@ -7,7 +7,7 @@
 ##
 
 ##
-# @VfioMigrationState:
+# @QapiVfioMigrationState:
 #
 # An enumeration of the VFIO device migration states.
 #
@@ -32,10 +32,9 @@
 #
 # Since: 9.1
 ##
-{ 'enum': 'VfioMigrationState',
+{ 'enum': 'QapiVfioMigrationState',
   'data': [ 'stop', 'running', 'stop-copy', 'resuming', 'running-p2p',
-'pre-copy', 'pre-copy-p2p' ],
-  'prefix': 'QAPI_VFIO_MIGRATION_STATE' }
+'pre-copy', 'pre-copy-p2p' ] }
 
 ##
 # @VFIO_MIGRATION:
@@ -63,5 +62,5 @@
   'data': {
   'device-id': 'str',
   'qom-path': 'str',
-  'device-state': 'VfioMigrationState'
+  'device-state': 'QapiVfioMigrationState'
   } }
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index 262d42a46e..17199b73ae 100644
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -81,7 +81,7 @@ static const char *mig_state_to_str(enum 
vfio_device_mig_state state)
 }
 }
 
-static VfioMigrationState
+static QapiVfioMigrationState
 mig_state_to_qapi_state(enum vfio_device_mig_state state)
 {
 switch (state) {
-- 
2.46.0




[PATCH v2 02/19] tests/qapi-schema: Drop temporary 'prefix'

2024-09-04 Thread Markus Armbruster
Recent commit "qapi: Smarter camel_to_upper() to reduce need for
'prefix'" added a temporary 'prefix' to delay changing the generated
code.

Revert it.  This changes TestUnionEnumA's generated enumeration
constant prefix from TEST_UNION_ENUMA to TEST_UNION_ENUM_A.

Signed-off-by: Markus Armbruster 
Reviewed-by: Thomas Huth 
---
 tests/unit/test-qobject-input-visitor.c  | 4 ++--
 tests/unit/test-qobject-output-visitor.c | 4 ++--
 tests/qapi-schema/qapi-schema-test.json  | 1 -
 tests/qapi-schema/qapi-schema-test.out   | 1 -
 4 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/tests/unit/test-qobject-input-visitor.c 
b/tests/unit/test-qobject-input-visitor.c
index 024e26c49e..5479e68237 100644
--- a/tests/unit/test-qobject-input-visitor.c
+++ b/tests/unit/test-qobject-input-visitor.c
@@ -720,7 +720,7 @@ static void 
test_visitor_in_union_in_union(TestInputVisitorData *data,
 
 visit_type_TestUnionInUnion(v, NULL, &tmp, &error_abort);
 g_assert_cmpint(tmp->type, ==, TEST_UNION_ENUM_VALUE_A);
-g_assert_cmpint(tmp->u.value_a.type_a, ==, TEST_UNION_ENUMA_VALUE_A1);
+g_assert_cmpint(tmp->u.value_a.type_a, ==, TEST_UNION_ENUM_A_VALUE_A1);
 g_assert_cmpint(tmp->u.value_a.u.value_a1.integer, ==, 2);
 g_assert_cmpint(strcmp(tmp->u.value_a.u.value_a1.name, "fish"), ==, 0);
 
@@ -734,7 +734,7 @@ static void 
test_visitor_in_union_in_union(TestInputVisitorData *data,
 
 visit_type_TestUnionInUnion(v, NULL, &tmp, &error_abort);
 g_assert_cmpint(tmp->type, ==, TEST_UNION_ENUM_VALUE_A);
-g_assert_cmpint(tmp->u.value_a.type_a, ==, TEST_UNION_ENUMA_VALUE_A2);
+g_assert_cmpint(tmp->u.value_a.type_a, ==, TEST_UNION_ENUM_A_VALUE_A2);
 g_assert_cmpint(tmp->u.value_a.u.value_a2.integer, ==, 1729);
 g_assert_cmpint(tmp->u.value_a.u.value_a2.size, ==, 87539319);
 
diff --git a/tests/unit/test-qobject-output-visitor.c 
b/tests/unit/test-qobject-output-visitor.c
index 1535b3ad17..3455f3b107 100644
--- a/tests/unit/test-qobject-output-visitor.c
+++ b/tests/unit/test-qobject-output-visitor.c
@@ -359,7 +359,7 @@ static void 
test_visitor_out_union_in_union(TestOutputVisitorData *data,
 
 TestUnionInUnion *tmp = g_new0(TestUnionInUnion, 1);
 tmp->type = TEST_UNION_ENUM_VALUE_A;
-tmp->u.value_a.type_a = TEST_UNION_ENUMA_VALUE_A1;
+tmp->u.value_a.type_a = TEST_UNION_ENUM_A_VALUE_A1;
 tmp->u.value_a.u.value_a1.integer = 42;
 tmp->u.value_a.u.value_a1.name = g_strdup("fish");
 
@@ -377,7 +377,7 @@ static void 
test_visitor_out_union_in_union(TestOutputVisitorData *data,
 visitor_reset(data);
 tmp = g_new0(TestUnionInUnion, 1);
 tmp->type = TEST_UNION_ENUM_VALUE_A;
-tmp->u.value_a.type_a = TEST_UNION_ENUMA_VALUE_A2;
+tmp->u.value_a.type_a = TEST_UNION_ENUM_A_VALUE_A2;
 tmp->u.value_a.u.value_a2.integer = 1729;
 tmp->u.value_a.u.value_a2.size = 87539319;
 
diff --git a/tests/qapi-schema/qapi-schema-test.json 
b/tests/qapi-schema/qapi-schema-test.json
index 0f5f54e621..8ca977c49d 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -119,7 +119,6 @@
   'data': [ 'value-a', 'value-b' ] }
 
 { 'enum': 'TestUnionEnumA',
-  'prefix': 'TEST_UNION_ENUMA', # TODO drop
   'data': [ 'value-a1', 'value-a2' ] }
 
 { 'struct': 'TestUnionTypeA1',
diff --git a/tests/qapi-schema/qapi-schema-test.out 
b/tests/qapi-schema/qapi-schema-test.out
index add7346f49..4617eb4e98 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -108,7 +108,6 @@ enum TestUnionEnum
 member value-a
 member value-b
 enum TestUnionEnumA
-prefix TEST_UNION_ENUMA
 member value-a1
 member value-a2
 object TestUnionTypeA1
-- 
2.46.0




Re: [PULL 10/11] crypto: push error reporting into TLS session I/O APIs

2024-08-27 Thread Markus Armbruster
Daniel P. Berrangé  writes:

> On Mon, Aug 12, 2024 at 05:38:41PM +0200, Thomas Huth wrote:
>> On 24/07/2024 11.47, Daniel P. Berrangé wrote:
>> > The current TLS session I/O APIs just return a synthetic errno
>> > value on error, which has been translated from a gnutls error
>> > value. This looses a large amount of valuable information that
>> > distinguishes different scenarios.
>> > 
>> > Pushing population of the "Error *errp" object into the TLS
>> > session I/O APIs gives more detailed error information.
>> > 
>> > Reviewed-by: Philippe Mathieu-Daudé 
>> > Signed-off-by: Daniel P. Berrangé 
>> > ---
>> 
>>  Hi Daniel!
>> 
>> iotest 233 is failing for me with -raw now, and bisection
>> points to this commit. Output is:
>> 
>> --- .../qemu/tests/qemu-iotests/233.out
>> +++ /tmp/qemu/tests/qemu-iotests/scratch/raw-file-233/233.out.bad
>> @@ -69,8 +69,8 @@
>>  1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>> 
>>  == check TLS with authorization ==
>> -qemu-img: Could not open 
>> 'driver=nbd,host=127.0.0.1,port=PORT,tls-creds=tls0': Failed to read option 
>> reply: Cannot read from TLS channel: Software caused connection abort
>> -qemu-img: Could not open 
>> 'driver=nbd,host=127.0.0.1,port=PORT,tls-creds=tls0': Failed to read option 
>> reply: Cannot read from TLS channel: Software caused connection abort
>> +qemu-img: Could not open 
>> 'driver=nbd,host=127.0.0.1,port=PORT,tls-creds=tls0': Failed to read option 
>> reply: Cannot read from TLS channel: The TLS connection was non-properly 
>> terminated.
>> +qemu-img: Could not open 
>> 'driver=nbd,host=127.0.0.1,port=PORT,tls-creds=tls0': Failed to read option 
>> reply: Cannot read from TLS channel: The TLS connection was non-properly 
>> terminated.
>
> This is an expected change. Previously squashed the real GNUTLS error
> into ECONNABORTED:
>
> -case GNUTLS_E_PREMATURE_TERMINATION:
> -errno = ECONNABORTED;
> -break;
>
>
> now we report the original gnutls root cause.
>
> IOW, we need to update the expected output files.

Has this been done?




Re: [PATCH 01/18] qapi: Smarter camel_to_upper() to reduce need for 'prefix'

2024-08-09 Thread Markus Armbruster
Kevin Wolf  writes:

> Am 30.07.2024 um 10:10 hat Markus Armbruster geschrieben:
>> camel_to_upper() converts its argument from camel case to upper case
>> with '_' between words.  Used for generated enumeration constant
>> prefixes.
>> 
>> When some of the words are spelled all caps, where exactly to insert
>> '_' is guesswork.  camel_to_upper()'s guesses are bad enough in places
>> to make people override them with a 'prefix' in the schema.
>> 
>> Rewrite it to guess better:
>> 
>> 1. Insert '_' after a non-upper case character followed by an upper
>>case character:
>> 
>>OneTwo -> ONE_TWO
>>One2Three -> ONE2_THREE
>> 
>> 2. Insert '_' before the last upper case character followed by a
>>non-upper case character:
>> 
>>ACRONYMWord -> ACRONYM_Word
>> 
>>Except at the beginning (as in OneTwo above), or when there is
>>already one:
>> 
>>AbCd -> AB_CD
>
> Maybe it's just me, but the exception "at the beginning" (in the sense
> of "after the first character") seems to be exactly where I thought
> "that looks strange" while going through your list below.

By "except at the beginning", I mean don't map "One" to "_ONE".

>   In particular,
> I'd expect X_DBG_* instead of XDBG_*.

What's the intent of the X in the XDbgFOO types?  Signify unstable?

If yes: we don't do that elsewhere.  Type names are not part of the
external interface.  We never used an X prefix for names of unstable
types.  We use an x- prefix for names of unstable commands, arguments
and members, but even that is optional today.  Feature flag @unstable is
the source of truth.

The XDbgFOO appear to be used just by x-debug-query-block-graph, which
has feature @unstable.

If the XDBG name bothers you, we can strip the X prefix from the type
names.  Happy to do that in this series.

>   I also thought that the Q_*
> spelling made more sense, though this might be less clear.

The crypto subsystem spells its prefix qcrypto_, QCRYPTO_, and QCrypto.
Before this series, it forces QAPI to generate QCRYPTO_ with 'prefix'
with two exceptions, probably oversights.

>But in case
> of doubt, less exceptions seems like a good choice.

Agree.  I want to be able to predict generated names :)

>> +# Copy remainder of ``value`` to ``ret`` with '_' inserted
>> +for ch in value[1:]:
>> +if ch.isupper() == upc:
>> +pass
>> +elif upc:
>> +# ``ret`` ends in upper case, next char isn't: insert '_'
>> +# before the last upper case char unless there is one
>> +# already, or it's at the beginning
>> +if len(ret) > 2 and ret[-2] != '_':
>> +ret = ret[:-1] + '_' + ret[-1]
>
> I think in the code this means I would have expected len(ret) >= 2.

I'm not sure I understand what you mean.

With len(ret) > 2, we map "QType" to "QTYPE".

With len(ret) >= 2, we'd map it to "Q_TYPE".




Re: [PATCH 09/18] qapi/machine: Rename CpuS390* to S390Cpu, and drop 'prefix'

2024-08-09 Thread Markus Armbruster
Zhao Liu  writes:

> On Tue, Jul 30, 2024 at 10:10:23AM +0200, Markus Armbruster wrote:
>> Date: Tue, 30 Jul 2024 10:10:23 +0200
>> From: Markus Armbruster 
>> Subject: [PATCH 09/18] qapi/machine: Rename CpuS390* to S390Cpu, and drop
>>  'prefix'
>> 
>> QAPI's 'prefix' feature can make the connection between enumeration
>> type and its constants less than obvious.  It's best used with
>> restraint.
>> 
>> CpuS390Entitlement has a 'prefix' to change the generated enumeration
>> constants' prefix from CPU_S390_POLARIZATION to S390_CPU_POLARIZATION.
>  ^^
>CPU_S390_ENTITLEMENT S390_CPU_ENTITLEMENT

Yes.

>> Rename the type to S390CpuEntitlement, so that 'prefix' is not needed.
>> 
>> Likewise change CpuS390Polarization to S390CpuPolarization, and
>> CpuS390State to S390CpuState.
>> 
>> Signed-off-by: Markus Armbruster 
>> ---
>>  qapi/machine-common.json|  5 ++---
>>  qapi/machine-target.json| 11 +--
>>  qapi/machine.json   |  9 -
>>  qapi/pragma.json|  6 +++---
>>  include/hw/qdev-properties-system.h |  2 +-
>>  include/hw/s390x/cpu-topology.h |  2 +-
>>  target/s390x/cpu.h  |  2 +-
>>  hw/core/qdev-properties-system.c|  6 +++---
>>  hw/s390x/cpu-topology.c |  6 +++---
>>  9 files changed, 23 insertions(+), 26 deletions(-)
>
> [snip]
>
>> diff --git a/qapi/pragma.json b/qapi/pragma.json
>> index 59fbe74b8c..beddea5ca4 100644
>> --- a/qapi/pragma.json
>> +++ b/qapi/pragma.json
>> @@ -47,9 +47,9 @@
>>  'BlockdevSnapshotWrapper',
>>  'BlockdevVmdkAdapterType',
>>  'ChardevBackendKind',
>> -'CpuS390Entitlement',
>> -'CpuS390Polarization',
>> -'CpuS390State',
>> +'S390CpuEntitlement',
>> +'S390CpuPolarization',
>> +'S390CpuState',
>>  'CxlCorErrorType',
>>  'DisplayProtocol',
>>  'DriveBackupWrapper',
>
> It seems to be in alphabetical order. The new names don't follow the
> original order.

You're right.

> Just the above nits,
>
> Reviewed-by: Zhao Liu 

Thanks!




Re: [PATCH 1/2] util: Refactor json-writer's string sanitizer to be public

2024-08-08 Thread Markus Armbruster
Daniel P. Berrangé  writes:

> On Fri, Aug 02, 2024 at 02:26:05PM -0500, Eric Blake wrote:
>> My next patch needs to convert text from an untrusted input into an
>> output representation that is suitable for display on a terminal is
>> useful to more than just the json-writer; the text should normally be
>> UTF-8, but blindly allowing all Unicode code points (including ASCII
>> ESC) through to a terminal risks remote-code-execution attacks on some
>> terminals.  Extract the existing body of json-writer's quoted_strinto
>> a new helper routine mod_utf8_sanitize, and generalize it to also work
>> on data that is length-limited rather than NUL-terminated.  [I was
>> actually surprised that glib does not have such a sanitizer already -
>> Google turns up lots of examples of rolling your own string
>> sanitizer.]
>> 
>> If desired in the future, we may want to tweak whether the output is
>> guaranteed to be ASCII (using lots of \u escape sequences, including
>> surrogate pairs for code points outside the BMP) or if we are okay
>> passing printable Unicode through (we still need to escape control
>> characters).  But for now, I went for minimal code churn, including
>> the fact that the resulting function allows a non-UTF-8 2-byte synonym
>> for U+.
>> 
>> Signed-off-by: Eric Blake 
>> ---
>>  include/qemu/unicode.h |  3 ++
>>  qobject/json-writer.c  | 47 +--
>>  util/unicode.c | 84 ++
>>  3 files changed, 88 insertions(+), 46 deletions(-)
>
> I was going to ask for a unit test, but "escaped_string" in
> test-qjson.c  looks like it will be covering this sufficiently

check-qjson.c, and other test cases torture it some more.

> well already, that we don't need to test it in isolation.
>
> Reviewed-by: Daniel P. Berrangé 
>
>
> With regards,
> Daniel




Re: [PATCH 1/2] util: Refactor json-writer's string sanitizer to be public

2024-08-08 Thread Markus Armbruster
Eric Blake  writes:

> My next patch needs to convert text from an untrusted input into an
> output representation that is suitable for display on a terminal is
> useful to more than just the json-writer; the text should normally be
> UTF-8, but blindly allowing all Unicode code points (including ASCII
> ESC) through to a terminal risks remote-code-execution attacks on some
> terminals.  Extract the existing body of json-writer's quoted_strinto
> a new helper routine mod_utf8_sanitize, and generalize it to also work
> on data that is length-limited rather than NUL-terminated.

This is two changes in one patch: factor out, and generalize.

You don't actually use the generalized variant.  Please leave that for
later, and keep this patch simple.

> [I was
> actually surprised that glib does not have such a sanitizer already -
> Google turns up lots of examples of rolling your own string
> sanitizer.]
>
> If desired in the future, we may want to tweak whether the output is
> guaranteed to be ASCII (using lots of \u escape sequences, including
> surrogate pairs for code points outside the BMP) or if we are okay
> passing printable Unicode through (we still need to escape control
> characters).  But for now, I went for minimal code churn, including
> the fact that the resulting function allows a non-UTF-8 2-byte synonym
> for U+.
>
> Signed-off-by: Eric Blake 
> ---
>  include/qemu/unicode.h |  3 ++
>  qobject/json-writer.c  | 47 +--
>  util/unicode.c | 84 ++
>  3 files changed, 88 insertions(+), 46 deletions(-)
>
> diff --git a/include/qemu/unicode.h b/include/qemu/unicode.h
> index 7fa10b8e604..e1013b29f72 100644
> --- a/include/qemu/unicode.h
> +++ b/include/qemu/unicode.h
> @@ -4,4 +4,7 @@
>  int mod_utf8_codepoint(const char *s, size_t n, char **end);
>  ssize_t mod_utf8_encode(char buf[], size_t bufsz, int codepoint);
>
> +void mod_utf8_sanitize(GString *buf, const char *str);
> +void mod_utf8_sanitize_len(GString *buf, const char *str, ssize_t len);
> +
>  #endif
> diff --git a/qobject/json-writer.c b/qobject/json-writer.c
> index 309a31d57a9..5c14574efee 100644
> --- a/qobject/json-writer.c
> +++ b/qobject/json-writer.c
> @@ -104,53 +104,8 @@ static void pretty_newline_or_space(JSONWriter *writer)
>
>  static void quoted_str(JSONWriter *writer, const char *str)
>  {
> -const char *ptr;
> -char *end;
> -int cp;
> -
>  g_string_append_c(writer->contents, '"');
> -
> -for (ptr = str; *ptr; ptr = end) {
> -cp = mod_utf8_codepoint(ptr, 6, &end);
> -switch (cp) {
> -case '\"':
> -g_string_append(writer->contents, "\\\"");
> -break;
> -case '\\':
> -g_string_append(writer->contents, "");
> -break;
> -case '\b':
> -g_string_append(writer->contents, "\\b");
> -break;
> -case '\f':
> -g_string_append(writer->contents, "\\f");
> -break;
> -case '\n':
> -g_string_append(writer->contents, "\\n");
> -break;
> -case '\r':
> -g_string_append(writer->contents, "\\r");
> -break;
> -case '\t':
> -g_string_append(writer->contents, "\\t");
> -break;
> -default:
> -if (cp < 0) {
> -cp = 0xFFFD; /* replacement character */
> -}
> -if (cp > 0x) {
> -/* beyond BMP; need a surrogate pair */
> -g_string_append_printf(writer->contents, "\\u%04X\\u%04X",
> -   0xD800 + ((cp - 0x1) >> 10),
> -   0xDC00 + ((cp - 0x1) & 0x3FF));
> -} else if (cp < 0x20 || cp >= 0x7F) {
> -g_string_append_printf(writer->contents, "\\u%04X", cp);
> -} else {
> -g_string_append_c(writer->contents, cp);
> -}
> -}
> -};
> -
> +mod_utf8_sanitize(writer->contents, str);
>  g_string_append_c(writer->contents, '"');
>  }
>
> diff --git a/util/unicode.c b/util/unicode.c
> index 8580bc598b3..a419ed4de35 100644
> --- a/util/unicode.c
> +++ b/util/unicode.c
> @@ -154,3 +154,87 @@ ssize_t mod_utf8_encode(char buf[], size_t bufsz, int 
> codepoint)
>  buf[4] = 0;
>  return 4;
>  }
> +
> +/**
> + * mod_utf8_sanitize:
> + * @buf: Destination buffer
> + * @str: Modified UTF-8 string to sanitize
> + *
> + * Append the contents of the NUL-terminated Modified UTF-8 string
> + * @str into @buf, with escape sequences used for non-printable ASCII

"Append into" or "append to"?

> + * and for quote characters.  The result is therefore safe for output
> + * to a terminal.

Actually, we escape double quote, backslash, ASCII control characters,
and non-ASCII characters, i.e. we leave just printable ASCII characters
other tha

Re: [PATCH 11/18] qapi/crypto: Rename QCryptoHashAlgorithm to *Algo, and drop prefix

2024-08-02 Thread Markus Armbruster
Daniel P. Berrangé  writes:

> On Tue, Jul 30, 2024 at 02:26:49PM +0200, Markus Armbruster wrote:
>> Daniel P. Berrangé  writes:
>> 
>> > On Tue, Jul 30, 2024 at 10:10:25AM +0200, Markus Armbruster wrote:
>> >> QAPI's 'prefix' feature can make the connection between enumeration
>> >> type and its constants less than obvious.  It's best used with
>> >> restraint.
>> >> 
>> >> QCryptoHashAlgorithm has a 'prefix' that overrides the generated
>> >> enumeration constants' prefix to QCRYPTO_HASH_ALG.
>> >> 
>> >> We could simply drop 'prefix', but then the prefix becomes
>> >> QCRYPTO_HASH_ALGORITHM, which is rather long.
>> >> 
>> >> We could additionally rename the type to QCryptoHashAlg, but I think
>> >> the abbreviation "alg" is less than clear.
>> >
>> > I would have gone with this, but it is a bit of a bike shed colouring
>> > debate so I'm not fussed
>> 
>> Either solution seems okay, so I went with my personal preference.  Do
>> feel free to state yours and ask me to respin!
>
> After reviewing the patches that follow, I'd observe that picking
> Algo has made the following patches much larger than if it had
> stuck with Alg. Basically changing both the types & constants,
> instead of only having to change the types. 

Yes.  Worth the more obvious names to me, but again, feel free to ask me
to respin for less churn.




Re: [PATCH v2 6/7] qapi/block-core: derpecate block-job-change

2024-08-02 Thread Markus Armbruster
Typo in subject: it's "deprecate".




Re: [PATCH v2 6/7] qapi/block-core: derpecate block-job-change

2024-08-02 Thread Markus Armbruster
Vladimir Sementsov-Ogievskiy  writes:

> On 18.07.24 14:01, Markus Armbruster wrote:
>> Vladimir Sementsov-Ogievskiy  writes:
>> 
>>> That's a first step to move on newer job-* APIs.
>>>
>>> The difference between block-job-change and job-change is in
>>> find_block_job_locked() vs find_job_locked() functions. What's
>>> different?
>>>
>>> 1. find_block_job_locked() do check, is found job a block-job. This OK
>>
>> Do you mean something like find_block_job_locked() finds only block
>> jobs, whereas find_job_locked() finds any kind of job?
>
> Yes

Thanks!

>>> when moving to more generic API, no needs to document this change.
>>>
>>> 2. find_block_job_locked() reports DeviceNotActive on failure, when
>>>find_job_locked() reports GenericError. Still, for block-job-change
>>>errors are not documented at all, so be silent in deprecated.txt as
>>>well.
>>>
>>> Signed-off-by: Vladimir Sementsov-Ogievskiy 

Suggest:

1. find_block_job_locked() finds only block jobs, whereas
   find_job_locked() finds any kind of job.  job-change is a
   compatible extension of block-job-change.

2. find_block_job_locked() reports DeviceNotActive on failure, when
   find_job_locked() reports GenericError.  Since the kind of error
   reported isn't documented for either command, and clients
   shouldn't rely on undocumented error details, job-change is a
   compatible replacement for block-job-change.




Re: [PATCH for-9.2 v11 10/11] hw/pci: Use -1 as the default value for rombar

2024-08-02 Thread Markus Armbruster
Akihiko Odaki  writes:

> vfio_pci_size_rom() distinguishes whether rombar is explicitly set to 1
> by checking dev->opts, bypassing the QOM property infrastructure.
>
> Use -1 as the default value for rombar to tell if the user explicitly
> set it to 1. The property is also converted from unsigned to signed.
> -1 is signed so it is safe to give it a new meaning. The values in
> [2 ^ 31, 2 ^ 32) will be invalid, but nobody should have typed these
> values by chance.

s/will be/become invalid/

Should we document the change somewhere?  I'm not sure.  Opinions?

> Suggested-by: Markus Armbruster 
> Signed-off-by: Akihiko Odaki 
> ---
>  include/hw/pci/pci_device.h | 2 +-
>  hw/pci/pci.c| 2 +-
>  hw/vfio/pci.c   | 5 ++---
>  3 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h
> index 1ff3ce94e25b..8fa845beee5e 100644
> --- a/include/hw/pci/pci_device.h
> +++ b/include/hw/pci/pci_device.h
> @@ -148,7 +148,7 @@ struct PCIDevice {
>  uint32_t romsize;
>  bool has_rom;
>  MemoryRegion rom;
> -uint32_t rom_bar;
> +int32_t rom_bar;
>  
>  /* INTx routing notifier */
>  PCIINTxRoutingNotifier intx_routing_notifier;
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index 4c7be5295110..d2eaf0c51dde 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -71,7 +71,7 @@ static Property pci_props[] = {
>  DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
>  DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
>  DEFINE_PROP_UINT32("romsize", PCIDevice, romsize, UINT32_MAX),
> -DEFINE_PROP_UINT32("rombar",  PCIDevice, rom_bar, 1),
> +DEFINE_PROP_INT32("rombar",  PCIDevice, rom_bar, -1),
>  DEFINE_PROP_BIT("multifunction", PCIDevice, cap_present,
>  QEMU_PCI_CAP_MULTIFUNCTION_BITNR, false),
>  DEFINE_PROP_BIT("x-pcie-lnksta-dllla", PCIDevice, cap_present,
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index 2407720c3530..dc53837eac73 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -1012,7 +1012,6 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev)
>  {
>  uint32_t orig, size = cpu_to_le32((uint32_t)PCI_ROM_ADDRESS_MASK);
>  off_t offset = vdev->config_offset + PCI_ROM_ADDRESS;
> -DeviceState *dev = DEVICE(vdev);
>  char *name;
>  int fd = vdev->vbasedev.fd;
>  
> @@ -1046,12 +1045,12 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev)
>  }
>  
>  if (vfio_opt_rom_in_denylist(vdev)) {
> -if (dev->opts && qdict_haskey(dev->opts, "rombar")) {
> +if (vdev->pdev.rom_bar > 0) {
>  warn_report("Device at %s is known to cause system instability"
>  " issues during option rom execution",
>  vdev->vbasedev.name);
>  error_printf("Proceeding anyway since user specified"
> -     " non zero value for rombar\n");
> + " positive value for rombar\n");
>  } else {
>  warn_report("Rom loading for device at %s has been disabled"
>  " due to system instability issues",

Preferably with the commit message tweak:

Reviewed-by: Markus Armbruster 




Re: [PATCH v2 0/4] hw/pci: Convert rom_bar into OnOffAuto

2024-08-01 Thread Markus Armbruster
Akihiko Odaki  writes:

> On 2024/08/01 16:52, Michael S. Tsirkin wrote:
>> On Thu, Aug 01, 2024 at 04:01:44PM +0900, Akihiko Odaki wrote:
>>> rom_bar_set() and and underlying visit_type_str_preserving() are ugly, but
>>> we can remove them once the deprecation period ends. On the other hand, if
>>> we don't make this change, dev->opts will keep floating around, and we will
>>> even have another use of it for "[PATCH v5 1/8] hw/pci: Do not add ROM BAR
>>> for SR-IOV VF"[1]. Eventually, having this refactoring early will result in
>>> less mess in the future.
>>>
>>> [1]: lore.kernel.org/r/20240715-sriov-v5-1-3f5539093...@daynix.com
>> I don't know that this should worry us much. Is there some project that
>> requires getting rid of dev->opts for some reason?
>
> No, but I just thought it is too ugly to add a new reference to it for the 
> aforementioned patch, circumventing the visitor code and the QOM property.

Use of dev->opts is an ugly hack.  I'd love to get rid of it, if the
price is right.




Re: [PATCH v2 0/4] hw/pci: Convert rom_bar into OnOffAuto

2024-08-01 Thread Markus Armbruster
Akihiko Odaki  writes:

> On 2024/07/31 17:32, Markus Armbruster wrote:
>> Akihiko Odaki  writes:
>> 
>>> rom_bar is tristate but was defined as uint32_t so convert it into
>>> OnOffAuto to clarify that. For compatibility, a uint32 value set via
>>> QOM will be converted into OnOffAuto.
>>>
>>> Signed-off-by: Akihiko Odaki 
>> 
>> I agree making property "rombar" an integer was a design mistake.  I
>> further agree that vfio_pci_size_rom() peeking into dev->opts to
>> distinguish "user didn't set a value" from "user set the default value")
>> is an unadvisable hack.
>> 
>> However, ...
>> 
>>> ---
>>> Changes in v2:
>>> - Documented in docs/about/deprecated.rst (Daniel P. Berrangé)
>>> - Link to v1: 
>>> https://lore.kernel.org/r/20240706-rombar-v1-0-802daef2a...@daynix.com
>>>
>>> ---
>>> Akihiko Odaki (4):
>>>qapi: Add visit_type_str_preserving()
>>>qapi: Do not consume a value when visit_type_enum() fails
>>>hw/pci: Convert rom_bar into OnOffAuto
>>>hw/qdev: Remove opts member
>>>
>>>   docs/about/deprecated.rst |  7 +
>>>   docs/igd-assign.txt   |  2 +-
>>>   include/hw/pci/pci_device.h   |  2 +-
>>>   include/hw/qdev-core.h|  4 ---
>>>   include/qapi/visitor-impl.h   |  3 ++-
>>>   include/qapi/visitor.h| 25 +
>>>   hw/core/qdev.c|  1 -
>>>   hw/pci/pci.c  | 57 
>>> +--
>>>   hw/vfio/pci-quirks.c  |  2 +-
>>>   hw/vfio/pci.c | 11 
>>>   hw/xen/xen_pt_load_rom.c  |  4 +--
>>>   qapi/opts-visitor.c   | 12 -
>>>   qapi/qapi-clone-visitor.c |  2 +-
>>>   qapi/qapi-dealloc-visitor.c   |  4 +--
>>>   qapi/qapi-forward-visitor.c   |  4 ++-
>>>   qapi/qapi-visit-core.c| 21 ---
>>>   qapi/qobject-input-visitor.c  | 23 
>>>   qapi/qobject-output-visitor.c |  2 +-
>>>   qapi/string-input-visitor.c   |  2 +-
>>>   qapi/string-output-visitor.c  |  2 +-
>>>   system/qdev-monitor.c | 12 +
>>>   tests/qtest/virtio-net-failover.c | 32 +++---
>>>   22 files changed, 161 insertions(+), 73 deletions(-)
>>> ---
>>> base-commit: f2cb4026fccfe073f84a4b440e41d3ed0c3134f6
>>> change-id: 20240704-rombar-1a4ba2890d6c
>>>
>>> Best regards,
>> 
>> ... this is an awful lot of QAPI visitor infrastructure.  Infrastructure
>> that will likely only ever be used for this one property.
>> 
>> Moreover, the property setter rom_bar_set() is a hack: it first tries to
>> parse the value as enum, and if that fails, as uint32_t.  QAPI already
>> provides a way to express "either this type or that type": alternate.
>> Like this:
>> 
>>  { 'alternate': 'OnOffAutoUint32',
>>'data': { 'sym': 'OnOffAuto',
>>  'uint': 'uint32' } }
>> 
>> Unfortunately, such alternates don't work on the command line due to
>> keyval visitor restrictions.  These cannot be lifted entirely, but we
>> might be able to lift them sufficiently to make this alternate work.
>
> The keyval visitor cannot implement alternates because the command line 
> input does not have type information. For example, you cannot 
> distinguish string "0" and integer 0.

Correct.

For alternate types, an input visitor picks the branch based on the
QType.

With JSON, we have scalar types null, number, string, and bool.

With keyval, we only have string.  Alternates with more than one scalar
branch don't work.

They could be made to work to some degree, though.  Observe:

* Any value can be a string.

* "frob" can be nothing else.

* "on" and "off" can also be bool.

* "123" and "1e3" can also be number or enum.

Instead of picking the branch based on the QType, we could pick based on
QType and value, where the value part is delegated to a visitor method.

This is also new infrastructure.  But it's more generally useful
infrastructure.

>> Whether it would be worth your trouble and mine just to clean up
>> "rombar" seems highly dubious, though.
>
> rom_bar_set() and and underlying visit_type_str_preserving() are ugl

Re: [PATCH 5/7] hw/block/fdc-isa: Assert that isa_fdc_get_drive_max_chs() found something

2024-07-31 Thread Markus Armbruster
Peter Maydell  writes:

> Coverity complains about an overflow in isa_fdc_get_drive_max_chs()
> that can happen if the loop over fd_formats never finds a match,
> because we initialize *maxc to 0 and then at the end of the
> function decrement it.
>
> This can't ever actually happen because fd_formats has at least
> one entry for each FloppyDriveType, so we must at least once
> find a match and update *maxc, *maxh and *maxs. Assert that we
> did find a match, which should keep Coverity happy and will also
> detect possible bugs in the data in fd_formats.
>
> Resolves: Coverity CID 1547663
> Signed-off-by: Peter Maydell 
> ---
>  hw/block/fdc-isa.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/hw/block/fdc-isa.c b/hw/block/fdc-isa.c
> index e43dc532af8..796835f57b3 100644
> --- a/hw/block/fdc-isa.c
> +++ b/hw/block/fdc-isa.c
> @@ -147,6 +147,8 @@ static void isa_fdc_get_drive_max_chs(FloppyDriveType 
> type, uint8_t *maxc,
>  *maxs = fdf->last_sect;
>  }
>  }
> +/* fd_formats must contain at least one entry per FloppyDriveType */
> +assert(*maxc);
>  (*maxc)--;
>  }

Reviewed-by: Markus Armbruster 




Re: [PATCH 4/7] hw/ide/atapi: Be explicit that assigning to s->lcyl truncates

2024-07-31 Thread Markus Armbruster
Peter Maydell  writes:

> In ide_atapi_cmd_reply_end() we calculate a 16-bit size, and then
> assign its two halves to s->lcyl and s->hcyl like this:
>
>s->lcyl = size;
>s->hcyl = size >> 8;
>
> Coverity warns that the first line here can overflow the
> 8-bit s->lcyl variable. This is true, and in this case we're
> deliberately only after the low 8 bits of the value. The
> code is clearer to both humans and Coverity if we're explicit
> that we only wanted the low 8 bits, though.
>

Resolves?

> Signed-off-by: Peter Maydell 
> ---
>  hw/ide/atapi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c
> index fcb6cca1573..e82959dc2d3 100644
> --- a/hw/ide/atapi.c
> +++ b/hw/ide/atapi.c
> @@ -265,7 +265,7 @@ void ide_atapi_cmd_reply_end(IDEState *s)
   /* a new transfer is needed */
   s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO;
   ide_bus_set_irq(s->bus);
   byte_count_limit = atapi_byte_count_limit(s);
   trace_ide_atapi_cmd_reply_end_bcl(s, byte_count_limit);
   size = s->packet_transfer_size;
   if (size > byte_count_limit) {
   /* byte count limit must be even if this case */
   if (byte_count_limit & 1)
>  byte_count_limit--;
>  size = byte_count_limit;
>  }
> -s->lcyl = size;
> +s->lcyl = size & 0xff;
>  s->hcyl = size >> 8;
>  s->elementary_transfer_size = size;
>  /* we cannot transmit more than one sector at a time */

@size is int.  I wonder why it's fine with size >> 8...  ah,
atapi_byte_count_limit() returns uint16_t, and Coverity is smart enough
to data-flow this via @byte_count_limit into @size.

Reviewed-by: Markus Armbruster 




Re: [PATCH v2 0/4] hw/pci: Convert rom_bar into OnOffAuto

2024-07-31 Thread Markus Armbruster
Akihiko Odaki  writes:

> rom_bar is tristate but was defined as uint32_t so convert it into
> OnOffAuto to clarify that. For compatibility, a uint32 value set via
> QOM will be converted into OnOffAuto.
>
> Signed-off-by: Akihiko Odaki 

I agree making property "rombar" an integer was a design mistake.  I
further agree that vfio_pci_size_rom() peeking into dev->opts to
distinguish "user didn't set a value" from "user set the default value")
is an unadvisable hack.

However, ...

> ---
> Changes in v2:
> - Documented in docs/about/deprecated.rst (Daniel P. Berrangé)
> - Link to v1: 
> https://lore.kernel.org/r/20240706-rombar-v1-0-802daef2a...@daynix.com
>
> ---
> Akihiko Odaki (4):
>   qapi: Add visit_type_str_preserving()
>   qapi: Do not consume a value when visit_type_enum() fails
>   hw/pci: Convert rom_bar into OnOffAuto
>   hw/qdev: Remove opts member
>
>  docs/about/deprecated.rst |  7 +
>  docs/igd-assign.txt   |  2 +-
>  include/hw/pci/pci_device.h   |  2 +-
>  include/hw/qdev-core.h|  4 ---
>  include/qapi/visitor-impl.h   |  3 ++-
>  include/qapi/visitor.h| 25 +
>  hw/core/qdev.c|  1 -
>  hw/pci/pci.c  | 57 
> +--
>  hw/vfio/pci-quirks.c  |  2 +-
>  hw/vfio/pci.c | 11 
>  hw/xen/xen_pt_load_rom.c  |  4 +--
>  qapi/opts-visitor.c   | 12 -
>  qapi/qapi-clone-visitor.c |  2 +-
>  qapi/qapi-dealloc-visitor.c   |  4 +--
>  qapi/qapi-forward-visitor.c   |  4 ++-
>  qapi/qapi-visit-core.c| 21 ---
>  qapi/qobject-input-visitor.c  | 23 
>  qapi/qobject-output-visitor.c |  2 +-
>  qapi/string-input-visitor.c   |  2 +-
>  qapi/string-output-visitor.c  |  2 +-
>  system/qdev-monitor.c | 12 +
>  tests/qtest/virtio-net-failover.c | 32 +++---
>  22 files changed, 161 insertions(+), 73 deletions(-)
> ---
> base-commit: f2cb4026fccfe073f84a4b440e41d3ed0c3134f6
> change-id: 20240704-rombar-1a4ba2890d6c
>
> Best regards,

... this is an awful lot of QAPI visitor infrastructure.  Infrastructure
that will likely only ever be used for this one property.

Moreover, the property setter rom_bar_set() is a hack: it first tries to
parse the value as enum, and if that fails, as uint32_t.  QAPI already
provides a way to express "either this type or that type": alternate.
Like this:

{ 'alternate': 'OnOffAutoUint32',
  'data': { 'sym': 'OnOffAuto',
'uint': 'uint32' } }

Unfortunately, such alternates don't work on the command line due to
keyval visitor restrictions.  These cannot be lifted entirely, but we
might be able to lift them sufficiently to make this alternate work.

Whether it would be worth your trouble and mine just to clean up
"rombar" seems highly dubious, though.




Re: [PATCH 01/18] qapi: Smarter camel_to_upper() to reduce need for 'prefix'

2024-07-30 Thread Markus Armbruster
Avihai Horon  writes:

> On 31/07/2024 8:12, Markus Armbruster wrote:
>> External email: Use caution opening links or attachments
>>
>>
>> Avihai Horon  writes:
>>
>>> On 30/07/2024 15:22, Markus Armbruster wrote:
>>>> Avihai, there's a question for you on VfioMigrationState.
>>>>
>>>> Daniel P. Berrangé  writes:
>>>>
>>>>> On Tue, Jul 30, 2024 at 10:10:15AM +0200, Markus Armbruster wrote:
>> [...]
>>
>>>> * VfioMigrationState
>>>>
>>>> Can't see why this one has a prefix.  Avihai, can you enlighten me?
>>>
>>> linux-headers/linux/vfio.h defines enum vfio_device_mig_state with values 
>>> VFIO_DEVICE_STATE_STOP etc.
>>
>> It does not define any VFIO_DEVICE_STATE_*, though.
>>
>>> I used the QAPI prefix to emphasize this is a QAPI entity rather than a 
>>> VFIO entity.
>>
>> We define about two dozen symbols starting with VFIO_, and several
>> hundreds starting with vfio_.  What makes this enumeration type
>> different so its members need emphasis?
>
> Right. I thought it would be clearer with the QAPI prefix because 
> VFIO_DEVICE_STATE_* and VFIO_MIGRATION_STATE_* have similar values.
>
> But it's not a must. If you want to reduce prefix usage, go ahead, I don't 
> have a strong opinion about it.

Thanks!




Re: [PATCH 01/18] qapi: Smarter camel_to_upper() to reduce need for 'prefix'

2024-07-30 Thread Markus Armbruster
Avihai Horon  writes:

> On 30/07/2024 15:22, Markus Armbruster wrote:
>>
>> Avihai, there's a question for you on VfioMigrationState.
>>
>> Daniel P. Berrangé  writes:
>>
>>> On Tue, Jul 30, 2024 at 10:10:15AM +0200, Markus Armbruster wrote:

[...]

>> * VfioMigrationState
>>
>>Can't see why this one has a prefix.  Avihai, can you enlighten me?
>
> linux-headers/linux/vfio.h defines enum vfio_device_mig_state with values 
> VFIO_DEVICE_STATE_STOP etc.

It does not define any VFIO_DEVICE_STATE_*, though.

> I used the QAPI prefix to emphasize this is a QAPI entity rather than a VFIO 
> entity.

We define about two dozen symbols starting with VFIO_, and several
hundreds starting with vfio_.  What makes this enumeration type
different so its members need emphasis?

[...]




Re: [PATCH 11/18] qapi/crypto: Rename QCryptoHashAlgorithm to *Algo, and drop prefix

2024-07-30 Thread Markus Armbruster
Daniel P. Berrangé  writes:

> On Tue, Jul 30, 2024 at 10:10:25AM +0200, Markus Armbruster wrote:
>> QAPI's 'prefix' feature can make the connection between enumeration
>> type and its constants less than obvious.  It's best used with
>> restraint.
>> 
>> QCryptoHashAlgorithm has a 'prefix' that overrides the generated
>> enumeration constants' prefix to QCRYPTO_HASH_ALG.
>> 
>> We could simply drop 'prefix', but then the prefix becomes
>> QCRYPTO_HASH_ALGORITHM, which is rather long.
>> 
>> We could additionally rename the type to QCryptoHashAlg, but I think
>> the abbreviation "alg" is less than clear.
>
> I would have gone with this, but it is a bit of a bike shed colouring
> debate so I'm not fussed

Either solution seems okay, so I went with my personal preference.  Do
feel free to state yours and ask me to respin!

>> Rename the type to QCryptoHashAlgo instead.  The prefix becomes to
>> QCRYPTO_HASH_ALGO.
>> 
>> Signed-off-by: Markus Armbruster 
>> ---
>>  qapi/crypto.json| 17 +-
>>  crypto/blockpriv.h  |  2 +-
>>  crypto/hashpriv.h   |  2 +-
>>  crypto/hmacpriv.h   |  4 +--
>>  crypto/ivgenpriv.h  |  2 +-
>>  include/crypto/afsplit.h|  8 ++---
>>  include/crypto/block.h  |  2 +-
>>  include/crypto/hash.h   | 18 +-
>>  include/crypto/hmac.h   |  6 ++--
>>  include/crypto/ivgen.h  |  6 ++--
>>  include/crypto/pbkdf.h  | 10 +++---
>>  backends/cryptodev-builtin.c|  8 ++---
>>  backends/cryptodev-lkcf.c   | 10 +++---
>>  block/parallels-ext.c   |  2 +-
>>  block/quorum.c  |  4 +--
>>  crypto/afsplit.c|  6 ++--
>>  crypto/block-luks.c | 16 -
>>  crypto/block.c  |  2 +-
>>  crypto/hash-afalg.c | 26 +++
>>  crypto/hash-gcrypt.c| 20 +--
>>  crypto/hash-glib.c  | 20 +--
>>  crypto/hash-gnutls.c| 20 +--
>>  crypto/hash-nettle.c| 18 +-
>>  crypto/hash.c   | 30 -
>>  crypto/hmac-gcrypt.c| 22 ++---
>>  crypto/hmac-glib.c  | 22 ++---
>>  crypto/hmac-gnutls.c| 22 ++---
>>  crypto/hmac-nettle.c| 22 ++---
>>  crypto/hmac.c   |  2 +-
>>  crypto/ivgen.c  |  4 +--
>>  crypto/pbkdf-gcrypt.c   | 36 ++--
>>  crypto/pbkdf-gnutls.c   | 36 ++--
>>  crypto/pbkdf-nettle.c   | 32 +-
>>  crypto/pbkdf-stub.c |  4 +--
>>  crypto/pbkdf.c  |  2 +-
>>  hw/misc/aspeed_hace.c   | 16 -
>>  io/channel-websock.c|  2 +-
>>  target/i386/sev.c   |  6 ++--
>>  tests/bench/benchmark-crypto-akcipher.c | 12 +++
>>  tests/bench/benchmark-crypto-hash.c | 10 +++---
>>  tests/bench/benchmark-crypto-hmac.c |  6 ++--
>>  tests/unit/test-crypto-afsplit.c| 10 +++---
>>  tests/unit/test-crypto-akcipher.c   |  6 ++--
>>  tests/unit/test-crypto-block.c  | 16 -
>>  tests/unit/test-crypto-hash.c   | 42 +++
>>  tests/unit/test-crypto-hmac.c   | 16 -
>>  tests/unit/test-crypto-ivgen.c  |  8 ++---
>>  tests/unit/test-crypto-pbkdf.c  | 44 -
>>  ui/vnc.c|  2 +-
>>  util/hbitmap.c  |  2 +-
>>  crypto/akcipher-gcrypt.c.inc| 14 
>>  crypto/akcipher-nettle.c.inc| 26 +++
>>  52 files changed, 350 insertions(+), 351 deletions(-)
>
> Acked-by: Daniel P. Berrangé 

Thanks!




Re: [PATCH 01/18] qapi: Smarter camel_to_upper() to reduce need for 'prefix'

2024-07-30 Thread Markus Armbruster
Avihai, there's a question for you on VfioMigrationState.

Daniel P. Berrangé  writes:

> On Tue, Jul 30, 2024 at 10:10:15AM +0200, Markus Armbruster wrote:
>> camel_to_upper() converts its argument from camel case to upper case
>> with '_' between words.  Used for generated enumeration constant
>> prefixes.
>> 
>> When some of the words are spelled all caps, where exactly to insert
>> '_' is guesswork.  camel_to_upper()'s guesses are bad enough in places
>> to make people override them with a 'prefix' in the schema.
>> 
>> Rewrite it to guess better:
>> 
>> 1. Insert '_' after a non-upper case character followed by an upper
>>case character:
>> 
>>OneTwo -> ONE_TWO
>>One2Three -> ONE2_THREE
>> 
>> 2. Insert '_' before the last upper case character followed by a
>>non-upper case character:
>> 
>>ACRONYMWord -> ACRONYM_Word
>> 
>>Except at the beginning (as in OneTwo above), or when there is
>>already one:
>> 
>>AbCd -> AB_CD
>> 
>> This changes the default enumeration constant prefix for a number of
>> enums.  Generated enumeration constants change only where the default
>> is not overridden with 'prefix'.
>> 
>> The following enumerations without a 'prefix' change:
>> 
>> enum old camel_to_upper()
>>  new camel_to_upper()
>> --
>> DisplayGLMode   DISPLAYGL_MODE
>>  DISPLAY_GL_MODE
>> EbpfProgramID   EBPF_PROGRAMID
>>  EBPF_PROGRAM_ID
>> HmatLBDataType  HMATLB_DATA_TYPE
>>  HMAT_LB_DATA_TYPE
>> HmatLBMemoryHierarchy   HMATLB_MEMORY_HIERARCHY
>>  HMAT_LB_MEMORY_HIERARCHY
>> MultiFDCompression  MULTIFD_COMPRESSION
>>  MULTI_FD_COMPRESSION
>> OffAutoPCIBAR   OFF_AUTOPCIBAR
>>  OFF_AUTO_PCIBAR
>> QCryptoBlockFormat  Q_CRYPTO_BLOCK_FORMAT
>>  QCRYPTO_BLOCK_FORMAT
>> QCryptoBlockLUKSKeyslotStateQ_CRYPTO_BLOCKLUKS_KEYSLOT_STATE
>>  QCRYPTO_BLOCK_LUKS_KEYSLOT_STATE
>> QKeyCodeQ_KEY_CODE
>>  QKEY_CODE
>> XDbgBlockGraphNodeType  X_DBG_BLOCK_GRAPH_NODE_TYPE
>>  XDBG_BLOCK_GRAPH_NODE_TYPE
>> TestUnionEnumA   TEST_UNION_ENUMA
>>  TEST_UNION_ENUM_A
>> 
>> Add a 'prefix' so generated code doesn't change now.  Subsequent
>> commits will remove most of them again.  Two will remain:
>> MULTIFD_COMPRESSION, because migration code generally spells "multifd"
>> that way, and Q_KEY_CODE, because that one is baked into
>> subprojects/keycodemapdb/tools/keymap-gen.
>> 
>> The following enumerations with a 'prefix' change so that the prefix
>> is now superfluous:
>> 
>> enum old camel_to_upper()
>>  new camel_to_upper() [equal to prefix]
>> --
>> BlkdebugIOType  BLKDEBUGIO_TYPE
>>  BLKDEBUG_IO_TYPE
>> QCryptoTLSCredsEndpoint Q_CRYPTOTLS_CREDS_ENDPOINT
>>  QCRYPTO_TLS_CREDS_ENDPOINT
>> QCryptoSecretFormat Q_CRYPTO_SECRET_FORMAT
>>  QCRYPTO_SECRET_FORMAT
>> QCryptoCipherMode   Q_CRYPTO_CIPHER_MODE
>>  QCRYPTO_CIPHER_MODE
>> QCryptodevBackendType   Q_CRYPTODEV_BACKEND_TYPE
>>  QCRYPTODEV_BACKEND_TYPE
>> QType [builtin] Q_TYPE
>>  QTYPE
>> 
>> Drop these prefixes.
>> 
>> The following enumerations with a 'prefix' change without making the
>> 'prefix' superfluous:
>> 
>> enum old camel_to_upper()
>>  new camel_to_upper() [equal 

[PATCH 02/18] tests/qapi-schema: Drop temporary 'prefix'

2024-07-30 Thread Markus Armbruster
Recent commit "qapi: Smarter camel_to_upper() to reduce need for
'prefix'" added a temporary 'prefix' to delay changing the generated
code.

Revert it.  This changes TestUnionEnumA's generated enumeration
constant prefix from TEST_UNION_ENUMA to TEST_UNION_ENUM_A.

Signed-off-by: Markus Armbruster 
---
 tests/unit/test-qobject-input-visitor.c  | 4 ++--
 tests/unit/test-qobject-output-visitor.c | 4 ++--
 tests/qapi-schema/qapi-schema-test.json  | 1 -
 tests/qapi-schema/qapi-schema-test.out   | 1 -
 4 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/tests/unit/test-qobject-input-visitor.c 
b/tests/unit/test-qobject-input-visitor.c
index 024e26c49e..5479e68237 100644
--- a/tests/unit/test-qobject-input-visitor.c
+++ b/tests/unit/test-qobject-input-visitor.c
@@ -720,7 +720,7 @@ static void 
test_visitor_in_union_in_union(TestInputVisitorData *data,
 
 visit_type_TestUnionInUnion(v, NULL, &tmp, &error_abort);
 g_assert_cmpint(tmp->type, ==, TEST_UNION_ENUM_VALUE_A);
-g_assert_cmpint(tmp->u.value_a.type_a, ==, TEST_UNION_ENUMA_VALUE_A1);
+g_assert_cmpint(tmp->u.value_a.type_a, ==, TEST_UNION_ENUM_A_VALUE_A1);
 g_assert_cmpint(tmp->u.value_a.u.value_a1.integer, ==, 2);
 g_assert_cmpint(strcmp(tmp->u.value_a.u.value_a1.name, "fish"), ==, 0);
 
@@ -734,7 +734,7 @@ static void 
test_visitor_in_union_in_union(TestInputVisitorData *data,
 
 visit_type_TestUnionInUnion(v, NULL, &tmp, &error_abort);
 g_assert_cmpint(tmp->type, ==, TEST_UNION_ENUM_VALUE_A);
-g_assert_cmpint(tmp->u.value_a.type_a, ==, TEST_UNION_ENUMA_VALUE_A2);
+g_assert_cmpint(tmp->u.value_a.type_a, ==, TEST_UNION_ENUM_A_VALUE_A2);
 g_assert_cmpint(tmp->u.value_a.u.value_a2.integer, ==, 1729);
 g_assert_cmpint(tmp->u.value_a.u.value_a2.size, ==, 87539319);
 
diff --git a/tests/unit/test-qobject-output-visitor.c 
b/tests/unit/test-qobject-output-visitor.c
index 1535b3ad17..3455f3b107 100644
--- a/tests/unit/test-qobject-output-visitor.c
+++ b/tests/unit/test-qobject-output-visitor.c
@@ -359,7 +359,7 @@ static void 
test_visitor_out_union_in_union(TestOutputVisitorData *data,
 
 TestUnionInUnion *tmp = g_new0(TestUnionInUnion, 1);
 tmp->type = TEST_UNION_ENUM_VALUE_A;
-tmp->u.value_a.type_a = TEST_UNION_ENUMA_VALUE_A1;
+tmp->u.value_a.type_a = TEST_UNION_ENUM_A_VALUE_A1;
 tmp->u.value_a.u.value_a1.integer = 42;
 tmp->u.value_a.u.value_a1.name = g_strdup("fish");
 
@@ -377,7 +377,7 @@ static void 
test_visitor_out_union_in_union(TestOutputVisitorData *data,
 visitor_reset(data);
 tmp = g_new0(TestUnionInUnion, 1);
 tmp->type = TEST_UNION_ENUM_VALUE_A;
-tmp->u.value_a.type_a = TEST_UNION_ENUMA_VALUE_A2;
+tmp->u.value_a.type_a = TEST_UNION_ENUM_A_VALUE_A2;
 tmp->u.value_a.u.value_a2.integer = 1729;
 tmp->u.value_a.u.value_a2.size = 87539319;
 
diff --git a/tests/qapi-schema/qapi-schema-test.json 
b/tests/qapi-schema/qapi-schema-test.json
index 0f5f54e621..8ca977c49d 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -119,7 +119,6 @@
   'data': [ 'value-a', 'value-b' ] }
 
 { 'enum': 'TestUnionEnumA',
-  'prefix': 'TEST_UNION_ENUMA', # TODO drop
   'data': [ 'value-a1', 'value-a2' ] }
 
 { 'struct': 'TestUnionTypeA1',
diff --git a/tests/qapi-schema/qapi-schema-test.out 
b/tests/qapi-schema/qapi-schema-test.out
index add7346f49..4617eb4e98 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -108,7 +108,6 @@ enum TestUnionEnum
 member value-a
 member value-b
 enum TestUnionEnumA
-prefix TEST_UNION_ENUMA
 member value-a1
 member value-a2
 object TestUnionTypeA1
-- 
2.45.0




[PATCH 07/18] qapi/machine: Drop temporary 'prefix'

2024-07-30 Thread Markus Armbruster
Recent commit "qapi: Smarter camel_to_upper() to reduce need for
'prefix'" added a temporary 'prefix' to delay changing the generated
code.

Revert it.  This improves HmatLBDataType's generated enumeration
constant prefix from HMATLB_DATA_TYPE to HMAT_LB_DATA_TYPE.

Signed-off-by: Markus Armbruster 
---
 qapi/machine.json| 1 -
 hw/core/numa.c   | 4 ++--
 hw/pci-bridge/cxl_upstream.c | 4 ++--
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/qapi/machine.json b/qapi/machine.json
index 5514450e12..fcfd249e2d 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -712,7 +712,6 @@
 # Since: 5.0
 ##
 { 'enum': 'HmatLBDataType',
-  'prefix': 'HMATLB_DATA_TYPE', # TODO drop
   'data': [ 'access-latency', 'read-latency', 'write-latency',
 'access-bandwidth', 'read-bandwidth', 'write-bandwidth' ] }
 
diff --git a/hw/core/numa.c b/hw/core/numa.c
index f8ce332cfe..fb81c1ed51 100644
--- a/hw/core/numa.c
+++ b/hw/core/numa.c
@@ -249,7 +249,7 @@ void parse_numa_hmat_lb(NumaState *numa_state, 
NumaHmatLBOptions *node,
 lb_data.initiator = node->initiator;
 lb_data.target = node->target;
 
-if (node->data_type <= HMATLB_DATA_TYPE_WRITE_LATENCY) {
+if (node->data_type <= HMAT_LB_DATA_TYPE_WRITE_LATENCY) {
 /* Input latency data */
 
 if (!node->has_latency) {
@@ -313,7 +313,7 @@ void parse_numa_hmat_lb(NumaState *numa_state, 
NumaHmatLBOptions *node,
 numa_info[node->target].lb_info_provided |= BIT(0);
 }
 lb_data.data = node->latency;
-} else if (node->data_type >= HMATLB_DATA_TYPE_ACCESS_BANDWIDTH) {
+} else if (node->data_type >= HMAT_LB_DATA_TYPE_ACCESS_BANDWIDTH) {
 /* Input bandwidth data */
 if (!node->has_bandwidth) {
 error_setg(errp, "Missing 'bandwidth' option");
diff --git a/hw/pci-bridge/cxl_upstream.c b/hw/pci-bridge/cxl_upstream.c
index e51221a5f3..f3e46f0651 100644
--- a/hw/pci-bridge/cxl_upstream.c
+++ b/hw/pci-bridge/cxl_upstream.c
@@ -234,7 +234,7 @@ static int build_cdat_table(CDATSubHeader ***cdat_table, 
void *priv)
 .type = CDAT_TYPE_SSLBIS,
 .length = sslbis_size,
 },
-.data_type = HMATLB_DATA_TYPE_ACCESS_LATENCY,
+.data_type = HMAT_LB_DATA_TYPE_ACCESS_LATENCY,
 .entry_base_unit = 1,
 },
 };
@@ -254,7 +254,7 @@ static int build_cdat_table(CDATSubHeader ***cdat_table, 
void *priv)
 .type = CDAT_TYPE_SSLBIS,
 .length = sslbis_size,
 },
-.data_type = HMATLB_DATA_TYPE_ACCESS_BANDWIDTH,
+.data_type = HMAT_LB_DATA_TYPE_ACCESS_BANDWIDTH,
 .entry_base_unit = 1024,
 },
 };
-- 
2.45.0




[PATCH 18/18] qapi/cryptodev: Rename QCryptodevBackendAlgType to *Algo, and drop prefix

2024-07-30 Thread Markus Armbruster
QAPI's 'prefix' feature can make the connection between enumeration
type and its constants less than obvious.  It's best used with
restraint.

QCryptodevBackendAlgType a 'prefix' that overrides the generated
enumeration constants' prefix to QCRYPTODEV_BACKEND_ALG.

We could simply drop 'prefix', but I think the abbreviation "alg" is
less than clear.

Additionally rename the type to QCryptodevBackendAlgoType.  The prefix
becomes QCRYPTODEV_BACKEND_ALGO_TYPE.

Signed-off-by: Markus Armbruster 
---
 qapi/cryptodev.json  |  5 ++---
 include/sysemu/cryptodev.h   |  2 +-
 backends/cryptodev-builtin.c |  6 +++---
 backends/cryptodev-lkcf.c|  4 ++--
 backends/cryptodev.c |  6 +++---
 hw/virtio/virtio-crypto.c| 14 +++---
 6 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/qapi/cryptodev.json b/qapi/cryptodev.json
index 65abc16842..5e417340dc 100644
--- a/qapi/cryptodev.json
+++ b/qapi/cryptodev.json
@@ -9,7 +9,7 @@
 ##
 
 ##
-# @QCryptodevBackendAlgType:
+# @QCryptodevBackendAlgoType:
 #
 # The supported algorithm types of a crypto device.
 #
@@ -19,8 +19,7 @@
 #
 # Since: 8.0
 ##
-{ 'enum': 'QCryptodevBackendAlgType',
-  'prefix': 'QCRYPTODEV_BACKEND_ALG',
+{ 'enum': 'QCryptodevBackendAlgoType',
   'data': ['sym', 'asym']}
 
 ##
diff --git a/include/sysemu/cryptodev.h b/include/sysemu/cryptodev.h
index 96d3998b93..b20822df0d 100644
--- a/include/sysemu/cryptodev.h
+++ b/include/sysemu/cryptodev.h
@@ -178,7 +178,7 @@ typedef struct CryptoDevBackendAsymOpInfo {
 typedef void (*CryptoDevCompletionFunc) (void *opaque, int ret);
 
 typedef struct CryptoDevBackendOpInfo {
-QCryptodevBackendAlgType algtype;
+QCryptodevBackendAlgoType algtype;
 uint32_t op_code;
 uint32_t queue_index;
 CryptoDevCompletionFunc cb;
diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c
index 170c93a6be..b1486be630 100644
--- a/backends/cryptodev-builtin.c
+++ b/backends/cryptodev-builtin.c
@@ -549,7 +549,7 @@ static int cryptodev_builtin_operation(
 CryptoDevBackendBuiltinSession *sess;
 CryptoDevBackendSymOpInfo *sym_op_info;
 CryptoDevBackendAsymOpInfo *asym_op_info;
-QCryptodevBackendAlgType algtype = op_info->algtype;
+QCryptodevBackendAlgoType algtype = op_info->algtype;
 int status = -VIRTIO_CRYPTO_ERR;
 Error *local_error = NULL;
 
@@ -561,11 +561,11 @@ static int cryptodev_builtin_operation(
 }
 
 sess = builtin->sessions[op_info->session_id];
-if (algtype == QCRYPTODEV_BACKEND_ALG_SYM) {
+if (algtype == QCRYPTODEV_BACKEND_ALGO_TYPE_SYM) {
 sym_op_info = op_info->u.sym_op_info;
 status = cryptodev_builtin_sym_operation(sess, sym_op_info,
  &local_error);
-} else if (algtype == QCRYPTODEV_BACKEND_ALG_ASYM) {
+} else if (algtype == QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) {
 asym_op_info = op_info->u.asym_op_info;
 status = cryptodev_builtin_asym_operation(sess, op_info->op_code,
   asym_op_info, &local_error);
diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c
index 0dc4b067f5..38deac0717 100644
--- a/backends/cryptodev-lkcf.c
+++ b/backends/cryptodev-lkcf.c
@@ -474,7 +474,7 @@ static int cryptodev_lkcf_operation(
 CryptoDevBackendLKCF *lkcf =
 CRYPTODEV_BACKEND_LKCF(backend);
 CryptoDevBackendLKCFSession *sess;
-QCryptodevBackendAlgType algtype = op_info->algtype;
+QCryptodevBackendAlgoType algtype = op_info->algtype;
 CryptoDevLKCFTask *task;
 
 if (op_info->session_id >= MAX_SESSIONS ||
@@ -485,7 +485,7 @@ static int cryptodev_lkcf_operation(
 }
 
 sess = lkcf->sess[op_info->session_id];
-if (algtype != QCRYPTODEV_BACKEND_ALG_ASYM) {
+if (algtype != QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) {
 error_report("algtype not supported: %u", algtype);
 return -VIRTIO_CRYPTO_NOTSUPP;
 }
diff --git a/backends/cryptodev.c b/backends/cryptodev.c
index 76dfe65904..d8bd2a1ae6 100644
--- a/backends/cryptodev.c
+++ b/backends/cryptodev.c
@@ -185,10 +185,10 @@ static int cryptodev_backend_operation(
 static int cryptodev_backend_account(CryptoDevBackend *backend,
  CryptoDevBackendOpInfo *op_info)
 {
-enum QCryptodevBackendAlgType algtype = op_info->algtype;
+enum QCryptodevBackendAlgoType algtype = op_info->algtype;
 int len;
 
-if (algtype == QCRYPTODEV_BACKEND_ALG_ASYM) {
+if (algtype == QCRYPTODEV_BACKEND_ALGO_TYPE_ASYM) {
 CryptoDevBackendAsymOpInfo *asym_op_info = op_info->u.asym_op_info;
 len = asym_op_info->src_len;
 
@@ -212,7 +212,7 @@ static int cryptodev_backend_account(CryptoDevBackend 
*backend,
 default:
 retur

[PATCH 13/18] qapi/crypto: Rename QCryptoIVGenAlgorithm to *Algo, and drop prefix

2024-07-30 Thread Markus Armbruster
QAPI's 'prefix' feature can make the connection between enumeration
type and its constants less than obvious.  It's best used with
restraint.

QCryptoIVGenAlgorithm has a 'prefix' that overrides the generated
enumeration constants' prefix to QCRYPTO_IVGEN_ALG.

We could simply drop 'prefix', but then the prefix becomes
QCRYPTO_IV_GEN_ALGORITHM, which is rather long.

We could additionally rename the type to QCryptoIVGenAlg, but I think
the abbreviation "alg" is less than clear.

Rename the type to QCryptoIVGenAlgo instead.  The prefix becomes
QCRYPTO_IV_GEN_ALGO.

Signed-off-by: Markus Armbruster 
---
 qapi/crypto.json   |  9 -
 crypto/ivgenpriv.h |  2 +-
 include/crypto/ivgen.h | 14 +++---
 crypto/block-luks.c| 16 
 crypto/block-qcow.c|  2 +-
 crypto/ivgen.c | 10 +-
 tests/unit/test-crypto-block.c | 14 +++---
 tests/unit/test-crypto-ivgen.c | 22 +++---
 8 files changed, 44 insertions(+), 45 deletions(-)

diff --git a/qapi/crypto.json b/qapi/crypto.json
index 6ab44fc018..996853cecf 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -122,7 +122,7 @@
   'data': ['ecb', 'cbc', 'xts', 'ctr']}
 
 ##
-# @QCryptoIVGenAlgorithm:
+# @QCryptoIVGenAlgo:
 #
 # The supported algorithms for generating initialization vectors for
 # full disk encryption.  The 'plain' generator should not be used for
@@ -138,8 +138,7 @@
 #
 # Since: 2.6
 ##
-{ 'enum': 'QCryptoIVGenAlgorithm',
-  'prefix': 'QCRYPTO_IVGEN_ALG',
+{ 'enum': 'QCryptoIVGenAlgo',
   'data': ['plain', 'plain64', 'essiv']}
 
 ##
@@ -226,7 +225,7 @@
   'base': 'QCryptoBlockOptionsLUKS',
   'data': { '*cipher-alg': 'QCryptoCipherAlgo',
 '*cipher-mode': 'QCryptoCipherMode',
-'*ivgen-alg': 'QCryptoIVGenAlgorithm',
+'*ivgen-alg': 'QCryptoIVGenAlgo',
 '*ivgen-hash-alg': 'QCryptoHashAlgo',
 '*hash-alg': 'QCryptoHashAlgo',
 '*iter-time': 'int' }}
@@ -323,7 +322,7 @@
 { 'struct': 'QCryptoBlockInfoLUKS',
   'data': {'cipher-alg': 'QCryptoCipherAlgo',
'cipher-mode': 'QCryptoCipherMode',
-   'ivgen-alg': 'QCryptoIVGenAlgorithm',
+   'ivgen-alg': 'QCryptoIVGenAlgo',
'*ivgen-hash-alg': 'QCryptoHashAlgo',
'hash-alg': 'QCryptoHashAlgo',
'detached-header': 'bool',
diff --git a/crypto/ivgenpriv.h b/crypto/ivgenpriv.h
index ef24c76345..e3388d30be 100644
--- a/crypto/ivgenpriv.h
+++ b/crypto/ivgenpriv.h
@@ -40,7 +40,7 @@ struct QCryptoIVGen {
 QCryptoIVGenDriver *driver;
 void *private;
 
-QCryptoIVGenAlgorithm algorithm;
+QCryptoIVGenAlgo algorithm;
 QCryptoCipherAlgo cipher;
 QCryptoHashAlgo hash;
 };
diff --git a/include/crypto/ivgen.h b/include/crypto/ivgen.h
index b059e332cd..bfa5d28103 100644
--- a/include/crypto/ivgen.h
+++ b/include/crypto/ivgen.h
@@ -44,7 +44,7 @@
  *
  * g_assert((ndata % 512) == 0);
  *
- * QCryptoIVGen *ivgen = qcrypto_ivgen_new(QCRYPTO_IVGEN_ALG_ESSIV,
+ * QCryptoIVGen *ivgen = qcrypto_ivgen_new(QCRYPTO_IV_GEN_ALGO_ESSIV,
  * QCRYPTO_CIPHER_ALGO_AES_128,
  * QCRYPTO_HASH_ALGO_SHA256,
  * key, nkey, errp);
@@ -97,7 +97,7 @@
 
 typedef struct QCryptoIVGen QCryptoIVGen;
 
-/* See also QCryptoIVGenAlgorithm enum in qapi/crypto.json */
+/* See also QCryptoIVGenAlgo enum in qapi/crypto.json */
 
 
 /**
@@ -113,19 +113,19 @@ typedef struct QCryptoIVGen QCryptoIVGen;
  * are required or not depends on the choice of @alg
  * requested.
  *
- * - QCRYPTO_IVGEN_ALG_PLAIN
+ * - QCRYPTO_IV_GEN_ALGO_PLAIN
  *
  * The IVs are generated by the 32-bit truncated sector
  * number. This should never be used for block devices
  * that are larger than 2^32 sectors in size.
  * All the other parameters are unused.
  *
- * - QCRYPTO_IVGEN_ALG_PLAIN64
+ * - QCRYPTO_IV_GEN_ALGO_PLAIN64
  *
  * The IVs are generated by the 64-bit sector number.
  * All the other parameters are unused.
  *
- * - QCRYPTO_IVGEN_ALG_ESSIV:
+ * - QCRYPTO_IV_GEN_ALGO_ESSIV:
  *
  * The IVs are generated by encrypting the 64-bit sector
  * number with a hash of an encryption key. The @cipheralg,
@@ -133,7 +133,7 @@ typedef struct QCryptoIVGen QCryptoIVGen;
  *
  * Returns: a new IV generator, or NULL on error
  */
-QCryptoIVGen *qcrypto_ivgen_n

[PATCH 14/18] qapi/crypto: Rename QCryptoAkCipherAlgorithm to *Algo, and drop prefix

2024-07-30 Thread Markus Armbruster
QAPI's 'prefix' feature can make the connection between enumeration
type and its constants less than obvious.  It's best used with
restraint.

QCryptoAkCipherAlgorithm has a 'prefix' that overrides the generated
enumeration constants' prefix to QCRYPTO_AKCIPHER_ALG.

We could simply drop 'prefix', but then the prefix becomes
QCRYPTO_AK_CIPHER_ALGORITHM, which is rather long.

We could additionally rename the type to QCryptoAkCipherAlg, but I
think the abbreviation "alg" is less than clear.

Rename the type to QCryptoAkCipherAlgo instead.  The prefix becomes
QCRYPTO_AK_CIPHER_ALGO.

Signed-off-by: Markus Armbruster 
---
 qapi/crypto.json|  7 +++
 crypto/akcipherpriv.h   |  2 +-
 backends/cryptodev-builtin.c|  4 ++--
 backends/cryptodev-lkcf.c   |  4 ++--
 crypto/akcipher.c   |  2 +-
 tests/bench/benchmark-crypto-akcipher.c |  2 +-
 tests/unit/test-crypto-akcipher.c   | 10 +-
 crypto/akcipher-gcrypt.c.inc|  4 ++--
 crypto/akcipher-nettle.c.inc|  4 ++--
 9 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/qapi/crypto.json b/qapi/crypto.json
index 996853cecf..5ea16c69e0 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -586,7 +586,7 @@
 '*sanity-check': 'bool',
 '*passwordid': 'str' } }
 ##
-# @QCryptoAkCipherAlgorithm:
+# @QCryptoAkCipherAlgo:
 #
 # The supported algorithms for asymmetric encryption ciphers
 #
@@ -594,8 +594,7 @@
 #
 # Since: 7.1
 ##
-{ 'enum': 'QCryptoAkCipherAlgorithm',
-  'prefix': 'QCRYPTO_AKCIPHER_ALG',
+{ 'enum': 'QCryptoAkCipherAlgo',
   'data': ['rsa']}
 
 ##
@@ -649,6 +648,6 @@
 # Since: 7.1
 ##
 { 'union': 'QCryptoAkCipherOptions',
-  'base': { 'alg': 'QCryptoAkCipherAlgorithm' },
+  'base': { 'alg': 'QCryptoAkCipherAlgo' },
   'discriminator': 'alg',
   'data': { 'rsa': 'QCryptoAkCipherOptionsRSA' }}
diff --git a/crypto/akcipherpriv.h b/crypto/akcipherpriv.h
index 739f639bcf..3b33e54f08 100644
--- a/crypto/akcipherpriv.h
+++ b/crypto/akcipherpriv.h
@@ -27,7 +27,7 @@
 typedef struct QCryptoAkCipherDriver QCryptoAkCipherDriver;
 
 struct QCryptoAkCipher {
-QCryptoAkCipherAlgorithm alg;
+QCryptoAkCipherAlgo alg;
 QCryptoAkCipherKeyType type;
 int max_plaintext_len;
 int max_ciphertext_len;
diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c
index 2672755661..d8b64091b6 100644
--- a/backends/cryptodev-builtin.c
+++ b/backends/cryptodev-builtin.c
@@ -64,7 +64,7 @@ static void cryptodev_builtin_init_akcipher(CryptoDevBackend 
*backend)
 {
 QCryptoAkCipherOptions opts;
 
-opts.alg = QCRYPTO_AKCIPHER_ALG_RSA;
+opts.alg = QCRYPTO_AK_CIPHER_ALGO_RSA;
 opts.u.rsa.padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW;
 if (qcrypto_akcipher_supports(&opts)) {
 backend->conf.crypto_services |=
@@ -318,7 +318,7 @@ static int cryptodev_builtin_create_akcipher_session(
 
 switch (sess_info->algo) {
 case VIRTIO_CRYPTO_AKCIPHER_RSA:
-opts.alg = QCRYPTO_AKCIPHER_ALG_RSA;
+opts.alg = QCRYPTO_AK_CIPHER_ALGO_RSA;
 if (cryptodev_builtin_set_rsa_options(sess_info->u.rsa.padding_algo,
 sess_info->u.rsa.hash_algo, &opts.u.rsa, errp) != 0) {
 return -1;
diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c
index 6e6012e716..6fb6e03d98 100644
--- a/backends/cryptodev-lkcf.c
+++ b/backends/cryptodev-lkcf.c
@@ -133,7 +133,7 @@ static int 
cryptodev_lkcf_set_op_desc(QCryptoAkCipherOptions *opts,
   Error **errp)
 {
 QCryptoAkCipherOptionsRSA *rsa_opt;
-if (opts->alg != QCRYPTO_AKCIPHER_ALG_RSA) {
+if (opts->alg != QCRYPTO_AK_CIPHER_ALGO_RSA) {
 error_setg(errp, "Unsupported alg: %u", opts->alg);
 return -1;
 }
@@ -518,7 +518,7 @@ static int cryptodev_lkcf_create_asym_session(
 
 switch (sess_info->algo) {
 case VIRTIO_CRYPTO_AKCIPHER_RSA:
-sess->akcipher_opts.alg = QCRYPTO_AKCIPHER_ALG_RSA;
+sess->akcipher_opts.alg = QCRYPTO_AK_CIPHER_ALGO_RSA;
 if (cryptodev_lkcf_set_rsa_opt(
 sess_info->u.rsa.padding_algo, sess_info->u.rsa.hash_algo,
 &sess->akcipher_opts.u.rsa, &local_error) != 0) {
diff --git a/crypto/akcipher.c b/crypto/akcipher.c
index e4bbc6e5f1..0a0576b792 100644
--- a/crypto/akcipher.c
+++ b/crypto/akcipher.c
@@ -115,7 +115,7 @@ int qcrypto_akcipher_export_p8info(const 
QCryptoAkCipherOptions *opts,
Error **errp)
 {
 switch (opts->alg) {
-case QCRYPTO_AKCIPHER_ALG_RSA:
+case

[PATCH 08/18] qapi/ui: Drop temporary 'prefix'

2024-07-30 Thread Markus Armbruster
Recent commit "qapi: Smarter camel_to_upper() to reduce need for
'prefix'" added a temporary 'prefix' to delay changing the generated
code.

Revert it.  This improves DisplayGLMode's generated enumeration
constant prefix from DISPLAYGL_MODE to DISPLAY_GL_MODE.

Signed-off-by: Markus Armbruster 
---
 qapi/ui.json  |  1 -
 system/vl.c   |  2 +-
 ui/dbus.c |  8 
 ui/egl-context.c  |  2 +-
 ui/egl-headless.c |  2 +-
 ui/egl-helpers.c  | 12 ++--
 ui/gtk.c  |  4 ++--
 ui/sdl2-gl.c  |  8 
 ui/sdl2.c |  2 +-
 ui/spice-core.c   |  2 +-
 10 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/qapi/ui.json b/qapi/ui.json
index 31c42821f6..46dde390a7 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1396,7 +1396,6 @@
 # Since: 3.0
 ##
 { 'enum': 'DisplayGLMode',
-  'prefix'  : 'DISPLAYGL_MODE', # TODO drop
   'data': [ 'off', 'on', 'core', 'es' ] }
 
 ##
diff --git a/system/vl.c b/system/vl.c
index 9e8f16f155..706d2a6fd6 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -1971,7 +1971,7 @@ static void qemu_create_early_backends(void)
 
 qemu_console_early_init();
 
-if (dpy.has_gl && dpy.gl != DISPLAYGL_MODE_OFF && display_opengl == 0) {
+if (dpy.has_gl && dpy.gl != DISPLAY_GL_MODE_OFF && display_opengl == 0) {
 #if defined(CONFIG_OPENGL)
 error_report("OpenGL is not supported by the display");
 #else
diff --git a/ui/dbus.c b/ui/dbus.c
index e08b5de064..7ecd39e784 100644
--- a/ui/dbus.c
+++ b/ui/dbus.c
@@ -176,7 +176,7 @@ dbus_display_add_console(DBusDisplay *dd, int idx, Error 
**errp)
 assert(con);
 
 if (qemu_console_is_graphic(con) &&
-dd->gl_mode != DISPLAYGL_MODE_OFF) {
+dd->gl_mode != DISPLAY_GL_MODE_OFF) {
 qemu_console_set_display_gl_ctx(con, &dd->glctx);
 }
 
@@ -466,9 +466,9 @@ static const TypeInfo dbus_vc_type_info = {
 static void
 early_dbus_init(DisplayOptions *opts)
 {
-DisplayGLMode mode = opts->has_gl ? opts->gl : DISPLAYGL_MODE_OFF;
+DisplayGLMode mode = opts->has_gl ? opts->gl : DISPLAY_GL_MODE_OFF;
 
-if (mode != DISPLAYGL_MODE_OFF) {
+if (mode != DISPLAY_GL_MODE_OFF) {
 #ifdef CONFIG_OPENGL
 egl_init(opts->u.dbus.rendernode, mode, &error_fatal);
 #else
@@ -482,7 +482,7 @@ early_dbus_init(DisplayOptions *opts)
 static void
 dbus_init(DisplayState *ds, DisplayOptions *opts)
 {
-DisplayGLMode mode = opts->has_gl ? opts->gl : DISPLAYGL_MODE_OFF;
+DisplayGLMode mode = opts->has_gl ? opts->gl : DISPLAY_GL_MODE_OFF;
 
 if (opts->u.dbus.addr && opts->u.dbus.p2p) {
 error_report("dbus: can't accept both addr=X and p2p=yes options");
diff --git a/ui/egl-context.c b/ui/egl-context.c
index 9e0df466f3..aed3e3ba1f 100644
--- a/ui/egl-context.c
+++ b/ui/egl-context.c
@@ -17,7 +17,7 @@ QEMUGLContext qemu_egl_create_context(DisplayGLCtx *dgc,
EGL_CONTEXT_MINOR_VERSION_KHR, params->minor_ver,
EGL_NONE
};
-   bool gles = (qemu_egl_mode == DISPLAYGL_MODE_ES);
+   bool gles = (qemu_egl_mode == DISPLAY_GL_MODE_ES);
 
ctx = eglCreateContext(qemu_egl_display, qemu_egl_config,
   eglGetCurrentContext(),
diff --git a/ui/egl-headless.c b/ui/egl-headless.c
index 6187249c73..1f6b845500 100644
--- a/ui/egl-headless.c
+++ b/ui/egl-headless.c
@@ -207,7 +207,7 @@ static const DisplayGLCtxOps eglctx_ops = {
 
 static void early_egl_headless_init(DisplayOptions *opts)
 {
-DisplayGLMode mode = DISPLAYGL_MODE_ON;
+DisplayGLMode mode = DISPLAY_GL_MODE_ON;
 
 if (opts->has_gl) {
 mode = opts->gl;
diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c
index 99b2ebbe23..81a57fa975 100644
--- a/ui/egl-helpers.c
+++ b/ui/egl-helpers.c
@@ -503,7 +503,7 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy,
 EGLint major, minor;
 EGLBoolean b;
 EGLint n;
-bool gles = (mode == DISPLAYGL_MODE_ES);
+bool gles = (mode == DISPLAY_GL_MODE_ES);
 
 qemu_egl_display = qemu_egl_get_display(dpy, platform);
 if (qemu_egl_display == EGL_NO_DISPLAY) {
@@ -533,7 +533,7 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy,
 return -1;
 }
 
-qemu_egl_mode = gles ? DISPLAYGL_MODE_ES : DISPLAYGL_MODE_CORE;
+qemu_egl_mode = gles ? DISPLAY_GL_MODE_ES : DISPLAY_GL_MODE_CORE;
 return 0;
 }
 
@@ -564,8 +564,8 @@ int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, 
DisplayGLMode mode)
 int qemu_egl_init_dpy_win32(EGLNativeDisplayType dpy, DisplayGLMode mode)
 {
 /* prefer GL ES, as that's what ANGLE supports */
-if (mode == DISPLAYGL_MODE_ON) {
-mode = DISPLAYGL_MODE_ES;
+if (mode == DISPLAY_GL_MODE_ON) {
+mode = DISPLAY_GL_MODE_ES;
 }
 
 if (qemu_egl_init_dpy(dpy, 0, mod

[PATCH 17/18] qapi/cryptodev: Drop unwanted 'prefix'

2024-07-30 Thread Markus Armbruster
QAPI's 'prefix' feature can make the connection between enumeration
type and its constants less than obvious.  It's best used with
restraint.

QCryptodevBackendServiceType has a 'prefix' that overrides the
generated enumeration constants' prefix to QCRYPTODEV_BACKEND_SERVICE.

Drop it.  The prefix becomes QCRYPTODEV_BACKEND_SERVICE_TYPE.

Signed-off-by: Markus Armbruster 
---
 qapi/cryptodev.json |  1 -
 backends/cryptodev-builtin.c|  8 
 backends/cryptodev-lkcf.c   |  2 +-
 backends/cryptodev-vhost-user.c |  6 +++---
 backends/cryptodev.c|  6 +++---
 hw/virtio/virtio-crypto.c   | 10 +-
 6 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/qapi/cryptodev.json b/qapi/cryptodev.json
index 60f8fe8e4a..65abc16842 100644
--- a/qapi/cryptodev.json
+++ b/qapi/cryptodev.json
@@ -31,7 +31,6 @@
 # Since: 8.0
 ##
 { 'enum': 'QCryptodevBackendServiceType',
-  'prefix': 'QCRYPTODEV_BACKEND_SERVICE',
   'data': ['cipher', 'hash', 'mac', 'aead', 'akcipher']}
 
 ##
diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c
index 6f3990481b..170c93a6be 100644
--- a/backends/cryptodev-builtin.c
+++ b/backends/cryptodev-builtin.c
@@ -68,7 +68,7 @@ static void cryptodev_builtin_init_akcipher(CryptoDevBackend 
*backend)
 opts.u.rsa.padding_alg = QCRYPTO_RSA_PADDING_ALGO_RAW;
 if (qcrypto_akcipher_supports(&opts)) {
 backend->conf.crypto_services |=
- (1u << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER);
+ (1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_AKCIPHER);
 backend->conf.akcipher_algo = 1u << VIRTIO_CRYPTO_AKCIPHER_RSA;
 }
 }
@@ -93,9 +93,9 @@ static void cryptodev_builtin_init(
 backend->conf.peers.ccs[0] = cc;
 
 backend->conf.crypto_services =
- 1u << QCRYPTODEV_BACKEND_SERVICE_CIPHER |
- 1u << QCRYPTODEV_BACKEND_SERVICE_HASH |
- 1u << QCRYPTODEV_BACKEND_SERVICE_MAC;
+ 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_CIPHER |
+ 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_HASH |
+ 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_MAC;
 backend->conf.cipher_algo_l = 1u << VIRTIO_CRYPTO_CIPHER_AES_CBC;
 backend->conf.hash_algo = 1u << VIRTIO_CRYPTO_HASH_SHA1;
 /*
diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c
index fde32950f6..0dc4b067f5 100644
--- a/backends/cryptodev-lkcf.c
+++ b/backends/cryptodev-lkcf.c
@@ -230,7 +230,7 @@ static void cryptodev_lkcf_init(CryptoDevBackend *backend, 
Error **errp)
 backend->conf.peers.ccs[0] = cc;
 
 backend->conf.crypto_services =
-1u << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER;
+1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_AKCIPHER;
 backend->conf.akcipher_algo = 1u << VIRTIO_CRYPTO_AKCIPHER_RSA;
 lkcf->running = true;
 
diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-user.c
index c3283ba84a..e33fb78521 100644
--- a/backends/cryptodev-vhost-user.c
+++ b/backends/cryptodev-vhost-user.c
@@ -221,9 +221,9 @@ static void cryptodev_vhost_user_init(
  cryptodev_vhost_user_event, NULL, s, NULL, true);
 
 backend->conf.crypto_services =
- 1u << QCRYPTODEV_BACKEND_SERVICE_CIPHER |
- 1u << QCRYPTODEV_BACKEND_SERVICE_HASH |
- 1u << QCRYPTODEV_BACKEND_SERVICE_MAC;
+ 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_CIPHER |
+ 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_HASH |
+ 1u << QCRYPTODEV_BACKEND_SERVICE_TYPE_MAC;
 backend->conf.cipher_algo_l = 1u << VIRTIO_CRYPTO_CIPHER_AES_CBC;
 backend->conf.hash_algo = 1u << VIRTIO_CRYPTO_HASH_SHA1;
 
diff --git a/backends/cryptodev.c b/backends/cryptodev.c
index fff89fd62a..76dfe65904 100644
--- a/backends/cryptodev.c
+++ b/backends/cryptodev.c
@@ -74,7 +74,7 @@ static int qmp_query_cryptodev_foreach(Object *obj, void 
*data)
 
 backend = CRYPTODEV_BACKEND(obj);
 services = backend->conf.crypto_services;
-for (i = 0; i < QCRYPTODEV_BACKEND_SERVICE__MAX; i++) {
+for (i = 0; i < QCRYPTODEV_BACKEND_SERVICE_TYPE__MAX; i++) {
 if (services & (1 << i)) {
 QAPI_LIST_PREPEND(info->service, i);
 }
@@ -424,11 +424,11 @@ cryptodev_backend_complete(UserCreatable *uc, Error 
**errp)
 }
 
 services = backend->conf.crypto_services;
-if (services & (1 << QCRYPTODEV_BACKEND_SERVICE_CIPHER)) {
+if (services & (1 << QCRYPTODEV_BACKEND_SERVICE_TYPE_CIPHER)) {
 backend->sym_sta

[PATCH 11/18] qapi/crypto: Rename QCryptoHashAlgorithm to *Algo, and drop prefix

2024-07-30 Thread Markus Armbruster
QAPI's 'prefix' feature can make the connection between enumeration
type and its constants less than obvious.  It's best used with
restraint.

QCryptoHashAlgorithm has a 'prefix' that overrides the generated
enumeration constants' prefix to QCRYPTO_HASH_ALG.

We could simply drop 'prefix', but then the prefix becomes
QCRYPTO_HASH_ALGORITHM, which is rather long.

We could additionally rename the type to QCryptoHashAlg, but I think
the abbreviation "alg" is less than clear.

Rename the type to QCryptoHashAlgo instead.  The prefix becomes to
QCRYPTO_HASH_ALGO.

Signed-off-by: Markus Armbruster 
---
 qapi/crypto.json| 17 +-
 crypto/blockpriv.h  |  2 +-
 crypto/hashpriv.h   |  2 +-
 crypto/hmacpriv.h   |  4 +--
 crypto/ivgenpriv.h  |  2 +-
 include/crypto/afsplit.h|  8 ++---
 include/crypto/block.h  |  2 +-
 include/crypto/hash.h   | 18 +-
 include/crypto/hmac.h   |  6 ++--
 include/crypto/ivgen.h  |  6 ++--
 include/crypto/pbkdf.h  | 10 +++---
 backends/cryptodev-builtin.c|  8 ++---
 backends/cryptodev-lkcf.c   | 10 +++---
 block/parallels-ext.c   |  2 +-
 block/quorum.c  |  4 +--
 crypto/afsplit.c|  6 ++--
 crypto/block-luks.c | 16 -
 crypto/block.c  |  2 +-
 crypto/hash-afalg.c | 26 +++
 crypto/hash-gcrypt.c| 20 +--
 crypto/hash-glib.c  | 20 +--
 crypto/hash-gnutls.c| 20 +--
 crypto/hash-nettle.c| 18 +-
 crypto/hash.c   | 30 -
 crypto/hmac-gcrypt.c| 22 ++---
 crypto/hmac-glib.c  | 22 ++---
 crypto/hmac-gnutls.c| 22 ++---
 crypto/hmac-nettle.c| 22 ++---
 crypto/hmac.c   |  2 +-
 crypto/ivgen.c  |  4 +--
 crypto/pbkdf-gcrypt.c   | 36 ++--
 crypto/pbkdf-gnutls.c   | 36 ++--
 crypto/pbkdf-nettle.c   | 32 +-
 crypto/pbkdf-stub.c |  4 +--
 crypto/pbkdf.c  |  2 +-
 hw/misc/aspeed_hace.c   | 16 -
 io/channel-websock.c|  2 +-
 target/i386/sev.c   |  6 ++--
 tests/bench/benchmark-crypto-akcipher.c | 12 +++
 tests/bench/benchmark-crypto-hash.c | 10 +++---
 tests/bench/benchmark-crypto-hmac.c |  6 ++--
 tests/unit/test-crypto-afsplit.c| 10 +++---
 tests/unit/test-crypto-akcipher.c   |  6 ++--
 tests/unit/test-crypto-block.c  | 16 -
 tests/unit/test-crypto-hash.c   | 42 +++
 tests/unit/test-crypto-hmac.c   | 16 -
 tests/unit/test-crypto-ivgen.c  |  8 ++---
 tests/unit/test-crypto-pbkdf.c  | 44 -
 ui/vnc.c|  2 +-
 util/hbitmap.c  |  2 +-
 crypto/akcipher-gcrypt.c.inc| 14 
 crypto/akcipher-nettle.c.inc| 26 +++
 52 files changed, 350 insertions(+), 351 deletions(-)

diff --git a/qapi/crypto.json b/qapi/crypto.json
index aafb5d5c8d..76095b0833 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -38,7 +38,7 @@
   'data': ['raw', 'base64']}
 
 ##
-# @QCryptoHashAlgorithm:
+# @QCryptoHashAlgo:
 #
 # The supported algorithms for computing content digests
 #
@@ -58,8 +58,7 @@
 #
 # Since: 2.6
 ##
-{ 'enum': 'QCryptoHashAlgorithm',
-  'prefix': 'QCRYPTO_HASH_ALG',
+{ 'enum': 'QCryptoHashAlgo',
   'data': ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd160']}
 
 ##
@@ -229,8 +228,8 @@
   'data': { '*cipher-alg': 'QCryptoCipherAlgorithm',
 '*cipher-mode': 'QCryptoCipherMode',
 '*ivgen-alg': 'QCryptoIVGenAlgorithm',
-'*ivgen-hash-alg': 'QCryptoHashAlgorithm',
-'*hash-alg': 'QCryptoHashAlgorithm',
+'*ivgen-hash-alg': 'QCryptoHashAlgo',
+'*hash-alg': 'QCryptoHashAlgo',
 '*iter-time': 'int' }}
 
 ##
@@ -326,8 +325,8 @@
   'data': {'cipher-alg': 'QCryptoCipherAlgorithm',
'cipher-mode': &#

[PATCH 01/18] qapi: Smarter camel_to_upper() to reduce need for 'prefix'

2024-07-30 Thread Markus Armbruster
Z_LIST_POLICY
QCryptoAkCipherAlgorithmQ_CRYPTO_AK_CIPHER_ALGORITHM
QCRYPTO_AK_CIPHER_ALGORITHM
QCRYPTO_AKCIPHER_ALG
QCryptoAkCipherKeyType  Q_CRYPTO_AK_CIPHER_KEY_TYPE
QCRYPTO_AK_CIPHER_KEY_TYPE
QCRYPTO_AKCIPHER_KEY_TYPE
QCryptoCipherAlgorithm  Q_CRYPTO_CIPHER_ALGORITHM
QCRYPTO_CIPHER_ALGORITHM
QCRYPTO_CIPHER_ALG
QCryptoHashAlgorithmQ_CRYPTO_HASH_ALGORITHM
QCRYPTO_HASH_ALGORITHM
QCRYPTO_HASH_ALG
QCryptoIVGenAlgorithm   Q_CRYPTOIV_GEN_ALGORITHM
QCRYPTO_IV_GEN_ALGORITHM
QCRYPTO_IVGEN_ALG
QCryptoRSAPaddingAlgorithm  Q_CRYPTORSA_PADDING_ALGORITHM
QCRYPTO_RSA_PADDING_ALGORITHM
QCRYPTO_RSA_PADDING_ALG
QCryptodevBackendAlgTypeQ_CRYPTODEV_BACKEND_ALG_TYPE
QCRYPTODEV_BACKEND_ALG_TYPE
QCRYPTODEV_BACKEND_ALG
QCryptodevBackendServiceTypeQ_CRYPTODEV_BACKEND_SERVICE_TYPE
QCRYPTODEV_BACKEND_SERVICE_TYPE
QCRYPTODEV_BACKEND_SERVICE

Subsequent commits will tweak things to remove most of these prefixes.
Only QAUTHZ_LIST_FORMAT and QAUTHZ_LIST_POLICY will remain.

Signed-off-by: Markus Armbruster 
---
 qapi/block-core.json |  3 +-
 qapi/common.json |  1 +
 qapi/crypto.json |  6 ++--
 qapi/cryptodev.json  |  1 -
 qapi/ebpf.json   |  1 +
 qapi/machine.json|  1 +
 qapi/migration.json  |  1 +
 qapi/ui.json |  2 ++
 scripts/qapi/common.py   | 42 ++--
 scripts/qapi/schema.py   |  2 +-
 tests/qapi-schema/alternate-array.out|  1 -
 tests/qapi-schema/comments.out   |  1 -
 tests/qapi-schema/doc-good.out   |  1 -
 tests/qapi-schema/empty.out  |  1 -
 tests/qapi-schema/include-repetition.out |  1 -
 tests/qapi-schema/include-simple.out |  1 -
 tests/qapi-schema/indented-expr.out  |  1 -
 tests/qapi-schema/qapi-schema-test.json  |  1 +
 tests/qapi-schema/qapi-schema-test.out   |  2 +-
 19 files changed, 37 insertions(+), 33 deletions(-)

diff --git a/qapi/block-core.json b/qapi/block-core.json
index f400b334c8..897bc7e0e7 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -2011,6 +2011,7 @@
 # Since: 4.0
 ##
 { 'enum': 'XDbgBlockGraphNodeType',
+  'prefix': 'X_DBG_BLOCK_GRAPH_NODE_TYPE', # TODO drop
   'data': [ 'block-backend', 'block-job', 'block-driver' ] }
 
 ##
@@ -3746,7 +3747,7 @@
 #
 # Since: 4.1
 ##
-{ 'enum': 'BlkdebugIOType', 'prefix': 'BLKDEBUG_IO_TYPE',
+{ 'enum': 'BlkdebugIOType',
   'data': [ 'read', 'write', 'write-zeroes', 'discard', 'flush',
 'block-status' ] }
 
diff --git a/qapi/common.json b/qapi/common.json
index 7558ce5430..25726d3113 100644
--- a/qapi/common.json
+++ b/qapi/common.json
@@ -92,6 +92,7 @@
 # Since: 2.12
 ##
 { 'enum': 'OffAutoPCIBAR',
+  'prefix': 'OFF_AUTOPCIBAR',   # TODO drop
   'data': [ 'off', 'auto', 'bar0', 'bar1', 'bar2', 'bar3', 'bar4', 'bar5' ] }
 
 ##
diff --git a/qapi/crypto.json b/qapi/crypto.json
index 39b191e8a2..e2d77c3fb3 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -20,7 +20,6 @@
 # Since: 2.5
 ##
 { 'enum': 'QCryptoTLSCredsEndpoint',
-  'prefix': 'QCRYPTO_TLS_CREDS_ENDPOINT',
   'data': ['client', 'server']}
 
 ##
@@ -36,7 +35,6 @@
 # Since: 2.6
 ##
 { 'enum': 'QCryptoSecretFormat',
-  'prefix': 'QCRYPTO_SECRET_FORMAT',
   'data': ['raw', 'base64']}
 
 ##
@@ -123,7 +121,6 @@
 # Since: 2.6
 ##
 { 'enum': 'QCryptoCipherMode',
-  'prefix': 'QCRYPTO_CIPHER_MODE',
   'data': ['ecb', 'cbc', 'xts', 'ctr']}
 
 ##
@@ -160,7 +157,7 @@
 # Since: 2.6
 ##
 { 'enum': 'QCryptoBlockFormat',
-#  'prefix': 'QCRYPTO_BLOCK_FORMAT',
+  'prefix': 'Q_CRYPTO_BLOCK_FORMAT', # TODO drop
   'data': ['qcow', 'luks']}
 
 ##
@

[PATCH 16/18] qapi/crypto: Rename QCryptoAFAlg to QCryptoAFAlgo

2024-07-30 Thread Markus Armbruster
For consistency with other types names *Algo.

Signed-off-by: Markus Armbruster 
---
 crypto/afalgpriv.h| 14 +++---
 crypto/hmacpriv.h |  2 +-
 crypto/afalg.c|  8 
 crypto/cipher-afalg.c | 12 ++--
 crypto/hash-afalg.c   | 14 +++---
 5 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/crypto/afalgpriv.h b/crypto/afalgpriv.h
index 5a2393f1b7..3fdcc0f831 100644
--- a/crypto/afalgpriv.h
+++ b/crypto/afalgpriv.h
@@ -30,9 +30,9 @@
 #define ALG_OPTYPE_LEN 4
 #define ALG_MSGIV_LEN(len) (sizeof(struct af_alg_iv) + (len))
 
-typedef struct QCryptoAFAlg QCryptoAFAlg;
+typedef struct QCryptoAFAlgo QCryptoAFAlgo;
 
-struct QCryptoAFAlg {
+struct QCryptoAFAlgo {
 QCryptoCipher base;
 
 int tfmfd;
@@ -46,22 +46,22 @@ struct QCryptoAFAlg {
  * @type: the type of crypto operation
  * @name: the name of crypto operation
  *
- * Allocate a QCryptoAFAlg object and bind itself to
+ * Allocate a QCryptoAFAlgo object and bind itself to
  * a AF_ALG socket.
  *
  * Returns:
- *  a new QCryptoAFAlg object, or NULL in error.
+ *  a new QCryptoAFAlgo object, or NULL in error.
  */
-QCryptoAFAlg *
+QCryptoAFAlgo *
 qcrypto_afalg_comm_alloc(const char *type, const char *name,
  Error **errp);
 
 /**
  * afalg_comm_free:
- * @afalg: the QCryptoAFAlg object
+ * @afalg: the QCryptoAFAlgo object
  *
  * Free the @afalg.
  */
-void qcrypto_afalg_comm_free(QCryptoAFAlg *afalg);
+void qcrypto_afalg_comm_free(QCryptoAFAlgo *afalg);
 
 #endif
diff --git a/crypto/hmacpriv.h b/crypto/hmacpriv.h
index bd4c498c62..f339596bd9 100644
--- a/crypto/hmacpriv.h
+++ b/crypto/hmacpriv.h
@@ -37,7 +37,7 @@ extern QCryptoHmacDriver qcrypto_hmac_lib_driver;
 
 #include "afalgpriv.h"
 
-QCryptoAFAlg *qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgo alg,
+QCryptoAFAlgo *qcrypto_afalg_hmac_ctx_new(QCryptoHashAlgo alg,
  const uint8_t *key, size_t nkey,
  Error **errp);
 extern QCryptoHmacDriver qcrypto_hmac_afalg_driver;
diff --git a/crypto/afalg.c b/crypto/afalg.c
index 52a491dbb5..246d0679d4 100644
--- a/crypto/afalg.c
+++ b/crypto/afalg.c
@@ -66,13 +66,13 @@ qcrypto_afalg_socket_bind(const char *type, const char 
*name,
 return sbind;
 }
 
-QCryptoAFAlg *
+QCryptoAFAlgo *
 qcrypto_afalg_comm_alloc(const char *type, const char *name,
  Error **errp)
 {
-QCryptoAFAlg *afalg;
+QCryptoAFAlgo *afalg;
 
-afalg = g_new0(QCryptoAFAlg, 1);
+afalg = g_new0(QCryptoAFAlgo, 1);
 /* initialize crypto API socket */
 afalg->opfd = -1;
 afalg->tfmfd = qcrypto_afalg_socket_bind(type, name, errp);
@@ -93,7 +93,7 @@ error:
 return NULL;
 }
 
-void qcrypto_afalg_comm_free(QCryptoAFAlg *afalg)
+void qcrypto_afalg_comm_free(QCryptoAFAlgo *afalg)
 {
 if (!afalg) {
 return;
diff --git a/crypto/cipher-afalg.c b/crypto/cipher-afalg.c
index c08eb7a39b..4980d419c4 100644
--- a/crypto/cipher-afalg.c
+++ b/crypto/cipher-afalg.c
@@ -65,7 +65,7 @@ qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgo alg,
  const uint8_t *key,
  size_t nkey, Error **errp)
 {
-QCryptoAFAlg *afalg;
+QCryptoAFAlgo *afalg;
 size_t expect_niv;
 char *name;
 
@@ -119,7 +119,7 @@ qcrypto_afalg_cipher_setiv(QCryptoCipher *cipher,
const uint8_t *iv,
size_t niv, Error **errp)
 {
-QCryptoAFAlg *afalg = container_of(cipher, QCryptoAFAlg, base);
+QCryptoAFAlgo *afalg = container_of(cipher, QCryptoAFAlgo, base);
 struct af_alg_iv *alg_iv;
 size_t expect_niv;
 
@@ -143,7 +143,7 @@ qcrypto_afalg_cipher_setiv(QCryptoCipher *cipher,
 }
 
 static int
-qcrypto_afalg_cipher_op(QCryptoAFAlg *afalg,
+qcrypto_afalg_cipher_op(QCryptoAFAlgo *afalg,
 const void *in, void *out,
 size_t len, bool do_encrypt,
 Error **errp)
@@ -202,7 +202,7 @@ qcrypto_afalg_cipher_encrypt(QCryptoCipher *cipher,
  const void *in, void *out,
  size_t len, Error **errp)
 {
-QCryptoAFAlg *afalg = container_of(cipher, QCryptoAFAlg, base);
+QCryptoAFAlgo *afalg = container_of(cipher, QCryptoAFAlgo, base);
 
 return qcrypto_afalg_cipher_op(afalg, in, out, len, true, errp);
 }
@@ -212,14 +212,14 @@ qcrypto_afalg_cipher_decrypt(QCryptoCipher *cipher,
  const void *in, void *out,
  size_t len, Error **errp)
 {
-QCryptoAFAlg *afalg = container_of(cipher, QCryptoAFAlg, base);
+QCryptoAFAlgo *afalg = container_of(cipher, QCryptoAFAlgo, base);
 
 return qcrypto_afalg_cipher_op(afalg, in, out, len, false, errp);
 }
 
 static void qcrypto_afalg_comm_ctx_free(QCryptoCipher *cipher)
 {
-QCryptoAFAlg *afalg = container_of(cipher, QCryptoAFAlg, base);
+QCryptoAFAlgo *afal

[PATCH 15/18] qapi/crypto: Rename QCryptoRSAPaddingAlgorithm to *Algo, and drop prefix

2024-07-30 Thread Markus Armbruster
QAPI's 'prefix' feature can make the connection between enumeration
type and its constants less than obvious.  It's best used with
restraint.

QCryptoRSAPaddingAlgorithm has a 'prefix' that overrides the generated
enumeration constants' prefix to QCRYPTO_RSA_PADDING_ALG.

We could simply drop 'prefix', but then the prefix becomes
QCRYPTO_RSA_PADDING_ALGORITHM, which is rather long.

We could additionally rename the type to QCryptoRSAPaddingAlg, but I
think the abbreviation "alg" is less than clear.

Rename the type to QCryptoRSAPaddingAlgo instead.  The prefix becomes
QCRYPTO_RSA_PADDING_ALGO.

Signed-off-by: Markus Armbruster 
---
 qapi/crypto.json|  9 -
 backends/cryptodev-builtin.c|  6 +++---
 backends/cryptodev-lkcf.c   | 10 +-
 tests/bench/benchmark-crypto-akcipher.c | 12 ++--
 tests/unit/test-crypto-akcipher.c   | 10 +-
 crypto/akcipher-gcrypt.c.inc| 18 +-
 crypto/akcipher-nettle.c.inc| 18 +-
 7 files changed, 41 insertions(+), 42 deletions(-)

diff --git a/qapi/crypto.json b/qapi/crypto.json
index 5ea16c69e0..8372d8abe3 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -608,7 +608,7 @@
   'data': ['public', 'private']}
 
 ##
-# @QCryptoRSAPaddingAlgorithm:
+# @QCryptoRSAPaddingAlgo:
 #
 # The padding algorithm for RSA.
 #
@@ -618,8 +618,7 @@
 #
 # Since: 7.1
 ##
-{ 'enum': 'QCryptoRSAPaddingAlgorithm',
-  'prefix': 'QCRYPTO_RSA_PADDING_ALG',
+{ 'enum': 'QCryptoRSAPaddingAlgo',
   'data': ['raw', 'pkcs1']}
 
 ##
@@ -629,13 +628,13 @@
 #
 # @hash-alg: QCryptoHashAlgo
 #
-# @padding-alg: QCryptoRSAPaddingAlgorithm
+# @padding-alg: QCryptoRSAPaddingAlgo
 #
 # Since: 7.1
 ##
 { 'struct': 'QCryptoAkCipherOptionsRSA',
   'data': { 'hash-alg':'QCryptoHashAlgo',
-'padding-alg': 'QCryptoRSAPaddingAlgorithm'}}
+'padding-alg': 'QCryptoRSAPaddingAlgo'}}
 
 ##
 # @QCryptoAkCipherOptions:
diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c
index d8b64091b6..6f3990481b 100644
--- a/backends/cryptodev-builtin.c
+++ b/backends/cryptodev-builtin.c
@@ -65,7 +65,7 @@ static void cryptodev_builtin_init_akcipher(CryptoDevBackend 
*backend)
 QCryptoAkCipherOptions opts;
 
 opts.alg = QCRYPTO_AK_CIPHER_ALGO_RSA;
-opts.u.rsa.padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW;
+opts.u.rsa.padding_alg = QCRYPTO_RSA_PADDING_ALGO_RAW;
 if (qcrypto_akcipher_supports(&opts)) {
 backend->conf.crypto_services |=
  (1u << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER);
@@ -200,12 +200,12 @@ static int cryptodev_builtin_set_rsa_options(
 return -1;
 }
 opt->hash_alg = hash_alg;
-opt->padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1;
+opt->padding_alg = QCRYPTO_RSA_PADDING_ALGO_PKCS1;
 return 0;
 }
 
 if (virtio_padding_algo == VIRTIO_CRYPTO_RSA_RAW_PADDING) {
-opt->padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW;
+opt->padding_alg = QCRYPTO_RSA_PADDING_ALGO_RAW;
 return 0;
 }
 
diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c
index 6fb6e03d98..fde32950f6 100644
--- a/backends/cryptodev-lkcf.c
+++ b/backends/cryptodev-lkcf.c
@@ -139,14 +139,14 @@ static int 
cryptodev_lkcf_set_op_desc(QCryptoAkCipherOptions *opts,
 }
 
 rsa_opt = &opts->u.rsa;
-if (rsa_opt->padding_alg == QCRYPTO_RSA_PADDING_ALG_PKCS1) {
+if (rsa_opt->padding_alg == QCRYPTO_RSA_PADDING_ALGO_PKCS1) {
 snprintf(key_desc, desc_len, "enc=%s hash=%s",
- QCryptoRSAPaddingAlgorithm_str(rsa_opt->padding_alg),
+ QCryptoRSAPaddingAlgo_str(rsa_opt->padding_alg),
  QCryptoHashAlgo_str(rsa_opt->hash_alg));
 
 } else {
 snprintf(key_desc, desc_len, "enc=%s",
- QCryptoRSAPaddingAlgorithm_str(rsa_opt->padding_alg));
+ QCryptoRSAPaddingAlgo_str(rsa_opt->padding_alg));
 }
 return 0;
 }
@@ -157,7 +157,7 @@ static int cryptodev_lkcf_set_rsa_opt(int 
virtio_padding_alg,
   Error **errp)
 {
 if (virtio_padding_alg == VIRTIO_CRYPTO_RSA_PKCS1_PADDING) {
-opt->padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1;
+opt->padding_alg = QCRYPTO_RSA_PADDING_ALGO_PKCS1;
 
 switch (virtio_hash_alg) {
 case VIRTIO_CRYPTO_RSA_MD5:
@@ -184,7 +184,7 @@ static int cryptodev_lkcf_set_rsa_opt(int 
virtio_padding_alg,
 }
 
 if (virtio_padding_alg == VIRTIO_CRYPTO_RSA_RAW_PADDING) {
-opt->padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW;
+opt->padding

[PATCH 00/18] qapi: Reduce use of 'prefix'.

2024-07-30 Thread Markus Armbruster
QAPI's 'prefix' feature can make the connection between enumeration
type and its constants less than obvious.  It's best used with
restraint.

We use 'prefix' for a number of reasons:

* To override an ugly default.

* To shorten the prefix.

* To work around name clashes.

This series attacks the first two.  It additionally improves a number
of ugly prefixes we don't override.

PATCH 01 improves the default prefix, and drops 'prefix' where it is
now redundant.  The patch adds temporary 'prefix' to not change
generated code.

PATCH 02-08 revert the temporary 'prefix'.

PATCH 10,17 drop 'prefix' where the default is now better.

PATCH 09,11-15,18 rename QAPI types, and drop their 'prefix'.  I'm
prepared to adjust the renames according to maintainers' preference.

PATCH 16 renames a non-QAPI type for consistency.

Markus Armbruster (18):
  qapi: Smarter camel_to_upper() to reduce need for 'prefix'
  tests/qapi-schema: Drop temporary 'prefix'
  qapi/block-core: Drop temporary 'prefix'
  qapi/common: Drop temporary 'prefix'
  qapi/crypto: Drop temporary 'prefix'
  qapi/ebpf: Drop temporary 'prefix'
  qapi/machine: Drop temporary 'prefix'
  qapi/ui: Drop temporary 'prefix'
  qapi/machine: Rename CpuS390* to S390Cpu, and drop 'prefix'
  qapi/crypto: Drop unwanted 'prefix'
  qapi/crypto: Rename QCryptoHashAlgorithm to *Algo, and drop prefix
  qapi/crypto: Rename QCryptoCipherAlgorithm to *Algo, and drop prefix
  qapi/crypto: Rename QCryptoIVGenAlgorithm to *Algo, and drop prefix
  qapi/crypto: Rename QCryptoAkCipherAlgorithm to *Algo, and drop prefix
  qapi/crypto: Rename QCryptoRSAPaddingAlgorithm to *Algo, and drop
prefix
  qapi/crypto: Rename QCryptoAFAlg to QCryptoAFAlgo
  qapi/cryptodev: Drop unwanted 'prefix'
  qapi/cryptodev: Rename QCryptodevBackendAlgType to *Algo, and drop
prefix

 qapi/block-core.json |   4 +-
 qapi/crypto.json |  56 --
 qapi/cryptodev.json  |   7 +-
 qapi/machine-common.json |   5 +-
 qapi/machine-target.json |  11 +-
 qapi/machine.json|   9 +-
 qapi/migration.json  |   1 +
 qapi/pragma.json |   6 +-
 qapi/ui.json |   1 +
 crypto/afalgpriv.h   |  14 +--
 crypto/akcipherpriv.h|   2 +-
 crypto/blockpriv.h   |   6 +-
 crypto/cipherpriv.h  |   2 +-
 crypto/hashpriv.h|   2 +-
 crypto/hmacpriv.h|   4 +-
 crypto/ivgenpriv.h   |   6 +-
 include/crypto/afsplit.h |   8 +-
 include/crypto/block.h   |   2 +-
 include/crypto/cipher.h  |  18 ++--
 include/crypto/hash.h|  18 ++--
 include/crypto/hmac.h|   6 +-
 include/crypto/ivgen.h   |  30 +++---
 include/crypto/pbkdf.h   |  14 +--
 include/hw/qdev-properties-system.h  |   2 +-
 include/hw/s390x/cpu-topology.h  |   2 +-
 include/sysemu/cryptodev.h   |   2 +-
 target/s390x/cpu.h   |   2 +-
 backends/cryptodev-builtin.c |  52 -
 backends/cryptodev-lkcf.c|  36 +++
 backends/cryptodev-vhost-user.c  |   6 +-
 backends/cryptodev.c |  12 +--
 block.c  |   6 +-
 block/crypto.c   |  10 +-
 block/parallels-ext.c|   2 +-
 block/qcow.c |   2 +-
 block/qcow2.c|  10 +-
 block/quorum.c   |   4 +-
 block/rbd.c  |   4 +-
 crypto/afalg.c   |   8 +-
 crypto/afsplit.c |   6 +-
 crypto/akcipher.c|   2 +-
 crypto/block-luks.c  | 128 +++
 crypto/block-qcow.c  |   6 +-
 crypto/block.c   |   8 +-
 crypto/cipher-afalg.c|  36 +++
 crypto/cipher.c  |  72 ++---
 crypto/hash-afalg.c  |  40 +++
 crypto/hash-gcrypt.c |  20 ++--
 crypto/hash-glib.c   |  20 ++--
 crypto/hash-gnutls.c |  20 ++--
 crypto/hash-nettle.c |  18 ++--
 crypto/hash.c|  30 +++---
 crypto/hmac-gcrypt.c |  22 ++--
 crypto/hmac-glib.c   |  22 ++--
 crypto/hmac-gnutls.c |  22 ++--
 crypto/hmac-nettle.c |  22 ++--
 crypto/hmac.c

[PATCH 05/18] qapi/crypto: Drop temporary 'prefix'

2024-07-30 Thread Markus Armbruster
Recent commit "qapi: Smarter camel_to_upper() to reduce need for
'prefix'" added two temporary 'prefix' to delay changing the generated
code.

Revert them.  This improves QCryptoBlockFormat's generated enumeration
constant prefix from Q_CRYPTO_BLOCK_FORMAT to QCRYPTO_BLOCK_FORMAT,
and QCryptoBlockLUKSKeyslotState's from
Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE to QCRYPTO_BLOCK_LUKS_KEYSLOT_STATE.

Signed-off-by: Markus Armbruster 
---
 qapi/crypto.json   |  2 --
 block/crypto.c | 10 +-
 block/qcow.c   |  2 +-
 block/qcow2.c  | 10 +-
 crypto/block-luks.c|  4 ++--
 crypto/block.c |  4 ++--
 tests/unit/test-crypto-block.c | 14 +++---
 7 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/qapi/crypto.json b/qapi/crypto.json
index e2d77c3fb3..42d321fdcb 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -157,7 +157,6 @@
 # Since: 2.6
 ##
 { 'enum': 'QCryptoBlockFormat',
-  'prefix': 'Q_CRYPTO_BLOCK_FORMAT', # TODO drop
   'data': ['qcow', 'luks']}
 
 ##
@@ -360,7 +359,6 @@
 # Since: 5.1
 ##
 { 'enum': 'QCryptoBlockLUKSKeyslotState',
-  'prefix': 'Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE', # TODO drop
   'data': [ 'active', 'inactive' ] }
 
 ##
diff --git a/block/crypto.c b/block/crypto.c
index 4eed3ffa6a..80b2dba17a 100644
--- a/block/crypto.c
+++ b/block/crypto.c
@@ -682,7 +682,7 @@ err:
 static int block_crypto_probe_luks(const uint8_t *buf,
int buf_size,
const char *filename) {
-return block_crypto_probe_generic(Q_CRYPTO_BLOCK_FORMAT_LUKS,
+return block_crypto_probe_generic(QCRYPTO_BLOCK_FORMAT_LUKS,
   buf, buf_size, filename);
 }
 
@@ -691,7 +691,7 @@ static int block_crypto_open_luks(BlockDriverState *bs,
   int flags,
   Error **errp)
 {
-return block_crypto_open_generic(Q_CRYPTO_BLOCK_FORMAT_LUKS,
+return block_crypto_open_generic(QCRYPTO_BLOCK_FORMAT_LUKS,
  &block_crypto_runtime_opts_luks,
  bs, options, flags, errp);
 }
@@ -724,7 +724,7 @@ block_crypto_co_create_luks(BlockdevCreateOptions 
*create_options, Error **errp)
 }
 
 create_opts = (QCryptoBlockCreateOptions) {
-.format = Q_CRYPTO_BLOCK_FORMAT_LUKS,
+.format = QCRYPTO_BLOCK_FORMAT_LUKS,
 .u.luks = *qapi_BlockdevCreateOptionsLUKS_base(luks_opts),
 };
 
@@ -889,7 +889,7 @@ block_crypto_get_specific_info_luks(BlockDriverState *bs, 
Error **errp)
 if (!info) {
 return NULL;
 }
-assert(info->format == Q_CRYPTO_BLOCK_FORMAT_LUKS);
+assert(info->format == QCRYPTO_BLOCK_FORMAT_LUKS);
 
 spec_info = g_new(ImageInfoSpecific, 1);
 spec_info->type = IMAGE_INFO_SPECIFIC_KIND_LUKS;
@@ -1002,7 +1002,7 @@ coroutine_fn block_crypto_co_amend_luks(BlockDriverState 
*bs,
 QCryptoBlockAmendOptions amend_opts;
 
 amend_opts = (QCryptoBlockAmendOptions) {
-.format = Q_CRYPTO_BLOCK_FORMAT_LUKS,
+.format = QCRYPTO_BLOCK_FORMAT_LUKS,
 .u.luks = *qapi_BlockdevAmendOptionsLUKS_base(&opts->u.luks),
 };
 return block_crypto_amend_options_generic_luks(bs, &amend_opts,
diff --git a/block/qcow.c b/block/qcow.c
index c2f89db055..84d1cca296 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -831,7 +831,7 @@ qcow_co_create(BlockdevCreateOptions *opts, Error **errp)
 }
 
 if (qcow_opts->encrypt &&
-qcow_opts->encrypt->format != Q_CRYPTO_BLOCK_FORMAT_QCOW)
+qcow_opts->encrypt->format != QCRYPTO_BLOCK_FORMAT_QCOW)
 {
 error_setg(errp, "Unsupported encryption format");
 return -EINVAL;
diff --git a/block/qcow2.c b/block/qcow2.c
index 70b19730a3..dd359d241b 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -3214,10 +3214,10 @@ qcow2_set_up_encryption(BlockDriverState *bs,
 int fmt, ret;
 
 switch (cryptoopts->format) {
-case Q_CRYPTO_BLOCK_FORMAT_LUKS:
+case QCRYPTO_BLOCK_FORMAT_LUKS:
 fmt = QCOW_CRYPT_LUKS;
 break;
-case Q_CRYPTO_BLOCK_FORMAT_QCOW:
+case QCRYPTO_BLOCK_FORMAT_QCOW:
 fmt = QCOW_CRYPT_AES;
 break;
 default:
@@ -5306,10 +5306,10 @@ qcow2_get_specific_info(BlockDriverState *bs, Error 
**errp)
 ImageInfoSpecificQCow2Encryption *qencrypt =
 g_new(ImageInfoSpecificQCow2Encryption, 1);
 switch (encrypt_info->format) {
-case Q_CRYPTO_BLOCK_FORMAT_QCOW:
+case QCRYPTO_BLOCK_FORMAT_QCOW:
 qencrypt->format = BLOCKDEV_QCOW2_ENCRYPTION_FORMAT_AES;
 break;
-case Q_CRYPTO_BLOCK_FORMAT_LUKS:

[PATCH 03/18] qapi/block-core: Drop temporary 'prefix'

2024-07-30 Thread Markus Armbruster
Recent commit "qapi: Smarter camel_to_upper() to reduce need for
'prefix'" added a temporary 'prefix' to delay changing the generated
code.

Revert it.  This improves XDbgBlockGraphNodeType's generated
enumeration constant prefix from
X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BACKEND to
XDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BACKEND.

Signed-off-by: Markus Armbruster 
---
 qapi/block-core.json | 1 -
 block.c  | 6 +++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/qapi/block-core.json b/qapi/block-core.json
index 897bc7e0e7..d4c869ac64 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -2011,7 +2011,6 @@
 # Since: 4.0
 ##
 { 'enum': 'XDbgBlockGraphNodeType',
-  'prefix': 'X_DBG_BLOCK_GRAPH_NODE_TYPE', # TODO drop
   'data': [ 'block-backend', 'block-job', 'block-driver' ] }
 
 ##
diff --git a/block.c b/block.c
index c317de9eaa..7d90007cae 100644
--- a/block.c
+++ b/block.c
@@ -6351,7 +6351,7 @@ XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **errp)
 if (!*name) {
 name = allocated_name = blk_get_attached_dev_id(blk);
 }
-xdbg_graph_add_node(gr, blk, X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BACKEND,
+xdbg_graph_add_node(gr, blk, XDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BACKEND,
name);
 g_free(allocated_name);
 if (blk_root(blk)) {
@@ -6364,7 +6364,7 @@ XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **errp)
  job = block_job_next_locked(job)) {
 GSList *el;
 
-xdbg_graph_add_node(gr, job, X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_JOB,
+xdbg_graph_add_node(gr, job, XDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_JOB,
 job->job.id);
 for (el = job->nodes; el; el = el->next) {
 xdbg_graph_add_edge(gr, job, (BdrvChild *)el->data);
@@ -6373,7 +6373,7 @@ XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **errp)
 }
 
 QTAILQ_FOREACH(bs, &graph_bdrv_states, node_list) {
-xdbg_graph_add_node(gr, bs, X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_DRIVER,
+xdbg_graph_add_node(gr, bs, XDBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_DRIVER,
bs->node_name);
 QLIST_FOREACH(child, &bs->children, next) {
 xdbg_graph_add_edge(gr, bs, child);
-- 
2.45.0




[PATCH 12/18] qapi/crypto: Rename QCryptoCipherAlgorithm to *Algo, and drop prefix

2024-07-30 Thread Markus Armbruster
QAPI's 'prefix' feature can make the connection between enumeration
type and its constants less than obvious.  It's best used with
restraint.

QCryptoCipherAlgorithm has a 'prefix' that overrides the generated
enumeration constants' prefix to QCRYPTO_CIPHER_ALG.

We could simply drop 'prefix', but then the prefix becomes
QCRYPTO_CIPHER_ALGORITHM, which is rather long.

We could additionally rename the type to QCryptoCipherAlg, but I think
the abbreviation "alg" is less than clear.

Rename the type to QCryptoCipherAlgo instead.  The prefix becomes
QCRYPTO_CIPHER_ALGO.

Signed-off-by: Markus Armbruster 
---
 qapi/block-core.json  |  2 +-
 qapi/crypto.json  |  9 ++-
 crypto/blockpriv.h|  4 +-
 crypto/cipherpriv.h   |  2 +-
 crypto/ivgenpriv.h|  2 +-
 include/crypto/cipher.h   | 18 +++---
 include/crypto/ivgen.h| 10 +--
 include/crypto/pbkdf.h|  4 +-
 backends/cryptodev-builtin.c  | 16 ++---
 block/rbd.c   |  4 +-
 crypto/block-luks.c   | 92 +--
 crypto/block-qcow.c   |  4 +-
 crypto/block.c|  2 +-
 crypto/cipher-afalg.c | 24 +++
 crypto/cipher.c   | 72 ++---
 crypto/ivgen.c|  4 +-
 crypto/secret_common.c|  2 +-
 tests/bench/benchmark-crypto-cipher.c | 22 +++
 tests/unit/test-crypto-block.c| 14 ++--
 tests/unit/test-crypto-cipher.c   | 66 +--
 tests/unit/test-crypto-ivgen.c|  8 +--
 ui/vnc.c  |  4 +-
 crypto/cipher-builtin.c.inc   | 18 +++---
 crypto/cipher-gcrypt.c.inc| 56 
 crypto/cipher-gnutls.c.inc| 38 +--
 crypto/cipher-nettle.c.inc| 58 -
 26 files changed, 277 insertions(+), 278 deletions(-)

diff --git a/qapi/block-core.json b/qapi/block-core.json
index d4c869ac64..af7d4b7b3a 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -4162,7 +4162,7 @@
 ##
 { 'struct': 'RbdEncryptionCreateOptionsLUKSBase',
   'base': 'RbdEncryptionOptionsLUKSBase',
-  'data': { '*cipher-alg': 'QCryptoCipherAlgorithm' } }
+  'data': { '*cipher-alg': 'QCryptoCipherAlgo' } }
 
 ##
 # @RbdEncryptionOptionsLUKS:
diff --git a/qapi/crypto.json b/qapi/crypto.json
index 76095b0833..6ab44fc018 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -62,7 +62,7 @@
   'data': ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd160']}
 
 ##
-# @QCryptoCipherAlgorithm:
+# @QCryptoCipherAlgo:
 #
 # The supported algorithms for content encryption ciphers
 #
@@ -95,8 +95,7 @@
 #
 # Since: 2.6
 ##
-{ 'enum': 'QCryptoCipherAlgorithm',
-  'prefix': 'QCRYPTO_CIPHER_ALG',
+{ 'enum': 'QCryptoCipherAlgo',
   'data': ['aes-128', 'aes-192', 'aes-256',
'des', '3des',
'cast5-128',
@@ -225,7 +224,7 @@
 ##
 { 'struct': 'QCryptoBlockCreateOptionsLUKS',
   'base': 'QCryptoBlockOptionsLUKS',
-  'data': { '*cipher-alg': 'QCryptoCipherAlgorithm',
+  'data': { '*cipher-alg': 'QCryptoCipherAlgo',
 '*cipher-mode': 'QCryptoCipherMode',
 '*ivgen-alg': 'QCryptoIVGenAlgorithm',
 '*ivgen-hash-alg': 'QCryptoHashAlgo',
@@ -322,7 +321,7 @@
 # Since: 2.7
 ##
 { 'struct': 'QCryptoBlockInfoLUKS',
-  'data': {'cipher-alg': 'QCryptoCipherAlgorithm',
+  'data': {'cipher-alg': 'QCryptoCipherAlgo',
'cipher-mode': 'QCryptoCipherMode',
'ivgen-alg': 'QCryptoIVGenAlgorithm',
'*ivgen-hash-alg': 'QCryptoHashAlgo',
diff --git a/crypto/blockpriv.h b/crypto/blockpriv.h
index cf1a66c00d..edf0b3a3d9 100644
--- a/crypto/blockpriv.h
+++ b/crypto/blockpriv.h
@@ -33,7 +33,7 @@ struct QCryptoBlock {
 void *opaque;
 
 /* Cipher parameters */
-QCryptoCipherAlgorithm alg;
+QCryptoCipherAlgo alg;
 QCryptoCipherMode mode;
 uint8_t *key;
 size_t nkey;
@@ -132,7 +132,7 @@ int qcrypto_block_encrypt_helper(QCryptoBlock *block,
  Error **errp);
 
 int qcrypto_block_init_cipher(QCryptoBlock *block,
-  QCryptoCipherAlgorithm alg,
+  

[PATCH 09/18] qapi/machine: Rename CpuS390* to S390Cpu, and drop 'prefix'

2024-07-30 Thread Markus Armbruster
QAPI's 'prefix' feature can make the connection between enumeration
type and its constants less than obvious.  It's best used with
restraint.

CpuS390Entitlement has a 'prefix' to change the generated enumeration
constants' prefix from CPU_S390_POLARIZATION to S390_CPU_POLARIZATION.
Rename the type to S390CpuEntitlement, so that 'prefix' is not needed.

Likewise change CpuS390Polarization to S390CpuPolarization, and
CpuS390State to S390CpuState.

Signed-off-by: Markus Armbruster 
---
 qapi/machine-common.json|  5 ++---
 qapi/machine-target.json| 11 +--
 qapi/machine.json   |  9 -
 qapi/pragma.json|  6 +++---
 include/hw/qdev-properties-system.h |  2 +-
 include/hw/s390x/cpu-topology.h |  2 +-
 target/s390x/cpu.h  |  2 +-
 hw/core/qdev-properties-system.c|  6 +++---
 hw/s390x/cpu-topology.c |  6 +++---
 9 files changed, 23 insertions(+), 26 deletions(-)

diff --git a/qapi/machine-common.json b/qapi/machine-common.json
index fa6bd71d12..b64e4895cf 100644
--- a/qapi/machine-common.json
+++ b/qapi/machine-common.json
@@ -9,13 +9,12 @@
 ##
 
 ##
-# @CpuS390Entitlement:
+# @S390CpuEntitlement:
 #
 # An enumeration of CPU entitlements that can be assumed by a virtual
 # S390 CPU
 #
 # Since: 8.2
 ##
-{ 'enum': 'CpuS390Entitlement',
-  'prefix': 'S390_CPU_ENTITLEMENT',
+{ 'enum': 'S390CpuEntitlement',
   'data': [ 'auto', 'low', 'medium', 'high' ] }
diff --git a/qapi/machine-target.json b/qapi/machine-target.json
index a552e2b0ce..6ee682adad 100644
--- a/qapi/machine-target.json
+++ b/qapi/machine-target.json
@@ -400,15 +400,14 @@
'TARGET_RISCV' ] } }
 
 ##
-# @CpuS390Polarization:
+# @S390CpuPolarization:
 #
 # An enumeration of CPU polarization that can be assumed by a virtual
 # S390 CPU
 #
 # Since: 8.2
 ##
-{ 'enum': 'CpuS390Polarization',
-  'prefix': 'S390_CPU_POLARIZATION',
+{ 'enum': 'S390CpuPolarization',
   'data': [ 'horizontal', 'vertical' ],
   'if': 'TARGET_S390X'
 }
@@ -445,7 +444,7 @@
   '*socket-id': 'uint16',
   '*book-id': 'uint16',
   '*drawer-id': 'uint16',
-  '*entitlement': 'CpuS390Entitlement',
+  '*entitlement': 'S390CpuEntitlement',
   '*dedicated': 'bool'
   },
   'features': [ 'unstable' ],
@@ -483,7 +482,7 @@
 #  "timestamp": { "seconds": 1401385907, "microseconds": 422329 } }
 ##
 { 'event': 'CPU_POLARIZATION_CHANGE',
-  'data': { 'polarization': 'CpuS390Polarization' },
+  'data': { 'polarization': 'S390CpuPolarization' },
   'features': [ 'unstable' ],
   'if': { 'all': [ 'TARGET_S390X', 'CONFIG_KVM' ] }
 }
@@ -498,7 +497,7 @@
 # Since: 8.2
 ##
 { 'struct': 'CpuPolarizationInfo',
-  'data': { 'polarization': 'CpuS390Polarization' },
+  'data': { 'polarization': 'S390CpuPolarization' },
   'if': { 'all': [ 'TARGET_S390X', 'CONFIG_KVM' ] }
 }
 
diff --git a/qapi/machine.json b/qapi/machine.json
index fcfd249e2d..bdb418696d 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -41,15 +41,14 @@
  'x86_64', 'xtensa', 'xtensaeb' ] }
 
 ##
-# @CpuS390State:
+# @S390CpuState:
 #
 # An enumeration of cpu states that can be assumed by a virtual S390
 # CPU
 #
 # Since: 2.12
 ##
-{ 'enum': 'CpuS390State',
-  'prefix': 'S390_CPU_STATE',
+{ 'enum': 'S390CpuState',
   'data': [ 'uninitialized', 'stopped', 'check-stop', 'operating', 'load' ] }
 
 ##
@@ -66,9 +65,9 @@
 # Since: 2.12
 ##
 { 'struct': 'CpuInfoS390',
-  'data': { 'cpu-state': 'CpuS390State',
+  'data': { 'cpu-state': 'S390CpuState',
 '*dedicated': 'bool',
-'*entitlement': 'CpuS390Entitlement' } }
+'*entitlement': 'S390CpuEntitlement' } }
 
 ##
 # @CpuInfoFast:
diff --git a/qapi/pragma.json b/qapi/pragma.json
index 59fbe74b8c..beddea5ca4 100644
--- a/qapi/pragma.json
+++ b/qapi/pragma.json
@@ -47,9 +47,9 @@
 'BlockdevSnapshotWrapper',
 'BlockdevVmdkAdapterType',
 'ChardevBackendKind',
-   

[PATCH 04/18] qapi/common: Drop temporary 'prefix'

2024-07-30 Thread Markus Armbruster
Recent commit "qapi: Smarter camel_to_upper() to reduce need for
'prefix'" added a temporary 'prefix' to delay changing the generated
code.

Revert it.  This improves OffAutoPCIBAR's generated enumeration
constant prefix from OFF_AUTOPCIBAR_OFF to OFF_AUTO_PCIBAR_OFF.

Signed-off-by: Markus Armbruster 
---
 qapi/common.json |  1 -
 hw/vfio/pci.c| 10 +-
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/qapi/common.json b/qapi/common.json
index 25726d3113..7558ce5430 100644
--- a/qapi/common.json
+++ b/qapi/common.json
@@ -92,7 +92,6 @@
 # Since: 2.12
 ##
 { 'enum': 'OffAutoPCIBAR',
-  'prefix': 'OFF_AUTOPCIBAR',   # TODO drop
   'data': [ 'off', 'auto', 'bar0', 'bar1', 'bar2', 'bar3', 'bar4', 'bar5' ] }
 
 ##
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 2407720c35..0a99e55247 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -1452,7 +1452,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vdev, 
Error **errp)
 int target_bar = -1;
 size_t msix_sz;
 
-if (!vdev->msix || vdev->msix_relo == OFF_AUTOPCIBAR_OFF) {
+if (!vdev->msix || vdev->msix_relo == OFF_AUTO_PCIBAR_OFF) {
 return true;
 }
 
@@ -1464,7 +1464,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vdev, 
Error **errp)
 /* PCI BARs must be a power of 2 */
 msix_sz = pow2ceil(msix_sz);
 
-if (vdev->msix_relo == OFF_AUTOPCIBAR_AUTO) {
+if (vdev->msix_relo == OFF_AUTO_PCIBAR_AUTO) {
 /*
  * TODO: Lookup table for known devices.
  *
@@ -1479,7 +1479,7 @@ static bool vfio_pci_relocate_msix(VFIOPCIDevice *vdev, 
Error **errp)
 return false;
 }
 } else {
-target_bar = (int)(vdev->msix_relo - OFF_AUTOPCIBAR_BAR0);
+target_bar = (int)(vdev->msix_relo - OFF_AUTO_PCIBAR_BAR0);
 }
 
 /* I/O port BARs cannot host MSI-X structures */
@@ -1624,7 +1624,7 @@ static bool vfio_msix_early_setup(VFIOPCIDevice *vdev, 
Error **errp)
 } else if (vfio_pci_is(vdev, PCI_VENDOR_ID_BAIDU,
PCI_DEVICE_ID_KUNLUN_VF)) {
 msix->pba_offset = 0xb400;
-} else if (vdev->msix_relo == OFF_AUTOPCIBAR_OFF) {
+} else if (vdev->msix_relo == OFF_AUTO_PCIBAR_OFF) {
 error_setg(errp, "hardware reports invalid configuration, "
"MSIX PBA outside of specified BAR");
 g_free(msix);
@@ -3403,7 +3403,7 @@ static Property vfio_pci_dev_properties[] = {
nv_gpudirect_clique,
qdev_prop_nv_gpudirect_clique, uint8_t),
 DEFINE_PROP_OFF_AUTO_PCIBAR("x-msix-relocation", VFIOPCIDevice, msix_relo,
-OFF_AUTOPCIBAR_OFF),
+OFF_AUTO_PCIBAR_OFF),
 #ifdef CONFIG_IOMMUFD
 DEFINE_PROP_LINK("iommufd", VFIOPCIDevice, vbasedev.iommufd,
  TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *),
-- 
2.45.0




[PATCH 06/18] qapi/ebpf: Drop temporary 'prefix'

2024-07-30 Thread Markus Armbruster
Recent commit "qapi: Smarter camel_to_upper() to reduce need for
'prefix'" added a temporary 'prefix' to delay changing the generated
code.

Revert it.  This improves EbpfProgramID's generated enumeration
constant prefix from EBPF_PROGRAMID to EBPF_PROGRAM_ID.

Signed-off-by: Markus Armbruster 
---
 qapi/ebpf.json  | 1 -
 ebpf/ebpf_rss.c | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/qapi/ebpf.json b/qapi/ebpf.json
index 166a9d0eb0..e500b5a744 100644
--- a/qapi/ebpf.json
+++ b/qapi/ebpf.json
@@ -42,7 +42,6 @@
 # Since: 9.0
 ##
 { 'enum': 'EbpfProgramID',
-  'prefix': 'EBPF_PROGRAMID',   # TODO drop
   'if': 'CONFIG_EBPF',
   'data': [ { 'name': 'rss' } ] }
 
diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c
index 87f0714910..dcaa80f380 100644
--- a/ebpf/ebpf_rss.c
+++ b/ebpf/ebpf_rss.c
@@ -271,4 +271,4 @@ void ebpf_rss_unload(struct EBPFRSSContext *ctx)
 ctx->map_indirections_table = -1;
 }
 
-ebpf_binary_init(EBPF_PROGRAMID_RSS, rss_bpf__elf_bytes)
+ebpf_binary_init(EBPF_PROGRAM_ID_RSS, rss_bpf__elf_bytes)
-- 
2.45.0




[PATCH 10/18] qapi/crypto: Drop unwanted 'prefix'

2024-07-30 Thread Markus Armbruster
QAPI's 'prefix' feature can make the connection between enumeration
type and its constants less than obvious.  It's best used with
restraint.

QCryptoAkCipherKeyType has a 'prefix' that overrides the generated
enumeration constants' prefix to QCRYPTO_AKCIPHER_KEY_TYPE.

Drop it.  The prefix becomes QCRYPTO_AK_CIPHER_KEY_TYPE.

Signed-off-by: Markus Armbruster 
---
 qapi/crypto.json|  1 -
 backends/cryptodev-builtin.c|  4 ++--
 backends/cryptodev-lkcf.c   |  6 +++---
 tests/bench/benchmark-crypto-akcipher.c |  2 +-
 tests/unit/test-crypto-akcipher.c   | 28 -
 crypto/akcipher-gcrypt.c.inc|  8 +++
 crypto/akcipher-nettle.c.inc|  8 +++
 crypto/rsakey-builtin.c.inc |  4 ++--
 crypto/rsakey-nettle.c.inc  |  4 ++--
 9 files changed, 32 insertions(+), 33 deletions(-)

diff --git a/qapi/crypto.json b/qapi/crypto.json
index 42d321fdcb..aafb5d5c8d 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -609,7 +609,6 @@
 # Since: 7.1
 ##
 { 'enum': 'QCryptoAkCipherKeyType',
-  'prefix': 'QCRYPTO_AKCIPHER_KEY_TYPE',
   'data': ['public', 'private']}
 
 ##
diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c
index 940104ee55..e95af9bb72 100644
--- a/backends/cryptodev-builtin.c
+++ b/backends/cryptodev-builtin.c
@@ -334,11 +334,11 @@ static int cryptodev_builtin_create_akcipher_session(
 
 switch (sess_info->keytype) {
 case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PUBLIC:
-type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC;
+type = QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC;
 break;
 
 case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PRIVATE:
-type = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE;
+type = QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE;
 break;
 
 default:
diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c
index 45aba1ff67..e1ee11a158 100644
--- a/backends/cryptodev-lkcf.c
+++ b/backends/cryptodev-lkcf.c
@@ -322,7 +322,7 @@ static void cryptodev_lkcf_execute_task(CryptoDevLKCFTask 
*task)
  * 2. generally, public key related compution is fast, just compute it with
  * thread-pool.
  */
-if (session->keytype == QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE) {
+if (session->keytype == QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE) {
 if (qcrypto_akcipher_export_p8info(&session->akcipher_opts,
session->key, session->keylen,
&p8info, &p8info_len,
@@ -534,11 +534,11 @@ static int cryptodev_lkcf_create_asym_session(
 
 switch (sess_info->keytype) {
 case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PUBLIC:
-sess->keytype = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC;
+sess->keytype = QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC;
 break;
 
 case VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PRIVATE:
-sess->keytype = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE;
+sess->keytype = QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE;
 break;
 
 default:
diff --git a/tests/bench/benchmark-crypto-akcipher.c 
b/tests/bench/benchmark-crypto-akcipher.c
index 5e68cb0a1c..bbc29c9b12 100644
--- a/tests/bench/benchmark-crypto-akcipher.c
+++ b/tests/bench/benchmark-crypto-akcipher.c
@@ -28,7 +28,7 @@ static QCryptoAkCipher *create_rsa_akcipher(const uint8_t 
*priv_key,
 opt.alg = QCRYPTO_AKCIPHER_ALG_RSA;
 opt.u.rsa.padding_alg = padding;
 opt.u.rsa.hash_alg = hash;
-return qcrypto_akcipher_new(&opt, QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE,
+return qcrypto_akcipher_new(&opt, QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE,
 priv_key, keylen, &error_abort);
 }
 
diff --git a/tests/unit/test-crypto-akcipher.c 
b/tests/unit/test-crypto-akcipher.c
index 4f1f4214dd..59bc6f1e69 100644
--- a/tests/unit/test-crypto-akcipher.c
+++ b/tests/unit/test-crypto-akcipher.c
@@ -692,7 +692,7 @@ struct QCryptoAkCipherTestData {
 static QCryptoRSAKeyTestData rsakey_test_data[] = {
 {
 .path = "/crypto/akcipher/rsakey-1024-public",
-.key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC,
+.key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PUBLIC,
 .key = rsa1024_public_key,
 .keylen = sizeof(rsa1024_public_key),
 .is_valid_key = true,
@@ -700,7 +700,7 @@ static QCryptoRSAKeyTestData rsakey_test_data[] = {
 },
 {
 .path = "/crypto/akcipher/rsakey-1024-private",
-.key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE,
+.key_type = QCRYPTO_AK_CIPHER_KEY_TYPE_PRIVATE,
 .key = rsa1024_private_key,
 .keylen = sizeof(rsa1024_private_key),
 .is_valid_key = true,
@@ -708,7 +708,7 @@ static QCryptoRSAKeyTestData rsakey_test_data[] = {
 },
 {
 .path = "/crypto/akcipher/rsakey-2048-public",

Re: [PATCH v2] block-backend: per-device throttling of BLOCK_IO_ERROR reports

2024-07-19 Thread Markus Armbruster
Kevin Wolf  writes:

> Am 19.07.2024 um 06:54 hat Markus Armbruster geschrieben:
>> Kevin Wolf  writes:
>> 
>> > Am 09.01.2024 um 14:13 hat Vladimir Sementsov-Ogievskiy geschrieben:
>> >> From: Leonid Kaplan 
>> >> 
>> >> BLOCK_IO_ERROR events comes from guest, so we must throttle them.
>> >> We still want per-device throttling, so let's use device id as a key.
>> >> 
>> >> Signed-off-by: Leonid Kaplan 
>> >> Signed-off-by: Vladimir Sementsov-Ogievskiy 
>> >> ---
>> >> 
>> >> v2: add Note: to QAPI doc
>> >> 
>> >>  monitor/monitor.c| 10 ++
>> >>  qapi/block-core.json |  2 ++
>> >>  2 files changed, 12 insertions(+)
>> >> 
>> >> diff --git a/monitor/monitor.c b/monitor/monitor.c
>> >> index 01ede1babd..ad0243e9d7 100644
>> >> --- a/monitor/monitor.c
>> >> +++ b/monitor/monitor.c
>> >> @@ -309,6 +309,7 @@ int error_printf_unless_qmp(const char *fmt, ...)
>> >>  static MonitorQAPIEventConf monitor_qapi_event_conf[QAPI_EVENT__MAX] = {
>> >>  /* Limit guest-triggerable events to 1 per second */
>> >>  [QAPI_EVENT_RTC_CHANGE]= { 1000 * SCALE_MS },
>> >> +[QAPI_EVENT_BLOCK_IO_ERROR]= { 1000 * SCALE_MS },
>> >>  [QAPI_EVENT_WATCHDOG]  = { 1000 * SCALE_MS },
>> >>  [QAPI_EVENT_BALLOON_CHANGE]= { 1000 * SCALE_MS },
>> >>  [QAPI_EVENT_QUORUM_REPORT_BAD] = { 1000 * SCALE_MS },
>> >> @@ -498,6 +499,10 @@ static unsigned int qapi_event_throttle_hash(const 
>> >> void *key)
>> >>  hash += g_str_hash(qdict_get_str(evstate->data, "qom-path"));
>> >>  }
>> >>  
>> >> +if (evstate->event == QAPI_EVENT_BLOCK_IO_ERROR) {
>> >> +hash += g_str_hash(qdict_get_str(evstate->data, "device"));
>> >> +}
>> >
>> > Using "device" only works with -drive, i.e. when the BlockBackend
>> > actually has a name. In modern configurations with a -blockdev
>> > referenced by -device, the BlockBackend doesn't have a name any more.
>> >
>> > Maybe we should be using the qdev id (or more generally, QOM path) here,
>> > but that's something the event doesn't even contain yet.
>> 
>> Uh, does the event reliably identify the I/O error's node or not?  If
>> not, then that's a serious design defect.
>> 
>> There's @node-name.  Several commands use "either @device or @node-name"
>> to identify a node.  Is that sufficient here?
>
> Possibly. The QAPI event is sent by a device, not by the backend, and
> the commit message claims per-device throttling. That's what made me
> think that we should base it on the device id.

This is an argument for having the event point at the device.  Events
that already point at the device carry a mandatory @qom-path, and some
also carry an optional qdev @id for backward compatibility.

As far as I can tell, not all devices implement this event.  If that's
true, then documentation should spell it out.

> But it's true that the error does originate in the backend (and it's
> unlikely that two devices are attached to the same node anyway), so the
> node-name could be good enough if we don't have a BlockBackend name. We
> should claim per-block-node rather then per-device throttling then.

Yes.




Re: [PATCH v5 3/3] qapi: introduce device-sync-config

2024-07-19 Thread Markus Armbruster
Vladimir Sementsov-Ogievskiy  writes:

> On 18.07.24 11:27, Markus Armbruster wrote:
>> Vladimir Sementsov-Ogievskiy  writes:
>> 
>>> Add command to sync config from vhost-user backend to the device. It
>>> may be helpful when VHOST_USER_SLAVE_CONFIG_CHANGE_MSG failed or not
>>> triggered interrupt to the guest or just not available (not supported
>>> by vhost-user server).
>>>
>>> Command result is racy if allow it during migration. Let's allow the
>>> sync only in RUNNING state.
>>
>> Is this still accurate?  The runstate_is_running() check is gone in
>> v4, the migration_is_running() check remains.
>
> Right, better to fix commit message like:
>
> Command result is racy if allow it during migration. Let's not allow it.

Suggest "Let's not allow that."

Thanks!

>>> Signed-off-by: Vladimir Sementsov-Ogievskiy 
>>
>> QAPI schema and QMP part:
>> Signed-off-by: Markus Armbruster 




Re: [PATCH v2] block-backend: per-device throttling of BLOCK_IO_ERROR reports

2024-07-19 Thread Markus Armbruster
Kevin Wolf  writes:

> Am 09.01.2024 um 14:13 hat Vladimir Sementsov-Ogievskiy geschrieben:
>> From: Leonid Kaplan 
>> 
>> BLOCK_IO_ERROR events comes from guest, so we must throttle them.
>> We still want per-device throttling, so let's use device id as a key.
>> 
>> Signed-off-by: Leonid Kaplan 
>> Signed-off-by: Vladimir Sementsov-Ogievskiy 
>> ---
>> 
>> v2: add Note: to QAPI doc
>> 
>>  monitor/monitor.c| 10 ++
>>  qapi/block-core.json |  2 ++
>>  2 files changed, 12 insertions(+)
>> 
>> diff --git a/monitor/monitor.c b/monitor/monitor.c
>> index 01ede1babd..ad0243e9d7 100644
>> --- a/monitor/monitor.c
>> +++ b/monitor/monitor.c
>> @@ -309,6 +309,7 @@ int error_printf_unless_qmp(const char *fmt, ...)
>>  static MonitorQAPIEventConf monitor_qapi_event_conf[QAPI_EVENT__MAX] = {
>>  /* Limit guest-triggerable events to 1 per second */
>>  [QAPI_EVENT_RTC_CHANGE]= { 1000 * SCALE_MS },
>> +[QAPI_EVENT_BLOCK_IO_ERROR]= { 1000 * SCALE_MS },
>>  [QAPI_EVENT_WATCHDOG]  = { 1000 * SCALE_MS },
>>  [QAPI_EVENT_BALLOON_CHANGE]= { 1000 * SCALE_MS },
>>  [QAPI_EVENT_QUORUM_REPORT_BAD] = { 1000 * SCALE_MS },
>> @@ -498,6 +499,10 @@ static unsigned int qapi_event_throttle_hash(const void 
>> *key)
>>  hash += g_str_hash(qdict_get_str(evstate->data, "qom-path"));
>>  }
>>  
>> +if (evstate->event == QAPI_EVENT_BLOCK_IO_ERROR) {
>> +hash += g_str_hash(qdict_get_str(evstate->data, "device"));
>> +}
>
> Using "device" only works with -drive, i.e. when the BlockBackend
> actually has a name. In modern configurations with a -blockdev
> referenced by -device, the BlockBackend doesn't have a name any more.
>
> Maybe we should be using the qdev id (or more generally, QOM path) here,
> but that's something the event doesn't even contain yet.

Uh, does the event reliably identify the I/O error's node or not?  If
not, then that's a serious design defect.

There's @node-name.  Several commands use "either @device or @node-name"
to identify a node.  Is that sufficient here?

[...]




[PATCH] qapi-block-core: Clean up blockdev-snapshot-internal-sync doc

2024-07-18 Thread Markus Armbruster
BlockdevSnapshotInternal is the arguments type of command
blockdev-snapshot-internal-sync.  Its doc comment contains this note:

# .. note:: In a transaction, if @name is empty or any snapshot matching
#@name exists, the operation will fail.  Only some image formats
#support it; for example, qcow2, and rbd.

"In a transaction" is misleading, and "if @name is empty or any
snapshot matching @name exists, the operation will fail" is redundant
with the command's Errors documentation.  Drop.

The remainder is fine.  Move it to the command's doc comment, where it
is more prominently visible, with a slight rephrasing for clarity.

Signed-off-by: Markus Armbruster 
---
 qapi/block-core.json | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/qapi/block-core.json b/qapi/block-core.json
index f400b334c8..994e384a71 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -6046,10 +6046,6 @@
 #
 # @name: the name of the internal snapshot to be created
 #
-# .. note:: In a transaction, if @name is empty or any snapshot matching
-#@name exists, the operation will fail.  Only some image formats
-#support it; for example, qcow2, and rbd.
-#
 # Since: 1.7
 ##
 { 'struct': 'BlockdevSnapshotInternal',
@@ -6070,6 +6066,9 @@
 # - If the format of the image used does not support it,
 #   GenericError
 #
+# .. note:: Only some image formats such as qcow2 and rbd support
+#internal snapshots.
+#
 # Since: 1.7
 #
 # .. qmp-example::
-- 
2.45.0




Re: [PATCH v9 4/7] qapi: add blockdev-replace command

2024-07-18 Thread Markus Armbruster
Vladimir Sementsov-Ogievskiy  writes:

> Add a command that can replace bs in following BdrvChild structures:
>
>  - qdev blk root child
>  - block-export blk root child
>  - any child of BlockDriverState selected by child-name
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy 
> ---
>  blockdev.c | 56 +++
>  qapi/block-core.json   | 88 ++
>  stubs/blk-by-qdev-id.c | 13 +++
>  stubs/meson.build  |  1 +
>  4 files changed, 158 insertions(+)
>  create mode 100644 stubs/blk-by-qdev-id.c
>
> diff --git a/blockdev.c b/blockdev.c
> index ba7e90b06e..2190467022 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -3559,6 +3559,62 @@ void qmp_x_blockdev_set_iothread(const char 
> *node_name, StrOrNull *iothread,
>  bdrv_try_change_aio_context(bs, new_context, NULL, errp);
>  }
>  
> +void qmp_blockdev_replace(BlockdevReplace *repl, Error **errp)
> +{
> +BdrvChild *child = NULL;
> +BlockDriverState *new_child_bs;
> +
> +if (repl->parent_type == BLOCK_PARENT_TYPE_DRIVER) {
> +BlockDriverState *parent_bs;
> +
> +parent_bs = bdrv_find_node(repl->u.driver.node_name);
> +if (!parent_bs) {
> +error_setg(errp, "Block driver node with node-name '%s' not "
> +   "found", repl->u.driver.node_name);
> +return;
> +}
> +
> +child = bdrv_find_child(parent_bs, repl->u.driver.child);
> +if (!child) {
> +error_setg(errp, "Block driver node '%s' doesn't have child "
> +   "named '%s'", repl->u.driver.node_name,
> +   repl->u.driver.child);
> +return;
> +}
> +} else {
> +/* Other types are similar, they work through blk */
> +BlockBackend *blk;
> +bool is_qdev = repl->parent_type == BLOCK_PARENT_TYPE_QDEV;
> +const char *id =
> +is_qdev ? repl->u.qdev.qdev_id : repl->u.export.export_id;
> +
> +assert(is_qdev || repl->parent_type == BLOCK_PARENT_TYPE_EXPORT);
> +
> +blk = is_qdev ? blk_by_qdev_id(id, errp) : blk_by_export_id(id, 
> errp);

blk_by_export_id() finds export @exp, and returns the associated block
backend exp->blk.  Fine.

blk_by_qdev_id() finds the device, and then searches @block_backends for
a blk with blk->dev == blk.  If a device has more than one block
backend, you get the one first in @block_backends.  I figure that's the
one created first.

Interface issue: when a device has multiple block backends, only one of
them can be replaced, and which one is kind of random.

Do such devices exist?

If no, could they exist?

If yes, what should we do about it now?

> +if (!blk) {
> +return;
> +}
> +
> +child = blk_root(blk);
> +if (!child) {
> +error_setg(errp, "%s '%s' is empty, nothing to replace",
> +   is_qdev ? "Device" : "Export", id);
> +return;
> +}
> +}
> +
> +assert(child);
> +assert(child->bs);
> +
> +new_child_bs = bdrv_find_node(repl->new_child);
> +if (!new_child_bs) {
> +error_setg(errp, "Node '%s' not found", repl->new_child);
> +return;
> +}
> +
> +bdrv_replace_child_bs(child, new_child_bs, errp);
> +}
> +
>  QemuOptsList qemu_common_drive_opts = {
>  .name = "drive",
>  .head = QTAILQ_HEAD_INITIALIZER(qemu_common_drive_opts.head),
> diff --git a/qapi/block-core.json b/qapi/block-core.json
> index df5e07debd..0a6f08a6e0 100644
> --- a/qapi/block-core.json
> +++ b/qapi/block-core.json
> @@ -6148,3 +6148,91 @@
>  ##
>  { 'struct': 'DummyBlockCoreForceArrays',
>'data': { 'unused-block-graph-info': ['BlockGraphInfo'] } }
> +
> +##
> +# @BlockParentType:
> +#
> +# @qdev: block device, such as created by device_add, and denoted by
> +# qdev-id
> +#
> +# @driver: block driver node, such as created by blockdev-add, and
> +# denoted by node-name

node-name and child?

> +#
> +# @export: block export, such created by block-export-add, and
> +# denoted by export-id
> +#
> +# Since 9.1
> +##

I'm kind of unhappy with this doc comment.  I feel makes sense only in
the context of its use.  Let me try to avoid that:

   # @driver: the parent is a block node, the child is one of its
   # children.
   #
   # @export: the parent is a block export, the child is its block
   # backend.
   #
   # @qdev: the parent is a device, the child is its block backend.

> +{ 'enum': 'BlockParentType',
> +  'data': ['qdev', 'driver', 'export'] }

If you take my comment, change the order here as well.

> +
> +##
> +# @BdrvChildRefQdev:
> +#
> +# @qdev-id: the device's ID or QOM path
> +#
> +# Since 9.1
> +##
> +{ 'struct': 'BdrvChildRefQdev',
> +  'data': { 'qdev-id': 'str' } }
> +
> +##
> +# @BdrvChildRefExport:
> +#
> +# @export-id: block export identifier

block-export.json calls this "block export id" in some places, and
"block export identifier" in oth

Re: [PATCH v9 2/7] block/export: add blk_by_export_id()

2024-07-18 Thread Markus Armbruster
Vladimir Sementsov-Ogievskiy  writes:

> We need it for further blockdev-replace functionality.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy 
> ---
>  block/export/export.c   | 18 ++
>  include/sysemu/block-backend-global-state.h |  1 +
>  2 files changed, 19 insertions(+)
>
> diff --git a/block/export/export.c b/block/export/export.c
> index 6d51ae8ed7..57beae7982 100644
> --- a/block/export/export.c
> +++ b/block/export/export.c
> @@ -355,3 +355,21 @@ BlockExportInfoList *qmp_query_block_exports(Error 
> **errp)
>  
>  return head;
>  }
> +
> +BlockBackend *blk_by_export_id(const char *id, Error **errp)
> +{
> +BlockExport *exp;
> +
> +exp = blk_exp_find(id);
> +if (exp == NULL) {
> +error_setg(errp, "Export '%s' not found", id);
> +return NULL;
> +}
> +
> +if (!exp->blk) {
> +error_setg(errp, "Export '%s' is empty", id);

Can this happen?

> +return NULL;
> +}
> +
> +return exp->blk;
> +}
> diff --git a/include/sysemu/block-backend-global-state.h 
> b/include/sysemu/block-backend-global-state.h
> index ccb35546a1..410d0cc5c7 100644
> --- a/include/sysemu/block-backend-global-state.h
> +++ b/include/sysemu/block-backend-global-state.h
> @@ -74,6 +74,7 @@ void blk_detach_dev(BlockBackend *blk, DeviceState *dev);
>  DeviceState *blk_get_attached_dev(BlockBackend *blk);
>  BlockBackend *blk_by_dev(void *dev);
>  BlockBackend *blk_by_qdev_id(const char *id, Error **errp);
> +BlockBackend *blk_by_export_id(const char *id, Error **errp);
>  void blk_set_dev_ops(BlockBackend *blk, const BlockDevOps *ops, void 
> *opaque);
>  
>  void blk_activate(BlockBackend *blk, Error **errp);




Re: [PATCH v2 6/7] qapi/block-core: derpecate block-job-change

2024-07-18 Thread Markus Armbruster
Vladimir Sementsov-Ogievskiy  writes:

> That's a first step to move on newer job-* APIs.
>
> The difference between block-job-change and job-change is in
> find_block_job_locked() vs find_job_locked() functions. What's
> different?
>
> 1. find_block_job_locked() do check, is found job a block-job. This OK

Do you mean something like find_block_job_locked() finds only block
jobs, whereas find_job_locked() finds any kind of job?

>when moving to more generic API, no needs to document this change.
>
> 2. find_block_job_locked() reports DeviceNotActive on failure, when
>find_job_locked() reports GenericError. Still, for block-job-change
>errors are not documented at all, so be silent in deprecated.txt as
>well.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy 




Re: [PATCH v2 5/7] qapi: add job-change

2024-07-18 Thread Markus Armbruster
Vladimir Sementsov-Ogievskiy  writes:

> Add a new-style command job-change, doing same thing as
> block-job-change. The aim is finally deprecate block-job-* APIs and
> move to job-* APIs.
>
> We add a new command to qapi/block-core.json, not to
> qapi/job.json to avoid resolving json file including loops for now.
> This all would be a lot simple to refactor when we finally drop
> deprecated block-job-* APIs.
>
> @type argument of the new command immediately becomes deprecated.

Where?

> Signed-off-by: Vladimir Sementsov-Ogievskiy 
> ---
>  job-qmp.c| 14 ++
>  qapi/block-core.json | 10 ++
>  2 files changed, 24 insertions(+)
>
> diff --git a/job-qmp.c b/job-qmp.c
> index c764bd3801..248e68f554 100644
> --- a/job-qmp.c
> +++ b/job-qmp.c
> @@ -139,6 +139,20 @@ void qmp_job_dismiss(const char *id, Error **errp)
>  job_dismiss_locked(&job, errp);
>  }
>  
> +void qmp_job_change(JobChangeOptions *opts, Error **errp)
> +{
> +Job *job;
> +
> +JOB_LOCK_GUARD();
> +job = find_job_locked(opts->id, errp);
> +
> +if (!job) {
> +return;
> +}
> +
> +job_change_locked(job, opts, errp);
> +}
> +
>  /* Called with job_mutex held. */
>  static JobInfo *job_query_single_locked(Job *job, Error **errp)
>  {
> diff --git a/qapi/block-core.json b/qapi/block-core.json
> index 660c7f4a48..9087ce300c 100644
> --- a/qapi/block-core.json
> +++ b/qapi/block-core.json
> @@ -3104,6 +3104,16 @@
>  { 'command': 'block-job-change',
>'data': 'JobChangeOptions', 'boxed': true }
>  
> +##
> +# @job-change:
> +#
> +# Change the block job's options.
> +#
> +# Since: 9.1
> +##
> +{ 'command': 'job-change',
> +  'data': 'JobChangeOptions', 'boxed': true }
> +
>  ##
>  # @BlockdevDiscardOptions:
>  #




Re: [PATCH v2 3/7] qapi: block-job-change: make copy-mode parameter optional

2024-07-18 Thread Markus Armbruster
Vladimir Sementsov-Ogievskiy  writes:

> We are going to add more parameters to change. We want to make possible
> to change only one or any subset of available options. So all the
> options should be optional.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy 
> ---
>  block/mirror.c   | 4 
>  qapi/block-core.json | 3 ++-
>  2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/block/mirror.c b/block/mirror.c
> index 2816bb1042..60e8d83e4f 100644
> --- a/block/mirror.c
> +++ b/block/mirror.c
> @@ -1272,6 +1272,10 @@ static void mirror_change(BlockJob *job, 
> JobChangeOptions *opts,
>  
>  GLOBAL_STATE_CODE();
>  
> +if (!change_opts->has_copy_mode) {
> +return;
> +}
> +
>  if (qatomic_read(&s->copy_mode) == change_opts->copy_mode) {
>  return;
>  }
> diff --git a/qapi/block-core.json b/qapi/block-core.json
> index 4ec5632596..660c7f4a48 100644
> --- a/qapi/block-core.json
> +++ b/qapi/block-core.json
> @@ -3071,11 +3071,12 @@
>  #
>  # @copy-mode: Switch to this copy mode.  Currently, only the switch
>  # from 'background' to 'write-blocking' is implemented.
> +# If absent, copy mode remains the same.  (optional since 9.1)
>  #
>  # Since: 8.2
>  ##
>  { 'struct': 'JobChangeOptionsMirror',
> -  'data': { 'copy-mode' : 'MirrorCopyMode' } }
> +  'data': { '*copy-mode' : 'MirrorCopyMode' } }
>  
>  ##
>  # @JobChangeOptions:

Acked-by: Markus Armbruster 




Re: [PATCH v2 1/7] qapi: rename BlockJobChangeOptions to JobChangeOptions

2024-07-18 Thread Markus Armbruster
Vladimir Sementsov-Ogievskiy  writes:

> We are going to move change action from block-job to job
> implementation, and then move to job-* extenral APIs, deprecating
> block-job-* APIs. This commit simplifies further transition.
>
> The commit is made by command
>
> git grep -l BlockJobChangeOptions | \
> xargs sed -i 's/BlockJobChangeOptions/JobChangeOptions/g'
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy 

Acked-by: Markus Armbruster 




Re: [PATCH v5 0/3] vhost-user-blk: live resize additional APIs

2024-07-18 Thread Markus Armbruster
Vladimir Sementsov-Ogievskiy  writes:

> ping. Markus, Eric, could someone give an ACC for QAPI part?

I apologize for the delay.  It was pretty bad.




Re: [PATCH v5 1/3] qdev-monitor: add option to report GenericError from find_device_state

2024-07-18 Thread Markus Armbruster
Vladimir Sementsov-Ogievskiy  writes:

> Here we just prepare for the following patch, making possible to report
> GenericError as recommended.
>
> This patch doesn't aim to prevent further use of DeviceNotFound by
> future interfaces:
>
>  - find_device_state() is used in blk_by_qdev_id() and qmp_get_blk()
>functions, which may lead to spread of DeviceNotFound anyway
>  - also, nothing prevent simply copy-pasting find_device_state() calls
>with false argument

A possible way to reduce the likelihood of further spread:

1. Rename find_device_state() to find_device_state_legacy().

2. New find_device_state() that reports GenericError.

Could also be done in a follow-up.

>
> Signed-off-by: Vladimir Sementsov-Ogievskiy 

The patch does what it says on the tin, so
Reviewed-by: Markus Armbruster 




Re: [PATCH v5 3/3] qapi: introduce device-sync-config

2024-07-18 Thread Markus Armbruster
Vladimir Sementsov-Ogievskiy  writes:

> Add command to sync config from vhost-user backend to the device. It
> may be helpful when VHOST_USER_SLAVE_CONFIG_CHANGE_MSG failed or not
> triggered interrupt to the guest or just not available (not supported
> by vhost-user server).
>
> Command result is racy if allow it during migration. Let's allow the
> sync only in RUNNING state.

Is this still accurate?  The runstate_is_running() check is gone in
v4, the migration_is_running() check remains.

> Signed-off-by: Vladimir Sementsov-Ogievskiy 

QAPI schema and QMP part:
Signed-off-by: Markus Armbruster 




Re: [PATCH v2 6/9] qapi: convert "Example" sections without titles

2024-07-17 Thread Markus Armbruster
John Snow  writes:

> On Wed, Jul 17, 2024, 3:44 AM Markus Armbruster  wrote:
>
>> John Snow  writes:
>>
>> > Use the no-option form of ".. qmp-example::" to convert any Examples
>> > that do not have any form of caption or explanation whatsoever. Note
>> > that in a few cases, example sections are split into two or more
>> > separate example blocks. This is only done stylistically to create a
>> > delineation between two or more logically independent examples.
>> >
>> > See commit-3: "docs/qapidoc: create qmp-example directive", for a
>> >   detailed explanation of this custom directive syntax.
>> >
>> > See commit+3: "qapi: remove "Example" doc section" for a detailed
>> >   explanation of why.
>> >
>> > Note: an empty "TODO" line was added to announce-self to keep the
>> > example from floating up into the body; this will be addressed more
>> > rigorously in the new qapidoc generator.
>> >
>> > Signed-off-by: John Snow 
>>
>> [...]
>>
>> > diff --git a/qapi/run-state.json b/qapi/run-state.json
>> > index 4d40c88876c..ab7116680b3 100644
>> > --- a/qapi/run-state.json
>> > +++ b/qapi/run-state.json
>>
>> [...]
>>
>> > @@ -469,7 +469,7 @@
>> >  #
>> >  # Since: 9.1
>> >  #
>> > -# Example:
>> > +# ..qmp-example::
>>
>> Lacks a space, output is messed up.  Can fix in my tree.
>
> Whoops. Wish rST was a bit pickier sometimes...

"I find it to be the Perl of ASCII-based markups." (Paolo)

>> >  #
>> >  # <- { "event": "GUEST_PVSHUTDOWN",
>> >  #  "timestamp": { "seconds": 1648245259, "microseconds": 893771
>> } }
>>
>> [...]
>>
>> R-by stands.




Re: [PATCH v2 0/9] qapi: convert example sections to qmp-example rST directives

2024-07-17 Thread Markus Armbruster
John Snow  writes:

> This patchset focuses on converting example sections to rST directives
> using a new `.. qmp-example::` directive.

Queued, thanks!




Re: [PATCH v2 9/9] qapi: remove "Example" doc section

2024-07-17 Thread Markus Armbruster
John Snow  writes:

> Fully eliminate the "Example" sections in QAPI doc blocks now that they
> have all been converted to arbitrary rST syntax using the
> ".. qmp-example::" directive. Update tests to match.
>
> Migrating to the new syntax
> ---
>
> The old "Example:" or "Examples:" section syntax is now caught as an
> error, but "Example::" is stil permitted as explicit rST syntax for an
> un-lexed, generic preformatted text block.
>
> ('Example' is not special in this case, any sentence that ends with "::"
> will start an indented code block in rST.)
>
> Arbitrary rST for Examples is now possible, but it's strongly
> recommended that documentation authors use the ".. qmp-example::"
> directive for consistent visual formatting in rendered HTML docs. The
> ":title:" directive option may be used to add extra information into the
> title bar for the example. The ":annotated:" option can be used to write
> arbitrary rST instead, with nested "::" blocks applying QMP formatting
> where desired.
>
> Other choices available are ".. code-block:: QMP" which will not create
> an "Example:" box, or the short-form "::" code-block syntax which will
> not apply QMP highlighting when used outside of the qmp-example
> directive.
>
> Why?
> 
>
> This patch has several benefits:
>
> 1. Example sections can now be written more arbitrarily, mixing
>explanatory paragraphs and code blocks however desired.
>
> 2. Example sections can now use fully arbitrary rST.
>
> 3. All code blocks are now lexed and validated as QMP; increasing
>usability of the docs and ensuring validity of example snippets.
>
>(To some extent - This patch only gaurantees it lexes correctly, not
>that it's valid under the JSON or QMP grammars. It will catch most
>small mistakes, however.)
>
> 4. Each qmp-example can be titled or annotated independently without
>bypassing the QMP lexer/validator.
>
>(i.e. code blocks are now for *code* only, so we don't have to
>sacrifice exposition for having lexically valid examples.)
>
> NOTE: As with the "Notes" conversion (d461c279737), this patch (and the
>   three preceding) may change the rendering order for Examples in
>   the current generator. The forthcoming qapidoc rewrite will fix
>   this by always generating documentation in source order.
>
> Signed-off-by: John Snow 

Reviewed-by: Markus Armbruster 




Re: [PATCH v2 6/9] qapi: convert "Example" sections without titles

2024-07-17 Thread Markus Armbruster
John Snow  writes:

> Use the no-option form of ".. qmp-example::" to convert any Examples
> that do not have any form of caption or explanation whatsoever. Note
> that in a few cases, example sections are split into two or more
> separate example blocks. This is only done stylistically to create a
> delineation between two or more logically independent examples.
>
> See commit-3: "docs/qapidoc: create qmp-example directive", for a
>   detailed explanation of this custom directive syntax.
>
> See commit+3: "qapi: remove "Example" doc section" for a detailed
>   explanation of why.
>
> Note: an empty "TODO" line was added to announce-self to keep the
> example from floating up into the body; this will be addressed more
> rigorously in the new qapidoc generator.
>
> Signed-off-by: John Snow 

[...]

> diff --git a/qapi/run-state.json b/qapi/run-state.json
> index 4d40c88876c..ab7116680b3 100644
> --- a/qapi/run-state.json
> +++ b/qapi/run-state.json

[...]

> @@ -469,7 +469,7 @@
>  #
>  # Since: 9.1
>  #
> -# Example:
> +# ..qmp-example::

Lacks a space, output is messed up.  Can fix in my tree.

>  #
>  # <- { "event": "GUEST_PVSHUTDOWN",
>  #  "timestamp": { "seconds": 1648245259, "microseconds": 893771 } }

[...]

R-by stands.




Re: [PATCH 8/8] qapi: remove "Example" doc section

2024-07-09 Thread Markus Armbruster
John Snow  writes:

> On Tue, Jul 9, 2024 at 6:52 AM Markus Armbruster  wrote:
>
>> John Snow  writes:
>>
>> > Fully eliminate the "Example" sections in QAPI doc blocks now that they
>> > have all been converted to arbitrary rST syntax using the
>> > ".. qmp-example::" directive. Update tests to match.
>> >
>> > Migrating to the new syntax
>> > ---
>> >
>> > The old "Example:" or "Examples:" section syntax is now caught as an
>> > error, but "Example::" is stil permitted as explicit rST syntax for an
>> > un-lexed, generic preformatted text block.
>> >
>> > ('Example' is not special in this case, any sentence that ends with "::"
>> > will start an indented code block in rST.)
>> >
>> > Arbitrary rST for Examples is now possible, but it's strongly
>> > recommended that documentation authors use the ".. qmp-example::"
>> > directive for consistent visual formatting in rendered HTML docs. The
>> > ":title:" directive option may be used to add extra information into the
>> > title bar for the example. The ":annotated:" option can be used to write
>> > arbitrary rST instead, with nested "::" blocks applying QMP formatting
>> > where desired.
>> >
>> > Other choices available are ".. code-block:: QMP" which will not create
>> > an "Example:" box, or the short-form "::" code-block syntax which will
>> > not apply QMP highlighting when used outside of the qmp-example
>> > directive.
>> >
>> > Why?
>> > 
>> >
>> > This patch has several benefits:
>> >
>> > 1. Example sections can now be written more arbitrarily, mixing
>> >explanatory paragraphs and code blocks however desired.
>> >
>> > 2. Example sections can now use fully arbitrary rST.
>> >
>> > 3. All code blocks are now lexed and validated as QMP; increasing
>> >usability of the docs and ensuring validity of example snippets.
>> >
>> >(To some extent - This patch only gaurantees it lexes correctly, not
>> >that it's valid under the JSON or QMP grammars. It will catch most
>> >small mistakes, however.)
>> >
>> > 4. Each qmp-example can be titled or annotated independently without
>> >bypassing the QMP lexer/validator.
>> >
>> >(i.e. code blocks are now for *code* only, so we don't have to
>> >sacrifice exposition for having lexically valid examples.)
>> >
>> > NOTE: As with the "Notes" conversion patch,
>>
>> Commit d461c279737 (qapi: convert "Note" sections to plain rST).
>>
>
> Didn't have a stable commit ID at the time, will work it in if/when the
> notes patches hit main.

They have.

>> > this patch (and those
>> >   preceding) may change the rendering order for Examples in the
>>
>> The three preceding ones, to be precise.
>>
>> >   current generator. The forthcoming qapidoc rewrite will fix this
>> >   by always generating documentation in source order.
>>
>> Conversions from "Example" section to plain reST may change order.  This
>> patch converts a test, and the preceding three convert the real uses.
>>
>> Does any of the patches actually change order?
>
> I do not actually know ...! It has the *potential* in the same exact way
> that the notes patch did, but I don't actually know if it *did*. My hunch
> is "no" because there's only one intermediate section we identified with
> the notes series, but I didn't exhaustively prove it. That's why I used the
> "may" weasel wording.

Alright, I checked.

In documentation of command announce-self, the example moves from after
the arguments to before.  Unwanted change.

I can keep it in place if I insert a TODO before the example like this:

diff --git a/qapi/net.json b/qapi/net.json
index 9a723e56b5..50bfd5b681 100644
--- a/qapi/net.json
+++ b/qapi/net.json
@@ -930,6 +930,8 @@
 # switches.  This can be useful when network bonds fail-over the
 # active slave.
 #
+# TODO: This line is a hack to separate the example from the body
+#
 # .. qmp-example::
 #
 # -> { "execute": "announce-self",

I had to delete the .doctrees cache to make sphinx-build generate
corrected output.

>> 

Re: [PATCH 4/8] docs/sphinx: add CSS styling for qmp-example directive

2024-07-09 Thread Markus Armbruster
John Snow  writes:

> On Tue, Jul 9, 2024 at 6:34 AM Markus Armbruster  wrote:
>
>> John Snow  writes:
>>
>> > From: Harmonie Snow 
>> >
>> > Add CSS styling for qmp-example directives to increase readability and
>> > consistently style all example blocks.
>> >
>> > Signed-off-by: Harmonie Snow 
>> > Signed-off-by: John Snow 
>>
>> Same sadness as for the previous patch.
>>
>
> Should we do anything about that? In the long run, I don't expect anyone
> will actually need to care about what this directive looked like in some
> intermediate state before we ever used it. If you want to evaluate the
> directive in the in-between states, I recommend modifying a document and
> seeing what it does; but I didn't really intend for anyone to really see it
> that way.
>
> (Isn't it a bit overboard to write unit tests for intermediate tree
> states...?)

I'm not asking for temporary tests, I just wonder why you delay
permanent ones until "[PATCH 8/8] qapi: remove "Example" doc section".

No big deal, thus:

>> Acked-by: Markus Armbruster 




Re: [PATCH 0/8] qapi: convert example sections to qmp-example rST directives

2024-07-09 Thread Markus Armbruster
You achieved a clean & consistent look for notes and examples in the
browser.  Love it!




Re: [PATCH 7/8] qapi: convert "Example" sections with longer prose

2024-07-09 Thread Markus Armbruster
John Snow  writes:

> These examples require longer explanations or have explanations that
> require markup to look reasonable when rendered and so use the longer
> form of the ".. qmp-example::" directive.
>
> By using the :annotated: option, the content in the example block is
> assumed *not* to be a code block literal and is instead parsed as normal
> rST - with the exception that any code literal blocks after `::` will
> assumed to be a QMP code literal block.
>
> Note: There's one title-less conversion in this patch that comes along
> for the ride because it's part of a larger "Examples" block that was
> better to convert all at once.
>
> See commit-5: "docs/qapidoc: create qmp-example directive", for a
>   detailed explanation of this custom directive syntax.
>
> See commit+1: "qapi: remove "Example" doc section" for a detailed
>   explanation of why.
>
> Signed-off-by: John Snow 
> ---
>  qapi/block.json | 26 --
>  qapi/machine.json   | 30 --
>  qapi/migration.json |  7 +--
>  qapi/virtio.json| 24 ++--
>  4 files changed, 59 insertions(+), 28 deletions(-)
>
> diff --git a/qapi/block.json b/qapi/block.json
> index 5ddd061e964..d95e9fd8140 100644
> --- a/qapi/block.json
> +++ b/qapi/block.json
> @@ -545,31 +545,37 @@
>  #
>  # Since: 4.0
>  #
> -# Example:
> +# .. qmp-example::
> +#:annotated:
>  #
> -# Set new histograms for all io types with intervals
> -# [0, 10), [10, 50), [50, 100), [100, +inf):
> +#Set new histograms for all io types with intervals
> +#[0, 10), [10, 50), [50, 100), [100, +inf)::
>  #
>  # -> { "execute": "block-latency-histogram-set",
>  #  "arguments": { "id": "drive0",
>  # "boundaries": [10, 50, 100] } }
>  # <- { "return": {} }
>  #
> -# Example:
> +# .. qmp-example::
> +#:annotated:
>  #
> -# Set new histogram only for write, other histograms will remain
> -# not changed (or not created):
> +#Set new histogram only for write, other histograms will remain
> +#not changed (or not created)::
>  #
>  # -> { "execute": "block-latency-histogram-set",
>  #  "arguments": { "id": "drive0",
>  # "boundaries-write": [10, 50, 100] } }
>  # <- { "return": {} }
>  #
> -# Example:
> +# .. qmp-example::
> +#:annotated:
>  #
> -# Set new histograms with the following intervals:
> -#   read, flush: [0, 10), [10, 50), [50, 100), [100, +inf)
> -#   write: [0, 1000), [1000, 5000), [5000, +inf)
> +#Set new histograms with the following intervals:
> +#
> +#- read, flush: [0, 10), [10, 50), [50, 100), [100, +inf)
> +#- write: [0, 1000), [1000, 5000), [5000, +inf)
> +#
> +#::
>  #
>  # -> { "execute": "block-latency-histogram-set",
>  #  "arguments": { "id": "drive0",
   # "boundaries": [10, 50, 100],
   # "boundaries-write": [1000, 5000] } }
   # <- { "return": {} }
   #
   # .. qmp-example::
   #:title: Remove all latency histograms
   #
   # -> { "execute": "block-latency-histogram-set",
   #  "arguments": { "id": "drive0" } }
   # <- { "return": {} }
   ##

I think using :annotated: for this one as well will look better.

[...]

Reviewed-by: Markus Armbruster 




Re: [PATCH 6/8] qapi: convert "Example" sections with titles

2024-07-09 Thread Markus Armbruster
John Snow  writes:

> When an Example section has a brief explanation, convert it to a
> qmp-example:: section using the :title: option.
>
> Rule of thumb: If the title can fit on a single line and requires no rST
> markup, it's a good candidate for using the :title: option of
> qmp-example.
>
> In this patch, trailing punctuation is removed from the title section
> for consistent headline aesthetics. In just one case, specifics of the
> example are removed to make the title read better.
>
> See commit-4: "docs/qapidoc: create qmp-example directive", for a
>   detailed explanation of this custom directive syntax.
>
> See commit+2: "qapi: remove "Example" doc section" for a detailed
>       explanation of why.
>
> Signed-off-by: John Snow 

Reviewed-by: Markus Armbruster 




Re: [PATCH 5/8] qapi: convert "Example" sections without titles

2024-07-09 Thread Markus Armbruster
John Snow  writes:

> On Sat, Jul 6, 2024, 10:42 AM Markus Armbruster  wrote:
>
>> John Snow  writes:
>>
>> > Use the no-option form of ".. qmp-example::" to convert any Examples
>> > that do not have any form of caption or explanation whatsoever. Note
>> > that in a few cases, example sections are split into two or more
>> > separate example blocks. This is only done stylistically to create a
>> > delineation between two or more logically independent examples.
>> >
>> > See commit-3: "docs/qapidoc: create qmp-example directive", for a
>> >   detailed explanation of this custom directive syntax.
>> >
>> > See commit+3: "qapi: remove "Example" doc section" for a detailed
>> >   explanation of why.
>> >
>> > Signed-off-by: John Snow 
>>
>> [...]
>>
>> > diff --git a/qapi/run-state.json b/qapi/run-state.json
>> > index 252d7d6afa7..718a3c958e9 100644
>> > --- a/qapi/run-state.json
>> > +++ b/qapi/run-state.json
>>
>> [...]
>>
>> > @@ -453,7 +453,7 @@
>> >  #
>> >  # Since: 5.0
>> >  #
>> > -# Example:
>> > +# .. qmp-example::
>> >  #
>> >  # <- { "event": "GUEST_CRASHLOADED",
>> >  #  "data": { "action": "run" },
>>
>> Trivial semantic conflict, we need
>>
>
> Caught on rebase late Fri, already fixed locally and will be in v2 (which I
> rebased on top of my sphinx 3.x patches, which change the do_parse() stuff
> too.)

With that fix
Reviewed-by: Markus Armbruster 

[...]




Re: [PATCH 8/8] qapi: remove "Example" doc section

2024-07-09 Thread Markus Armbruster
John Snow  writes:

> Fully eliminate the "Example" sections in QAPI doc blocks now that they
> have all been converted to arbitrary rST syntax using the
> ".. qmp-example::" directive. Update tests to match.
>
> Migrating to the new syntax
> ---
>
> The old "Example:" or "Examples:" section syntax is now caught as an
> error, but "Example::" is stil permitted as explicit rST syntax for an
> un-lexed, generic preformatted text block.
>
> ('Example' is not special in this case, any sentence that ends with "::"
> will start an indented code block in rST.)
>
> Arbitrary rST for Examples is now possible, but it's strongly
> recommended that documentation authors use the ".. qmp-example::"
> directive for consistent visual formatting in rendered HTML docs. The
> ":title:" directive option may be used to add extra information into the
> title bar for the example. The ":annotated:" option can be used to write
> arbitrary rST instead, with nested "::" blocks applying QMP formatting
> where desired.
>
> Other choices available are ".. code-block:: QMP" which will not create
> an "Example:" box, or the short-form "::" code-block syntax which will
> not apply QMP highlighting when used outside of the qmp-example
> directive.
>
> Why?
> 
>
> This patch has several benefits:
>
> 1. Example sections can now be written more arbitrarily, mixing
>explanatory paragraphs and code blocks however desired.
>
> 2. Example sections can now use fully arbitrary rST.
>
> 3. All code blocks are now lexed and validated as QMP; increasing
>usability of the docs and ensuring validity of example snippets.
>
>(To some extent - This patch only gaurantees it lexes correctly, not
>that it's valid under the JSON or QMP grammars. It will catch most
>small mistakes, however.)
>
> 4. Each qmp-example can be titled or annotated independently without
>bypassing the QMP lexer/validator.
>
>(i.e. code blocks are now for *code* only, so we don't have to
>sacrifice exposition for having lexically valid examples.)
>
> NOTE: As with the "Notes" conversion patch,

Commit d461c279737 (qapi: convert "Note" sections to plain rST).

> this patch (and those
>   preceding) may change the rendering order for Examples in the

The three preceding ones, to be precise.

>   current generator. The forthcoming qapidoc rewrite will fix this
>   by always generating documentation in source order.

Conversions from "Example" section to plain reST may change order.  This
patch converts a test, and the preceding three convert the real uses.

Does any of the patches actually change order?

> Signed-off-by: John Snow 
> ---
>  docs/devel/qapi-code-gen.rst| 58 -
>  scripts/qapi/parser.py  | 10 +-
>  tests/qapi-schema/doc-good.json | 19 +++
>  tests/qapi-schema/doc-good.out  | 26 ++-
>  tests/qapi-schema/doc-good.txt  | 23 ++---
>  5 files changed, 98 insertions(+), 38 deletions(-)
>
> diff --git a/docs/devel/qapi-code-gen.rst b/docs/devel/qapi-code-gen.rst
> index ae97b335cbf..2e10a3cbd69 100644
> --- a/docs/devel/qapi-code-gen.rst
> +++ b/docs/devel/qapi-code-gen.rst
> @@ -899,7 +899,7 @@ Documentation markup
>  
>  
>  Documentation comments can use most rST markup.  In particular,
> -a ``::`` literal block can be used for examples::
> +a ``::`` literal block can be used for pre-formatted text::
>  
>  # ::
>  #
> @@ -995,8 +995,8 @@ line "Features:", like this::
># @feature: Description text
>  
>  A tagged section begins with a paragraph that starts with one of the
> -following words: "Since:", "Example:"/"Examples:", "Returns:",
> -"Errors:", "TODO:".  It ends with the start of a new section.
> +following words: "Since:", "Returns:", "Errors:", "TODO:".  It ends with
> +the start of a new section.
>  
>  The second and subsequent lines of tagged sections must be indented
>  like this::
> @@ -1020,13 +1020,53 @@ detailing a relevant error condition. For example::
>  A "Since: x.y.z" tagged section lists the release that introduced the
>  definition.
>  
> -An "Example" or "Examples" section is rendered entirely
> -as literal fixed-width text.  "TODO" sections are not rendered at all
> -(they are for developers, not users of QMP).  In other sections, the
> -text is formatted, and rST markup can be used.
> +"TODO" sections are not rendered at all (they are for developers, not

Drop "at all"?

> +users of QMP).  In other sections, the text is formatted, and rST markup
> +can be used.
> +
> +QMP Examples can be added by using the ``.. qmp-example::``
> +directive. In its simplest form, this can be used to contain a single
> +QMP code block which accepts standard JSON syntax with additional server
> +directionality indicators (``->`` and ``<-``), and elisions (``...``).
> +
> +Optionally, a plaintext title may be provided by using the ``:title:``
> +direct

Re: [PATCH 4/8] docs/sphinx: add CSS styling for qmp-example directive

2024-07-09 Thread Markus Armbruster
John Snow  writes:

> From: Harmonie Snow 
>
> Add CSS styling for qmp-example directives to increase readability and
> consistently style all example blocks.
>
> Signed-off-by: Harmonie Snow 
> Signed-off-by: John Snow 

Same sadness as for the previous patch.

Acked-by: Markus Armbruster 




Re: [PATCH 3/8] docs/qapidoc: add QMP highlighting to annotated qmp-example blocks

2024-07-09 Thread Markus Armbruster
John Snow  writes:

> For any code literal blocks inside of a qmp-example directive, apply and
> enforce the QMP lexer/highlighter to those blocks.
>
> This way, you won't need to write:
>
> ```
> .. qmp-example::
>:annotated:
>
>Blah blah
>
>.. code-block:: QMP
>
>   -> { "lorem": "ipsum" }
> ```
>
> But instead, simply:
>
> ```
> .. qmp-example::
>:annotated:
>
>Blah blah::
>
>  -> { "lorem": "ipsum" }
> ```
>
> Once the directive block is exited, whatever the previous default
> highlight language was will be restored; localizing the forced QMP
> lexing to exclusively this directive.
>
> Note, if the default language is *already* QMP, this directive will not
> generate and restore redundant highlight configuration nodes. We may
> well decide that the default language ought to be QMP for any QAPI
> reference pages, but this way the directive behaves consistently no
> matter where it is used.
>
> Signed-off-by: John Snow 

Sadly, the previous patch didn't add tests, so this patch's effect
isn't as easy to observe as it could be.

Acked-by: Markus Armbruster 




Re: [PATCH 2/8] docs/qapidoc: create qmp-example directive

2024-07-09 Thread Markus Armbruster
John Snow  writes:

> This is a directive that creates a syntactic sugar for creating
> "Example" boxes very similar to the ones already used in the bitmaps.rst
> document, please see e.g.
> https://www.qemu.org/docs/master/interop/bitmaps.html#creation-block-dirty-bitmap-add
>
> In its simplest form, when a custom title is not needed or wanted, and
> the example body is *solely* a QMP example:
>
> ```
> .. qmp-example::
>
>{body}
> ```
>
> is syntactic sugar for:
>
> ```
> .. admonition:: Example:
>
>.. code-block:: QMP
>
>   {body}
> ```
>
> When a custom, plaintext title that describes the example is desired,
> this form:
>
> ```
> .. qmp-example::
>:title: Defrobnification
>
>{body}
> ```
>
> Is syntactic sugar for:
>
> ```
> .. admonition:: Example: Defrobnification
>
>.. code-block:: QMP
>
>   {body}
> ```
>
> Lastly, when Examples are multi-step processes that require non-QMP
> exposition, have lengthy titles, or otherwise involve prose with rST
> markup (lists, cross-references, etc), the most complex form:
>
> ```
> .. qmp-example::
>:annotated:
>
>This example shows how to use `foo-command`::
>
>  {body}
>
>For more information, please see `frobnozz`.
> ```
>
> Is desugared to:
>
> ```
> .. admonition:: Example:
>
>This example shows how to use `foo-command`::
>
>  {body}
>
>For more information, please see `frobnozz`.
> ```
>
> Note that :annotated: and :title: options can be combined together, if
> desired.
>
> The primary benefit here being documentation source consistently using
> the same directive for all forms of examples to ensure consistent visual
> styling, and ensuring all relevant prose is visually grouped alongside
> the code literal block.
>
> Note that as of this commit, the code-block rST syntax "::" does not
> apply QMP highlighting; you would need to use ".. code-block:: QMP". The
> very next commit changes this behavior to assume all "::" code blocks
> within this directive are QMP blocks.
>
> Signed-off-by: John Snow 

Acked-by: Markus Armbruster 




Re: [PATCH 1/8] docs/qapidoc: factor out do_parse()

2024-07-09 Thread Markus Armbruster
John Snow  writes:

> On Sat, Jul 6, 2024, 10:47 AM Markus Armbruster  wrote:
>
>> John Snow  writes:
>>
>> > Factor out the compatibility parser helper into a base class, so it can
>> > be shared by other directives.
>> >
>> > Signed-off-by: John Snow 
>>
>> R-by stands.
>
> Assuming true even if I rebase on top of the 3.x patches and do_parse()
> becomes quite a bit more trivial?

If you think the changes don't warrant a fresh review, keep my R-by.
You may get one anyway ;)




Re: QEMU Community Call Agenda Items (July 9th, 2024)

2024-07-08 Thread Markus Armbruster
Cc: Block layer core maintainers

Philippe Mathieu-Daudé  writes:

> On 8/7/24 16:58, Alex Bennée wrote:
>> Hi,
>> The KVM/QEMU community call is at:
>>https://meet.jit.si/kvmcallmeeting
>>@
>>9/7/2024 14:00 UTC
>> Are there any agenda items for the sync-up?
>
> - I don't remember who mentioned "3 phase reset and KVM",
>   maybe Daniel Barboza or Peter Xu.
>
> - Questions for block team:
>
>   . Are there plan to remove the legacy DriveInfo? What should
> we use instead, blk_by_name() and/or blk_by_qdev_id()?
>
>   . Are there plan to move away from the IF_FOO (see blockdev::if_name)
> or is it OK to use them and keep them in mind with new designs?
>
>   . To model one HW with multiple drives (at least 3), is there
> a recommended way to create that from the CLI?




Re: [PATCH 1/8] docs/qapidoc: factor out do_parse()

2024-07-06 Thread Markus Armbruster
John Snow  writes:

> Factor out the compatibility parser helper into a base class, so it can
> be shared by other directives.
>
> Signed-off-by: John Snow 

R-by stands.




  1   2   3   4   5   6   7   8   9   10   >