LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Michael Mueller <mimu@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org, kvm@vger.kernel.org,
linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Gleb Natapov <gleb@kernel.org>, Alexander Graf <agraf@suse.de>,
Christian Borntraeger <borntraeger@de.ibm.com>,
"Jason J. Herne" <jjherne@linux.vnet.ibm.com>,
Cornelia Huck <cornelia.huck@de.ibm.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Andreas Faerber <afaerber@suse.de>,
Richard Henderson <rth@twiddle.net>,
Eduardo Habkost <ehabkost@redhat.com>,
Michael Mueller <mimu@linux.vnet.ibm.com>
Subject: [PATCH v3 01/16] Introduce probe mode for machine type none
Date: Mon, 2 Mar 2015 13:43:53 +0100 [thread overview]
Message-ID: <1425300248-40277-2-git-send-email-mimu@linux.vnet.ibm.com> (raw)
In-Reply-To: <1425300248-40277-1-git-send-email-mimu@linux.vnet.ibm.com>
QEMU now switches into "probe mode" when the selected machine is "none" and no
specific accelerator(s) has been requested (i.e.: "-machine none").
In probe mode a by "<ARCH>_CONFIG" defines predefined list of accelerators run
their init() methods.
Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
---
accel.c | 31 +++++++++++++++++++++++++------
include/hw/boards.h | 1 +
include/sysemu/kvm.h | 10 ++++++++++
kvm-all.c | 3 +++
4 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/accel.c b/accel.c
index 74e41da..260b009 100644
--- a/accel.c
+++ b/accel.c
@@ -36,6 +36,9 @@
int tcg_tb_size;
static bool tcg_allowed = true;
+static const char *probe_mode_accels =
+ "kvm:"
+ "tcg";
static int tcg_init(MachineState *ms)
{
@@ -59,13 +62,15 @@ static AccelClass *accel_find(const char *opt_name)
return ac;
}
-static int accel_init_machine(AccelClass *acc, MachineState *ms)
+static int accel_init_machine(AccelClass *acc, MachineState *ms,
+ bool probe_mode)
{
ObjectClass *oc = OBJECT_CLASS(acc);
const char *cname = object_class_get_name(oc);
AccelState *accel = ACCEL(object_new(cname));
int ret;
ms->accelerator = accel;
+ ms->probe_mode = probe_mode;
*(acc->allowed) = true;
ret = acc->init_machine(ms);
if (ret < 0) {
@@ -78,20 +83,30 @@ static int accel_init_machine(AccelClass *acc, MachineState *ms)
int configure_accelerator(MachineState *ms)
{
- const char *p;
+ const char *p, *name;
char buf[10];
int ret;
bool accel_initialised = false;
bool init_failed = false;
AccelClass *acc = NULL;
+ ObjectClass *oc;
+ bool probe_mode = false;
p = qemu_opt_get(qemu_get_machine_opts(), "accel");
if (p == NULL) {
- /* Use the default "accelerator", tcg */
- p = "tcg";
+ oc = (ObjectClass *) MACHINE_GET_CLASS(current_machine);
+ name = object_class_get_name(oc);
+ probe_mode = !strcmp(name, "none" TYPE_MACHINE_SUFFIX);
+ if (probe_mode) {
+ /* Use these accelerators in probe mode, tcg should be last */
+ p = probe_mode_accels;
+ } else {
+ /* Use the default "accelerator", tcg */
+ p = "tcg";
+ }
}
- while (!accel_initialised && *p != '\0') {
+ while ((probe_mode || !accel_initialised) && *p != '\0') {
if (*p == ':') {
p++;
}
@@ -106,7 +121,7 @@ int configure_accelerator(MachineState *ms)
acc->name);
continue;
}
- ret = accel_init_machine(acc, ms);
+ ret = accel_init_machine(acc, ms, probe_mode);
if (ret < 0) {
init_failed = true;
fprintf(stderr, "failed to initialize %s: %s\n",
@@ -128,6 +143,10 @@ int configure_accelerator(MachineState *ms)
fprintf(stderr, "Back to %s accelerator.\n", acc->name);
}
+ if (probe_mode) {
+ accel_initialised = false;
+ }
+
return !accel_initialised;
}
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 3ddc449..3253fa5 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -135,6 +135,7 @@ struct MachineState {
bool usb;
char *firmware;
bool iommu;
+ bool probe_mode;
ram_addr_t ram_size;
ram_addr_t maxram_size;
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 30cb84d..fbc18c8 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -50,6 +50,7 @@ extern bool kvm_msi_via_irqfd_allowed;
extern bool kvm_gsi_routing_allowed;
extern bool kvm_gsi_direct_mapping;
extern bool kvm_readonly_mem_allowed;
+extern bool kvm_probe_mode;
#if defined CONFIG_KVM || !defined NEED_CPU_H
#define kvm_enabled() (kvm_allowed)
@@ -143,6 +144,15 @@ extern bool kvm_readonly_mem_allowed;
*/
#define kvm_readonly_mem_enabled() (kvm_readonly_mem_allowed)
+/**
+ * kvm_probe_mode_enabled:
+ *
+ * Returns: true if KVM is initialized for a machine type that
+ * has its probe_mode attribute set (ie QEMU was started in probe
+ * mode)
+ */
+#define kvm_probe_mode_enabled() (kvm_probe_mode)
+
#else
#define kvm_enabled() (0)
#define kvm_irqchip_in_kernel() (false)
diff --git a/kvm-all.c b/kvm-all.c
index 05a79c2..f9e4434 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -126,6 +126,7 @@ bool kvm_gsi_routing_allowed;
bool kvm_gsi_direct_mapping;
bool kvm_allowed;
bool kvm_readonly_mem_allowed;
+bool kvm_probe_mode;
static const KVMCapabilityInfo kvm_required_capabilites[] = {
KVM_CAP_INFO(USER_MEMORY),
@@ -1471,6 +1472,8 @@ static int kvm_init(MachineState *ms)
goto err;
}
+ kvm_probe_mode = ms->probe_mode;
+
s->nr_slots = kvm_check_extension(s, KVM_CAP_NR_MEMSLOTS);
/* If unspecified, use the default value */
--
1.8.3.1
next prev parent reply other threads:[~2015-03-02 12:53 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-02 12:43 [PATCH v3 00/16] s390x cpu model implementation Michael Mueller
2015-03-02 12:43 ` Michael Mueller [this message]
2015-03-02 13:57 ` [PATCH v3 01/16] Introduce probe mode for machine type none Andreas Färber
2015-03-02 16:43 ` [Qemu-devel] " Michael Mueller
2015-03-02 16:57 ` Andreas Färber
2015-03-03 10:55 ` Michael Mueller
2015-03-04 19:19 ` Eduardo Habkost
2015-03-05 14:56 ` Michael Mueller
2015-03-05 15:07 ` Eduardo Habkost
2015-03-02 19:17 ` Eduardo Habkost
2015-03-03 10:23 ` [Qemu-devel] " Michael Mueller
2015-03-02 12:43 ` [PATCH v3 02/16] Introduce option --probe to switch into probe mode Michael Mueller
2015-03-02 12:43 ` [PATCH v3 03/16] Introduce stub routine cpu_desc_avail Michael Mueller
2015-03-02 12:43 ` [PATCH v3 04/16] target-s390x: Introduce cpu facilities Michael Mueller
2015-03-02 12:43 ` [PATCH v3 05/16] target-s390x: Generate facility defines per cpu model Michael Mueller
2015-03-02 12:43 ` [PATCH v3 06/16] target-s390x: Introduce cpu models Michael Mueller
2015-03-02 12:43 ` [PATCH v3 07/16] target-s390x: Define cpu model specific facility lists Michael Mueller
2015-03-02 12:44 ` [PATCH v3 08/16] target-s390x: Add cpu model alias definition routines Michael Mueller
2015-03-02 12:44 ` [PATCH v3 09/16] target-s390x: Update linux-headers/asm-s390/kvm.h Michael Mueller
2015-03-02 12:44 ` [PATCH v3 10/16] target-s390x: Add KVM VM attribute interface for cpu models Michael Mueller
2015-03-02 12:44 ` [PATCH v3 11/16] target-s390x: Add cpu class initialization routines Michael Mueller
2015-03-02 12:44 ` [PATCH v3 12/16] target-s390x: Prepare accelerator during cpu object realization Michael Mueller
2015-03-02 12:44 ` [PATCH v3 13/16] target-s390x: New QMP command query-cpu-model Michael Mueller
2015-03-02 12:44 ` [PATCH v3 14/16] target-s390x: Extend QMP command query-cpu-definitions Michael Mueller
2015-03-02 19:11 ` Eduardo Habkost
2015-03-04 9:00 ` [Qemu-devel] " Michael Mueller
2015-03-02 12:44 ` [PATCH v3 15/16] target-s390x: Introduce facility test routine Michael Mueller
2015-03-02 12:44 ` [PATCH v3 16/16] target-s390x: Enable cpu model usage Michael Mueller
2015-03-02 19:25 ` [PATCH v3 00/16] s390x cpu model implementation 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=1425300248-40277-2-git-send-email-mimu@linux.vnet.ibm.com \
--to=mimu@linux.vnet.ibm.com \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=borntraeger@de.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=ehabkost@redhat.com \
--cc=gleb@kernel.org \
--cc=jjherne@linux.vnet.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--subject='Re: [PATCH v3 01/16] Introduce probe mode for machine type none' \
/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
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).