[PATCH 0/3] hw/sparc, hw/sparc64: add hostid=/machineid= -machine properties

Frode Tennebø posted 3 patches 1 week ago
docs/system/target-sparc.rst   | 23 +++++++++++
docs/system/target-sparc64.rst | 22 +++++++++++
hw/sparc/meson.build           |  1 +
hw/sparc/sun4m.c               | 55 ++++++++++++++++++++++----
hw/sparc/sun_hostid.c          | 88 ++++++++++++++++++++++++++++++++++++++++++
hw/sparc64/meson.build         |  1 +
hw/sparc64/sun4u.c             | 74 +++++++++++++++++++++++++++++++----
include/hw/nvram/sun_nvram.h   | 11 ++++--
include/hw/sparc/sun_hostid.h  | 48 +++++++++++++++++++++++
9 files changed, 306 insertions(+), 17 deletions(-)
[PATCH 0/3] hw/sparc, hw/sparc64: add hostid=/machineid= -machine properties
Posted by Frode Tennebø 1 week ago
This series adds "hostid" and "machineid" as -machine sub-properties
for the sun4m and sun4u/sun4v machine families:

    qemu-system-sparc  -machine SS-20,hostid=0x352e09,machineid=0x80
    qemu-system-sparc64 -machine sun4u,hostid=0x352e09,machineid=0x72

Background: these machines report a classic 32-bit Sun "hostid" to
the guest OS (as read by hostid(1), and historically use by some
software for license checks), built from two independent pieces stored
in the emulated NVRAM/IDPROM - a fixed per-model machine-type byte, and
the low 24 bits of the machine's Ethernet MAC address. QEMU already
reproduces this scheme, but until now neither half was settable from
the command line: the machine-type byte was fixed per hwdef, and the
low 24 bits always tracked whatever MAC ended up on the emulated NIC.
Both properties default to that existing behaviour when left unset,
so this series is fully backward compatible.

Patch 1 adds a small shared helper (hw/sparc/sun_hostid.c) rather
than duplicating the property getter/setter logic between the two
machine families: a generic SunHostIDProps struct that a machine's
own instance struct embeds anywhere, located via byte offset, plus
two functions to register the properties on a class and initialise
an instance.

Patch 2 wires this into sun4m, via the existing sun4m-common
abstract machine class.

Patch 3 wires it into sun4u/sun4v. Since sun4u.c had no shared
abstract machine class before this series, patch 3 introduces one
(sun4u-common) as the parent of both "sun4u" and "sun4v", and
registers the properties on it once - both machines pick them up
through QOM's class-hierarchy property lookup. The "niagara" machine
(hw/sparc64/niagara.c) is a separate machine family that does not
use this NVRAM/IDPROM hostid mechanism and is unaffected.

PS: This is my first patch set for QEMU.

---
Frode Tennebø (3):
      hw/sparc: add shared sun_hostid helper for hostid/machineid properties
      hw/sparc: add hostid= and machineid= -machine sub-properties
      hw/sparc64: add hostid= and machineid= -machine sub-properties

 docs/system/target-sparc.rst   | 23 +++++++++++
 docs/system/target-sparc64.rst | 22 +++++++++++
 hw/sparc/meson.build           |  1 +
 hw/sparc/sun4m.c               | 55 ++++++++++++++++++++++----
 hw/sparc/sun_hostid.c          | 88 ++++++++++++++++++++++++++++++++++++++++++
 hw/sparc64/meson.build         |  1 +
 hw/sparc64/sun4u.c             | 74 +++++++++++++++++++++++++++++++----
 include/hw/nvram/sun_nvram.h   | 11 ++++--
 include/hw/sparc/sun_hostid.h  | 48 +++++++++++++++++++++++
 9 files changed, 306 insertions(+), 17 deletions(-)
---
base-commit: f8296b816fabd370307cd22b0270b610fc0fa279
change-id: 20260917-add_hostid_sub-properties-473a0d2ea35e

Best regards,
-- 
Frode Tennebø <frode@tennebo.com>


Re: [PATCH 0/3] hw/sparc, hw/sparc64: add hostid=/machineid= -machine properties
Posted by Artyom Tarasenko 1 day, 8 hours ago
On Sat, Sep 19, 2026 at 4:56 PM Frode Tennebø <frode@tennebo.com> wrote:
>
> This series adds "hostid" and "machineid" as -machine sub-properties
> for the sun4m and sun4u/sun4v machine families:
>
>     qemu-system-sparc  -machine SS-20,hostid=0x352e09,machineid=0x80
>     qemu-system-sparc64 -machine sun4u,hostid=0x352e09,machineid=0x72
>
> Background: these machines report a classic 32-bit Sun "hostid" to
> the guest OS (as read by hostid(1), and historically use by some
> software for license checks), built from two independent pieces stored
> in the emulated NVRAM/IDPROM - a fixed per-model machine-type byte, and
> the low 24 bits of the machine's Ethernet MAC address. QEMU already
> reproduces this scheme, but until now neither half was settable from
> the command line: the machine-type byte was fixed per hwdef, and the
> low 24 bits always tracked whatever MAC ended up on the emulated NIC.
> Both properties default to that existing behaviour when left unset,
> so this series is fully backward compatible.
>
> Patch 1 adds a small shared helper (hw/sparc/sun_hostid.c) rather
> than duplicating the property getter/setter logic between the two
> machine families: a generic SunHostIDProps struct that a machine's
> own instance struct embeds anywhere, located via byte offset, plus
> two functions to register the properties on a class and initialise
> an instance.
>
> Patch 2 wires this into sun4m, via the existing sun4m-common
> abstract machine class.
>
> Patch 3 wires it into sun4u/sun4v. Since sun4u.c had no shared
> abstract machine class before this series, patch 3 introduces one
> (sun4u-common) as the parent of both "sun4u" and "sun4v", and
> registers the properties on it once - both machines pick them up
> through QOM's class-hierarchy property lookup. The "niagara" machine
> (hw/sparc64/niagara.c) is a separate machine family that does not
> use this NVRAM/IDPROM hostid mechanism and is unaffected.
>
> PS: This is my first patch set for QEMU.

Acked-by: Artyom Tarasenko <atar4qemu@gmail.com>

>
> ---
> Frode Tennebø (3):
>       hw/sparc: add shared sun_hostid helper for hostid/machineid properties
>       hw/sparc: add hostid= and machineid= -machine sub-properties
>       hw/sparc64: add hostid= and machineid= -machine sub-properties
>
>  docs/system/target-sparc.rst   | 23 +++++++++++
>  docs/system/target-sparc64.rst | 22 +++++++++++
>  hw/sparc/meson.build           |  1 +
>  hw/sparc/sun4m.c               | 55 ++++++++++++++++++++++----
>  hw/sparc/sun_hostid.c          | 88 ++++++++++++++++++++++++++++++++++++++++++
>  hw/sparc64/meson.build         |  1 +
>  hw/sparc64/sun4u.c             | 74 +++++++++++++++++++++++++++++++----
>  include/hw/nvram/sun_nvram.h   | 11 ++++--
>  include/hw/sparc/sun_hostid.h  | 48 +++++++++++++++++++++++
>  9 files changed, 306 insertions(+), 17 deletions(-)
> ---
> base-commit: f8296b816fabd370307cd22b0270b610fc0fa279
> change-id: 20260917-add_hostid_sub-properties-473a0d2ea35e
>
> Best regards,
> --
> Frode Tennebø <frode@tennebo.com>
>


-- 
Regards,
Artyom Tarasenko

SPARC and PPC PReP under qemu blog: http://tyom.blogspot.com/search/label/qemu