From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59869) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrO3J-0006B4-AG for qemu-devel@nongnu.org; Mon, 02 Jun 2014 04:57:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WrO3D-0004at-JQ for qemu-devel@nongnu.org; Mon, 02 Jun 2014 04:57:09 -0400 Received: from mail-wi0-x235.google.com ([2a00:1450:400c:c05::235]:43868) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrO3D-0004af-C9 for qemu-devel@nongnu.org; Mon, 02 Jun 2014 04:57:03 -0400 Received: by mail-wi0-f181.google.com with SMTP id n15so4200834wiw.8 for ; Mon, 02 Jun 2014 01:57:02 -0700 (PDT) Message-ID: <1401699419.2875.117.camel@localhost.localdomain> From: Marcel Apfelbaum Date: Mon, 02 Jun 2014 11:56:59 +0300 In-Reply-To: <1401611464.2875.99.camel@localhost.localdomain> References: <1401482467-31550-1-git-send-email-ehabkost@redhat.com> <1401611464.2875.99.camel@localhost.localdomain> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH] machine: Add kvm-type property Reply-To: marcel.a@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: kvm@vger.kernel.org, Alexander Graf , qemu-devel@nongnu.org, "Aneesh Kumar K.V" , Paolo Bonzini , Andreas =?ISO-8859-1?Q?F=E4rber?= On Sun, 2014-06-01 at 11:31 +0300, Marcel Apfelbaum wrote: > On Fri, 2014-05-30 at 17:41 -0300, Eduardo Habkost wrote: > > The kvm-type machine option was left out when MachineState was > > introduced, preventing the kvm-type option from being used. Add the > > missing property. > Very interesting how did I miss that. > Thanks! > Marcel > > > > > Signed-off-by: Eduardo Habkost > > Cc: Andreas Färber > > 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=hv,accel=kvm > > 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=hv,accel=kvm > > Invalid argument kvm-type=hv > > > > (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, const char *value, Error **errp) > > ms->firmware = g_strdup(value); > > } > > > > +static char *machine_get_kvm_type(Object *obj, Error **errp) > > +{ > > + MachineState *ms = MACHINE(obj); > > + > > + return g_strdup(ms->kvm_type); > > +} > > + > > +static void machine_set_kvm_type(Object *obj, const char *value, Error **errp) > > +{ > > + MachineState *ms = MACHINE(obj); > > + > > + g_free(ms->kvm_type); Hi, Here also, like in my other replies, I think it should be the caller responsibility to free the string. A set method should not touch its parameter. Thanks, Marcel > > + ms->kvm_type = 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); > > } > > > > 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; > > > > ram_addr_t ram_size; > > const char *boot_order; > > > >