From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47037) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1auWl0-0001Hi-IU for qemu-devel@nongnu.org; Sun, 24 Apr 2016 23:00:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1auWkx-0006N5-Df for qemu-devel@nongnu.org; Sun, 24 Apr 2016 23:00:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56101) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1auWkx-0006Mz-8S for qemu-devel@nongnu.org; Sun, 24 Apr 2016 23:00:15 -0400 Date: Mon, 25 Apr 2016 11:00:08 +0800 From: Peter Xu Message-ID: <20160425030008.GD3261@pxdev.xzpeter.org> References: <1461535977-331-1-git-send-email-davidkiarie4@gmail.com> <1461535977-331-4-git-send-email-davidkiarie4@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1461535977-331-4-git-send-email-davidkiarie4@gmail.com> Subject: Re: [Qemu-devel] [V9 3/4] hw/core: Add AMD IOMMU to machine properties List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Kiarie Cc: qemu-devel@nongnu.org, jan.kizska@web.de, mst@redhat.com, valentine.sinitsyn@gmail.com, marcel@redhat.com, imammedo@redhat.com On Mon, Apr 25, 2016 at 01:12:56AM +0300, David Kiarie wrote: > Added a bool, subject to review to machine properties which > it used to override iommu emulated from Intel to AMD. > > Signed-off-by: David Kiarie > --- > hw/core/machine.c | 32 +++++++++++++++++++++++++++++--- > include/hw/boards.h | 1 + > include/hw/i386/intel_iommu.h | 1 + > qemu-options.hx | 7 +++++-- > util/qemu-config.c | 8 ++++++-- > 5 files changed, 42 insertions(+), 7 deletions(-) > > diff --git a/hw/core/machine.c b/hw/core/machine.c > index 6dbbc85..792641b 100644 > --- a/hw/core/machine.c > +++ b/hw/core/machine.c > @@ -15,6 +15,8 @@ > #include "qapi/error.h" > #include "qapi-visit.h" > #include "qapi/visitor.h" > +#include "hw/i386/amd_iommu.h" > +#include "hw/i386/intel_iommu.h" > #include "hw/sysbus.h" > #include "sysemu/sysemu.h" > #include "qemu/error-report.h" > @@ -300,6 +302,26 @@ static void machine_set_iommu(Object *obj, bool value, Error **errp) > ms->iommu = value; > } > > +static void machine_set_iommu_override(Object *obj, const char *value, > + Error **errp) > +{ > + MachineState *ms = MACHINE(obj); > + Error *err = NULL; > + > + ms->x_iommu_type = false; > + /* ensure a valid iommu type */ > + if (g_strcmp0(value, AMD_IOMMU_STR) && > + g_strcmp0(value, INTEL_IOMMU_STR)) { > + error_setg(errp, "Invalid IOMMU type %s", value); > + error_propagate(errp, err); > + return; > + } > + > + if ((g_strcmp0(value, AMD_IOMMU_STR) == 0)) { > + ms->x_iommu_type = true; > + } Would it be clearer to use: if (g_strcmp0(value, AMD_IOMMU_STR) == 0) { ... } else if (g_strcmp0(value, INTEL_IOMMU_STR) == 0) { ... } else { error... } ? Thanks. -- peterx