qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Juan Quintela <quintela@redhat.com>,
	Michael Tokarev <mjt@tls.msk.ru>, Alexander Graf <agraf@suse.de>,
	Markus Armbruster <armbru@redhat.com>,
	Marcel Apfelbaum <marcel@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PULL 1/9] osdep: Change default value of qemu_hw_version() to "2.5+"
Date: Thu, 26 Nov 2015 18:44:01 +0200	[thread overview]
Message-ID: <1448556198-25213-2-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1448556198-25213-1-git-send-email-mst@redhat.com>

From: Eduardo Habkost <ehabkost@redhat.com>

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>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@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 24eb6f0..5da4fb0 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -51,6 +51,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)
 {
-- 
MST

  reply	other threads:[~2015-11-26 16:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-26 16:43 [Qemu-devel] [PULL 0/9] vhost, pc: fixes for 2.5 Michael S. Tsirkin
2015-11-26 16:44 ` Michael S. Tsirkin [this message]
2015-11-26 16:44 ` [Qemu-devel] [PULL 2/9] pc: Don't set hw_version on pc-*-2.5 Michael S. Tsirkin
2015-11-26 16:44 ` [Qemu-devel] [PULL 3/9] vhost-user: set link down when the char device is closed Michael S. Tsirkin
2015-11-26 16:44 ` [Qemu-devel] [PULL 4/9] vhost-user: clarify start and enable Michael S. Tsirkin
2015-11-26 16:44 ` [Qemu-devel] [PULL 5/9] tests/vhost-user-bridge: propose GUEST_ANNOUNCE feature Michael S. Tsirkin
2015-11-26 16:44 ` [Qemu-devel] [PULL 6/9] tests/vhost-user-bridge: read command line arguments Michael S. Tsirkin
2015-11-26 16:44 ` [Qemu-devel] [PULL 7/9] Revert "vhost: send SET_VRING_ENABLE at start/stop" Michael S. Tsirkin
2015-11-26 16:44 ` [Qemu-devel] [PULL 8/9] Fix memory leak on error Michael S. Tsirkin
2015-11-26 16:44 ` [Qemu-devel] [PULL 9/9] vhost-user-test: fix migration overlap test Michael S. Tsirkin
2015-11-26 17:39 ` [Qemu-devel] [PULL 0/9] vhost, pc: fixes for 2.5 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1448556198-25213-2-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=agraf@suse.de \
    --cc=armbru@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=marcel@redhat.com \
    --cc=mjt@tls.msk.ru \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).