pc: support user provided NIC naming/indexing
cover pc: support user provided NIC naming/indexing
Series implements support for 'onboard' naming scheme for network interfaces (1), which is based on PCI firmware spec and lets user to explicitly specify index that will be used by guest to name network interface, ex:
-device e1000,acpi-index=33
should make guest rename NIC name to 'eno33' where 'eno' is default prefix for this scheme.
Hope is that it will allow to simplify launching VMs from template disk images with different set VM configurations without need to reconfigure guest network intrfaces or risk of loosing network connectivity.
For more detailed description/examples see patches [3-4/5]
1)
https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
Git repo for testing:
https://github.com/imammedo/qemu/branches acpi-index-rfc
Igor Mammedov (5):
acpi: add aml_to_decimalstring() and aml_call6() helpers
tests: acpi: temporary whitelist DSDT changes
pci: introduce apci-index property for PCI device
pci: acpi: add _DSM method to PCI devices
tests: acpi: update expected data files
include/hw/acpi/aml-build.h | 3 + include/hw/acpi/pci.h | 1 + include/hw/acpi/pcihp.h | 7 +- include/hw/pci/pci.h | 1 + tests/qtest/bios-tables-test-allowed-diff.h | 21 +++++ hw/acpi/aml-build.c | 28 +++++++ hw/acpi/pci.c | 84 ++++++++++++++++++++ hw/acpi/pcihp.c | 25 +++++- hw/i386/acpi-build.c | 31 +++++++- hw/pci/pci.c | 1 + tests/data/acpi/pc/DSDT | Bin 5065 -> 6023 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 6390 -> 7348 bytes tests/data/acpi/pc/DSDT.bridge | Bin 6924 -> 8689 bytes tests/data/acpi/pc/DSDT.cphp | Bin 5529 -> 6487 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 6719 -> 7677 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 5026 -> 5990 bytes tests/data/acpi/pc/DSDT.hpbrroot | Bin 3084 -> 3177 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 5137 -> 6095 bytes tests/data/acpi/pc/DSDT.memhp | Bin 6424 -> 7382 bytes tests/data/acpi/pc/DSDT.numamem | Bin 5071 -> 6029 bytes tests/data/acpi/pc/DSDT.roothp | Bin 5261 -> 6324 bytes tests/data/acpi/q35/DSDT | Bin 7801 -> 7863 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9126 -> 9188 bytes tests/data/acpi/q35/DSDT.bridge | Bin 7819 -> 7911 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8265 -> 8327 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9455 -> 9517 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 7876 -> 7938 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9160 -> 9222 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 8932 -> 9024 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7807 -> 7869 bytes tests/data/acpi/q35/DSDT.tis | Bin 8407 -> 8468 bytes 31 files changed, 197 insertions(+), 5 deletions(-)
Signature · 1 line
2.27.0
RFC 1/5 acpi: add aml_to_decimalstring() and aml_call6() helpers
it will be used by follow up patches
--- include/hw/acpi/aml-build.h | 3 +++ hw/acpi/aml-build.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+)
include/hw/acpi/aml-build.h +3 -0
@@ -301,6 +301,7 @@ Aml *aml_arg(int pos);Aml *aml_to_integer (Aml *arg);Aml *aml_to_hexstring (Aml *src,Aml *dst);Aml *aml_to_buffer (Aml *src,Aml *dst); +Aml *aml_to_decimalstring (Aml *src,Aml *dst);Aml *aml_store (Aml *val,Aml *target);Aml *aml_and (Aml *arg1,Aml *arg2,Aml *dst);Aml *aml_or (Aml *arg1,Aml *arg2,Aml *dst);
@@ -323,6 +324,8 @@ Aml *aml_call3(const char *method, Aml *arg1, Aml *arg2, Aml *arg3);Aml *aml_call4 (const char *method,Aml *arg1,Aml *arg2,Aml *arg3,Aml *arg4);Aml *aml_call5 (const char *method,Aml *arg1,Aml *arg2,Aml *arg3,Aml *arg4,Aml *arg5); +Aml *aml_call6 (const char *method,Aml *arg1,Aml *arg2,Aml *arg3,Aml *arg4, +Aml *arg5,Aml *arg6); Aml *aml_gpio_int(AmlConsumerAndProducer con_and_pro, AmlLevelAndEdge edge_level, AmlActiveHighAndLow active_level, AmlShared shared,
hw/acpi/aml-build.c +28 -0
@@ -633,6 +633,19 @@ Aml *aml_to_buffer(Aml *src, Aml *dst)return var; } +/* ACPI 2.0a: 17.2.4.4 Type 2 Opcodes Encoding: DefToDecimalString */ +Aml *aml_to_decimalstring (Aml *src,Aml *dst) +{ +Aml *var =aml_opcode (0x97 /* ToDecimalStringOp */ ); +aml_append (var, src); +if (dst) { +aml_append (var, dst); + }else { +build_append_byte (var->buf,0x00 /* NullNameOp */ ); + } +return var; +} +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefStore */ Aml *aml_store (Aml *val,Aml *target) {
@@ -834,6 +847,21 @@ Aml *aml_call5(const char *method, Aml *arg1, Aml *arg2, Aml *arg3, Aml *arg4,return var; } +/* helper to call method with 5 arguments */ +Aml *aml_call6 (const char *method,Aml *arg1,Aml *arg2,Aml *arg3,Aml *arg4, +Aml *arg5,Aml *arg6) +{ +Aml *var =aml_alloc (); +build_append_namestring (var->buf,"%s" , method); +aml_append (var, arg1); +aml_append (var, arg2); +aml_append (var, arg3); +aml_append (var, arg4); +aml_append (var, arg5); +aml_append (var, arg6); +return var; +} +/* * ACPI 5.0: 6.4.3.8.1 GPIO Connection Descriptor * Type 1, Large Item Name 0xC
Signature · 1 line
2.27.0
RFC 2/5 tests: acpi: temporary whitelist DSDT changes
In reply to Igor Mammedov--- tests/qtest/bios-tables-test-allowed-diff.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +21 -0
@@ -1 +1,22 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/pc/DSDT" , +"tests/data/acpi/pc/DSDT.acpihmat" , +"tests/data/acpi/pc/DSDT.bridge" , +"tests/data/acpi/pc/DSDT.cphp" , +"tests/data/acpi/pc/DSDT.dimmpxm" , +"tests/data/acpi/pc/DSDT.hpbridge" , +"tests/data/acpi/pc/DSDT.hpbrroot" , +"tests/data/acpi/pc/DSDT.ipmikcs" , +"tests/data/acpi/pc/DSDT.memhp" , +"tests/data/acpi/pc/DSDT.numamem" , +"tests/data/acpi/pc/DSDT.roothp" , +"tests/data/acpi/q35/DSDT" , +"tests/data/acpi/q35/DSDT.acpihmat" , +"tests/data/acpi/q35/DSDT.bridge" , +"tests/data/acpi/q35/DSDT.cphp" , +"tests/data/acpi/q35/DSDT.dimmpxm" , +"tests/data/acpi/q35/DSDT.ipmibt" , +"tests/data/acpi/q35/DSDT.memhp" , +"tests/data/acpi/q35/DSDT.mmio64" , +"tests/data/acpi/q35/DSDT.numamem" , +"tests/data/acpi/q35/DSDT.tis",
Signature · 1 line
2.27.0
RFC 3/5 pci: introduce apci-index property for PCI device
In reply to Igor MammedovIn x86/ACPI world, since systemd v197, linux distros are using predictable network interface naming since systemd v197. Which on QEMU based VMs results into path based naming scheme, that names network interfaces based on PCI topology.
With this one has to plug NIC in exacly the same bus/slot, which was used when disk image was first provisioned/configured or one risks to loose network configuration due to NIC being renamed to actually used topology.
That also restricts freedom reshape PCI configuration of VM without need to reconfigure used guest image.
systemd also offers "onboard" naming scheme which is preffered over PCI slot/topology one, provided that firmware implements:
"
PCI Firmware Specification 3.1
4.6.7. DSM for Naming a PCI or PCI Express Device Under
Operating Systems
"
that allows to assign user defined index to PCI device, which systemd will use to name NIC. For example, using
-device e1000,acpi-index=100
guest will rename NIC to 'eno100', where 'eno' is default prefix for "onboard" naming scheme. This doesn't reqiure any advance configuration on guest side.
Hope is that 'acpi-index' will be easier to consume by mangment layer, compared to forcing specic PCI topology and/or having several disk image templates for different topologies and will help to simplify process of spawning VM from the same template without need to reconfigure guest network configuration.
this patch adds, 'acpi-index'* property and wires up (abuses) unused pci hotplug registers to pass index value to AML code at runtime.
Following patch will add corresponding _DSM code and wire it up to PCI devices described in ACPI.
*) name comes from linux kernel terminology
---
CC: [email protected]
include/hw/acpi/pcihp.h | 7 ++++++- include/hw/pci/pci.h | 1 + hw/acpi/pci.c | 6 ++++++ hw/acpi/pcihp.c | 25 ++++++++++++++++++++++++- hw/i386/acpi-build.c | 10 ++++++++++ hw/pci/pci.c | 1 + 6 files changed, 48 insertions(+), 2 deletions(-)
include/hw/acpi/pcihp.h +6 -1
@@ -46,6 +46,7 @@ typedef struct AcpiPciHpPciStatus { typedef struct AcpiPciHpState { AcpiPciHpPciStatus acpi_pcihp_pci_status[ACPI_PCIHP_MAX_HOTPLUG_BUS]; uint32_t hotplug_select; + uint32_t acpi_index; PCIBus *root; MemoryRegion io; bool legacy_piix;
@@ -71,6 +72,8 @@ void acpi_pcihp_reset(AcpiPciHpState *s, bool acpihp_root_off);extern const VMStateDescription vmstate_acpi_pcihp_pci_status; +bool vmstate_acpi_pcihp_use_acpi_index (void *opaque,int version_id); +#define VMSTATE_PCI_HOTPLUG (pcihp, state, test_pcihp) \ VMSTATE_UINT32_TEST(pcihp.hotplug_select, state, \ test_pcihp), \
@@ -78,6 +81,8 @@ extern const VMStateDescription vmstate_acpi_pcihp_pci_status; ACPI_PCIHP_MAX_HOTPLUG_BUS, \ test_pcihp, 1, \ vmstate_acpi_pcihp_pci_status, \ - AcpiPciHpPciStatus) + AcpiPciHpPciStatus), \ + VMSTATE_UINT32_TEST(pcihp.acpi_index, state, \ + vmstate_acpi_pcihp_use_acpi_index)#endif
include/hw/pci/pci.h +1 -0
@@ -357,6 +357,7 @@ struct PCIDevice {/* ID of standby device in net_failover pair */ char *failover_pair_id; +uint32_t acpi_index; }; void pci_register_bar(PCIDevice *pci_dev, int region_num,
hw/acpi/pci.c +6 -0
@@ -27,6 +27,7 @@#include "hw/acpi/aml-build.h" #include "hw/acpi/pci.h" #include "hw/pci/pcie_host.h" +#include "hw/acpi/pcihp.h" void build_mcfg (GArray *table_data,BIOSLinker *linker,AcpiMcfgInfo *info) {
@@ -59,3 +60,8 @@ void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info) "MCFG", table_data->len - mcfg_start, 1, NULL, NULL); } +bool vmstate_acpi_pcihp_use_acpi_index (void *opaque,int version_id) +{ +AcpiPciHpState *s = opaque; +return s->acpi_index; +}
hw/acpi/pcihp.c +24 -1
@@ -347,7 +347,8 @@ static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size)trace_acpi_pci_down_read (val);break ;case PCI_EJ_BASE : -/* No feature defined yet */ + val = s->acpi_index; + s->acpi_index =0 ;trace_acpi_pci_features_read (val);break ;case PCI_RMV_BASE :
@@ -367,8 +368,30 @@ static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size)static void pci_write (void *opaque,hwaddr addr,uint64_t data,unsigned int size) { +int slot; +PCIBus *bus; +BusChild *kid, *next;AcpiPciHpState *s = opaque; + + s->acpi_index =0 ;switch (addr) { +case PCI_UP_BASE : + slot =ctz32 (data); + +if (s->hotplug_select >=ACPI_PCIHP_MAX_HOTPLUG_BUS ) { +break ; + } + + bus =acpi_pcihp_find_hotplug_bus (s, s->hotplug_select); + QTAILQ_FOREACH_SAFE(kid, &bus->qbus.children, sibling, next) { +Object *o =OBJECT (kid->child); +PCIDevice *dev =PCI_DEVICE (o); +if (PCI_SLOT (dev->devfn) == slot) { + s->acpi_index =object_property_get_uint (o,"acpi-index" ,NULL ); +break ; + } + } +break ;case PCI_EJ_BASE :if (s->hotplug_select >=ACPI_PCIHP_MAX_HOTPLUG_BUS ) {break ;
hw/i386/acpi-build.c +10 -0
@@ -1132,6 +1132,16 @@ static void build_piix4_pci_hotplug(Aml *table)aml_append (method,aml_return (aml_int (0 )));aml_append (scope, method); + method =aml_method ("AIDX" ,2 ,AML_NOTSERIALIZED ); +aml_append (method,aml_acquire (aml_name ("BLCK" ),0xFFFF )); +aml_append (method,aml_store (aml_arg (0 ),aml_name ("BNUM" ))); +aml_append (method, +aml_store (aml_shiftleft (aml_int (1 ),aml_arg (1 )),aml_name ("PCIU" ))); +aml_append (method,aml_store (aml_name ("B0EJ" ),aml_local (0 ))); +aml_append (method,aml_release (aml_name ("BLCK" ))); +aml_append (method,aml_return (aml_local (0 ))); +aml_append (scope, method); +aml_append (table, scope); }
hw/pci/pci.c +1 -0
@@ -76,6 +76,7 @@ static Property pci_props[] = { QEMU_PCIE_EXTCAP_INIT_BITNR, true),DEFINE_PROP_STRING ("failover_pair_id" , PCIDevice, failover_pair_id), +DEFINE_PROP_UINT32 ("acpi-index" , PCIDevice, acpi_index,-1 ), DEFINE_PROP_END_OF_LIST() };
Signature · 1 line
2.27.0
RFC 4/5 pci: acpi: add _DSM method to PCI devices
In reply to Igor MammedovImplement _DSM according to:
PCI Firmware Specification 3.1
4.6.7. DSM for Naming a PCI or PCI Express Device Under
Operating Systems
and wire it up to cold and hot-plugged PCI devices. Feature depends on ACPI hotplug being enabled (as that provides PCI devices descriptions in ACPI and MMIO registers that are reused to fetch acpi-index).
acpi-index should work for
- cold plugged NICs:
$QEMU -evice e1000,acpi-index=100
=> 'eno100'
- hot-plugged
(monitor) device_add e1000,acpi-index=200,id=remove_me
=> 'eno200'
- replugged
(monitor) device_del remove_me
(monitor) device_add e1000,acpi-index=1
=> 'eno1'Windows also sees index under "PCI Label Id" field in properties dialog but otherwise it doesn't seem to have any effect.
--- include/hw/acpi/pci.h | 1 + hw/acpi/pci.c | 78 +++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 21 ++++++++++-- 3 files changed, 97 insertions(+), 3 deletions(-)
include/hw/acpi/pci.h +1 -0
@@ -34,4 +34,5 @@ typedef struct AcpiMcfgInfo { } AcpiMcfgInfo;void build_mcfg (GArray *table_data,BIOSLinker *linker,AcpiMcfgInfo *info); +Aml *aml_pci_device_dsm (void );#endif
hw/acpi/pci.c +78 -0
81 lines not on this page · raw message
hw/i386/acpi-build.c +18 -3
@@ -385,6 +385,13 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,aml_call2 ("PCEJ" ,aml_name ("BSEL" ),aml_name ("_SUN" )) );aml_append (dev, method); + method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); +aml_append (method, +aml_return (aml_call6 ("PDSM" ,aml_arg (0 ),aml_arg (1 ), +aml_arg (2 ),aml_arg (3 ), +aml_name ("BSEL" ),aml_name ("_SUN" ))) + ); +aml_append (dev, method);aml_append (parent_scope, dev);build_append_pcihp_notify_entry (notify_method, slot);
@@ -412,6 +419,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, dev =aml_device ("S%.02X" ,PCI_DEVFN (slot,0 ));aml_append (dev,aml_name_decl ("_ADR" ,aml_int (slot <<16 ))); +aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); + method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); +aml_append (method, +aml_return (aml_call6 ("PDSM" ,aml_arg (0 ),aml_arg (1 ),aml_arg (2 ), +aml_arg (3 ),aml_name ("BSEL" ),aml_name ("_SUN" ))) + ); +aml_append (dev, method); +if (pc->class_id ==PCI_CLASS_DISPLAY_VGA ) {/* add VGA specific AML methods */ int s3d;
@@ -434,9 +449,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,aml_append (method,aml_return (aml_int (s3d)));aml_append (dev, method); }else if (hotplug_enabled_dev) { -/* add _SUN/_EJ0 to make slot hotpluggable */ -aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); - +/* add _EJ0 to make slot hotpluggable */ method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED );aml_append (method, aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
@@ -1142,6 +1155,8 @@ static void build_piix4_pci_hotplug(Aml *table)aml_append (method,aml_return (aml_local (0 )));aml_append (scope, method); +aml_append (scope,aml_pci_device_dsm ()); +aml_append (table, scope); }
Signature · 1 line
2.27.0
Re: [RFC 4/5] pci: acpi: add _DSM method to PCI devices
Quoted 110 lines · Igor Mammedov
Implement
_DSMaccording to:
PCI Firmware Specification 3.1
4.6.7. DSM for Naming a PCI or PCI Express Device Under
Operating Systems
and wire it up to cold and hot-plugged PCI devices. Feature depends on ACPI hotplug being enabled (as that provides PCI devices descriptions in ACPI and MMIO registers that are reused to fetch acpi-index).acpi-index should work for
- cold plugged NICs:$QEMU -evice e1000,acpi-index=100 => 'eno100' - hot-plugged (monitor) device_add e1000,acpi-index=200,id=remove_me => 'eno200' - replugged (monitor) device_del remove_me (monitor) device_add e1000,acpi-index=1 => 'eno1'Windows also sees index under "PCI Label Id" field in properties dialog but otherwise it doesn't seem to have any effect.
Signed-off-by Igor Mammedov <[email protected]>--- include/hw/acpi/pci.h | 1 + hw/acpi/pci.c | 78 +++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 21 ++++++++++-- 3 files changed, 97 insertions(+), 3 deletions(-)include/hw/acpi/pci.h +1
-0@@ -34,4 +34,5 @@ typedef struct AcpiMcfgInfo { } AcpiMcfgInfo;void build_mcfg (GArray *table_data,BIOSLinker *linker,AcpiMcfgInfo *info); +Aml *aml_pci_device_dsm (void );#endif hw/acpi/pci.c +61
-0@@ -65,3 +65,81 @@ bool vmstate_acpi_pcihp_use_acpi_index(void *opaque, int version_id)AcpiPciHpState *s = opaque;return s->acpi_index; } + +Aml *aml_pci_device_dsm (void ) +{ +Aml *method, *UUID , *ifctx, *ifctx1, *ifctx2, *ifctx3, *elsectx; +Aml *acpi_index =aml_local (0 ); +Aml *zero =aml_int (0 ); +Aml *bnum =aml_arg (4 ); +Aml *sun =aml_arg (5 ); + + method =aml_method ("PDSM" ,6 ,AML_SERIALIZED ); + +/* +* PCI Firmware Specification 3.1 +* 4.6. _DSM Definitions for PCI +*/ +UUID =aml_touuid ("E5C937D0-3553-4D7A-9117-EA4D19C3434D" ); + ifctx =aml_if (aml_equal (aml_arg (0 ),UUID )); + { +aml_append (ifctx,aml_store (aml_call2 ("AIDX" , bnum, sun), acpi_index)); + ifctx1 =aml_if (aml_equal (aml_arg (2 ), zero)); + { +uint8_t byte_list[1 ]; + + ifctx2 =aml_if (aml_equal (aml_arg (1 ),aml_int (2 ))); + { +/* +* advertise function 7 if device has acpi-index +*/ + ifctx3 =aml_if (aml_lnot (aml_equal (acpi_index, zero))); + { + byte_list[0 ] = +1 /* have supported functions */ | +1 <<7 /* support for function 7 */ + ; +aml_append (ifctx3,aml_return (aml_buffer (1 , byte_list))); + } +aml_append (ifctx2, ifctx3); + } +aml_append (ifctx1, ifctx2); + + byte_list[0 ] =0 ;/* nothing supported */ +aml_append (ifctx1,aml_return (aml_buffer (1 , byte_list))); + } +aml_append (ifctx, ifctx1); + elsectx =aml_else (); +/* +* PCI Firmware Specification 3.1 +* 4.6.7. _DSM for Naming a PCI or PCI Express Device Under +* Operating Systems +*/ + ifctx1 =aml_if (aml_equal (aml_arg (2 ),aml_int (7 ))); + { +Aml *pkg =aml_package (2 ); +Aml *label =aml_local (2 ); +Aml *ret =aml_local (1 ); + +aml_append (ifctx1,aml_concatenate (aml_string ("PCI Device " ), +aml_to_decimalstring (acpi_index,NULL ), label)); + +aml_append (pkg, zero); +aml_append (pkg,aml_string ("placeholder" ));
hw/acpi/pci.c bool vmstate_acpi_pcihp_use_acpi_index(void *opaque, int version_id) · line 138
Quoted 10 lines
hw/acpi/pci.c +10
-0+aml_append (ifctx1,aml_store (pkg, ret)); +/* +* update apci-index to actual value +*/ +aml_append (ifctx1,aml_store (acpi_index,aml_index (ret, zero))); +/* +* update device label to actual value +*/ +aml_append (ifctx1,aml_store (label,aml_index (ret,aml_int (1 )))); +aml_append (ifctx1,aml_return (ret));
This code needs more comments to explain what it's doing. E.g. what is device label?
Spec seems to say the string is optional. Is it relevant somehow?
spec also says string must be unique. Do we need to enforce that?
Quoted 62 lines
hw/acpi/pci.c +7
-0+ } +aml_append (elsectx, ifctx1); +aml_append (ifctx, elsectx); + } +aml_append (method, ifctx); +return method; +}hw/i386/acpi-build.c +18
-3@@ -385,6 +385,13 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,aml_call2 ("PCEJ" ,aml_name ("BSEL" ),aml_name ("_SUN" )) );aml_append (dev, method); + method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); +aml_append (method, +aml_return (aml_call6 ("PDSM" ,aml_arg (0 ),aml_arg (1 ), +aml_arg (2 ),aml_arg (3 ), +aml_name ("BSEL" ),aml_name ("_SUN" ))) + ); +aml_append (dev, method);aml_append (parent_scope, dev);build_append_pcihp_notify_entry (notify_method, slot);@@ -412,6 +419,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, dev =aml_device ("S%.02X" ,PCI_DEVFN (slot,0 ));aml_append (dev,aml_name_decl ("_ADR" ,aml_int (slot <<16 ))); +aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); + method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); +aml_append (method, +aml_return (aml_call6 ("PDSM" ,aml_arg (0 ),aml_arg (1 ),aml_arg (2 ), +aml_arg (3 ),aml_name ("BSEL" ),aml_name ("_SUN" ))) + ); +aml_append (dev, method); +if (pc->class_id ==PCI_CLASS_DISPLAY_VGA ) {/* add VGA specific AML methods */ int s3d;@@ -434,9 +449,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,aml_append (method,aml_return (aml_int (s3d)));aml_append (dev, method); }else if (hotplug_enabled_dev) { -/* add _SUN/_EJ0 to make slot hotpluggable */ -aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); - +/* add _EJ0 to make slot hotpluggable */ method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED );aml_append (method, aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))@@ -1142,6 +1155,8 @@ static void build_piix4_pci_hotplug(Aml *table)aml_append (method,aml_return (aml_local (0 )));aml_append (scope, method); +aml_append (scope,aml_pci_device_dsm ()); +aml_append (table, scope); }Signature · 1 line
2.27.0
Re: [RFC 4/5] pci: acpi: add _DSM method to PCI devices
Quoted 117 lines · On Wed, 13 Jan 2021 07:13:04 -0500 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 116 lines · Igor Mammedov
Implement
_DSMaccording to:
PCI Firmware Specification 3.1
4.6.7. DSM for Naming a PCI or PCI Express Device Under
Operating Systems
and wire it up to cold and hot-plugged PCI devices. Feature depends on ACPI hotplug being enabled (as that provides PCI devices descriptions in ACPI and MMIO registers that are reused to fetch acpi-index).acpi-index should work for
- cold plugged NICs:$QEMU -evice e1000,acpi-index=100 => 'eno100' - hot-plugged (monitor) device_add e1000,acpi-index=200,id=remove_me => 'eno200' - replugged (monitor) device_del remove_me (monitor) device_add e1000,acpi-index=1 => 'eno1'Windows also sees index under "PCI Label Id" field in properties dialog but otherwise it doesn't seem to have any effect.
Signed-off-by Igor Mammedov <[email protected]>--- include/hw/acpi/pci.h | 1 + hw/acpi/pci.c | 78 +++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 21 ++++++++++-- 3 files changed, 97 insertions(+), 3 deletions(-)include/hw/acpi/pci.h +1
-0@@ -34,4 +34,5 @@ typedef struct AcpiMcfgInfo { } AcpiMcfgInfo;void build_mcfg (GArray *table_data,BIOSLinker *linker,AcpiMcfgInfo *info); +Aml *aml_pci_device_dsm (void );#endif hw/acpi/pci.c +67
-0@@ -65,3 +65,81 @@ bool vmstate_acpi_pcihp_use_acpi_index(void *opaque, int version_id)AcpiPciHpState *s = opaque;return s->acpi_index; } + +Aml *aml_pci_device_dsm (void ) +{ +Aml *method, *UUID , *ifctx, *ifctx1, *ifctx2, *ifctx3, *elsectx; +Aml *acpi_index =aml_local (0 ); +Aml *zero =aml_int (0 ); +Aml *bnum =aml_arg (4 ); +Aml *sun =aml_arg (5 ); + + method =aml_method ("PDSM" ,6 ,AML_SERIALIZED ); + +/* +* PCI Firmware Specification 3.1 +* 4.6. _DSM Definitions for PCI +*/ +UUID =aml_touuid ("E5C937D0-3553-4D7A-9117-EA4D19C3434D" ); + ifctx =aml_if (aml_equal (aml_arg (0 ),UUID )); + { +aml_append (ifctx,aml_store (aml_call2 ("AIDX" , bnum, sun), acpi_index)); + ifctx1 =aml_if (aml_equal (aml_arg (2 ), zero)); + { +uint8_t byte_list[1 ]; + + ifctx2 =aml_if (aml_equal (aml_arg (1 ),aml_int (2 ))); + { +/* +* advertise function 7 if device has acpi-index +*/ + ifctx3 =aml_if (aml_lnot (aml_equal (acpi_index, zero))); + { + byte_list[0 ] = +1 /* have supported functions */ | +1 <<7 /* support for function 7 */ + ; +aml_append (ifctx3,aml_return (aml_buffer (1 , byte_list))); + } +aml_append (ifctx2, ifctx3); + } +aml_append (ifctx1, ifctx2); + + byte_list[0 ] =0 ;/* nothing supported */ +aml_append (ifctx1,aml_return (aml_buffer (1 , byte_list))); + } +aml_append (ifctx, ifctx1); + elsectx =aml_else (); +/* +* PCI Firmware Specification 3.1 +* 4.6.7. _DSM for Naming a PCI or PCI Express Device Under +* Operating Systems +*/ + ifctx1 =aml_if (aml_equal (aml_arg (2 ),aml_int (7 ))); + { +Aml *pkg =aml_package (2 ); +Aml *label =aml_local (2 ); +Aml *ret =aml_local (1 ); + +aml_append (ifctx1,aml_concatenate (aml_string ("PCI Device " ), +aml_to_decimalstring (acpi_index,NULL ), label)); + +aml_append (pkg, zero); +aml_append (pkg,aml_string ("placeholder" )); +aml_append (ifctx1,aml_store (pkg, ret)); +/* +* update apci-index to actual value +*/ +aml_append (ifctx1,aml_store (acpi_index,aml_index (ret, zero))); +/*
Quoted 8 lines
hw/acpi/pci.c bool vmstate_acpi_pcihp_use_acpi_index(void *opaque, int version_id) · line 138
Quoted 4 lines
hw/acpi/pci.c +4
-0+* update device label to actual value +*/ +aml_append (ifctx1,aml_store (label,aml_index (ret,aml_int (1 )))); +aml_append (ifctx1,aml_return (ret));This code needs more comments to explain what it's doing. E.g. what is device label?
Spec seems to say the string is optional. Is it relevant somehow?
potentially label may be used (with custom rules) to for interface naming or as human readable PCI device description.
We probably can drop it, or provide and additional PCIDevice option to let user specify it on CLI along with acpi-index.
Quoted 2 lines
spec also says string must be unique. Do we need to enforce that?
I think we should enforce it (Though I intentionally dropped it from RFC)
Quoted 63 lines
Quoted 62 lines
hw/acpi/pci.c +7
-0+ } +aml_append (elsectx, ifctx1); +aml_append (ifctx, elsectx); + } +aml_append (method, ifctx); +return method; +}hw/i386/acpi-build.c +18
-3@@ -385,6 +385,13 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,aml_call2 ("PCEJ" ,aml_name ("BSEL" ),aml_name ("_SUN" )) );aml_append (dev, method); + method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); +aml_append (method, +aml_return (aml_call6 ("PDSM" ,aml_arg (0 ),aml_arg (1 ), +aml_arg (2 ),aml_arg (3 ), +aml_name ("BSEL" ),aml_name ("_SUN" ))) + ); +aml_append (dev, method);aml_append (parent_scope, dev);build_append_pcihp_notify_entry (notify_method, slot);@@ -412,6 +419,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, dev =aml_device ("S%.02X" ,PCI_DEVFN (slot,0 ));aml_append (dev,aml_name_decl ("_ADR" ,aml_int (slot <<16 ))); +aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); + method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); +aml_append (method, +aml_return (aml_call6 ("PDSM" ,aml_arg (0 ),aml_arg (1 ),aml_arg (2 ), +aml_arg (3 ),aml_name ("BSEL" ),aml_name ("_SUN" ))) + ); +aml_append (dev, method); +if (pc->class_id ==PCI_CLASS_DISPLAY_VGA ) {/* add VGA specific AML methods */ int s3d;@@ -434,9 +449,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,aml_append (method,aml_return (aml_int (s3d)));aml_append (dev, method); }else if (hotplug_enabled_dev) { -/* add _SUN/_EJ0 to make slot hotpluggable */ -aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); - +/* add _EJ0 to make slot hotpluggable */ method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED );aml_append (method, aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))@@ -1142,6 +1155,8 @@ static void build_piix4_pci_hotplug(Aml *table)aml_append (method,aml_return (aml_local (0 )));aml_append (scope, method); +aml_append (scope,aml_pci_device_dsm ()); +aml_append (table, scope); }Signature · 1 line
2.27.0
Re: [RFC 4/5] pci: acpi: add _DSM method to PCI devices
In reply to Igor MammedovQuoted 46 lines · Igor Mammedov
Implement
_DSMaccording to:
PCI Firmware Specification 3.1
4.6.7. DSM for Naming a PCI or PCI Express Device Under
Operating Systems
and wire it up to cold and hot-plugged PCI devices. Feature depends on ACPI hotplug being enabled (as that provides PCI devices descriptions in ACPI and MMIO registers that are reused to fetch acpi-index).acpi-index should work for
- cold plugged NICs:$QEMU -evice e1000,acpi-index=100 => 'eno100' - hot-plugged (monitor) device_add e1000,acpi-index=200,id=remove_me => 'eno200' - replugged (monitor) device_del remove_me (monitor) device_add e1000,acpi-index=1 => 'eno1'Windows also sees index under "PCI Label Id" field in properties dialog but otherwise it doesn't seem to have any effect.
Signed-off-by Igor Mammedov <[email protected]>--- include/hw/acpi/pci.h | 1 + hw/acpi/pci.c | 78 +++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 21 ++++++++++-- 3 files changed, 97 insertions(+), 3 deletions(-)include/hw/acpi/pci.h +1
-0@@ -34,4 +34,5 @@ typedef struct AcpiMcfgInfo { } AcpiMcfgInfo;void build_mcfg (GArray *table_data,BIOSLinker *linker,AcpiMcfgInfo *info); +Aml *aml_pci_device_dsm (void );#endif hw/acpi/pci.c +0
-0
hw/acpi/pci.c bool vmstate_acpi_pcihp_use_acpi_index(void *opaque, int version_id) · line 71
Quoted 7 lines
hw/acpi/pci.c +4
-0@@ -65,3 +65,81 @@ bool vmstate_acpi_pcihp_use_acpi_index(void *opaque, int version_id)AcpiPciHpState *s = opaque;return s->acpi_index; } + +Aml *aml_pci_device_dsm (void ) +{ +Aml *method, *UUID , *ifctx, *ifctx1, *ifctx2, *ifctx3, *elsectx;
s/UUID/uuid/ I think ...
And can we move ifctx things to the correct scope?
Quoted 129 lines
hw/acpi/pci.c +74
-0+Aml *acpi_index =aml_local (0 ); +Aml *zero =aml_int (0 ); +Aml *bnum =aml_arg (4 ); +Aml *sun =aml_arg (5 ); + + method =aml_method ("PDSM" ,6 ,AML_SERIALIZED ); + +/* +* PCI Firmware Specification 3.1 +* 4.6. _DSM Definitions for PCI +*/ +UUID =aml_touuid ("E5C937D0-3553-4D7A-9117-EA4D19C3434D" ); + ifctx =aml_if (aml_equal (aml_arg (0 ),UUID )); + { +aml_append (ifctx,aml_store (aml_call2 ("AIDX" , bnum, sun), acpi_index)); + ifctx1 =aml_if (aml_equal (aml_arg (2 ), zero)); + { +uint8_t byte_list[1 ]; + + ifctx2 =aml_if (aml_equal (aml_arg (1 ),aml_int (2 ))); + { +/* +* advertise function 7 if device has acpi-index +*/ + ifctx3 =aml_if (aml_lnot (aml_equal (acpi_index, zero))); + { + byte_list[0 ] = +1 /* have supported functions */ | +1 <<7 /* support for function 7 */ + ; +aml_append (ifctx3,aml_return (aml_buffer (1 , byte_list))); + } +aml_append (ifctx2, ifctx3); + } +aml_append (ifctx1, ifctx2); + + byte_list[0 ] =0 ;/* nothing supported */ +aml_append (ifctx1,aml_return (aml_buffer (1 , byte_list))); + } +aml_append (ifctx, ifctx1); + elsectx =aml_else (); +/* +* PCI Firmware Specification 3.1 +* 4.6.7. _DSM for Naming a PCI or PCI Express Device Under +* Operating Systems +*/ + ifctx1 =aml_if (aml_equal (aml_arg (2 ),aml_int (7 ))); + { +Aml *pkg =aml_package (2 ); +Aml *label =aml_local (2 ); +Aml *ret =aml_local (1 ); + +aml_append (ifctx1,aml_concatenate (aml_string ("PCI Device " ), +aml_to_decimalstring (acpi_index,NULL ), label)); + +aml_append (pkg, zero); +aml_append (pkg,aml_string ("placeholder" )); +aml_append (ifctx1,aml_store (pkg, ret)); +/* +* update apci-index to actual value +*/ +aml_append (ifctx1,aml_store (acpi_index,aml_index (ret, zero))); +/* +* update device label to actual value +*/ +aml_append (ifctx1,aml_store (label,aml_index (ret,aml_int (1 )))); +aml_append (ifctx1,aml_return (ret)); + } +aml_append (elsectx, ifctx1); +aml_append (ifctx, elsectx); + } +aml_append (method, ifctx); +return method; +}hw/i386/acpi-build.c +18
-3@@ -385,6 +385,13 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,aml_call2 ("PCEJ" ,aml_name ("BSEL" ),aml_name ("_SUN" )) );aml_append (dev, method); + method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); +aml_append (method, +aml_return (aml_call6 ("PDSM" ,aml_arg (0 ),aml_arg (1 ), +aml_arg (2 ),aml_arg (3 ), +aml_name ("BSEL" ),aml_name ("_SUN" ))) + ); +aml_append (dev, method);aml_append (parent_scope, dev);build_append_pcihp_notify_entry (notify_method, slot);@@ -412,6 +419,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, dev =aml_device ("S%.02X" ,PCI_DEVFN (slot,0 ));aml_append (dev,aml_name_decl ("_ADR" ,aml_int (slot <<16 ))); +aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); + method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); +aml_append (method, +aml_return (aml_call6 ("PDSM" ,aml_arg (0 ),aml_arg (1 ),aml_arg (2 ), +aml_arg (3 ),aml_name ("BSEL" ),aml_name ("_SUN" ))) + ); +aml_append (dev, method); +if (pc->class_id ==PCI_CLASS_DISPLAY_VGA ) {/* add VGA specific AML methods */ int s3d;@@ -434,9 +449,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,aml_append (method,aml_return (aml_int (s3d)));aml_append (dev, method); }else if (hotplug_enabled_dev) { -/* add _SUN/_EJ0 to make slot hotpluggable */ -aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); - +/* add _EJ0 to make slot hotpluggable */ method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED );aml_append (method, aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))@@ -1142,6 +1155,8 @@ static void build_piix4_pci_hotplug(Aml *table)aml_append (method,aml_return (aml_local (0 )));aml_append (scope, method); +aml_append (scope,aml_pci_device_dsm ()); +aml_append (table, scope); }Signature · 1 line
2.27.0
Re: [RFC 4/5] pci: acpi: add _DSM method to PCI devices
Quoted 57 lines · On Tue, 26 Jan 2021 06:16:50 -0500 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 46 lines · Igor Mammedov
Implement
_DSMaccording to:
PCI Firmware Specification 3.1
4.6.7. DSM for Naming a PCI or PCI Express Device Under
Operating Systems
and wire it up to cold and hot-plugged PCI devices. Feature depends on ACPI hotplug being enabled (as that provides PCI devices descriptions in ACPI and MMIO registers that are reused to fetch acpi-index).acpi-index should work for
- cold plugged NICs:$QEMU -evice e1000,acpi-index=100 => 'eno100' - hot-plugged (monitor) device_add e1000,acpi-index=200,id=remove_me => 'eno200' - replugged (monitor) device_del remove_me (monitor) device_add e1000,acpi-index=1 => 'eno1'Windows also sees index under "PCI Label Id" field in properties dialog but otherwise it doesn't seem to have any effect.
Signed-off-by Igor Mammedov <[email protected]>--- include/hw/acpi/pci.h | 1 + hw/acpi/pci.c | 78 +++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 21 ++++++++++-- 3 files changed, 97 insertions(+), 3 deletions(-)include/hw/acpi/pci.h +1
-0@@ -34,4 +34,5 @@ typedef struct AcpiMcfgInfo { } AcpiMcfgInfo;void build_mcfg (GArray *table_data,BIOSLinker *linker,AcpiMcfgInfo *info); +Aml *aml_pci_device_dsm (void );#endif hw/acpi/pci.c +0
-0hw/acpi/pci.c bool vmstate_acpi_pcihp_use_acpi_index(void *opaque, int version_id) · line 71
Quoted 7 lines
hw/acpi/pci.c +4
-0@@ -65,3 +65,81 @@ bool vmstate_acpi_pcihp_use_acpi_index(void *opaque, int version_id)AcpiPciHpState *s = opaque;return s->acpi_index; } + +Aml *aml_pci_device_dsm (void ) +{ +Aml *method, *UUID , *ifctx, *ifctx1, *ifctx2, *ifctx3, *elsectx;s/UUID/uuid/ I think ...
Quoted 1 line
And can we move ifctx things to the correct scope?
I'll try to do it.
Quoted 131 lines
Quoted 130 lines
hw/acpi/pci.c +74
-0+Aml *acpi_index =aml_local (0 ); +Aml *zero =aml_int (0 ); +Aml *bnum =aml_arg (4 ); +Aml *sun =aml_arg (5 ); + + method =aml_method ("PDSM" ,6 ,AML_SERIALIZED ); + +/* +* PCI Firmware Specification 3.1 +* 4.6. _DSM Definitions for PCI +*/ +UUID =aml_touuid ("E5C937D0-3553-4D7A-9117-EA4D19C3434D" ); + ifctx =aml_if (aml_equal (aml_arg (0 ),UUID )); + { +aml_append (ifctx,aml_store (aml_call2 ("AIDX" , bnum, sun), acpi_index)); + ifctx1 =aml_if (aml_equal (aml_arg (2 ), zero)); + { +uint8_t byte_list[1 ]; + + ifctx2 =aml_if (aml_equal (aml_arg (1 ),aml_int (2 ))); + { +/* +* advertise function 7 if device has acpi-index +*/ + ifctx3 =aml_if (aml_lnot (aml_equal (acpi_index, zero))); + { + byte_list[0 ] = +1 /* have supported functions */ | +1 <<7 /* support for function 7 */ + ; +aml_append (ifctx3,aml_return (aml_buffer (1 , byte_list))); + } +aml_append (ifctx2, ifctx3); + } +aml_append (ifctx1, ifctx2); + + byte_list[0 ] =0 ;/* nothing supported */ +aml_append (ifctx1,aml_return (aml_buffer (1 , byte_list))); + } +aml_append (ifctx, ifctx1); + elsectx =aml_else (); +/* +* PCI Firmware Specification 3.1 +* 4.6.7. _DSM for Naming a PCI or PCI Express Device Under +* Operating Systems +*/ + ifctx1 =aml_if (aml_equal (aml_arg (2 ),aml_int (7 ))); + { +Aml *pkg =aml_package (2 ); +Aml *label =aml_local (2 ); +Aml *ret =aml_local (1 ); + +aml_append (ifctx1,aml_concatenate (aml_string ("PCI Device " ), +aml_to_decimalstring (acpi_index,NULL ), label)); + +aml_append (pkg, zero); +aml_append (pkg,aml_string ("placeholder" )); +aml_append (ifctx1,aml_store (pkg, ret)); +/* +* update apci-index to actual value +*/ +aml_append (ifctx1,aml_store (acpi_index,aml_index (ret, zero))); +/* +* update device label to actual value +*/ +aml_append (ifctx1,aml_store (label,aml_index (ret,aml_int (1 )))); +aml_append (ifctx1,aml_return (ret)); + } +aml_append (elsectx, ifctx1); +aml_append (ifctx, elsectx); + } +aml_append (method, ifctx); +return method; +}hw/i386/acpi-build.c +18
-3@@ -385,6 +385,13 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,aml_call2 ("PCEJ" ,aml_name ("BSEL" ),aml_name ("_SUN" )) );aml_append (dev, method); + method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); +aml_append (method, +aml_return (aml_call6 ("PDSM" ,aml_arg (0 ),aml_arg (1 ), +aml_arg (2 ),aml_arg (3 ), +aml_name ("BSEL" ),aml_name ("_SUN" ))) + ); +aml_append (dev, method);aml_append (parent_scope, dev);build_append_pcihp_notify_entry (notify_method, slot);@@ -412,6 +419,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, dev =aml_device ("S%.02X" ,PCI_DEVFN (slot,0 ));aml_append (dev,aml_name_decl ("_ADR" ,aml_int (slot <<16 ))); +aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); + method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); +aml_append (method, +aml_return (aml_call6 ("PDSM" ,aml_arg (0 ),aml_arg (1 ),aml_arg (2 ), +aml_arg (3 ),aml_name ("BSEL" ),aml_name ("_SUN" ))) + ); +aml_append (dev, method); +if (pc->class_id ==PCI_CLASS_DISPLAY_VGA ) {/* add VGA specific AML methods */ int s3d;@@ -434,9 +449,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,aml_append (method,aml_return (aml_int (s3d)));aml_append (dev, method); }else if (hotplug_enabled_dev) { -/* add _SUN/_EJ0 to make slot hotpluggable */ -aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); - +/* add _EJ0 to make slot hotpluggable */ method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED );aml_append (method, aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))@@ -1142,6 +1155,8 @@ static void build_piix4_pci_hotplug(Aml *table)aml_append (method,aml_return (aml_local (0 )));aml_append (scope, method); +aml_append (scope,aml_pci_device_dsm ()); +aml_append (table, scope); }Signature · 1 line
2.27.0
RFC 5/5 tests: acpi: update expected data files
In reply to Igor MammedovExpected change is addition of
AIDX and PDSM methods at PCI0 scope and
_DSM methods (+ _SUN field where it was missing) to each PCI device slot
@@ -277,6 +277,54 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001)
Release (BLCK)
Return (Zero)
}
+
+ Method (AIDX, 2, NotSerialized)
+ {
+ Acquire (BLCK, 0xFFFF)
+ BNUM = Arg0
+ PCIU = (One << Arg1)
+ Local0 = B0EJ /* \_SB_.PCI0.B0EJ */
+ Release (BLCK)
+ Return (Local0)+ }
+
+ Method (PDSM, 6, Serialized)
+ {
+ If ((Arg0 == ToUUID ("e5c937d0-3553-4d7a-9117-ea4d19c3434d") /* Device Labeling Interface */))
+ {
+ Local0 = AIDX (Arg4, Arg5)
+ If ((Arg2 == Zero))
+ {+ If ((Arg1 == 0x02))
+ {
+ If ((Local0 != Zero))
+ {
+ Return (Buffer (One)
+ {
+ 0x81 // .
+ })
+ }
+ }
+
+ Return (Buffer (One)
+ {
+ 0x00 // .
+ })
+ }
+ ElseIf ((Arg2 == 0x07))
+ {+ Concatenate ("PCI Device ", ToDecimalString (Local0), Local2)
+ Local1 = Package (0x02)
+ {
+ Zero,
+ "placeholder"
+ }
+ Local1 [Zero] = Local0
+ Local1 [One] = Local2
+ Return (Local1)
+ }
+ }
+ }
}
Scope (_SB)
@@ -883,11 +931,22 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001)
Device (S00)
{
Name (_ADR, Zero) // _ADR: Address
+ Name (_SUN, Zero) // _SUN: Slot User Number
+ Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method
+ {
+ Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, _SUN))
+ }
}
[...]
@@ -912,6 +971,11 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001)
{
PCEJ (BSEL, _SUN)
}+
+ Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method
+ {
+ Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, _SUN))
+ }
}
[...]
--- tests/data/acpi/pc/DSDT | Bin 5065 -> 6023 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 6390 -> 7348 bytes tests/data/acpi/pc/DSDT.bridge | Bin 6924 -> 8689 bytes tests/data/acpi/pc/DSDT.cphp | Bin 5529 -> 6487 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 6719 -> 7677 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 5026 -> 5990 bytes tests/data/acpi/pc/DSDT.hpbrroot | Bin 3084 -> 3177 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 5137 -> 6095 bytes tests/data/acpi/pc/DSDT.memhp | Bin 6424 -> 7382 bytes tests/data/acpi/pc/DSDT.numamem | Bin 5071 -> 6029 bytes tests/data/acpi/pc/DSDT.roothp | Bin 5261 -> 6324 bytes tests/data/acpi/q35/DSDT | Bin 7801 -> 7863 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9126 -> 9188 bytes tests/data/acpi/q35/DSDT.bridge | Bin 7819 -> 7911 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8265 -> 8327 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9455 -> 9517 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 7876 -> 7938 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9160 -> 9222 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 8932 -> 9024 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7807 -> 7869 bytes tests/data/acpi/q35/DSDT.tis | Bin 8407 -> 8468 bytes 21 files changed, 0 insertions(+), 0 deletions(-)
tests/data/acpi/pc/DSDT binary +0 -0
tests/data/acpi/pc/DSDT.acpihmat binary +0 -0
tests/data/acpi/pc/DSDT.bridge binary +0 -0
tests/data/acpi/pc/DSDT.cphp binary +0 -0
tests/data/acpi/pc/DSDT.dimmpxm binary +0 -0
tests/data/acpi/pc/DSDT.hpbridge binary +0 -0
tests/data/acpi/pc/DSDT.hpbrroot binary +0 -0
tests/data/acpi/pc/DSDT.ipmikcs binary +0 -0
tests/data/acpi/pc/DSDT.memhp binary +0 -0
tests/data/acpi/pc/DSDT.numamem binary +0 -0
tests/data/acpi/pc/DSDT.roothp binary +0 -0
tests/data/acpi/q35/DSDT binary +0 -0
tests/data/acpi/q35/DSDT.acpihmat binary +0 -0
tests/data/acpi/q35/DSDT.bridge binary +0 -0
tests/data/acpi/q35/DSDT.cphp binary +0 -0
tests/data/acpi/q35/DSDT.dimmpxm binary +0 -0
tests/data/acpi/q35/DSDT.ipmibt binary +0 -0
tests/data/acpi/q35/DSDT.memhp binary +0 -0
tests/data/acpi/q35/DSDT.mmio64 binary +0 -0
tests/data/acpi/q35/DSDT.numamem binary +0 -0
tests/data/acpi/q35/DSDT.tis binary +0 -0
Signature · 1 line
2.27.0
Quoted 5 lines · Igor Mammedov
Series implements support for 'onboard' naming scheme for network interfaces (1), which is based on PCI firmware spec and lets user to explicitly specify index that will be used by guest to name network interface, ex:
Quoted 8 lines
-device e1000,acpi-index=33should make guest rename NIC name to 'eno33' where 'eno' is default prefix for this scheme.
Hope is that it will allow to simplify launching VMs from template disk images with different set VM configurations without need to reconfigure guest network intrfaces or risk of loosing network connectivity.
Questions:
the spec says:
Assignment of specific device names to multi-function devices installed in expansion slots, and/or PCI or PCI Express devices that are hot-added to expansion slots in operating system- environment would be handled in operating system-specific manner, and is not specified via this specification.
Accordingly, link below says:
" Names incorporating Firmware/BIOS provided index numbers for on-board devices (example: eno1)"
to what extend does guest assume the index is for on-board devices? it seems things work for fedora but how confident are we that this will keep working.
Further, code seems to only look at the slot level. According to this, and according to the spec, this does not work with multifunction devices, does it?
The link you supplied lists another option:
"Names incorporating Firmware/BIOS provided PCI Express hotplug slot index numbers (example: ens1)" these are under management control already ...
Also if we ask users to supply the property on the slot then it seems that the property can be baked into ACPI when it's created instead of being loaded from host - we can avoid adding new registers, this seems preferable. Could someone from management side chime in on whether that is sufficient?
More questions:
does all this affect windows guests at all?
where does the "acpi index" terminology come from? the pci firmware spec talks about "instance number", right?
Quoted 50 lines
For more detailed description/examples see patches [3-4/5]
1)
https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/Git repo for testing:
https://github.com/imammedo/qemu/branches acpi-index-rfcIgor Mammedov (5):
acpi: addaml_to_decimalstring()andaml_call6()helpers
tests: acpi: temporary whitelist DSDT changes
pci: introduce apci-index property for PCI device
pci: acpi: add_DSMmethod to PCI devices
tests: acpi: update expected data filesinclude/hw/acpi/aml-build.h | 3 + include/hw/acpi/pci.h | 1 + include/hw/acpi/pcihp.h | 7 +- include/hw/pci/pci.h | 1 + tests/qtest/bios-tables-test-allowed-diff.h | 21 +++++ hw/acpi/aml-build.c | 28 +++++++ hw/acpi/pci.c | 84 ++++++++++++++++++++ hw/acpi/pcihp.c | 25 +++++- hw/i386/acpi-build.c | 31 +++++++- hw/pci/pci.c | 1 + tests/data/acpi/pc/DSDT | Bin 5065 -> 6023 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 6390 -> 7348 bytes tests/data/acpi/pc/DSDT.bridge | Bin 6924 -> 8689 bytes tests/data/acpi/pc/DSDT.cphp | Bin 5529 -> 6487 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 6719 -> 7677 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 5026 -> 5990 bytes tests/data/acpi/pc/DSDT.hpbrroot | Bin 3084 -> 3177 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 5137 -> 6095 bytes tests/data/acpi/pc/DSDT.memhp | Bin 6424 -> 7382 bytes tests/data/acpi/pc/DSDT.numamem | Bin 5071 -> 6029 bytes tests/data/acpi/pc/DSDT.roothp | Bin 5261 -> 6324 bytes tests/data/acpi/q35/DSDT | Bin 7801 -> 7863 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9126 -> 9188 bytes tests/data/acpi/q35/DSDT.bridge | Bin 7819 -> 7911 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8265 -> 8327 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9455 -> 9517 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 7876 -> 7938 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9160 -> 9222 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 8932 -> 9024 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7807 -> 7869 bytes tests/data/acpi/q35/DSDT.tis | Bin 8407 -> 8468 bytes 31 files changed, 197 insertions(+), 5 deletions(-)Signature · 1 line
2.27.0
Quoted 22 lines · On Wed, 13 Jan 2021 07:09:56 -0500 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
Series implements support for 'onboard' naming scheme for network interfaces (1), which is based on PCI firmware spec and lets user to explicitly specify index that will be used by guest to name network interface, ex:
Quoted 8 lines
-device e1000,acpi-index=33should make guest rename NIC name to 'eno33' where 'eno' is default prefix for this scheme.
Hope is that it will allow to simplify launching VMs from template disk images with different set VM configurations without need to reconfigure guest network intrfaces or risk of loosing network connectivity.
Questions:
the spec says:
Assignment of specific device names to multi-function devices installed in expansion slots, and/or PCI or PCI Express devices that are hot-added to expansion slots in operating system- environment would be handled in operating system-specific manner, and is not specified via this specification.
Quoted 6 lines
Accordingly, link below says:
" Names incorporating Firmware/BIOS provided index numbers for on-board devices (example: eno1)"to what extend does guest assume the index is for on-board devices? it seems things work for fedora but how confident are we that this will keep working.
code itself is not limiting it to onboard devices in any way. (I can only speculate here, reason for calling it onboard is that on real hardware ACPI is mostly static tables and firmware provides an option to set index for only built-in NICs). Technically there is no reason to call in onboad though.
I'd believe it should work with any distribution that uses recent enough systemd/udev (released starting from 2003).
Quoted 3 lines
Further, code seems to only look at the slot level. According to this, and according to the spec, this does not work with multifunction devices, does it?
we probably should disable it for multifunction devices, any suggestions how to detect those in QEMU?
Quoted 3 lines
The link you supplied lists another option:
"Names incorporating Firmware/BIOS provided PCI Express hotplug slot index numbers (example: ens1)" these are under management control already ...
with it interface name continues to depend on PCI topology (and theoretically limited to PCI expess). That's becomes harder to consume as complexity grows (i.e. mgmt needs to keep NIC in the same place for which guest image was configured for). acpi-index doesn't impose such limitation.
In case of 1 NIC, it could be moved anywhere within PCI hierarchy and guest doesn't have to be reconfigured to account for new interface name (i.e without loosing network connectivity - that's the actual issue coming from upper layers that made me look into acpi-index approach).
In another words acpi index is easier to consume for users above libvirt and frees mgmt hands in a way it could distribute PCI devices. Even better would be if guest image could carry index as metadata
Quoted 5 lines
Also if we ask users to supply the property on the slot then it seems that the property can be baked into ACPI when it's created instead of being loaded from host - we can avoid adding new registers, this seems preferable. Could someone from management side chime in on whether that is sufficient?
I did consider it (it would be simpler, but not much), however unless we disable PCI hotplug for affected slots it won't work. (unplug device from such slot and plug another in that place will still return boot time index. That's why I ended up with hotplug variant.
I chose abusing existing PCI hotplug registers for it, but we can use a new range if that's preferred.
Quoted 3 lines
More questions:
does all this affect windows guests at all?
I don't know (spec shows examples that reminded me about NIC naming which Windows use(s|d)). But I won't bet on it.
If I recall correctly, for e1000 NIC, it didn't made any difference in naming (pre-existing guest image).
Quoted 2 lines
where does the "acpi index" terminology come from? the pci firmware spec talks about "instance number", right?
it comes from linux kernel (that's how it's named in sysfs) and systemd/udev uses it. So I tried to avoid making up another one.
Quoted 52 lines
Quoted 50 lines
For more detailed description/examples see patches [3-4/5]
1)
https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/Git repo for testing:
https://github.com/imammedo/qemu/branches acpi-index-rfcIgor Mammedov (5):
acpi: addaml_to_decimalstring()andaml_call6()helpers
tests: acpi: temporary whitelist DSDT changes
pci: introduce apci-index property for PCI device
pci: acpi: add_DSMmethod to PCI devices
tests: acpi: update expected data filesinclude/hw/acpi/aml-build.h | 3 + include/hw/acpi/pci.h | 1 + include/hw/acpi/pcihp.h | 7 +- include/hw/pci/pci.h | 1 + tests/qtest/bios-tables-test-allowed-diff.h | 21 +++++ hw/acpi/aml-build.c | 28 +++++++ hw/acpi/pci.c | 84 ++++++++++++++++++++ hw/acpi/pcihp.c | 25 +++++- hw/i386/acpi-build.c | 31 +++++++- hw/pci/pci.c | 1 + tests/data/acpi/pc/DSDT | Bin 5065 -> 6023 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 6390 -> 7348 bytes tests/data/acpi/pc/DSDT.bridge | Bin 6924 -> 8689 bytes tests/data/acpi/pc/DSDT.cphp | Bin 5529 -> 6487 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 6719 -> 7677 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 5026 -> 5990 bytes tests/data/acpi/pc/DSDT.hpbrroot | Bin 3084 -> 3177 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 5137 -> 6095 bytes tests/data/acpi/pc/DSDT.memhp | Bin 6424 -> 7382 bytes tests/data/acpi/pc/DSDT.numamem | Bin 5071 -> 6029 bytes tests/data/acpi/pc/DSDT.roothp | Bin 5261 -> 6324 bytes tests/data/acpi/q35/DSDT | Bin 7801 -> 7863 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9126 -> 9188 bytes tests/data/acpi/q35/DSDT.bridge | Bin 7819 -> 7911 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8265 -> 8327 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9455 -> 9517 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 7876 -> 7938 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9160 -> 9222 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 8932 -> 9024 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7807 -> 7869 bytes tests/data/acpi/q35/DSDT.tis | Bin 8407 -> 8468 bytes 31 files changed, 197 insertions(+), 5 deletions(-)Signature · 1 line
2.27.0
Quoted 32 lines · Igor Mammedov
Quoted 22 lines · On Wed, 13 Jan 2021 07:09:56 -0500 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
Series implements support for 'onboard' naming scheme for network interfaces (1), which is based on PCI firmware spec and lets user to explicitly specify index that will be used by guest to name network interface, ex:
Quoted 8 lines
-device e1000,acpi-index=33should make guest rename NIC name to 'eno33' where 'eno' is default prefix for this scheme.
Hope is that it will allow to simplify launching VMs from template disk images with different set VM configurations without need to reconfigure guest network intrfaces or risk of loosing network connectivity.
Questions:
the spec says:
Assignment of specific device names to multi-function devices installed in expansion slots, and/or PCI or PCI Express devices that are hot-added to expansion slots in operating system- environment would be handled in operating system-specific manner, and is not specified via this specification.Quoted 6 lines
Accordingly, link below says:
" Names incorporating Firmware/BIOS provided index numbers for on-board devices (example: eno1)"to what extend does guest assume the index is for on-board devices? it seems things work for fedora but how confident are we that this will keep working.
Quoted 5 lines
code itself is not limiting it to onboard devices in any way. (I can only speculate here, reason for calling it onboard is that on real hardware ACPI is mostly static tables and firmware provides an option to set index for only built-in NICs). Technically there is no reason to call in onboad though.
Well there's an smbios thing that I believe says onboard in the spec. Come to think of it that one actually applies to multifunction devices too.
Quoted 10 lines
I'd believe it should work with any distribution that uses recent enough systemd/udev (released starting from 2003).
Quoted 3 lines
Further, code seems to only look at the slot level. According to this, and according to the spec, this does not work with multifunction devices, does it?
we probably should disable it for multifunction devices, any suggestions how to detect those in QEMU?
QEMU_PCI_CAP_MULTIFUNCTION_BITNR ?
Enforcing this will help but can we make this self-documenting somehow?
Quoted 10 lines
Quoted 4 lines
The link you supplied lists another option:
"Names incorporating Firmware/BIOS provided PCI Express hotplug slot index numbers (example: ens1)" these are under management control already ...with it interface name continues to depend on PCI topology (and theoretically limited to PCI expess). That's becomes harder to consume as complexity grows (i.e. mgmt needs to keep NIC in the same place for which guest image was configured for). acpi-index doesn't impose such limitation.
Quoted 4 lines
In case of 1 NIC, it could be moved anywhere within PCI hierarchy and guest doesn't have to be reconfigured to account for new interface name (i.e without loosing network connectivity - that's the actual issue coming from upper layers that made me look into acpi-index approach).
Could you describe the issue in a bit more detail in the commit log pls?
Quoted 10 lines
In another words acpi index is easier to consume for users above libvirt and frees mgmt hands in a way it could distribute PCI devices. Even better would be if guest image could carry index as metadata
Quoted 5 lines
Also if we ask users to supply the property on the slot then it seems that the property can be baked into ACPI when it's created instead of being loaded from host - we can avoid adding new registers, this seems preferable. Could someone from management side chime in on whether that is sufficient?
Quoted 3 lines
I did consider it (it would be simpler, but not much), however unless we disable PCI hotplug for affected slots it won't work. (unplug device from such slot and plug another in that place will still return boot time index.
Well it's interesting that you mention it. Let's say you remove a device then plug in a different index immediately ... Guest gets a wrong name temporarily, right?
Should we worry about that?
Quoted 4 lines
That's why I ended up with hotplug variant.
I chose abusing existing PCI hotplug registers for it, but we can use a new range if that's preferred.
Would it work for multi-function devices though?
If yes that's a big advantage ...
Quoted 9 lines
Quoted 3 lines
More questions:
does all this affect windows guests at all?
I don't know (spec shows examples that reminded me about NIC naming which Windows use(s|d)). But I won't bet on it.
If I recall correctly, for e1000 NIC, it didn't made any difference in naming (pre-existing guest image).
Quoted 5 lines
Quoted 2 lines
where does the "acpi index" terminology come from? the pci firmware spec talks about "instance number", right?
it comes from linux kernel (that's how it's named in sysfs) and systemd/udev uses it. So I tried to avoid making up another one.
OTOH that's guest specific ... and does not seem to imply the limitations unless you look at the code ...
Quoted 53 lines
Quoted 53 lines
Quoted 51 lines
For more detailed description/examples see patches [3-4/5]
1)
https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/Git repo for testing:
https://github.com/imammedo/qemu/branches acpi-index-rfcIgor Mammedov (5):
acpi: addaml_to_decimalstring()andaml_call6()helpers
tests: acpi: temporary whitelist DSDT changes
pci: introduce apci-index property for PCI device
pci: acpi: add_DSMmethod to PCI devices
tests: acpi: update expected data filesinclude/hw/acpi/aml-build.h | 3 + include/hw/acpi/pci.h | 1 + include/hw/acpi/pcihp.h | 7 +- include/hw/pci/pci.h | 1 + tests/qtest/bios-tables-test-allowed-diff.h | 21 +++++ hw/acpi/aml-build.c | 28 +++++++ hw/acpi/pci.c | 84 ++++++++++++++++++++ hw/acpi/pcihp.c | 25 +++++- hw/i386/acpi-build.c | 31 +++++++- hw/pci/pci.c | 1 + tests/data/acpi/pc/DSDT | Bin 5065 -> 6023 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 6390 -> 7348 bytes tests/data/acpi/pc/DSDT.bridge | Bin 6924 -> 8689 bytes tests/data/acpi/pc/DSDT.cphp | Bin 5529 -> 6487 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 6719 -> 7677 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 5026 -> 5990 bytes tests/data/acpi/pc/DSDT.hpbrroot | Bin 3084 -> 3177 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 5137 -> 6095 bytes tests/data/acpi/pc/DSDT.memhp | Bin 6424 -> 7382 bytes tests/data/acpi/pc/DSDT.numamem | Bin 5071 -> 6029 bytes tests/data/acpi/pc/DSDT.roothp | Bin 5261 -> 6324 bytes tests/data/acpi/q35/DSDT | Bin 7801 -> 7863 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9126 -> 9188 bytes tests/data/acpi/q35/DSDT.bridge | Bin 7819 -> 7911 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8265 -> 8327 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9455 -> 9517 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 7876 -> 7938 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9160 -> 9222 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 8932 -> 9024 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7807 -> 7869 bytes tests/data/acpi/q35/DSDT.tis | Bin 8407 -> 8468 bytes 31 files changed, 197 insertions(+), 5 deletions(-)Signature · 1 line
2.27.0
Quoted 39 lines · On Sun, 17 Jan 2021 05:59:18 -0500 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 32 lines · Igor Mammedov
Quoted 22 lines · On Wed, 13 Jan 2021 07:09:56 -0500 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
Series implements support for 'onboard' naming scheme for network interfaces (1), which is based on PCI firmware spec and lets user to explicitly specify index that will be used by guest to name network interface, ex:
Quoted 8 lines
-device e1000,acpi-index=33should make guest rename NIC name to 'eno33' where 'eno' is default prefix for this scheme.
Hope is that it will allow to simplify launching VMs from template disk images with different set VM configurations without need to reconfigure guest network intrfaces or risk of loosing network connectivity.
Questions:
the spec says:
Assignment of specific device names to multi-function devices installed in expansion slots, and/or PCI or PCI Express devices that are hot-added to expansion slots in operating system- environment would be handled in operating system-specific manner, and is not specified via this specification.Quoted 6 lines
Accordingly, link below says:
" Names incorporating Firmware/BIOS provided index numbers for on-board devices (example: eno1)"to what extend does guest assume the index is for on-board devices? it seems things work for fedora but how confident are we that this will keep working.
Quoted 5 lines
code itself is not limiting it to onboard devices in any way. (I can only speculate here, reason for calling it onboard is that on real hardware ACPI is mostly static tables and firmware provides an option to set index for only built-in NICs). Technically there is no reason to call in onboad though.
Quoted 3 lines
Well there's an smbios thing that I believe says onboard in the spec. Come to think of it that one actually applies to multifunction devices too.
Can you point to the specific place in the spec, pls?
Quoted 10 lines
Quoted 10 lines
I'd believe it should work with any distribution that uses recent enough systemd/udev (released starting from 2003).
Quoted 3 lines
Further, code seems to only look at the slot level. According to this, and according to the spec, this does not work with multifunction devices, does it?
Quoted 6 lines
Quoted 2 lines
we probably should disable it for multifunction devices, any suggestions how to detect those in QEMU?
QEMU_PCI_CAP_MULTIFUNCTION_BITNR?Enforcing this will help but can we make this self-documenting somehow?
what do you mean saying "to make it self-documenting somehow"?
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
The link you supplied lists another option:
"Names incorporating Firmware/BIOS provided PCI Express hotplug slot index numbers (example: ens1)" these are under management control already ...with it interface name continues to depend on PCI topology (and theoretically limited to PCI expess). That's becomes harder to consume as complexity grows (i.e. mgmt needs to keep NIC in the same place for which guest image was configured for). acpi-index doesn't impose such limitation.
Quoted 7 lines
Quoted 4 lines
In case of 1 NIC, it could be moved anywhere within PCI hierarchy and guest doesn't have to be reconfigured to account for new interface name (i.e without loosing network connectivity - that's the actual issue coming from upper layers that made me look into acpi-index approach).
Could you describe the issue in a bit more detail in the commit log pls?
sure
Quoted 10 lines
Quoted 10 lines
In another words acpi index is easier to consume for users above libvirt and frees mgmt hands in a way it could distribute PCI devices. Even better would be if guest image could carry index as metadata
Quoted 5 lines
Also if we ask users to supply the property on the slot then it seems that the property can be baked into ACPI when it's created instead of being loaded from host - we can avoid adding new registers, this seems preferable. Could someone from management side chime in on whether that is sufficient?
Quoted 8 lines
Quoted 3 lines
I did consider it (it would be simpler, but not much), however unless we disable PCI hotplug for affected slots it won't work. (unplug device from such slot and plug another in that place will still return boot time index.
Well it's interesting that you mention it. Let's say you remove a device then plug in a different index immediately ... Guest gets a wrong name temporarily, right?
Should we worry about that?
guest will get not a wrong name but rather name that user asked for. (i.e. NIC with old index could be moved to other slot and still keep its name)
Quoted 7 lines
Quoted 4 lines
That's why I ended up with hotplug variant.
I chose abusing existing PCI hotplug registers for it, but we can use a new range if that's preferred.
Would it work for multi-function devices though?
If yes that's a big advantage ...
Does ACPI hotplug work with multi-function devices (I thought not)? If not, I'd prefer explicitly disable new feature
for multi-function devices (the code is heavily based on ACPI hotplug infrastructure we already have).
(
in other words, I don't see immediate benefit in grabbing new registers )
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
More questions:
does all this affect windows guests at all?
I don't know (spec shows examples that reminded me about NIC naming which Windows use(s|d)). But I won't bet on it.
If I recall correctly, for e1000 NIC, it didn't made any difference in naming (pre-existing guest image).
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
where does the "acpi index" terminology come from? the pci firmware spec talks about "instance number", right?
it comes from linux kernel (that's how it's named in sysfs) and systemd/udev uses it. So I tried to avoid making up another one.
OTOH that's guest specific ... and does not seem to imply the limitations unless you look at the code ...
"instance number" looks to me too generic (it's fine in context of specific chapter in spec). While linux kernel's variant looks to me as as better option that fits the bill.
If you don't object, I'd prefer 'acpi-index'.
Quoted 54 lines
Quoted 53 lines
Quoted 53 lines
Quoted 51 lines
For more detailed description/examples see patches [3-4/5]
1)
https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/Git repo for testing:
https://github.com/imammedo/qemu/branches acpi-index-rfcIgor Mammedov (5):
acpi: addaml_to_decimalstring()andaml_call6()helpers
tests: acpi: temporary whitelist DSDT changes
pci: introduce apci-index property for PCI device
pci: acpi: add_DSMmethod to PCI devices
tests: acpi: update expected data filesinclude/hw/acpi/aml-build.h | 3 + include/hw/acpi/pci.h | 1 + include/hw/acpi/pcihp.h | 7 +- include/hw/pci/pci.h | 1 + tests/qtest/bios-tables-test-allowed-diff.h | 21 +++++ hw/acpi/aml-build.c | 28 +++++++ hw/acpi/pci.c | 84 ++++++++++++++++++++ hw/acpi/pcihp.c | 25 +++++- hw/i386/acpi-build.c | 31 +++++++- hw/pci/pci.c | 1 + tests/data/acpi/pc/DSDT | Bin 5065 -> 6023 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 6390 -> 7348 bytes tests/data/acpi/pc/DSDT.bridge | Bin 6924 -> 8689 bytes tests/data/acpi/pc/DSDT.cphp | Bin 5529 -> 6487 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 6719 -> 7677 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 5026 -> 5990 bytes tests/data/acpi/pc/DSDT.hpbrroot | Bin 3084 -> 3177 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 5137 -> 6095 bytes tests/data/acpi/pc/DSDT.memhp | Bin 6424 -> 7382 bytes tests/data/acpi/pc/DSDT.numamem | Bin 5071 -> 6029 bytes tests/data/acpi/pc/DSDT.roothp | Bin 5261 -> 6324 bytes tests/data/acpi/q35/DSDT | Bin 7801 -> 7863 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9126 -> 9188 bytes tests/data/acpi/q35/DSDT.bridge | Bin 7819 -> 7911 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8265 -> 8327 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9455 -> 9517 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 7876 -> 7938 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9160 -> 9222 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 8932 -> 9024 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7807 -> 7869 bytes tests/data/acpi/q35/DSDT.tis | Bin 8407 -> 8468 bytes 31 files changed, 197 insertions(+), 5 deletions(-)Signature · 1 line
2.27.0