* [Qemu-devel] [PATCH 01/16] qapi: Complete system_powerdown conversion
2011-11-28 18:11 [Qemu-devel] [PATCH 1.1 v1 00/16]: QAPI conversions round 3 Luiz Capitulino
@ 2011-11-28 18:11 ` Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 02/16] console: Drop unused prototypes Luiz Capitulino
` (14 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Luiz Capitulino @ 2011-11-28 18:11 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori, mdroth
Commit 5bc465e4b1b6f4582a400c0a7033a1c841744278 converted only
the HMP part of the system_powerdown command to the QAPI, this
commit completes it by converting the QMP part too.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
monitor.c | 10 ----------
qmp-commands.hx | 5 +----
2 files changed, 1 insertions(+), 14 deletions(-)
diff --git a/monitor.c b/monitor.c
index 1be222e..344b196 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1796,16 +1796,6 @@ static void do_boot_set(Monitor *mon, const QDict *qdict)
}
}
-/**
- * do_system_powerdown(): Issue a machine powerdown
- */
-static int do_system_powerdown(Monitor *mon, const QDict *qdict,
- QObject **ret_data)
-{
- qemu_system_powerdown_request();
- return 0;
-}
-
#if defined(TARGET_I386)
static void print_pte(Monitor *mon, target_phys_addr_t addr,
target_phys_addr_t pte,
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 97975a5..d5d317a 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -244,10 +244,7 @@ EQMP
{
.name = "system_powerdown",
.args_type = "",
- .params = "",
- .help = "send system power down event",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_system_powerdown,
+ .mhandler.cmd_new = qmp_marshal_input_system_powerdown,
},
SQMP
--
1.7.8.rc3.31.g017d1.dirty
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 02/16] console: Drop unused prototypes
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 ` Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 03/16] QError: Introduce QERR_IO_ERROR Luiz Capitulino
` (13 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Luiz Capitulino @ 2011-11-28 18:11 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori, mdroth
Commit e235cec3762d2aa20b548114ea7b172113690463 converted the query-mice
command to the QAPI but forgot to remove two prototypes used by the old
QAPI. Drop them.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
console.h | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/console.h b/console.h
index 6ac4ed3..9466886 100644
--- a/console.h
+++ b/console.h
@@ -74,8 +74,6 @@ struct MouseTransformInfo {
int a[7];
};
-void do_info_mice_print(Monitor *mon, const QObject *data);
-void do_info_mice(Monitor *mon, QObject **ret_data);
void do_mouse_set(Monitor *mon, const QDict *qdict);
/* keysym is a unicode code except for special keys (see QEMU_KEY_xxx
--
1.7.8.rc3.31.g017d1.dirty
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 03/16] QError: Introduce QERR_IO_ERROR
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 ` Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 04/16] qapi: Convert memsave Luiz Capitulino
` (12 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Luiz Capitulino @ 2011-11-28 18:11 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori, mdroth
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
qerror.c | 4 ++++
qerror.h | 3 +++
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/qerror.c b/qerror.c
index fdf62b9..d8d0256 100644
--- a/qerror.c
+++ b/qerror.c
@@ -149,6 +149,10 @@ static const QErrorStringTable qerror_table[] = {
.desc = "Password incorrect",
},
{
+ .error_fmt = QERR_IO_ERROR,
+ .desc = "An IO error has occurred",
+ },
+ {
.error_fmt = QERR_JSON_PARSING,
.desc = "Invalid JSON syntax",
},
diff --git a/qerror.h b/qerror.h
index 2d3d43b..2a64b24 100644
--- a/qerror.h
+++ b/qerror.h
@@ -126,6 +126,9 @@ QError *qobject_to_qerror(const QObject *obj);
#define QERR_INVALID_PASSWORD \
"{ 'class': 'InvalidPassword', 'data': {} }"
+#define QERR_IO_ERROR \
+ "{ 'class': 'IOError', 'data': {} }"
+
#define QERR_JSON_PARSING \
"{ 'class': 'JSONParsing', 'data': {} }"
--
1.7.8.rc3.31.g017d1.dirty
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 04/16] qapi: Convert memsave
2011-11-28 18:11 [Qemu-devel] [PATCH 1.1 v1 00/16]: QAPI conversions round 3 Luiz Capitulino
` (2 preceding siblings ...)
2011-11-28 18:11 ` [Qemu-devel] [PATCH 03/16] QError: Introduce QERR_IO_ERROR Luiz Capitulino
@ 2011-11-28 18:11 ` Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 05/16] qapi: Convert pmemsave Luiz Capitulino
` (11 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Luiz Capitulino @ 2011-11-28 18:11 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori, mdroth
Please, note that the QMP command has a new 'cpu' parameter.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
cpus.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
hmp-commands.hx | 3 +--
hmp.c | 19 +++++++++++++++++++
hmp.h | 1 +
monitor.c | 38 --------------------------------------
qapi-schema.json | 26 ++++++++++++++++++++++++++
qmp-commands.hx | 10 +++-------
7 files changed, 96 insertions(+), 47 deletions(-)
diff --git a/cpus.c b/cpus.c
index 82530c4..2197c52 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1136,3 +1136,49 @@ CpuInfoList *qmp_query_cpus(Error **errp)
return head;
}
+
+void qmp_memsave(int64_t addr, int64_t size, const char *filename,
+ bool has_cpu, int64_t cpu, Error **errp)
+{
+ FILE *f;
+ uint32_t l;
+ CPUState *env;
+ uint8_t buf[1024];
+
+ if (!has_cpu) {
+ cpu = 0;
+ }
+
+ for (env = first_cpu; env; env = env->next_cpu) {
+ if (cpu == env->cpu_index) {
+ break;
+ }
+ }
+
+ if (env == NULL) {
+ error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cpu", "a valid cpu");
+ return;
+ }
+
+ f = fopen(filename, "wb");
+ if (!f) {
+ error_set(errp, QERR_OPEN_FILE_FAILED, filename);
+ return;
+ }
+
+ while (size != 0) {
+ l = sizeof(buf);
+ if (l > size)
+ l = size;
+ cpu_memory_rw_debug(env, addr, buf, l, 0);
+ if (fwrite(buf, 1, l, f) != l) {
+ error_set(errp, QERR_IO_ERROR);
+ goto exit;
+ }
+ addr += l;
+ size -= l;
+ }
+
+exit:
+ fclose(f);
+}
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 089c1ac..e178cac 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -689,8 +689,7 @@ ETEXI
.args_type = "val:l,size:i,filename:s",
.params = "addr size file",
.help = "save to disk virtual memory dump starting at 'addr' of size 'size'",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_memory_save,
+ .mhandler.cmd = hmp_memsave,
},
STEXI
diff --git a/hmp.c b/hmp.c
index 443d3a7..59139b2 100644
--- a/hmp.c
+++ b/hmp.c
@@ -14,6 +14,14 @@
#include "hmp.h"
#include "qmp-commands.h"
+static void hmp_handle_error(Monitor *mon, Error **errp)
+{
+ if (error_is_set(errp)) {
+ monitor_printf(mon, "%s\n", error_get_pretty(*errp));
+ error_free(*errp);
+ }
+}
+
void hmp_info_name(Monitor *mon)
{
NameInfo *info;
@@ -521,3 +529,14 @@ void hmp_cpu(Monitor *mon, const QDict *qdict)
monitor_printf(mon, "invalid CPU index\n");
}
}
+
+void hmp_memsave(Monitor *mon, const QDict *qdict)
+{
+ uint32_t size = qdict_get_int(qdict, "size");
+ const char *filename = qdict_get_str(qdict, "filename");
+ uint64_t addr = qdict_get_int(qdict, "val");
+ Error *errp = NULL;
+
+ qmp_memsave(addr, size, filename, true, monitor_get_cpu_index(), &errp);
+ hmp_handle_error(mon, &errp);
+}
diff --git a/hmp.h b/hmp.h
index 4422578..dd8ad0c 100644
--- a/hmp.h
+++ b/hmp.h
@@ -37,5 +37,6 @@ void hmp_stop(Monitor *mon, const QDict *qdict);
void hmp_system_reset(Monitor *mon, const QDict *qdict);
void hmp_system_powerdown(Monitor *mon, const QDict *qdict);
void hmp_cpu(Monitor *mon, const QDict *qdict);
+void hmp_memsave(Monitor *mon, const QDict *qdict);
#endif
diff --git a/monitor.c b/monitor.c
index 344b196..7272014 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1370,44 +1370,6 @@ static void do_print(Monitor *mon, const QDict *qdict)
monitor_printf(mon, "\n");
}
-static int do_memory_save(Monitor *mon, const QDict *qdict, QObject **ret_data)
-{
- FILE *f;
- uint32_t size = qdict_get_int(qdict, "size");
- const char *filename = qdict_get_str(qdict, "filename");
- target_long addr = qdict_get_int(qdict, "val");
- uint32_t l;
- CPUState *env;
- uint8_t buf[1024];
- int ret = -1;
-
- env = mon_get_cpu();
-
- f = fopen(filename, "wb");
- if (!f) {
- qerror_report(QERR_OPEN_FILE_FAILED, filename);
- return -1;
- }
- while (size != 0) {
- l = sizeof(buf);
- if (l > size)
- l = size;
- cpu_memory_rw_debug(env, addr, buf, l, 0);
- if (fwrite(buf, 1, l, f) != l) {
- monitor_printf(mon, "fwrite() error in do_memory_save\n");
- goto exit;
- }
- addr += l;
- size -= l;
- }
-
- ret = 0;
-
-exit:
- fclose(f);
- return ret;
-}
-
static int do_physical_memory_save(Monitor *mon, const QDict *qdict,
QObject **ret_data)
{
diff --git a/qapi-schema.json b/qapi-schema.json
index cb1ba77..c0df21e 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -887,3 +887,29 @@
# Notes: Do not use this command.
##
{ 'command': 'cpu', 'data': {'index': 'int'} }
+
+##
+# @memsave:
+#
+# Save a portion of guest memory to a file.
+#
+# @val: the virtual address of the guest to start from
+#
+# @size: the size of memory region to save
+#
+# @filename: the file to save the memory to as binary data
+#
+# @cpu: #optional the index of the virtual CPU to use for translating the
+# virtual address (defaults to CPU 0)
+#
+# Returns: Nothing on success
+# If @cpu is not a valid VCPU, InvalidParameterValue
+# If @filename cannot be opened, OpenFileFailed
+# If an I/O error occurs while writing the file, IOError
+#
+# Since: 0.14.0
+#
+# Notes: Errors were not reliably returned until 1.1
+##
+{ 'command': 'memsave',
+ 'data': {'val': 'int', 'size': 'int', 'filename': 'str', '*cpu': 'int'} }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index d5d317a..7b3cbe2 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -352,11 +352,8 @@ EQMP
{
.name = "memsave",
- .args_type = "val:l,size:i,filename:s",
- .params = "addr size file",
- .help = "save to disk virtual memory dump starting at 'addr' of size 'size'",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_memory_save,
+ .args_type = "val:l,size:i,filename:s,cpu:i?",
+ .mhandler.cmd_new = qmp_marshal_input_memsave,
},
SQMP
@@ -370,6 +367,7 @@ Arguments:
- "val": the starting address (json-int)
- "size": the memory size, in bytes (json-int)
- "filename": file path (json-string)
+- "cpu": virtual CPU index (json-int, optional)
Example:
@@ -379,8 +377,6 @@ Example:
"filename": "/tmp/virtual-mem-dump" } }
<- { "return": {} }
-Note: Depends on the current CPU.
-
EQMP
{
--
1.7.8.rc3.31.g017d1.dirty
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 05/16] qapi: Convert pmemsave
2011-11-28 18:11 [Qemu-devel] [PATCH 1.1 v1 00/16]: QAPI conversions round 3 Luiz Capitulino
` (3 preceding siblings ...)
2011-11-28 18:11 ` [Qemu-devel] [PATCH 04/16] qapi: Convert memsave Luiz Capitulino
@ 2011-11-28 18:11 ` Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 06/16] qapi: Convert cont Luiz Capitulino
` (10 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Luiz Capitulino @ 2011-11-28 18:11 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori, mdroth
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
cpus.c | 30 ++++++++++++++++++++++++++++++
hmp-commands.hx | 3 +--
hmp.c | 11 +++++++++++
hmp.h | 1 +
monitor.c | 37 -------------------------------------
qapi-schema.json | 22 ++++++++++++++++++++++
qmp-commands.hx | 5 +----
7 files changed, 66 insertions(+), 43 deletions(-)
diff --git a/cpus.c b/cpus.c
index 2197c52..72ab6f5 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1182,3 +1182,33 @@ void qmp_memsave(int64_t addr, int64_t size, const char *filename,
exit:
fclose(f);
}
+
+void qmp_pmemsave(int64_t addr, int64_t size, const char *filename,
+ Error **errp)
+{
+ FILE *f;
+ uint32_t l;
+ uint8_t buf[1024];
+
+ f = fopen(filename, "wb");
+ if (!f) {
+ error_set(errp, QERR_OPEN_FILE_FAILED, filename);
+ return;
+ }
+
+ while (size != 0) {
+ l = sizeof(buf);
+ if (l > size)
+ l = size;
+ cpu_physical_memory_rw(addr, buf, l, 0);
+ if (fwrite(buf, 1, l, f) != l) {
+ error_set(errp, QERR_IO_ERROR);
+ goto exit;
+ }
+ addr += l;
+ size -= l;
+ }
+
+exit:
+ fclose(f);
+}
diff --git a/hmp-commands.hx b/hmp-commands.hx
index e178cac..a165725 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -703,8 +703,7 @@ ETEXI
.args_type = "val:l,size:i,filename:s",
.params = "addr size file",
.help = "save to disk physical memory dump starting at 'addr' of size 'size'",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_physical_memory_save,
+ .mhandler.cmd = hmp_pmemsave,
},
STEXI
diff --git a/hmp.c b/hmp.c
index 59139b2..3dcd491 100644
--- a/hmp.c
+++ b/hmp.c
@@ -540,3 +540,14 @@ void hmp_memsave(Monitor *mon, const QDict *qdict)
qmp_memsave(addr, size, filename, true, monitor_get_cpu_index(), &errp);
hmp_handle_error(mon, &errp);
}
+
+void hmp_pmemsave(Monitor *mon, const QDict *qdict)
+{
+ uint32_t size = qdict_get_int(qdict, "size");
+ const char *filename = qdict_get_str(qdict, "filename");
+ uint64_t addr = qdict_get_int(qdict, "val");
+ Error *errp = NULL;
+
+ qmp_pmemsave(addr, size, filename, &errp);
+ hmp_handle_error(mon, &errp);
+}
diff --git a/hmp.h b/hmp.h
index dd8ad0c..4882bea 100644
--- a/hmp.h
+++ b/hmp.h
@@ -38,5 +38,6 @@ void hmp_system_reset(Monitor *mon, const QDict *qdict);
void hmp_system_powerdown(Monitor *mon, const QDict *qdict);
void hmp_cpu(Monitor *mon, const QDict *qdict);
void hmp_memsave(Monitor *mon, const QDict *qdict);
+void hmp_pmemsave(Monitor *mon, const QDict *qdict);
#endif
diff --git a/monitor.c b/monitor.c
index 7272014..a1b46b3 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1370,43 +1370,6 @@ static void do_print(Monitor *mon, const QDict *qdict)
monitor_printf(mon, "\n");
}
-static int do_physical_memory_save(Monitor *mon, const QDict *qdict,
- QObject **ret_data)
-{
- FILE *f;
- uint32_t l;
- uint8_t buf[1024];
- uint32_t size = qdict_get_int(qdict, "size");
- const char *filename = qdict_get_str(qdict, "filename");
- target_phys_addr_t addr = qdict_get_int(qdict, "val");
- int ret = -1;
-
- f = fopen(filename, "wb");
- if (!f) {
- qerror_report(QERR_OPEN_FILE_FAILED, filename);
- return -1;
- }
- while (size != 0) {
- l = sizeof(buf);
- if (l > size)
- l = size;
- cpu_physical_memory_read(addr, buf, l);
- if (fwrite(buf, 1, l, f) != l) {
- monitor_printf(mon, "fwrite() error in do_physical_memory_save\n");
- goto exit;
- }
- fflush(f);
- addr += l;
- size -= l;
- }
-
- ret = 0;
-
-exit:
- fclose(f);
- return ret;
-}
-
static void do_sum(Monitor *mon, const QDict *qdict)
{
uint32_t addr;
diff --git a/qapi-schema.json b/qapi-schema.json
index c0df21e..57bfe9a 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -913,3 +913,25 @@
##
{ 'command': 'memsave',
'data': {'val': 'int', 'size': 'int', 'filename': 'str', '*cpu': 'int'} }
+
+##
+# @pmemsave:
+#
+# Save a portion of guest physical memory to a file.
+#
+# @val: the physical address of the guest to start from
+#
+# @size: the size of memory region to save
+#
+# @filename: the file to save the memory to as binary data
+#
+# Returns: Nothing on success
+# If @filename cannot be opened, OpenFileFailed
+# If an I/O error occurs while writing the file, IOError
+#
+# Since: 0.14.0
+#
+# Notes: Errors were not reliably returned until 1.1
+##
+{ 'command': 'pmemsave',
+ 'data': {'val': 'int', 'size': 'int', 'filename': 'str'} }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 7b3cbe2..48a11db 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -382,10 +382,7 @@ EQMP
{
.name = "pmemsave",
.args_type = "val:l,size:i,filename:s",
- .params = "addr size file",
- .help = "save to disk physical memory dump starting at 'addr' of size 'size'",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_physical_memory_save,
+ .mhandler.cmd_new = qmp_marshal_input_pmemsave,
},
SQMP
--
1.7.8.rc3.31.g017d1.dirty
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 06/16] qapi: Convert cont
2011-11-28 18:11 [Qemu-devel] [PATCH 1.1 v1 00/16]: QAPI conversions round 3 Luiz Capitulino
` (4 preceding siblings ...)
2011-11-28 18:11 ` [Qemu-devel] [PATCH 05/16] qapi: Convert pmemsave Luiz Capitulino
@ 2011-11-28 18:11 ` Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 07/16] qapi: Convert inject-nmi Luiz Capitulino
` (9 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Luiz Capitulino @ 2011-11-28 18:11 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori, mdroth
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
hmp-commands.hx | 3 +-
hmp.c | 32 +++++++++++++++++++++++
hmp.h | 1 +
monitor.c | 74 +++++++++++-------------------------------------------
monitor.h | 3 ++
qapi-schema.json | 17 ++++++++++++
qmp-commands.hx | 5 +---
qmp.c | 37 +++++++++++++++++++++++++++
8 files changed, 107 insertions(+), 65 deletions(-)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index a165725..bbfa9c4 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -304,8 +304,7 @@ ETEXI
.args_type = "",
.params = "",
.help = "resume emulation",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_cont,
+ .mhandler.cmd = hmp_cont,
},
STEXI
diff --git a/hmp.c b/hmp.c
index 3dcd491..a82cb52 100644
--- a/hmp.c
+++ b/hmp.c
@@ -551,3 +551,35 @@ void hmp_pmemsave(Monitor *mon, const QDict *qdict)
qmp_pmemsave(addr, size, filename, &errp);
hmp_handle_error(mon, &errp);
}
+
+static void hmp_cont_cb(void *opaque, int err)
+{
+ Monitor *mon = opaque;
+
+ if (!err) {
+ hmp_cont(mon, NULL);
+ }
+}
+
+void hmp_cont(Monitor *mon, const QDict *qdict)
+{
+ Error *errp = NULL;
+
+ qmp_cont(&errp);
+ if (error_is_set(&errp)) {
+ if (error_is_type(errp, QERR_DEVICE_ENCRYPTED)) {
+ const char *device;
+
+ /* The device is encrypted. Ask the user for the password
+ and retry */
+
+ device = error_get_field(errp, "device");
+ assert(device != NULL);
+
+ monitor_read_block_device_key(mon, device, hmp_cont_cb, mon);
+ error_free(errp);
+ return;
+ }
+ hmp_handle_error(mon, &errp);
+ }
+}
diff --git a/hmp.h b/hmp.h
index 4882bea..b034704 100644
--- a/hmp.h
+++ b/hmp.h
@@ -39,5 +39,6 @@ void hmp_system_powerdown(Monitor *mon, const QDict *qdict);
void hmp_cpu(Monitor *mon, const QDict *qdict);
void hmp_memsave(Monitor *mon, const QDict *qdict);
void hmp_pmemsave(Monitor *mon, const QDict *qdict);
+void hmp_cont(Monitor *mon, const QDict *qdict);
#endif
diff --git a/monitor.c b/monitor.c
index a1b46b3..b0d1862 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1073,65 +1073,6 @@ static void do_singlestep(Monitor *mon, const QDict *qdict)
}
}
-static void encrypted_bdrv_it(void *opaque, BlockDriverState *bs);
-
-struct bdrv_iterate_context {
- Monitor *mon;
- int err;
-};
-
-static void iostatus_bdrv_it(void *opaque, BlockDriverState *bs)
-{
- bdrv_iostatus_reset(bs);
-}
-
-/**
- * do_cont(): Resume emulation.
- */
-static int do_cont(Monitor *mon, const QDict *qdict, QObject **ret_data)
-{
- struct bdrv_iterate_context context = { mon, 0 };
-
- if (runstate_check(RUN_STATE_INMIGRATE)) {
- qerror_report(QERR_MIGRATION_EXPECTED);
- return -1;
- } else if (runstate_check(RUN_STATE_INTERNAL_ERROR) ||
- runstate_check(RUN_STATE_SHUTDOWN)) {
- qerror_report(QERR_RESET_REQUIRED);
- return -1;
- }
-
- bdrv_iterate(iostatus_bdrv_it, NULL);
- bdrv_iterate(encrypted_bdrv_it, &context);
- /* only resume the vm if all keys are set and valid */
- if (!context.err) {
- vm_start();
- return 0;
- } else {
- return -1;
- }
-}
-
-static void bdrv_key_cb(void *opaque, int err)
-{
- Monitor *mon = opaque;
-
- /* another key was set successfully, retry to continue */
- if (!err)
- do_cont(mon, NULL, NULL);
-}
-
-static void encrypted_bdrv_it(void *opaque, BlockDriverState *bs)
-{
- struct bdrv_iterate_context *context = opaque;
-
- if (!context->err && bdrv_key_required(bs)) {
- context->err = -EBUSY;
- monitor_read_bdrv_key_start(context->mon, bs, bdrv_key_cb,
- context->mon);
- }
-}
-
static void do_gdbserver(Monitor *mon, const QDict *qdict)
{
const char *device = qdict_get_try_str(qdict, "device");
@@ -4858,3 +4799,18 @@ int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,
return err;
}
+
+int monitor_read_block_device_key(Monitor *mon, const char *device,
+ BlockDriverCompletionFunc *completion_cb,
+ void *opaque)
+{
+ BlockDriverState *bs;
+
+ bs = bdrv_find(device);
+ if (!bs) {
+ monitor_printf(mon, "Device not found %s\n", device);
+ return -1;
+ }
+
+ return monitor_read_bdrv_key_start(mon, bs, completion_cb, opaque);
+}
diff --git a/monitor.h b/monitor.h
index e76795f..052f1cb 100644
--- a/monitor.h
+++ b/monitor.h
@@ -49,6 +49,9 @@ void monitor_resume(Monitor *mon);
int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,
BlockDriverCompletionFunc *completion_cb,
void *opaque);
+int monitor_read_block_device_key(Monitor *mon, const char *device,
+ BlockDriverCompletionFunc *completion_cb,
+ void *opaque);
int monitor_get_fd(Monitor *mon, const char *fdname);
diff --git a/qapi-schema.json b/qapi-schema.json
index 57bfe9a..1d312e0 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -935,3 +935,20 @@
##
{ 'command': 'pmemsave',
'data': {'val': 'int', 'size': 'int', 'filename': 'str'} }
+
+##
+# @cont:
+#
+# Resume guest VCPU execution.
+#
+# Since: 0.14.0
+#
+# Returns: If successful, nothing
+# If the QEMU is waiting for an incoming migration, MigrationExpected
+# If QEMU was started with an encrypted block device and a key has
+# not yet been set, DeviceEncrypted.
+#
+# Notes: This command will succeed if the guest is currently running.
+##
+{ 'command': 'cont' }
+
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 48a11db..1f5109c 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -199,10 +199,7 @@ EQMP
{
.name = "cont",
.args_type = "",
- .params = "",
- .help = "resume emulation",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_cont,
+ .mhandler.cmd_new = qmp_marshal_input_cont,
},
SQMP
diff --git a/qmp.c b/qmp.c
index 511dd62..d71ceb4 100644
--- a/qmp.c
+++ b/qmp.c
@@ -117,3 +117,40 @@ SpiceInfo *qmp_query_spice(Error **errp)
return NULL;
};
#endif
+
+static void iostatus_bdrv_it(void *opaque, BlockDriverState *bs)
+{
+ bdrv_iostatus_reset(bs);
+}
+
+static void encrypted_bdrv_it(void *opaque, BlockDriverState *bs)
+{
+ Error **err = opaque;
+
+ if (!error_is_set(err) && bdrv_key_required(bs)) {
+ error_set(err, QERR_DEVICE_ENCRYPTED, bdrv_get_device_name(bs));
+ }
+}
+
+void qmp_cont(Error **errp)
+{
+ Error *local_err = NULL;
+
+ if (runstate_check(RUN_STATE_INMIGRATE)) {
+ error_set(errp, QERR_MIGRATION_EXPECTED);
+ return;
+ } else if (runstate_check(RUN_STATE_INTERNAL_ERROR) ||
+ runstate_check(RUN_STATE_SHUTDOWN)) {
+ error_set(errp, QERR_RESET_REQUIRED);
+ return;
+ }
+
+ bdrv_iterate(iostatus_bdrv_it, NULL);
+ bdrv_iterate(encrypted_bdrv_it, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ }
+
+ vm_start();
+}
--
1.7.8.rc3.31.g017d1.dirty
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 07/16] qapi: Convert inject-nmi
2011-11-28 18:11 [Qemu-devel] [PATCH 1.1 v1 00/16]: QAPI conversions round 3 Luiz Capitulino
` (5 preceding siblings ...)
2011-11-28 18:11 ` [Qemu-devel] [PATCH 06/16] qapi: Convert cont Luiz Capitulino
@ 2011-11-28 18:11 ` Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 08/16] qapi: Convert set_link Luiz Capitulino
` (8 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Luiz Capitulino @ 2011-11-28 18:11 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori, mdroth
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
cpus.c | 13 +++++++++++++
hmp-commands.hx | 3 +--
hmp.c | 8 ++++++++
hmp.h | 1 +
monitor.c | 19 -------------------
qapi-schema.json | 13 +++++++++++++
qmp-commands.hx | 5 +----
7 files changed, 37 insertions(+), 25 deletions(-)
diff --git a/cpus.c b/cpus.c
index 72ab6f5..b7acbb9 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1212,3 +1212,16 @@ void qmp_pmemsave(int64_t addr, int64_t size, const char *filename,
exit:
fclose(f);
}
+
+void qmp_inject_nmi(Error **errp)
+{
+#if defined(TARGET_I386)
+ CPUState *env;
+
+ for (env = first_cpu; env != NULL; env = env->next_cpu) {
+ cpu_interrupt(env, CPU_INTERRUPT_NMI);
+ }
+#else
+ error_set(errp, QERR_UNSUPPORTED);
+#endif
+}
diff --git a/hmp-commands.hx b/hmp-commands.hx
index bbfa9c4..fff39ea 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -736,8 +736,7 @@ ETEXI
.args_type = "",
.params = "",
.help = "inject an NMI on all guest's CPUs",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_inject_nmi,
+ .mhandler.cmd = hmp_inject_nmi,
},
#endif
STEXI
diff --git a/hmp.c b/hmp.c
index a82cb52..fbd55c6 100644
--- a/hmp.c
+++ b/hmp.c
@@ -583,3 +583,11 @@ void hmp_cont(Monitor *mon, const QDict *qdict)
hmp_handle_error(mon, &errp);
}
}
+
+void hmp_inject_nmi(Monitor *mon, const QDict *qdict)
+{
+ Error *errp = NULL;
+
+ qmp_inject_nmi(&errp);
+ hmp_handle_error(mon, &errp);
+}
diff --git a/hmp.h b/hmp.h
index b034704..8a31f87 100644
--- a/hmp.h
+++ b/hmp.h
@@ -40,5 +40,6 @@ void hmp_cpu(Monitor *mon, const QDict *qdict);
void hmp_memsave(Monitor *mon, const QDict *qdict);
void hmp_pmemsave(Monitor *mon, const QDict *qdict);
void hmp_cont(Monitor *mon, const QDict *qdict);
+void hmp_inject_nmi(Monitor *mon, const QDict *qdict);
#endif
diff --git a/monitor.c b/monitor.c
index b0d1862..62b1747 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2204,25 +2204,6 @@ static void do_wav_capture(Monitor *mon, const QDict *qdict)
}
#endif
-#if defined(TARGET_I386)
-static int do_inject_nmi(Monitor *mon, const QDict *qdict, QObject **ret_data)
-{
- CPUState *env;
-
- for (env = first_cpu; env != NULL; env = env->next_cpu) {
- cpu_interrupt(env, CPU_INTERRUPT_NMI);
- }
-
- return 0;
-}
-#else
-static int do_inject_nmi(Monitor *mon, const QDict *qdict, QObject **ret_data)
-{
- qerror_report(QERR_UNSUPPORTED);
- return -1;
-}
-#endif
-
static qemu_acl *find_acl(Monitor *mon, const char *name)
{
qemu_acl *acl = qemu_acl_find(name);
diff --git a/qapi-schema.json b/qapi-schema.json
index 1d312e0..a7f11be 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -952,3 +952,16 @@
##
{ 'command': 'cont' }
+##
+# @inject-nmi:
+#
+# Injects an Non-Maskable Interrupt into all guest's VCPUs.
+#
+# Returns: If successful, nothing
+# If the Virtual Machine doesn't support NMI injection, Unsupported
+#
+# Since: 0.14.0
+#
+# Notes: Only x86 Virtual Machines support this command.
+##
+{ 'command': 'inject-nmi' }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 1f5109c..ff0b801 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -407,10 +407,7 @@ EQMP
{
.name = "inject-nmi",
.args_type = "",
- .params = "",
- .help = "",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_inject_nmi,
+ .mhandler.cmd_new = qmp_marshal_input_inject_nmi,
},
SQMP
--
1.7.8.rc3.31.g017d1.dirty
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 08/16] qapi: Convert set_link
2011-11-28 18:11 [Qemu-devel] [PATCH 1.1 v1 00/16]: QAPI conversions round 3 Luiz Capitulino
` (6 preceding siblings ...)
2011-11-28 18:11 ` [Qemu-devel] [PATCH 07/16] qapi: Convert inject-nmi Luiz Capitulino
@ 2011-11-28 18:11 ` Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 09/16] qapi: Convert block_passwd Luiz Capitulino
` (7 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Luiz Capitulino @ 2011-11-28 18:11 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori, mdroth
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
hmp-commands.hx | 3 +--
hmp.c | 10 ++++++++++
hmp.h | 1 +
net.c | 10 ++++------
net.h | 1 -
qapi-schema.json | 20 ++++++++++++++++++++
qmp-commands.hx | 5 +----
7 files changed, 37 insertions(+), 13 deletions(-)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index fff39ea..546b740 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1037,8 +1037,7 @@ ETEXI
.args_type = "name:s,up:b",
.params = "name on|off",
.help = "change the link status of a network adapter",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_set_link,
+ .mhandler.cmd = hmp_set_link,
},
STEXI
diff --git a/hmp.c b/hmp.c
index fbd55c6..9b21990 100644
--- a/hmp.c
+++ b/hmp.c
@@ -591,3 +591,13 @@ void hmp_inject_nmi(Monitor *mon, const QDict *qdict)
qmp_inject_nmi(&errp);
hmp_handle_error(mon, &errp);
}
+
+void hmp_set_link(Monitor *mon, const QDict *qdict)
+{
+ const char *name = qdict_get_str(qdict, "name");
+ int up = qdict_get_bool(qdict, "up");
+ Error *errp = NULL;
+
+ qmp_set_link(name, up, &errp);
+ hmp_handle_error(mon, &errp);
+}
diff --git a/hmp.h b/hmp.h
index 8a31f87..32d7f68 100644
--- a/hmp.h
+++ b/hmp.h
@@ -41,5 +41,6 @@ void hmp_memsave(Monitor *mon, const QDict *qdict);
void hmp_pmemsave(Monitor *mon, const QDict *qdict);
void hmp_cont(Monitor *mon, const QDict *qdict);
void hmp_inject_nmi(Monitor *mon, const QDict *qdict);
+void hmp_set_link(Monitor *mon, const QDict *qdict);
#endif
diff --git a/net.c b/net.c
index cb52050..f7bebf8 100644
--- a/net.c
+++ b/net.c
@@ -34,6 +34,7 @@
#include "monitor.h"
#include "qemu-common.h"
#include "qemu_socket.h"
+#include "qmp-commands.h"
#include "hw/qdev.h"
#include "iov.h"
@@ -1258,12 +1259,10 @@ void do_info_network(Monitor *mon)
}
}
-int do_set_link(Monitor *mon, const QDict *qdict, QObject **ret_data)
+void qmp_set_link(const char *name, bool up, Error **errp)
{
VLANState *vlan;
VLANClientState *vc = NULL;
- const char *name = qdict_get_str(qdict, "name");
- int up = qdict_get_bool(qdict, "up");
QTAILQ_FOREACH(vlan, &vlans, next) {
QTAILQ_FOREACH(vc, &vlan->clients, next) {
@@ -1280,8 +1279,8 @@ int do_set_link(Monitor *mon, const QDict *qdict, QObject **ret_data)
done:
if (!vc) {
- qerror_report(QERR_DEVICE_NOT_FOUND, name);
- return -1;
+ error_set(errp, QERR_DEVICE_NOT_FOUND, name);
+ return;
}
vc->link_down = !up;
@@ -1300,7 +1299,6 @@ done:
if (vc->peer && vc->peer->info->link_status_changed) {
vc->peer->info->link_status_changed(vc->peer);
}
- return 0;
}
void net_cleanup(void)
diff --git a/net.h b/net.h
index 9f633f8..c6b4190 100644
--- a/net.h
+++ b/net.h
@@ -122,7 +122,6 @@ int qemu_find_nic_model(NICInfo *nd, const char * const *models,
const char *default_model);
void do_info_network(Monitor *mon);
-int do_set_link(Monitor *mon, const QDict *qdict, QObject **ret_data);
/* NIC info */
diff --git a/qapi-schema.json b/qapi-schema.json
index a7f11be..024ddcc 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -965,3 +965,23 @@
# Notes: Only x86 Virtual Machines support this command.
##
{ 'command': 'inject-nmi' }
+
+##
+# @set_link:
+#
+# Sets the link status of a virtual network adapter.
+#
+# @name: the device name of the virtual network adapter
+#
+# @up: true to set the link status to be up
+#
+# Returns: Nothing on success
+# If @name is not a valid network device, DeviceNotFound
+#
+# Since: 0.14.0
+#
+# Notes: Not all network adapters support setting link status. This command
+# will succeed even if the network adapter does not support link status
+# notification.
+##
+{ 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index ff0b801..a65da39 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -730,10 +730,7 @@ EQMP
{
.name = "set_link",
.args_type = "name:s,up:b",
- .params = "name on|off",
- .help = "change the link status of a network adapter",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_set_link,
+ .mhandler.cmd_new = qmp_marshal_input_set_link,
},
SQMP
--
1.7.8.rc3.31.g017d1.dirty
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 09/16] qapi: Convert block_passwd
2011-11-28 18:11 [Qemu-devel] [PATCH 1.1 v1 00/16]: QAPI conversions round 3 Luiz Capitulino
` (7 preceding siblings ...)
2011-11-28 18:11 ` [Qemu-devel] [PATCH 08/16] qapi: Convert set_link Luiz Capitulino
@ 2011-11-28 18:11 ` Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 10/16] qapi: Convert balloon Luiz Capitulino
` (6 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Luiz Capitulino @ 2011-11-28 18:11 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori, mdroth
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
blockdev.c | 22 ++++++++++------------
blockdev.h | 1 -
hmp-commands.hx | 3 +--
hmp.c | 10 ++++++++++
hmp.h | 1 +
qapi-schema.json | 33 +++++++++++++++++++++++++++++++++
qmp-commands.hx | 5 +----
7 files changed, 56 insertions(+), 19 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 2228186..fc9cc63 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -15,6 +15,7 @@
#include "qemu-config.h"
#include "sysemu.h"
#include "block_int.h"
+#include "qmp-commands.h"
static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives);
@@ -660,28 +661,25 @@ int do_eject(Monitor *mon, const QDict *qdict, QObject **ret_data)
return eject_device(mon, bs, force);
}
-int do_block_set_passwd(Monitor *mon, const QDict *qdict,
- QObject **ret_data)
+void qmp_block_passwd(const char *device, const char *password, Error **errp)
{
BlockDriverState *bs;
int err;
- bs = bdrv_find(qdict_get_str(qdict, "device"));
+ bs = bdrv_find(device);
if (!bs) {
- qerror_report(QERR_DEVICE_NOT_FOUND, qdict_get_str(qdict, "device"));
- return -1;
+ error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+ return;
}
- err = bdrv_set_key(bs, qdict_get_str(qdict, "password"));
+ err = bdrv_set_key(bs, password);
if (err == -EINVAL) {
- qerror_report(QERR_DEVICE_NOT_ENCRYPTED, bdrv_get_device_name(bs));
- return -1;
+ error_set(errp, QERR_DEVICE_NOT_ENCRYPTED, bdrv_get_device_name(bs));
+ return;
} else if (err < 0) {
- qerror_report(QERR_INVALID_PASSWORD);
- return -1;
+ error_set(errp, QERR_INVALID_PASSWORD);
+ return;
}
-
- return 0;
}
int do_change_block(Monitor *mon, const char *device,
diff --git a/blockdev.h b/blockdev.h
index 3587786..d1a7204 100644
--- a/blockdev.h
+++ b/blockdev.h
@@ -59,7 +59,6 @@ DriveInfo *add_init_drive(const char *opts);
void do_commit(Monitor *mon, const QDict *qdict);
int do_eject(Monitor *mon, const QDict *qdict, QObject **ret_data);
-int do_block_set_passwd(Monitor *mon, const QDict *qdict, QObject **ret_data);
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);
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 546b740..a054b9a 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1197,8 +1197,7 @@ ETEXI
.args_type = "device:B,password:s",
.params = "block_passwd device password",
.help = "set the password of encrypted block devices",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_block_set_passwd,
+ .mhandler.cmd = hmp_block_passwd,
},
STEXI
diff --git a/hmp.c b/hmp.c
index 9b21990..0306a97 100644
--- a/hmp.c
+++ b/hmp.c
@@ -601,3 +601,13 @@ void hmp_set_link(Monitor *mon, const QDict *qdict)
qmp_set_link(name, up, &errp);
hmp_handle_error(mon, &errp);
}
+
+void hmp_block_passwd(Monitor *mon, const QDict *qdict)
+{
+ const char *device = qdict_get_str(qdict, "device");
+ const char *password = qdict_get_str(qdict, "password");
+ Error *errp = NULL;
+
+ qmp_block_passwd(device, password, &errp);
+ hmp_handle_error(mon, &errp);
+}
diff --git a/hmp.h b/hmp.h
index 32d7f68..d6aa232 100644
--- a/hmp.h
+++ b/hmp.h
@@ -42,5 +42,6 @@ void hmp_pmemsave(Monitor *mon, const QDict *qdict);
void hmp_cont(Monitor *mon, const QDict *qdict);
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);
#endif
diff --git a/qapi-schema.json b/qapi-schema.json
index 024ddcc..08c16a6 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -985,3 +985,36 @@
# notification.
##
{ 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
+
+##
+# @block_passwd:
+#
+# This command sets the password of a block device that has not been open
+# with a password and requires one.
+#
+# The two cases where this can happen are a block device is created through
+# QEMU's initial command line or a block device is changed through the legacy
+# @change interface.
+#
+# In the event that the block device is created through the initial command
+# line, the VM will start in the stopped state regardless of whether '-S' is
+# used. The intention is for a management tool to query the block devices to
+# determine which ones are encrypted, set the passwords with this command, and
+# then start the guest with the @cont command.
+#
+# @device: the name of the device to set the password on
+#
+# @password: the password to use for the device
+#
+# Returns: nothing on success
+# If @device is not a valid block device, DeviceNotFound
+# If @device is not encrypted, DeviceNotEncrypted
+# If @password is not valid for this device, InvalidPassword
+#
+# Notes: Not all block formats support encryption and some that do are not
+# able to validate that a password is correct. Disk corruption may
+# occur if an invalid password is specified.
+#
+# Since: 0.14.0
+##
+{ 'command': 'block_passwd', 'data': {'device': 'str', 'password': 'str'} }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index a65da39..5e7e5dd 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -806,10 +806,7 @@ EQMP
{
.name = "block_passwd",
.args_type = "device:B,password:s",
- .params = "block_passwd device password",
- .help = "set the password of encrypted block devices",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_block_set_passwd,
+ .mhandler.cmd_new = qmp_marshal_input_block_passwd,
},
SQMP
--
1.7.8.rc3.31.g017d1.dirty
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 10/16] qapi: Convert balloon
2011-11-28 18:11 [Qemu-devel] [PATCH 1.1 v1 00/16]: QAPI conversions round 3 Luiz Capitulino
` (8 preceding siblings ...)
2011-11-28 18:11 ` [Qemu-devel] [PATCH 09/16] qapi: Convert block_passwd Luiz Capitulino
@ 2011-11-28 18:11 ` Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 11/16] qapi: Convert block_resize Luiz Capitulino
` (5 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Luiz Capitulino @ 2011-11-28 18:11 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori, mdroth
Note that the command being dropped uses the deprecated MONITOR_CMD_ASYNC
API, but the new command is a regular synchronous command. There shouldn't
be visible differences though, as MONITOR_CMD_ASYNC is internal only.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
balloon.c | 28 ++++++++--------------------
balloon.h | 3 ---
hmp-commands.hx | 4 +---
hmp.c | 12 ++++++++++++
hmp.h | 1 +
qapi-schema.json | 20 ++++++++++++++++++++
qmp-commands.hx | 6 +-----
7 files changed, 43 insertions(+), 31 deletions(-)
diff --git a/balloon.c b/balloon.c
index e1cd5fa..0166744 100644
--- a/balloon.c
+++ b/balloon.c
@@ -100,31 +100,19 @@ BalloonInfo *qmp_query_balloon(Error **errp)
return info;
}
-/**
- * do_balloon(): Request VM to change its memory allocation
- */
-int do_balloon(Monitor *mon, const QDict *params,
- MonitorCompletion cb, void *opaque)
+void qmp_balloon(int64_t value, Error **errp)
{
- int64_t target;
- int ret;
-
if (kvm_enabled() && !kvm_has_sync_mmu()) {
- qerror_report(QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon");
- return -1;
+ error_set(errp, QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon");
+ return;
}
- target = qdict_get_int(params, "value");
- if (target <= 0) {
+ if (value <= 0) {
qerror_report(QERR_INVALID_PARAMETER_VALUE, "target", "a size");
- return -1;
+ return;
}
- ret = qemu_balloon(target);
- if (ret == 0) {
- qerror_report(QERR_DEVICE_NOT_ACTIVE, "balloon");
- return -1;
+
+ if (qemu_balloon(value) == 0) {
+ error_set(errp, QERR_DEVICE_NOT_ACTIVE, "balloon");
}
-
- cb(opaque, NULL);
- return 0;
}
diff --git a/balloon.h b/balloon.h
index b36abea..b60fd5d 100644
--- a/balloon.h
+++ b/balloon.h
@@ -24,7 +24,4 @@ int qemu_add_balloon_handler(QEMUBalloonEvent *event_func,
QEMUBalloonStatus *stat_func, void *opaque);
void qemu_remove_balloon_handler(void *opaque);
-int do_balloon(Monitor *mon, const QDict *params,
- MonitorCompletion cb, void *opaque);
-
#endif
diff --git a/hmp-commands.hx b/hmp-commands.hx
index a054b9a..0badaac 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1021,9 +1021,7 @@ ETEXI
.args_type = "value:M",
.params = "target",
.help = "request VM to change its memory allocation (in MB)",
- .user_print = monitor_user_noop,
- .mhandler.cmd_async = do_balloon,
- .flags = MONITOR_CMD_ASYNC,
+ .mhandler.cmd = hmp_balloon,
},
STEXI
diff --git a/hmp.c b/hmp.c
index 0306a97..f9b3400 100644
--- a/hmp.c
+++ b/hmp.c
@@ -611,3 +611,15 @@ void hmp_block_passwd(Monitor *mon, const QDict *qdict)
qmp_block_passwd(device, password, &errp);
hmp_handle_error(mon, &errp);
}
+
+void hmp_balloon(Monitor *mon, const QDict *qdict)
+{
+ int64_t value = qdict_get_int(qdict, "value");
+ Error *errp = NULL;
+
+ qmp_balloon(value, &errp);
+ if (error_is_set(&errp)) {
+ monitor_printf(mon, "balloon: %s\n", error_get_pretty(errp));
+ error_free(errp);
+ }
+}
diff --git a/hmp.h b/hmp.h
index d6aa232..b0984ac 100644
--- a/hmp.h
+++ b/hmp.h
@@ -43,5 +43,6 @@ void hmp_cont(Monitor *mon, const QDict *qdict);
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);
#endif
diff --git a/qapi-schema.json b/qapi-schema.json
index 08c16a6..6b71c45 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1018,3 +1018,23 @@
# Since: 0.14.0
##
{ 'command': 'block_passwd', 'data': {'device': 'str', 'password': 'str'} }
+
+##
+# @balloon:
+#
+# Request the balloon driver to change its balloon size.
+#
+# @value: the target size of the balloon in bytes
+#
+# Returns: Nothing on success
+# If the balloon driver is enabled but not functional because the KVM
+# kernel module cannot support it, KvmMissingCap
+# If no balloon device is present, DeviceNotActive
+#
+# Notes: This command just issues a request to the guest. When it returns,
+# the balloon size may not have changed. A guest can change the balloon
+# size independent of this command.
+#
+# Since: 0.14.0
+##
+{ 'command': 'balloon', 'data': {'value': 'int'} }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 5e7e5dd..cf18ccd 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -703,11 +703,7 @@ EQMP
{
.name = "balloon",
.args_type = "value:M",
- .params = "target",
- .help = "request VM to change its memory allocation (in MB)",
- .user_print = monitor_user_noop,
- .mhandler.cmd_async = do_balloon,
- .flags = MONITOR_CMD_ASYNC,
+ .mhandler.cmd_new = qmp_marshal_input_balloon,
},
SQMP
--
1.7.8.rc3.31.g017d1.dirty
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 11/16] qapi: Convert block_resize
2011-11-28 18:11 [Qemu-devel] [PATCH 1.1 v1 00/16]: QAPI conversions round 3 Luiz Capitulino
` (9 preceding siblings ...)
2011-11-28 18:11 ` [Qemu-devel] [PATCH 10/16] qapi: Convert balloon Luiz Capitulino
@ 2011-11-28 18:11 ` Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 12/16] qapi: Convert blockdev_snapshot_sync Luiz Capitulino
` (4 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Luiz Capitulino @ 2011-11-28 18:11 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori, mdroth
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
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 12/16] qapi: Convert blockdev_snapshot_sync
2011-11-28 18:11 [Qemu-devel] [PATCH 1.1 v1 00/16]: QAPI conversions round 3 Luiz Capitulino
` (10 preceding siblings ...)
2011-11-28 18:11 ` [Qemu-devel] [PATCH 11/16] qapi: Convert block_resize Luiz Capitulino
@ 2011-11-28 18:11 ` Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 13/16] qapi: Convert human-monitor-command Luiz Capitulino
` (3 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Luiz Capitulino @ 2011-11-28 18:11 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori, mdroth
Unfortunately, this conversion required an additional change.
In the old QMP command, the 'snapshot-file' argument is specified as
optional. The idea is to take the snapshot internally if 'snapshot-file'
is not passed. However, internal snapshots are not supported yet so
the command returns a MissingParamater error if 'snapshot-file' is not
passed. Which makes the argument actually required and will cause
compatibility breakage if we change that in the future.
To fix this the QAPI converted blockdev_snapshot_sync command makes the
'snapshot-file' argument required. Again, in practice it's actually required,
so this is not incompatible.
If we do implement internal snapshots someday, we'll need a new argument
for it.
Note that this discussion doesn't affect HMP.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
blockdev.c | 49 +++++++++++++++++--------------------------------
blockdev.h | 1 -
hmp-commands.hx | 2 +-
hmp.c | 19 +++++++++++++++++++
hmp.h | 1 +
qapi-schema.json | 29 +++++++++++++++++++++++++++++
qmp-commands.hx | 6 ++----
7 files changed, 69 insertions(+), 38 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 874b09f..744fff8 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -551,28 +551,20 @@ void do_commit(Monitor *mon, const QDict *qdict)
}
}
-int do_snapshot_blkdev(Monitor *mon, const QDict *qdict, QObject **ret_data)
+void qmp_blockdev_snapshot_sync(const char *device, const char *snapshot_file,
+ bool has_format, const char *format,
+ Error **errp)
{
- const char *device = qdict_get_str(qdict, "device");
- const char *filename = qdict_get_try_str(qdict, "snapshot-file");
- const char *format = qdict_get_try_str(qdict, "format");
BlockDriverState *bs;
BlockDriver *drv, *old_drv, *proto_drv;
int ret = 0;
int flags;
char old_filename[1024];
- if (!filename) {
- qerror_report(QERR_MISSING_PARAMETER, "snapshot-file");
- ret = -1;
- goto out;
- }
-
bs = bdrv_find(device);
if (!bs) {
- qerror_report(QERR_DEVICE_NOT_FOUND, device);
- ret = -1;
- goto out;
+ error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+ return;
}
pstrcpy(old_filename, sizeof(old_filename), bs->filename);
@@ -580,35 +572,34 @@ int do_snapshot_blkdev(Monitor *mon, const QDict *qdict, QObject **ret_data)
old_drv = bs->drv;
flags = bs->open_flags;
- if (!format) {
+ if (!has_format) {
format = "qcow2";
}
drv = bdrv_find_format(format);
if (!drv) {
- qerror_report(QERR_INVALID_BLOCK_FORMAT, format);
- ret = -1;
- goto out;
+ error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
+ return;
}
- proto_drv = bdrv_find_protocol(filename);
+ proto_drv = bdrv_find_protocol(snapshot_file);
if (!proto_drv) {
- qerror_report(QERR_INVALID_BLOCK_FORMAT, format);
- ret = -1;
- goto out;
+ error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
+ return;
}
- ret = bdrv_img_create(filename, format, bs->filename,
+ ret = bdrv_img_create(snapshot_file, format, bs->filename,
bs->drv->format_name, NULL, -1, flags);
if (ret) {
- goto out;
+ error_set(errp, QERR_UNDEFINED_ERROR);
+ return;
}
qemu_aio_flush();
bdrv_flush(bs);
bdrv_close(bs);
- ret = bdrv_open(bs, filename, flags, drv);
+ ret = bdrv_open(bs, snapshot_file, flags, drv);
/*
* If reopening the image file we just created fails, fall back
* and try to re-open the original image. If that fails too, we
@@ -617,17 +608,11 @@ int do_snapshot_blkdev(Monitor *mon, const QDict *qdict, QObject **ret_data)
if (ret != 0) {
ret = bdrv_open(bs, old_filename, flags, old_drv);
if (ret != 0) {
- qerror_report(QERR_OPEN_FILE_FAILED, old_filename);
+ error_set(errp, QERR_OPEN_FILE_FAILED, old_filename);
} else {
- qerror_report(QERR_OPEN_FILE_FAILED, filename);
+ error_set(errp, QERR_OPEN_FILE_FAILED, snapshot_file);
}
}
-out:
- if (ret) {
- ret = -1;
- }
-
- return ret;
}
static int eject_device(Monitor *mon, BlockDriverState *bs, int force)
diff --git a/blockdev.h b/blockdev.h
index 69f18fb..154424e 100644
--- a/blockdev.h
+++ b/blockdev.h
@@ -62,6 +62,5 @@ int do_eject(Monitor *mon, const QDict *qdict, QObject **ret_data);
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);
#endif
diff --git a/hmp-commands.hx b/hmp-commands.hx
index ec4c9a1..3192494 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -840,7 +840,7 @@ ETEXI
"If format is specified, the snapshot file will\n\t\t\t"
"be created in that format. Otherwise the\n\t\t\t"
"snapshot will be internal! (currently unsupported)",
- .mhandler.cmd_new = do_snapshot_blkdev,
+ .mhandler.cmd = hmp_snapshot_blkdev,
},
STEXI
diff --git a/hmp.c b/hmp.c
index cb20858..2c734f7 100644
--- a/hmp.c
+++ b/hmp.c
@@ -633,3 +633,22 @@ void hmp_block_resize(Monitor *mon, const QDict *qdict)
qmp_block_resize(device, size, &errp);
hmp_handle_error(mon, &errp);
}
+
+void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
+{
+ const char *device = qdict_get_str(qdict, "device");
+ const char *filename = qdict_get_try_str(qdict, "snapshot-file");
+ const char *format = qdict_get_try_str(qdict, "format");
+ Error *errp = NULL;
+
+ if (!filename) {
+ /* In the future, if 'snapshot-file' is not specified, the snapshot
+ will be taken internally. Today it's actually required. */
+ error_set(&errp, QERR_MISSING_PARAMETER, "snapshot-file");
+ hmp_handle_error(mon, &errp);
+ return;
+ }
+
+ qmp_blockdev_snapshot_sync(device, filename, !!format, format, &errp);
+ hmp_handle_error(mon, &errp);
+}
diff --git a/hmp.h b/hmp.h
index c236fd2..e4227d3 100644
--- a/hmp.h
+++ b/hmp.h
@@ -45,5 +45,6 @@ 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);
+void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict);
#endif
diff --git a/qapi-schema.json b/qapi-schema.json
index a6e3fdd..da40c13 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1056,3 +1056,32 @@
# Since: 0.14.0
##
{ 'command': 'block_resize', 'data': { 'device': 'str', 'size': 'int' }}
+
+##
+# @blockdev-snapshot-sync
+#
+# Generates a synchronous snapshot of a block device.
+#
+# @device: the name of the device to generate the snapshot from.
+#
+# @snapshot-file: the target of the new image. If the file exists, or if it
+# is a device, the snapshot will be created in the existing
+# file/device. If does not exist, a new file will be created.
+#
+# @format: #optional the format of the snapshot image, default is 'qcow2'.
+#
+# Returns: nothing on success
+# If @device is not a valid block device, DeviceNotFound
+# If @snapshot-file can't be opened, OpenFileFailed
+# If @format is invalid, InvalidBlockFormat
+#
+# Notes: One of the last steps taken by this command is to close the current
+# image being used by @device and open the @snapshot-file one. If that
+# fails, the command will try to reopen the original image file. If
+# that also fails OpenFileFailed will be returned and the guest may get
+# unexpected errors.
+#
+# Since 0.14.0
+##
+{ 'command': 'blockdev-snapshot-sync',
+ 'data': { 'device': 'str', 'snapshot-file': 'str', '*format': 'str' } }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index a35946f..8edf99b 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -665,10 +665,8 @@ EQMP
{
.name = "blockdev-snapshot-sync",
- .args_type = "device:B,snapshot-file:s?,format:s?",
- .params = "device [new-image-file] [format]",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_snapshot_blkdev,
+ .args_type = "device:B,snapshot-file:s,format:s?",
+ .mhandler.cmd_new = qmp_marshal_input_blockdev_snapshot_sync,
},
SQMP
--
1.7.8.rc3.31.g017d1.dirty
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 13/16] qapi: Convert human-monitor-command
2011-11-28 18:11 [Qemu-devel] [PATCH 1.1 v1 00/16]: QAPI conversions round 3 Luiz Capitulino
` (11 preceding siblings ...)
2011-11-28 18:11 ` [Qemu-devel] [PATCH 12/16] qapi: Convert blockdev_snapshot_sync Luiz Capitulino
@ 2011-11-28 18:11 ` Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 14/16] qapi: Convert migrate_cancel Luiz Capitulino
` (2 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Luiz Capitulino @ 2011-11-28 18:11 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori, mdroth
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
monitor.c | 23 ++++++++++++++---------
qapi-schema.json | 28 ++++++++++++++++++++++++++++
qmp-commands.hx | 5 +----
3 files changed, 43 insertions(+), 13 deletions(-)
diff --git a/monitor.c b/monitor.c
index 62b1747..7334401 100644
--- a/monitor.c
+++ b/monitor.c
@@ -513,10 +513,10 @@ static int do_qmp_capabilities(Monitor *mon, const QDict *params,
static void handle_user_command(Monitor *mon, const char *cmdline);
-static int do_hmp_passthrough(Monitor *mon, const QDict *params,
- QObject **ret_data)
+char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index,
+ int64_t cpu_index, Error **errp)
{
- int ret = 0;
+ char *output = NULL;
Monitor *old_mon, hmp;
CharDriverState mchar;
@@ -527,25 +527,30 @@ static int do_hmp_passthrough(Monitor *mon, const QDict *params,
old_mon = cur_mon;
cur_mon = &hmp;
- if (qdict_haskey(params, "cpu-index")) {
- ret = monitor_set_cpu(qdict_get_int(params, "cpu-index"));
+ if (has_cpu_index) {
+ int ret = monitor_set_cpu(cpu_index);
if (ret < 0) {
cur_mon = old_mon;
- qerror_report(QERR_INVALID_PARAMETER_VALUE, "cpu-index", "a CPU number");
+ error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
+ "a CPU number");
goto out;
}
}
- handle_user_command(&hmp, qdict_get_str(params, "command-line"));
+ handle_user_command(&hmp, command_line);
cur_mon = old_mon;
if (qemu_chr_mem_osize(hmp.chr) > 0) {
- *ret_data = QOBJECT(qemu_chr_mem_to_qs(hmp.chr));
+ QString *str = qemu_chr_mem_to_qs(hmp.chr);
+ output = g_strdup(qstring_get_str(str));
+ QDECREF(str);
+ } else {
+ output = g_strdup("");
}
out:
qemu_chr_close_mem(hmp.chr);
- return ret;
+ return output;
}
static int compare_cmd(const char *name, const char *list)
diff --git a/qapi-schema.json b/qapi-schema.json
index da40c13..a762d2e 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1085,3 +1085,31 @@
##
{ 'command': 'blockdev-snapshot-sync',
'data': { 'device': 'str', 'snapshot-file': 'str', '*format': 'str' } }
+
+##
+# @human-monitor-command:
+#
+# Execute a command on the human monitor and return the output.
+#
+# @command-line: the command to execute in the human monitor
+#
+# @cpu-index: #optional The CPU to use for commands that require an implicit CPU
+#
+# Returns: the output of the command as a string
+#
+# Since: 0.14.0
+#
+# Notes: This command only exists as a stop-gap. It's use is highly
+# discouraged. The semantics of this command are not guaranteed.
+#
+# Known limitations:
+#
+# o This command is stateless, this means that commands that depend
+# on state information (such as getfd) might not work
+#
+# o Commands that prompt the user for data (eg. 'cont' when the block
+# device is encrypted) don't currently work
+##
+{ 'command': 'human-monitor-command',
+ 'data': {'command-line': 'str', '*cpu-index': 'int'},
+ 'returns': 'str' }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 8edf99b..0c41eae 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -932,10 +932,7 @@ EQMP
{
.name = "human-monitor-command",
.args_type = "command-line:s,cpu-index:i?",
- .params = "",
- .help = "",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_hmp_passthrough,
+ .mhandler.cmd_new = qmp_marshal_input_human_monitor_command,
},
SQMP
--
1.7.8.rc3.31.g017d1.dirty
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 14/16] qapi: Convert migrate_cancel
2011-11-28 18:11 [Qemu-devel] [PATCH 1.1 v1 00/16]: QAPI conversions round 3 Luiz Capitulino
` (12 preceding siblings ...)
2011-11-28 18:11 ` [Qemu-devel] [PATCH 13/16] qapi: Convert human-monitor-command Luiz Capitulino
@ 2011-11-28 18:11 ` 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
15 siblings, 0 replies; 17+ messages in thread
From: Luiz Capitulino @ 2011-11-28 18:11 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori, mdroth
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
hmp-commands.hx | 3 +--
hmp.c | 5 +++++
hmp.h | 1 +
migration.c | 3 +--
migration.h | 2 --
qapi-schema.json | 13 +++++++++++++
qmp-commands.hx | 5 +----
7 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 3192494..e205bfb 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -771,8 +771,7 @@ ETEXI
.args_type = "",
.params = "",
.help = "cancel the current VM migration",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_migrate_cancel,
+ .mhandler.cmd = hmp_migrate_cancel,
},
STEXI
diff --git a/hmp.c b/hmp.c
index 2c734f7..f7c9755 100644
--- a/hmp.c
+++ b/hmp.c
@@ -652,3 +652,8 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
qmp_blockdev_snapshot_sync(device, filename, !!format, format, &errp);
hmp_handle_error(mon, &errp);
}
+
+void hmp_migrate_cancel(Monitor *mon, const QDict *qdict)
+{
+ qmp_migrate_cancel(NULL);
+}
diff --git a/hmp.h b/hmp.h
index e4227d3..2b0c1e4 100644
--- a/hmp.h
+++ b/hmp.h
@@ -46,5 +46,6 @@ 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);
void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict);
+void hmp_migrate_cancel(Monitor *mon, const QDict *qdict);
#endif
diff --git a/migration.c b/migration.c
index 8280d71..fa603d6 100644
--- a/migration.c
+++ b/migration.c
@@ -468,10 +468,9 @@ int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
return 0;
}
-int do_migrate_cancel(Monitor *mon, const QDict *qdict, QObject **ret_data)
+void qmp_migrate_cancel(Error **errp)
{
migrate_fd_cancel(migrate_get_current());
- return 0;
}
int do_migrate_set_speed(Monitor *mon, const QDict *qdict, QObject **ret_data)
diff --git a/migration.h b/migration.h
index 0682179..ff2e40b 100644
--- a/migration.h
+++ b/migration.h
@@ -42,8 +42,6 @@ int qemu_start_incoming_migration(const char *uri);
int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data);
-int do_migrate_cancel(Monitor *mon, const QDict *qdict, QObject **ret_data);
-
int do_migrate_set_speed(Monitor *mon, const QDict *qdict, QObject **ret_data);
uint64_t migrate_max_downtime(void);
diff --git a/qapi-schema.json b/qapi-schema.json
index a762d2e..27c060a 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1113,3 +1113,16 @@
{ 'command': 'human-monitor-command',
'data': {'command-line': 'str', '*cpu-index': 'int'},
'returns': 'str' }
+
+##
+# @migrate_cancel
+#
+# Cancel the current executing migration process.
+#
+# Returns: nothing on success
+#
+# Notes: This command succeeds even if there is no migration process running.
+#
+# Since: 0.14.0
+##
+{ 'command': 'migrate_cancel' }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 0c41eae..49c7d00 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -471,10 +471,7 @@ EQMP
{
.name = "migrate_cancel",
.args_type = "",
- .params = "",
- .help = "cancel the current VM migration",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_migrate_cancel,
+ .mhandler.cmd_new = qmp_marshal_input_migrate_cancel,
},
SQMP
--
1.7.8.rc3.31.g017d1.dirty
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 15/16] qapi: Convert migrate_set_downtime
2011-11-28 18:11 [Qemu-devel] [PATCH 1.1 v1 00/16]: QAPI conversions round 3 Luiz Capitulino
` (13 preceding siblings ...)
2011-11-28 18:11 ` [Qemu-devel] [PATCH 14/16] qapi: Convert migrate_cancel Luiz Capitulino
@ 2011-11-28 18:11 ` Luiz Capitulino
2011-11-28 18:11 ` [Qemu-devel] [PATCH 16/16] qapi: Convert migrate_set_speed Luiz Capitulino
15 siblings, 0 replies; 17+ messages in thread
From: Luiz Capitulino @ 2011-11-28 18:11 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori, mdroth
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
hmp-commands.hx | 3 +--
hmp.c | 6 ++++++
hmp.h | 1 +
migration.c | 13 ++++---------
migration.h | 3 ---
qapi-schema.json | 13 +++++++++++++
qmp-commands.hx | 5 +----
7 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index e205bfb..4a79978 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -801,8 +801,7 @@ ETEXI
.args_type = "value:T",
.params = "value",
.help = "set maximum tolerated downtime (in seconds) for migrations",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_migrate_set_downtime,
+ .mhandler.cmd = hmp_migrate_set_downtime,
},
STEXI
diff --git a/hmp.c b/hmp.c
index f7c9755..d7577b7 100644
--- a/hmp.c
+++ b/hmp.c
@@ -657,3 +657,9 @@ void hmp_migrate_cancel(Monitor *mon, const QDict *qdict)
{
qmp_migrate_cancel(NULL);
}
+
+void hmp_migrate_set_downtime(Monitor *mon, const QDict *qdict)
+{
+ double value = qdict_get_double(qdict, "value");
+ qmp_migrate_set_downtime(value, NULL);
+}
diff --git a/hmp.h b/hmp.h
index 2b0c1e4..9182622 100644
--- a/hmp.h
+++ b/hmp.h
@@ -47,5 +47,6 @@ void hmp_balloon(Monitor *mon, const QDict *qdict);
void hmp_block_resize(Monitor *mon, const QDict *qdict);
void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict);
void hmp_migrate_cancel(Monitor *mon, const QDict *qdict);
+void hmp_migrate_set_downtime(Monitor *mon, const QDict *qdict);
#endif
diff --git a/migration.c b/migration.c
index fa603d6..a563162 100644
--- a/migration.c
+++ b/migration.c
@@ -490,14 +490,9 @@ int do_migrate_set_speed(Monitor *mon, const QDict *qdict, QObject **ret_data)
return 0;
}
-int do_migrate_set_downtime(Monitor *mon, const QDict *qdict,
- QObject **ret_data)
+void qmp_migrate_set_downtime(double value, Error **errp)
{
- double d;
-
- d = qdict_get_double(qdict, "value") * 1e9;
- d = MAX(0, MIN(UINT64_MAX, d));
- max_downtime = (uint64_t)d;
-
- return 0;
+ value *= 1e9;
+ value = MAX(0, MIN(UINT64_MAX, value));
+ max_downtime = (uint64_t)value;
}
diff --git a/migration.h b/migration.h
index ff2e40b..539f8f1 100644
--- a/migration.h
+++ b/migration.h
@@ -46,9 +46,6 @@ int do_migrate_set_speed(Monitor *mon, const QDict *qdict, QObject **ret_data);
uint64_t migrate_max_downtime(void);
-int do_migrate_set_downtime(Monitor *mon, const QDict *qdict,
- QObject **ret_data);
-
void do_info_migrate_print(Monitor *mon, const QObject *data);
void do_info_migrate(Monitor *mon, QObject **ret_data);
diff --git a/qapi-schema.json b/qapi-schema.json
index 27c060a..5118439 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1126,3 +1126,16 @@
# Since: 0.14.0
##
{ 'command': 'migrate_cancel' }
+
+##
+# @migrate_set_downtime
+#
+# Set maximum tolerated downtime for migration.
+#
+# @value: maximum downtime in seconds
+#
+# Returns: nothing on success
+#
+# Since: 0.14.0
+##
+{ 'command': 'migrate_set_downtime', 'data': {'value': 'number'} }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 49c7d00..9c1bf93 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -518,10 +518,7 @@ EQMP
{
.name = "migrate_set_downtime",
.args_type = "value:T",
- .params = "value",
- .help = "set maximum tolerated downtime (in seconds) for migrations",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_migrate_set_downtime,
+ .mhandler.cmd_new = qmp_marshal_input_migrate_set_downtime,
},
SQMP
--
1.7.8.rc3.31.g017d1.dirty
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 16/16] qapi: Convert migrate_set_speed
2011-11-28 18:11 [Qemu-devel] [PATCH 1.1 v1 00/16]: QAPI conversions round 3 Luiz Capitulino
` (14 preceding siblings ...)
2011-11-28 18:11 ` [Qemu-devel] [PATCH 15/16] qapi: Convert migrate_set_downtime Luiz Capitulino
@ 2011-11-28 18:11 ` Luiz Capitulino
15 siblings, 0 replies; 17+ messages in thread
From: Luiz Capitulino @ 2011-11-28 18:11 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori, mdroth
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
hmp-commands.hx | 3 +--
hmp.c | 6 ++++++
hmp.h | 1 +
migration.c | 12 ++++--------
migration.h | 2 --
qapi-schema.json | 15 +++++++++++++++
qmp-commands.hx | 5 +----
7 files changed, 28 insertions(+), 16 deletions(-)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 4a79978..904eea6 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -786,8 +786,7 @@ ETEXI
.params = "value",
.help = "set maximum speed (in bytes) for migrations. "
"Defaults to MB if no size suffix is specified, ie. B/K/M/G/T",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_migrate_set_speed,
+ .mhandler.cmd = hmp_migrate_set_speed,
},
STEXI
diff --git a/hmp.c b/hmp.c
index d7577b7..4c330e2 100644
--- a/hmp.c
+++ b/hmp.c
@@ -663,3 +663,9 @@ void hmp_migrate_set_downtime(Monitor *mon, const QDict *qdict)
double value = qdict_get_double(qdict, "value");
qmp_migrate_set_downtime(value, NULL);
}
+
+void hmp_migrate_set_speed(Monitor *mon, const QDict *qdict)
+{
+ int64_t value = qdict_get_int(qdict, "value");
+ qmp_migrate_set_speed(value, NULL);
+}
diff --git a/hmp.h b/hmp.h
index 9182622..093242d 100644
--- a/hmp.h
+++ b/hmp.h
@@ -48,5 +48,6 @@ void hmp_block_resize(Monitor *mon, const QDict *qdict);
void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict);
void hmp_migrate_cancel(Monitor *mon, const QDict *qdict);
void hmp_migrate_set_downtime(Monitor *mon, const QDict *qdict);
+void hmp_migrate_set_speed(Monitor *mon, const QDict *qdict);
#endif
diff --git a/migration.c b/migration.c
index a563162..75d4f02 100644
--- a/migration.c
+++ b/migration.c
@@ -473,21 +473,17 @@ void qmp_migrate_cancel(Error **errp)
migrate_fd_cancel(migrate_get_current());
}
-int do_migrate_set_speed(Monitor *mon, const QDict *qdict, QObject **ret_data)
+void qmp_migrate_set_speed(int64_t value, Error **errp)
{
- int64_t d;
MigrationState *s;
- d = qdict_get_int(qdict, "value");
- if (d < 0) {
- d = 0;
+ if (value < 0) {
+ value = 0;
}
s = migrate_get_current();
- s->bandwidth_limit = d;
+ s->bandwidth_limit = value;
qemu_file_set_rate_limit(s->file, s->bandwidth_limit);
-
- return 0;
}
void qmp_migrate_set_downtime(double value, Error **errp)
diff --git a/migration.h b/migration.h
index 539f8f1..999d60f 100644
--- a/migration.h
+++ b/migration.h
@@ -42,8 +42,6 @@ int qemu_start_incoming_migration(const char *uri);
int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data);
-int do_migrate_set_speed(Monitor *mon, const QDict *qdict, QObject **ret_data);
-
uint64_t migrate_max_downtime(void);
void do_info_migrate_print(Monitor *mon, const QObject *data);
diff --git a/qapi-schema.json b/qapi-schema.json
index 5118439..b6773b7 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1139,3 +1139,18 @@
# Since: 0.14.0
##
{ 'command': 'migrate_set_downtime', 'data': {'value': 'number'} }
+
+##
+# @migrate_set_speed
+#
+# Set maximum speed for migration.
+#
+# @value: maximum speed in bytes.
+#
+# Returns: nothing on success
+#
+# Notes: A value lesser than zero will be automatically round up to zero.
+#
+# Since: 0.14.0
+##
+{ 'command': 'migrate_set_speed', 'data': {'value': 'int'} }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 9c1bf93..35f99ef 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -492,10 +492,7 @@ EQMP
{
.name = "migrate_set_speed",
.args_type = "value:o",
- .params = "value",
- .help = "set maximum speed (in bytes) for migrations",
- .user_print = monitor_user_noop,
- .mhandler.cmd_new = do_migrate_set_speed,
+ .mhandler.cmd_new = qmp_marshal_input_migrate_set_speed,
},
SQMP
--
1.7.8.rc3.31.g017d1.dirty
^ permalink raw reply related [flat|nested] 17+ messages in thread