Add chardev-send-break monitor command
PATCH v2 1/1 Add chardev-send-break monitor command
Sending a break on a serial console can be useful for debugging the guest. But not all chardev backends support sending breaks (only telnet and mux do). The chardev-send-break command allows to send a break even if using other backends.
---
v2: added tests and Acked-by line
chardev/char.c | 12 ++++++++++++ hmp-commands.hx | 16 ++++++++++++++++ hmp.c | 8 ++++++++ hmp.h | 1 + qapi-schema.json | 20 ++++++++++++++++++++ tests/test-char.c | 12 ++++++++++-- tests/test-hmp.c | 1 + 7 files changed, 68 insertions(+), 2 deletions(-)
chardev/char.c +12 -0
@@ -951,6 +951,18 @@ void qmp_chardev_remove(const char *id, Error **errp)object_unparent (OBJECT (chr)); } +void qmp_chardev_send_break (const char *id,Error **errp) +{ +Chardev *chr; + + chr =qemu_chr_find (id); +if (chr ==NULL ) { +error_setg (errp,"Chardev '%s' not found" , id); +return ; + } +qemu_chr_be_event (chr,CHR_EVENT_BREAK ); +} +void qemu_chr_cleanup (void ) {object_unparent (get_chardevs_root ());
hmp-commands.hx +16 -0
@@ -1745,6 +1745,22 @@ Removes the chardev @var{id}. ETEXI { + .name = "chardev-send-break", + .args_type = "id:s", + .params = "id", + .help = "send break on chardev", + .cmd = hmp_chardev_send_break, + .command_completion = chardev_remove_completion, + }, + +STEXI +@item chardev-send-break id +@findex chardev-send-break +Sends break on the chardev @var{id}. + +ETEXI + + { .name = "qemu-io", .args_type = "device:B,command:s", .params = "[device] \"[command]\"",
hmp.c +8 -0
@@ -2233,6 +2233,14 @@ void hmp_chardev_remove(Monitor *mon, const QDict *qdict)hmp_handle_error (mon, &local_err); } +void hmp_chardev_send_break (Monitor *mon,const QDict *qdict) +{ +Error *local_err =NULL ; + +qmp_chardev_send_break (qdict_get_str (qdict,"id" ), &local_err); +hmp_handle_error (mon, &local_err); +} +void hmp_qemu_io (Monitor *mon,const QDict *qdict) {BlockBackend *blk;
hmp.h +1 -0
@@ -103,6 +103,7 @@ void hmp_nbd_server_add(Monitor *mon, const QDict *qdict);void hmp_nbd_server_stop (Monitor *mon,const QDict *qdict);void hmp_chardev_add (Monitor *mon,const QDict *qdict);void hmp_chardev_remove (Monitor *mon,const QDict *qdict); +void hmp_chardev_send_break (Monitor *mon,const QDict *qdict);void hmp_qemu_io (Monitor *mon,const QDict *qdict);void hmp_cpu_add (Monitor *mon,const QDict *qdict);void hmp_object_add (Monitor *mon,const QDict *qdict);
qapi-schema.json +20 -0
@@ -5114,6 +5114,26 @@ { 'command': 'chardev-remove', 'data': {'id': 'str'} } ## +# @chardev-send-break: +# +# Send a break to a character device +# +# @id: the chardev's ID, must exist +# +# Returns: Nothing on success +# +# Since: 2.10 +# +# Example: +# +# -> { "execute": "chardev-send-break", "arguments": { "id" : "foo" } } +# <- { "return": {} } +# +## +{ 'command': 'chardev-send-break', 'data': {'id': 'str'} } + + +## # @TpmModel: # # An enumeration of TPM models
tests/test-char.c +10 -2
@@ -53,7 +53,9 @@ static void fe_event(void *opaque, int event)FeHandler *h = opaque; h->last_event = event; - quit = true; +if (event !=CHR_EVENT_BREAK ) { + quit = true; + } }#ifdef CONFIG_HAS_GLIB_SUBPROCESS_TESTS
@@ -491,7 +493,7 @@ static void char_file_test(void) file.in = fifo; file.has_in = true; - chr =qemu_chardev_new (NULL ,TYPE_CHARDEV_FILE , &backend, + chr =qemu_chardev_new ("label-file" ,TYPE_CHARDEV_FILE , &backend, &error_abort);qemu_chr_fe_init (&be, chr, &error_abort);
@@ -501,6 +503,12 @@ static void char_file_test(void) fe_event, &fe, NULL, true); + g_assert_cmpint(fe.last_event, !=, CHR_EVENT_BREAK); +qmp_chardev_send_break ("label-foo" ,NULL ); + g_assert_cmpint(fe.last_event, !=, CHR_EVENT_BREAK); +qmp_chardev_send_break ("label-file" ,NULL ); + g_assert_cmpint(fe.last_event, ==, CHR_EVENT_BREAK); +main_loop ();close (fd);
tests/test-hmp.c +1 -0
@@ -22,6 +22,7 @@ static int verbose;static const char *hmp_cmds[] = {"boot_set ndc" ,"chardev-add null,id=testchardev1" , +"chardev-send-break testchardev2" ,"chardev-remove testchardev1" ,"commit all" ,"cpu-add 1" ,
Signature · 1 line
2.11.0
Quoted 13 lines · Stefan Fritsch
Sending a break on a serial console can be useful for debugging the guest. But not all chardev backends support sending breaks (only telnet and mux do). The chardev-send-break command allows to send a break even if using other backends.
Signed-off-by Stefan Fritsch <[email protected]>---
v2: added tests and Acked-by line+++ b/hmp-commands.hx
hmp-commands.hx Removes the chardev @var{id}. · line 1751
Quoted 7 lines
hmp-commands.hx +4
-0@@ -1745,6 +1745,22 @@ Removes the chardev @var{id}. ETEXI { + .name = "chardev-send-break", + .args_type = "id:s", + .params = "id", + .help = "send break on chardev",
Compare this wording,...
hmp-commands.hx Removes the chardev @var{id}. · line 1759
Quoted 4 lines
hmp-commands.hx +4
-0+STEXI +@item chardev-send-break id +@findex chardev-send-break +Sends break on the chardev @var{id}.
repeated here,
qapi-schema.json line 5119
Quoted 8 lines
qapi-schema.json +4
-0+++ b/qapi-schema.json@@ -5114,6 +5114,26 @@ { 'command': 'chardev-remove', 'data': {'id': 'str'} } ## +# @chardev-send-break: +# +# Send a break to a character device
...with this wording. I like 'send a break' better than 'send break', but even better might be 'send a break sequence' or even 'emulate a break sequence' (by definition, a break is NOT a character, but on bare metal character devices it IS a defined electrical sequence distinct from characters to make the recipient aware that the sender is trying to get attention).
Otherwise, the patch looks fine to me. If all that changes is some word-smithing (and the maintainer may be willing to do that), you can add:
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Marc-André Lureau
Reviewed-byQuoted 9 lines · Eric Blake
Quoted 7 lines · Stefan Fritsch
Sending a break on a serial console can be useful for debugging the guest. But not all chardev backends support sending breaks (only telnet and mux do). The chardev-send-break command allows to send a break even if using other backends.
Signed-off-by Stefan Fritsch <[email protected]>
Looks good to me,
Quoted 39 lines
---
hmp-commands.hx Removes the chardev @var{id}. · line 1751
Quoted 12 lines
v2: added tests and Acked-by line
+++ b/hmp-commands.hx
hmp-commands.hx +4
-0@@ -1745,6 +1745,22 @@ Removes the chardev @var{id}. ETEXI { + .name = "chardev-send-break", + .args_type = "id:s", + .params = "id", + .help = "send break on chardev",Compare this wording,...
hmp-commands.hx Removes the chardev @var{id}. · line 1759
Quoted 4 lines
hmp-commands.hx +4
-0+STEXI +@item chardev-send-break id +@findex chardev-send-break +Sends break on the chardev @var{id}.repeated here,
qapi-schema.json line 5119
Quoted 8 lines
qapi-schema.json +4
-0+++ b/qapi-schema.json@@ -5114,6 +5114,26 @@ { 'command': 'chardev-remove', 'data': {'id': 'str'} } ## +# @chardev-send-break: +# +# Send a break to a character device...with this wording. I like 'send a break' better than 'send break', but even better might be 'send a break sequence' or even 'emulate a break sequence' (by definition, a break is NOT a character, but on bare metal character devices it IS a defined electrical sequence distinct from characters to make the recipient aware that the sender is trying to get attention).
Quoted 4 lines
Otherwise, the patch looks fine to me. If all that changes is some word-smithing (and the maintainer may be willing to do that), you can add:
Reviewed-by Eric Blake <[email protected]>
Paolo would you take it (perhaps on the next iteration)?
thanks
Signature · 1 line
Marc-André Lureau
Quoted 55 lines · * Marc-André Lureau ([email protected]) wrote:
Quoted 9 lines · Eric Blake
Quoted 7 lines · Stefan Fritsch
Sending a break on a serial console can be useful for debugging the guest. But not all chardev backends support sending breaks (only telnet and mux do). The chardev-send-break command allows to send a break even if using other backends.
Signed-off-by Stefan Fritsch <[email protected]>Looks good to me,
Reviewed-by Marc-André Lureau <[email protected]>Quoted 39 lines
---
hmp-commands.hx Removes the chardev @var{id}. · line 1751
Quoted 12 lines
v2: added tests and Acked-by line
+++ b/hmp-commands.hx
hmp-commands.hx +4
-0@@ -1745,6 +1745,22 @@ Removes the chardev @var{id}. ETEXI { + .name = "chardev-send-break", + .args_type = "id:s", + .params = "id", + .help = "send break on chardev",Compare this wording,...
hmp-commands.hx Removes the chardev @var{id}. · line 1759
Quoted 4 lines
hmp-commands.hx +4
-0+STEXI +@item chardev-send-break id +@findex chardev-send-break +Sends break on the chardev @var{id}.repeated here,
qapi-schema.json line 5119
Quoted 8 lines
qapi-schema.json +4
-0+++ b/qapi-schema.json@@ -5114,6 +5114,26 @@ { 'command': 'chardev-remove', 'data': {'id': 'str'} } ## +# @chardev-send-break: +# +# Send a break to a character device...with this wording. I like 'send a break' better than 'send break', but even better might be 'send a break sequence' or even 'emulate a break sequence' (by definition, a break is NOT a character, but on bare metal character devices it IS a defined electrical sequence distinct from characters to make the recipient aware that the sender is trying to get attention).
Quoted 6 lines
Quoted 4 lines
Otherwise, the patch looks fine to me. If all that changes is some word-smithing (and the maintainer may be willing to do that), you can add:
Reviewed-by Eric Blake <[email protected]>Paolo would you take it (perhaps on the next iteration)?
I can take it through HMP; I'm just doing a pull now.
Dave
Quoted 3 lines
thanks
Signature · 1 line
Marc-André Lureau
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Dr. David Alan Gilbert
AppliedQuoted 47 lines · * Eric Blake ([email protected]) wrote:
Quoted 13 lines · Stefan Fritsch
Sending a break on a serial console can be useful for debugging the guest. But not all chardev backends support sending breaks (only telnet and mux do). The chardev-send-break command allows to send a break even if using other backends.
Signed-off-by Stefan Fritsch <[email protected]>---
v2: added tests and Acked-by line+++ b/hmp-commands.hx
Review Removes the chardev @var{id}. · line 1751
Quoted 7 lines
(quoted diff) +4
-0@@ -1745,6 +1745,22 @@ Removes the chardev @var{id}. ETEXI { + .name = "chardev-send-break", + .args_type = "id:s", + .params = "id", + .help = "send break on chardev",Compare this wording,...
Review Removes the chardev @var{id}. · line 1755
Quoted 4 lines
(quoted diff) +4
-0+STEXI +@item chardev-send-break id +@findex chardev-send-break +Sends break on the chardev @var{id}.repeated here,
Review line 5119
Quoted 8 lines
(quoted diff) +4
-0+++ b/qapi-schema.json@@ -5114,6 +5114,26 @@ { 'command': 'chardev-remove', 'data': {'id': 'str'} } ## +# @chardev-send-break: +# +# Send a break to a character device...with this wording. I like 'send a break' better than 'send break', but even better might be 'send a break sequence' or even 'emulate a break sequence' (by definition, a break is NOT a character, but on bare metal character devices it IS a defined electrical sequence distinct from characters to make the recipient aware that the sender is trying to get attention).
Quoted 3 lines
Otherwise, the patch looks fine to me. If all that changes is some word-smithing (and the maintainer may be willing to do that), you can add:
Reviewed-by Eric Blake <[email protected]>
I'll go with the 'send a break' - the official terminology seems to be a 'break condition', but I've never heard anyone say that, it's always been 'send a break'.
hmp-commands.hx +2 -2
@@ -1748,7 +1748,7 @@ ETEXI .name = "chardev-send-break", .args_type = "id:s", .params = "id", - .help = "send break on chardev", + .help = "send a break on chardev", .cmd = hmp_chardev_send_break, .command_completion = chardev_remove_completion, },
@@ -1756,7 +1756,7 @@ ETEXI STEXI @item chardev-send-break id @findex chardev-send-break -Sends break on the chardev @var{id}. +Send a break on the chardev @var{id}. ETEXI
Queued to HMP
Dave
Quoted 6 lines
Signature · 4 lines
-- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 52 lines · On Thursday, 29 June 2017 16:00:54 CEST Dr. David Alan Gilbert wrote:
Quoted 51 lines · * Eric Blake ([email protected]) wrote:
Quoted 13 lines · Stefan Fritsch
Sending a break on a serial console can be useful for debugging the guest. But not all chardev backends support sending breaks (only telnet and mux do). The chardev-send-break command allows to send a break even if using other backends.
Signed-off-by Stefan Fritsch <[email protected]>---
v2: added tests and Acked-by line+++ b/hmp-commands.hx
Review Removes the chardev @var{id}. · line 1753
Quoted 9 lines
(quoted diff) +4
-0@@ -1745,6 +1745,22 @@ Removes the chardev @var{id}. ETEXI { + .name = "chardev-send-break", + .args_type = "id:s", + .params = "id", + .help = "send break on chardev",Compare this wording,...
Review Removes the chardev @var{id}. · line 1757
Quoted 4 lines
(quoted diff) +4
-0+STEXI +@item chardev-send-break id +@findex chardev-send-break +Sends break on the chardev @var{id}.repeated here,
Review line 5121
Quoted 10 lines
(quoted diff) +4
-0+++ b/qapi-schema.json@@ -5114,6 +5114,26 @@ { 'command': 'chardev-remove', 'data': {'id': 'str'} } ## +# @chardev-send-break: +# +# Send a break to a character device...with this wording. I like 'send a break' better than 'send break', but even better might be 'send a break sequence' or even 'emulate a break sequence' (by definition, a break is NOT a character, but on bare metal character devices it IS a defined electrical sequence distinct from characters to make the recipient aware that the sender is trying to get attention).
Quoted 7 lines
Quoted 3 lines
Otherwise, the patch looks fine to me. If all that changes is some word-smithing (and the maintainer may be willing to do that), you can add:
Reviewed-by Eric Blake <[email protected]>I'll go with the 'send a break' - the official terminology seems to be a 'break condition', but I've never heard anyone say that, it's always been 'send a break'.
I also think that "send a break" is best for people who google for it.
Thanks.
Cheers,
Stefan
Hi,
Quoted 9 lines · Stefan Fritsch
Sending a break on a serial console can be useful for debugging the guest. But not all chardev backends support sending breaks (only telnet and mux do). The chardev-send-break command allows to send a break even if using other backends.
Signed-off-by Stefan Fritsch <[email protected]>---
v2: added tests and Acked-by line
[...]
tests/test-hmp.c static int verbose; · line 28
Quoted 12 lines
tests/test-hmp.c +1
-0@@ -22,6 +22,7 @@ static int verbose;static const char *hmp_cmds[] = {"boot_set ndc" ,"chardev-add null,id=testchardev1" , +"chardev-send-break testchardev2" ,"chardev-remove testchardev1" ,"commit all" ,"cpu-add 1" ,
Did you use "testchardev2" here on purpose, or should that have been a "testchardev1" instead? "testchardev2" is not a valid identifier in the HMP test, so this might not exercise the code path that you might have intended?
Thomas
Quoted 20 lines · Thomas Huth
Quoted 9 lines · Stefan Fritsch
Sending a break on a serial console can be useful for debugging the guest. But not all chardev backends support sending breaks (only telnet and mux do). The chardev-send-break command allows to send a break even if using other backends.
Signed-off-by Stefan Fritsch <[email protected]>---
v2: added tests and Acked-by line[...]
Quoted 9 lines
tests/test-hmp.c +1
-0@@ -22,6 +22,7 @@ static int verbose;static const char *hmp_cmds[] = {"boot_set ndc" ,"chardev-add null,id=testchardev1" , +"chardev-send-break testchardev2" ,
Quoted 8 lines
tests/test-hmp.c static int verbose; · line 28
Quoted 3 lines
tests/test-hmp.c +0
-0"chardev-remove testchardev1" ,"commit all" , "cpu-add 1",Did you use "testchardev2" here on purpose, or should that have been a "testchardev1" instead? "testchardev2" is not a valid identifier in the HMP test, so this might not exercise the code path that you might have intended?
You are right, this should have been "testchardev1". Actually, one could do both, which would then exercise two different code paths.
Cheers,
Stefan