block/create: Make x-blockdev-create a job

This changes the x-blockdev-create QMP command so that it doesn't block
the monitor and the main loop any more, but starts a background job that
performs the image creation.

The basic job as implemented here is all that is necessary to make image
creation asynchronous and to provide a QMP interface that can be marked
stable, but it still lacks a few features that jobs usually provide: The
job will ignore pause commands and it doesn't publish more than very
basic progress yet (total-progress is 1 and current-progress advances
from 0 to 1 when the driver callbacks returns). These features can be
added later without breaking compatibility.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
This commit is contained in:
Kevin Wolf 2018-01-18 14:33:04 +01:00
parent 1266c9b9f5
commit e5ab4347f9
4 changed files with 66 additions and 33 deletions

View file

@ -4013,14 +4013,18 @@
##
# @x-blockdev-create:
#
# Create an image format on a given node.
# TODO Replace with something asynchronous (block job?)
# Starts a job to create an image format on a given node. The job is
# automatically finalized, but a manual job-dismiss is required.
#
# Since: 2.12
# @job-id: Identifier for the newly created job.
#
# @options: Options for the image creation.
#
# Since: 3.0
##
{ 'command': 'x-blockdev-create',
'data': 'BlockdevCreateOptions',
'boxed': true }
'data': { 'job-id': 'str',
'options': 'BlockdevCreateOptions' } }
##
# @blockdev-open-tray:

View file

@ -17,10 +17,12 @@
#
# @backup: drive backup job type, see "drive-backup"
#
# @create: image creation job type, see "x-blockdev-create" (since 3.0)
#
# Since: 1.7
##
{ 'enum': 'JobType',
'data': ['commit', 'stream', 'mirror', 'backup'] }
'data': ['commit', 'stream', 'mirror', 'backup', 'create'] }
##
# @JobStatus: