From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Vincent Bernat <vincent@bernat.ch>
Cc: Igor Mammedov <imammedo@redhat.com>,
qemu-devel@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH v2 1/2] hw/smbios: support for type 41 (onboard devices extended information)
Date: Thu, 1 Apr 2021 09:41:33 +0100 [thread overview]
Message-ID: <YGWHPWSrOLxEQtMA@redhat.com> (raw)
In-Reply-To: <20210401082544.16522-1-vincent@bernat.ch>
On Thu, Apr 01, 2021 at 10:25:43AM +0200, Vincent Bernat wrote:
> Type 41 defines the attributes of devices that are onboard. The
> original intent was to imply the BIOS had some level of control over
> the enablement of the associated devices.
>
> If network devices are present in this table, by default, udev will
> name the corresponding interfaces enoX, X being the instance number.
> Without such information, udev will fallback to using the PCI ID and
> this usually gives ens3 or ens4. This can be a bit annoying as the
> name of the network card may depend on the order of options and may
> change if a new PCI device is added earlier on the commande line.
> Being able to provide SMBIOS type 41 entry ensure the name of the
> interface won't change and helps the user guess the right name without
> booting a first time.
>
> This can be invoked with:
>
> $QEMU -netdev user,id=internet
> -device virtio-net-pci,mac=50:54:00:00:00:42,netdev=internet \
> -smbios type=41,designation='Onboard LAN',instance=1,kind=ethernet,pci=0000:00:09.0
>
> Which results in the guest seeing dmidecode data and the interface
> exposed as "eno1":
>
> $ dmidecode -t 41
> # dmidecode 3.3
> Getting SMBIOS data from sysfs.
> SMBIOS 2.8 present.Handle 0x2900, DMI type 41, 11 bytes
> Onboard Device
> Reference Designation: Onboard LAN
> Type: Ethernet
> Status: Enabled
> Type Instance: 1
> Bus Address: 0000:00:09.0
> $ udevadm info -p /sys/class/net/eno1 | grep ONBOARD
> E: ID_NET_NAME_ONBOARD=eno1
> E: ID_NET_LABEL_ONBOARD=Onboard LAN
>
> Signed-off-by: Vincent Bernat <vincent@bernat.ch>
> ---
> hw/smbios/smbios.c | 119 +++++++++++++++++++++++++++++++++++
> include/hw/firmware/smbios.h | 11 ++++
> qemu-options.hx | 7 ++-
> 3 files changed, 136 insertions(+), 1 deletion(-)
>
> diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
> index f22c4f5b734e..46a08652dff4 100644
> --- a/hw/smbios/smbios.c
> +++ b/hw/smbios/smbios.c
> static void smbios_register_config(void)
> {
> qemu_add_opts(&qemu_smbios_opts);
> @@ -773,6 +826,26 @@ static void smbios_build_type_32_table(void)
> SMBIOS_BUILD_TABLE_POST;
> }
>
> +static void smbios_build_type_41_table(void)
> +{
> + unsigned instance = 0;
> + struct type41_instance *t41;
> +
> + QTAILQ_FOREACH(t41, &type41, next) {
> + SMBIOS_BUILD_TABLE_PRE(41, 0x2900 + instance, true);
> +
> + SMBIOS_TABLE_SET_STR(41, reference_designation_str, t41->designation);
> + t->device_type = t41->kind;
> + t->device_type_instance = t41->instance;
> + t->segment_group_number = cpu_to_le16(t41->pci.segment);
> + t->bus_number = t41->pci.bus;
> + t->device_number = t41->pci.device;
> +
> + SMBIOS_BUILD_TABLE_POST;
> + instance++;
> + }
> +}
> +
> static void smbios_build_type_127_table(void)
> {
> SMBIOS_BUILD_TABLE_PRE(127, 0x7F00, true); /* required */
> @@ -928,6 +1001,7 @@ void smbios_get_tables(MachineState *ms,
>
> smbios_build_type_32_table();
> smbios_build_type_38_table();
> + smbios_build_type_41_table();
> smbios_build_type_127_table();
>
> smbios_validate_table(ms);
> @@ -1224,6 +1298,51 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
> save_opt(&type17.part, opts, "part");
> type17.speed = qemu_opt_get_number(opts, "speed", 0);
> return;
> + case 41: {
> + struct type41_instance *t;
> + Error *local_err = NULL;
> + int pseg, pbus, pdevice, pfunction;
> +
> + if (!qemu_opts_validate(opts, qemu_smbios_type41_opts, errp)) {
> + return;
> + }
> + t = calloc(1, sizeof(struct type41_instance));
> + if (!t) {
> + error_setg(errp,
> + "Unable to allocate memory for a new type 41 instance");
> + return;
> + }
QEMU uses GLib allocation functions throughout, which abort
on OOM. So replace this with g_new0.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2021-04-01 8:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-01 8:25 [PATCH v2 1/2] hw/smbios: support for type 41 (onboard devices extended information) Vincent Bernat
2021-04-01 8:25 ` [PATCH v2 2/2] hw/smbios: retrieve PCI address from specified device for Type 41 Vincent Bernat
2021-04-01 9:38 ` Daniel P. Berrangé
2021-04-01 10:07 ` Vincent Bernat
2021-04-01 10:19 ` Daniel P. Berrangé
2021-04-01 12:27 ` Vincent Bernat
2021-04-01 13:59 ` Michael S. Tsirkin
2021-04-01 14:26 ` Vincent Bernat
2021-04-01 16:32 ` Michael S. Tsirkin
2021-04-01 8:41 ` Daniel P. Berrangé [this message]
2021-04-01 8:46 ` [PATCH v2 1/2] hw/smbios: support for type 41 (onboard devices extended information) Vincent Bernat
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=YGWHPWSrOLxEQtMA@redhat.com \
--to=berrange@redhat.com \
--cc=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=vincent@bernat.ch \
/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 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.