qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: Valeriy Vdovin <valeriy.vdovin@virtuozzo.com>, qemu-devel@nongnu.org
Cc: Eric Blake <eblake@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Richard Henderson <richard.henderson@linaro.org>,
	Denis Lunev <den@openvz.org>
Subject: Re: [PATCH v6] qapi: introduce 'query-cpu-model-cpuid' action
Date: Tue, 20 Apr 2021 20:00:28 +0300	[thread overview]
Message-ID: <6d8371c1-8864-62ad-9349-182a5e74858f@virtuozzo.com> (raw)
In-Reply-To: <20210420161940.24306-1-valeriy.vdovin@virtuozzo.com>

20.04.2021 19:19, Valeriy Vdovin wrote:
> Introducing new qapi method 'query-cpu-model-cpuid'. This method can be used to
> get virtualized cpu model info generated by QEMU during VM initialization in
> the form of cpuid representation.
> 

[..]

> +CpuModelCpuidDescription *qmp_query_cpu_model_cpuid(Error **errp)
> +{
> +    MachineState *ms = MACHINE(qdev_get_machine());
> +    const char *class_name;
> +    CpuModelCpuidDescription *info;
> +    Object *cpu;
> +    char *model_id, *vendor;
> +
> +    /*
> +     * Method requires initialized machine and cpu
> +     */
> +    if (!ms || !ms->possible_cpus) {
> +      error_setg(errp, "Nothing to report");
> +      return NULL;

indentation should be fixed to 4+4=8 spaces totally, as patchew already said.

> +    }
> +
> +    cpu = ms->possible_cpus->cpus[0].cpu;
> +
> +    class_name = object_class_get_name(object_get_class(cpu));
> +    model_id = object_property_get_str(cpu, "model-id", errp);
> +    if (!model_id) {
> +        error_setg(errp, "'model-id' property not found");

object_property_get_str has errp argument, so it should care to set it on error path. You shouldn't call error_setg by hand here, it will crash (trying to set errp which is already set).

> +        return NULL;
> +    }
> +    vendor = object_property_get_str(cpu, "vendor", errp);
> +    if (!vendor) {
> +        error_setg(errp, "'vendor' property not found");

and here

> +        return NULL;
> +    }
> +
> +    info = g_malloc0(sizeof(*info));
> +    info->model_id = g_strdup(model_id);
> +    info->vendor = g_strdup(vendor);
> +    info->class_name = g_strdup(class_name);
> +    cpu_model_fill_cpuid(cpu, info);
> +
> +    return info;
> +}
> +

With fixed style and dropped extra error_setg() calls:

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>


-- 
Best regards,
Vladimir


  parent reply	other threads:[~2021-04-20 17:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-20 16:19 [PATCH v6] qapi: introduce 'query-cpu-model-cpuid' action Valeriy Vdovin
2021-04-20 16:42 ` no-reply
2021-04-20 17:00 ` Vladimir Sementsov-Ogievskiy [this message]
2021-04-20 17:09 ` Eduardo Habkost
2021-04-21 17:39   ` Valeriy Vdovin
2021-04-21 20:17     ` Eduardo Habkost
2021-04-22  9:02       ` Valeriy Vdovin
2021-04-23 20:32         ` Eduardo Habkost
2021-04-22  9:41       ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6d8371c1-8864-62ad-9349-182a5e74858f@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=armbru@redhat.com \
    --cc=den@openvz.org \
    --cc=eblake@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=valeriy.vdovin@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).