Skip to content

Commit 4e7a834

Browse files
committed
Address comments
1 parent 8d09790 commit 4e7a834

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

scripts/vm/hypervisor/kvm/gpudiscovery.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ for VM in "${VMS[@]}"; do
704704
# -- PCI hostdevs: use xmlstarlet to extract the full domain:bus:slot.func
705705
# for all PCI host devices. libvirt's <address> element may omit the domain
706706
# attribute, in which case we default to 0.
707-
while read -r dom bus slot func; do
707+
while IFS=: read -r dom bus slot func; do
708708
[[ -n "$bus" && -n "$slot" && -n "$func" ]] || continue
709709
[[ -n "$dom" ]] || dom="0"
710710
# Format to match lspci -D output (e.g., 0000:01:00.0) by padding with zeros
@@ -715,9 +715,9 @@ for VM in "${VMS[@]}"; do
715715
BDF="${dom_fmt}:${bus_fmt}:${slot_fmt}.${func_fmt}"
716716
pci_to_vm["$BDF"]="$VM"
717717
done < <(echo "$xml" | xmlstarlet sel -T -t -m "//hostdev[@type='pci']/source/address" \
718-
-v "substring-after(@domain, '0x')" -o " " \
719-
-v "substring-after(@bus, '0x')" -o " " \
720-
-v "substring-after(@slot, '0x')" -o " " \
718+
-v "substring-after(@domain, '0x')" -o ":" \
719+
-v "substring-after(@bus, '0x')" -o ":" \
720+
-v "substring-after(@slot, '0x')" -o ":" \
721721
-v "substring-after(@function, '0x')" -n 2>/dev/null || true)
722722

723723
# -- MDEV hostdevs: use xmlstarlet to extract UUIDs --
@@ -989,6 +989,8 @@ for LINE in "${LINES[@]}"; do
989989
if [[ ${#vlist[@]} -eq 0 && ${#flist[@]} -eq 0 ]]; then
990990
FP_ENABLED=1
991991
fi
992+
993+
# Sets global DOMAIN/BUS/SLOT/FUNC for JSON output below
992994
parse_pci_address "$PCI_ADDR"
993995

994996
# Emit JSON

0 commit comments

Comments
 (0)