[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 5/7] add qdev property type "cpu"
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH 5/7] add qdev property type "cpu" |
Date: |
Sat, 26 Jun 2010 09:46:22 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
Paolo Bonzini <address@hidden> writes:
[...]
> diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
> index 5a8739d..2759c83 100644
> --- a/hw/qdev-properties.c
> +++ b/hw/qdev-properties.c
> @@ -1,6 +1,7 @@
> #include "net.h"
> #include "qdev.h"
> #include "qerror.h"
> +#include "cpus.h"
>
> void *qdev_get_prop_ptr(DeviceState *dev, Property *prop)
> {
> @@ -281,6 +282,44 @@ PropertyInfo qdev_prop_string = {
> .free = free_string,
> };
>
> +/* --- cpu --- */
> +
> +static int parse_cpu(DeviceState *dev, Property *prop, const char *str)
> +{
> + CPUState **ptr = qdev_get_prop_ptr(dev, prop);
> + char *end;
> + int id;
> +
> + if (!*str)
> + return -ENOENT;
> +
> + id = strtol (str, &end, 0);
> + if (*end)
> + return -ENOENT;
> +
> + *ptr = cpu_get_by_id(id);
> + if (*ptr == NULL)
> + return -ENOENT;
> + return 0;
> +}
> +
> +static int print_cpu(DeviceState *dev, Property *prop, char *dest, size_t
> len)
> +{
> + CPUState **ptr = qdev_get_prop_ptr(dev, prop);
> + if (*ptr)
> + return snprintf(dest, len, "CPU #%d", cpu_get_id(*ptr));
> + else
> + return snprintf(dest, len, "CPU #<null>");
> +}
Hmm. Parse method doesn't accept output of the print method. Not so
nice. Is the "CPU #" decoration essential?
Oh, and beware of the Secret Tab Police.
[...]
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