diff mbox

linux-user: remove nmi.c and fw-path-provider.c

Message ID 20171103193802.11876-1-laurent@vivier.eu (mailing list archive)
State New, archived
Headers show

Commit Message

Laurent Vivier Nov. 3, 2017, 7:38 p.m. UTC
linux-user binaries don't need firmware and NMI,
so don't add them in this case, move QDEV
firmware functions to qdev-fw.c

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 hw/core/Makefile.objs |  5 +--
 hw/core/qdev-fw.c     | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/core/qdev.c        | 77 -----------------------------------------
 3 files changed, 99 insertions(+), 79 deletions(-)
 create mode 100644 hw/core/qdev-fw.c

Comments

Alexey Kardashevskiy Nov. 6, 2017, 12:44 a.m. UTC | #1
On 04/11/17 06:38, Laurent Vivier wrote:
> linux-user binaries don't need firmware and NMI,
> so don't add them in this case, move QDEV
> firmware functions to qdev-fw.c


When configured with --target-list=ppc64-linux-user , config-host.mak gets
TARGET_DIRS=ppc64-linux-user  and I would expect CONFIG_SOFTMMU to be
disabled in Makefile#27 and qdev.c not to be compiled at all but this is
not happening, I wonder why...


> 
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
>  hw/core/Makefile.objs |  5 +--
>  hw/core/qdev-fw.c     | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  hw/core/qdev.c        | 77 -----------------------------------------
>  3 files changed, 99 insertions(+), 79 deletions(-)
>  create mode 100644 hw/core/qdev-fw.c
> 
> diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs
> index f8d7a4aaed..1240728c87 100644
> --- a/hw/core/Makefile.objs
> +++ b/hw/core/Makefile.objs
> @@ -1,11 +1,12 @@
>  # core qdev-related obj files, also used by *-user:
>  common-obj-y += qdev.o qdev-properties.o
>  common-obj-y += bus.o reset.o
> -common-obj-y += fw-path-provider.o
> +common-obj-$(CONFIG_SOFTMMU) += qdev-fw.o
> +common-obj-$(CONFIG_SOFTMMU) += fw-path-provider.o
>  # irq.o needed for qdev GPIO handling:
>  common-obj-y += irq.o
>  common-obj-y += hotplug.o
> -common-obj-y += nmi.o
> +common-obj-$(CONFIG_SOFTMMU) += nmi.o
>  
>  common-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o
>  common-obj-$(CONFIG_XILINX_AXI) += stream.o
Laurent Vivier Nov. 6, 2017, 10:15 a.m. UTC | #2
Le 06/11/2017 à 01:44, Alexey Kardashevskiy a écrit :
> On 04/11/17 06:38, Laurent Vivier wrote:
>> linux-user binaries don't need firmware and NMI,
>> so don't add them in this case, move QDEV
>> firmware functions to qdev-fw.c
> 
> 
> When configured with --target-list=ppc64-linux-user , config-host.mak gets
> TARGET_DIRS=ppc64-linux-user  and I would expect CONFIG_SOFTMMU to be
> disabled in Makefile#27 and qdev.c not to be compiled at all but this is
> not happening, I wonder why...

this is driven by config-target.mak and config-target.h which are target
specific.

for ppc64-linux-user, you have ppc64-linux-user/config-target.mak:
...
CONFIG_LINUX_USER=y
...

for ppc64-softmmu/config-target.mak:
...
CONFIG_SOFTMMU=y
...

Thanks,
Laurent
Paolo Bonzini Nov. 7, 2017, 12:48 p.m. UTC | #3
On 03/11/2017 20:38, Laurent Vivier wrote:
> linux-user binaries don't need firmware and NMI,
> so don't add them in this case, move QDEV
> firmware functions to qdev-fw.c
> 
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

