qemu-e2k/block
John Snow 0ec4dfb8d6 blockjobs: add block_job_verb permission table
Which commands ("verbs") are appropriate for jobs in which state is
also somewhat burdensome to keep track of.

As of this commit, it looks rather useless, but begins to look more
interesting the more states we add to the STM table.

A recurring theme is that no verb will apply to an 'undefined' job.

Further, it's not presently possible to restrict the "pause" or "resume"
verbs any more than they are in this commit because of the asynchronous
nature of how jobs enter the PAUSED state; justifications for some
seemingly erroneous applications are given below.

=====
Verbs
=====

Cancel:    Any state except undefined.
Pause:     Any state except undefined;
           'created': Requests that the job pauses as it starts.
           'running': Normal usage. (PAUSED)
           'paused':  The job may be paused for internal reasons,
                      but the user may wish to force an indefinite
                      user-pause, so this is allowed.
           'ready':   Normal usage. (STANDBY)
           'standby': Same logic as above.
Resume:    Any state except undefined;
           'created': Will lift a user's pause-on-start request.
           'running': Will lift a pause request before it takes effect.
           'paused':  Normal usage.
           'ready':   Will lift a pause request before it takes effect.
           'standby': Normal usage.
Set-speed: Any state except undefined, though ready may not be meaningful.
Complete:  Only a 'ready' job may accept a complete request.

=======
Changes
=======

(1)

To facilitate "nice" error checking, all five major block-job verb
interfaces in blockjob.c now support an errp parameter:

- block_job_user_cancel is added as a new interface.
- block_job_user_pause gains an errp paramter
- block_job_user_resume gains an errp parameter
- block_job_set_speed already had an errp parameter.
- block_job_complete already had an errp parameter.

(2)

block-job-pause and block-job-resume will no longer no-op when trying
to pause an already paused job, or trying to resume a job that isn't
paused. These functions will now report that they did not perform the
action requested because it was not possible.

iotests have been adjusted to address this new behavior.

(3)

block-job-complete doesn't worry about checking !block_job_started,
because the permission table guards against this.

(4)

