From: Luiz Capitulino <lcapitulino@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, mdroth@linux.vnet.ibm.com
Subject: [Qemu-devel] [PATCH 11/16] qapi: Convert block_resize
Date: Mon, 28 Nov 2011 16:11:20 -0200 [thread overview]
Message-ID: <1322503885-5913-12-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1322503885-5913-1-git-send-email-lcapitulino@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
blockdev.c | 18 +++++++-----------
blockdev.h | 1 -
hmp-commands.hx | 3 +--
hmp.c | 10 ++++++++++
hmp.h | 1 +
qapi-schema.json | 18 ++++++++++++++++++
qmp-commands.hx | 5 +----
7 files changed, 38 insertions(+), 18 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index fc9cc63..874b09f 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -752,27 +752,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
* 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;
bs = bdrv_find(device);
if (!bs) {
- qerror_report(QERR_DEVICE_NOT_FOUND, device);
- return -1;
+ error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+ return;
}
if (size < 0) {
- qerror_report(QERR_UNDEFINED_ERROR);
- return -1;
+ error_set(errp, QERR_UNDEFINED_ERROR);
+ return;
}
if (bdrv_truncate(bs, size)) {
- qerror_report(QERR_UNDEFINED_ERROR);
- return -1;
+ error_set(errp, QERR_UNDEFINED_ERROR);
+ return;
}
-
- return 0;
}
diff --git a/blockdev.h b/blockdev.h
index d1a7204..69f18fb 100644
--- a/blockdev.h
+++ b/blockdev.h
@@ -63,6 +63,5 @@ int do_change_block(Monitor *mon, const char *device,
const char *filename, const char *fmt);
int do_drive_del(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
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 0badaac..ec4c9a1 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -57,8 +57,7 @@ ETEXI
.args_type = "device:B,size:o",
.params = "device size",
.help = "resize a block image",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_block_resize,
+ .mhandler.cmd = hmp_block_resize,
},
STEXI
diff --git a/hmp.c b/hmp.c
index f9b3400..cb20858 100644
--- a/hmp.c
+++ b/hmp.c
@@ -623,3 +623,13 @@ void hmp_balloon(Monitor *mon, const QDict *qdict)
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);
+}
diff --git a/hmp.h b/hmp.h
index b0984ac..c236fd2 100644
--- a/hmp.h
+++ b/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_block_passwd(Monitor *mon, const QDict *qdict);
void hmp_balloon(Monitor *mon, const QDict *qdict);
+void hmp_block_resize(Monitor *mon, const QDict *qdict);
#endif
diff --git a/qapi-schema.json b/qapi-schema.json
index 6b71c45..a6e3fdd 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1038,3 +1038,21 @@
# Since: 0.14.0
##
{ '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' }}
diff --git a/qmp-commands.hx b/qmp-commands.hx
index cf18ccd..a35946f 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -642,10 +642,7 @@ EQMP
{
.name = "block_resize",
.args_type = "device:B,size:o",
- .params = "device size",
- .help = "resize a block image",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_block_resize,
+ .mhandler.cmd_new = qmp_marshal_input_block_resize,
},
SQMP
--
1.7.8.rc3.31.g017d1.dirty
next prev parent reply other threads:[~2011-11-28 18:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-28 18:11 [Qemu-devel] [PATCH 1.1 v1 00/16]: QAPI conversions round 3 Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 01/16] qapi: Complete system_powerdown conversion Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 02/16] console: Drop unused prototypes Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 03/16] QError: Introduce QERR_IO_ERROR Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 04/16] qapi: Convert memsave Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 05/16] qapi: Convert pmemsave Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 06/16] qapi: Convert cont Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 07/16] qapi: Convert inject-nmi Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 08/16] qapi: Convert set_link Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 09/16] qapi: Convert block_passwd Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 10/16] qapi: Convert balloon Luiz Capitulino
2011-11-28 18:11 ` Luiz Capitulino [this message]
2011-11-28 18:11 ` [Qemu-devel] [PATCH 12/16] qapi: Convert blockdev_snapshot_sync Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 13/16] qapi: Convert human-monitor-command Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 14/16] qapi: Convert migrate_cancel Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 15/16] qapi: Convert migrate_set_downtime Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 16/16] qapi: Convert migrate_set_speed Luiz Capitulino
-- strict thread matches above, loose matches on Subject: below --
2011-12-05 20:00 [Qemu-devel] [PATCH v2 00/16]: QAPI conversions round 3 Luiz Capitulino
2011-12-05 20:00 ` [Qemu-devel] [PATCH 11/16] qapi: Convert block_resize Luiz Capitulino
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1322503885-5913-12-git-send-email-lcapitulino@redhat.com \
--to=lcapitulino@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).