qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Akihiko Odaki <akihiko.odaki@daynix.com>
To: Joelle van Dyne <j@getutm.app>, qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
	"Hanna Reitz" <hreitz@redhat.com>,
	"Eric Blake" <eblake@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"open list:Block layer core" <qemu-block@nongnu.org>
Subject: Re: [PATCH] block: support locking on change medium
Date: Mon, 9 Sep 2024 16:36:50 +0900	[thread overview]
Message-ID: <dab54af1-cf9d-401c-a11f-657334b52d5a@daynix.com> (raw)
In-Reply-To: <20240909015847.40377-1-j@getutm.app>

On 2024/09/09 10:58, Joelle van Dyne wrote:
> New optional argument for 'blockdev-change-medium' QAPI command to allow
> the caller to specify if they wish to enable file locking.
> 
> Signed-off-by: Joelle van Dyne <j@getutm.app>
> ---
>   qapi/block.json                | 23 ++++++++++++++++++++++-
>   block/monitor/block-hmp-cmds.c |  2 +-
>   block/qapi-sysemu.c            | 22 ++++++++++++++++++++++
>   ui/cocoa.m                     |  1 +
>   4 files changed, 46 insertions(+), 2 deletions(-)
> 
> diff --git a/qapi/block.json b/qapi/block.json
> index e66666f5c6..35e8e2e191 100644
> --- a/qapi/block.json
> +++ b/qapi/block.json
> @@ -309,6 +309,23 @@
>   { 'enum': 'BlockdevChangeReadOnlyMode',
>     'data': ['retain', 'read-only', 'read-write'] }
>   
> +##
> +# @BlockdevChangeFileLockingMode:
> +#
> +# Specifies the new locking mode of a file image passed to the
> +# @blockdev-change-medium command.
> +#
> +# @auto: Use locking if API is available
> +#
> +# @off: Disable file image locking
> +#
> +# @on: Enable file image locking
> +#
> +# Since: 9.2
> +##
> +{ 'enum': 'BlockdevChangeFileLockingMode',
> +  'data': ['auto', 'off', 'on'] }

You can use OnOffAuto type instead of defining your own.

> +
>   ##
>   # @blockdev-change-medium:
>   #
> @@ -330,6 +347,9 @@
>   # @read-only-mode: change the read-only mode of the device; defaults
>   #     to 'retain'
>   #
> +# @file-locking-mode: change the locking mode of the file image; defaults
> +#     to 'auto' (since: 9.2)
> +#
>   # @force: if false (the default), an eject request through
>   #     blockdev-open-tray will be sent to the guest if it has locked
>   #     the tray (and the tray will not be opened immediately); if true,
> @@ -378,7 +398,8 @@
>               'filename': 'str',
>               '*format': 'str',
>               '*force': 'bool',
> -            '*read-only-mode': 'BlockdevChangeReadOnlyMode' } }
> +            '*read-only-mode': 'BlockdevChangeReadOnlyMode',
> +            '*file-locking-mode': 'BlockdevChangeFileLockingMode' } }
>   
>   ##
>   # @DEVICE_TRAY_MOVED:
> diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
> index bdf2eb50b6..ff64020a80 100644
> --- a/block/monitor/block-hmp-cmds.c
> +++ b/block/monitor/block-hmp-cmds.c
> @@ -1007,5 +1007,5 @@ void hmp_change_medium(Monitor *mon, const char *device, const char *target,
>       }
>   
>       qmp_blockdev_change_medium(device, NULL, target, arg, true, force,
> -                               !!read_only, read_only_mode, errp);
> +                               !!read_only, read_only_mode, false, 0, errp);
>   }
> diff --git a/block/qapi-sysemu.c b/block/qapi-sysemu.c
> index e4282631d2..8064bdfb3a 100644
> --- a/block/qapi-sysemu.c
> +++ b/block/qapi-sysemu.c
> @@ -311,6 +311,8 @@ void qmp_blockdev_change_medium(const char *device,
>                                   bool has_force, bool force,
>                                   bool has_read_only,
>                                   BlockdevChangeReadOnlyMode read_only,
> +                                bool has_file_locking_mode,
> +                                BlockdevChangeFileLockingMode file_locking_mode,
>                                   Error **errp)
>   {
>       BlockBackend *blk;
> @@ -362,6 +364,26 @@ void qmp_blockdev_change_medium(const char *device,
>           qdict_put_str(options, "driver", format);
>       }
>   
> +    if (!has_file_locking_mode) {
> +        file_locking_mode = BLOCKDEV_CHANGE_FILE_LOCKING_MODE_AUTO;
> +    }
> +
> +    switch (file_locking_mode) {
> +    case BLOCKDEV_CHANGE_FILE_LOCKING_MODE_AUTO:
> +        break;
> +
> +    case BLOCKDEV_CHANGE_FILE_LOCKING_MODE_OFF:
> +        qdict_put_str(options, "file.locking", "off");
> +        break;
> +
> +    case BLOCKDEV_CHANGE_FILE_LOCKING_MODE_ON:
> +        qdict_put_str(options, "file.locking", "on");
> +        break;
> +
> +    default:
> +        abort();
> +    }
> +
>       medium_bs = bdrv_open(filename, NULL, options, bdrv_flags, errp);
>   
>       if (!medium_bs) {
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index 4c2dd33532..6e73c6e13e 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -1611,6 +1611,7 @@ - (void)changeDeviceMedia:(id)sender
>                                          "raw",
>                                          true, false,
>                                          false, 0,
> +                                       false, 0,

This change is irrelevant.

Regards,
Akihiko Odaki


  reply	other threads:[~2024-09-09  7:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-09  1:58 [PATCH] block: support locking on change medium Joelle van Dyne
2024-09-09  7:36 ` Akihiko Odaki [this message]
2024-09-09 14:18   ` Joelle van Dyne
2024-09-10  4:24     ` Akihiko Odaki
2024-09-09  9:56 ` Kevin Wolf
2024-09-09 14:25   ` Joelle van Dyne
2024-09-09 15:42     ` Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dab54af1-cf9d-401c-a11f-657334b52d5a@daynix.com \
    --to=akihiko.odaki@daynix.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=j@getutm.app \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).