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?
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
--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).
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.