diff mbox series

[5/5] include: Move hardware version declarations to new qemu/hw-version.h

Message ID 20220208200856.3558249-6-peter.maydell@linaro.org
State New
Headers show
Series include: Trim some fat from osdep.h | expand

Commit Message

Peter Maydell Feb. 8, 2022, 8:08 p.m. UTC
The "hardware version" machinery (qemu_set_hw_version(),
qemu_hw_version(), and the QEMU_HW_VERSION define) is used by fewer
than 10 files.  Move it out from osdep.h into a new
qemu/hw-version.h.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 include/qemu/hw-version.h | 27 +++++++++++++++++++++++++++
 include/qemu/osdep.h      | 16 ----------------
 hw/arm/nseries.c          |  1 +
 hw/ide/core.c             |  1 +
 hw/scsi/megasas.c         |  1 +
 hw/scsi/scsi-bus.c        |  1 +
 hw/scsi/scsi-disk.c       |  1 +
 softmmu/vl.c              |  1 +
 target/i386/cpu.c         |  1 +
 target/s390x/cpu_models.c |  1 +
 util/osdep.c              |  1 +
 11 files changed, 36 insertions(+), 16 deletions(-)
 create mode 100644 include/qemu/hw-version.h

Comments

Richard Henderson Feb. 8, 2022, 11:06 p.m. UTC | #1
On 2/9/22 07:08, Peter Maydell wrote:
> The "hardware version" machinery (qemu_set_hw_version(),
> qemu_hw_version(), and the QEMU_HW_VERSION define) is used by fewer
> than 10 files.  Move it out from osdep.h into a new
> qemu/hw-version.h.
> 
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
>   include/qemu/hw-version.h | 27 +++++++++++++++++++++++++++
>   include/qemu/osdep.h      | 16 ----------------
>   hw/arm/nseries.c          |  1 +
>   hw/ide/core.c             |  1 +
>   hw/scsi/megasas.c         |  1 +
>   hw/scsi/scsi-bus.c        |  1 +
>   hw/scsi/scsi-disk.c       |  1 +
>   softmmu/vl.c              |  1 +
>   target/i386/cpu.c         |  1 +
>   target/s390x/cpu_models.c |  1 +
>   util/osdep.c              |  1 +
>   11 files changed, 36 insertions(+), 16 deletions(-)
>   create mode 100644 include/qemu/hw-version.h

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
Peter Maydell Feb. 9, 2022, 9:25 a.m. UTC | #2
On Wed, 9 Feb 2022 at 09:20, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> On 8/2/22 21:08, Peter Maydell wrote:
> > The "hardware version" machinery (qemu_set_hw_version(),
> > qemu_hw_version(), and the QEMU_HW_VERSION define) is used by fewer
> > than 10 files.  Move it out from osdep.h into a new
> > qemu/hw-version.h.
> >
> > Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> > ---
> >   include/qemu/hw-version.h | 27 +++++++++++++++++++++++++++
> >   include/qemu/osdep.h      | 16 ----------------
> >   hw/arm/nseries.c          |  1 +
> >   hw/ide/core.c             |  1 +
> >   hw/scsi/megasas.c         |  1 +
> >   hw/scsi/scsi-bus.c        |  1 +
> >   hw/scsi/scsi-disk.c       |  1 +
> >   softmmu/vl.c              |  1 +
> >   target/i386/cpu.c         |  1 +
> >   target/s390x/cpu_models.c |  1 +
> >   util/osdep.c              |  1 +
> >   11 files changed, 36 insertions(+), 16 deletions(-)
> >   create mode 100644 include/qemu/hw-version.h
> >
> > diff --git a/include/qemu/hw-version.h b/include/qemu/hw-version.h
> > new file mode 100644
> > index 00000000000..730a8c904d9
> > --- /dev/null
> > +++ b/include/qemu/hw-version.h
> > @@ -0,0 +1,27 @@
> > +/*
> > + * QEMU "hardware version" machinery
> > + *
> > + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> > + * See the COPYING file in the top-level directory.
> > + */
> > +#ifndef QEMU_HW_VERSION_H
> > +#define QEMU_HW_VERSION_H
> > +
> > +/*
> > + * Starting on QEMU 2.5, qemu_hw_version() returns "2.5+" by default
> > + * instead of QEMU_VERSION, so setting hw_version on MachineClass
> > + * is no longer mandatory.
> > + *
> > + * Do NOT change this string, or it will break compatibility on all
> > + * machine classes that don't set hw_version.
> > + */
> > +#define QEMU_HW_VERSION "2.5+"
> > +
> > +/* QEMU "hardware version" setting. Used to replace code that exposed
> > + * QEMU_VERSION to guests in the past and need to keep compatibility.
> > + * Do not use qemu_hw_version() in new code.
>
> Can you include the "legacy" word somewhere in the include path?

I'm not completely convinced that (a) we have a clear idea of
what of our APIs are legacy and what are not or (b) that we could
coherently move the 'legacy' ones into separate files.
If you want to propose something like that as an RFC, I don't
100% object to it, but I don't want to do a very small subset
of that as part of what is really just a "get stuff out of osdep"
series.

thanks
-- PMM
Peter Maydell Feb. 9, 2022, 1:44 p.m. UTC | #3
On Wed, 9 Feb 2022 at 10:10, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> On 9/2/22 10:25, Peter Maydell wrote:
> > On Wed, 9 Feb 2022 at 09:20, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> > I'm not completely convinced that (a) we have a clear idea of
> > what of our APIs are legacy and what are not or (b) that we could
> > coherently move the 'legacy' ones into separate files.
> > If you want to propose something like that as an RFC, I don't
> > 100% object to it, but I don't want to do a very small subset
> > of that as part of what is really just a "get stuff out of osdep"
> > series.
>
> OK, thanks.

Thinking about the 'legacy API' issue a bit, rather than putting
them in particular include paths, maybe we could have a file
we list them in, and have checkpatch automatically check for new
uses of them. But I think our major problems with legacy APIs are
more "we never go through and complete transitions" rather than
"new code coming in uses old APIs we're trying to move away from"...

-- PMM
diff mbox series

Patch

diff --git a/include/qemu/hw-version.h b/include/qemu/hw-version.h
new file mode 100644
index 00000000000..730a8c904d9
--- /dev/null
+++ b/include/qemu/hw-version.h
@@ -0,0 +1,27 @@ 
+/*
+ * QEMU "hardware version" machinery
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef QEMU_HW_VERSION_H
+#define QEMU_HW_VERSION_H
+
+/*
+ * Starting on QEMU 2.5, qemu_hw_version() returns "2.5+" by default
+ * instead of QEMU_VERSION, so setting hw_version on MachineClass
+ * is no longer mandatory.
+ *
+ * Do NOT change this string, or it will break compatibility on all
+ * machine classes that don't set hw_version.
+ */
+#define QEMU_HW_VERSION "2.5+"
+
+/* QEMU "hardware version" setting. Used to replace code that exposed
+ * QEMU_VERSION to guests in the past and need to keep compatibility.
+ * Do not use qemu_hw_version() in new code.
+ */
+void qemu_set_hw_version(const char *);
+const char *qemu_hw_version(void);
+
+#endif
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index e36f62a254e..650ba1aa505 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -534,22 +534,6 @@  static inline void qemu_timersub(const struct timeval *val1,
 
 void qemu_set_cloexec(int fd);
 
-/* Starting on QEMU 2.5, qemu_hw_version() returns "2.5+" by default
- * instead of QEMU_VERSION, so setting hw_version on MachineClass
- * is no longer mandatory.
- *
- * Do NOT change this string, or it will break compatibility on all
- * machine classes that don't set hw_version.
- */
-#define QEMU_HW_VERSION "2.5+"
-
-/* QEMU "hardware version" setting. Used to replace code that exposed
- * QEMU_VERSION to guests in the past and need to keep compatibility.
- * Do not use qemu_hw_version() in new code.
- */
-void qemu_set_hw_version(const char *);
-const char *qemu_hw_version(void);
-
 void fips_set_state(bool requested);
 bool fips_get_state(void);
 
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
index af3164c5519..9c1cafae86b 100644
--- a/hw/arm/nseries.c
+++ b/hw/arm/nseries.c
@@ -24,6 +24,7 @@ 
 #include "chardev/char.h"
 #include "qemu/cutils.h"
 #include "qemu/bswap.h"
+#include "qemu/hw-version.h"
 #include "sysemu/reset.h"
 #include "sysemu/runstate.h"
 #include "sysemu/sysemu.h"
diff --git a/hw/ide/core.c b/hw/ide/core.c
index e28f8aad611..33463d9b8f2 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -29,6 +29,7 @@ 
 #include "qemu/error-report.h"
 #include "qemu/main-loop.h"
 #include "qemu/timer.h"
+#include "qemu/hw-version.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/blockdev.h"
 #include "sysemu/dma.h"
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index cd43945827c..d5dfb412bac 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -28,6 +28,7 @@ 
 #include "hw/pci/msix.h"
 #include "qemu/iov.h"
 #include "qemu/module.h"
+#include "qemu/hw-version.h"
 #include "hw/scsi/scsi.h"
 #include "scsi/constants.h"
 #include "trace.h"
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index 4057e04ce89..b2e2bc3c96c 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -3,6 +3,7 @@ 
 #include "qemu/error-report.h"
 #include "qemu/module.h"
 #include "qemu/option.h"
+#include "qemu/hw-version.h"
 #include "hw/qdev-properties.h"
 #include "hw/scsi/scsi.h"
 #include "migration/qemu-file-types.h"
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 9c0dc7b9468..3666b8d9468 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -25,6 +25,7 @@ 
 #include "qemu/error-report.h"
 #include "qemu/main-loop.h"
 #include "qemu/module.h"
+#include "qemu/hw-version.h"
 #include "hw/scsi/scsi.h"
 #include "migration/qemu-file-types.h"
 #include "migration/vmstate.h"
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 5e1b35ba489..1fe028800fd 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -36,6 +36,7 @@ 
 #include "qemu-version.h"
 #include "qemu/cutils.h"
 #include "qemu/help_option.h"
+#include "qemu/hw-version.h"
 #include "qemu/uuid.h"
 #include "sysemu/reset.h"
 #include "sysemu/runstate.h"
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index aa9e6368004..c9954df4a74 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -21,6 +21,7 @@ 
 #include "qemu/units.h"
 #include "qemu/cutils.h"
 #include "qemu/qemu-print.h"
+#include "qemu/hw-version.h"
 #include "cpu.h"
 #include "tcg/helper-tcg.h"
 #include "sysemu/reset.h"
diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
index 11e06cc51fa..17ae771939b 100644
--- a/target/s390x/cpu_models.c
+++ b/target/s390x/cpu_models.c
@@ -19,6 +19,7 @@ 
 #include "qapi/error.h"
 #include "qapi/visitor.h"
 #include "qemu/module.h"
+#include "qemu/hw-version.h"
 #include "qemu/qemu-print.h"
 #ifndef CONFIG_USER_ONLY
 #include "sysemu/sysemu.h"
diff --git a/util/osdep.c b/util/osdep.c
index 72b678ca2e3..7c4deda6feb 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -39,6 +39,7 @@  extern int madvise(char *, size_t, int);
 #include "qemu/error-report.h"
 #include "qemu/madvise.h"
 #include "qemu/mprotect.h"
+#include "qemu/hw-version.h"
 #include "monitor/monitor.h"
 
 static bool fips_enabled = false;