Device state visualization reloaded
cover Device state visualization reloaded
More than one year ago I posted some patches to add a monitor command callend device_show. The purpose of that command is to dump the state of some qdev device based on its vmstate.
To improve the usability of that interface, the previous series also tried to create a canonical qdev tree path name format and even added monitor command expansion. That format created quite a few discussions, and we never came to some conclusion.
As device_show is still a useful tool for debugging but qdev structuring and addressing may significantly change in the near future, I decided to reanimate those patches while avoiding almost any change of the addressing scheme. The only one I propose is automatic ID assignment for anonymous devices so that any qdev device is in principle addressable (e.g. APIC and IO-APIC on x86).
As back then, device_show remains HMP-only to avoid any stable ABI issues around QMP.
Jan Kiszka (6):
monitor: return length of printed string via monitor_[v]printf Add base64 encoder/decoder
QMP: Reserve namespace for complex object classes
QMP: Add QBuffer
monitor: Add basic device state visualization
qdev: Generate IDs for anonymous devices
Makefile | 2 +- Makefile.objs | 4 +- QMP/qmp-spec.txt | 24 ++++- base64.c | 202 +++++++++++++++++++++++++++++++++++++ base64.h | 19 ++++ check-qbuffer.c | 172 ++++++++++++++++++++++++++++++++ configure | 2 +- hmp-commands.hx | 16 +++ hw/hw.h | 2 + hw/qdev-properties.c | 2 +- hw/qdev.c | 271 ++++++++++++++++++++++++++++++++++++++++++++++++-- hw/qdev.h | 3 + monitor.c | 23 +++-- monitor.h | 4 +- qbuffer.c | 117 ++++++++++++++++++++++ qbuffer.h | 33 ++++++ qemu-tool.c | 6 +- qerror.c | 4 + qerror.h | 3 + qjson.c | 15 +++ qobject.h | 1 + 21 files changed, 894 insertions(+), 31 deletions(-) create mode 100644 base64.c create mode 100644 base64.h create mode 100644 check-qbuffer.c create mode 100644 qbuffer.c create mode 100644 qbuffer.h
Signature · 1 line
1.7.3.4
PATCH 1/6 monitor: return length of printed string via monitor_[v]printf
This simply forwards the result of the internal vsnprintf to the callers of monitor_printf and monitor_vprintf. When invoked over a QMP session or in absence of an active monitor, -1 is returned.
--- monitor.c | 23 +++++++++++++++-------- monitor.h | 4 ++-- qemu-tool.c | 6 ++++-- 3 files changed, 21 insertions(+), 12 deletions(-)
monitor.c +15 -8
@@ -270,29 +270,36 @@ static void monitor_puts(Monitor *mon, const char *str) } } -void monitor_vprintf (Monitor *mon,const char *fmt,va_list ap) +int monitor_vprintf (Monitor *mon,const char *fmt,va_list ap) {char buf[4096 ]; +int ret; -if (!mon) -return ; - +if (!mon) { +return -1 ; + }mon_print_count_inc (mon);if (monitor_ctrl_mode (mon)) { -return ; +return -1 ; } -vsnprintf (buf,sizeof (buf), fmt, ap); + ret =vsnprintf (buf,sizeof (buf), fmt, ap);monitor_puts (mon, buf); + +return ret; } -void monitor_printf (Monitor *mon,const char *fmt, ...) +int monitor_printf (Monitor *mon,const char *fmt, ...) {va_list ap; +int ret; +va_start (ap, fmt); -monitor_vprintf (mon, fmt, ap); + ret =monitor_vprintf (mon, fmt, ap);va_end (ap); + +return ret; }void monitor_print_filename (Monitor *mon,const char *filename)
monitor.h +2 -2
@@ -52,9 +52,9 @@ int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,int monitor_get_fd (Monitor *mon,const char *fdname); -void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) +int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0); -void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3); +int monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3);void monitor_print_filename (Monitor *mon,const char *filename);void monitor_flush (Monitor *mon);
qemu-tool.c +4 -2
@@ -44,12 +44,14 @@ void monitor_set_error(Monitor *mon, QError *qerror) { } -void monitor_vprintf (Monitor *mon,const char *fmt,va_list ap) +int monitor_vprintf (Monitor *mon,const char *fmt,va_list ap) { +return -1 ; } -void monitor_printf (Monitor *mon,const char *fmt, ...) +int monitor_printf (Monitor *mon,const char *fmt, ...) { +return -1 ; }void monitor_print_filename (Monitor *mon,const char *filename)
Signature · 1 line
1.7.3.4
PATCH 2/6 Add base64 encoder/decoder
In reply to Jan KiszkaWill be used by QBuffer.
--- Makefile.objs | 2 +- base64.c | 202 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ base64.h | 19 ++++++ 3 files changed, 222 insertions(+), 1 deletions(-) create mode 100644 base64.c create mode 100644 base64.h
Makefile.objs +1 -1
@@ -2,7 +2,7 @@ # QObject qobject-obj-y = qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o qobject-obj-y += qjson.o json-lexer.o json-streamer.o json-parser.o -qobject-obj-y += qerror.o error.o +qobject-obj-y += qerror.o error.o base64.o ####################################################################### # oslib-obj-y is code depending on the OS (win32 vs posix)
base64.c new file +202 -0
202 lines not on this page · raw message
base64.h new file +19 -0
@@ -0,0 +1,19 @@ +/* +* Base64 encoder/decoder conforming to RFC 4648 +* (based on Mozilla's nsprpub/lib/libc/src/base64.c) +* +* Copyright (C) 2010 Siemens AG +* +* Authors: +* Jan Kiszka <[email protected]> +* +* This work is licensed under the terms of the GNU LGPL, version 2.1 or later. +* See the COPYING.LIB file in the top-level directory. +* +*/ + +#include <inttypes.h> +#include <stddef.h> + +void base64_encode (const uint8_t *src,size_t srclen,char *dest); +int base64_decode (const char *src,size_t srclen,uint8_t *dest);
Signature · 1 line
1.7.3.4
Re: [Qemu-devel] [PATCH 2/6] Add base64 encoder/decoder
Quoted 1 line · Jan Kiszka
Will be used by QBuffer.
Is it possible to use the glib base64 encode/decode routines instead of rolling our own here?
-- PMM
Re: [Qemu-devel] [PATCH 2/6] Add base64 encoder/decoder
Quoted 5 lines · Peter Maydell
Quoted 1 line · Jan Kiszka
Will be used by QBuffer.
Is it possible to use the glib base64 encode/decode routines instead of rolling our own here?
Yeah, times are changing. Need to check what's there and how to use it.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [Qemu-devel] [PATCH 2/6] Add base64 encoder/decoder
Quoted 8 lines · Jan Kiszka
Quoted 5 lines · Peter Maydell
Quoted 1 line · Jan Kiszka
Will be used by QBuffer.
Is it possible to use the glib base64 encode/decode routines instead of rolling our own here?
Yeah, times are changing. Need to check what's there and how to use it.
Requires glib >= 2.12, we are currently at >= 2.0, right? Would it be OK to raise the entry barrier?
I'm also still looking for error handling of g_base64_decode. I guess one is supposed to compare returned length against some expected value. Well, it's glib...
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [Qemu-devel] [PATCH 2/6] Add base64 encoder/decoder
Quoted 8 lines · Jan Kiszka
Quoted 7 lines · Jan Kiszka
Quoted 5 lines · Peter Maydell
Quoted 1 line · Jan Kiszka
Will be used by QBuffer.
Is it possible to use the glib base64 encode/decode routines instead of rolling our own here?
Quoted 8 lines
Quoted 1 line
Yeah, times are changing. Need to check what's there and how to use it.
Requires glib >= 2.12, we are currently at >= 2.0, right? Would it be OK to raise the entry barrier?
I'm also still looking for error handling of
g_base64_decode. I guess one is supposed to compare returned length against some expected value. Well, it's glib...
The length check is not sufficient, and glib's decoder fails on my invalid input string tests.
I think proper error detection in base64 inputs is a worthwhile feature that glib lacks. So I'll stick with roll-our-own (actually, it's Mozilla's version).
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [Qemu-devel] [PATCH 2/6] Add base64 encoder/decoder
Quoted 18 lines · On Fri, 26 Aug 2011 20:02:37 +0200 Jan Kiszka <[email protected]> wrote:
Quoted 8 lines · Jan Kiszka
Quoted 7 lines · Jan Kiszka
Quoted 5 lines · Peter Maydell
Quoted 1 line · Jan Kiszka
Will be used by QBuffer.
Is it possible to use the glib base64 encode/decode routines instead of rolling our own here?
Quoted 8 lines
Quoted 1 line
Yeah, times are changing. Need to check what's there and how to use it.
Requires glib >= 2.12, we are currently at >= 2.0, right? Would it be OK to raise the entry barrier?
I'm also still looking for error handling of
g_base64_decode. I guess one is supposed to compare returned length against some expected value. Well, it's glib...
Quoted 6 lines
The length check is not sufficient, and glib's decoder fails on my invalid input string tests.
I think proper error detection in base64 inputs is a worthwhile feature that glib lacks. So I'll stick with roll-our-own (actually, it's Mozilla's version).
The guest-agent is using glib's to implement file read & write, I think it should switch to Jan's implementation?
[Qemu-devel] required glib version? Re: [PATCH 2/6] Add base64 encoder/decoder
In reply to Jan KiszkaQuoted 6 lines · Jan Kiszka
Quoted 1 line · Jan Kiszka
[ using glib base64 decoder ]
Requires glib>= 2.12, we are currently at>= 2.0, right? Would it be OK to raise the entry barrier?
In master it currently is >= 2.20 due to v9fs_init_worker_threads using g_thread_get_initialized which was added in 2.20 according to the docs.
Which makes the build fail on rhel-5 (shipping with glib 2.12).
Guess we'll need to clearly define which minimum glib version we want require. And whenever we want apply this to the whole code base or allow different minimum requirements for different components.
Requiring glib 2.20 for all components isn't going to fly as we certainly want be able to run the qemu guest agent almost everythere. Requiring something newer than 2.0 for the qemu emulator might be reasonable of there are good reasons (aka useful glib features) though.
Comments?
cheers,
Gerd
PATCH 3/6 QMP: Reserve namespace for complex object classes
In reply to Jan KiszkaThis reserves JSON objects that contain the key '__class__' for QMP-specific complex objects. First user will be the buffer class.
--- QMP/qmp-spec.txt | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-)
QMP/qmp-spec.txt +13 -3
@@ -146,6 +146,15 @@ The format is: For a listing of supported asynchronous events, please, refer to the qmp-events.txt file. +2.6 Complex object classes +-------------------------- + +JSON objects that contain the key-value pair '"__class__": json-string' are +reserved for QMP-specific complex object classes that. QMP specifies which +further keys each of these objects include and how they are encoded. + +So far, no complex object class is specified. + 3. QMP Examples ===============
@@ -229,9 +238,10 @@ avoid modifying QMP. Both upstream and downstream need to take care to preserve long-term compatibility and interoperability. To help with that, QMP reserves JSON object member names beginning with -'__' (double underscore) for downstream use ("downstream names"). This -means upstream will never use any downstream names for its commands, -arguments, errors, asynchronous events, and so forth. +'__' (double underscore) for downstream use ("downstream names"). Downstream +names MUST NOT end with '__' as this pattern is reserved for QMP-defined JSON +object classes. Upstream will never use any downstream names for its +commands, arguments, errors, asynchronous events, and so forth. Any new names downstream wishes to add must begin with '__'. To ensure compatibility with other downstreams, it is strongly
Signature · 1 line
1.7.3.4
Re: [Qemu-devel] [PATCH 3/6] QMP: Reserve namespace for complex object classes
Quoted 14 lines · On Fri, 26 Aug 2011 16:48:13 +0200 Jan Kiszka <[email protected]> wrote:
This reserves JSON objects that contain the key '
__class__' for QMP-specific complex objects. First user will be the buffer class.CC Luiz Capitulino <[email protected]>Signed-off-by Jan Kiszka <[email protected]>--- QMP/qmp-spec.txt | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-)QMP/qmp-spec.txt +0
-0
QMP/qmp-spec.txt The format is: · line 153
Quoted 8 lines
QMP/qmp-spec.txt +5
-0@@ -146,6 +146,15 @@ The format is: For a listing of supported asynchronous events, please, refer to the qmp-events.txt file. +2.6 Complex object classes +-------------------------- + +JSON objects that contain the key-value pair '"__class__": json-string' are +reserved for QMP-specific complex object classes that. QMP specifies which
Can I just drop the period or is it misplaced?
Quoted 21 lines
QMP/qmp-spec.txt +8
-3+further keys each of these objects include and how they are encoded. + +So far, no complex object class is specified. + 3. QMP Examples ===============@@ -229,9 +238,10 @@ avoid modifying QMP. Both upstream and downstream need to take care to preserve long-term compatibility and interoperability. To help with that, QMP reserves JSON object member names beginning with -'__' (double underscore) for downstream use ("downstream names"). This -means upstream will never use any downstream names for its commands, -arguments, errors, asynchronous events, and so forth. +'__' (double underscore) for downstream use ("downstream names"). Downstream +names MUST NOT end with '__' as this pattern is reserved for QMP-defined JSON +object classes. Upstream will never use any downstream names for its +commands, arguments, errors, asynchronous events, and so forth. Any new names downstream wishes to add must begin with '__'. To ensure compatibility with other downstreams, it is strongly
Re: [Qemu-devel] [PATCH 3/6] QMP: Reserve namespace for complex object classes
Quoted 20 lines · Luiz Capitulino
Quoted 17 lines · On Fri, 26 Aug 2011 16:48:13 +0200 Jan Kiszka <[email protected]> wrote:
This reserves JSON objects that contain the key '
__class__' for QMP-specific complex objects. First user will be the buffer class.CC Luiz Capitulino <[email protected]>Signed-off-by Jan Kiszka <[email protected]>--- QMP/qmp-spec.txt | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-)QMP/qmp-spec.txt +0
-0@@ -146,6 +146,15 @@ The format is: For a listing of supported asynchronous events, please, refer to the qmp-events.txt file.
Quoted 7 lines
QMP/qmp-spec.txt The format is: · line 153
Quoted 5 lines
QMP/qmp-spec.txt +5
-0+2.6 Complex object classes +-------------------------- + +JSON objects that contain the key-value pair '"__class__": json-string' are +reserved for QMP-specific complex object classes that. QMP specifies whichCan I just drop the period or is it misplaced?
Actually, 'that' is misplaced.
Quoted 5 lines
QMP/qmp-spec.txt The format is: · line 157
Quoted 5 lines
QMP/qmp-spec.txt +4
-0+further keys each of these objects include and how they are encoded. + +So far, no complex object class is specified. +
Thanks,
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [Qemu-devel] [PATCH 3/6] QMP: Reserve namespace for complex object classes
In reply to Luiz CapitulinoQuoted 5 lines · Luiz Capitulino
Quoted 2 lines · On Fri, 26 Aug 2011 16:48:13 +0200 Jan Kiszka<[email protected]> wrote:
This reserves JSON objects that contain the key '
__class__' for QMP-specific complex objects. First user will be the buffer class.
BTW, we need to teach QAPI how handle these types.
QAPI already has the information about the class that it's working with.
I think that means you can probably do something like this (completely
untested):
qapi/qmp-output-visitor.c +2 -0
@@ -105,6 +105,8 @@ static void qmp_output_start_struct(Visitor *v, void **obj,qmp_output_add (qov, name, dict);qmp_output_push (qov, dict); + +visit_type_str (v,"__class__" , kind, errp); }static void qmp_output_end_struct (Visitor *v,Error **errp)
That will add class information for every type that gets written by QAPI. Likewise:
qapi/qmp-input-visitor.c +6 -0
@@ -86,6 +86,7 @@ static void qmp_input_start_struct(Visitor *v, void **obj, con {QmpInputVisitor *qiv =to_qiv (v);const QObject *qobj =qmp_input_get_object (qiv, name); +char *type;if (!qobj ||qobject_type (qobj) !=QTYPE_QDICT ) { error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
@@ -101,6 +102,15 @@ static void qmp_input_start_struct(Visitor *v, void **obj,if (obj) { *obj =g_malloc0 (size); } + +visit_type_str (v, &type,"__class__" , errp); +if (error_is_set (errp)) { +return ; + }
Will do type checking on incoming data.
Maybe we should relax that and only do the type checking if __class__ is specified..
Regards,
Anthony Liguori
Quoted 45 lines
Quoted 12 lines
CC Luiz Capitulino<[email protected]>Signed-off-by Jan Kiszka<[email protected]>--- QMP/qmp-spec.txt | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-)QMP/qmp-spec.txt +0
-0QMP/qmp-spec.txt The format is: · line 153
Quoted 8 lines
QMP/qmp-spec.txt +5
-0@@ -146,6 +146,15 @@ The format is: For a listing of supported asynchronous events, please, refer to the qmp-events.txt file. +2.6 Complex object classes +-------------------------- + +JSON objects that contain the key-value pair '"__class__": json-string' are +reserved for QMP-specific complex object classes that. QMP specifies whichCan I just drop the period or is it misplaced?
Quoted 21 lines
QMP/qmp-spec.txt +8
-3+further keys each of these objects include and how they are encoded. + +So far, no complex object class is specified. + 3. QMP Examples ===============@@ -229,9 +238,10 @@ avoid modifying QMP. Both upstream and downstream need to take care to preserve long-term compatibility and interoperability. To help with that, QMP reserves JSON object member names beginning with -'__' (double underscore) for downstream use ("downstream names"). This -means upstream will never use any downstream names for its commands, -arguments, errors, asynchronous events, and so forth. +'__' (double underscore) for downstream use ("downstream names"). Downstream +names MUST NOT end with '__' as this pattern is reserved for QMP-defined JSON +object classes. Upstream will never use any downstream names for its +commands, arguments, errors, asynchronous events, and so forth. Any new names downstream wishes to add must begin with '__'. To ensure compatibility with other downstreams, it is strongly
PATCH 4/6 QMP: Add QBuffer
In reply to Jan KiszkaThis introduces a buffer object for use with QMP. As a buffer is not natively encodable in JSON, we encode it as a base64 string and encapsulate the result in the new QMP object class "buffer".
The first use case for this is pushing the content of buffers that are part of a device state into a qdict.
--- Makefile | 2 +- Makefile.objs | 2 +- QMP/qmp-spec.txt | 10 +++- check-qbuffer.c | 172 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ configure | 2 +- qbuffer.c | 117 ++++++++++++++++++++++++++++++++++++ qbuffer.h | 33 ++++++++++ qjson.c | 15 +++++ qobject.h | 1 + 9 files changed, 350 insertions(+), 4 deletions(-) create mode 100644 check-qbuffer.c create mode 100644 qbuffer.c create mode 100644 qbuffer.h
Makefile +1 -1
@@ -151,7 +151,7 @@ qemu-io$(EXESUF): qemu-io.o cmd.o qemu-tool.o qemu-error.o $(oslib-obj-y) $(trac qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $@") -check-qint.o check-qstring.o check-qdict.o check-qlist.o check-qfloat.o check-qjson.o test-coroutine.o: $(GENERATED_HEADERS) +check-qint.o check-qstring.o check-qdict.o check-qlist.o check-qfloat.o check-qjson.o test-coroutine.o check-qbuffer: $(GENERATED_HEADERS) CHECK_PROG_DEPS = $(oslib-obj-y) $(trace-obj-y) qemu-tool.o
Makefile.objs +1 -1
@@ -1,6 +1,6 @@ ####################################################################### # QObject -qobject-obj-y = qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o +qobject-obj-y = qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o qbuffer.o qobject-obj-y += qjson.o json-lexer.o json-streamer.o json-parser.o qobject-obj-y += qerror.o error.o base64.o
QMP/qmp-spec.txt +9 -1
@@ -153,7 +153,15 @@ JSON objects that contain the key-value pair '"__class__": json-string' are reserved for QMP-specific complex object classes that. QMP specifies which further keys each of these objects include and how they are encoded. -So far, no complex object class is specified. +2.6.1 Buffer class +------------------ + +This QMP object class allows to transport binary data. A buffer object +consists of the following keys: + +{ "__class__": "buffer", "data": json-string } + +The data string is base64 encoded according to RFC 4648. 3. QMP Examples ===============
check-qbuffer.c new file +172 -0
172 lines not on this page · raw message
configure +1 -1
@@ -2630,7 +2630,7 @@ if test "$softmmu" = yes ; then tools="qemu-ga\$(EXESUF) $tools" fi if [ "$check_utests" = "yes" ]; then - tools="check-qint check-qstring check-qdict check-qlist $tools" + tools="check-qint check-qstring check-qdict check-qlist check-qbuffer $tools" tools="check-qfloat check-qjson $tools" fi fi
qbuffer.c new file +117 -0
117 lines not on this page · raw message
qbuffer.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* QBuffer Module +* +* Copyright (C) 2010 Siemens AG +* +* Authors: +* Jan Kiszka <[email protected]> +* +* This work is licensed under the terms of the GNU LGPL, version 2.1 or later. +* See the COPYING.LIB file in the top-level directory. +* +*/ + +#ifndef QBUFFER_H +#define QBUFFER_H + +#include <stdint.h> +#include "qobject.h" +#include "qstring.h" + +typedef struct QBuffer { +QObject_HEAD ; +void *data; +size_t size; +}QBuffer ; + +QBuffer *qbuffer_from_data (const void *data,size_t size); +QBuffer *qbuffer_from_qstring (const QString *string); +const void *qbuffer_get_data (const QBuffer *qb); +size_t qbuffer_get_size (const QBuffer *qb); +QBuffer *qobject_to_qbuffer (const QObject *obj); + +#endif /* QBUFFER_H */
qjson.c +15 -0
@@ -19,7 +19,9 @@#include "qlist.h" #include "qbool.h" #include "qfloat.h" +#include "qbuffer.h" #include "qdict.h" +#include "base64.h" typedef struct JSONParsingState {
@@ -268,6 +270,19 @@ static void to_json(const QObject *obj, QString *str, int pretty, int indent) }break ; } +case QTYPE_QBUFFER : { +QBuffer *val =qobject_to_qbuffer (obj); +size_t data_size =qbuffer_get_size (val); +size_t str_len = ((data_size +2 ) /3 ) *4 ; +char *buffer =g_malloc (str_len +1 ); + +base64_encode (qbuffer_get_data (val), data_size, buffer); +qstring_append (str,"{\"__class__\": \"buffer\", \"data\": \"" ); +qstring_append (str, buffer); +qstring_append (str,"\"}" ); +g_free (buffer); +break ; + }case QTYPE_QERROR :/* XXX: should QError be emitted? */ case QTYPE_NONE :
qobject.h +1 -0
@@ -44,6 +44,7 @@ typedef enum {QTYPE_QFLOAT ,QTYPE_QBOOL ,QTYPE_QERROR , +QTYPE_QBUFFER , } qtype_code;struct QObject ;
Signature · 1 line
1.7.3.4
PATCH v2 4/6 QMP: Add QBuffer
This introduces a buffer object for use with QMP. As a buffer is not natively encodable in JSON, we encode it as a base64 string and encapsulate the result in the new QMP object class "buffer".
The first use case for this is pushing the content of buffers that are part of a device state into a qdict.
---
Changes in v2:
- fixed unit tests
Makefile | 5 +- Makefile.objs | 2 +- QMP/qmp-spec.txt | 10 +++- check-qbuffer.c | 172 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ configure | 2 +- qbuffer.c | 117 ++++++++++++++++++++++++++++++++++++ qbuffer.h | 33 ++++++++++ qjson.c | 15 +++++ qobject.h | 1 + 9 files changed, 352 insertions(+), 5 deletions(-) create mode 100644 check-qbuffer.c create mode 100644 qbuffer.c create mode 100644 qbuffer.h
Makefile +3 -2
@@ -151,7 +151,7 @@ qemu-io$(EXESUF): qemu-io.o cmd.o qemu-tool.o qemu-error.o $(oslib-obj-y) $(trac qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $@") -check-qint.o check-qstring.o check-qdict.o check-qlist.o check-qfloat.o check-qjson.o test-coroutine.o: $(GENERATED_HEADERS) +check-qint.o check-qstring.o check-qdict.o check-qlist.o check-qfloat.o check-qjson.o test-coroutine.o check-qbuffer.o: $(GENERATED_HEADERS) CHECK_PROG_DEPS = $(oslib-obj-y) $(trace-obj-y) qemu-tool.o
@@ -160,7 +160,8 @@ check-qstring: check-qstring.o qstring.o $(CHECK_PROG_DEPS) check-qdict: check-qdict.o qdict.o qfloat.o qint.o qstring.o qbool.o qlist.o $(CHECK_PROG_DEPS) check-qlist: check-qlist.o qlist.o qint.o $(CHECK_PROG_DEPS) check-qfloat: check-qfloat.o qfloat.o $(CHECK_PROG_DEPS) -check-qjson: check-qjson.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o qjson.o json-streamer.o json-lexer.o json-parser.o error.o qerror.o qemu-error.o $(CHECK_PROG_DEPS) +check-qbuffer: check-qbuffer.o qbuffer.o qstring.o base64.o $(CHECK_PROG_DEPS) +check-qjson: check-qjson.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o qjson.o qbuffer.o base64.o json-streamer.o json-lexer.o json-parser.o error.o qerror.o qemu-error.o $(CHECK_PROG_DEPS) test-coroutine: test-coroutine.o qemu-timer-common.o async.o $(coroutine-obj-y) $(CHECK_PROG_DEPS) $(qapi-obj-y): $(GENERATED_HEADERS)
Makefile.objs +1 -1
@@ -1,6 +1,6 @@ ####################################################################### # QObject -qobject-obj-y = qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o +qobject-obj-y = qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o qbuffer.o qobject-obj-y += qjson.o json-lexer.o json-streamer.o json-parser.o qobject-obj-y += qerror.o error.o base64.o
QMP/qmp-spec.txt +9 -1
@@ -153,7 +153,15 @@ JSON objects that contain the key-value pair '"__class__": json-string' are reserved for QMP-specific complex object classes that. QMP specifies which further keys each of these objects include and how they are encoded. -So far, no complex object class is specified. +2.6.1 Buffer class +------------------ + +This QMP object class allows to transport binary data. A buffer object +consists of the following keys: + +{ "__class__": "buffer", "data": json-string } + +The data string is base64 encoded according to RFC 4648. 3. QMP Examples ===============
check-qbuffer.c new file +172 -0
172 lines not on this page · raw message
configure +1 -1
@@ -2630,7 +2630,7 @@ if test "$softmmu" = yes ; then tools="qemu-ga\$(EXESUF) $tools" fi if [ "$check_utests" = "yes" ]; then - tools="check-qint check-qstring check-qdict check-qlist $tools" + tools="check-qint check-qstring check-qdict check-qlist check-qbuffer $tools" tools="check-qfloat check-qjson $tools" fi fi
qbuffer.c new file +117 -0
117 lines not on this page · raw message
qbuffer.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* QBuffer Module +* +* Copyright (C) 2010 Siemens AG +* +* Authors: +* Jan Kiszka <[email protected]> +* +* This work is licensed under the terms of the GNU LGPL, version 2.1 or later. +* See the COPYING.LIB file in the top-level directory. +* +*/ + +#ifndef QBUFFER_H +#define QBUFFER_H + +#include <stdint.h> +#include "qobject.h" +#include "qstring.h" + +typedef struct QBuffer { +QObject_HEAD ; +void *data; +size_t size; +}QBuffer ; + +QBuffer *qbuffer_from_data (const void *data,size_t size); +QBuffer *qbuffer_from_qstring (const QString *string); +const void *qbuffer_get_data (const QBuffer *qb); +size_t qbuffer_get_size (const QBuffer *qb); +QBuffer *qobject_to_qbuffer (const QObject *obj); + +#endif /* QBUFFER_H */
qjson.c +15 -0
@@ -19,7 +19,9 @@#include "qlist.h" #include "qbool.h" #include "qfloat.h" +#include "qbuffer.h" #include "qdict.h" +#include "base64.h" typedef struct JSONParsingState {
@@ -268,6 +270,19 @@ static void to_json(const QObject *obj, QString *str, int pretty, int indent) }break ; } +case QTYPE_QBUFFER : { +QBuffer *val =qobject_to_qbuffer (obj); +size_t data_size =qbuffer_get_size (val); +size_t str_len = ((data_size +2 ) /3 ) *4 ; +char *buffer =g_malloc (str_len +1 ); + +base64_encode (qbuffer_get_data (val), data_size, buffer); +qstring_append (str,"{\"__class__\": \"buffer\", \"data\": \"" ); +qstring_append (str, buffer); +qstring_append (str,"\"}" ); +g_free (buffer); +break ; + }case QTYPE_QERROR :/* XXX: should QError be emitted? */ case QTYPE_NONE :
qobject.h +1 -0
@@ -44,6 +44,7 @@ typedef enum {QTYPE_QFLOAT ,QTYPE_QBOOL ,QTYPE_QERROR , +QTYPE_QBUFFER , } qtype_code;struct QObject ;
PATCH 5/6 monitor: Add basic device state visualization
In reply to Jan KiszkaThis introduces device_show, a monitor command that saves the vmstate of a qdev device and visualizes it. Buffers are cut after 16 byte by default, but the full content can be requested via '-f'. To pretty-print sub-arrays, vmstate is extended to store the start index name. A new qerror is introduced to signal a missing vmstate. QMP is not supported as we cannot provide a stable interface, at least at this point.
--- hmp-commands.hx | 16 ++++ hw/hw.h | 2 + hw/qdev.c | 248 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/qdev.h | 2 + qerror.c | 4 + qerror.h | 3 + 6 files changed, 275 insertions(+), 0 deletions(-)
hmp-commands.hx +16 -0
@@ -586,6 +586,22 @@ Remove device @var{id}. ETEXI { + .name = "device_show", + .args_type = "full:-f,id:s", + .params = "[-f] device", + .help = "show device state (specify -f for full buffer dumping)", + .user_print = device_user_print, + .mhandler.cmd_new = do_device_show, + }, + +STEXI +@item device_show [@code{-f}] @var{id} + +Show state of device @var{id} in a human-readable form. Buffers are cut +after 16 bytes unless a full dump is requested via @code{-f}. +ETEXI + + { .name = "cpu", .args_type = "index:i", .params = "index",
hw/hw.h +2 -0
@@ -304,6 +304,7 @@ enum VMStateFlags { typedef struct { const char *name; + const char *start_index; size_t offset; size_t size; size_t start;
@@ -437,6 +438,7 @@ extern const VMStateInfo vmstate_info_unused_buffer; .size = sizeof(_type), \ .flags = VMS_ARRAY, \ .offset = vmstate_offset_sub_array(_state, _field, _type, _start), \ + .start_index = (stringify(_start)), \ }#define VMSTATE_ARRAY_INT32_UNSAFE (_field, _state, _field_num, _info, _type) {\
hw/qdev.c +248 -0
257 lines not on this page · raw message
hw/qdev.h +2 -0
@@ -215,6 +215,8 @@ void do_info_qtree(Monitor *mon);void do_info_qdm (Monitor *mon);int do_device_add (Monitor *mon,const QDict *qdict,QObject **ret_data);int do_device_del (Monitor *mon,const QDict *qdict,QObject **ret_data); +void device_user_print (Monitor *mon,const QObject *data); +int do_device_show (Monitor *mon,const QDict *qdict,QObject **ret_data);/*** qdev-properties.c ***/
qerror.c +4 -0
@@ -105,6 +105,10 @@ static const QErrorStringTable qerror_table[] = { .desc = "Device '%(device)' does not support hotplugging", }, { + .error_fmt = QERR_DEVICE_NO_STATE, + .desc = "No state available for device '%(device)'", + }, + { .error_fmt = QERR_DUPLICATE_ID, .desc = "Duplicate ID '%(id)' for %(object)", },
qerror.h +3 -0
@@ -94,6 +94,9 @@ QError *qobject_to_qerror(const QObject *obj);#define QERR_DEVICE_NO_HOTPLUG \ "{ 'class': 'DeviceNoHotplug', 'data': { 'device': %s } }" +#define QERR_DEVICE_NO_STATE \ + "{ 'class': 'DeviceNoState', 'data': { 'device': %s } }" +#define QERR_DUPLICATE_ID \ "{ 'class': 'DuplicateId', 'data': { 'id': %s, 'object': %s } }"
Signature · 1 line
1.7.3.4
PATCH 6/6 qdev: Generate IDs for anonymous devices
In reply to Jan KiszkaIn order to address devices for that the user forgot or is even unable (no_user) to provide an ID, assign an automatically generated one. Such IDs have the format #<number>, thus are outside the name space availing to users. Don't use them for bus naming to avoid any other user-visible change.
--- hw/qdev-properties.c | 2 +- hw/qdev.c | 25 +++++++++++++------------ hw/qdev.h | 1 + 3 files changed, 15 insertions(+), 13 deletions(-)
hw/qdev-properties.c +1 -1
@@ -682,7 +682,7 @@ int qdev_prop_set_drive(DeviceState *dev, const char *name, BlockDriverState *vaif (res <0 ) {error_report ("Can't attach drive %s to %s.%s: %s" ,bdrv_get_device_name (value), - dev->id ? dev->id : dev->info->name, + dev->id != dev->auto_id ? dev->id : dev->info->name, name,strerror (-res));return -1 ; }
hw/qdev.c +13 -12
@@ -85,6 +85,7 @@ static DeviceInfo *qdev_find_info(BusInfo *bus_info, const char *name)static DeviceState *qdev_create_from_info (BusState *bus,DeviceInfo *info) { +static unsigned int auto_id;DeviceState *dev;assert (bus->info == info->bus_info);
@@ -94,6 +95,8 @@ static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info)qdev_prop_set_defaults (dev, dev->info->props);qdev_prop_set_defaults (dev, dev->parent_bus->info->props);qdev_prop_set_globals (dev); +snprintf (dev->auto_id,sizeof (dev->auto_id),"#%u" , ++auto_id); + dev->id = dev->auto_id;QLIST_INSERT_HEAD (&bus->children, dev, sibling);if (qdev_hotplug) {assert (bus->allow_hotplug);
@@ -574,8 +577,9 @@ DeviceState *qdev_find_recursive(BusState *bus, const char *id)BusState *child; QLIST_FOREACH(dev, &bus->children, sibling) { -if (dev->id &&strcmp (dev->id, id) ==0 ) +if (strcmp (dev->id, id) ==0 ) {return dev; + } QLIST_FOREACH(child, &dev->child_bus, sibling) { ret =qdev_find_recursive (child, id);if (ret) {
@@ -591,8 +595,8 @@ static void qbus_list_bus(DeviceState *dev)BusState *child;const char *sep =" " ; -error_printf ("child busses at \"%s\":" , - dev->id ? dev->id : dev->info->name); +error_printf ("child busses at \"%s\"/\"%s\":" , + dev->info->name, dev->id); QLIST_FOREACH(child, &dev->child_bus, sibling) {error_printf ("%s\"%s\"" , sep, child->name); sep =", " ;
@@ -607,9 +611,7 @@ static void qbus_list_dev(BusState *bus)error_printf ("devices at \"%s\":" , bus->name); QLIST_FOREACH(dev, &bus->children, sibling) { -error_printf ("%s\"%s\"" , sep, dev->info->name); -if (dev->id) -error_printf ("/\"%s\"" , dev->id); +error_printf ("%s\"%s\"/\"%s\"" , sep, dev->info->name, dev->id); sep =", " ; }error_printf ("\n" );
@@ -638,7 +640,7 @@ static DeviceState *qbus_find_dev(BusState *bus, char *elem)* (3) driver alias, if present */ QLIST_FOREACH(dev, &bus->children, sibling) { -if (dev->id &&strcmp (dev->id, elem) ==0 ) { +if (strcmp (dev->id, elem) ==0 ) {return dev; } }
@@ -754,8 +756,8 @@ void qbus_create_inplace(BusState *bus, BusInfo *info,if (name) {/* use supplied name */ bus->name =g_strdup (name); - }else if (parent && parent->id) { -/* parent device has id -> use it for bus name */ + }else if (parent && parent->id != parent->auto_id) { +/* parent device has user-assigned id -> use it for bus name */ len =strlen (parent->id) +16 ; buf =g_malloc (len);snprintf (buf, len,"%s.%d" , parent->id, parent->num_child_bus);
@@ -850,8 +852,7 @@ static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *props,static void qdev_print (Monitor *mon,DeviceState *dev,int indent) {BusState *child; -qdev_printf ("dev: %s, id \"%s\"\n" , dev->info->name, - dev->id ? dev->id :"" ); +qdev_printf ("dev: %s, id \"%s\"\n" , dev->info->name, dev->id); indent +=2 ;if (dev->num_gpio_in) {qdev_printf ("gpio-in %d\n" , dev->num_gpio_in);
@@ -1196,7 +1197,7 @@ int do_device_show(Monitor *mon, const QDict *qdict, QObject **ret_data) name =g_malloc (name_len);snprintf (name, name_len,"%s" , dev->info->name); *ret_data =qobject_from_jsonf ("{ 'device': %s, 'id': %s, 'version': %d }" , - name, dev->id ? :"" , vmsd->version_id); + name, dev->id, vmsd->version_id);g_free (name); qlist =qlist_new ();parse_vmstate (vmsd, dev, qlist,qdict_get_try_bool (qdict,"full" , false));
hw/qdev.h +1 -0
@@ -31,6 +31,7 @@ enum {so that it can be embedded in individual device state structures. */ struct DeviceState {const char *id; +char auto_id[16 ];enum DevState state;QemuOpts *opts;int hotplugged;
Signature · 1 line
1.7.3.4
Re: [Qemu-devel] [PATCH 6/6] qdev: Generate IDs for anonymous devices
Quoted 5 lines · Jan Kiszka
In order to address devices for that the user forgot or is even unable (
no_user) to provide an ID, assign an automatically generated one. Such IDs have the format #<number>, thus are outside the name space availing to users. Don't use them for bus naming to avoid any other user-visible change.
I don't think this is a very nice approach. Why not eliminate anonymous devices entirely and use a parent derived name for devices that are not created by the user?
Regards,
Anthony Liguori
Quoted 127 lines
CC Markus Armbruster<[email protected]>Signed-off-by Jan Kiszka<[email protected]>--- hw/qdev-properties.c | 2 +- hw/qdev.c | 25 +++++++++++++------------ hw/qdev.h | 1 + 3 files changed, 15 insertions(+), 13 deletions(-)hw/qdev-properties.c +1
-1@@ -682,7 +682,7 @@ int qdev_prop_set_drive(DeviceState *dev, const char *name, BlockDriverState *vaif (res<0 ) {error_report ("Can't attach drive %s to %s.%s: %s" ,bdrv_get_device_name (value), - dev->id ? dev->id : dev->info->name, + dev->id != dev->auto_id ? dev->id : dev->info->name, name,strerror (-res));return -1 ; }hw/qdev.c +13
-12@@ -85,6 +85,7 @@ static DeviceInfo *qdev_find_info(BusInfo *bus_info, const char *name)static DeviceState *qdev_create_from_info (BusState *bus,DeviceInfo *info) { +static unsigned int auto_id;DeviceState *dev;assert (bus->info == info->bus_info);@@ -94,6 +95,8 @@ static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info)qdev_prop_set_defaults (dev, dev->info->props);qdev_prop_set_defaults (dev, dev->parent_bus->info->props);qdev_prop_set_globals (dev); +snprintf (dev->auto_id,sizeof (dev->auto_id),"#%u" , ++auto_id); + dev->id = dev->auto_id;QLIST_INSERT_HEAD (&bus->children, dev, sibling);if (qdev_hotplug) {assert (bus->allow_hotplug);@@ -574,8 +577,9 @@ DeviceState *qdev_find_recursive(BusState *bus, const char *id)BusState *child; QLIST_FOREACH(dev,&bus->children, sibling) { -if (dev->id&&strcmp (dev->id, id) ==0 ) +if (strcmp (dev->id, id) ==0 ) {return dev; + } QLIST_FOREACH(child,&dev->child_bus, sibling) { ret =qdev_find_recursive (child, id);if (ret) {@@ -591,8 +595,8 @@ static void qbus_list_bus(DeviceState *dev)BusState *child;const char *sep =" " ; -error_printf ("child busses at \"%s\":" , - dev->id ? dev->id : dev->info->name); +error_printf ("child busses at \"%s\"/\"%s\":" , + dev->info->name, dev->id); QLIST_FOREACH(child,&dev->child_bus, sibling) {error_printf ("%s\"%s\"" , sep, child->name); sep =", " ;@@ -607,9 +611,7 @@ static void qbus_list_dev(BusState *bus)error_printf ("devices at \"%s\":" , bus->name); QLIST_FOREACH(dev,&bus->children, sibling) { -error_printf ("%s\"%s\"" , sep, dev->info->name); -if (dev->id) -error_printf ("/\"%s\"" , dev->id); +error_printf ("%s\"%s\"/\"%s\"" , sep, dev->info->name, dev->id); sep =", " ; }error_printf ("\n" );@@ -638,7 +640,7 @@ static DeviceState *qbus_find_dev(BusState *bus, char *elem)* (3) driver alias, if present */ QLIST_FOREACH(dev,&bus->children, sibling) { -if (dev->id&&strcmp (dev->id, elem) ==0 ) { +if (strcmp (dev->id, elem) ==0 ) {return dev; } }@@ -754,8 +756,8 @@ void qbus_create_inplace(BusState *bus, BusInfo *info,if (name) {/* use supplied name */ bus->name =g_strdup (name); - }else if (parent&& parent->id) { -/* parent device has id -> use it for bus name */ + }else if (parent&& parent->id != parent->auto_id) { +/* parent device has user-assigned id -> use it for bus name */ len =strlen (parent->id) +16 ; buf =g_malloc (len);snprintf (buf, len,"%s.%d" , parent->id, parent->num_child_bus);@@ -850,8 +852,7 @@ static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *props,static void qdev_print (Monitor *mon,DeviceState *dev,int indent) {BusState *child; -qdev_printf ("dev: %s, id \"%s\"\n" , dev->info->name, - dev->id ? dev->id :"" ); +qdev_printf ("dev: %s, id \"%s\"\n" , dev->info->name, dev->id); indent +=2 ;if (dev->num_gpio_in) {qdev_printf ("gpio-in %d\n" , dev->num_gpio_in);@@ -1196,7 +1197,7 @@ int do_device_show(Monitor *mon, const QDict *qdict, QObject **ret_data) name =g_malloc (name_len);snprintf (name, name_len,"%s" , dev->info->name); *ret_data =qobject_from_jsonf ("{ 'device': %s, 'id': %s, 'version': %d }" , - name, dev->id ? :"" , vmsd->version_id); + name, dev->id, vmsd->version_id);g_free (name); qlist =qlist_new ();parse_vmstate (vmsd, dev, qlist,qdict_get_try_bool (qdict,"full" , false));hw/qdev.h +1
-0@@ -31,6 +31,7 @@ enum {so that it can be embedded in individual device state structures. */ struct DeviceState {const char *id; +char auto_id[16 ];enum DevState state;QemuOpts *opts;int hotplugged;
Re: [Qemu-devel] [PATCH 6/6] qdev: Generate IDs for anonymous devices
Quoted 10 lines · Anthony Liguori
Quoted 5 lines · Jan Kiszka
In order to address devices for that the user forgot or is even unable (
no_user) to provide an ID, assign an automatically generated one. Such IDs have the format #<number>, thus are outside the name space availing to users. Don't use them for bus naming to avoid any other user-visible change.I don't think this is a very nice approach. Why not eliminate anonymous devices entirely and use a parent derived name for devices that are not created by the user?
This eliminates anonymous devices completely. So I guess you are asking for a different naming scheme, something like <parent-id>.child#<no> e.g.? Well, we would end up with fairly long names when a complete hierarchy is anonymous. What would be the benefit?
I'm really just looking for some simple, temporary workaround without touching the existing fragile naming scheme. What we really need is full path addressing, but that without preserving all the legacy.
Jan
Re: [Qemu-devel] [PATCH 6/6] qdev: Generate IDs for anonymous devices
Quoted 8 lines · Jan Kiszka
Quoted 7 lines · Anthony Liguori
Quoted 5 lines · Jan Kiszka
In order to address devices for that the user forgot or is even unable (
no_user) to provide an ID, assign an automatically generated one. Such IDs have the format #<number>, thus are outside the name space availing to users. Don't use them for bus naming to avoid any other user-visible change.
Quoted 8 lines
Quoted 3 lines
I don't think this is a very nice approach. Why not eliminate anonymous devices entirely and use a parent derived name for devices that are not created by the user?
This eliminates anonymous devices completely. So I guess you are asking for a different naming scheme, something like<parent-id>.child#<no> e.g.? Well, we would end up with fairly long names when a complete hierarchy is anonymous. What would be the benefit?
No, I'm saying that whenever a device is created, it should be given a non-random name. IOW, the names of these devices should be stable.
Quoted 3 lines
I'm really just looking for some simple, temporary workaround without touching the existing fragile naming scheme. What we really need is full path addressing, but that without preserving all the legacy.
Yeah, I understand, and I hesitated making any grander suggestions here, but I'm not sure how much work it would be to just remove any caller that passes NULL for ID and replace it with something more meaningful. I think that's a helpful clean up long term no matter what.
Regards,
Anthony Liguori
Quoted 3 lines
Jan
Re: [Qemu-devel] [PATCH 6/6] qdev: Generate IDs for anonymous devices
Quoted 21 lines · Anthony Liguori
Quoted 8 lines · Jan Kiszka
Quoted 7 lines · Anthony Liguori
Quoted 5 lines · Jan Kiszka
In order to address devices for that the user forgot or is even unable (
no_user) to provide an ID, assign an automatically generated one. Such IDs have the format #<number>, thus are outside the name space availing to users. Don't use them for bus naming to avoid any other user-visible change.Quoted 8 lines
Quoted 3 lines
I don't think this is a very nice approach. Why not eliminate anonymous devices entirely and use a parent derived name for devices that are not created by the user?
This eliminates anonymous devices completely. So I guess you are asking for a different naming scheme, something like<parent-id>.child#<no> e.g.? Well, we would end up with fairly long names when a complete hierarchy is anonymous. What would be the benefit?
No, I'm saying that whenever a device is created, it should be given a non-random name. IOW, the names of these devices should be stable.
Quoted 8 lines
Quoted 3 lines
I'm really just looking for some simple, temporary workaround without touching the existing fragile naming scheme. What we really need is full path addressing, but that without preserving all the legacy.
Yeah, I understand, and I hesitated making any grander suggestions here, but I'm not sure how much work it would be to just remove any caller that passes NULL for ID and replace it with something more meaningful. I think that's a helpful clean up long term no matter what.
That won't solve the problem of finding a unique device name. If we want to derive it from stable device properties (bus addresses etc.), we first of all have to define them for all types of devices. And that's basically were the discussion exploded last year IIRC.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [Qemu-devel] [PATCH 6/6] qdev: Generate IDs for anonymous devices
Quoted 31 lines · Jan Kiszka
Quoted 21 lines · Anthony Liguori
Quoted 8 lines · Jan Kiszka
Quoted 7 lines · Anthony Liguori
Quoted 5 lines · Jan Kiszka
In order to address devices for that the user forgot or is even unable (
no_user) to provide an ID, assign an automatically generated one. Such IDs have the format #<number>, thus are outside the name space availing to users. Don't use them for bus naming to avoid any other user-visible change.Quoted 8 lines
Quoted 3 lines
I don't think this is a very nice approach. Why not eliminate anonymous devices entirely and use a parent derived name for devices that are not created by the user?
This eliminates anonymous devices completely. So I guess you are asking for a different naming scheme, something like<parent-id>.child#<no> e.g.? Well, we would end up with fairly long names when a complete hierarchy is anonymous. What would be the benefit?
No, I'm saying that whenever a device is created, it should be given a non-random name. IOW, the names of these devices should be stable.
Quoted 8 lines
Quoted 3 lines
I'm really just looking for some simple, temporary workaround without touching the existing fragile naming scheme. What we really need is full path addressing, but that without preserving all the legacy.
Yeah, I understand, and I hesitated making any grander suggestions here, but I'm not sure how much work it would be to just remove any caller that passes NULL for ID and replace it with something more meaningful. I think that's a helpful clean up long term no matter what.
Quoted 5 lines
That won't solve the problem of finding a unique device name. If we want to derive it from stable device properties (bus addresses etc.), we first of all have to define them for all types of devices. And that's basically were the discussion exploded last year IIRC.
Why not use the OpenFirmware naming that we already have for some devices instead of inventing something new?
--
Gleb.
Re: [Qemu-devel] [PATCH 6/6] qdev: Generate IDs for anonymous devices
Quoted 32 lines · Gleb Natapov
Quoted 31 lines · Jan Kiszka
Quoted 29 lines · Anthony Liguori
Quoted 8 lines · Jan Kiszka
Quoted 7 lines · Anthony Liguori
Quoted 5 lines · Jan Kiszka
In order to address devices for that the user forgot or is even unable (
no_user) to provide an ID, assign an automatically generated one. Such IDs have the format #<number>, thus are outside the name space availing to users. Don't use them for bus naming to avoid any other user-visible change.Quoted 8 lines
Quoted 3 lines
I don't think this is a very nice approach. Why not eliminate anonymous devices entirely and use a parent derived name for devices that are not created by the user?
This eliminates anonymous devices completely. So I guess you are asking for a different naming scheme, something like<parent-id>.child#<no> e.g.? Well, we would end up with fairly long names when a complete hierarchy is anonymous. What would be the benefit?
No, I'm saying that whenever a device is created, it should be given a non-random name. IOW, the names of these devices should be stable.
Quoted 3 lines
I'm really just looking for some simple, temporary workaround without touching the existing fragile naming scheme. What we really need is full path addressing, but that without preserving all the legacy.
Yeah, I understand, and I hesitated making any grander suggestions here, but I'm not sure how much work it would be to just remove any caller that passes NULL for ID and replace it with something more meaningful. I think that's a helpful clean up long term no matter what.
Quoted 7 lines
Quoted 5 lines
That won't solve the problem of finding a unique device name. If we want to derive it from stable device properties (bus addresses etc.), we first of all have to define them for all types of devices. And that's basically were the discussion exploded last year IIRC.
Why not use the OpenFirmware naming that we already have for some devices instead of inventing something new?
Because I do not want to establish any path names before QOM conversion (including potential device reorganization) has been started. Specifically as I do not need naming for "some" devices, but for all.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [Qemu-devel] [PATCH 6/6] qdev: Generate IDs for anonymous devices
Quoted 38 lines · Jan Kiszka
Quoted 37 lines · Gleb Natapov
Quoted 36 lines · Jan Kiszka
Quoted 21 lines · Anthony Liguori
Quoted 8 lines · Jan Kiszka
Quoted 7 lines · Anthony Liguori
Quoted 5 lines · Jan Kiszka
In order to address devices for that the user forgot or is even unable (
no_user) to provide an ID, assign an automatically generated one. Such IDs have the format #<number>, thus are outside the name space availing to users. Don't use them for bus naming to avoid any other user-visible change.Quoted 8 lines
Quoted 3 lines
I don't think this is a very nice approach. Why not eliminate anonymous devices entirely and use a parent derived name for devices that are not created by the user?
This eliminates anonymous devices completely. So I guess you are asking for a different naming scheme, something like<parent-id>.child#<no> e.g.? Well, we would end up with fairly long names when a complete hierarchy is anonymous. What would be the benefit?
No, I'm saying that whenever a device is created, it should be given a non-random name. IOW, the names of these devices should be stable.
Quoted 8 lines
Quoted 3 lines
I'm really just looking for some simple, temporary workaround without touching the existing fragile naming scheme. What we really need is full path addressing, but that without preserving all the legacy.
Yeah, I understand, and I hesitated making any grander suggestions here, but I'm not sure how much work it would be to just remove any caller that passes NULL for ID and replace it with something more meaningful. I think that's a helpful clean up long term no matter what.
That won't solve the problem of finding a unique device name. If we want to derive it from stable device properties (bus addresses etc.), we first of all have to define them for all types of devices. And that's basically were the discussion exploded last year IIRC.
Quoted 5 lines
Quoted 2 lines
Why not use the OpenFirmware naming that we already have for some devices instead of inventing something new?
Because I do not want to establish any path names before QOM conversion (including potential device reorganization) has been started.
In theory device paths are dictated by HW topology, not today's flavor of QEMU object model.
Quoted 2 lines
Specifically as I do not need naming for "some" devices, but for all.
It can be extended. We already have three types of device naming. One is used in qdev, another is used for migration and yet another one for passing device names to firmware. We should converge to a single one :)
--
Gleb.
Re: [Qemu-devel] [PATCH 6/6] qdev: Generate IDs for anonymous devices
Quoted 39 lines · Gleb Natapov
Quoted 38 lines · Jan Kiszka
Quoted 37 lines · Gleb Natapov
Quoted 36 lines · Jan Kiszka
Quoted 21 lines · Anthony Liguori
Quoted 8 lines · Jan Kiszka
Quoted 7 lines · Anthony Liguori
Quoted 5 lines · Jan Kiszka
In order to address devices for that the user forgot or is even unable (
no_user) to provide an ID, assign an automatically generated one. Such IDs have the format #<number>, thus are outside the name space availing to users. Don't use them for bus naming to avoid any other user-visible change.Quoted 8 lines
Quoted 3 lines
I don't think this is a very nice approach. Why not eliminate anonymous devices entirely and use a parent derived name for devices that are not created by the user?
This eliminates anonymous devices completely. So I guess you are asking for a different naming scheme, something like<parent-id>.child#<no> e.g.? Well, we would end up with fairly long names when a complete hierarchy is anonymous. What would be the benefit?
No, I'm saying that whenever a device is created, it should be given a non-random name. IOW, the names of these devices should be stable.
Quoted 8 lines
Quoted 3 lines
I'm really just looking for some simple, temporary workaround without touching the existing fragile naming scheme. What we really need is full path addressing, but that without preserving all the legacy.
Yeah, I understand, and I hesitated making any grander suggestions here, but I'm not sure how much work it would be to just remove any caller that passes NULL for ID and replace it with something more meaningful. I think that's a helpful clean up long term no matter what.
That won't solve the problem of finding a unique device name. If we want to derive it from stable device properties (bus addresses etc.), we first of all have to define them for all types of devices. And that's basically were the discussion exploded last year IIRC.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Why not use the OpenFirmware naming that we already have for some devices instead of inventing something new?
Because I do not want to establish any path names before QOM conversion (including potential device reorganization) has been started.
In theory device paths are dictated by HW topology, not today's flavor of QEMU object model.
There will be changes in the object composition, but predicting them today and modeling this on top of current qdev is nothing I want to try.
Quoted 6 lines
Quoted 3 lines
Specifically as I do not need naming for "some" devices, but for all.
It can be extended. We already have three types of device naming. One is used in qdev, another is used for migration and yet another one for passing device names to firmware. We should converge to a single one :)
Yes, but that's beyond what this patch set can achieve or what will happen in foreseeable time.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 3 lines · Jan Kiszka
More than one year ago I posted some patches to add a monitor command callend
device_show. The purpose of that command is to dump the state of some qdev device based on its vmstate.
I have a series that does the same thing as this in a totally different way. Instead of a VMState interpreter, it converts all marshalling to go through a Visitor interface. This makes it extensible to devices that don't currently support VMState.
Regards,
Anthony Liguori
Quoted 55 lines
To improve the usability of that interface, the previous series also tried to create a canonical qdev tree path name format and even added monitor command expansion. That format created quite a few discussions, and we never came to some conclusion.
As
device_showis still a useful tool for debugging but qdev structuring and addressing may significantly change in the near future, I decided to reanimate those patches while avoiding almost any change of the addressing scheme. The only one I propose is automatic ID assignment for anonymous devices so that any qdev device is in principle addressable (e.g. APIC and IO-APIC on x86).As back then,
device_showremains HMP-only to avoid any stable ABI issues around QMP.CC Luiz Capitulino<[email protected]>CC Markus Armbruster<[email protected]>Jan Kiszka (6):
monitor: return length of printed string via monitor_[v]printf Add base64 encoder/decoder
QMP: Reserve namespace for complex object classes
QMP: Add QBuffer
monitor: Add basic device state visualization
qdev: Generate IDs for anonymous devicesMakefile | 2 +- Makefile.objs | 4 +- QMP/qmp-spec.txt | 24 ++++- base64.c | 202 +++++++++++++++++++++++++++++++++++++ base64.h | 19 ++++ check-qbuffer.c | 172 ++++++++++++++++++++++++++++++++ configure | 2 +- hmp-commands.hx | 16 +++ hw/hw.h | 2 + hw/qdev-properties.c | 2 +- hw/qdev.c | 271 ++++++++++++++++++++++++++++++++++++++++++++++++-- hw/qdev.h | 3 + monitor.c | 23 +++-- monitor.h | 4 +- qbuffer.c | 117 ++++++++++++++++++++++ qbuffer.h | 33 ++++++ qemu-tool.c | 6 +- qerror.c | 4 + qerror.h | 3 + qjson.c | 15 +++ qobject.h | 1 + 21 files changed, 894 insertions(+), 31 deletions(-)create mode 100644
base64.c
create mode 100644base64.h
create mode 100644check-qbuffer.c
create mode 100644qbuffer.c
create mode 100644qbuffer.h
Quoted 9 lines · Anthony Liguori
Quoted 3 lines · Jan Kiszka
More than one year ago I posted some patches to add a monitor command callend
device_show. The purpose of that command is to dump the state of some qdev device based on its vmstate.I have a series that does the same thing as this in a totally different way. Instead of a VMState interpreter, it converts all marshalling to go through a Visitor interface. This makes it extensible to devices that don't currently support VMState.
For obtaining a raw picture of some device state, there is still gdb. What this feature is targeting at is a refined view, something VMState already represents as it (in the absence of bugs) contains the complete persistent state, and only that.
Once we have QOM in place and also sorted out how VMState 2.0 may look like and how it can be extracted from or expressed within the device model, we will probably change the internals of this feature again.
Jan
Quoted 16 lines · On Fri, 26 Aug 2011 16:48:10 +0200 Jan Kiszka <[email protected]> wrote:
More than one year ago I posted some patches to add a monitor command callend
device_show. The purpose of that command is to dump the state of some qdev device based on its vmstate.To improve the usability of that interface, the previous series also tried to create a canonical qdev tree path name format and even added monitor command expansion. That format created quite a few discussions, and we never came to some conclusion.
As
device_showis still a useful tool for debugging but qdev structuring and addressing may significantly change in the near future, I decided to reanimate those patches while avoiding almost any change of the addressing scheme. The only one I propose is automatic ID assignment for anonymous devices so that any qdev device is in principle addressable (e.g. APIC and IO-APIC on x86).
Quoted 5 lines
As back then,
device_showremains HMP-only to avoid any stable ABI issues around QMP.CC Luiz Capitulino <[email protected]>CC Markus Armbruster <[email protected]>
This looks good to me and I'm willing to apply it. Only issue I'd like to see resolved is the base64 encoder/decoder. This series introduces a new one, while the guest agent uses glib's.
I think we should choose one of them and stick to it.
Any other objections apart from that? Markus?
Quoted 16 lines · Jan Kiszka
More than one year ago I posted some patches to add a monitor command callend
device_show. The purpose of that command is to dump the state of some qdev device based on its vmstate.To improve the usability of that interface, the previous series also tried to create a canonical qdev tree path name format and even added monitor command expansion. That format created quite a few discussions, and we never came to some conclusion.
As
device_showis still a useful tool for debugging but qdev structuring and addressing may significantly change in the near future, I decided to reanimate those patches while avoiding almost any change of the addressing scheme. The only one I propose is automatic ID assignment for anonymous devices so that any qdev device is in principle addressable (e.g. APIC and IO-APIC on x86).
Quoted 2 lines
As back then,
device_showremains HMP-only to avoid any stable ABI issues around QMP.
I'm afraid that won't be enough to stop people
scripting this command - libvirt accessed
HMP for years.
On the other hand, no QMP command means e.g.
libvirt users don't get any benefit from this.
What I think will solve these problems, for both HMP and QMP, is an explicit 'debug_unstable' or 'debug_unsupported' command that will expose all kind of debugging functionality making it
very explicit that it's an unsupported debugging utility.
Proposed syntax:
debug_unstable <subcommand> <options>
Example:
debug_unstable device_show -all
Signature · 1 line
MSt
Quoted 32 lines · Michael S. Tsirkin
Quoted 16 lines · Jan Kiszka
More than one year ago I posted some patches to add a monitor command callend
device_show. The purpose of that command is to dump the state of some qdev device based on its vmstate.To improve the usability of that interface, the previous series also tried to create a canonical qdev tree path name format and even added monitor command expansion. That format created quite a few discussions, and we never came to some conclusion.
As
device_showis still a useful tool for debugging but qdev structuring and addressing may significantly change in the near future, I decided to reanimate those patches while avoiding almost any change of the addressing scheme. The only one I propose is automatic ID assignment for anonymous devices so that any qdev device is in principle addressable (e.g. APIC and IO-APIC on x86).Quoted 2 lines
As back then,
device_showremains HMP-only to avoid any stable ABI issues around QMP.I'm afraid that won't be enough to stop people
scripting this command - libvirt accessed
HMP for years.On the other hand, no QMP command means e.g.
libvirt users don't get any benefit from this.What I think will solve these problems, for both HMP and QMP, is an explicit '
debug_unstable' or 'debug_unsupported' command that will expose all kind of debugging functionality making it
very explicit that it's an unsupported debugging utility.
Quoted 7 lines
Proposed syntax:
debug_unstable<subcommand> <options>Example:
debug_unstabledevice_show-all
For HMP, this would needlessly complicate the user interface, nothing I would support. People scripting things on top of HMP are generally doing this on their own risk and cannot expect output stability.
device_show is like info qtree: the output will naturally change as the emulated hardware evolves, information is added/removed, or we simply improve the layout. Recent changes on info network are an example for the latter.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 21 lines · Jan Kiszka
Quoted 12 lines · Michael S. Tsirkin
I'm afraid that won't be enough to stop people
scripting this command - libvirt accessed
HMP for years.On the other hand, no QMP command means e.g.
libvirt users don't get any benefit from this.What I think will solve these problems, for both HMP and QMP, is an explicit '
debug_unstable' or 'debug_unsupported' command that will expose all kind of debugging functionality making it
very explicit that it's an unsupported debugging utility.Quoted 7 lines
Proposed syntax:
debug_unstable<subcommand> <options>
Example:
debug_unstabledevice_show-all
Quoted 8 lines
For HMP, this would needlessly complicate the user interface, nothing I would support. People scripting things on top of HMP are generally doing this on their own risk and cannot expect output stability.
device_showis like info qtree: the output will naturally change as the emulated hardware evolves, information is added/removed, or we simply improve the layout. Recent changes on info network are an example for the latter.
Yeah, I'm not worried about stability. HMP commands that aren't exposed as QMP commands are inherently unstable and should not be scripted to.
I'm still contemplating how we go about doing this. This series introduces a couple new concepts like QMP class hinting anonymous IDs. I'm concerned that we'll further complicate the need to support backwards compatibility.
Would the command be useful if you couldn't address devices? If it just dumped the full machine state all at once? That would at least obviate the need to add anonymous IDs.
Regards,
Anthony Liguori
Quoted 3 lines
Jan
Quoted 4 lines · Anthony Liguori
I'm still contemplating how we go about doing this. This series introduces a couple new concepts like QMP class hinting anonymous IDs. I'm concerned that we'll further complicate the need to support backwards compatibility.
Anonymous IDs must not be considered stable. If you prefer, we could try to filter them out for QMP use. Need to check though if there is a good location to catch them, but the rule is trivial.
I will also happily drop anonymous IDs again once we have converted all devices to stable QOM full path addressing. But that will simply take too much time to wait for it I'm afraid.
Quoted 4 lines
Would the command be useful if you couldn't address devices? If it just dumped the full machine state all at once? That would at least obviate the need to add anonymous IDs.
Theoretically usable, but extremely unhandy. I would not like so see such an interface exposed to users.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 15 lines · Jan Kiszka
Quoted 4 lines · Anthony Liguori
I'm still contemplating how we go about doing this. This series introduces a couple new concepts like QMP class hinting anonymous IDs. I'm concerned that we'll further complicate the need to support backwards compatibility.
Anonymous IDs must not be considered stable. If you prefer, we could try to filter them out for QMP use. Need to check though if there is a good location to catch them, but the rule is trivial.
I will also happily drop anonymous IDs again once we have converted all devices to stable QOM full path addressing. But that will simply take too much time to wait for it I'm afraid.
Quoted 1 line
Quoted 6 lines
Quoted 3 lines
Would the command be useful if you couldn't address devices? If it just dumped the full machine state all at once? That would at least obviate the need to add anonymous IDs.
Theoretically usable, but extremely unhandy. I would not like so see such an interface exposed to users.
What about just taking the device type (iow the savevm section name)?
In most scenarios, it's probably easier for a user and will still only have a single match.
Regards,
Anthony Liguori
Quoted 3 lines
Jan
Quoted 20 lines · Anthony Liguori
Quoted 19 lines · Jan Kiszka
Quoted 4 lines · Anthony Liguori
I'm still contemplating how we go about doing this. This series introduces a couple new concepts like QMP class hinting anonymous IDs. I'm concerned that we'll further complicate the need to support backwards compatibility.
Anonymous IDs must not be considered stable. If you prefer, we could try to filter them out for QMP use. Need to check though if there is a good location to catch them, but the rule is trivial.
I will also happily drop anonymous IDs again once we have converted all devices to stable QOM full path addressing. But that will simply take too much time to wait for it I'm afraid.
Quoted 4 lines
Would the command be useful if you couldn't address devices? If it just dumped the full machine state all at once? That would at least obviate the need to add anonymous IDs.
Quoted 7 lines
Quoted 2 lines
Theoretically usable, but extremely unhandy. I would not like so see such an interface exposed to users.
What about just taking the device type (iow the savevm section name)?
In most scenarios, it's probably easier for a user and will still only have a single match.
This naming is not yet exposed via any user interface. We would have to extend info qtree, not sure if we want this...
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 26 lines · Anthony Liguori
Quoted 25 lines · Jan Kiszka
Quoted 12 lines · Michael S. Tsirkin
I'm afraid that won't be enough to stop people
scripting this command - libvirt accessed
HMP for years.On the other hand, no QMP command means e.g.
libvirt users don't get any benefit from this.What I think will solve these problems, for both HMP and QMP, is an explicit '
debug_unstable' or 'debug_unsupported' command that will expose all kind of debugging functionality making it
very explicit that it's an unsupported debugging utility.Quoted 7 lines
Proposed syntax:
debug_unstable<subcommand> <options>
Example:
debug_unstabledevice_show-allFor HMP, this would needlessly complicate the user interface, nothing I would support. People scripting things on top of HMP are generally doing this on their own risk and cannot expect output stability.
Quoted 8 lines
Quoted 4 lines
device_showis like info qtree: the output will naturally change as the emulated hardware evolves, information is added/removed, or we simply improve the layout. Recent changes on info network are an example for the latter.Yeah, I'm not worried about stability. HMP commands that aren't exposed as QMP commands are inherently unstable and should not be scripted to.
They are also not accessible when using libvirt, right? Which means almost all cases I care about: debugging on my laptop I can easily attach with gdb and inspect state.
Quoted 4 lines
I'm still contemplating how we go about doing this. This series introduces a couple new concepts like QMP class hinting anonymous IDs. I'm concerned that we'll further complicate the need to support backwards compatibility.
Dazed and confused. Above you stated these commands are inherently unstable and no need to support?
Quoted 11 lines
Would the command be useful if you couldn't address devices? If it just dumped the full machine state all at once? That would at least obviate the need to add anonymous IDs.
Regards,
Anthony Liguori
Quoted 3 lines
Jan
Quoted 32 lines · Michael S. Tsirkin
Quoted 31 lines · Anthony Liguori
Quoted 29 lines · Jan Kiszka
Quoted 12 lines · Michael S. Tsirkin
I'm afraid that won't be enough to stop people
scripting this command - libvirt accessed
HMP for years.On the other hand, no QMP command means e.g.
libvirt users don't get any benefit from this.What I think will solve these problems, for both HMP and QMP, is an explicit '
debug_unstable' or 'debug_unsupported' command that will expose all kind of debugging functionality making it
very explicit that it's an unsupported debugging utility.Quoted 7 lines
Proposed syntax:
debug_unstable<subcommand> <options>
Example:
debug_unstabledevice_show-allFor HMP, this would needlessly complicate the user interface, nothing I would support. People scripting things on top of HMP are generally doing this on their own risk and cannot expect output stability.
device_showis like info qtree: the output will naturally change as the emulated hardware evolves, information is added/removed, or we simply improve the layout. Recent changes on info network are an example for the latter.
Quoted 5 lines
Quoted 3 lines
Yeah, I'm not worried about stability. HMP commands that aren't exposed as QMP commands are inherently unstable and should not be scripted to.
They are also not accessible when using libvirt, right?
$ virsh human-monitor-passthrough GuestName device_show foo
Should work.
Quoted 10 lines
Which means almost all cases I care about: debugging on my laptop I can easily attach with gdb and inspect state.
Quoted 4 lines
I'm still contemplating how we go about doing this. This series introduces a couple new concepts like QMP class hinting anonymous IDs. I'm concerned that we'll further complicate the need to support backwards compatibility.
Dazed and confused. Above you stated these commands are inherently unstable and no need to support?
Right, my concern is that the unstable command results in changes that are visible in stable interfaces. As Jan suggested, we could try to hide this from those commands but that seems a bit ugly to me.
Regards,
Anthony Liguori
Quoted 12 lines
Quoted 11 lines
Would the command be useful if you couldn't address devices? If it just dumped the full machine state all at once? That would at least obviate the need to add anonymous IDs.
Regards,
Anthony Liguori
Quoted 3 lines
Jan
Quoted 37 lines · Anthony Liguori
Quoted 36 lines · Michael S. Tsirkin
Quoted 34 lines · Anthony Liguori
Quoted 21 lines · Jan Kiszka
Quoted 12 lines · Michael S. Tsirkin
I'm afraid that won't be enough to stop people
scripting this command - libvirt accessed
HMP for years.On the other hand, no QMP command means e.g.
libvirt users don't get any benefit from this.What I think will solve these problems, for both HMP and QMP, is an explicit '
debug_unstable' or 'debug_unsupported' command that will expose all kind of debugging functionality making it
very explicit that it's an unsupported debugging utility.Quoted 7 lines
Proposed syntax:
debug_unstable<subcommand> <options>
Example:
debug_unstabledevice_show-allQuoted 8 lines
For HMP, this would needlessly complicate the user interface, nothing I would support. People scripting things on top of HMP are generally doing this on their own risk and cannot expect output stability.
device_showis like info qtree: the output will naturally change as the emulated hardware evolves, information is added/removed, or we simply improve the layout. Recent changes on info network are an example for the latter.Yeah, I'm not worried about stability. HMP commands that aren't exposed as QMP commands are inherently unstable and should not be scripted to.
Quoted 5 lines
Quoted 1 line
They are also not accessible when using libvirt, right?
$ virsh human-monitor-passthrough GuestName device_show fooShould work.
So how, in the end, will user know it's unsupported? I don't agree with 'all HMP is unstable' as people will use it and will come to depend on it.
What I'm asking is something like 'enable_unsupported_commands', which will expose all kind of stuff.
Could also be extra stuff in existing commands too - e.g. info pci is a natural way to see config space
for devices.
Signature · 1 line
MST
Am 06.09.2011 19:05, schrieb Michael S. Tsirkin:
Quoted 40 lines · Anthony Liguori
Quoted 39 lines · Michael S. Tsirkin
Quoted 37 lines · Anthony Liguori
Quoted 26 lines · Jan Kiszka
Quoted 25 lines · Michael S. Tsirkin
Quoted 12 lines
I'm afraid that won't be enough to stop people
scripting this command - libvirt accessed
HMP for years.On the other hand, no QMP command means e.g.
libvirt users don't get any benefit from this.What I think will solve these problems, for both HMP and QMP, is an explicit '
debug_unstable' or 'debug_unsupported' command that will expose all kind of debugging functionality making it
very explicit that it's an unsupported debugging utility.Quoted 7 lines
Proposed syntax:
debug_unstable<subcommand> <options>
Example:
debug_unstabledevice_show-allFor HMP, this would needlessly complicate the user interface, nothing I would support. People scripting things on top of HMP are generally doing this on their own risk and cannot expect output stability.
Quoted 8 lines
Quoted 4 lines
device_showis like info qtree: the output will naturally change as the emulated hardware evolves, information is added/removed, or we simply improve the layout. Recent changes on info network are an example for the latter.Yeah, I'm not worried about stability. HMP commands that aren't exposed as QMP commands are inherently unstable and should not be scripted to.
They are also not accessible when using libvirt, right?
Quoted 7 lines
Quoted 3 lines
$ virsh human-monitor-passthrough GuestName device_show fooShould work.
So how, in the end, will user know it's unsupported? I don't agree with 'all HMP is unstable' as people will use it and will come to depend on it.
Why unsupported? It's just not a stable API to script against. It's a user interface, not a programming interface. So as long as you use it manually, that's perfectly fine.
Would you expect that virt-manager never changes its GUI because there might be some scripts that try to achieve things by screen scraping? The interface is just not meant for such uses, and if you use it in that way and it breaks with the next version it's your own fault.
Kevin
Quoted 53 lines · Kevin Wolf
Am 06.09.2011 19:05, schrieb Michael S. Tsirkin:
Quoted 40 lines · Anthony Liguori
Quoted 39 lines · Michael S. Tsirkin
Quoted 37 lines · Anthony Liguori
Quoted 26 lines · Jan Kiszka
Quoted 25 lines · Michael S. Tsirkin
Quoted 12 lines
I'm afraid that won't be enough to stop people
scripting this command - libvirt accessed
HMP for years.On the other hand, no QMP command means e.g.
libvirt users don't get any benefit from this.What I think will solve these problems, for both HMP and QMP, is an explicit '
debug_unstable' or 'debug_unsupported' command that will expose all kind of debugging functionality making it
very explicit that it's an unsupported debugging utility.Quoted 7 lines
Proposed syntax:
debug_unstable<subcommand> <options>
Example:
debug_unstabledevice_show-allFor HMP, this would needlessly complicate the user interface, nothing I would support. People scripting things on top of HMP are generally doing this on their own risk and cannot expect output stability.
Quoted 8 lines
Quoted 4 lines
device_showis like info qtree: the output will naturally change as the emulated hardware evolves, information is added/removed, or we simply improve the layout. Recent changes on info network are an example for the latter.Yeah, I'm not worried about stability. HMP commands that aren't exposed as QMP commands are inherently unstable and should not be scripted to.
They are also not accessible when using libvirt, right?
Quoted 7 lines
Quoted 3 lines
$ virsh human-monitor-passthrough GuestName device_show fooShould work.
So how, in the end, will user know it's unsupported? I don't agree with 'all HMP is unstable' as people will use it and will come to depend on it.
Why unsupported? It's just not a stable API to script against. It's a user interface, not a programming interface. So as long as you use it manually, that's perfectly fine.
Quoted 6 lines
Would you expect that virt-manager never changes its GUI because there might be some scripts that try to achieve things by screen scraping? The interface is just not meant for such uses, and if you use it in that way and it breaks with the next version it's your own fault.
Kevin
I certainly think that radically changing a GUI is very bad usability. Screen scarping is a silly example, but documentation does appear e.g. on the web, and GUI changes invalidate it. I won't mention recent examples of user unhappiness - it takes years to live down such trauma.
If we expose qemu internals in a command, that's a very bad idea to give such command to the user, because
1. users will come to depend on the command, whatever you tell them
2. the fact it's there means there is some unaddressed need, so we plaster over it with unsupported commands instead of addressing it properly
But if the command is not for users at all, if it's
for qemu debugging, then exposing internals is a very logical thing. Only problem is - we must make it very very clear which commands are for qemu debugging.
Signature · 1 line
MST
Quoted 4 lines · Michael S. Tsirkin
But if the command is not for users at all, if it's
for qemu debugging, then exposing internals is a very logical thing. Only problem is - we must make it very very clear which commands are for qemu debugging.
This command it also for users, to debug guests.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 9 lines · Jan Kiszka
Quoted 4 lines · Michael S. Tsirkin
But if the command is not for users at all, if it's
for qemu debugging, then exposing internals is a very logical thing. Only problem is - we must make it very very clear which commands are for qemu debugging.This command it also for users, to debug guests.
Jan
Hmm, guest visible state must be stable by definition. So why can't we make the interfaces stable then?
Quoted 3 lines
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Jan Kiszka
Quoted 4 lines · Michael S. Tsirkin
But if the command is not for users at all, if it's
for qemu debugging, then exposing internals is a very logical thing. Only problem is - we must make it very very clear which commands are for qemu debugging.
Quoted 6 lines
Quoted 3 lines
This command it also for users, to debug guests.
Jan
Hmm, guest visible state must be stable by definition. So why can't we make the interfaces stable then?
Because right now how you reference devices cannot be stable.
Going back to a previous thread, what if the command took a qdev class type as a filter?
That would be a stable name, not require anonymous IDs, and would have the property of usually being a single device.
Regards,
Anthony Liguori
Quoted 5 lines
Quoted 4 lines
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
Quoted 15 lines · Anthony Liguori
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Jan Kiszka
Quoted 4 lines · Michael S. Tsirkin
But if the command is not for users at all, if it's
for qemu debugging, then exposing internals is a very logical thing. Only problem is - we must make it very very clear which commands are for qemu debugging.Quoted 6 lines
Quoted 3 lines
This command it also for users, to debug guests.
Jan
Hmm, guest visible state must be stable by definition. So why can't we make the interfaces stable then?
Quoted 7 lines
Because right now how you reference devices cannot be stable.
Going back to a previous thread, what if the command took a qdev class type as a filter?
That would be a stable name, not require anonymous IDs, and would have the property of usually being a single device.
It's surely not usual that there is only a single instance of a device type. That's why my old series introduced (unstable) instance numbering. I refrained for warming those patches up again.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 8 lines · Anthony Liguori
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Jan Kiszka
Quoted 4 lines · Michael S. Tsirkin
But if the command is not for users at all, if it's
for qemu debugging, then exposing internals is a very logical thing. Only problem is - we must make it very very clear which commands are for qemu debugging.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
This command it also for users, to debug guests.
Jan
Hmm, guest visible state must be stable by definition. So why can't we make the interfaces stable then?
Because right now how you reference devices cannot be stable.
For devices that do have IDs, we can support this
on QMP as well then?
Signature · 1 line
MST
Quoted 32 lines · Michael S. Tsirkin
Quoted 31 lines · Anthony Liguori
Quoted 29 lines · Jan Kiszka
Quoted 12 lines · Michael S. Tsirkin
I'm afraid that won't be enough to stop people
scripting this command - libvirt accessed
HMP for years.On the other hand, no QMP command means e.g.
libvirt users don't get any benefit from this.What I think will solve these problems, for both HMP and QMP, is an explicit '
debug_unstable' or 'debug_unsupported' command that will expose all kind of debugging functionality making it
very explicit that it's an unsupported debugging utility.Quoted 7 lines
Proposed syntax:
debug_unstable<subcommand> <options>
Example:
debug_unstabledevice_show-allFor HMP, this would needlessly complicate the user interface, nothing I would support. People scripting things on top of HMP are generally doing this on their own risk and cannot expect output stability.
device_showis like info qtree: the output will naturally change as the emulated hardware evolves, information is added/removed, or we simply improve the layout. Recent changes on info network are an example for the latter.
Quoted 7 lines
Quoted 3 lines
Yeah, I'm not worried about stability. HMP commands that aren't exposed as QMP commands are inherently unstable and should not be scripted to.
They are also not accessible when using libvirt, right? Which means almost all cases I care about: debugging on my laptop I can easily attach with gdb and inspect state.
HMP passthrough or - I bet that's what you rather want - monitor passthrough from gdb.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux