Skip to content

Commit e654919

Browse files
brenns10elmarco
authored andcommitted
dump: Add command interface for kdump-raw formats
The QMP dump API represents the dump format as an enumeration. Add three new enumerators, one for each supported kdump compression, each named "kdump-raw-*". For the HMP command line, rather than adding a new flag corresponding to each format, it seems more human-friendly to add a single flag "-R" to switch the kdump formats to "raw" mode. The choice of "-R" also correlates nicely to the "makedumpfile -R" option, which would serve to reassemble a flattened vmcore. Signed-off-by: Stephen Brennan <[email protected]> Reviewed-by: Daniel P. Berrangé <[email protected]> [ Marc-André: replace loff_t with off_t, indent fixes ] Reviewed-by: Marc-André Lureau <[email protected]> Message-Id: <[email protected]>
1 parent d43a01d commit e654919

File tree

4 files changed

+76
-11
lines changed

4 files changed

+76
-11
lines changed

dump/dump-hmp-cmds.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
1919
bool paging = qdict_get_try_bool(qdict, "paging", false);
2020
bool zlib = qdict_get_try_bool(qdict, "zlib", false);
2121
bool lzo = qdict_get_try_bool(qdict, "lzo", false);
22+
bool raw = qdict_get_try_bool(qdict, "raw", false);
2223
bool snappy = qdict_get_try_bool(qdict, "snappy", false);
2324
const char *file = qdict_get_str(qdict, "filename");
2425
bool has_begin = qdict_haskey(qdict, "begin");
@@ -40,16 +41,28 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
4041
dump_format = DUMP_GUEST_MEMORY_FORMAT_WIN_DMP;
4142
}
4243

