Re: [Qemu-devel] [PATCH v6] hw/acpi: extract acpi_add_rom_blob()

2019-05-29 Thread Wei Yang
On Tue, May 28, 2019 at 11:01:32PM -0400, Michael S. Tsirkin wrote:
>On Tue, Mar 26, 2019 at 10:43:20AM +0800, Wei Yang wrote:
>> arm and i386 has almost the same function acpi_add_rom_blob(), except
>> giving different FWCfgCallback function.
>> 
>> This patch moves acpi_add_rom_blob() to utils.c by passing
>> FWCfgCallback to it.
>> 
>> Signed-off-by: Wei Yang 
>> Reviewed-by: Igor Mammedov 
>
>Conflicts with your other patches. Pls rebase on top.
>

Ah, would you mind letting me know which tree I need to rebase on?


-- 
Wei Yang
Help you, Help me



Re: [Qemu-devel] [PATCH v6] hw/acpi: extract acpi_add_rom_blob()

2019-05-28 Thread Michael S. Tsirkin
On Tue, Mar 26, 2019 at 10:43:20AM +0800, Wei Yang wrote:
> arm and i386 has almost the same function acpi_add_rom_blob(), except
> giving different FWCfgCallback function.
> 
> This patch moves acpi_add_rom_blob() to utils.c by passing
> FWCfgCallback to it.
> 
> Signed-off-by: Wei Yang 
> Reviewed-by: Igor Mammedov 

Conflicts with your other patches. Pls rebase on top.

