[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 01/11] accel/kvm: Check MachineClass kvm_type() return value
- To: qemu-devel@xxxxxxxxxx
- From: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
- Date: Fri, 19 Feb 2021 18:38:37 +0100
- Authentication-results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@xxxxxxxxxx
- Cc: Aurelien Jarno <aurelien@xxxxxxxxxxx>, Peter Maydell <peter.maydell@xxxxxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, qemu-ppc@xxxxxxxxxx, qemu-s390x@xxxxxxxxxx, Halil Pasic <pasic@xxxxxxxxxxxxx>, Huacai Chen <chenhuacai@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Marcel Apfelbaum <marcel.apfelbaum@xxxxxxxxx>, David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>, qemu-arm@xxxxxxxxxx, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Paolo Bonzini <pbonzini@xxxxxxxxxx>, kvm@xxxxxxxxxxxxxxx, BALATON Zoltan <balaton@xxxxxxxxxx>, Leif Lindholm <leif@xxxxxxxxxxxx>, Richard Henderson <richard.henderson@xxxxxxxxxx>, Radoslaw Biernacki <rad@xxxxxxxxxxxx>, Alistair Francis <alistair@xxxxxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Eduardo Habkost <ehabkost@xxxxxxxxxx>, "Michael S. Tsirkin" <mst@xxxxxxxxxx>, Thomas Huth <thuth@xxxxxxxxxx>, Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx>, Hervé Poussineau <hpoussin@xxxxxxxxxxx>, Greg Kurz <groug@xxxxxxxx>, Christian Borntraeger <borntraeger@xxxxxxxxxx>, Cornelia Huck <cohuck@xxxxxxxxxx>, "Edgar E. Iglesias" <edgar.iglesias@xxxxxxxxx>, David Hildenbrand <david@xxxxxxxxxx>, Mark Cave-Ayland <mark.cave-ayland@xxxxxxxxxxxx>, Aleksandar Rikalo <aleksandar.rikalo@xxxxxxxxxx>, Philippe Mathieu-Daudé <f4bug@xxxxxxxxx>, Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
- Delivery-date: Fri, 19 Feb 2021 17:39:03 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
MachineClass::kvm_type() can return -1 on failure.
Document it, and add a check in kvm_init().
Signed-off-by: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
---
include/hw/boards.h | 3 ++-
accel/kvm/kvm-all.c | 6 ++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/hw/boards.h b/include/hw/boards.h
index a46dfe5d1a6..68d3d10f6b0 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -127,7 +127,8 @@ typedef struct {
* implement and a stub device is required.
* @kvm_type:
* Return the type of KVM corresponding to the kvm-type string option or
- * computed based on other criteria such as the host kernel capabilities.
+ * computed based on other criteria such as the host kernel capabilities
+ * (which can't be negative), or -1 on error.
* @numa_mem_supported:
* true if '--numa node.mem' option is supported and false otherwise
* @smp_parse:
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 84c943fcdb2..b069938d881 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -2057,6 +2057,12 @@ static int kvm_init(MachineState *ms)
"kvm-type",
&error_abort);
type = mc->kvm_type(ms, kvm_type);
+ if (type < 0) {
+ ret = -EINVAL;
+ fprintf(stderr, "Failed to detect kvm-type for machine '%s'\n",
+ mc->name);
+ goto err;
+ }
}
do {
--
2.26.2
|