mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-24 20:19:44 +00:00
Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging
* remotes/qmp-unstable/queue/qmp: json-parser: drop superfluous assignment for token variable readline: Clear screen on form feed. monitor: Add delvm and loadvm argument completion monitor: Add host_net_remove arguments completion readline: Make completion strings always unique monitor: Add host_net_add device argument completion net: Export valid host network devices list monitor: Add migrate_set_capability completion monitor: Add watchdog_action argument completion monitor: Add ringbuf_write and ringbuf_read argument completion dump: simplify get_len_buf_out() dump: hoist lzo_init() from get_len_buf_out() to dump_init() dump: select header bitness based on ELF class, not ELF architecture dump: eliminate DumpState.page_size ("guest's page size") dump: eliminate DumpState.page_shift ("guest's page shift") dump: simplify write_start_flat_header() dump: fill in the flat header signature more pleasingly to the eye Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
05fedeef83
140
dump.c
140
dump.c
@ -90,8 +90,6 @@ typedef struct DumpState {
|
|||||||
uint8_t *note_buf; /* buffer for notes */
|
uint8_t *note_buf; /* buffer for notes */
|
||||||
size_t note_buf_offset; /* the writing place in note_buf */
|
size_t note_buf_offset; /* the writing place in note_buf */
|
||||||
uint32_t nr_cpus; /* number of guest's cpu */
|
uint32_t nr_cpus; /* number of guest's cpu */
|
||||||
size_t page_size; /* guest's page size */
|
|
||||||
uint32_t page_shift; /* guest's page shift */
|
|
||||||
uint64_t max_mapnr; /* the biggest guest's phys-mem's number */
|
uint64_t max_mapnr; /* the biggest guest's phys-mem's number */
|
||||||
size_t len_dump_bitmap; /* the size of the place used to store
|
size_t len_dump_bitmap; /* the size of the place used to store
|
||||||
dump_bitmap in vmcore */
|
dump_bitmap in vmcore */
|
||||||
@ -711,27 +709,25 @@ static int create_vmcore(DumpState *s)
|
|||||||
|
|
||||||
static int write_start_flat_header(int fd)
|
static int write_start_flat_header(int fd)
|
||||||
{
|
{
|
||||||
uint8_t *buf;
|
MakedumpfileHeader *mh;
|
||||||
MakedumpfileHeader mh;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
memset(&mh, 0, sizeof(mh));
|
QEMU_BUILD_BUG_ON(sizeof *mh > MAX_SIZE_MDF_HEADER);
|
||||||
strncpy(mh.signature, MAKEDUMPFILE_SIGNATURE,
|
mh = g_malloc0(MAX_SIZE_MDF_HEADER);
|
||||||
strlen(MAKEDUMPFILE_SIGNATURE));
|
|
||||||
|
|
||||||
mh.type = cpu_to_be64(TYPE_FLAT_HEADER);
|
memcpy(mh->signature, MAKEDUMPFILE_SIGNATURE,
|
||||||
mh.version = cpu_to_be64(VERSION_FLAT_HEADER);
|
MIN(sizeof mh->signature, sizeof MAKEDUMPFILE_SIGNATURE));
|
||||||
|
|
||||||
buf = g_malloc0(MAX_SIZE_MDF_HEADER);
|
mh->type = cpu_to_be64(TYPE_FLAT_HEADER);
|
||||||
memcpy(buf, &mh, sizeof(mh));
|
mh->version = cpu_to_be64(VERSION_FLAT_HEADER);
|
||||||
|
|
||||||
size_t written_size;
|
size_t written_size;
|
||||||
written_size = qemu_write_full(fd, buf, MAX_SIZE_MDF_HEADER);
|
written_size = qemu_write_full(fd, mh, MAX_SIZE_MDF_HEADER);
|
||||||
if (written_size != MAX_SIZE_MDF_HEADER) {
|
if (written_size != MAX_SIZE_MDF_HEADER) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(buf);
|
g_free(mh);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -808,7 +804,7 @@ static int create_header32(DumpState *s)
|
|||||||
|
|
||||||
strncpy(dh->signature, KDUMP_SIGNATURE, strlen(KDUMP_SIGNATURE));
|
strncpy(dh->signature, KDUMP_SIGNATURE, strlen(KDUMP_SIGNATURE));
|
||||||
dh->header_version = cpu_convert_to_target32(6, endian);
|
dh->header_version = cpu_convert_to_target32(6, endian);
|
||||||
block_size = s->page_size;
|
block_size = TARGET_PAGE_SIZE;
|
||||||
dh->block_size = cpu_convert_to_target32(block_size, endian);
|
dh->block_size = cpu_convert_to_target32(block_size, endian);
|
||||||
sub_hdr_size = sizeof(struct KdumpSubHeader32) + s->note_size;
|
sub_hdr_size = sizeof(struct KdumpSubHeader32) + s->note_size;
|
||||||
sub_hdr_size = DIV_ROUND_UP(sub_hdr_size, block_size);
|
sub_hdr_size = DIV_ROUND_UP(sub_hdr_size, block_size);
|
||||||
@ -915,7 +911,7 @@ static int create_header64(DumpState *s)
|
|||||||
|
|
||||||
strncpy(dh->signature, KDUMP_SIGNATURE, strlen(KDUMP_SIGNATURE));
|
strncpy(dh->signature, KDUMP_SIGNATURE, strlen(KDUMP_SIGNATURE));
|
||||||
dh->header_version = cpu_convert_to_target32(6, endian);
|
dh->header_version = cpu_convert_to_target32(6, endian);
|
||||||
block_size = s->page_size;
|
block_size = TARGET_PAGE_SIZE;
|
||||||
dh->block_size = cpu_convert_to_target32(block_size, endian);
|
dh->block_size = cpu_convert_to_target32(block_size, endian);
|
||||||
sub_hdr_size = sizeof(struct KdumpSubHeader64) + s->note_size;
|
sub_hdr_size = sizeof(struct KdumpSubHeader64) + s->note_size;
|
||||||
sub_hdr_size = DIV_ROUND_UP(sub_hdr_size, block_size);
|
sub_hdr_size = DIV_ROUND_UP(sub_hdr_size, block_size);
|
||||||
@ -1004,7 +1000,7 @@ out:
|
|||||||
|
|
||||||
static int write_dump_header(DumpState *s)
|
static int write_dump_header(DumpState *s)
|
||||||
{
|
{
|
||||||
if (s->dump_info.d_machine == EM_386) {
|
if (s->dump_info.d_class == ELFCLASS32) {
|
||||||
return create_header32(s);
|
return create_header32(s);
|
||||||
} else {
|
} else {
|
||||||
return create_header64(s);
|
return create_header64(s);
|
||||||
@ -1086,9 +1082,9 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
|
|||||||
if (!block) {
|
if (!block) {
|
||||||
block = QTAILQ_FIRST(&s->guest_phys_blocks.head);
|
block = QTAILQ_FIRST(&s->guest_phys_blocks.head);
|
||||||
*blockptr = block;
|
*blockptr = block;
|
||||||
assert(block->target_start % s->page_size == 0);
|
assert((block->target_start & ~TARGET_PAGE_MASK) == 0);
|
||||||
assert(block->target_end % s->page_size == 0);
|
assert((block->target_end & ~TARGET_PAGE_MASK) == 0);
|
||||||
*pfnptr = paddr_to_pfn(block->target_start, s->page_shift);
|
*pfnptr = paddr_to_pfn(block->target_start);
|
||||||
if (bufptr) {
|
if (bufptr) {
|
||||||
*bufptr = block->host_addr;
|
*bufptr = block->host_addr;
|
||||||
}
|
}
|
||||||
@ -1096,10 +1092,10 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
*pfnptr = *pfnptr + 1;
|
*pfnptr = *pfnptr + 1;
|
||||||
addr = pfn_to_paddr(*pfnptr, s->page_shift);
|
addr = pfn_to_paddr(*pfnptr);
|
||||||
|
|
||||||
if ((addr >= block->target_start) &&
|
if ((addr >= block->target_start) &&
|
||||||
(addr + s->page_size <= block->target_end)) {
|
(addr + TARGET_PAGE_SIZE <= block->target_end)) {
|
||||||
buf = block->host_addr + (addr - block->target_start);
|
buf = block->host_addr + (addr - block->target_start);
|
||||||
} else {
|
} else {
|
||||||
/* the next page is in the next block */
|
/* the next page is in the next block */
|
||||||
@ -1108,9 +1104,9 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
|
|||||||
if (!block) {
|
if (!block) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
assert(block->target_start % s->page_size == 0);
|
assert((block->target_start & ~TARGET_PAGE_MASK) == 0);
|
||||||
assert(block->target_end % s->page_size == 0);
|
assert((block->target_end & ~TARGET_PAGE_MASK) == 0);
|
||||||
*pfnptr = paddr_to_pfn(block->target_start, s->page_shift);
|
*pfnptr = paddr_to_pfn(block->target_start);
|
||||||
buf = block->host_addr;
|
buf = block->host_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1224,42 +1220,24 @@ static void free_data_cache(DataCache *data_cache)
|
|||||||
|
|
||||||
static size_t get_len_buf_out(size_t page_size, uint32_t flag_compress)
|
static size_t get_len_buf_out(size_t page_size, uint32_t flag_compress)
|
||||||
{
|
{
|
||||||
size_t len_buf_out_zlib, len_buf_out_lzo, len_buf_out_snappy;
|
switch (flag_compress) {
|
||||||
size_t len_buf_out;
|
case DUMP_DH_COMPRESSED_ZLIB:
|
||||||
|
return compressBound(page_size);
|
||||||
|
|
||||||
/* init buf_out */
|
case DUMP_DH_COMPRESSED_LZO:
|
||||||
len_buf_out_zlib = len_buf_out_lzo = len_buf_out_snappy = 0;
|
/*
|
||||||
|
* LZO will expand incompressible data by a little amount. Please check
|
||||||
/* buf size for zlib */
|
* the following URL to see the expansion calculation:
|
||||||
len_buf_out_zlib = compressBound(page_size);
|
* http://www.oberhumer.com/opensource/lzo/lzofaq.php
|
||||||
|
*/
|
||||||
/* buf size for lzo */
|
return page_size + page_size / 16 + 64 + 3;
|
||||||
#ifdef CONFIG_LZO
|
|
||||||
if (flag_compress & DUMP_DH_COMPRESSED_LZO) {
|
|
||||||
if (lzo_init() != LZO_E_OK) {
|
|
||||||
/* return 0 to indicate lzo is unavailable */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* LZO will expand incompressible data by a little amount. please check the
|
|
||||||
* following URL to see the expansion calculation:
|
|
||||||
* http://www.oberhumer.com/opensource/lzo/lzofaq.php
|
|
||||||
*/
|
|
||||||
len_buf_out_lzo = page_size + page_size / 16 + 64 + 3;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_SNAPPY
|
#ifdef CONFIG_SNAPPY
|
||||||
/* buf size for snappy */
|
case DUMP_DH_COMPRESSED_SNAPPY:
|
||||||
len_buf_out_snappy = snappy_max_compressed_length(page_size);
|
return snappy_max_compressed_length(page_size);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
/* get the biggest that can store all kinds of compressed page */
|
return 0;
|
||||||
len_buf_out = MAX(len_buf_out_zlib,
|
|
||||||
MAX(len_buf_out_lzo, len_buf_out_snappy));
|
|
||||||
|
|
||||||
return len_buf_out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1294,11 +1272,8 @@ static int write_dump_pages(DumpState *s)
|
|||||||
prepare_data_cache(&page_data, s, offset_data);
|
prepare_data_cache(&page_data, s, offset_data);
|
||||||
|
|
||||||
/* prepare buffer to store compressed data */
|
/* prepare buffer to store compressed data */
|
||||||
len_buf_out = get_len_buf_out(s->page_size, s->flag_compress);
|
len_buf_out = get_len_buf_out(TARGET_PAGE_SIZE, s->flag_compress);
|
||||||
if (len_buf_out == 0) {
|
assert(len_buf_out != 0);
|
||||||
dump_error(s, "dump: failed to get length of output buffer.\n");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_LZO
|
#ifdef CONFIG_LZO
|
||||||
wrkmem = g_malloc(LZO1X_1_MEM_COMPRESS);
|
wrkmem = g_malloc(LZO1X_1_MEM_COMPRESS);
|
||||||
@ -1310,19 +1285,19 @@ static int write_dump_pages(DumpState *s)
|
|||||||
* init zero page's page_desc and page_data, because every zero page
|
* init zero page's page_desc and page_data, because every zero page
|
||||||
* uses the same page_data
|
* uses the same page_data
|
||||||
*/
|
*/
|
||||||
pd_zero.size = cpu_convert_to_target32(s->page_size, endian);
|
pd_zero.size = cpu_convert_to_target32(TARGET_PAGE_SIZE, endian);
|
||||||
pd_zero.flags = cpu_convert_to_target32(0, endian);
|
pd_zero.flags = cpu_convert_to_target32(0, endian);
|
||||||
pd_zero.offset = cpu_convert_to_target64(offset_data, endian);
|
pd_zero.offset = cpu_convert_to_target64(offset_data, endian);
|
||||||
pd_zero.page_flags = cpu_convert_to_target64(0, endian);
|
pd_zero.page_flags = cpu_convert_to_target64(0, endian);
|
||||||
buf = g_malloc0(s->page_size);
|
buf = g_malloc0(TARGET_PAGE_SIZE);
|
||||||
ret = write_cache(&page_data, buf, s->page_size, false);
|
ret = write_cache(&page_data, buf, TARGET_PAGE_SIZE, false);
|
||||||
g_free(buf);
|
g_free(buf);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dump_error(s, "dump: failed to write page data(zero page).\n");
|
dump_error(s, "dump: failed to write page data(zero page).\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset_data += s->page_size;
|
offset_data += TARGET_PAGE_SIZE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* dump memory to vmcore page by page. zero page will all be resided in the
|
* dump memory to vmcore page by page. zero page will all be resided in the
|
||||||
@ -1330,7 +1305,7 @@ static int write_dump_pages(DumpState *s)
|
|||||||
*/
|
*/
|
||||||
while (get_next_page(&block_iter, &pfn_iter, &buf, s)) {
|
while (get_next_page(&block_iter, &pfn_iter, &buf, s)) {
|
||||||
/* check zero page */
|
/* check zero page */
|
||||||
if (is_zero_page(buf, s->page_size)) {
|
if (is_zero_page(buf, TARGET_PAGE_SIZE)) {
|
||||||
ret = write_cache(&page_desc, &pd_zero, sizeof(PageDescriptor),
|
ret = write_cache(&page_desc, &pd_zero, sizeof(PageDescriptor),
|
||||||
false);
|
false);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@ -1351,8 +1326,9 @@ static int write_dump_pages(DumpState *s)
|
|||||||
*/
|
*/
|
||||||
size_out = len_buf_out;
|
size_out = len_buf_out;
|
||||||
if ((s->flag_compress & DUMP_DH_COMPRESSED_ZLIB) &&
|
if ((s->flag_compress & DUMP_DH_COMPRESSED_ZLIB) &&
|
||||||
(compress2(buf_out, (uLongf *)&size_out, buf, s->page_size,
|
(compress2(buf_out, (uLongf *)&size_out, buf,
|
||||||
Z_BEST_SPEED) == Z_OK) && (size_out < s->page_size)) {
|
TARGET_PAGE_SIZE, Z_BEST_SPEED) == Z_OK) &&
|
||||||
|
(size_out < TARGET_PAGE_SIZE)) {
|
||||||
pd.flags = cpu_convert_to_target32(DUMP_DH_COMPRESSED_ZLIB,
|
pd.flags = cpu_convert_to_target32(DUMP_DH_COMPRESSED_ZLIB,
|
||||||
endian);
|
endian);
|
||||||
pd.size = cpu_convert_to_target32(size_out, endian);
|
pd.size = cpu_convert_to_target32(size_out, endian);
|
||||||
@ -1364,9 +1340,9 @@ static int write_dump_pages(DumpState *s)
|
|||||||
}
|
}
|
||||||
#ifdef CONFIG_LZO
|
#ifdef CONFIG_LZO
|
||||||
} else if ((s->flag_compress & DUMP_DH_COMPRESSED_LZO) &&
|
} else if ((s->flag_compress & DUMP_DH_COMPRESSED_LZO) &&
|
||||||
(lzo1x_1_compress(buf, s->page_size, buf_out,
|
(lzo1x_1_compress(buf, TARGET_PAGE_SIZE, buf_out,
|
||||||
(lzo_uint *)&size_out, wrkmem) == LZO_E_OK) &&
|
(lzo_uint *)&size_out, wrkmem) == LZO_E_OK) &&
|
||||||
(size_out < s->page_size)) {
|
(size_out < TARGET_PAGE_SIZE)) {
|
||||||
pd.flags = cpu_convert_to_target32(DUMP_DH_COMPRESSED_LZO,
|
pd.flags = cpu_convert_to_target32(DUMP_DH_COMPRESSED_LZO,
|
||||||
endian);
|
endian);
|
||||||
pd.size = cpu_convert_to_target32(size_out, endian);
|
pd.size = cpu_convert_to_target32(size_out, endian);
|
||||||
@ -1379,9 +1355,9 @@ static int write_dump_pages(DumpState *s)
|
|||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_SNAPPY
|
#ifdef CONFIG_SNAPPY
|
||||||
} else if ((s->flag_compress & DUMP_DH_COMPRESSED_SNAPPY) &&
|
} else if ((s->flag_compress & DUMP_DH_COMPRESSED_SNAPPY) &&
|
||||||
(snappy_compress((char *)buf, s->page_size,
|
(snappy_compress((char *)buf, TARGET_PAGE_SIZE,
|
||||||
(char *)buf_out, &size_out) == SNAPPY_OK) &&
|
(char *)buf_out, &size_out) == SNAPPY_OK) &&
|
||||||
(size_out < s->page_size)) {
|
(size_out < TARGET_PAGE_SIZE)) {
|
||||||
pd.flags = cpu_convert_to_target32(
|
pd.flags = cpu_convert_to_target32(
|
||||||
DUMP_DH_COMPRESSED_SNAPPY, endian);
|
DUMP_DH_COMPRESSED_SNAPPY, endian);
|
||||||
pd.size = cpu_convert_to_target32(size_out, endian);
|
pd.size = cpu_convert_to_target32(size_out, endian);
|
||||||
@ -1395,13 +1371,13 @@ static int write_dump_pages(DumpState *s)
|
|||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* fall back to save in plaintext, size_out should be
|
* fall back to save in plaintext, size_out should be
|
||||||
* assigned to s->page_size
|
* assigned TARGET_PAGE_SIZE
|
||||||
*/
|
*/
|
||||||
pd.flags = cpu_convert_to_target32(0, endian);
|
pd.flags = cpu_convert_to_target32(0, endian);
|
||||||
size_out = s->page_size;
|
size_out = TARGET_PAGE_SIZE;
|
||||||
pd.size = cpu_convert_to_target32(size_out, endian);
|
pd.size = cpu_convert_to_target32(size_out, endian);
|
||||||
|
|
||||||
ret = write_cache(&page_data, buf, s->page_size, false);
|
ret = write_cache(&page_data, buf, TARGET_PAGE_SIZE, false);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dump_error(s, "dump: failed to write page data.\n");
|
dump_error(s, "dump: failed to write page data.\n");
|
||||||
goto out;
|
goto out;
|
||||||
@ -1536,7 +1512,7 @@ static void get_max_mapnr(DumpState *s)
|
|||||||
GuestPhysBlock *last_block;
|
GuestPhysBlock *last_block;
|
||||||
|
|
||||||
last_block = QTAILQ_LAST(&s->guest_phys_blocks.head, GuestPhysBlockHead);
|
last_block = QTAILQ_LAST(&s->guest_phys_blocks.head, GuestPhysBlockHead);
|
||||||
s->max_mapnr = paddr_to_pfn(last_block->target_end, s->page_shift);
|
s->max_mapnr = paddr_to_pfn(last_block->target_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dump_init(DumpState *s, int fd, bool has_format,
|
static int dump_init(DumpState *s, int fd, bool has_format,
|
||||||
@ -1613,14 +1589,12 @@ static int dump_init(DumpState *s, int fd, bool has_format,
|
|||||||
}
|
}
|
||||||
|
|
||||||
s->nr_cpus = nr_cpus;
|
s->nr_cpus = nr_cpus;
|
||||||
s->page_size = TARGET_PAGE_SIZE;
|
|
||||||
s->page_shift = ffs(s->page_size) - 1;
|
|
||||||
|
|
||||||
get_max_mapnr(s);
|
get_max_mapnr(s);
|
||||||
|
|
||||||
uint64_t tmp;
|
uint64_t tmp;
|
||||||
tmp = DIV_ROUND_UP(DIV_ROUND_UP(s->max_mapnr, CHAR_BIT), s->page_size);
|
tmp = DIV_ROUND_UP(DIV_ROUND_UP(s->max_mapnr, CHAR_BIT), TARGET_PAGE_SIZE);
|
||||||
s->len_dump_bitmap = tmp * s->page_size;
|
s->len_dump_bitmap = tmp * TARGET_PAGE_SIZE;
|
||||||
|
|
||||||
/* init for kdump-compressed format */
|
/* init for kdump-compressed format */
|
||||||
if (has_format && format != DUMP_GUEST_MEMORY_FORMAT_ELF) {
|
if (has_format && format != DUMP_GUEST_MEMORY_FORMAT_ELF) {
|
||||||
@ -1630,6 +1604,12 @@ static int dump_init(DumpState *s, int fd, bool has_format,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO:
|
case DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO:
|
||||||
|
#ifdef CONFIG_LZO
|
||||||
|
if (lzo_init() != LZO_E_OK) {
|
||||||
|
error_setg(errp, "failed to initialize the LZO library");
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
s->flag_compress = DUMP_DH_COMPRESSED_LZO;
|
s->flag_compress = DUMP_DH_COMPRESSED_LZO;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -335,6 +335,7 @@ ETEXI
|
|||||||
.params = "tag|id",
|
.params = "tag|id",
|
||||||
.help = "restore a VM snapshot from its tag or id",
|
.help = "restore a VM snapshot from its tag or id",
|
||||||
.mhandler.cmd = do_loadvm,
|
.mhandler.cmd = do_loadvm,
|
||||||
|
.command_completion = loadvm_completion,
|
||||||
},
|
},
|
||||||
|
|
||||||
STEXI
|
STEXI
|
||||||
@ -350,6 +351,7 @@ ETEXI
|
|||||||
.params = "tag|id",
|
.params = "tag|id",
|
||||||
.help = "delete a VM snapshot from its tag or id",
|
.help = "delete a VM snapshot from its tag or id",
|
||||||
.mhandler.cmd = do_delvm,
|
.mhandler.cmd = do_delvm,
|
||||||
|
.command_completion = delvm_completion,
|
||||||
},
|
},
|
||||||
|
|
||||||
STEXI
|
STEXI
|
||||||
@ -852,6 +854,7 @@ ETEXI
|
|||||||
.params = "device data",
|
.params = "device data",
|
||||||
.help = "Write to a ring buffer character device",
|
.help = "Write to a ring buffer character device",
|
||||||
.mhandler.cmd = hmp_ringbuf_write,
|
.mhandler.cmd = hmp_ringbuf_write,
|
||||||
|
.command_completion = ringbuf_write_completion,
|
||||||
},
|
},
|
||||||
|
|
||||||
STEXI
|
STEXI
|
||||||
@ -868,6 +871,7 @@ ETEXI
|
|||||||
.params = "device size",
|
.params = "device size",
|
||||||
.help = "Read from a ring buffer character device",
|
.help = "Read from a ring buffer character device",
|
||||||
.mhandler.cmd = hmp_ringbuf_read,
|
.mhandler.cmd = hmp_ringbuf_read,
|
||||||
|
.command_completion = ringbuf_write_completion,
|
||||||
},
|
},
|
||||||
|
|
||||||
STEXI
|
STEXI
|
||||||
@ -973,6 +977,7 @@ ETEXI
|
|||||||
.params = "capability state",
|
.params = "capability state",
|
||||||
.help = "Enable/Disable the usage of a capability for migration",
|
.help = "Enable/Disable the usage of a capability for migration",
|
||||||
.mhandler.cmd = hmp_migrate_set_capability,
|
.mhandler.cmd = hmp_migrate_set_capability,
|
||||||
|
.command_completion = migrate_set_capability_completion,
|
||||||
},
|
},
|
||||||
|
|
||||||
STEXI
|
STEXI
|
||||||
@ -1206,9 +1211,10 @@ ETEXI
|
|||||||
{
|
{
|
||||||
.name = "host_net_add",
|
.name = "host_net_add",
|
||||||
.args_type = "device:s,opts:s?",
|
.args_type = "device:s,opts:s?",
|
||||||
.params = "tap|user|socket|vde|netmap|dump [options]",
|
.params = "tap|user|socket|vde|netmap|bridge|dump [options]",
|
||||||
.help = "add host VLAN client",
|
.help = "add host VLAN client",
|
||||||
.mhandler.cmd = net_host_device_add,
|
.mhandler.cmd = net_host_device_add,
|
||||||
|
.command_completion = host_net_add_completion,
|
||||||
},
|
},
|
||||||
|
|
||||||
STEXI
|
STEXI
|
||||||
@ -1223,6 +1229,7 @@ ETEXI
|
|||||||
.params = "vlan_id name",
|
.params = "vlan_id name",
|
||||||
.help = "remove host VLAN client",
|
.help = "remove host VLAN client",
|
||||||
.mhandler.cmd = net_host_device_remove,
|
.mhandler.cmd = net_host_device_remove,
|
||||||
|
.command_completion = host_net_remove_completion,
|
||||||
},
|
},
|
||||||
|
|
||||||
STEXI
|
STEXI
|
||||||
@ -1357,6 +1364,7 @@ ETEXI
|
|||||||
.params = "[reset|shutdown|poweroff|pause|debug|none]",
|
.params = "[reset|shutdown|poweroff|pause|debug|none]",
|
||||||
.help = "change watchdog action",
|
.help = "change watchdog action",
|
||||||
.mhandler.cmd = do_watchdog_action,
|
.mhandler.cmd = do_watchdog_action,
|
||||||
|
.command_completion = watchdog_action_completion,
|
||||||
},
|
},
|
||||||
|
|
||||||
STEXI
|
STEXI
|
||||||
|
11
hmp.h
11
hmp.h
@ -103,5 +103,16 @@ void chardev_add_completion(ReadLineState *rs, int nb_args, const char *str);
|
|||||||
void set_link_completion(ReadLineState *rs, int nb_args, const char *str);
|
void set_link_completion(ReadLineState *rs, int nb_args, const char *str);
|
||||||
void netdev_add_completion(ReadLineState *rs, int nb_args, const char *str);
|
void netdev_add_completion(ReadLineState *rs, int nb_args, const char *str);
|
||||||
void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str);
|
void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str);
|
||||||
|
void ringbuf_write_completion(ReadLineState *rs, int nb_args, const char *str);
|
||||||
|
void ringbuf_read_completion(ReadLineState *rs, int nb_args, const char *str);
|
||||||
|
void watchdog_action_completion(ReadLineState *rs, int nb_args,
|
||||||
|
const char *str);
|
||||||
|
void migrate_set_capability_completion(ReadLineState *rs, int nb_args,
|
||||||
|
const char *str);
|
||||||
|
void host_net_add_completion(ReadLineState *rs, int nb_args, const char *str);
|
||||||
|
void host_net_remove_completion(ReadLineState *rs, int nb_args,
|
||||||
|
const char *str);
|
||||||
|
void delvm_completion(ReadLineState *rs, int nb_args, const char *str);
|
||||||
|
void loadvm_completion(ReadLineState *rs, int nb_args, const char *str);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -177,6 +177,7 @@ struct NICInfo {
|
|||||||
extern int nb_nics;
|
extern int nb_nics;
|
||||||
extern NICInfo nd_table[MAX_NICS];
|
extern NICInfo nd_table[MAX_NICS];
|
||||||
extern int default_net;
|
extern int default_net;
|
||||||
|
extern const char *host_net_devices[];
|
||||||
|
|
||||||
/* from net.c */
|
/* from net.c */
|
||||||
extern const char *legacy_tftp_prefix;
|
extern const char *legacy_tftp_prefix;
|
||||||
|
@ -286,9 +286,8 @@ void qemu_chr_add_handlers(CharDriverState *s,
|
|||||||
void qemu_chr_be_generic_open(CharDriverState *s);
|
void qemu_chr_be_generic_open(CharDriverState *s);
|
||||||
void qemu_chr_accept_input(CharDriverState *s);
|
void qemu_chr_accept_input(CharDriverState *s);
|
||||||
int qemu_chr_add_client(CharDriverState *s, int fd);
|
int qemu_chr_add_client(CharDriverState *s, int fd);
|
||||||
void qemu_chr_info_print(Monitor *mon, const QObject *ret_data);
|
|
||||||
void qemu_chr_info(Monitor *mon, QObject **ret_data);
|
|
||||||
CharDriverState *qemu_chr_find(const char *name);
|
CharDriverState *qemu_chr_find(const char *name);
|
||||||
|
bool chr_is_ringbuf(const CharDriverState *chr);
|
||||||
|
|
||||||
QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename);
|
QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename);
|
||||||
|
|
||||||
|
@ -22,10 +22,10 @@
|
|||||||
|
|
||||||
#define ARCH_PFN_OFFSET (0)
|
#define ARCH_PFN_OFFSET (0)
|
||||||
|
|
||||||
#define paddr_to_pfn(X, page_shift) \
|
#define paddr_to_pfn(X) \
|
||||||
(((unsigned long long)(X) >> (page_shift)) - ARCH_PFN_OFFSET)
|
(((unsigned long long)(X) >> TARGET_PAGE_BITS) - ARCH_PFN_OFFSET)
|
||||||
#define pfn_to_paddr(X, page_shift) \
|
#define pfn_to_paddr(X) \
|
||||||
(((unsigned long long)(X) + ARCH_PFN_OFFSET) << (page_shift))
|
(((unsigned long long)(X) + ARCH_PFN_OFFSET) << TARGET_PAGE_BITS)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* flag for compressed format
|
* flag for compressed format
|
||||||
|
176
monitor.c
176
monitor.c
@ -70,6 +70,7 @@
|
|||||||
#include "qmp-commands.h"
|
#include "qmp-commands.h"
|
||||||
#include "hmp.h"
|
#include "hmp.h"
|
||||||
#include "qemu/thread.h"
|
#include "qemu/thread.h"
|
||||||
|
#include "block/qapi.h"
|
||||||
|
|
||||||
/* for pic/irq_info */
|
/* for pic/irq_info */
|
||||||
#if defined(TARGET_SPARC)
|
#if defined(TARGET_SPARC)
|
||||||
@ -4412,6 +4413,45 @@ void chardev_remove_completion(ReadLineState *rs, int nb_args, const char *str)
|
|||||||
qapi_free_ChardevInfoList(start);
|
qapi_free_ChardevInfoList(start);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ringbuf_completion(ReadLineState *rs, const char *str)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
ChardevInfoList *list, *start;
|
||||||
|
|
||||||
|
len = strlen(str);
|
||||||
|
readline_set_completion_index(rs, len);
|
||||||
|
|
||||||
|
start = list = qmp_query_chardev(NULL);
|
||||||
|
while (list) {
|
||||||
|
ChardevInfo *chr_info = list->value;
|
||||||
|
|
||||||
|
if (!strncmp(chr_info->label, str, len)) {
|
||||||
|
CharDriverState *chr = qemu_chr_find(chr_info->label);
|
||||||
|
if (chr && chr_is_ringbuf(chr)) {
|
||||||
|
readline_add_completion(rs, chr_info->label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
list = list->next;
|
||||||
|
}
|
||||||
|
qapi_free_ChardevInfoList(start);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ringbuf_read_completion(ReadLineState *rs, int nb_args, const char *str)
|
||||||
|
{
|
||||||
|
if (nb_args != 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ringbuf_completion(rs, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ringbuf_write_completion(ReadLineState *rs, int nb_args, const char *str)
|
||||||
|
{
|
||||||
|
if (nb_args != 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ringbuf_completion(rs, str);
|
||||||
|
}
|
||||||
|
|
||||||
void device_del_completion(ReadLineState *rs, int nb_args, const char *str)
|
void device_del_completion(ReadLineState *rs, int nb_args, const char *str)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
@ -4520,6 +4560,142 @@ void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void watchdog_action_completion(ReadLineState *rs, int nb_args, const char *str)
|
||||||
|
{
|
||||||
|
if (nb_args != 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
readline_set_completion_index(rs, strlen(str));
|
||||||
|
add_completion_option(rs, str, "reset");
|
||||||
|
add_completion_option(rs, str, "shutdown");
|
||||||
|
add_completion_option(rs, str, "poweroff");
|
||||||
|
add_completion_option(rs, str, "pause");
|
||||||
|
add_completion_option(rs, str, "debug");
|
||||||
|
add_completion_option(rs, str, "none");
|
||||||
|
}
|
||||||
|
|
||||||
|
void migrate_set_capability_completion(ReadLineState *rs, int nb_args,
|
||||||
|
const char *str)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
len = strlen(str);
|
||||||
|
readline_set_completion_index(rs, len);
|
||||||
|
if (nb_args == 2) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < MIGRATION_CAPABILITY_MAX; i++) {
|
||||||
|
const char *name = MigrationCapability_lookup[i];
|
||||||
|
if (!strncmp(str, name, len)) {
|
||||||
|
readline_add_completion(rs, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (nb_args == 3) {
|
||||||
|
add_completion_option(rs, str, "on");
|
||||||
|
add_completion_option(rs, str, "off");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void host_net_add_completion(ReadLineState *rs, int nb_args, const char *str)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
size_t len;
|
||||||
|
if (nb_args != 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
len = strlen(str);
|
||||||
|
readline_set_completion_index(rs, len);
|
||||||
|
for (i = 0; host_net_devices[i]; i++) {
|
||||||
|
if (!strncmp(host_net_devices[i], str, len)) {
|
||||||
|
readline_add_completion(rs, host_net_devices[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void host_net_remove_completion(ReadLineState *rs, int nb_args, const char *str)
|
||||||
|
{
|
||||||
|
NetClientState *ncs[255];
|
||||||
|
int count, i, len;
|
||||||
|
|
||||||
|
len = strlen(str);
|
||||||
|
readline_set_completion_index(rs, len);
|
||||||
|
if (nb_args == 2) {
|
||||||
|
count = qemu_find_net_clients_except(NULL, ncs,
|
||||||
|
NET_CLIENT_OPTIONS_KIND_NONE, 255);
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
int id;
|
||||||
|
char name[16];
|
||||||
|
|
||||||
|
if (net_hub_id_for_client(ncs[i], &id)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
snprintf(name, sizeof(name), "%d", id);
|
||||||
|
if (!strncmp(str, name, len)) {
|
||||||
|
readline_add_completion(rs, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
} else if (nb_args == 3) {
|
||||||
|
count = qemu_find_net_clients_except(NULL, ncs,
|
||||||
|
NET_CLIENT_OPTIONS_KIND_NIC, 255);
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
const char *name;
|
||||||
|
|
||||||
|
name = ncs[i]->name;
|
||||||
|
if (!strncmp(str, name, len)) {
|
||||||
|
readline_add_completion(rs, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vm_completion(ReadLineState *rs, const char *str)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
BlockDriverState *bs = NULL;
|
||||||
|
|
||||||
|
len = strlen(str);
|
||||||
|
readline_set_completion_index(rs, len);
|
||||||
|
while ((bs = bdrv_next(bs))) {
|
||||||
|
SnapshotInfoList *snapshots, *snapshot;
|
||||||
|
|
||||||
|
if (!bdrv_can_snapshot(bs)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (bdrv_query_snapshot_info_list(bs, &snapshots, NULL)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
snapshot = snapshots;
|
||||||
|
while (snapshot) {
|
||||||
|
char *completion = snapshot->value->name;
|
||||||
|
if (!strncmp(str, completion, len)) {
|
||||||
|
readline_add_completion(rs, completion);
|
||||||
|
}
|
||||||
|
completion = snapshot->value->id;
|
||||||
|
if (!strncmp(str, completion, len)) {
|
||||||
|
readline_add_completion(rs, completion);
|
||||||
|
}
|
||||||
|
snapshot = snapshot->next;
|
||||||
|
}
|
||||||
|
qapi_free_SnapshotInfoList(snapshots);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void delvm_completion(ReadLineState *rs, int nb_args, const char *str)
|
||||||
|
{
|
||||||
|
if (nb_args == 2) {
|
||||||
|
vm_completion(rs, str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadvm_completion(ReadLineState *rs, int nb_args, const char *str)
|
||||||
|
{
|
||||||
|
if (nb_args == 2) {
|
||||||
|
vm_completion(rs, str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void monitor_find_completion_by_table(Monitor *mon,
|
static void monitor_find_completion_by_table(Monitor *mon,
|
||||||
const mon_cmd_t *cmd_table,
|
const mon_cmd_t *cmd_table,
|
||||||
char **args,
|
char **args,
|
||||||
|
34
net/net.c
34
net/net.c
@ -49,6 +49,22 @@
|
|||||||
|
|
||||||
static QTAILQ_HEAD(, NetClientState) net_clients;
|
static QTAILQ_HEAD(, NetClientState) net_clients;
|
||||||
|
|
||||||
|
const char *host_net_devices[] = {
|
||||||
|
"tap",
|
||||||
|
"socket",
|
||||||
|
"dump",
|
||||||
|
#ifdef CONFIG_NET_BRIDGE
|
||||||
|
"bridge",
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_SLIRP
|
||||||
|
"user",
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_VDE
|
||||||
|
"vde",
|
||||||
|
#endif
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
int default_net = 1;
|
int default_net = 1;
|
||||||
|
|
||||||
/***********************************************************/
|
/***********************************************************/
|
||||||
@ -897,21 +913,11 @@ int net_client_init(QemuOpts *opts, int is_netdev, Error **errp)
|
|||||||
static int net_host_check_device(const char *device)
|
static int net_host_check_device(const char *device)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
const char *valid_param_list[] = { "tap", "socket", "dump"
|
for (i = 0; host_net_devices[i]; i++) {
|
||||||
#ifdef CONFIG_NET_BRIDGE
|
if (!strncmp(host_net_devices[i], device,
|
||||||
, "bridge"
|
strlen(host_net_devices[i]))) {
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_SLIRP
|
|
||||||
,"user"
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_VDE
|
|
||||||
,"vde"
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
for (i = 0; i < ARRAY_SIZE(valid_param_list); i++) {
|
|
||||||
if (!strncmp(valid_param_list[i], device,
|
|
||||||
strlen(valid_param_list[i])))
|
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2849,7 +2849,7 @@ fail:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool chr_is_ringbuf(const CharDriverState *chr)
|
bool chr_is_ringbuf(const CharDriverState *chr)
|
||||||
{
|
{
|
||||||
return chr->chr_write == ringbuf_chr_write;
|
return chr->chr_write == ringbuf_chr_write;
|
||||||
}
|
}
|
||||||
|
@ -423,7 +423,6 @@ static QObject *parse_object(JSONParserContext *ctxt, va_list *ap)
|
|||||||
if (!token_is_operator(token, '{')) {
|
if (!token_is_operator(token, '{')) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
token = NULL;
|
|
||||||
|
|
||||||
dict = qdict_new();
|
dict = qdict_new();
|
||||||
|
|
||||||
@ -449,7 +448,6 @@ static QObject *parse_object(JSONParserContext *ctxt, va_list *ap)
|
|||||||
parse_error(ctxt, token, "expected separator in dict");
|
parse_error(ctxt, token, "expected separator in dict");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
token = NULL;
|
|
||||||
|
|
||||||
if (parse_pair(ctxt, dict, ap) == -1) {
|
if (parse_pair(ctxt, dict, ap) == -1) {
|
||||||
goto out;
|
goto out;
|
||||||
@ -461,10 +459,8 @@ static QObject *parse_object(JSONParserContext *ctxt, va_list *ap)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
token = NULL;
|
|
||||||
} else {
|
} else {
|
||||||
token = parser_context_pop_token(ctxt);
|
(void)parser_context_pop_token(ctxt);
|
||||||
token = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return QOBJECT(dict);
|
return QOBJECT(dict);
|
||||||
@ -487,10 +483,8 @@ static QObject *parse_array(JSONParserContext *ctxt, va_list *ap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!token_is_operator(token, '[')) {
|
if (!token_is_operator(token, '[')) {
|
||||||
token = NULL;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
token = NULL;
|
|
||||||
|
|
||||||
list = qlist_new();
|
list = qlist_new();
|
||||||
|
|
||||||
@ -523,8 +517,6 @@ static QObject *parse_array(JSONParserContext *ctxt, va_list *ap)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
token = NULL;
|
|
||||||
|
|
||||||
obj = parse_value(ctxt, ap);
|
obj = parse_value(ctxt, ap);
|
||||||
if (obj == NULL) {
|
if (obj == NULL) {
|
||||||
parse_error(ctxt, token, "expecting value");
|
parse_error(ctxt, token, "expecting value");
|
||||||
@ -539,11 +531,8 @@ static QObject *parse_array(JSONParserContext *ctxt, va_list *ap)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
token = NULL;
|
|
||||||
} else {
|
} else {
|
||||||
token = parser_context_pop_token(ctxt);
|
(void)parser_context_pop_token(ctxt);
|
||||||
token = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return QOBJECT(list);
|
return QOBJECT(list);
|
||||||
|
@ -263,6 +263,12 @@ static void readline_hist_add(ReadLineState *rs, const char *cmdline)
|
|||||||
void readline_add_completion(ReadLineState *rs, const char *str)
|
void readline_add_completion(ReadLineState *rs, const char *str)
|
||||||
{
|
{
|
||||||
if (rs->nb_completions < READLINE_MAX_COMPLETIONS) {
|
if (rs->nb_completions < READLINE_MAX_COMPLETIONS) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < rs->nb_completions; i++) {
|
||||||
|
if (!strcmp(rs->completions[i], str)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
rs->completions[rs->nb_completions++] = g_strdup(str);
|
rs->completions[rs->nb_completions++] = g_strdup(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -345,6 +351,12 @@ static void readline_completion(ReadLineState *rs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void readline_clear_screen(ReadLineState *rs)
|
||||||
|
{
|
||||||
|
rs->printf_func(rs->opaque, "\033[2J\033[1;1H");
|
||||||
|
readline_show_prompt(rs);
|
||||||
|
}
|
||||||
|
|
||||||
/* return true if command handled */
|
/* return true if command handled */
|
||||||
void readline_handle_byte(ReadLineState *rs, int ch)
|
void readline_handle_byte(ReadLineState *rs, int ch)
|
||||||
{
|
{
|
||||||
@ -363,6 +375,9 @@ void readline_handle_byte(ReadLineState *rs, int ch)
|
|||||||
case 9:
|
case 9:
|
||||||
readline_completion(rs);
|
readline_completion(rs);
|
||||||
break;
|
break;
|
||||||
|
case 12:
|
||||||
|
readline_clear_screen(rs);
|
||||||
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
case 13:
|
case 13:
|
||||||
rs->cmd_buf[rs->cmd_buf_size] = '\0';
|
rs->cmd_buf[rs->cmd_buf_size] = '\0';
|
||||||
|
Loading…
Reference in New Issue
Block a user