Message ID | 1410891148-28849-22-git-send-email-armbru@redhat.com |
---|---|
State | New |
Headers | show |
On Tue, Sep 16, 2014 at 08:12:26PM +0200, Markus Armbruster wrote: > Much more command code needs conversion. I'm converting these now > because they's using bdrv_dev_* functions, which I'm about to lift > into BlockBackend. > > Signed-off-by: Markus Armbruster <armbru@redhat.com> > --- > blockdev.c | 20 ++++++++++++-------- > 1 file changed, 12 insertions(+), 8 deletions(-) > > diff --git a/blockdev.c b/blockdev.c > index e218c59..e115bde 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -1502,8 +1502,10 @@ exit: > } > > > -static void eject_device(BlockDriverState *bs, int force, Error **errp) > +static void eject_device(BlockBackend *blk, int force, Error **errp) > { > + BlockDriverState *bs = blk_bs(blk); > + > if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_EJECT, errp)) { > return; > } > @@ -1527,15 +1529,15 @@ static void eject_device(BlockDriverState *bs, int force, Error **errp) > > void qmp_eject(const char *device, bool has_force, bool force, Error **errp) > { > - BlockDriverState *bs; > + BlockBackend *blk; > > - bs = bdrv_find(device); > - if (!bs) { > + blk = blk_by_name(device); > + if (!blk) { > error_set(errp, QERR_DEVICE_NOT_FOUND, device); > return; > } > > - eject_device(bs, force, errp); > + eject_device(blk, force, errp); > } > > void qmp_block_passwd(bool has_device, const char *device, > @@ -1594,16 +1596,18 @@ static void qmp_bdrv_open_encrypted(BlockDriverState *bs, const char *filename, > void qmp_change_blockdev(const char *device, const char *filename, > const char *format, Error **errp) > { > + BlockBackend *blk; > BlockDriverState *bs; > BlockDriver *drv = NULL; > int bdrv_flags; > Error *err = NULL; > > - bs = bdrv_find(device); > - if (!bs) { > + blk = blk_by_name(device); > + if (!blk) { > error_set(errp, QERR_DEVICE_NOT_FOUND, device); > return; > } > + bs = blk_bs(blk); > > if (format) { > drv = bdrv_find_whitelisted_format(format, bs->read_only); > @@ -1613,7 +1617,7 @@ void qmp_change_blockdev(const char *device, const char *filename, > } > } > > - eject_device(bs, 0, &err); > + eject_device(blk, 0, &err); > if (err) { > error_propagate(errp, err); > return; > -- > 1.9.3 > Reviewed-by: Benoit Canet <benoit.canet@nodalink.com>
On 16.09.2014 20:12, Markus Armbruster wrote: > Much more command code needs conversion. I'm converting these now > because they's using bdrv_dev_* functions, which I'm about to lift Either this is again some phrase I haven't yet picked up or it should be "they're". ;-) > into BlockBackend. > > Signed-off-by: Markus Armbruster <armbru@redhat.com> > --- > blockdev.c | 20 ++++++++++++-------- > 1 file changed, 12 insertions(+), 8 deletions(-) With that fixed (or alternatively another Wikipedia or Wiktionary reference): Reviewed-by: Max Reitz <mreitz@redhat.com>
Max Reitz <mreitz@redhat.com> writes: > On 16.09.2014 20:12, Markus Armbruster wrote: >> Much more command code needs conversion. I'm converting these now >> because they's using bdrv_dev_* functions, which I'm about to lift > > Either this is again some phrase I haven't yet picked up or it should > be "they're". ;-) Nah, this is actually me trying to think and write at the same time :) I'll fix it. >> into BlockBackend. >> >> Signed-off-by: Markus Armbruster <armbru@redhat.com> >> --- >> blockdev.c | 20 ++++++++++++-------- >> 1 file changed, 12 insertions(+), 8 deletions(-) > > With that fixed (or alternatively another Wikipedia or Wiktionary > reference): > > Reviewed-by: Max Reitz <mreitz@redhat.com> Thanks!
Am 16.09.2014 um 20:12 hat Markus Armbruster geschrieben: > Much more command code needs conversion. I'm converting these now > because they's using bdrv_dev_* functions, which I'm about to lift > into BlockBackend. > > Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com>
diff --git a/blockdev.c b/blockdev.c index e218c59..e115bde 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1502,8 +1502,10 @@ exit: } -static void eject_device(BlockDriverState *bs, int force, Error **errp) +static void eject_device(BlockBackend *blk, int force, Error **errp) { + BlockDriverState *bs = blk_bs(blk); + if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_EJECT, errp)) { return; } @@ -1527,15 +1529,15 @@ static void eject_device(BlockDriverState *bs, int force, Error **errp) void qmp_eject(const char *device, bool has_force, bool force, Error **errp) { - BlockDriverState *bs; + BlockBackend *blk; - bs = bdrv_find(device); - if (!bs) { + blk = blk_by_name(device); + if (!blk) { error_set(errp, QERR_DEVICE_NOT_FOUND, device); return; } - eject_device(bs, force, errp); + eject_device(blk, force, errp); } void qmp_block_passwd(bool has_device, const char *device, @@ -1594,16 +1596,18 @@ static void qmp_bdrv_open_encrypted(BlockDriverState *bs, const char *filename, void qmp_change_blockdev(const char *device, const char *filename, const char *format, Error **errp) { + BlockBackend *blk; BlockDriverState *bs; BlockDriver *drv = NULL; int bdrv_flags; Error *err = NULL; - bs = bdrv_find(device); - if (!bs) { + blk = blk_by_name(device); + if (!blk) { error_set(errp, QERR_DEVICE_NOT_FOUND, device); return; } + bs = blk_bs(blk); if (format) { drv = bdrv_find_whitelisted_format(format, bs->read_only); @@ -1613,7 +1617,7 @@ void qmp_change_blockdev(const char *device, const char *filename, } } - eject_device(bs, 0, &err); + eject_device(blk, 0, &err); if (err) { error_propagate(errp, err); return;
Much more command code needs conversion. I'm converting these now because they's using bdrv_dev_* functions, which I'm about to lift into BlockBackend. Signed-off-by: Markus Armbruster <armbru@redhat.com> --- blockdev.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)