From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48701) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwvhI-0001o8-7B for qemu-devel@nongnu.org; Thu, 12 Nov 2015 12:30:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZwvhH-0007u9-6I for qemu-devel@nongnu.org; Thu, 12 Nov 2015 12:30:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49891) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwvhH-0007u1-1c for qemu-devel@nongnu.org; Thu, 12 Nov 2015 12:30:07 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id C751A46B for ; Thu, 12 Nov 2015 17:30:06 +0000 (UTC) From: Eduardo Habkost Date: Thu, 12 Nov 2015 15:29:54 -0200 Message-Id: <1447349395-26716-2-git-send-email-ehabkost@redhat.com> In-Reply-To: <1447349395-26716-1-git-send-email-ehabkost@redhat.com> References: <1447349395-26716-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [PATCH 1/2] osdep: Change default value of qemu_hw_version() to "2.5+" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 Signed-off-by: Eduardo Habkost --- 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