> ---
> v6:
>   * change author from Igor to Michael
> v5:
>   * remove unnecessary header glib/gprintf.h
>   * rearrange include header to make it more suitable
> v4:
>   * extract -> moves
>   * adjust comment in source to make checkpatch happy
> v3:
>   * put acpi_add_rom_blob() to hw/acpi/utils.c
> v2:
>   * remove unused header in original source file
> 
> author
> ---
>  hw/acpi/Makefile.objs|  2 +-
>  hw/acpi/utils.c  | 36 
>  hw/arm/virt-acpi-build.c | 26 ++
>  hw/i386/acpi-build.c | 26 ++
>  include/hw/acpi/utils.h  |  9 +
>  5 files changed, 66 insertions(+), 33 deletions(-)
>  create mode 100644 hw/acpi/utils.c
>  create mode 100644 include/hw/acpi/utils.h
> 
> diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
> index 2d46e3789a..ba93c5b64a 100644
> --- a/hw/acpi/Makefile.objs
> +++ b/hw/acpi/Makefile.objs
> @@ -10,7 +10,7 @@ common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o
>  
>  common-obj-y += acpi_interface.o
>  common-obj-y += bios-linker-loader.o
> -common-obj-y += aml-build.o
> +common-obj-y += aml-build.o utils.o
>  common-obj-$(CONFIG_TPM) += tpm.o
>  
>  common-obj-$(CONFIG_IPMI) += ipmi.o
> diff --git a/hw/acpi/utils.c b/hw/acpi/utils.c
> new file mode 100644
> index 00..77b9e8148f
> --- /dev/null
> +++ b/hw/acpi/utils.c
> @@ -0,0 +1,36 @@
> +/*
> + * Utilities for generating ACPI tables and passing them to Guests
> + *
> + * Copyright (C) 2019 Intel Corporation
> + * Copyright (C) 2019 Red Hat Inc
> + *
> + * Author: Wei Yang 
> + * Author: Michael S. Tsirkin 
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> +
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> +
> + * You should have received a copy of the GNU General Public License along
> + * with this program; if not, see .
> + */
> +
> +#include "qemu/osdep.h"
> +#include "hw/acpi/aml-build.h"
> +#include "hw/acpi/utils.h"
> +#include "hw/loader.h"
> +
> +MemoryRegion *acpi_add_rom_blob(FWCfgCallback update, void *opaque,
> +GArray *blob, const char *name,
> +uint64_t max_size)
> +{
> +return rom_add_blob(name, blob->data, acpi_data_len(blob), max_size, -1,
> +name, update, opaque, NULL, true);
> +}
> +
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index 57679a89bf..a846f74a14 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -37,9 +37,9 @@
>  #include "hw/acpi/acpi.h"
>  #include "hw/nvram/fw_cfg.h"
>  #include "hw/acpi/bios-linker-loader.h"
> -#include "hw/loader.h"
>  #include "hw/hw.h"
>  #include "hw/acpi/aml-build.h"
> +#include "hw/acpi/utils.h"
>  #include "hw/pci/pcie_host.h"
>  #include "hw/pci/pci.h"
>  #include "hw/arm/virt.h"
> @@ -881,14 +881,6 @@ static void virt_acpi_build_reset(void *build_opaque)
>  build_state->patched = false;
>  }
>  
> -static MemoryRegion *acpi_add_rom_blob(AcpiBuildState *build_state,
> -   GArray *blob, const char *name,
> -   uint64_t max_size)
> -{
> -return rom_add_blob(name, blob->data, acpi_data_len(blob), max_size, -1,
> -name, virt_acpi_build_update, build_state, NULL, 
> true);
> -}
> -
>  static const VMStateDescription vmstate_virt_acpi_build = {
>  .name = "virt_acpi_build",
>  .version_id = 1,
> @@ -920,20 +912,22 @@ void virt_acpi_setup(VirtMachineState *vms)
>  virt_acpi_build(vms, &tables);
>  
>  /* Now expose it all to Guest */
> -build_state->table_mr = acpi_add_rom_blob(build_state, tables.table_data,
> -   ACPI_BUILD_TABLE_FILE,
> -   ACPI_BUILD_TABLE_MAX_SIZE);
> +build_state->table_mr = acpi_add_rom_blob(virt_acpi_build_update,
> +  build_state, tables.table_data,
> +  ACPI_BUILD_TABLE_FILE,
> +  ACPI_BUILD_TABLE_MAX_SIZE);
>  a

Re: [Qemu-devel] [PATCH v6] hw/acpi: extract acpi_add_rom_blob()

2019-05-27 Thread Wei Yang
On Mon, May 27, 2019 at 10:41:57AM -0400, Michael S. Tsirkin wrote:
>On Mon, May 27, 2019 at 10:34:23AM +0800, Wei Yang wrote:
>> On Tue, Mar 26, 2019 at 10:43:20AM +0800, Wei Yang wrote:
>> >arm and i386 has almost the same function acpi_add_rom_blob(), except
>> >giving different FWCfgCallback function.
>> >
>> >This patch moves acpi_add_rom_blob() to utils.c by passing
>> >FWCfgCallback to it.
>> >
>> >Signed-off-by: Wei Yang 
>> >Reviewed-by: Igor Mammedov 
>> >
>> 
>> Hello~ would this one be picked up?
>
>
>Yes in the next pull. It's a holiday here in states -
>hopefully tomorrow.
>

Ah, thanks~ Happy holiday~

>> >---
>> >v6:
>> >  * change author from Igor to Michael
>> >v5:
>> >  * remove unnecessary header glib/gprintf.h
>> >  * rearrange include header to make it more suitable
>> >v4:
>> >  * extract -> moves
>> >  * adjust comment in source to make checkpatch happy
>> >v3:
>> >  * put acpi_add_rom_blob() to hw/acpi/utils.c
>> >v2:
>> >  * remove unused header in original source file
>> >
>> >author
>> >---
>> > hw/acpi/Makefile.objs|  2 +-
>> > hw/acpi/utils.c  | 36 
>> > hw/arm/virt-acpi-build.c | 26 ++
>> > hw/i386/acpi-build.c | 26 ++
>> > include/hw/acpi/utils.h  |  9 +
>> > 5 files changed, 66 insertions(+), 33 deletions(-)
>> > create mode 100644 hw/acpi/utils.c
>> > create mode 100644 include/hw/acpi/utils.h
>> >
>> >diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
>> >index 2d46e3789a..ba93c5b64a 100644
>> >--- a/hw/acpi/Makefile.objs
>> >+++ b/hw/acpi/Makefile.objs
>> >@@ -10,7 +10,7 @@ common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o
>> > 
>> > common-obj-y += acpi_interface.o
>> > common-obj-y += bios-linker-loader.o
>> >-common-obj-y += aml-build.o
>> >+common-obj-y += aml-build.o utils.o
>> > common-obj-$(CONFIG_TPM) += tpm.o
>> > 
>> > common-obj-$(CONFIG_IPMI) += ipmi.o
>> >diff --git a/hw/acpi/utils.c b/hw/acpi/utils.c
>> >new file mode 100644
>> >index 00..77b9e8148f
>> >--- /dev/null
>> >+++ b/hw/acpi/utils.c
>> >@@ -0,0 +1,36 @@
>> >+/*
>> >+ * Utilities for generating ACPI tables and passing them to Guests
>> >+ *
>> >+ * Copyright (C) 2019 Intel Corporation
>> >+ * Copyright (C) 2019 Red Hat Inc
>> >+ *
>> >+ * Author: Wei Yang 
>> >+ * Author: Michael S. Tsirkin 
>> >+ *
>> >+ * This program is free software; you can redistribute it and/or modify
>> >+ * it under the terms of the GNU General Public License as published by
>> >+ * the Free Software Foundation; either version 2 of the License, or
>> >+ * (at your option) any later version.
>> >+
>> >+ * This program is distributed in the hope that it will be useful,
>> >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> >+ * GNU General Public License for more details.
>> >+
>> >+ * You should have received a copy of the GNU General Public License along
>> >+ * with this program; if not, see .
>> >+ */
>> >+
>> >+#include "qemu/osdep.h"
>> >+#include "hw/acpi/aml-build.h"
>> >+#include "hw/acpi/utils.h"
>> >+#include "hw/loader.h"
>> >+
>> >+MemoryRegion *acpi_add_rom_blob(FWCfgCallback update, void *opaque,
>> >+GArray *blob, const char *name,
>> >+uint64_t max_size)
>> >+{
>> >+return rom_add_blob(name, blob->data, acpi_data_len(blob), max_size, 
>> >-1,
>> >+name, update, opaque, NULL, true);
>> >+}
>> >+
>> >diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
>> >index 57679a89bf..a846f74a14 100644
>> >--- a/hw/arm/virt-acpi-build.c
>> >+++ b/hw/arm/virt-acpi-build.c
>> >@@ -37,9 +37,9 @@
>> > #include "hw/acpi/acpi.h"
>> > #include "hw/nvram/fw_cfg.h"
>> > #include "hw/acpi/bios-linker-loader.h"
>> >-#include "hw/loader.h"
>> > #include "hw/hw.h"
>> > #include "hw/acpi/aml-build.h"
>> >+#include "hw/acpi/utils.h"
>> > #include "hw/pci/pcie_host.h"
>> > #include "hw/pci/pci.h"
>> > #include "hw/arm/virt.h"
>> >@@ -881,14 +881,6 @@ static void virt_acpi_build_reset(void *build_opaque)
>> > build_state->patched = false;
>> > }
>> > 
>> >-static MemoryRegion *acpi_add_rom_blob(AcpiBuildState *build_state,
>> >-   GArray *blob, const char *name,
>> >-   uint64_t max_size)
>> >-{
>> >-return rom_add_blob(name, blob->data, acpi_data_len(blob), max_size, 
>> >-1,
>> >-name, virt_acpi_build_update, build_state, NULL, 
>> >true);
>> >-}
>> >-
>> > static const VMStateDescription vmstate_virt_acpi_build = {
>> > .name = "virt_acpi_build",
>> > .version_id = 1,
>> >@@ -920,20 +912,22 @@ void virt_acpi_setup(VirtMachineState *vms)
>> > virt_acpi_build(vms, &tables);
>> > 
>> > /* Now expose it all to Guest */
>> >-build_state->table_mr = acpi_add_rom_blob(bui

Re: [Qemu-devel] [PATCH v6] hw/acpi: extract acpi_add_rom_blob()

2019-05-27 Thread Michael S. Tsirkin
On Mon, May 27, 2019 at 10:34:23AM +0800, Wei Yang wrote:
> On Tue, Mar 26, 2019 at 10:43:20AM +0800, Wei Yang wrote:
> >arm and i386 has almost the same function acpi_add_rom_blob(), except
> >giving different FWCfgCallback function.
> >
> >This patch moves acpi_add_rom_blob() to utils.c by passing
> >FWCfgCallback to it.
> >
> >Signed-off-by: Wei Yang 
> >Reviewed-by: Igor Mammedov 
> >
> 
> Hello~ would this one be picked up?


Yes in the next pull. It's a holiday here in states -
hopefully tomorrow.

> >---
> >v6:
> >  * change author from Igor to Michael
> >v5:
> >  * remove unnecessary header glib/gprintf.h
> >  * rearrange include header to make it more suitable
> >v4:
> >  * extract -> moves
> >  * adjust comment in source to make checkpatch happy
> >v3:
> >  * put acpi_add_rom_blob() to hw/acpi/utils.c
> >v2:
> >  * remove unused header in original source file
> >
> >author
> >---
> > hw/acpi/Makefile.objs|  2 +-
> > hw/acpi/utils.c  | 36 
> > hw/arm/virt-acpi-build.c | 26 ++
> > hw/i386/acpi-build.c | 26 ++
> > include/hw/acpi/utils.h  |  9 +
> > 5 files changed, 66 insertions(+), 33 deletions(-)
> > create mode 100644 hw/acpi/utils.c
> > create mode 100644 include/hw/acpi/utils.h
> >
> >diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
> >index 2d46e3789a..ba93c5b64a 100644
> >--- a/hw/acpi/Makefile.objs
> >+++ b/hw/acpi/Makefile.objs
> >@@ -10,7 +10,7 @@ common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o
> > 
> > common-obj-y += acpi_interface.o
> > common-obj-y += bios-linker-loader.o
> >-common-obj-y += aml-build.o
> >+common-obj-y += aml-build.o utils.o
> > common-obj-$(CONFIG_TPM) += tpm.o
> > 
> > common-obj-$(CONFIG_IPMI) += ipmi.o
> >diff --git a/hw/acpi/utils.c b/hw/acpi/utils.c
> >new file mode 100644
> >index 00..77b9e8148f
> >--- /dev/null
> >+++ b/hw/acpi/utils.c
> >@@ -0,0 +1,36 @@
> >+/*
> >+ * Utilities for generating ACPI tables and passing them to Guests
> >+ *
> >+ * Copyright (C) 2019 Intel Corporation
> >+ * Copyright (C) 2019 Red Hat Inc
> >+ *
> >+ * Author: Wei Yang 
> >+ * Author: Michael S. Tsirkin 
> >+ *
> >+ * This program is free software; you can redistribute it and/or modify
> >+ * it under the terms of the GNU General Public License as published by
> >+ * the Free Software Foundation; either version 2 of the License, or
> >+ * (at your option) any later version.
> >+
> >+ * This program is distributed in the hope that it will be useful,
> >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
> >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> >+ * GNU General Public License for more details.
> >+
> >+ * You should have received a copy of the GNU General Public License along
> >+ * with this program; if not, see .
> >+ */
> >+
> >+#include "qemu/osdep.h"
> >+#include "hw/acpi/aml-build.h"
> >+#include "hw/acpi/utils.h"
> >+#include "hw/loader.h"
> >+
> >+MemoryRegion *acpi_add_rom_blob(FWCfgCallback update, void *opaque,
> >+GArray *blob, const char *name,
> >+uint64_t max_size)
> >+{
> >+return rom_add_blob(name, blob->data, acpi_data_len(blob), max_size, -1,
> >+name, update, opaque, NULL, true);
> >+}
> >+
> >diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> >index 57679a89bf..a846f74a14 100644
> >--- a/hw/arm/virt-acpi-build.c
> >+++ b/hw/arm/virt-acpi-build.c
> >@@ -37,9 +37,9 @@
> > #include "hw/acpi/acpi.h"
> > #include "hw/nvram/fw_cfg.h"
> > #include "hw/acpi/bios-linker-loader.h"
> >-#include "hw/loader.h"
> > #include "hw/hw.h"
> > #include "hw/acpi/aml-build.h"
> >+#include "hw/acpi/utils.h"
> > #include "hw/pci/pcie_host.h"
> > #include "hw/pci/pci.h"
> > #include "hw/arm/virt.h"
> >@@ -881,14 +881,6 @@ static void virt_acpi_build_reset(void *build_opaque)
> > build_state->patched = false;
> > }
> > 
> >-static MemoryRegion *acpi_add_rom_blob(AcpiBuildState *build_state,
> >-   GArray *blob, const char *name,
> >-   uint64_t max_size)
> >-{
> >-return rom_add_blob(name, blob->data, acpi_data_len(blob), max_size, -1,
> >-name, virt_acpi_build_update, build_state, NULL, 
> >true);
> >-}
> >-
> > static const VMStateDescription vmstate_virt_acpi_build = {
> > .name = "virt_acpi_build",
> > .version_id = 1,
> >@@ -920,20 +912,22 @@ void virt_acpi_setup(VirtMachineState *vms)
> > virt_acpi_build(vms, &tables);
> > 
> > /* Now expose it all to Guest */
> >-build_state->table_mr = acpi_add_rom_blob(build_state, 
> >tables.table_data,
> >-   ACPI_BUILD_TABLE_FILE,
> >-   ACPI_BUILD_TABLE_MAX_SIZE);
> >+build_state->table_mr = acpi_add_rom_blob(virt_

Re: [Qemu-devel] [PATCH v6] hw/acpi: extract acpi_add_rom_blob()

2019-05-26 Thread Wei Yang
On Tue, Mar 26, 2019 at 10:43:20AM +0800, Wei Yang wrote:
>arm and i386 has almost the same function acpi_add_rom_blob(), except
>giving different FWCfgCallback function.
>
>This patch moves acpi_add_rom_blob() to utils.c by passing
>FWCfgCallback to it.
>
>Signed-off-by: Wei Yang 
>Reviewed-by: Igor Mammedov 
>

Hello~ would this one be picked up?

>---
>v6:
>  * change author from Igor to Michael
>v5:
>  * remove unnecessary header glib/gprintf.h
>  * rearrange include header to make it more suitable
>v4:
>  * extract -> moves
>  * adjust comment in source to make checkpatch happy
>v3:
>  * put acpi_add_rom_blob() to hw/acpi/utils.c
>v2:
>  * remove unused header in original source file
>
>author
>---
> hw/acpi/Makefile.objs|  2 +-
> hw/acpi/utils.c  | 36 
> hw/arm/virt-acpi-build.c | 26 ++
> hw/i386/acpi-build.c | 26 ++
> include/hw/acpi/utils.h  |  9 +
> 5 files changed, 66 insertions(+), 33 deletions(-)
> create mode 100644 hw/acpi/utils.c
> create mode 100644 include/hw/acpi/utils.h
>
>diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
>index 2d46e3789a..ba93c5b64a 100644
>--- a/hw/acpi/Makefile.objs
>+++ b/hw/acpi/Makefile.objs
>@@ -10,7 +10,7 @@ common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o
> 
> common-obj-y += acpi_interface.o
> common-obj-y += bios-linker-loader.o
>-common-obj-y += aml-build.o
>+common-obj-y += aml-build.o utils.o
> common-obj-$(CONFIG_TPM) += tpm.o
> 
> common-obj-$(CONFIG_IPMI) += ipmi.o
>diff --git a/hw/acpi/utils.c b/hw/acpi/utils.c
>new file mode 100644
>index 00..77b9e8148f
>--- /dev/null
>+++ b/hw/acpi/utils.c
>@@ -0,0 +1,36 @@
>+/*
>+ * Utilities for generating ACPI tables and passing them to Guests
>+ *
>+ * Copyright (C) 2019 Intel Corporation
>+ * Copyright (C) 2019 Red Hat Inc
>+ *
>+ * Author: Wei Yang 
>+ * Author: Michael S. Tsirkin 
>+ *
>+ * This program is free software; you can redistribute it and/or modify
>+ * it under the terms of the GNU General Public License as published by
>+ * the Free Software Foundation; either version 2 of the License, or
>+ * (at your option) any later version.
>+
>+ * This program is distributed in the hope that it will be useful,
>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>+ * GNU General Public License for more details.
>+
>+ * You should have received a copy of the GNU General Public License along
>+ * with this program; if not, see .
>+ */
>+
>+#include "qemu/osdep.h"
>+#include "hw/acpi/aml-build.h"
>+#include "hw/acpi/utils.h"
>+#include "hw/loader.h"
>+
>+MemoryRegion *acpi_add_rom_blob(FWCfgCallback update, void *opaque,
>+GArray *blob, const char *name,
>+uint64_t max_size)
>+{
>+return rom_add_blob(name, blob->data, acpi_data_len(blob), max_size, -1,
>+name, update, opaque, NULL, true);
>+}
>+
>diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
>index 57679a89bf..a846f74a14 100644
>--- a/hw/arm/virt-acpi-build.c
>+++ b/hw/arm/virt-acpi-build.c
>@@ -37,9 +37,9 @@
> #include "hw/acpi/acpi.h"
> #include "hw/nvram/fw_cfg.h"
> #include "hw/acpi/bios-linker-loader.h"
>-#include "hw/loader.h"
> #include "hw/hw.h"
> #include "hw/acpi/aml-build.h"
>+#include "hw/acpi/utils.h"
> #include "hw/pci/pcie_host.h"
> #include "hw/pci/pci.h"
> #include "hw/arm/virt.h"
>@@ -881,14 +881,6 @@ static void virt_acpi_build_reset(void *build_opaque)
> build_state->patched = false;
> }
> 
>-static MemoryRegion *acpi_add_rom_blob(AcpiBuildState *build_state,
>-   GArray *blob, const char *name,
>-   uint64_t max_size)
>-{
>-return rom_add_blob(name, blob->data, acpi_data_len(blob), max_size, -1,
>-name, virt_acpi_build_update, build_state, NULL, 
>true);
>-}
>-
> static const VMStateDescription vmstate_virt_acpi_build = {
> .name = "virt_acpi_build",
> .version_id = 1,
>@@ -920,20 +912,22 @@ void virt_acpi_setup(VirtMachineState *vms)
> virt_acpi_build(vms, &tables);
> 
> /* Now expose it all to Guest */
>-build_state->table_mr = acpi_add_rom_blob(build_state, tables.table_data,
>-   ACPI_BUILD_TABLE_FILE,
>-   ACPI_BUILD_TABLE_MAX_SIZE);
>+build_state->table_mr = acpi_add_rom_blob(virt_acpi_build_update,
>+  build_state, tables.table_data,
>+  ACPI_BUILD_TABLE_FILE,
>+  ACPI_BUILD_TABLE_MAX_SIZE);
> assert(build_state->table_mr != NULL);
> 
> build_state->linker_mr =
>-acpi_add_rom_blob(build_state, tables.linker->cmd_blob,
>-   

Re: [Qemu-devel] [PATCH v6] hw/acpi: extract acpi_add_rom_blob()

2019-05-14 Thread Wei Yang
On Tue, Mar 26, 2019 at 10:43:20AM +0800, Wei Yang wrote:
>arm and i386 has almost the same function acpi_add_rom_blob(), except
>giving different FWCfgCallback function.
>
>This patch moves acpi_add_rom_blob() to utils.c by passing
>FWCfgCallback to it.
>
>Signed-off-by: Wei Yang 
>Reviewed-by: Igor Mammedov 

Hi, all

would someone pick up this?

>
>---
>v6:
>  * change author from Igor to Michael
>v5:
>  * remove unnecessary header glib/gprintf.h
>  * rearrange include header to make it more suitable
>v4:
>  * extract -> moves
>  * adjust comment in source to make checkpatch happy
>v3:
>  * put acpi_add_rom_blob() to hw/acpi/utils.c
>v2:
>  * remove unused header in original source file
>
>author
>---
> hw/acpi/Makefile.objs|  2 +-
> hw/acpi/utils.c  | 36 
> hw/arm/virt-acpi-build.c | 26 ++
> hw/i386/acpi-build.c | 26 ++
> include/hw/acpi/utils.h  |  9 +
> 5 files changed, 66 insertions(+), 33 deletions(-)
> create mode 100644 hw/acpi/utils.c
> create mode 100644 include/hw/acpi/utils.h
>
>diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
>index 2d46e3789a..ba93c5b64a 100644
>--- a/hw/acpi/Makefile.objs
>+++ b/hw/acpi/Makefile.objs
>@@ -10,7 +10,7 @@ common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o
> 
> common-obj-y += acpi_interface.o
> common-obj-y += bios-linker-loader.o
>-common-obj-y += aml-build.o
>+common-obj-y += aml-build.o utils.o
> common-obj-$(CONFIG_TPM) += tpm.o
> 
> common-obj-$(CONFIG_IPMI) += ipmi.o
>diff --git a/hw/acpi/utils.c b/hw/acpi/utils.c
>new file mode 100644
>index 00..77b9e8148f
>--- /dev/null
>+++ b/hw/acpi/utils.c
>@@ -0,0 +1,36 @@
>+/*
>+ * Utilities for generating ACPI tables and passing them to Guests
>+ *
>+ * Copyright (C) 2019 Intel Corporation
>+ * Copyright (C) 2019 Red Hat Inc
>+ *
>+ * Author: Wei Yang 
>+ * Author: Michael S. Tsirkin 
>+ *
>+ * This program is free software; you can redistribute it and/or modify
>+ * it under the terms of the GNU General Public License as published by
>+ * the Free Software Foundation; either version 2 of the License, or
>+ * (at your option) any later version.
>+
>+ * This program is distributed in the hope that it will be useful,
>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>+ * GNU General Public License for more details.
>+
>+ * You should have received a copy of the GNU General Public License along
>+ * with this program; if not, see .
>+ */
>+
>+#include "qemu/osdep.h"
>+#include "hw/acpi/aml-build.h"
>+#include "hw/acpi/utils.h"
>+#include "hw/loader.h"
>+
>+MemoryRegion *acpi_add_rom_blob(FWCfgCallback update, void *opaque,
>+GArray *blob, const char *name,
>+uint64_t max_size)
>+{
>+return rom_add_blob(name, blob->data, acpi_data_len(blob), max_size, -1,
>+name, update, opaque, NULL, true);
>+}
>+
>diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
>index 57679a89bf..a846f74a14 100644
>--- a/hw/arm/virt-acpi-build.c
>+++ b/hw/arm/virt-acpi-build.c
>@@ -37,9 +37,9 @@
> #include "hw/acpi/acpi.h"
> #include "hw/nvram/fw_cfg.h"
> #include "hw/acpi/bios-linker-loader.h"
>-#include "hw/loader.h"
> #include "hw/hw.h"
> #include "hw/acpi/aml-build.h"
>+#include "hw/acpi/utils.h"
> #include "hw/pci/pcie_host.h"
> #include "hw/pci/pci.h"
> #include "hw/arm/virt.h"
>@@ -881,14 +881,6 @@ static void virt_acpi_build_reset(void *build_opaque)
> build_state->patched = false;
> }
> 
>-static MemoryRegion *acpi_add_rom_blob(AcpiBuildState *build_state,
>-   GArray *blob, const char *name,
>-   uint64_t max_size)
>-{
>-return rom_add_blob(name, blob->data, acpi_data_len(blob), max_size, -1,
>-name, virt_acpi_build_update, build_state, NULL, 
>true);
>-}
>-
> static const VMStateDescription vmstate_virt_acpi_build = {
> .name = "virt_acpi_build",
> .version_id = 1,
>@@ -920,20 +912,22 @@ void virt_acpi_setup(VirtMachineState *vms)
> virt_acpi_build(vms, &tables);
> 
> /* Now expose it all to Guest */
>-build_state->table_mr = acpi_add_rom_blob(build_state, tables.table_data,
>-   ACPI_BUILD_TABLE_FILE,
>-   ACPI_BUILD_TABLE_MAX_SIZE);
>+build_state->table_mr = acpi_add_rom_blob(virt_acpi_build_update,
>+  build_state, tables.table_data,
>+  ACPI_BUILD_TABLE_FILE,
>+  ACPI_BUILD_TABLE_MAX_SIZE);
> assert(build_state->table_mr != NULL);
> 
> build_state->linker_mr =
>-acpi_add_rom_blob(build_state, tables.linker->cmd_blob,
>-