2

I am trying to create a VM using the virt-install utility and while that is easy enough to do what I would like to be able to do is proving quite difficult.

I would like to be able to specify the domain/bus/slot/function of the ethernet interfaces that I am adding. I realize that I can use virsh edit after the domain is created to modify these settings from the defaults they are given but I was wondering if anyone knows whether or not it can be dome from the command line using the virt-install utility and if it can be done, do you know what the proper syntax is?

Thank you.

Shawn

Shawn  
  • 33
  • 6
  • I forgot to mention that my research to date has led me to the --controller deviec option but I can't seem to nail down the proper syntax. I am trying to add 14 NICs spread across 5 different pci slots. – Shawn   Feb 20 '17 at 21:36

1 Answers1

3

Yes, you can specify all those on the virt-install command line. Check virt-install --network=? for a complete list of what you can specify. These correspond to the attributes set in XML.

For instance, if your <interface> looks like this:

    <interface type='bridge'>
      <mac address='52:54:00:c2:de:ce'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </interface>

You can specify it like:

virt-install ... -network bridge=br0,model=virtio,mac=52:54:00:c2:de:ce,address.type=pci,address.domain=0,address.bus=1,address.slot=0,address.function=0 ...

You can also, instead of doing an installation, use --print-xml to get the generated XML. Then you can customize this to your liking and automate many installations directly without going through virt-install.

       --print-xml [STEP]
           Print the generated XML of the guest, instead of defining it. By
           default this WILL do storage creation (can be disabled with
           --dry-run). This option implies --quiet.

           If the VM install has multiple phases, by default this will print
           all generated XML. If you want to print a particular step, use
           --print-xml 2 (for the second phase XML).
Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • Thanks Michael. I had tried something similar to that but I receive errors such as the following: ERROR Error in network device parameters: Unknown options ['address.domain', 'address.slot', 'address.bus', 'address.type', 'address.function'] I suspect that it is due to my version of virt-install. I am running 0.600. Thank you very much. – Shawn   Feb 20 '17 at 23:26
  • @Shawn  That's way too old. Looks like you have Ubuntu 12.04 LTS. Time to update to something current. It goes out of support shortly anyway. – Michael Hampton Feb 20 '17 at 23:38
  • Thank you very much. I'm going to get started on that right now. – Shawn   Feb 21 '17 at 00:21
  • Upgraded to virt-install 1.4.0-2 and it works exactly as you described. Thank you very much once again. – Shawn   Feb 21 '17 at 04:28