qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, ehabkost@redhat.com, afaerber@suse.de,
	mst@redhat.com
Subject: [Qemu-devel] [PATCH 1/9] cpu: rename cpu_exists() to qemu_get_cpu_by_arch_id()
Date: Thu,  4 Feb 2016 12:49:12 +0100	[thread overview]
Message-ID: <1454586552-10251-1-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1454586455-10202-1-git-send-email-imammedo@redhat.com>

cpu_exists() already does CPU lookup but
discards found CPU and returns boolean instead.
Make it more useful by returning a found CPU
and also rename it more descriptive name.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/i386/pc.c      |  2 +-
 include/qom/cpu.h | 10 +++++-----
 qom/cpu.c         |  6 +++---
 target-i386/cpu.c |  2 +-
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 942ac06..d72246d 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1088,7 +1088,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
         return;
     }
 
-    if (cpu_exists(apic_id)) {
+    if (qemu_get_cpu_by_arch_id(apic_id)) {
         error_setg(errp, "Unable to add CPU: %" PRIi64
                    ", it already exists", id);
         return;
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 035179c..bd26bf5 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -622,14 +622,14 @@ void async_run_on_cpu(CPUState *cpu, void (*func)(void *data), void *data);
 CPUState *qemu_get_cpu(int index);
 
 /**
- * cpu_exists:
- * @id: Guest-exposed CPU ID to lookup.
+ * qemu_get_cpu_by_arch_id:
+ * @id: Guest-exposed CPU ID to lookup returned by CPUState@get_arch_id()
  *
- * Search for CPU with specified ID.
+ * Gets a CPU matching @id.
  *
- * Returns: %true - CPU is found, %false - CPU isn't found.
+ * Returns: The CPU or %NULL if there is no matching CPU.
  */
-bool cpu_exists(int64_t id);
+CPUState *qemu_get_cpu_by_arch_id(int id);
 
 /**
  * cpu_throttle_set:
diff --git a/qom/cpu.c b/qom/cpu.c
index 8f537a4..e66989b 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -26,7 +26,7 @@
 #include "qemu/error-report.h"
 #include "sysemu/sysemu.h"
 
-bool cpu_exists(int64_t id)
+CPUState *qemu_get_cpu_by_arch_id(int id)
 {
     CPUState *cpu;
 
@@ -34,10 +34,10 @@ bool cpu_exists(int64_t id)
         CPUClass *cc = CPU_GET_CLASS(cpu);
 
         if (cc->get_arch_id(cpu) == id) {
-            return true;
+            return cpu;
         }
     }
-    return false;
+    return NULL;
 }
 
 CPUState *cpu_generic_init(const char *typename, const char *cpu_model)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index b255644..3918f01 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1789,7 +1789,7 @@ static void x86_cpuid_set_apic_id(Object *obj, Visitor *v, void *opaque,
         return;
     }
 
-    if ((value != cpu->apic_id) && cpu_exists(value)) {
+    if ((value != cpu->apic_id) && qemu_get_cpu_by_arch_id(value)) {
         error_setg(errp, "CPU with APIC ID %" PRIi64 " exists", value);
         return;
     }
-- 
1.8.3.1

  parent reply	other threads:[~2016-02-04 11:49 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-04 11:47 [Qemu-devel] [PATCH 0/9] pc: do not create invalid MADT.LAPIC/Processor entries Igor Mammedov
2016-02-04 11:47 ` [Qemu-devel] [PATCH 2/9] machine: introduce MachineClass.possible_cpu_arch_ids() hook Igor Mammedov
2016-02-04 12:18   ` Marcel Apfelbaum
2016-02-04 13:36     ` Igor Mammedov
2016-02-05 14:13       ` Eduardo Habkost
2016-02-05 14:49         ` Igor Mammedov
2016-02-05 15:04   ` Eduardo Habkost
2016-02-05 15:39     ` Igor Mammedov
2016-02-05 15:50       ` Eduardo Habkost
2016-02-05 16:29         ` Igor Mammedov
2016-02-04 11:47 ` [Qemu-devel] [PATCH 3/9] pc: acpi: cleanup qdev_get_machine() calls Igor Mammedov
2016-02-04 12:21   ` Marcel Apfelbaum
2016-02-04 11:47 ` [Qemu-devel] [PATCH 4/9] pc: acpi: SRAT: create only valid processor lapic entries Igor Mammedov
2016-02-05 15:07   ` Eduardo Habkost
2016-02-04 11:47 ` [Qemu-devel] [PATCH 5/9] pc: acpi: create Processor and Notify objects only for valid lapics Igor Mammedov
2016-02-05 15:17   ` Eduardo Habkost
2016-02-05 15:43     ` Igor Mammedov
2016-02-04 11:47 ` [Qemu-devel] [PATCH 6/9] pc: acpi: create MADT.lapic entries " Igor Mammedov
2016-02-05 15:28   ` Eduardo Habkost
2016-02-05 16:14     ` Igor Mammedov
2016-02-11 16:11       ` Eduardo Habkost
2016-02-12 10:04         ` Igor Mammedov
2016-02-04 11:47 ` [Qemu-devel] [PATCH 7/9] pc: acpi: drop not needed intermediate bitmap cpu->found_cpus Igor Mammedov
2016-02-05 15:39   ` Eduardo Habkost
2016-02-05 16:19     ` Igor Mammedov
2016-02-05 16:44       ` Igor Mammedov
2016-02-11 15:59         ` Eduardo Habkost
2016-02-12 10:05           ` Igor Mammedov
2016-02-04 11:47 ` [Qemu-devel] [PATCH 8/9] pc: move apic_id_limit to PCMachineState Igor Mammedov
     [not found]   ` <56B348BA.40502@gmail.com>
2016-02-04 17:08     ` Igor Mammedov
2016-02-04 18:18       ` Michael S. Tsirkin
2016-02-04 18:24         ` Igor Mammedov
2016-02-04 11:47 ` [Qemu-devel] [PATCH 9/9] pc: acpi: clarify why possible LAPIC entries must be present in MADT Igor Mammedov
2016-02-05 15:39   ` Eduardo Habkost
2016-02-04 11:49 ` Igor Mammedov [this message]
2016-02-05 14:20   ` [Qemu-devel] [PATCH 1/9] cpu: rename cpu_exists() to qemu_get_cpu_by_arch_id() Eduardo Habkost

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=1454586552-10251-1-git-send-email-imammedo@redhat.com \
    --to=imammedo@redhat.com \
    --cc=afaerber@suse.de \
    --cc=ehabkost@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).