test-bdrv-drain's job implementation needs to announce that it is
'ready' now, in order to be completed.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2018-03-19 12:01:24 +01:00
..
Makefile.objs block: x-blockdev-create QMP command 2018-03-09 15:17:47 +01:00
accounting.c block: make accounting thread-safe 2017-06-16 07:55:00 +08:00
backup.c blockjobs: model single jobs as transactions 2018-03-19 12:01:24 +01:00
blkdebug.c block: Switch passthrough drivers to .bdrv_co_block_status() 2018-03-02 18:39:07 +01:00
blkreplay.c block: change variable names in BlockDriverState 2017-06-26 14:54:46 +02:00
blkverify.c Move include qemu/option.h from qemu-common.h to actual users 2018-02-09 13:52:16 +01:00
block-backend.c block: let blk_add/remove_aio_context_notifier() tolerate BDS changes 2018-03-13 15:38:55 -05:00
bochs.c block: Deprecate bdrv_set_read_only() and users 2017-11-17 13:35:59 +01:00
cloop.c block: Deprecate bdrv_set_read_only() and users 2017-11-17 13:35:59 +01:00
commit.c blockjobs: model single jobs as transactions 2018-03-19 12:01:24 +01:00
create.c block: x-blockdev-create QMP command 2018-03-09 15:17:47 +01:00
crypto.c block: implement the bdrv_reopen_prepare helper for LUKS driver 2018-03-09 15:17:47 +01:00
crypto.h qcow: convert QCow to use QCryptoBlock for encryption 2017-07-11 17:44:56 +02:00
curl.c Move include qemu/option.h from qemu-common.h to actual users 2018-02-09 13:52:16 +01:00
dirty-bitmap.c dirty-bitmap: add locked state 2018-03-13 17:05:00 -04:00
dmg-bz2.c dmg: Move libbz2 code to dmg-bz2.so 2016-10-07 14:14:06 +02:00
dmg.c block: Deprecate bdrv_set_read_only() and users 2017-11-17 13:35:59 +01:00
dmg.h block: remove "qemu/osdep.h" from header file 2017-12-18 17:07:02 +03:00
file-posix.c file-posix: Fix no-op bdrv_truncate() with falloc preallocation 2018-03-09 15:17:48 +01:00
file-win32.c file-win32: Support .bdrv_co_create 2018-03-09 15:17:47 +01:00
gluster.c block: include original filename when reporting invalid URIs 2018-03-13 08:06:55 -04:00
io.c block: extract AIO_WAIT_WHILE() from BlockDriverState 2018-03-02 18:39:07 +01:00
iscsi-opts.c Move include qemu/option.h from qemu-common.h to actual users 2018-02-09 13:52:16 +01:00
iscsi.c block: convert bdrv_invalidate_cache callback to coroutine_fn 2018-03-09 15:17:47 +01:00
linux-aio.c block: explicitly acquire aiocontext in aio callbacks that need it 2017-02-21 11:39:39 +00:00
mirror.c blockjobs: model single jobs as transactions 2018-03-19 12:01:24 +01:00
nbd-client.c nbd: BLOCK_STATUS for standard get_block_status function: client part 2018-03-13 15:43:48 -05:00
nbd-client.h nbd: BLOCK_STATUS for standard get_block_status function: client part 2018-03-13 15:43:48 -05:00
nbd.c nbd: BLOCK_STATUS for standard get_block_status function: client part 2018-03-13 15:43:48 -05:00
nfs.c nfs: Support .bdrv_co_create 2018-03-09 15:17:47 +01:00
null.c null: Switch to .bdrv_co_block_status() 2018-03-02 18:39:07 +01:00
nvme.c nvme: Drop pointless .bdrv_co_get_block_status() 2018-03-02 18:39:07 +01:00
parallels.c block: convert bdrv_check callback to coroutine_fn 2018-03-09 15:17:47 +01:00
parallels.h Clean up includes 2018-02-09 05:05:11 +01:00
qapi.c Include less of the generated modular QAPI headers 2018-03-02 13:45:50 -06:00
qcow.c block: rename .bdrv_create() to .bdrv_co_create_opts() 2018-03-02 18:39:07 +01:00
qcow2-bitmap.c qcow2: fix flushing after dirty bitmap metadata writes 2018-03-09 15:17:47 +01:00
qcow2-cache.c qcow2: Allow configuring the L2 slice size 2018-02-13 17:00:00 +01:00
qcow2-cluster.c qcow2: Check L1 table parameters in qcow2_expand_zero_clusters() 2018-03-09 15:17:47 +01:00
qcow2-refcount.c qcow2: Make qemu-img check detect corrupted L1 tables in snapshots 2018-03-09 15:17:47 +01:00
qcow2-snapshot.c qcow2: Check snapshot L1 table in qcow2_snapshot_delete() 2018-03-09 15:17:47 +01:00
qcow2.c block: x-blockdev-create QMP command 2018-03-09 15:17:47 +01:00
qcow2.h qcow2: Generalize validate_table_offset() into qcow2_validate_table() 2018-03-09 15:17:47 +01:00
qed-check.c block: convert bdrv_check callback to coroutine_fn 2018-03-09 15:17:47 +01:00
qed-cluster.c qed: protect table cache with CoMutex 2017-07-17 11:34:11 +08:00
qed-l2-cache.c qed: protect table cache with CoMutex 2017-07-17 11:34:11 +08:00
qed-table.c block: convert bdrv_check callback to coroutine_fn 2018-03-09 15:17:47 +01:00
qed.c block: convert bdrv_check callback to coroutine_fn 2018-03-09 15:17:47 +01:00
qed.h qed: protect table cache with CoMutex 2017-07-17 11:34:11 +08:00
quorum.c Include less of the generated modular QAPI headers 2018-03-02 13:45:50 -06:00
raw-format.c block: rename .bdrv_create() to .bdrv_co_create_opts() 2018-03-02 18:39:07 +01:00
rbd.c rbd: Use qemu_rbd_connect() in qemu_rbd_do_create() 2018-03-09 15:17:47 +01:00
replication.c Move include qemu/option.h from qemu-common.h to actual users 2018-02-09 13:52:16 +01:00
sheepdog.c block: include original filename when reporting invalid URIs 2018-03-13 08:06:55 -04:00
snapshot.c Move include qemu/option.h from qemu-common.h to actual users 2018-02-09 13:52:16 +01:00
ssh.c ssh: Support .bdrv_co_create 2018-03-09 15:17:48 +01:00
stream.c blockjobs: model single jobs as transactions 2018-03-19 12:01:24 +01:00
throttle-groups.c Include less of the generated modular QAPI headers 2018-03-02 13:45:50 -06:00
throttle.c block: Switch passthrough drivers to .bdrv_co_block_status() 2018-03-02 18:39:07 +01:00
trace-events blockjobs: add block_job_verb permission table 2018-03-19 12:01:24 +01:00
vdi.c block: convert bdrv_check callback to coroutine_fn 2018-03-09 15:17:47 +01:00
vhdx-endian.c vhdx: Use QEMU UUID API 2016-09-23 11:42:52 +08:00
vhdx-log.c vhdx: use QEMU_ALIGN_DOWN 2017-08-31 12:29:07 +02:00
vhdx.c block: convert bdrv_check callback to coroutine_fn 2018-03-09 15:17:47 +01:00
vhdx.h block: vhdx - update PAYLOAD_BLOCK_UNMAPPED value to match 1.00 spec 2014-12-12 15:42:22 +00:00
vmdk.c block: convert bdrv_check callback to coroutine_fn 2018-03-09 15:17:47 +01:00
vpc.c block: rename .bdrv_create() to .bdrv_co_create_opts() 2018-03-02 18:39:07 +01:00
vvfat.c vvfat: Switch to .bdrv_co_block_status() 2018-03-02 18:39:07 +01:00
vxhs.c qobject: Use simpler QDict/QList scalar insertion macros 2017-05-09 09:13:51 +02:00
win32-aio.c block: explicitly acquire aiocontext in aio callbacks that need it 2017-02-21 11:39:39 +00:00
write-threshold.c Include less of the generated modular QAPI headers 2018-03-02 13:45:50 -06:00