mirror of https://github.com/xqemu/xqemu.git
qapi: Convert block_resize
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
parent
d72f326431
commit
5e7caacb25
18
blockdev.c
18
blockdev.c
|
@ -861,27 +861,23 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
||||||
* existing QERR_ macro mess is cleaned up. A good example for better
|
* existing QERR_ macro mess is cleaned up. A good example for better
|
||||||
* error reports can be found in the qemu-img resize code.
|
* error reports can be found in the qemu-img resize code.
|
||||||
*/
|
*/
|
||||||
int do_block_resize(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
void qmp_block_resize(const char *device, int64_t size, Error **errp)
|
||||||
{
|
{
|
||||||
const char *device = qdict_get_str(qdict, "device");
|
|
||||||
int64_t size = qdict_get_int(qdict, "size");
|
|
||||||
BlockDriverState *bs;
|
BlockDriverState *bs;
|
||||||
|
|
||||||
bs = bdrv_find(device);
|
bs = bdrv_find(device);
|
||||||
if (!bs) {
|
if (!bs) {
|
||||||
qerror_report(QERR_DEVICE_NOT_FOUND, device);
|
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
|
||||||
return -1;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size < 0) {
|
if (size < 0) {
|
||||||
qerror_report(QERR_UNDEFINED_ERROR);
|
error_set(errp, QERR_UNDEFINED_ERROR);
|
||||||
return -1;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bdrv_truncate(bs, size)) {
|
if (bdrv_truncate(bs, size)) {
|
||||||
qerror_report(QERR_UNDEFINED_ERROR);
|
error_set(errp, QERR_UNDEFINED_ERROR);
|
||||||
return -1;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,5 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
|
||||||
int do_block_set_io_throttle(Monitor *mon,
|
int do_block_set_io_throttle(Monitor *mon,
|
||||||
const QDict *qdict, QObject **ret_data);
|
const QDict *qdict, QObject **ret_data);
|
||||||
int do_snapshot_blkdev(Monitor *mon, const QDict *qdict, QObject **ret_data);
|
int do_snapshot_blkdev(Monitor *mon, const QDict *qdict, QObject **ret_data);
|
||||||
int do_block_resize(Monitor *mon, const QDict *qdict, QObject **ret_data);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -57,8 +57,7 @@ ETEXI
|
||||||
.args_type = "device:B,size:o",
|
.args_type = "device:B,size:o",
|
||||||
.params = "device size",
|
.params = "device size",
|
||||||
.help = "resize a block image",
|
.help = "resize a block image",
|
||||||
.user_print = monitor_user_noop,
|
.mhandler.cmd = hmp_block_resize,
|
||||||
.mhandler.cmd_new = do_block_resize,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
STEXI
|
STEXI
|
||||||
|
|
10
hmp.c
10
hmp.c
|
@ -633,3 +633,13 @@ void hmp_balloon(Monitor *mon, const QDict *qdict)
|
||||||
error_free(errp);
|
error_free(errp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hmp_block_resize(Monitor *mon, const QDict *qdict)
|
||||||
|
{
|
||||||
|
const char *device = qdict_get_str(qdict, "device");
|
||||||
|
int64_t size = qdict_get_int(qdict, "size");
|
||||||
|
Error *errp = NULL;
|
||||||
|
|
||||||
|
qmp_block_resize(device, size, &errp);
|
||||||
|
hmp_handle_error(mon, &errp);
|
||||||
|
}
|
||||||
|
|
1
hmp.h
1
hmp.h
|
@ -44,5 +44,6 @@ void hmp_inject_nmi(Monitor *mon, const QDict *qdict);
|
||||||
void hmp_set_link(Monitor *mon, const QDict *qdict);
|
void hmp_set_link(Monitor *mon, const QDict *qdict);
|
||||||
void hmp_block_passwd(Monitor *mon, const QDict *qdict);
|
void hmp_block_passwd(Monitor *mon, const QDict *qdict);
|
||||||
void hmp_balloon(Monitor *mon, const QDict *qdict);
|
void hmp_balloon(Monitor *mon, const QDict *qdict);
|
||||||
|
void hmp_block_resize(Monitor *mon, const QDict *qdict);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1052,3 +1052,21 @@
|
||||||
# Since: 0.14.0
|
# Since: 0.14.0
|
||||||
##
|
##
|
||||||
{ 'command': 'balloon', 'data': {'value': 'int'} }
|
{ 'command': 'balloon', 'data': {'value': 'int'} }
|
||||||
|
|
||||||
|
##
|
||||||
|
# @block_resize
|
||||||
|
#
|
||||||
|
# Resize a block image while a guest is running.
|
||||||
|
#
|
||||||
|
# @device: the name of the device to get the image resized
|
||||||
|
#
|
||||||
|
# @size: new image size in bytes
|
||||||
|
#
|
||||||
|
# Returns: nothing on success
|
||||||
|
# If @device is not a valid block device, DeviceNotFound
|
||||||
|
#
|
||||||
|
# Notes: This command returns UndefinedError in a number of error conditions.
|
||||||
|
#
|
||||||
|
# Since: 0.14.0
|
||||||
|
##
|
||||||
|
{ 'command': 'block_resize', 'data': { 'device': 'str', 'size': 'int' }}
|
||||||
|
|
|
@ -642,10 +642,7 @@ EQMP
|
||||||
{
|
{
|
||||||
.name = "block_resize",
|
.name = "block_resize",
|
||||||
.args_type = "device:B,size:o",
|
.args_type = "device:B,size:o",
|
||||||
.params = "device size",
|
.mhandler.cmd_new = qmp_marshal_input_block_resize,
|
||||||
.help = "resize a block image",
|
|
||||||
.user_print = monitor_user_noop,
|
|
||||||
.mhandler.cmd_new = do_block_resize,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
SQMP
|
SQMP
|
||||||
|
|
Loading…
Reference in New Issue