mirror of https://github.com/xemu-project/xemu.git
dump: Improve some dump-guest-memory error messages
Zero @length is rejected with "Invalid parameter 'length'". Improve to "parameter 'length' expects a non-zero length". qemu_open_old() is a wrapper around qemu_open_internal() that throws away error information. Switch to the wrapper that doesn't: qemu_create(). Example improvement: (qemu) dump-guest-memory /dev/fdset/x 0 1 Error: Could not open '/dev/fdset/x': Invalid argument becomes Error: Could not parse fdset /dev/fdset/x @protocol values not starting with "fd:" or "file:" are rejected with "Invalid parameter 'protocol'". Improve to "parameter 'protocol' must start with 'file:' or 'fd:'". While there, make the conditional checking @protocol a little more obvious. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20231031104531.3169721-5-armbru@redhat.com>
This commit is contained in:
parent
f8c49724cb
commit
28035bed1c
18
dump/dump.c
18
dump/dump.c
|
@ -1828,7 +1828,7 @@ static void dump_init(DumpState *s, int fd, bool has_format,
|
||||||
|
|
||||||
s->fd = fd;
|
s->fd = fd;
|
||||||
if (has_filter && !length) {
|
if (has_filter && !length) {
|
||||||
error_setg(errp, QERR_INVALID_PARAMETER, "length");
|
error_setg(errp, "parameter 'length' expects a non-zero size");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
s->filter_area_begin = begin;
|
s->filter_area_begin = begin;
|
||||||
|
@ -2088,7 +2088,7 @@ void qmp_dump_guest_memory(bool paging, const char *protocol,
|
||||||
{
|
{
|
||||||
ERRP_GUARD();
|
ERRP_GUARD();
|
||||||
const char *p;
|
const char *p;
|
||||||
int fd = -1;
|
int fd;
|
||||||
DumpState *s;
|
DumpState *s;
|
||||||
bool detach_p = false;
|
bool detach_p = false;
|
||||||
bool kdump_raw = false;
|
bool kdump_raw = false;
|
||||||
|
@ -2175,18 +2175,14 @@ void qmp_dump_guest_memory(bool paging, const char *protocol,
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else if (strstart(protocol, "file:", &p)) {
|
||||||
|
fd = qemu_create(p, O_WRONLY | O_TRUNC | O_BINARY, S_IRUSR, errp);
|
||||||
if (strstart(protocol, "file:", &p)) {
|
|
||||||
fd = qemu_open_old(p, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR);
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
error_setg_file_open(errp, errno, p);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
error_setg(errp,
|
||||||
if (fd == -1) {
|
"parameter 'protocol' must start with 'file:' or 'fd:'");
|
||||||
error_setg(errp, QERR_INVALID_PARAMETER, "protocol");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (kdump_raw && lseek(fd, 0, SEEK_CUR) == (off_t) -1) {
|
if (kdump_raw && lseek(fd, 0, SEEK_CUR) == (off_t) -1) {
|
||||||
|
|
Loading…
Reference in New Issue