qmp: Use unsigned integers for address parameters
PATCH v3 1/1 qmp: Use unsigned integers for address parameters
Fixes higher-half address parsing for QMP commands [p]memsave.
--- qapi/machine.json | 11 +++++++++-- system/cpus.c | 10 +++++----- 2 files changed, 14 insertions(+), 7 deletions(-)
qapi/machine.json +9 -2
@@ -852,7 +852,11 @@ # <- { "return": {} } ## { 'command': 'memsave', - 'data': {'val': 'int', 'size': 'int', 'filename': 'str', '*cpu-index': 'int'} } + 'data': { + 'val': 'uint64', + 'size': 'size', + 'filename': 'str', + '*cpu-index': 'int' } } ## # @pmemsave:
@@ -878,7 +882,10 @@ # <- { "return": {} } ## { 'command': 'pmemsave', - 'data': {'val': 'int', 'size': 'int', 'filename': 'str'} } + 'data': { + 'val': 'uint64', + 'size': 'size', + 'filename': 'str' } } ## # @Memdev:
system/cpus.c +5 -5
@@ -792,14 +792,14 @@ int vm_stop_force_state(RunState state) } } -void qmp_memsave (int64_t addr,int64_t size,const char *filename, +void qmp_memsave (uint64_t addr,uint64_t size,const char *filename,bool has_cpu,int64_t cpu_index,Error **errp) {FILE *f; -uint32_t l; +uint64_t l;CPUState *cpu;uint8_t buf[1024 ]; -int64_t orig_addr = addr, orig_size = size; +uint64_t orig_addr = addr, orig_size = size;if (!has_cpu) { cpu_index =0 ;
@@ -840,11 +840,11 @@ exit:fclose (f); } -void qmp_pmemsave (int64_t addr,int64_t size,const char *filename, +void qmp_pmemsave (uint64_t addr,uint64_t size,const char *filename,Error **errp) {FILE *f; -uint32_t l; +uint64_t l;uint8_t buf[1024 ]; f =fopen (filename,"wb" );
Signature · 1 line
2.34.1
Let's go back to v1's title
qmp: Fix higher half vaddrs for [p]memsave
Quoted 50 lines · Josh Junon
Fixes higher-half address parsing for QMP commands
[p]memsave.Signed-off-by Josh Junon <[email protected]>--- qapi/machine.json | 11 +++++++++-- system/cpus.c | 10 +++++----- 2 files changed, 14 insertions(+), 7 deletions(-)qapi/machine.json +9
-2@@ -852,7 +852,11 @@ # <- { "return": {} } ## { 'command': 'memsave', - 'data': {'val': 'int', 'size': 'int', 'filename': 'str', '*cpu-index': 'int'} } + 'data': { + 'val': 'uint64', + 'size': 'size', + 'filename': 'str', + '*cpu-index': 'int' } } ## # @pmemsave:@@ -878,7 +882,10 @@ # <- { "return": {} } ## { 'command': 'pmemsave', - 'data': {'val': 'int', 'size': 'int', 'filename': 'str'} } + 'data': { + 'val': 'uint64', + 'size': 'size', + 'filename': 'str' } } ## # @Memdev:system/cpus.c +1
-1@@ -792,14 +792,14 @@ int vm_stop_force_state(RunState state) } } -void qmp_memsave (int64_t addr,int64_t size,const char *filename, +void qmp_memsave (uint64_t addr,uint64_t size,const char *filename,bool has_cpu,int64_t cpu_index,Error **errp) {
system/cpus.c int vm_stop_force_state(RunState state) · line 805
Quoted 10 lines
system/cpus.c +2
-2FILE *f; -uint32_t l; +uint64_t l;CPUState *cpu;uint8_t buf[1024 ]; -int64_t orig_addr = addr, orig_size = size; +uint64_t orig_addr = addr, orig_size = size;if (!has_cpu) { cpu_index =0 ;
}
[...]
if (cpu_memory_rw_debug(cpu, addr, buf, l, 0) != 0) {
error_setg(errp, "Invalid addr 0x%016" PRIx64 "/size %" PRId64
" specified", orig_addr, orig_size);@size is now unsigned and should be formatted with PRIu64.
goto exit;
}Quoted 4 lines
system/cpus.c +0
-0@@ -840,11 +840,11 @@ exit:fclose (f); }
system/cpus.c exit: · line 850
Quoted 10 lines
system/cpus.c +2
-2-void qmp_pmemsave (int64_t addr,int64_t size,const char *filename, +void qmp_pmemsave (uint64_t addr,uint64_t size,const char *filename,Error **errp) {FILE *f; -uint32_t l; +uint64_t l;uint8_t buf[1024 ]; f =fopen (filename,"wb" );
I can address my nitpicks in my tree, no respin necessary.
Quoted 72 lines · Markus Armbruster
Let's go back to v1's title
qmp: Fix higher half vaddrs for [p]memsave
Quoted 50 lines · Josh Junon
Fixes higher-half address parsing for QMP commands
[p]memsave.Signed-off-by Josh Junon <[email protected]>--- qapi/machine.json | 11 +++++++++-- system/cpus.c | 10 +++++----- 2 files changed, 14 insertions(+), 7 deletions(-)qapi/machine.json +9
-2@@ -852,7 +852,11 @@ # <- { "return": {} } ## { 'command': 'memsave', - 'data': {'val': 'int', 'size': 'int', 'filename': 'str', '*cpu-index': 'int'} } + 'data': { + 'val': 'uint64', + 'size': 'size', + 'filename': 'str', + '*cpu-index': 'int' } } ## # @pmemsave:@@ -878,7 +882,10 @@ # <- { "return": {} } ## { 'command': 'pmemsave', - 'data': {'val': 'int', 'size': 'int', 'filename': 'str'} } + 'data': { + 'val': 'uint64', + 'size': 'size', + 'filename': 'str' } } ## # @Memdev:system/cpus.c +1
-1@@ -792,14 +792,14 @@ int vm_stop_force_state(RunState state) } } -void qmp_memsave (int64_t addr,int64_t size,const char *filename, +void qmp_memsave (uint64_t addr,uint64_t size,const char *filename,bool has_cpu,int64_t cpu_index,Error **errp) {system/cpus.c int vm_stop_force_state(RunState state) · line 805
Quoted 10 lines
system/cpus.c +2
-2FILE *f; -uint32_t l; +uint64_t l;CPUState *cpu;uint8_t buf[1024 ]; -int64_t orig_addr = addr, orig_size = size; +uint64_t orig_addr = addr, orig_size = size;if (!has_cpu) { cpu_index =0 ;} [...] if (cpu_memory_rw_debug(cpu, addr, buf, l, 0) != 0) { error_setg(errp, "Invalid addr 0x%016" PRIx64 "/size %" PRId64 " specified", orig_addr, orig_size);
Quoted 1 line
@size is now unsigned and should be formatted with PRIu64.
Ah yes, missed that one last round. Apologies!
Quoted 16 lines
goto exit; }Quoted 13 lines
system/cpus.c +2
-2@@ -840,11 +840,11 @@ exit:fclose (f); } -void qmp_pmemsave (int64_t addr,int64_t size,const char *filename, +void qmp_pmemsave (uint64_t addr,uint64_t size,const char *filename,Error **errp) {FILE *f; -uint32_t l; +uint64_t l;uint8_t buf[1024 ];
Quoted 6 lines
system/cpus.c exit: · line 850
Quoted 1 line
system/cpus.c +0
-0f =fopen (filename,"wb" );I can address my nitpicks in my tree, no respin necessary.
Reviewed-by Markus Armbruster <[email protected]>
Sounds good to me, thank you for the reviews!
- Josh
Markus Armbruster
AppliedQuoted 4 lines · Josh Junon
Fixes higher-half address parsing for QMP commands
[p]memsave.Signed-off-by Josh Junon <[email protected]>
Queued for 9.1. Thanks!