Skip to content

Commit

Permalink
fix: support for sr-iov passthrough virtual machine network adapters
Browse files Browse the repository at this point in the history
Signed-off-by: Stoyan Zhelyazkov <stoyan.zhelyazkov@broadcom.com>
  • Loading branch information
spacegospod authored Feb 15, 2024
1 parent 8370be8 commit af161f8
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 296 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,15 @@ func computeDevAddr(device types.BaseVirtualDevice, ctlr types.BaseVirtualContro
if err != nil {
return "", err
}

un := -1
if vd.UnitNumber != nil {
un = int(structure.DeRef(vd.UnitNumber).(int32))
}
parts := []string{
ctype,
strconv.Itoa(int(vc.BusNumber)),
strconv.Itoa(int(structure.DeRef(vd.UnitNumber).(int32))),
strconv.Itoa(un),
}
return strings.Join(parts, ":"), nil
}
Expand Down Expand Up @@ -469,7 +474,7 @@ func (r *Subresource) FindVirtualDeviceByAddr(l object.VirtualDeviceList) (types
dsf := findVirtualDeviceInListDeviceSelectFunc(ckey, du)
devices := l.Select(dsf)
if len(devices) != 1 {
return nil, fmt.Errorf("invalid device result - %d results returned (expected 1): controller key %q, disk number: %d", len(devices), ckey, du)
return nil, fmt.Errorf("invalid device result - %d results returned (expected 1): controller key %q, device number: %d", len(devices), ckey, du)
}
device := devices[0]
log.Printf("[DEBUG] FindVirtualDevice: Device found: %s", l.Name(device))
Expand Down
Loading

0 comments on commit af161f8

Please # to comment.