43-
if (zlib) {
44-
dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB;
44+
if (zlib && raw) {
45+
if (raw) {
46+
dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_RAW_ZLIB;
47+
} else {
48+
dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB;
49+
}
4550
}
4651

4752
if (lzo) {
48-
dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO;
53+
if (raw) {
54+
dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_RAW_LZO;
55+
} else {
56+
dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO;
57+
}
4958
}
5059

5160
if (snappy) {
52-
dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY;
61+
if (raw) {
62+
dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_RAW_SNAPPY;
63+
} else {
64+
dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY;
65+
}
5366
}
5467

5568
if (has_begin) {

dump/dump.c

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2090,6 +2090,7 @@ void qmp_dump_guest_memory(bool paging, const char *file,
20902090
int fd = -1;
20912091
DumpState *s;
20922092
bool detach_p = false;
2093+
bool kdump_raw = false;
20932094

20942095
if (runstate_check(RUN_STATE_INMIGRATE)) {
20952096
error_setg(errp, "Dump not allowed during incoming migration.");
@@ -2103,6 +2104,29 @@ void qmp_dump_guest_memory(bool paging, const char *file,
21032104
return;
21042105
}
21052106

2107+
/*
2108+
* externally, we represent kdump-raw-* as separate formats, but internally
2109+
* they are handled the same, except for the "raw" flag
2110+
*/
2111+
if (has_format) {
2112+
switch (format) {
2113+
case DUMP_GUEST_MEMORY_FORMAT_KDUMP_RAW_ZLIB:
2114+
format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB;
2115+
kdump_raw = true;
2116+
break;
2117+
case DUMP_GUEST_MEMORY_FORMAT_KDUMP_RAW_LZO:
2118+
format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO;
2119+
kdump_raw = true;
2120+
break;
2121+
case DUMP_GUEST_MEMORY_FORMAT_KDUMP_RAW_SNAPPY:
2122+
format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY;
2123+
kdump_raw = true;
2124+
break;
2125+
default:
2126+
break;
2127+
}
2128+
}
2129+
21062130
/*
21072131
* kdump-compressed format need the whole memory dumped, so paging or
21082132
* filter is not supported here.
@@ -2166,6 +2190,10 @@ void qmp_dump_guest_memory(bool paging, const char *file,
21662190
error_setg(errp, QERR_INVALID_PARAMETER, "protocol");
21672191
return;
21682192
}
2193+
if (kdump_raw && lseek(fd, 0, SEEK_CUR) == (off_t) -1) {
2194+
error_setg(errp, "kdump-raw formats require a seekable file");
2195+
return;
2196+
}
21692197

21702198
if (!dump_migration_blocker) {
21712199
error_setg(&dump_migration_blocker,
@@ -2186,7 +2214,7 @@ void qmp_dump_guest_memory(bool paging, const char *file,
21862214
dump_state_prepare(s);
21872215

21882216
dump_init(s, fd, has_format, format, paging, has_begin,
2189-
begin, length, false, errp);
2217+
begin, length, kdump_raw, errp);
21902218
if (*errp) {
21912219
qatomic_set(&s->status, DUMP_STATUS_FAILED);
21922220
return;
@@ -2214,15 +2242,18 @@ DumpGuestMemoryCapability *qmp_query_dump_guest_memory_capability(Error **errp)
22142242

22152243
/* kdump-zlib is always available */
22162244
QAPI_LIST_APPEND(tail, DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB);
2245+
QAPI_LIST_APPEND(tail, DUMP_GUEST_MEMORY_FORMAT_KDUMP_RAW_ZLIB);
22172246

22182247
/* add new item if kdump-lzo is available */
22192248
#ifdef CONFIG_LZO
22202249
QAPI_LIST_APPEND(tail, DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO);
2250+
QAPI_LIST_APPEND(tail, DUMP_GUEST_MEMORY_FORMAT_KDUMP_RAW_LZO);
22212251
#endif
22222252

22232253
/* add new item if kdump-snappy is available */
22242254
#ifdef CONFIG_SNAPPY
22252255
QAPI_LIST_APPEND(tail, DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY);
2256+
QAPI_LIST_APPEND(tail, DUMP_GUEST_MEMORY_FORMAT_KDUMP_RAW_SNAPPY);
22262257
#endif
22272258

22282259
if (win_dump_available(NULL)) {

hmp-commands.hx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,14 +1085,16 @@ ERST
10851085

10861086
{
10871087
.name = "dump-guest-memory",
1088-
.args_type = "paging:-p,detach:-d,windmp:-w,zlib:-z,lzo:-l,snappy:-s,filename:F,begin:l?,length:l?",
1089-
.params = "[-p] [-d] [-z|-l|-s|-w] filename [begin length]",
1088+
.args_type = "paging:-p,detach:-d,windmp:-w,zlib:-z,lzo:-l,snappy:-s,raw:-R,filename:F,begin:l?,length:l?",
1089+
.params = "[-p] [-d] [-z|-l|-s|-w] [-R] filename [begin length]",
10901090
.help = "dump guest memory into file 'filename'.\n\t\t\t"
10911091
"-p: do paging to get guest's memory mapping.\n\t\t\t"
10921092
"-d: return immediately (do not wait for completion).\n\t\t\t"
10931093
"-z: dump in kdump-compressed format, with zlib compression.\n\t\t\t"
10941094
"-l: dump in kdump-compressed format, with lzo compression.\n\t\t\t"
10951095
"-s: dump in kdump-compressed format, with snappy compression.\n\t\t\t"
1096+
"-R: when using kdump (-z, -l, -s), use raw rather than makedumpfile-flattened\n\t\t\t"
1097+
" format\n\t\t\t"
10961098
"-w: dump in Windows crashdump format (can be used instead of ELF-dump converting),\n\t\t\t"
10971099
" for Windows x86 and x64 guests with vmcoreinfo driver only.\n\t\t\t"
10981100
"begin: the starting physical address.\n\t\t\t"
@@ -1115,6 +1117,9 @@ SRST
11151117
dump in kdump-compressed format, with lzo compression.
11161118
``-s``
11171119
dump in kdump-compressed format, with snappy compression.
1120+
``-R``
1121+
when using kdump (-z, -l, -s), use raw rather than makedumpfile-flattened
1122+
format
11181123
``-w``
11191124
dump in Windows crashdump format (can be used instead of ELF-dump converting),
11201125
for Windows x64 guests with vmcoreinfo driver only

qapi/dump.json

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,35 @@
1515
#
1616
# @elf: elf format
1717
#
18-
# @kdump-zlib: kdump-compressed format with zlib-compressed
18+
# @kdump-zlib: makedumpfile flattened, kdump-compressed format with zlib
19+
# compression
1920
#
20-
# @kdump-lzo: kdump-compressed format with lzo-compressed
21+
# @kdump-lzo: makedumpfile flattened, kdump-compressed format with lzo
22+
# compression
2123
#
22-
# @kdump-snappy: kdump-compressed format with snappy-compressed
24+
# @kdump-snappy: makedumpfile flattened, kdump-compressed format with snappy
25+
# compression
26+
#
27+
# @kdump-raw-zlib: raw assembled kdump-compressed format with zlib compression
28+
# (since 8.2)
29+
#
30+
# @kdump-raw-lzo: raw assembled kdump-compressed format with lzo compression
31+
# (since 8.2)
32+
#
33+
# @kdump-raw-snappy: raw assembled kdump-compressed format with snappy
34+
# compression (since 8.2)
2335
#
2436
# @win-dmp: Windows full crashdump format, can be used instead of ELF
2537
# converting (since 2.13)
2638
#
2739
# Since: 2.0
2840
##
2941
{ 'enum': 'DumpGuestMemoryFormat',
30-
'data': [ 'elf', 'kdump-zlib', 'kdump-lzo', 'kdump-snappy', 'win-dmp' ] }
42+
'data': [
43+
'elf',
44+
'kdump-zlib', 'kdump-lzo', 'kdump-snappy',
45+
'kdump-raw-zlib', 'kdump-raw-lzo', 'kdump-raw-snappy',
46+
'win-dmp' ] }
3147

3248
##
3349
# @dump-guest-memory:

0 commit comments

Comments
 (0)