@samitouri / QOSamiQemu / commits / 3060e9b93b

treewide: replace qemu_hw_version() with QEMU_HW_VERSION

The version is never set on 2.5+ machine types, so qemu_hw_version() and qemu_set_hw_version() are not needed anymore. Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Paolo Bonzini committed Mar 24, 2026 at 17:56 UTC 3060e9b93bcc894a01e48b7fafae0a1d88f46bc2
9 files changed +9 -41
hw/ide/core.c
+1 -1
@@ -2660,7 +2660,7 @@ int ide_init_drive(IDEState *s, IDEDevice *dev, IDEDriveKind kind, Error **errp)
2660 if (dev->version) {
2661 pstrcpy(s->version, sizeof(s->version), dev->version);
2662 } else {
2663 - pstrcpy(s->version, sizeof(s->version), qemu_hw_version());
2663 + pstrcpy(s->version, sizeof(s->version), QEMU_HW_VERSION);
2664 }
2665
2666 ide_reset(s);
hw/scsi/megasas.c
+1 -1
@@ -782,7 +782,7 @@ static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd)
782
783 memcpy(info.product_name, base_class->product_name, 24);
784 snprintf(info.serial_number, 32, "%s", s->hba_serial);
785 - snprintf(info.package_version, 0x60, "%s-QEMU", qemu_hw_version());
785 + snprintf(info.package_version, 0x60, "%s-QEMU", QEMU_HW_VERSION);
786 memcpy(info.image_component[0].name, "APP", 3);
787 snprintf(info.image_component[0].version, 10, "%s-QEMU",
788 base_class->product_version);
hw/scsi/scsi-bus.c
+1 -1
@@ -703,7 +703,7 @@ static bool scsi_target_emulate_inquiry(SCSITargetReq *r)
703 r->buf[7] = 0x10 | (r->req.bus->info->tcq ? 0x02 : 0); /* Sync, TCQ. */
704 memcpy(&r->buf[8], "QEMU ", 8);
705 memcpy(&r->buf[16], "QEMU TARGET ", 16);
706 - pstrcpy((char *) &r->buf[32], 4, qemu_hw_version());
706 + pstrcpy((char *) &r->buf[32], 4, QEMU_HW_VERSION);
707 }
708 return true;
709 }
hw/scsi/scsi-disk.c
+1 -1
@@ -2543,7 +2543,7 @@ static void scsi_realize(SCSIDevice *dev, Error **errp)
2543 }
2544
2545 if (!s->version) {
2546 - s->version = g_strdup(qemu_hw_version());
2546 + s->version = g_strdup(QEMU_HW_VERSION);
2547 }
2548 if (!s->vendor) {
2549 s->vendor = g_strdup("QEMU");
include/hw/core/boards.h
-6
@@ -197,11 +197,6 @@ typedef struct {
197 * used to provide @cpu_index to socket number mapping, allowing
198 * a machine to group CPU threads belonging to the same socket/package
199 * Returns: socket number given cpu_index belongs to.
200 - * @hw_version:
201 - * Value of QEMU_VERSION when the machine was added to QEMU.
202 - * Set only by old machines because they need to keep
203 - * compatibility on code that exposed QEMU_VERSION to guests in
204 - * the past (and now use qemu_hw_version()).
200 * @possible_cpu_arch_ids:
201 * Returns an array of @CPUArchId architecture-dependent CPU IDs
202 * which includes CPU IDs for present and possible to hotplug CPUs.
@@ -297,7 +292,6 @@ struct MachineClass {
292 const char *default_display;
293 const char *default_nic;
294 GPtrArray *compat_props;
300 - const char *hw_version;
295 ram_addr_t default_ram_size;
296 const char *default_cpu_type;
297 bool default_kernel_irqchip_split;
include/qemu/hw-version.h
+4 -14
@@ -1,5 +1,5 @@
1 /*
2 - * QEMU "hardware version" machinery
2 + * QEMU "hardware version" constant
3 *
4 * This work is licensed under the terms of the GNU GPL, version 2 or later.
5 * See the COPYING file in the top-level directory.
@@ -8,20 +8,10 @@
8 #define QEMU_HW_VERSION_H
9
10 /*
11 - * Starting on QEMU 2.5, qemu_hw_version() returns "2.5+" by default
12 - * instead of QEMU_VERSION, so setting hw_version on MachineClass
13 - * is no longer mandatory.
14 - *
15 - * Do NOT change this string, or it will break compatibility on all
16 - * machine classes that don't set hw_version.
11 + * Starting on QEMU 2.5, devices with a version string in their
12 + * identification data return "2.5+" instead of QEMU_VERSION. Do
13 + * NOT change this string as it is visible to guests.
14 */
15 #define QEMU_HW_VERSION "2.5+"
16
20 -/* QEMU "hardware version" setting. Used to replace code that exposed
21 - * QEMU_VERSION to guests in the past and need to keep compatibility.
22 - * Do not use qemu_hw_version() in new code.
23 - */
24 -void qemu_set_hw_version(const char *);
25 -const char *qemu_hw_version(void);
26 -
17 #endif
system/vl.c
-4
@@ -2212,10 +2212,6 @@ static void qemu_create_machine(QDict *qdict)
2212
2213 cpu_exec_init_all();
2214
2215 - if (machine_class->hw_version) {
2216 - qemu_set_hw_version(machine_class->hw_version);
2217 - }
2218 -
2215 /*
2216 * Get the default machine options from the machine if it is not already
2217 * specified either by the configuration file or by the command line.
target/s390x/cpu_models.c
+1 -1
@@ -955,7 +955,7 @@ static void s390_qemu_cpu_model_class_init(ObjectClass *oc, const void *data)
955
956 xcc->is_migration_safe = true;
957 xcc->desc = g_strdup_printf("QEMU Virtual CPU version %s",
958 - qemu_hw_version());
958 + QEMU_HW_VERSION);
959 }
960
961 static void s390_max_cpu_model_class_init(ObjectClass *oc, const void *data)
util/osdep.c
-12
@@ -31,8 +31,6 @@
31 #include "qemu/hw-version.h"
32 #include "monitor/monitor.h"
33
34 -static const char *hw_version = QEMU_HW_VERSION;
35 -
34 int socket_set_cork(int fd, int v)
35 {
36 #if defined(SOL_TCP) && defined(TCP_CORK)
@@ -533,16 +531,6 @@ ssize_t qemu_send_full(int s, const void *buf, size_t count)
531 return total;
532 }
533
536 -void qemu_set_hw_version(const char *version)
537 -{
538 - hw_version = version;
539 -}
540 -
541 -const char *qemu_hw_version(void)
542 -{
543 - return hw_version;
544 -}
545 -
534 #ifdef _WIN32
535 static void socket_cleanup(void)
536 {