Skip to contentSkip to conversation

Registering buffers with a qdict

Qemu-devel Jan Kiszka 3 participants 9 messages May 7, 2010 – May 10, 2010

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

Hi Luiz,

what is the recommended way of pushing larger buffers (up to 64K so far) into a qdict? QLIST of QINT (one per byte) looks a bit heavy. I thought about hex-encoding the content first (series of "%02X"), then registering it as QSTRING. Or should we introduce a new type, QBUFFER?

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#1 lore raw
Quoted 6 lines · On Fri, 07 May 2010 13:45:03 +0200 Jan Kiszka <[email protected]> wrote:

Hi Luiz,

what is the recommended way of pushing larger buffers (up to 64K so far) into a qdict? QLIST of QINT (one per byte) looks a bit heavy. I thought about hex-encoding the content first (series of "%02X"), then registering it as QSTRING. Or should we introduce a new type, QBUFFER?

I don't think that hex-encoding the contents is so bad if your use case is
very specific and isolated.

On the other hand, I do prefer a QBuffer type, specially because we can
have buffer operations.

author
#2 lore raw
Quoted 5 lines · Luiz Capitulino
Quoted 2 lines · On Fri, 07 May 2010 13:45:03 +0200 Jan Kiszka <[email protected]> wrote:

Hi Luiz,

Quoted 7 lines
Quoted 4 lines

what is the recommended way of pushing larger buffers (up to 64K so far) into a qdict? QLIST of QINT (one per byte) looks a bit heavy. I thought about hex-encoding the content first (series of "%02X"), then registering it as QSTRING. Or should we introduce a new type, QBUFFER?

I don't think that hex-encoding the contents is so bad if your use case is
very specific and isolated.

The focus will be first on visualizing the buffer (user_print), but who knows what happens once the services is also exposed via QMP.

Quoted 3 lines

On the other hand, I do prefer a QBuffer type, specially because we can
have buffer operations.

The q<type>.c files look sufficiently simply, guess I will add a buffer type. Still, hex-encoding is probably the best representation for QMP.

Thanks,
Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#3 lore raw
Quoted 18 lines · On Fri, 07 May 2010 16:21:13 +0200 Jan Kiszka <[email protected]> wrote:
Quoted 5 lines · Luiz Capitulino
Quoted 2 lines · On Fri, 07 May 2010 13:45:03 +0200 Jan Kiszka <[email protected]> wrote:

Hi Luiz,

Quoted 7 lines
Quoted 4 lines

what is the recommended way of pushing larger buffers (up to 64K so far) into a qdict? QLIST of QINT (one per byte) looks a bit heavy. I thought about hex-encoding the content first (series of "%02X"), then registering it as QSTRING. Or should we introduce a new type, QBUFFER?

I don't think that hex-encoding the contents is so bad if your use case is
very specific and isolated.

The focus will be first on visualizing the buffer (user_print), but who knows what happens once the services is also exposed via QMP.

Quoted 1 line
Quoted 5 lines
Quoted 2 lines

On the other hand, I do prefer a QBuffer type, specially because we can
have buffer operations.

The q<type>.c files look sufficiently simply, guess I will add a buffer type. Still, hex-encoding is probably the best representation for QMP.

Yes, either as a string or (as suggested by Markus) an array of numbers,
if you wish to expose this via QMP you (or any of us) will have to update the parser to support it.

author
#4 lore raw
Quoted 20 lines · Luiz Capitulino
Quoted 17 lines · On Fri, 07 May 2010 16:21:13 +0200 Jan Kiszka <[email protected]> wrote:
Quoted 11 lines · Luiz Capitulino
Quoted 6 lines · On Fri, 07 May 2010 13:45:03 +0200 Jan Kiszka <[email protected]> wrote:

Hi Luiz,

what is the recommended way of pushing larger buffers (up to 64K so far) into a qdict? QLIST of QINT (one per byte) looks a bit heavy. I thought about hex-encoding the content first (series of "%02X"), then registering it as QSTRING. Or should we introduce a new type, QBUFFER?

I don't think that hex-encoding the contents is so bad if your use case is
very specific and isolated.

The focus will be first on visualizing the buffer (user_print), but who knows what happens once the services is also exposed via QMP.

Quoted 2 lines

On the other hand, I do prefer a QBuffer type, specially because we can
have buffer operations.

Quoted 8 lines
Quoted 2 lines

The q<type>.c files look sufficiently simply, guess I will add a buffer type. Still, hex-encoding is probably the best representation for QMP.

Yes, either as a string or (as suggested by Markus) an array of numbers,
if you wish to expose this via QMP you (or any of us) will have to update the parser to support it.

