qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [V9 3/4] hw/core: Add AMD IOMMU to machine properties


From: Peter Xu
Subject: Re: [Qemu-devel] [V9 3/4] hw/core: Add AMD IOMMU to machine properties
Date: Mon, 25 Apr 2016 11:00:08 +0800
User-agent: Mutt/1.5.24 (2015-08-30)

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 <address@hidden>
> ---
>  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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]