* [Qemu-devel] [PATCH 0/2] Don't require hw_version to be set on every machine
@ 2015-11-12 17:29 Eduardo Habkost
2015-11-12 17:29 ` [Qemu-devel] [PATCH 1/2] osdep: Change default value of qemu_hw_version() to "2.5+" Eduardo Habkost
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Eduardo Habkost @ 2015-11-12 17:29 UTC (permalink / raw)
To: qemu-devel
Cc: Michael S. Tsirkin, Hannes Reinecke, Paolo Bonzini, John Snow,
Richard Henderson
This changes the qemu_hw_version() default to "2.5+" so we don't
make every machine class broken by default unless they set
hw_version.
For reference, these are the current users of qemu_hw_version():
hw/arm/nseries.c: pstrcat((void *) w, 12, qemu_hw_version()); /* char version[12] */
hw/ide/core.c: pstrcpy(s->version, sizeof(s->version), qemu_hw_version());
hw/scsi/megasas.c: snprintf(info.package_version, 0x60, "%s-QEMU", qemu_hw_version());
hw/scsi/scsi-bus.c: pstrcpy((char *) &r->buf[32], 4, qemu_hw_version());
hw/scsi/scsi-disk.c: s->version = g_strdup(qemu_hw_version());
target-i386/cpu.c: qemu_hw_version());
Cc: Andrzej Zaborowski <balrogg@gmail.com>
Cc: John Snow <jsnow@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Richard Henderson <rth@twiddle.net>
Eduardo Habkost (2):
osdep: Change default value of qemu_hw_version() to "2.5+"
pc: Don't set hw_version on pc-*-2.5
hw/i386/pc_piix.c | 1 -
hw/i386/pc_q35.c | 1 -
include/hw/boards.h | 5 +++++
include/qemu/osdep.h | 4 ++++
util/osdep.c | 9 ++++++++-
5 files changed, 17 insertions(+), 3 deletions(-)
--
2.1.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 1/2] osdep: Change default value of qemu_hw_version() to "2.5+"
2015-11-12 17:29 [Qemu-devel] [PATCH 0/2] Don't require hw_version to be set on every machine Eduardo Habkost
@ 2015-11-12 17:29 ` Eduardo Habkost
2015-11-12 17:29 ` [Qemu-devel] [PATCH 2/2] pc: Don't set hw_version on pc-*-2.5 Eduardo Habkost
2015-11-23 12:53 ` [Qemu-devel] [PATCH 0/2] Don't require hw_version to be set on every machine Eduardo Habkost
2 siblings, 0 replies; 5+ messages in thread
From: Eduardo Habkost @ 2015-11-12 17:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini, Michael S. Tsirkin
There are two issues with qemu_hw_version() today:
1) If a machine has hw_version set, the value returned by it is
not very useful, because it is not the actual QEMU version.
2) If a machine does't set hw_version, the return value of
qemu_hw_version() is broken, because it will change when
upgrading QEMU.
For those reasons, using qemu_hw_version() is strongly
discouraged, and should be used only in code that used
QEMU_VERSION in the past and needs to keep compatibility.
To fix (2), instead of making every machine broken by default
unless they set hw_version, make qemu_hw_version() simply return
"2.5+" if qemu_set_hw_version() is not called.
Suggested-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
include/hw/boards.h | 5 +++++
include/qemu/osdep.h | 4 ++++
util/osdep.c | 9 ++++++++-
3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 3e9a92c..51906af 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -52,6 +52,11 @@ bool machine_mem_merge(MachineState *machine);
* used to provide @cpu_index to socket number mapping, allowing
* a machine to group CPU threads belonging to the same socket/package
* Returns: socket number given cpu_index belongs to.
+ * @hw_version:
+ * Value of QEMU_VERSION when the machine was added to QEMU.
+ * Set only by old machines because they need to keep
+ * compatibility on code that exposed QEMU_VERSION to guests in
+ * the past (and now use qemu_hw_version()).
*/
struct MachineClass {
/*< private >*/
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 861d84b..84e84ac 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -256,6 +256,10 @@ static inline void qemu_timersub(const struct timeval *val1,
void qemu_set_cloexec(int fd);
+/* QEMU "hardware version" setting. Used to replace code that exposed
+ * QEMU_VERSION to guests in the past and need to keep compatibilty.
+ * Do not use qemu_hw_version() in new code.
+ */
void qemu_set_hw_version(const char *);
const char *qemu_hw_version(void);
diff --git a/util/osdep.c b/util/osdep.c
index 80c6bfe..534b511 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -52,7 +52,14 @@ extern int madvise(caddr_t, size_t, int);
static bool fips_enabled = false;
-static const char *hw_version = QEMU_VERSION;
+/* 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.
+ */
+static const char *hw_version = "2.5+";
int socket_set_cork(int fd, int v)
{
--
2.1.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 2/2] pc: Don't set hw_version on pc-*-2.5
2015-11-12 17:29 [Qemu-devel] [PATCH 0/2] Don't require hw_version to be set on every machine Eduardo Habkost
2015-11-12 17:29 ` [Qemu-devel] [PATCH 1/2] osdep: Change default value of qemu_hw_version() to "2.5+" Eduardo Habkost
@ 2015-11-12 17:29 ` Eduardo Habkost
2015-11-23 12:53 ` [Qemu-devel] [PATCH 0/2] Don't require hw_version to be set on every machine Eduardo Habkost
2 siblings, 0 replies; 5+ messages in thread
From: Eduardo Habkost @ 2015-11-12 17:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini, Michael S. Tsirkin
Now that qemu_hw_version() returns a fixed "2.5+" string instead
of QEMU_VERSION, we don't need to set hw_version on pc-*-2.5
explicitly.
Suggested-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/pc_piix.c | 1 -
hw/i386/pc_q35.c | 1 -
2 files changed, 2 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 07d0baa..2e41efe 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -472,7 +472,6 @@ static void pc_i440fx_machine_options(MachineClass *m)
static void pc_i440fx_2_5_machine_options(MachineClass *m)
{
pc_i440fx_machine_options(m);
- m->hw_version = QEMU_VERSION;
m->alias = "pc";
m->is_default = 1;
}
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 0fdae09..133bc68 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -373,7 +373,6 @@ static void pc_q35_machine_options(MachineClass *m)
static void pc_q35_2_5_machine_options(MachineClass *m)
{
pc_q35_machine_options(m);
- m->hw_version = QEMU_VERSION;
m->alias = "q35";
}
--
2.1.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] Don't require hw_version to be set on every machine
2015-11-12 17:29 [Qemu-devel] [PATCH 0/2] Don't require hw_version to be set on every machine Eduardo Habkost
2015-11-12 17:29 ` [Qemu-devel] [PATCH 1/2] osdep: Change default value of qemu_hw_version() to "2.5+" Eduardo Habkost
2015-11-12 17:29 ` [Qemu-devel] [PATCH 2/2] pc: Don't set hw_version on pc-*-2.5 Eduardo Habkost
@ 2015-11-23 12:53 ` Eduardo Habkost
2015-11-23 12:54 ` Michael S. Tsirkin
2 siblings, 1 reply; 5+ messages in thread
From: Eduardo Habkost @ 2015-11-23 12:53 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Richard Henderson, John Snow, Hannes Reinecke,
Michael S. Tsirkin
Ping? Any thoughts on this approach?
-rc2 is too late for this kind of change, maybe?
On Thu, Nov 12, 2015 at 03:29:53PM -0200, Eduardo Habkost wrote:
> This changes the qemu_hw_version() default to "2.5+" so we don't
> make every machine class broken by default unless they set
> hw_version.
>
> For reference, these are the current users of qemu_hw_version():
>
> hw/arm/nseries.c: pstrcat((void *) w, 12, qemu_hw_version()); /* char version[12] */
> hw/ide/core.c: pstrcpy(s->version, sizeof(s->version), qemu_hw_version());
> hw/scsi/megasas.c: snprintf(info.package_version, 0x60, "%s-QEMU", qemu_hw_version());
> hw/scsi/scsi-bus.c: pstrcpy((char *) &r->buf[32], 4, qemu_hw_version());
> hw/scsi/scsi-disk.c: s->version = g_strdup(qemu_hw_version());
> target-i386/cpu.c: qemu_hw_version());
>
> Cc: Andrzej Zaborowski <balrogg@gmail.com>
> Cc: John Snow <jsnow@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Hannes Reinecke <hare@suse.de>
> Cc: Richard Henderson <rth@twiddle.net>
>
> Eduardo Habkost (2):
> osdep: Change default value of qemu_hw_version() to "2.5+"
> pc: Don't set hw_version on pc-*-2.5
>
> hw/i386/pc_piix.c | 1 -
> hw/i386/pc_q35.c | 1 -
> include/hw/boards.h | 5 +++++
> include/qemu/osdep.h | 4 ++++
> util/osdep.c | 9 ++++++++-
> 5 files changed, 17 insertions(+), 3 deletions(-)
>
> --
> 2.1.0
>
>
--
Eduardo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] Don't require hw_version to be set on every machine
2015-11-23 12:53 ` [Qemu-devel] [PATCH 0/2] Don't require hw_version to be set on every machine Eduardo Habkost
@ 2015-11-23 12:54 ` Michael S. Tsirkin
0 siblings, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2015-11-23 12:54 UTC (permalink / raw)
To: Eduardo Habkost
Cc: Paolo Bonzini, Richard Henderson, John Snow, qemu-devel, Hannes Reinecke
On Mon, Nov 23, 2015 at 10:53:39AM -0200, Eduardo Habkost wrote:
>
> Ping? Any thoughts on this approach?
>
> -rc2 is too late for this kind of change, maybe?
>
I queued this up for 2.5, will merge later this week
unless anyone objects.
> On Thu, Nov 12, 2015 at 03:29:53PM -0200, Eduardo Habkost wrote:
> > This changes the qemu_hw_version() default to "2.5+" so we don't
> > make every machine class broken by default unless they set
> > hw_version.
> >
> > For reference, these are the current users of qemu_hw_version():
> >
> > hw/arm/nseries.c: pstrcat((void *) w, 12, qemu_hw_version()); /* char version[12] */
> > hw/ide/core.c: pstrcpy(s->version, sizeof(s->version), qemu_hw_version());
> > hw/scsi/megasas.c: snprintf(info.package_version, 0x60, "%s-QEMU", qemu_hw_version());
> > hw/scsi/scsi-bus.c: pstrcpy((char *) &r->buf[32], 4, qemu_hw_version());
> > hw/scsi/scsi-disk.c: s->version = g_strdup(qemu_hw_version());
> > target-i386/cpu.c: qemu_hw_version());
> >
> > Cc: Andrzej Zaborowski <balrogg@gmail.com>
> > Cc: John Snow <jsnow@redhat.com>
> > Cc: Paolo Bonzini <pbonzini@redhat.com>
> > Cc: Hannes Reinecke <hare@suse.de>
> > Cc: Richard Henderson <rth@twiddle.net>
> >
> > Eduardo Habkost (2):
> > osdep: Change default value of qemu_hw_version() to "2.5+"
> > pc: Don't set hw_version on pc-*-2.5
> >
> > hw/i386/pc_piix.c | 1 -
> > hw/i386/pc_q35.c | 1 -
> > include/hw/boards.h | 5 +++++
> > include/qemu/osdep.h | 4 ++++
> > util/osdep.c | 9 ++++++++-
> > 5 files changed, 17 insertions(+), 3 deletions(-)
> >
> > --
> > 2.1.0
> >
> >
>
> --
> Eduardo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-11-23 12:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-12 17:29 [Qemu-devel] [PATCH 0/2] Don't require hw_version to be set on every machine Eduardo Habkost
2015-11-12 17:29 ` [Qemu-devel] [PATCH 1/2] osdep: Change default value of qemu_hw_version() to "2.5+" Eduardo Habkost
2015-11-12 17:29 ` [Qemu-devel] [PATCH 2/2] pc: Don't set hw_version on pc-*-2.5 Eduardo Habkost
2015-11-23 12:53 ` [Qemu-devel] [PATCH 0/2] Don't require hw_version to be set on every machine Eduardo Habkost
2015-11-23 12:54 ` Michael S. Tsirkin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.