From a quick glance at the JSON spec, there is no room for a new type. I

think we have to overload an existing one and convert that into a QBuffer (typically, we know the actual semantic). Hex string encoding is most compact, so I went this road. But I'm open to change it into a true type if JSON actually allows it (or we are fine with breaking it).

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#5 lore raw
Quoted 28 lines · On Mon, 10 May 2010 12:59:47 +0200 Jan Kiszka <[email protected]> wrote:
Quoted 18 lines · Luiz Capitulino
Quoted 15 lines · On Fri, 07 May 2010 16:21:13 +0200 Jan Kiszka <[email protected]> wrote:
Quoted 11 lines · Luiz Capitulino
Quoted 6 lines · On Fri, 07 May 2010 13:45:03 +0200 Jan Kiszka <[email protected]> wrote:

Hi Luiz,

what is the recommended way of pushing larger buffers (up to 64K so far) into a qdict? QLIST of QINT (one per byte) looks a bit heavy. I thought about hex-encoding the content first (series of "%02X"), then registering it as QSTRING. Or should we introduce a new type, QBUFFER?

I don't think that hex-encoding the contents is so bad if your use case is
very specific and isolated.

The focus will be first on visualizing the buffer (user_print), but who knows what happens once the services is also exposed via QMP.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

On the other hand, I do prefer a QBuffer type, specially because we can
have buffer operations.

The q<type>.c files look sufficiently simply, guess I will add a buffer type. Still, hex-encoding is probably the best representation for QMP.

Yes, either as a string or (as suggested by Markus) an array of numbers,
if you wish to expose this via QMP you (or any of us) will have to update the parser to support it.

Quoted 5 lines

From a quick glance at the JSON spec, there is no room for a new type. I think we have to overload an existing one and convert that into a QBuffer (typically, we know the actual semantic). Hex string encoding is most compact, so I went this road. But I'm open to change it into a true type if JSON actually allows it (or we are fine with breaking it).

We have capabilities support but I don't think we should use it for this
case. We can have QBuffer internally and the parser can convert it to a valid json type.

#6 lore raw
In reply to Jan Kiszka
Quoted 5 lines · Jan Kiszka

From a quick glance at the JSON spec, there is no room for a new type. I
think we have to overload an existing one and convert that into a QBuffer (typically, we know the actual semantic). Hex string encoding is most compact, so I went this road.

Base64 is even more compact.

Quoted 3 lines

But I'm open to change it into a true
type if JSON actually allows it (or we are fine with breaking it).

That ruins any possibility of using a standard json encoder/decoder on the other end.

Signature · 1 line
error compiling committee.c: too many arguments to function
author
#7 lore raw
Quoted 7 lines · Avi Kivity
Quoted 4 lines · Jan Kiszka

From a quick glance at the JSON spec, there is no room for a new type. I
think we have to overload an existing one and convert that into a QBuffer (typically, we know the actual semantic). Hex string encoding is most compact, so I went this road.

Base64 is even more compact.

For sure, still room for improvements. There is just no encode() service in current qemu, so I went the lazy way so far. :)

Quoted 8 lines
Quoted 4 lines

But I'm open to change it into a true
type if JSON actually allows it (or we are fine with breaking it).

That ruins any possibility of using a standard json encoder/decoder on the other end.

That was my concern as well. Such decoders would not able to tell strings apart from buffers as that can only be derived from the context. Still, they could visualize the result and/or forward it to some libqmp for proper interpretation.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#8 lore raw
Quoted 9 lines · Jan Kiszka
Quoted 7 lines · Avi Kivity
Quoted 5 lines · Jan Kiszka

From a quick glance at the JSON spec, there is no room for a new type. I
think we have to overload an existing one and convert that into a QBuffer (typically, we know the actual semantic). Hex string encoding is most compact, so I went this road.

Quoted 5 lines
Quoted 2 lines

Base64 is even more compact.

For sure, still room for improvements. There is just no encode() service in current qemu, so I went the lazy way so far. :)

Well, if we expose these encoded buffers via QMP, we can't unlazy the implementation. It becomes an ABI, so we better think (and document) this through.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

But I'm open to change it into a true
type if JSON actually allows it (or we are fine with breaking it).

Quoted 9 lines
Quoted 4 lines

That ruins any possibility of using a standard json encoder/decoder on the other end.

That was my concern as well. Such decoders would not able to tell strings apart from buffers as that can only be derived from the context. Still, they could visualize the result and/or forward it to some libqmp for proper interpretation.

That's fine; the documentation for a command that accepts or returns buffers would mention that the value is a hex (or base64) encoded string.

Signature · 1 line
error compiling committee.c: too many arguments to function