> ---
>  hw/core/Makefile.objs |  5 +--
>  hw/core/qdev-fw.c     | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  hw/core/qdev.c        | 77 -----------------------------------------
>  3 files changed, 99 insertions(+), 79 deletions(-)
>  create mode 100644 hw/core/qdev-fw.c
> 
> diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs
> index f8d7a4aaed..1240728c87 100644
> --- a/hw/core/Makefile.objs
> +++ b/hw/core/Makefile.objs
> @@ -1,11 +1,12 @@
>  # core qdev-related obj files, also used by *-user:
>  common-obj-y += qdev.o qdev-properties.o
>  common-obj-y += bus.o reset.o
> -common-obj-y += fw-path-provider.o
> +common-obj-$(CONFIG_SOFTMMU) += qdev-fw.o
> +common-obj-$(CONFIG_SOFTMMU) += fw-path-provider.o
>  # irq.o needed for qdev GPIO handling:
>  common-obj-y += irq.o
>  common-obj-y += hotplug.o
> -common-obj-y += nmi.o
> +common-obj-$(CONFIG_SOFTMMU) += nmi.o
>  
>  common-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o
>  common-obj-$(CONFIG_XILINX_AXI) += stream.o
> diff --git a/hw/core/qdev-fw.c b/hw/core/qdev-fw.c
> new file mode 100644
> index 0000000000..aa35e9d0ac
> --- /dev/null
> +++ b/hw/core/qdev-fw.c
> @@ -0,0 +1,96 @@
> +/*
> + *  qdev fw helpers
> + *
> + *  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 <http://www.gnu.org/licenses/>.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "hw/qdev.h"
> +#include "hw/fw-path-provider.h"
> +
> +const char *qdev_fw_name(DeviceState *dev)
> +{
> +    DeviceClass *dc = DEVICE_GET_CLASS(dev);
> +
> +    if (dc->fw_name) {
> +        return dc->fw_name;
> +    }
> +
> +    return object_get_typename(OBJECT(dev));
> +}
> +
> +static char *bus_get_fw_dev_path(BusState *bus, DeviceState *dev)
> +{
> +    BusClass *bc = BUS_GET_CLASS(bus);
> +
> +    if (bc->get_fw_dev_path) {
> +        return bc->get_fw_dev_path(dev);
> +    }
> +
> +    return NULL;
> +}
> +
> +static char *qdev_get_fw_dev_path_from_handler(BusState *bus, DeviceState *dev)
> +{
> +    Object *obj = OBJECT(dev);
> +    char *d = NULL;
> +
> +    while (!d && obj->parent) {
> +        obj = obj->parent;
> +        d = fw_path_provider_try_get_dev_path(obj, bus, dev);
> +    }
> +    return d;
> +}
> +
> +char *qdev_get_own_fw_dev_path_from_handler(BusState *bus, DeviceState *dev)
> +{
> +    Object *obj = OBJECT(dev);
> +
> +    return fw_path_provider_try_get_dev_path(obj, bus, dev);
> +}
> +
> +static int qdev_get_fw_dev_path_helper(DeviceState *dev, char *p, int size)
> +{
> +    int l = 0;
> +
> +    if (dev && dev->parent_bus) {
> +        char *d;
> +        l = qdev_get_fw_dev_path_helper(dev->parent_bus->parent, p, size);
> +        d = qdev_get_fw_dev_path_from_handler(dev->parent_bus, dev);
> +        if (!d) {
> +            d = bus_get_fw_dev_path(dev->parent_bus, dev);
> +        }
> +        if (d) {
> +            l += snprintf(p + l, size - l, "%s", d);
> +            g_free(d);
> +        } else {
> +            return l;
> +        }
> +    }
> +    l += snprintf(p + l , size - l, "/");
> +
> +    return l;
> +}
> +
> +char *qdev_get_fw_dev_path(DeviceState *dev)
> +{
> +    char path[128];
> +    int l;
> +
> +    l = qdev_get_fw_dev_path_helper(dev, path, 128);
> +
> +    path[l - 1] = '\0';
> +
> +    return g_strdup(path);
> +}
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 11112951a5..49df62ba8c 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -27,7 +27,6 @@
>  
>  #include "qemu/osdep.h"
>  #include "hw/qdev.h"
> -#include "hw/fw-path-provider.h"
>  #include "sysemu/sysemu.h"
>  #include "qapi/qmp/qerror.h"
>  #include "qapi/visitor.h"
> @@ -48,17 +47,6 @@ const VMStateDescription *qdev_get_vmsd(DeviceState *dev)
>      return dc->vmsd;
>  }
>  
> -const char *qdev_fw_name(DeviceState *dev)
> -{
> -    DeviceClass *dc = DEVICE_GET_CLASS(dev);
> -
> -    if (dc->fw_name) {
> -        return dc->fw_name;
> -    }
> -
> -    return object_get_typename(OBJECT(dev));
> -}
> -
>  static void bus_remove_child(BusState *bus, DeviceState *child)
>  {
>      BusChild *kid;
> @@ -619,71 +607,6 @@ DeviceState *qdev_find_recursive(BusState *bus, const char *id)
>      return NULL;
>  }
>  
> -static char *bus_get_fw_dev_path(BusState *bus, DeviceState *dev)
> -{
> -    BusClass *bc = BUS_GET_CLASS(bus);
> -
> -    if (bc->get_fw_dev_path) {
> -        return bc->get_fw_dev_path(dev);
> -    }
> -
> -    return NULL;
> -}
> -
> -static char *qdev_get_fw_dev_path_from_handler(BusState *bus, DeviceState *dev)
> -{
> -    Object *obj = OBJECT(dev);
> -    char *d = NULL;
> -
> -    while (!d && obj->parent) {
> -        obj = obj->parent;
> -        d = fw_path_provider_try_get_dev_path(obj, bus, dev);
> -    }
> -    return d;
> -}
> -
> -char *qdev_get_own_fw_dev_path_from_handler(BusState *bus, DeviceState *dev)
> -{
> -    Object *obj = OBJECT(dev);
> -
> -    return fw_path_provider_try_get_dev_path(obj, bus, dev);
> -}
> -
> -static int qdev_get_fw_dev_path_helper(DeviceState *dev, char *p, int size)
> -{
> -    int l = 0;
> -
> -    if (dev && dev->parent_bus) {
> -        char *d;
> -        l = qdev_get_fw_dev_path_helper(dev->parent_bus->parent, p, size);
> -        d = qdev_get_fw_dev_path_from_handler(dev->parent_bus, dev);
> -        if (!d) {
> -            d = bus_get_fw_dev_path(dev->parent_bus, dev);
> -        }
> -        if (d) {
> -            l += snprintf(p + l, size - l, "%s", d);
> -            g_free(d);
> -        } else {
> -            return l;
> -        }
> -    }
> -    l += snprintf(p + l , size - l, "/");
> -
> -    return l;
> -}
> -
> -char* qdev_get_fw_dev_path(DeviceState *dev)
> -{
> -    char path[128];
> -    int l;
> -
> -    l = qdev_get_fw_dev_path_helper(dev, path, 128);
> -
> -    path[l-1] = '\0';
> -
> -    return g_strdup(path);
> -}
> -
>  char *qdev_get_dev_path(DeviceState *dev)
>  {
>      BusClass *bc;
>
diff mbox

Patch

diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs
index f8d7a4aaed..1240728c87 100644
--- a/hw/core/Makefile.objs
+++ b/hw/core/Makefile.objs
@@ -1,11 +1,12 @@ 
 # core qdev-related obj files, also used by *-user:
 common-obj-y += qdev.o qdev-properties.o
 common-obj-y += bus.o reset.o
-common-obj-y += fw-path-provider.o
+common-obj-$(CONFIG_SOFTMMU) += qdev-fw.o
+common-obj-$(CONFIG_SOFTMMU) += fw-path-provider.o
 # irq.o needed for qdev GPIO handling:
 common-obj-y += irq.o
 common-obj-y += hotplug.o
-common-obj-y += nmi.o
+common-obj-$(CONFIG_SOFTMMU) += nmi.o
 
 common-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o
 common-obj-$(CONFIG_XILINX_AXI) += stream.o
diff --git a/hw/core/qdev-fw.c b/hw/core/qdev-fw.c
new file mode 100644
index 0000000000..aa35e9d0ac
--- /dev/null
+++ b/hw/core/qdev-fw.c
@@ -0,0 +1,96 @@ 
+/*
+ *  qdev fw helpers
+ *
+ *  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 <http://www.gnu.org/licenses/>.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/qdev.h"
+#include "hw/fw-path-provider.h"
+
+const char *qdev_fw_name(DeviceState *dev)
+{
+    DeviceClass *dc = DEVICE_GET_CLASS(dev);
+
+    if (dc->fw_name) {
+        return dc->fw_name;
+    }
+
+    return object_get_typename(OBJECT(dev));
+}
+
+static char *bus_get_fw_dev_path(BusState *bus, DeviceState *dev)
+{
+    BusClass *bc = BUS_GET_CLASS(bus);
+
+    if (bc->get_fw_dev_path) {
+        return bc->get_fw_dev_path(dev);
+    }
+
+    return NULL;
+}
+
+static char *qdev_get_fw_dev_path_from_handler(BusState *bus, DeviceState *dev)
+{
+    Object *obj = OBJECT(dev);
+    char *d = NULL;
+
+    while (!d && obj->parent) {
+        obj = obj->parent;
+        d = fw_path_provider_try_get_dev_path(obj, bus, dev);
+    }
+    return d;
+}
+
+char *qdev_get_own_fw_dev_path_from_handler(BusState *bus, DeviceState *dev)
+{
+    Object *obj = OBJECT(dev);
+
+    return fw_path_provider_try_get_dev_path(obj, bus, dev);
+}
+
+static int qdev_get_fw_dev_path_helper(DeviceState *dev, char *p, int size)
+{
+    int l = 0;
+
+    if (dev && dev->parent_bus) {
+        char *d;
+        l = qdev_get_fw_dev_path_helper(dev->parent_bus->parent, p, size);
+        d = qdev_get_fw_dev_path_from_handler(dev->parent_bus, dev);
+        if (!d) {
+            d = bus_get_fw_dev_path(dev->parent_bus, dev);
+        }
+        if (d) {
+            l += snprintf(p + l, size - l, "%s", d);
+            g_free(d);
+        } else {
+            return l;
+        }
+    }
+    l += snprintf(p + l , size - l, "/");
+
+    return l;
+}
+
+char *qdev_get_fw_dev_path(DeviceState *dev)
+{
+    char path[128];
+    int l;
+
+    l = qdev_get_fw_dev_path_helper(dev, path, 128);
+
+    path[l - 1] = '\0';
+
+    return g_strdup(path);
+}
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 11112951a5..49df62ba8c 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -27,7 +27,6 @@ 
 
 #include "qemu/osdep.h"
 #include "hw/qdev.h"
-#include "hw/fw-path-provider.h"
 #include "sysemu/sysemu.h"
 #include "qapi/qmp/qerror.h"
 #include "qapi/visitor.h"
@@ -48,17 +47,6 @@  const VMStateDescription *qdev_get_vmsd(DeviceState *dev)
     return dc->vmsd;
 }
 
-const char *qdev_fw_name(DeviceState *dev)
-{
-    DeviceClass *dc = DEVICE_GET_CLASS(dev);
-
-    if (dc->fw_name) {
-        return dc->fw_name;
-    }
-
-    return object_get_typename(OBJECT(dev));
-}
-
 static void bus_remove_child(BusState *bus, DeviceState *child)
 {
     BusChild *kid;
@@ -619,71 +607,6 @@  DeviceState *qdev_find_recursive(BusState *bus, const char *id)
     return NULL;
 }
 
-static char *bus_get_fw_dev_path(BusState *bus, DeviceState *dev)
-{
-    BusClass *bc = BUS_GET_CLASS(bus);
-
-    if (bc->get_fw_dev_path) {
-        return bc->get_fw_dev_path(dev);
-    }
-
-    return NULL;
-}
-
-static char *qdev_get_fw_dev_path_from_handler(BusState *bus, DeviceState *dev)
-{
-    Object *obj = OBJECT(dev);
-    char *d = NULL;
-
-    while (!d && obj->parent) {
-        obj = obj->parent;
-        d = fw_path_provider_try_get_dev_path(obj, bus, dev);
-    }
-    return d;
-}
-
-char *qdev_get_own_fw_dev_path_from_handler(BusState *bus, DeviceState *dev)
-{
-    Object *obj = OBJECT(dev);
-
-    return fw_path_provider_try_get_dev_path(obj, bus, dev);
-}
-
-static int qdev_get_fw_dev_path_helper(DeviceState *dev, char *p, int size)
-{
-    int l = 0;
-
-    if (dev && dev->parent_bus) {
-        char *d;
-        l = qdev_get_fw_dev_path_helper(dev->parent_bus->parent, p, size);
-        d = qdev_get_fw_dev_path_from_handler(dev->parent_bus, dev);
-        if (!d) {
-            d = bus_get_fw_dev_path(dev->parent_bus, dev);
-        }
-        if (d) {
-            l += snprintf(p + l, size - l, "%s", d);
-            g_free(d);
-        } else {
-            return l;
-        }
-    }
-    l += snprintf(p + l , size - l, "/");
-
-    return l;
-}
-
-char* qdev_get_fw_dev_path(DeviceState *dev)
-{
-    char path[128];
-    int l;
-
-    l = qdev_get_fw_dev_path_helper(dev, path, 128);
-
-    path[l-1] = '\0';
-
-    return g_strdup(path);
-}
-
 char *qdev_get_dev_path(DeviceState *dev)
 {
     BusClass *bc;