how-to use virt-install to connect at openvswitch bridge

how-to use virt-install to connect at openvswitch bridge post thumbnail image

Very simple question with an answer that is hard to find: how-to use virt-install to connect at openvswitch bridge.
I am using Centos version 7 as my KVM host.
After some testing and time searching. I got this. In a few words. Just add “virtualport_type=openvswitch” to your network settings.

After you have downloaded your qcow2 image (my case is centos7.qcow2 where I used guestfish to modify root password and avoid cloud_init), you can execute virt-install as follow.

virt-install -n testvm --vcpus 2 --ram 2048 --connect qemu:///system \
--disk path=./centos.qcow2,format=qcow2,bus=virtio,cache=none \
--network=bridge:external,model=virtio,virtualport_type=openvswitch \
--os-type=linux  --noautoconsole --vnc --os-variant=rhel7 \

If yo prefer to modify XML file for your VMs (or KVM domains), you can use the following example as a reference.

    <interface type='bridge'>
      <source bridge='bridge_a'/>
      <virtualport type='openvswitch'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x11' function='0x0'/>

If you are starting with KVM you can use the following commands:

  • See VM or domain list
virsh list
  • Get XML configuration from a VM called domain_name and save it into a file called domain_name.xml. Now you can edit the file and look for the section where you have the interface configuration.
virsh dumpxml domain_name > domain_name.xml
  • Create a VM from a XML file. You can destroy and undefine the previous one first . Caution here! the VM will stop working, try to do a gently shutdown instead
virsh destroy domain_name
virsh undefine domain_name
virsh create domain_name.xml

Sometimes I got issues with virtio and I use “rtl8139” instead.
If you don’t have virt-install uses:

yum -y install virt-install

See ya!

Leave a Reply

Related Post