[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Re: [PATCH 5/7] add qdev property type "cpu"
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] Re: [PATCH 5/7] add qdev property type "cpu" |
Date: |
Tue, 29 Jun 2010 13:42:17 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
Paolo Bonzini <address@hidden> writes:
>> Hmm. Parse method doesn't accept output of the print method. Not so
>> nice. Is the "CPU #" decoration essential?
>
> I noticed the same in parse/print string:
>
> static int parse_string(DeviceState *dev, Property *prop, const char *str)
> {
> char **ptr = qdev_get_prop_ptr(dev, prop);
>
> if (*ptr)
> qemu_free(*ptr);
> *ptr = qemu_strdup(str);
> return 0;
> }
>
> static int print_string(DeviceState *dev, Property *prop, char *dest,
> size_t len)
> {
> char **ptr = qdev_get_prop_ptr(dev, prop);
> if (!*ptr)
> return snprintf(dest, len, "<null>");
> return snprintf(dest, len, "\"%s\"", *ptr);
> }
>
> It looks like printing representation is chosen "for the user", not
> for parsing.
Yes, but does that mean we *should* add such decorations?
For me, the print method should be reasonably close to what the parse
method accepts. A bit like Lisp's princ, whose ouput is close, but not
identical to what the reader accepts (for output acceptable to the
reader, use prin1).
As to "for the user":
dev-prop: cpu_env = CPU #0
dev-prop: cpu_env = 0
Both are equally intelligible, in my opinion: obvious if you know what
the property is about, gibberish if you don't. The latter is slightly
easier to parse with simple tools like AWK.
By the way, print_string() should escape double-quote and funny
characters.
Re: [Qemu-devel] [PATCH 5/7] add qdev property type "cpu", Blue Swirl, 2010/06/27
[Qemu-devel] [PATCH 2/7] include qemu-common.h when needed by the next patches, Paolo Bonzini, 2010/06/25
[Qemu-devel] [PATCH 3/7] include stdio.h freely, remove dyngen-exec.h hacks, Paolo Bonzini, 2010/06/25
[Qemu-devel] [PATCH 1/7] rtc: Remove TARGET_I386 from qemu-config.c, enables driftfix, Paolo Bonzini, 2010/06/25
Re: [Qemu-devel] [PATCH 0/7] poison TARGET_xxx for compile once object and header file cleanups, Richard Henderson, 2010/06/25
Re: [Qemu-devel] [PATCH 0/7] poison TARGET_xxx for compile once object and header file cleanups, Blue Swirl, 2010/06/27