Assignable PCIe devices have a root complex path and a more descriptive I/O slot path; example output from a T4-2:
# ldomctl list-io PATH NAME /@400/@2/@0/@8 /SYS/MB/PCIE0 /@500/@2/@0/@a /SYS/MB/PCIE1 ... /@400/@2/@0/@e /SYS/MB/SASHBA /@400/@1/@0/@4 /SYS/MB/NET0 /@500/@1/@0/@5 /SYS/MB/NET2 The latter is much more descriptive, matches actual labels on the back of the hardware as well as information from ILOM. ldom.conf currently accepts only the first value, which is not really informative unless you know how each element maps to physical hardware. The second value is a no-brainer, stable across different machines and more useful to work with when building systems whith many domains having PCIe devices assigned; `ldomctl list-io' is no longer needed to produce a working configuration. So make ldom.conf `iodevice' take both values; ldomctl looks them up in the list of components which stores both, so just match against both and keep yielding the root complex path internally. The diff is bigger because I renamed struct iodev's path member to dev to clarify how it may be either a path or a name/NAC. Changing my ldom.conf like this after the diff still results in `ldomctl init-system' producing identical machine descriptions: -iodevice "/@400/@2/@0/@8" # /SYS/MB/PCIE0 +iodevice "/SYS/MB/PCIE0" Feedback? OK? (for after release) commit 3016bbec8c36884c64b5dff8b3bc520d50d36c5d Author: Klemens Nanni <k...@openbsd.org> Date: Sun Sep 18 01:07:49 2022 +0200 Allow passing iodevice pseudonyms diff --git a/usr.sbin/ldomctl/config.c b/usr.sbin/ldomctl/config.c index 048e6e58e72..82f4f6ce5cb 100644 --- a/usr.sbin/ldomctl/config.c +++ b/usr.sbin/ldomctl/config.c @@ -2645,7 +2645,7 @@ guest_add_variable(struct guest *guest, const char *name, const char *str) } void -guest_add_iodev(struct guest *guest, const char *path) +guest_add_iodev(struct guest *guest, const char *dev) { struct component *component; struct subdevice *subdevice; @@ -2654,17 +2654,18 @@ guest_add_iodev(struct guest *guest, const char *path) errx(1, "direct I/O not supported by hypervisor"); TAILQ_FOREACH(component, &components, link) { - if (strcmp(component->path, path) == 0) + if (strcmp(component->nac, dev) == 0 || + strcmp(component->path, dev) == 0) break; } if (component == NULL) - errx(1, "incorrect device path %s", path); + errx(1, "incorrect device path %s", dev); if (component->assigned) - errx(1, "device path %s already assigned", path); + errx(1, "device path %s already assigned", dev); subdevice = xzalloc(sizeof(*subdevice)); - subdevice->path = path; + subdevice->path = component->path; TAILQ_INSERT_TAIL(&guest->subdevice_list, subdevice, link); component->assigned = 1; } @@ -2873,7 +2874,7 @@ build_config(const char *filename, int noaction) SIMPLEQ_FOREACH(var, &domain->var_list, entry) guest_add_variable(guest, var->name, var->str); SIMPLEQ_FOREACH(iodev, &domain->iodev_list, entry) - guest_add_iodev(guest, iodev->path); + guest_add_iodev(guest, iodev->dev); guest_finalize(guest); } diff --git a/usr.sbin/ldomctl/ldom.conf.5 b/usr.sbin/ldomctl/ldom.conf.5 index a6555199e65..efad2b38b46 100644 --- a/usr.sbin/ldomctl/ldom.conf.5 +++ b/usr.sbin/ldomctl/ldom.conf.5 @@ -50,8 +50,13 @@ Declare the amount of memory assigned to a domain, in bytes. can be specified with a human-readable scale, using the format described in .Xr scan_scaled 3 , e.g. 512M. -.It Ic iodevice Ar path +.It Ic iodevice Ar device Assign the specified PCIe device to the guest domain. +.Ar device +may be either a device path +.Pq Pa /@400/@2/@0/@8 +or a pseudonym +.Pq Pa /SYS/MB/PCIE0 . This keyword can be used multiple times. .It Ic variable Ar name Ns = Ns Ar value Set the specified NVRAM variable for the domain. diff --git a/usr.sbin/ldomctl/ldomctl.h b/usr.sbin/ldomctl/ldomctl.h index b5210ee3c0e..ee40b59df30 100644 --- a/usr.sbin/ldomctl/ldomctl.h +++ b/usr.sbin/ldomctl/ldomctl.h @@ -176,7 +176,7 @@ struct var { struct iodev { SIMPLEQ_ENTRY(iodev) entry; - const char *path; + const char *dev; }; struct domain { diff --git a/usr.sbin/ldomctl/parse.y b/usr.sbin/ldomctl/parse.y index f987ab60042..2323bfebe30 100644 --- a/usr.sbin/ldomctl/parse.y +++ b/usr.sbin/ldomctl/parse.y @@ -220,13 +220,13 @@ domainopts : VCPU vcpu { struct iodev *iodev; SIMPLEQ_FOREACH(odomain, &conf->domain_list, entry) SIMPLEQ_FOREACH(iodev, &odomain->iodev_list, entry) - if (strcmp(iodev->path, $2) == 0) { + if (strcmp(iodev->dev, $2) == 0) { yyerror("iodevice %s already" " assigned", $2); YYERROR; } iodev = xmalloc(sizeof(struct iodev)); - iodev->path = $2; + iodev->dev = $2; SIMPLEQ_INSERT_TAIL(&domain->iodev_list, iodev, entry); } ;