From: kn Date: Thu, 6 Oct 2022 21:35:52 +0000 (+0000) Subject: accept iodevices as NACs as well X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=ee96180de911a25bf20a6f878c381b9ba950e865;p=openbsd accept iodevices as NACs as well 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 | head -n2 PATH NAME /@400/@2/@0/@8 /SYS/MB/PCIE0 ldom.conf(5) `iodevice' currently accepts PATH values, which are cryptic and completely hardware specific, whereas NAME values are obvious (partially same across machines) and match physical slot labels ("0 PCIe2 x8") besides information from ILOM: /System/PCI_Devices/Add-on/Device_0 location = PCIE0 (PCIe Slot 0). Make ldom.conf `iodevice' accept either value; internally nothing changes. Rename struct iodev's path member to dev to clarify this further. OK kettenis --- diff --git a/usr.sbin/ldomctl/config.c b/usr.sbin/ldomctl/config.c index 048e6e58e72..3539363d8eb 100644 --- a/usr.sbin/ldomctl/config.c +++ b/usr.sbin/ldomctl/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.42 2021/01/31 05:14:24 deraadt Exp $ */ +/* $OpenBSD: config.c,v 1.43 2022/10/06 21:35:52 kn Exp $ */ /* * Copyright (c) 2012, 2018 Mark Kettenis @@ -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..46825b6027f 100644 --- a/usr.sbin/ldomctl/ldom.conf.5 +++ b/usr.sbin/ldomctl/ldom.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ldom.conf.5,v 1.17 2022/03/31 17:27:30 naddy Exp $ +.\" $OpenBSD: ldom.conf.5,v 1.18 2022/10/06 21:35:52 kn Exp $ .\" .\" Copyright (c) 2012 Mark Kettenis .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 31 2022 $ +.Dd $Mdocdate: October 6 2022 $ .Dt LDOM.CONF 5 sparc64 .Os .Sh NAME @@ -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..6a64f04d1d2 100644 --- a/usr.sbin/ldomctl/ldomctl.h +++ b/usr.sbin/ldomctl/ldomctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ldomctl.h,v 1.15 2021/01/30 19:32:44 kn Exp $ */ +/* $OpenBSD: ldomctl.h,v 1.16 2022/10/06 21:35:52 kn Exp $ */ /* * Copyright (c) 2012 Mark Kettenis @@ -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..7fd4ceaf4f7 100644 --- a/usr.sbin/ldomctl/parse.y +++ b/usr.sbin/ldomctl/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.24 2021/10/15 15:01:28 naddy Exp $ */ +/* $OpenBSD: parse.y,v 1.25 2022/10/06 21:35:52 kn Exp $ */ /* * Copyright (c) 2012 Mark Kettenis @@ -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); } ;