From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eduardo Habkost Subject: [PATCH] machine: Add kvm-type property Date: Fri, 30 May 2014 17:41:07 -0300 Message-ID: <1401482467-31550-1-git-send-email-ehabkost@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Paolo Bonzini , kvm@vger.kernel.org, "Aneesh Kumar K.V" , Alexander Graf , Marcel Apfelbaum To: qemu-devel@nongnu.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= Return-path: Received: from mx1.redhat.com ([209.132.183.28]:4940 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933857AbaE3Ul3 (ORCPT ); Fri, 30 May 2014 16:41:29 -0400 Sender: kvm-owner@vger.kernel.org List-ID: The kvm-type machine option was left out when MachineState was introduced, preventing the kvm-type option from being used. Add the missing property. Signed-off-by: Eduardo Habkost Cc: Andreas F=C3=A4rber Cc: Aneesh Kumar K.V Cc: Alexander Graf Cc: Marcel Apfelbaum --- Tested in a x86 machine only. Help would be welcome to test it on a PPC machine using -machine spapr and KVM. Before this patch: $ qemu-system-x86_64 -machine pc,kvm-type=3Dhv,accel=3Dkvm qemu-system-x86_64: Property '.kvm-type' not found (This means the option won't work even for sPAPR machines.) After applying this patch: $ qemu-system-x86_64 -machine pc,kvm-type=3Dhv,accel=3Dkvm Invalid argument kvm-type=3Dhv (This means the x86 KVM init code is seeing (and rejecting) the option, and the sPAPR code can use it.) Note that qemu-system-x86_64 will segfault with the above command-line unless an additional fix (submitted today) is applied (kvm: Ensure negative return value on kvm_init() error handling path). --- hw/core/machine.c | 17 +++++++++++++++++ include/hw/boards.h | 1 + 2 files changed, 18 insertions(+) diff --git a/hw/core/machine.c b/hw/core/machine.c index cbba679..ed47b3a 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -235,6 +235,21 @@ static void machine_set_firmware(Object *obj, cons= t char *value, Error **errp) ms->firmware =3D g_strdup(value); } =20 +static char *machine_get_kvm_type(Object *obj, Error **errp) +{ + MachineState *ms =3D MACHINE(obj); + + return g_strdup(ms->kvm_type); +} + +static void machine_set_kvm_type(Object *obj, const char *value, Error= **errp) +{ + MachineState *ms =3D MACHINE(obj); + + g_free(ms->kvm_type); + ms->kvm_type =3D g_strdup(value); +} + static void machine_initfn(Object *obj) { object_property_add_str(obj, "accel", @@ -274,6 +289,8 @@ static void machine_initfn(Object *obj) object_property_add_bool(obj, "usb", machine_get_usb, machine_set_= usb, NULL); object_property_add_str(obj, "firmware", machine_get_firmware, machine_set_firmware= , NULL); + object_property_add_str(obj, "kvm-type", + machine_get_kvm_type, machine_set_kvm_type= , NULL); } =20 static void machine_finalize(Object *obj) diff --git a/include/hw/boards.h b/include/hw/boards.h index 2d2e2be..44956d6 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -111,6 +111,7 @@ struct MachineState { bool mem_merge; bool usb; char *firmware; + char *kvm_type; =20 ram_addr_t ram_size; const char *boot_order; --=20 1.9.0