From 2462329ffe92dcc60138631bbddfc49d58c8b4f4 Mon Sep 17 00:00:00 2001 From: Jason King Date: Wed, 3 Jun 2020 21:18:05 +0000 Subject: [PATCH 1/3] OS-7458 bhyve should allow pci_slot addressing for NICs --- src/vm/man/vmadm.1m.md | 29 +++++++++++++++++++++++++++++ src/vm/node_modules/proptable.js | 11 ++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/vm/man/vmadm.1m.md b/src/vm/man/vmadm.1m.md index c7c2fe892..525e78f32 100644 --- a/src/vm/man/vmadm.1m.md +++ b/src/vm/man/vmadm.1m.md @@ -1745,6 +1745,35 @@ tab-complete UUIDs rather than having to type them out for every command. create: yes update yes (requires zone stop/boot) + nics.*.pci_slot: + + Specifies the virtual PCI slot that this NIC will occupy. Bhyve places + each NIC into a PCI slot that is identified by the PCI bus, device, and + function (BDF). The slot may be specified as :: + ("0:10:0"), : ("10:0") or ("10"). If a bus + is not specified, 0 is used. Multiple NIC instances may be grouped + together on the same device by specifying different function values + for each NIC (e.g. "0:10:0", "0:10:1"). + + Per the PCI specification legal values for bus, device and function are: + + bus: 0 - 255, inclusive + device: 0 - 31, inclusive + function: 0 - 7, inclusive + + All functions on devices 0, 6, 30, and 31 on bus 0 are reserved. By + default, NICs do not include a `pci_slot` property. Instead, each + NIC instance is allocated its own function on the reserved bus 0, + device 6 virtual PCI slot. This property is generally only required + when it is necessary to have more than 8 NICs in a single bhyve VM. + + type: string (::, :function, or ) + vmtype: bhyve + listable: yes + create: yes + update: yes (special, see description in 'update' section above) + default: no + nics.*.primary This option selects which NIC's default gateway and nameserver values diff --git a/src/vm/node_modules/proptable.js b/src/vm/node_modules/proptable.js index 37b75cc09..20a4cf202 100644 --- a/src/vm/node_modules/proptable.js +++ b/src/vm/node_modules/proptable.js @@ -20,7 +20,7 @@ * * CDDL HEADER END * - * Copyright 2020, Joyent, Inc. + * Copyright 2020 Joyent, Inc. * */ @@ -1472,6 +1472,15 @@ exports.properties = { }, updatable: true, zonexml: 'zone.network.global-nic' + }, 'nics.*.pci_slot': { + payload: { + allowed: { + 'bhyve': ['add', 'update'] + }, + type: 'string' + }, + updatable: true, + zonexml: 'zone.device.net-attr.pci-slot' }, 'nics.*.primary': { loadValueTranslator: 'utils.fixBoolean', payload: { From 708e1c71066f3affb701bddfe49f380ff83b55dc Mon Sep 17 00:00:00 2001 From: Jason King Date: Wed, 3 Jun 2020 22:11:16 +0000 Subject: [PATCH 2/3] Update VM.js --- src/vm/node_modules/VM.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/vm/node_modules/VM.js b/src/vm/node_modules/VM.js index 979c07e4b..07a50e1ce 100644 --- a/src/vm/node_modules/VM.js +++ b/src/vm/node_modules/VM.js @@ -6342,6 +6342,11 @@ function buildNicZonecfg(vmobj, payload, log) + nic.allowed_dhcp_cids.join(',') + '")\n'; } + if (nic.hasOwnProperty('pci_slot')) { + zfs = zcfg + 'add property (name=pci-slit, value="' + + nic.pci_slot + '")\n'; + } + for (var prop in nicProperties) { prop = nicProperties[prop]; if (nic.hasOwnProperty(prop)) { From 755745f3ad6e0ce4d310a27ce8e8847c95ccfbd6 Mon Sep 17 00:00:00 2001 From: Jason King Date: Thu, 4 Jun 2020 16:39:22 +0000 Subject: [PATCH 3/3] Fix typo --- src/vm/node_modules/VM.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vm/node_modules/VM.js b/src/vm/node_modules/VM.js index 07a50e1ce..dc96941a4 100644 --- a/src/vm/node_modules/VM.js +++ b/src/vm/node_modules/VM.js @@ -6343,7 +6343,7 @@ function buildNicZonecfg(vmobj, payload, log) } if (nic.hasOwnProperty('pci_slot')) { - zfs = zcfg + 'add property (name=pci-slit, value="' + zfs = zcfg + 'add property (name=pci-slot, value="' + nic.pci_slot + '")\n'; }