Skip to content

blockdev: Add blockdev-change-medium with read-only option

Max Reitz qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 14 repliesIn review
  2. v13 patches 9 repliesSuperseded

Changes in v2 from the cover letter

- basically completely rewritten
- Dropped 'auto' [Kevin and Markus]
- Introduced blockdev-change-medium [Eric]

- Patch 1 introduces the new QMP command 'blockdev-change-medium'; there are (at least) two questionable design choices which I want to explain here:
- The name is rather long; furthermore, the name 'change-blockdev' was already suggested by the existing code. I used such a long name because (1) there are no *-blockdev commands, but there are blockdev-* commands, so "blockdev" should be the prefix, not the suffix, and (2) "blockdev-change" could mean anything, so I wanted to be as clear as possible.
- The 'format' argument is optional; this is because by making it mandatory, it would have been difficult for the 'change' QMP and HMP commands to retain their 'format' argument optional as well (which we have to do thanks to compatibility)
- Patches 2 to 4 should be thoroughly explained by their commit title

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4qmp: Introduce blockdev-change-mediumblockdev.c include/sysemu/blockdev.h qapi/block-core.json +2 more+57 -63 replies
2/4hmp: Use blockdev-change-medium for change commandhmp.c+15 -123 replies
3/4blockdev: Add read-only option to blockdev-change-mediumblockdev.c hmp.c qapi/block-core.json +2 more+72 -51 reply
4/4hmp: Add read-only option to change commandhmp-commands.hx hmp.c+37 -41 reply

Reviews trailers per patch

3 of 4 patches have a Reviewed-by or Acked-by.

PatchEric Blake
1/4
2/4R-b
3/4R-b
4/4R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [Qemu-devel] [PATCH v2 0/4] blockdev: Add blockdev-change-medium with read-only option

The 'change' QMP and HMP command allows replacing the medium in drives which support this, e.g. floppy disk drives. For some drives, the medium carries information about whether it can be written to or not (again, floppy drives). Therefore, it should be possible to change the read-only state of block devices when changing the loaded medium.

Following a suggestion from Eric, this series first introduces a 'blockdev-change-medium' QMP command which is intended to replace the 'change' command for block devices. Then, an optional additional 'read-only' parameter is added which allows chaning the read-only state in three ways:

- 'retain': Just keep the status as it was before; this is the current behavior and thus this will be the default.
- 'ro': Force read-only access
- 'rw': Force writable access

Finally, that 'read-only' parameter is added to the HMP 'change' command. This series does not add a 'blockdev-change-medium' QMP command because 'change' being overloaded for VNC and block devices is not too bad for HMP (while it is for QMP).

v2:
- basically completely rewritten
- Dropped 'auto' [Kevin and Markus]
- Introduced blockdev-change-medium [Eric]

- Patch 1 introduces the new QMP command 'blockdev-change-medium'; there are (at least) two questionable design choices which I want to explain here:
- The name is rather long; furthermore, the name 'change-blockdev' was already suggested by the existing code. I used such a long name because (1) there are no *-blockdev commands, but there are blockdev-* commands, so "blockdev" should be the prefix, not the suffix, and (2) "blockdev-change" could mean anything, so I wanted to be as clear as possible.
- The 'format' argument is optional; this is because by making it mandatory, it would have been difficult for the 'change' QMP and HMP commands to retain their 'format' argument optional as well (which we have to do thanks to compatibility)
- Patches 2 to 4 should be thoroughly explained by their commit title

Max Reitz (4):
qmp: Introduce blockdev-change-medium
hmp: Use blockdev-change-medium for change command
blockdev: Add read-only option to blockdev-change-medium
hmp: Add read-only option to change command

 blockdev.c                | 31 +++++++++++++++++++++++----
 hmp-commands.hx           | 20 +++++++++++++++---
 hmp.c                     | 46 +++++++++++++++++++++++++++++-----------
 include/sysemu/blockdev.h |  2 --
 qapi/block-core.json      | 43 ++++++++++++++++++++++++++++++++++++++
 qmp-commands.hx           | 53 +++++++++++++++++++++++++++++++++++++++++++++++
 qmp.c                     |  3 ++-
 7 files changed, 176 insertions(+), 22 deletions(-)
Signature · 1 line
1.9.3