On 2018-02-08 20:23, Kevin Wolf wrote: > This adds the .bdrv_co_create driver callback to sheepdog, which enables > image creation over QMP. > > Signed-off-by: Kevin Wolf <kw...@redhat.com> > --- > qapi/block-core.json | 24 +++++- > block/sheepdog.c | 209 > ++++++++++++++++++++++++++++++++++++--------------- > 2 files changed, 170 insertions(+), 63 deletions(-) > > diff --git a/qapi/block-core.json b/qapi/block-core.json > index 7d004dddf9..08217e3e38 100644 > --- a/qapi/block-core.json > +++ b/qapi/block-core.json > @@ -3492,6 +3492,28 @@ > 'erasure-coded': 'SheepdogRedundancyErasureCoded' } } > > ## > +# @BlockdevCreateOptionsSheepdog: > +# > +# Driver specific image creation options for Sheepdog. > +# > +# @location Where to store the new image file > +# @size Size of the virtual disk in bytes > +# @backing_file File name of a base image
s/_/-/ With that fixed: Reviewed-by: Max Reitz <mre...@redhat.com> > +# @preallocation Preallocation mode (allowed values: off, full) > +# @redundancy Redundancy of the image > +# @object-size Object size of the image > +# > +# Since: 2.12 > +## > +{ 'struct': 'BlockdevCreateOptionsSheepdog', > + 'data': { 'location': 'BlockdevOptionsSheepdog', > + 'size': 'size', > + '*backing-file': 'str', > + '*preallocation': 'PreallocMode', > + '*redundancy': 'SheepdogRedundancy', > + '*object-size': 'size' } } > + > +## > # @BlockdevCreateNotSupported: > # > # This is used for all drivers that don't support creating images. [...] > index dc0348f120..05129dc809 100644 > --- a/block/sheepdog.c > +++ b/block/sheepdog.c [...] > @@ -2142,15 +2144,95 @@ static int sd_create(const char *filename, QemuOpts > *opts, [...] > +static int sd_create(const char *filename, QemuOpts *opts, > + Error **errp) > +{ [...] > + v = qobject_input_visitor_new_keyval(crumpled); > + visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err); > + visit_free(v); > + qobject_decref(crumpled); > + > + if (local_err) { > + error_propagate(errp, local_err); > + ret = -EINVAL; > + goto fail; > + } > + > + create_options->u.sheepdog.size = > + ROUND_UP(create_options->u.sheepdog.size, BDRV_SECTOR_SIZE); I think I'd prefer an assertion that the type is indeed sheepdog before this. > + > + if (redundancy) { > + create_options->u.sheepdog.has_redundancy = true; > + create_options->u.sheepdog.redundancy = > + parse_redundancy_str(redundancy); > + if (create_options->u.sheepdog.redundancy == NULL) { > + error_setg(errp, "Invalid redundancy mode"); > + ret = -EINVAL; > + goto fail; > + } > + }
signature.asc
Description: OpenPGP digital signature