We prefer revisions be posted as new threads.  Next time :)

Fails to build for me:

    [334/335] Generating docs/QEMU manual with a custom command
    FAILED: [code=1] docs/docs.stamp 
    /usr/bin/env CONFDIR=etc/qemu 
/work/armbru/qemu/bld-docs/pyvenv/bin/sphinx-build -q -j auto -W 
-Dkerneldoc_werror=1 -Dversion=11.0.90 -Drelease= -Ddepfile=docs/docs.d 
-Ddepfile_stamp=docs/docs.stamp -b html -d 
/work/armbru/qemu/bld-docs/docs/manual.p /work/armbru/qemu/docs 
/work/armbru/qemu/bld-docs/docs/manual
    /work/armbru/qemu/docs/system/devices/remote-i2c-master.rst: WARNING: 
document isn't included in any toctree [toc.not_included]

Should you add a reference to your new .rst to
docs/system/device-emulation.rst section "Emulated Devices"?

Ilya Chichkov <[email protected]> writes:

> Add a "remote-i2c-master" device that exposes a QEMU I2C bus to the
> host system through a FUSE/CUSE character device. This lets external
> host programs and standard i2c-tools interact with I2C slaves emulated
> inside QEMU as if they were real devices attached to the host.
>
> The implementation is split into three layers:
>
>   - A non-blocking finite state machine that drives the QEMU I2C
>     master. It is pumped by a QEMU Bottom Half and uses virtual timers
>     to yield during long transfers and to model clock stretching for
>     asynchronous slaves, so the main loop is never blocked. The FSM
>     walks IDLE -> ADDR -> SEND/RECV -> WAIT_STRETCH -> END -> FINISHED
>     and handles NACKs (ENXIO), lost arbitration (EBUSY, with optional
>     back-off and retry), stretch timeouts, and manual abort/reset.
>
>   - An abstract RemoteI2CBackend QOM base class that decouples the
>     internal I2C hardware state machine (the frontend) from any
>     host-specific transport, exposing on_tx_complete and on_tx_error
>     virtual callbacks.
>
>   - A concrete remote-i2c-backend-cuse backend implementing that
>     transport over CUSE. It manages the FUSE session and integrates
>     its file descriptors into QEMU's main AioContext event loop,
>     translates Linux I2C_RDWR, I2C_SMBUS and I2C_SLAVE ioctls into
>     generic byte streams for the FSM, and formats responses back into
>     Linux I2C/SMBus structures for the FUSE driver. SMBus repeated
>     start is supported for atomic write-then-read operations.
>
> Example usage:
>
>   -device remote-i2c-master,i2cbus=i2c-bus.0,devname=i2c-33
>   -object remote-i2c-backend-cuse,id=b0,devname=i2c-33
>
> This creates /dev/i2c-33 on the host, usable with i2c-tools:
>
>   i2cdetect -y -l
>   i2cget -y <bus_id> <addr> <reg>
>
> Signed-off-by: Ilya Chichkov <[email protected]>

[...]

> diff --git a/qapi/qom.json b/qapi/qom.json
> index dd45ac1087..1552103a4a 100644
> --- a/qapi/qom.json
> +++ b/qapi/qom.json
> @@ -1258,6 +1258,8 @@
>      'tls-creds-psk',
>      'tls-creds-x509',
>      'tls-cipher-suites',
> +    { 'name': 'remote-i2c-backend-cuse',
> +      'if': 'CONFIG_LINUX' },
>      { 'name': 'x-remote-object', 'features': [ 'unstable' ] },
>      { 'name': 'x-vfio-user-server', 'features': [ 'unstable' ] }
>    ] }
> @@ -1334,6 +1336,8 @@
>        'tls-creds-psk':              'TlsCredsPskProperties',
>        'tls-creds-x509':             'TlsCredsX509Properties',
>        'tls-cipher-suites':          'TlsCredsProperties',
> +      'remote-i2c-backend-cuse':    { 'type': 
> 'RemoteI2CBackendCuseProperties',
> +                                      'if': 'CONFIG_LINUX' },
>        'x-remote-object':            'RemoteObjectProperties',
>        'x-vfio-user-server':         'VfioUserServerProperties'
>    } }
> @@ -1377,3 +1381,27 @@
>  ##
>  { 'command': 'object-del', 'data': {'id': 'str'},
>    'allow-preconfig': true }
> +
> +##
> +# @RemoteI2CBackendCuseProperties:
> +#
> +# Properties for the CUSE remote I2C backend.  See
> +# :doc:`/system/devices/remote-i2c-master` for usage information.

Suggest "for detailed usage information."

> +#
> +# @devname: The name of the character device node to create under /dev
> +#     (e.g., 'i2c-33' creates /dev/i2c-33).  The node is accessible
> +#     via the standard Linux I2C device interface and usable directly
> +#     with i2c-tools and the Linux i2c-dev API.
> +#
> +# @fuse-opts: Options passed verbatim to the FUSE/CUSE session at
> +#     mount time, one option (or argument) per list element.  For
> +#     example ['-d'] enables debug tracing, and ['-o', 'allow_other']
> +#     grants other users access.  See the libfuse documentation for
> +#     the full list of supported options.
> +#
> +# Since: 11.2
> +##
> +{ 'struct': 'RemoteI2CBackendCuseProperties',
> +  'data': { 'devname': 'str',
> +            '*fuse-opts': ['str'] },
> +  'if': 'CONFIG_LINUX' }

Please add this type before its use.  Put it right before
RemoteObjectProperties?

With that, QAPI schema
Acked-by: Markus Armbruster <[email protected]>

[...]


Reply via email to