1 2 Previous Next 15 Replies Latest reply on Aug 19, 2019 2:28 AM by LucD

    Unable to add SRIOV adapter

    jayant1212 Novice

      Hi

      I am not able to add SRIOV adapter. Can you help me debug my code:

       

      Foreach ($VM in ($vmlist)) {

          Write-host $VM

          $spec   = New-Object VMware.Vim.VirtualMachineConfigSpec

          $dev    = New-Object Vmware.Vim.VirtualDeviceConfigSpec

          $dev.Operation  = 'add'

       

       

          $dev.Device                   = New-Object VMware.Vim.VirtualSriovEthernetCard

          $dev.Device.SriovBacking      = New-Object VMware.Vim.VirtualSriovEthernetCardSriovBackingInfo

          $pciBackingInfo = New-Object VMware.Vim.VirtualPCIPassthroughDeviceBackingInfo

       

       

          $pciBackingInfo.deviceName  = "sriov11"

          $pciBackingInfo.deviceId    = "0"

          $pciBackingInfo.vendorId    = "0"

          $pciBackingInfo.systemId    = "BYPASS"

          $pciBackingInfo.id          = "00000:000:00.00"

       

       

          $dev.Device.SriovBacking.physicalFunctionBacking = $pciBackingInfo

       

       

          $spec.DeviceChange += $dev

       

       

          $VM.ExtensionData.ReconfigVM($spec)

          break

      }

       

      I am getting the following error:

      Exception calling "ReconfigVM" with "1" argument(s): "Invalid configuration for device '0'."

      At /var/software/esxi_expts_powercli/sriovvm.ps1:67 char:5

      +     $VM.ExtensionData.ReconfigVM($spec)

      +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

      + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

      + FullyQualifiedErrorId : VimException

        • 1. Re: Unable to add SRIOV adapter
          LucD Guru
          User ModeratorsvExpertCommunity Warriors

          Can't really test since I don't have a SR-IOV card in my lab, but the Key field is normally a required property.

          Try adding, use a negative number to ensure you are not using an existing key.

           

             $dev.Device.Key = -1

           

          • 2. Re: Unable to add SRIOV adapter
            jayant1212 Novice

            Hi LucD

            It didn't help. The device in question VMware.Vim.VirtualSriovEthernetCard doesn't have that attribute.

            Do you know anyone who has been able to achieve this?

             

            The experiment attempted below doesn't work either:

            PowerCLI and SRIOV NICs?

             

            Regards

            Jayant

            • 3. Re: Unable to add SRIOV adapter
              LucD Guru
              vExpertUser ModeratorsCommunity Warriors

              No, I'm afraid not.

               

              I'm not sure your claim "doesn't have that attribute" is correct.

              Every VirtualDevice has the Key property.
              And all devices are derived from VirtualDevice.

              • 4. Re: Unable to add SRIOV adapter
                jayant1212 Novice

                Hi Luc

                This is the error that I saw:

                The property 'key' cannot be found on this object. Verify that the property exists and can be set.

                At /var/software/esxi_expts_powercli/sriovvm.ps1:51 char:5

                +     $dev.Device.key = -1

                +     ~~~~~~~~~~~~~~~~~~~~

                + CategoryInfo          : InvalidOperation: (:) [], RuntimeException

                + FullyQualifiedErrorId : PropertyNotFound

                 

                 

                Exception calling "ReconfigVM" with "1" argument(s): "Invalid configuration for device '0'."

                At /var/software/esxi_expts_powercli/sriovvm.ps1:68 char:5

                +     $VM.ExtensionData.ReconfigVM($spec)

                +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

                + FullyQualifiedErrorId : VimException

                 

                Regards

                Jayant

                • 5. Re: Unable to add SRIOV adapter
                  LucD Guru
                  Community WarriorsvExpertUser Moderators

                  Not sure where you added that line, but seems to be working for me.

                   

                  Foreach ($VM in ($vmlist)) {

                     Write-host $VM

                     $spec   = New-Object VMware.Vim.VirtualMachineConfigSpec

                     $dev   = New-Object Vmware.Vim.VirtualDeviceConfigSpec

                     $dev.Operation  = 'add'


                     $dev.Device   = New-Object VMware.Vim.VirtualSriovEthernetCard

                     $dev.Device.Key = -1

                     $dev.Device.SriovBacking   = New-Object VMware.Vim.VirtualSriovEthernetCardSriovBackingInfo

                     $pciBackingInfo = New-Object VMware.Vim.VirtualPCIPassthroughDeviceBackingInfo

                     $pciBackingInfo.deviceName  = "sriov11"

                     $pciBackingInfo.deviceId   = "0"

                     $pciBackingInfo.vendorId   = "0"

                     $pciBackingInfo.systemId   = "BYPASS"

                     $pciBackingInfo.id   = "00000:000:00.00"


                     $dev.Device.SriovBacking.physicalFunctionBacking = $pciBackingInfo

                     $spec.DeviceChange += $dev

                     $VM.ExtensionData.ReconfigVM($spec)

                  }

                  • 6. Re: Unable to add SRIOV adapter
                    jayant1212 Novice

                    Hi Luc

                    Sorry, that was my bad. I think I used it wrongly. However, I am still at a loss of how to achieve this.

                    I am seeing that some option maybe available if I use a PCi-passthrough configuration for SRIOV. I was hoping you could help me with that in the meantime.

                     

                    $pt         =  New-Object VMware.Vim.PciPassthroughDevice

                    This is not working.

                    New-Object : Cannot find type [VMware.Vim.PciPassthroughDevice]: verify that the assembly containing this type is loaded.

                    At /var/software/esxi_expts_powercli/passthru.ps1:37 char:20

                    +     $pt         =  New-Object VMware.Vim.PciPassthroughDevice

                    +                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                    + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException

                    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

                     

                    Any idea about this one?

                     

                    Thanks

                    Jayant

                    • 7. Re: Unable to add SRIOV adapter
                      LucD Guru
                      vExpertCommunity WarriorsUser Moderators

                      That should be.

                       

                      New-Object -TypeName VMware.Vim.VirtualPCIPassthrough

                      • 8. Re: Unable to add SRIOV adapter
                        jayant1212 Novice

                        Hi Luc

                        I have figured out PCI passthrough part at least. I am able to change the property of a pass through capable device and then reboot it to make it working.

                         

                        For SRIOV, the below command works to attach the networkadapter.

                        New-NetworkAdapter -VM $VM  -NetworkName "PG6" -WakeOnLan -StartConnected -Type SriovEthernetCard

                         

                        However, the VM doesn't start after using the above command and complains of bad configuration.

                         

                        At the same time, if a network adapter is added from GUI, the VM starts.

                         

                        Can you help me in this regard?

                        • 9. Re: Unable to add SRIOV adapter
                          LucD Guru
                          vExpertCommunity WarriorsUser Moderators

                          I'm afraid not.
                          I don't have that HW available, so I can't really test anything.

                           

                          If you are on vSphere 6.7U1 (or higher), you could try to capture your actions in the Web Client via CodeCapture.

                          That might show you how the Web Client does it.

                          • 10. Re: Unable to add SRIOV adapter
                            jayant1212 Novice

                            Hi

                            I have installed this one update-from-esxi6.7-6.7_update02

                            I will try CodeCapture with this. There is an example here: Introducing Code Capture - VMware PowerCLI Blog - VMware Blogs

                            Hope this will suffice, if not, please share with me something that you know to be working perfectly fine

                             

                            Also, note the environment that I am using. This is normal web login with ESXi host. Will this support code capture?

                             

                            Thanks

                            Jayant

                            • 11. Re: Unable to add SRIOV adapter
                              LucD Guru
                              User ModeratorsCommunity WarriorsvExpert

                              No, I'm afraid you will need a vCenter connection.

                              • 12. Re: Unable to add SRIOV adapter
                                LucD Guru
                                Community WarriorsUser ModeratorsvExpert

                                Btw, which PowerCLI version are you using?

                                In PowerCLI 11.3.0 the SriovEthernetCard Type was added to the New-NetworkAdapter cmdlet.

                                • 13. Re: Unable to add SRIOV adapter
                                  jayant1212 Novice

                                  Hi Luc

                                  I am using the same. And I have tried that. After using that option, the VM doesn't power on for me. I had highlighted this in my previous reply as well.

                                   

                                  What does work is keeping a backup of my SRIOV vmx configuration and keeping a backup of non-SRIOV vmx file and switching between those. I am gonna try a few things out and see the behavior

                                   

                                  Regards

                                  Jayant

                                  • 14. Re: Unable to add SRIOV adapter
                                    jayant1212 Novice

                                    Hi Luc

                                    I am happy to inform that the command actually works. I am new to powershell and I had a bug in my code where it wasn't applying the interface properties on the VM correctly.

                                    I have fixed the code and now I can see that the VM boots up.

                                     

                                    The command is: $newnet = New-NetworkAdapter -VM $myvm1 -NetworkName <pg_name> -WakeOnLan -StartConnected -Type SriovEthernetCard

                                     

                                    However, this command has its caveats. While it does allow you to attach a SRIOV network adapter, it offers no control whatsoever on the base physical function from which the virtual function is chosen to attach to the network. This control is also desirable.

                                    Once the interface is created, it maybe possible to update that information before powering on the VM.

                                     

                                    Nevertheless, I will mark your answer as correct and close this case and raise another one if I need any further discussions.

                                     

                                    Thanks for all the brainstorming

                                    Jayant

                                    1 2 Previous Next