From 22227f121bddb038a0335cf83a3c24f451e2e836 Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Tue, 20 May 2014 13:39:43 +0200 Subject: dump: eliminate DumpState.page_shift ("guest's page shift") Just use TARGET_PAGE_BITS. "DumpState.page_shift" used to have type "uint32_t", while the replacement TARGET_PAGE_BITS has type "int". Since "DumpState.page_shift" was only used as bit shift counts in the paddr_to_pfn() and pfn_to_paddr() macros, this is safe. Suggested-by: Paolo Bonzini Signed-off-by: Laszlo Ersek Reviewed-by: Paolo Bonzini Signed-off-by: Luiz Capitulino --- include/sysemu/dump.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h index efab7a32f3..12af557b55 100644 --- a/include/sysemu/dump.h +++ b/include/sysemu/dump.h @@ -22,10 +22,10 @@ #define ARCH_PFN_OFFSET (0) -#define paddr_to_pfn(X, page_shift) \ - (((unsigned long long)(X) >> (page_shift)) - ARCH_PFN_OFFSET) -#define pfn_to_paddr(X, page_shift) \ - (((unsigned long long)(X) + ARCH_PFN_OFFSET) << (page_shift)) +#define paddr_to_pfn(X) \ + (((unsigned long long)(X) >> TARGET_PAGE_BITS) - ARCH_PFN_OFFSET) +#define pfn_to_paddr(X) \ + (((unsigned long long)(X) + ARCH_PFN_OFFSET) << TARGET_PAGE_BITS) /* * flag for compressed format -- cgit v1.2.3-55-g7522 From 8e5977797d76e33856506c9a0c454ae9ab23034c Mon Sep 17 00:00:00 2001 From: Hani Benhabiles Date: Tue, 27 May 2014 23:39:30 +0100 Subject: monitor: Add ringbuf_write and ringbuf_read argument completion Export chr_is_ringbuf() function. Also remove left-over function prototypes while at it. Signed-off-by: Hani Benhabiles Signed-off-by: Luiz Capitulino --- hmp-commands.hx | 2 ++ hmp.h | 2 ++ include/sysemu/char.h | 3 +-- monitor.c | 39 +++++++++++++++++++++++++++++++++++++++ qemu-char.c | 2 +- 5 files changed, 45 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/hmp-commands.hx b/hmp-commands.hx index 2e462c04aa..dcec5efab7 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -852,6 +852,7 @@ ETEXI .params = "device data", .help = "Write to a ring buffer character device", .mhandler.cmd = hmp_ringbuf_write, + .command_completion = ringbuf_write_completion, }, STEXI @@ -868,6 +869,7 @@ ETEXI .params = "device size", .help = "Read from a ring buffer character device", .mhandler.cmd = hmp_ringbuf_read, + .command_completion = ringbuf_write_completion, }, STEXI diff --git a/hmp.h b/hmp.h index aba59e95f0..212e5d2ae6 100644 --- a/hmp.h +++ b/hmp.h @@ -103,5 +103,7 @@ 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 netdev_add_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); #endif diff --git a/include/sysemu/char.h b/include/sysemu/char.h index b81a6ff185..7f5eeb38b0 100644 --- a/include/sysemu/char.h +++ b/include/sysemu/char.h @@ -286,9 +286,8 @@ void qemu_chr_add_handlers(CharDriverState *s, void qemu_chr_be_generic_open(CharDriverState *s); void qemu_chr_accept_input(CharDriverState *s); 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); +bool chr_is_ringbuf(const CharDriverState *chr); QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename); diff --git a/monitor.c b/monitor.c index 0565816910..e539e40b83 100644 --- a/monitor.c +++ b/monitor.c @@ -4412,6 +4412,45 @@ void chardev_remove_completion(ReadLineState *rs, int nb_args, const char *str) 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) { size_t len; diff --git a/qemu-char.c b/qemu-char.c index 17b476edf0..4c04bbc24e 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2849,7 +2849,7 @@ fail: return NULL; } -static bool chr_is_ringbuf(const CharDriverState *chr) +bool chr_is_ringbuf(const CharDriverState *chr) { return chr->chr_write == ringbuf_chr_write; } -- cgit v1.2.3-55-g7522 From 84007e81814bd1b523eb36b027ef8a84d7f00206 Mon Sep 17 00:00:00 2001 From: Hani Benhabiles Date: Tue, 27 May 2014 23:39:33 +0100 Subject: net: Export valid host network devices list Signed-off-by: Hani Benhabiles Reviewed-by: Stefan Hajnoczi Signed-off-by: Luiz Capitulino --- include/net/net.h | 1 + net/net.c | 34 ++++++++++++++++++++-------------- 2 files changed, 21 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/net/net.h b/include/net/net.h index 8166345a13..8b189da5ee 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -177,6 +177,7 @@ struct NICInfo { extern int nb_nics; extern NICInfo nd_table[MAX_NICS]; extern int default_net; +extern const char *host_net_devices[]; /* from net.c */ extern const char *legacy_tftp_prefix; diff --git a/net/net.c b/net/net.c index 0ff2e40f35..6344160403 100644 --- a/net/net.c +++ b/net/net.c @@ -49,6 +49,22 @@ 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; /***********************************************************/ @@ -897,21 +913,11 @@ int net_client_init(QemuOpts *opts, int is_netdev, Error **errp) static int net_host_check_device(const char *device) { int i; - const char *valid_param_list[] = { "tap", "socket", "dump" -#ifdef CONFIG_NET_BRIDGE - , "bridge" -#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]))) + for (i = 0; host_net_devices[i]; i++) { + if (!strncmp(host_net_devices[i], device, + strlen(host_net_devices[i]))) { return 1; + } } return 0; -- cgit v1.2.3-55-g7522