I would like to create virtual machines with mast network interfaces. This is possible to by first creating a guest using virt-install, then modifying the domain XML.

Is there a way to do this from the command line? Naively starting with:

virt-install -w mcast ...

Results in:

ERROR    internal error: No <source> 'port' attribute specified with socket interface

The XML generated by the above looks like:

<interface type="mcast">
  <mac address="52:54:00:21:ec:7c"/>

...so it is indeed missing the source element. However, the obvious solution doesn't work:

virt-install -w mcast,source=

That results in the same XML.

Is there a way to make this work from the virt-install command line?


There may be a better answer out there, but what I've settled on is:

virt-install -r 512 -n myguest \
  --disk vol=default/centos-base.qcow2 --import \
  -w user -w mcast,model=virtio --print-xml |
awk '{print} /interface.*type="mcast"/ {print "<source address=\"\" port=\"8000\"/>"}' |
virsh create /dev/stdin

The above results in:

<interface type='mcast'>
  <source address='' port='8000'/>
  <model type='virtio'/>

While normally I would shudder at using awk to process XML, in this case the output from libvirt is very predictable.

| improve this answer | |
  • I've even used sed to hack libvirt XML in a similar manner. – Michael Hampton Mar 4 '16 at 2:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.