[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [PATCH v6 1/2] spapr: helper functions to get valid host
From: |
Greg Kurz |
Subject: |
Re: [Qemu-ppc] [PATCH v6 1/2] spapr: helper functions to get valid host fields |
Date: |
Thu, 14 Mar 2019 17:59:22 +0100 |
On Thu, 14 Mar 2019 13:29:48 -0300
"Maxiwell S. Garcia" <address@hidden> wrote:
> The pseries options 'host-serial' and 'host-model' accepts
> 'none', 'passthrough', or <string> content. The helper
> functions in this commit return a valid host field based on
> user options.
>
> Signed-off-by: Maxiwell S. Garcia <address@hidden>
> ---
Reviewed-by: Greg Kurz <address@hidden>
> hw/ppc/spapr.c | 48 +++++++++++++++++++++++-------------------
> include/hw/ppc/spapr.h | 4 ++++
> 2 files changed, 30 insertions(+), 22 deletions(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 6c16d6cfaf..3e2d5fe438 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1211,6 +1211,24 @@ static void spapr_dt_chosen(SpaprMachineState *spapr,
> void *fdt)
> g_free(bootlist);
> }
>
> +#define SPAPR_GET_VALID_HOST(attr) \
> +char *spapr_get_valid_host_##attr(SpaprMachineState *spapr) \
> +{ \
> + char *buf = NULL; \
> + if (spapr->host_##attr && \
> + !g_str_equal(spapr->host_##attr, "none")) { \
> + if (g_str_equal(spapr->host_##attr, "passthrough")) { \
> + kvmppc_get_host_##attr(&buf); \
> + } else { \
> + buf = g_strdup(spapr->host_##attr); \
> + } \
> + } \
> + return buf; \
> +}
> +
> +SPAPR_GET_VALID_HOST(serial);
> +SPAPR_GET_VALID_HOST(model);
> +
> static void spapr_dt_hypervisor(SpaprMachineState *spapr, void *fdt)
> {
> /* The /hypervisor node isn't in PAPR - this is a hack to allow PR
> @@ -1256,30 +1274,16 @@ static void *spapr_build_fdt(SpaprMachineState *spapr)
> * Add info to guest to indentify which host is it being run on
> * and what is the uuid of the guest
> */
> - if (spapr->host_model && !g_str_equal(spapr->host_model, "none")) {
> - if (g_str_equal(spapr->host_model, "passthrough")) {
> - /* -M host-model=passthrough */
> - if (kvmppc_get_host_model(&buf)) {
> - _FDT(fdt_setprop_string(fdt, 0, "host-model", buf));
> - g_free(buf);
> - }
> - } else {
> - /* -M host-model=<user-string> */
> - _FDT(fdt_setprop_string(fdt, 0, "host-model",
> spapr->host_model));
> - }
> + buf = spapr_get_valid_host_model(spapr);
> + if (buf) {
> + _FDT(fdt_setprop_string(fdt, 0, "host-model", buf));
> + g_free(buf);
> }
>
> - if (spapr->host_serial && !g_str_equal(spapr->host_serial, "none")) {
> - if (g_str_equal(spapr->host_serial, "passthrough")) {
> - /* -M host-serial=passthrough */
> - if (kvmppc_get_host_serial(&buf)) {
> - _FDT(fdt_setprop_string(fdt, 0, "host-serial", buf));
> - g_free(buf);
> - }
> - } else {
> - /* -M host-serial=<user-string> */
> - _FDT(fdt_setprop_string(fdt, 0, "host-serial",
> spapr->host_serial));
> - }
> + buf = spapr_get_valid_host_serial(spapr);
> + if (buf) {
> + _FDT(fdt_setprop_string(fdt, 0, "host-serial", buf));
> + g_free(buf);
> }
>
> buf = qemu_uuid_unparse_strdup(&qemu_uuid);
> diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
> index 2b4c05a2ec..5e0a1b2a8a 100644
> --- a/include/hw/ppc/spapr.h
> +++ b/include/hw/ppc/spapr.h
> @@ -856,6 +856,10 @@ int spapr_caps_post_migration(SpaprMachineState *spapr);
>
> void spapr_check_pagesize(SpaprMachineState *spapr, hwaddr pagesize,
> Error **errp);
> +
> +char *spapr_get_valid_host_serial(SpaprMachineState *spapr);
> +char *spapr_get_valid_host_model(SpaprMachineState *spapr);
> +
> /*
> * XIVE definitions
> */