Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Libvirt Multi VM Support #131

Closed
ssasso opened this issue Jan 7, 2022 · 3 comments
Closed

Libvirt Multi VM Support #131

ssasso opened this issue Jan 7, 2022 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@ssasso
Copy link
Collaborator

ssasso commented Jan 7, 2022

Following discussion in #124 we may want to support "Multi VM" nodes also on libvirt topologies (containerlab is already supporting it - thanks @jbemmel for pointing that out).
This could be useful to run vQFX and vMX in netsim-tools.

An example Vagrantfile for vQFX is the following one:

Vagrant.configure("2") do |config|

  # RE is also where the data ports are connected
  config.vm.define "re" do |re|
    re.vm.provider :libvirt do |domain|
      domain.management_network_mac = "08-4F-A9-00-00-01"
      domain.qemu_use_session = false
    end
    
    re.vm.box = "juniper/vqfx10k-re"
    re.vm.guest = :freebsd
    re.vm.boot_timeout = 360
    re.ssh.insert_key = false
    
    re.vm.synced_folder '.', '/vagrant', disabled: true
    
    re.vm.provider :libvirt do |domain|
      domain.cpus = 2
      domain.memory = 2048
      domain.nic_model_type = "virtio-net-pci"
    end
    
    # First Virtual Network, link to PFE
    re.vm.network :private_network,
                  :libvirt__tunnel_type => "udp",
                  :libvirt__tunnel_local_ip => "127.1.254.1",
                  :libvirt__tunnel_local_port => "10001",
                  :libvirt__tunnel_ip => "127.1.254.2",
                  :libvirt__tunnel_port => "10001",
                  :libvirt__iface_name => "vgif_re_1",
                  auto_config: false

    # Additional UNUSED PORT
    re.vm.network :private_network,
                  :libvirt__tunnel_type => "udp",
                  :libvirt__tunnel_local_ip => "127.1.254.1",
                  :libvirt__tunnel_local_port => "10099",
                  :libvirt__tunnel_ip => "127.1.254.2",
                  :libvirt__tunnel_port => "10099",
                  :libvirt__iface_name => "vgif_re_2",
                  auto_config: false

    # Dataplane Ports are here
    (1..5).each do |seg_id|
        re.vm.network :private_network,
                  :libvirt__tunnel_type => "udp",
                  :libvirt__tunnel_local_ip => "127.1.22.1",
                  :libvirt__tunnel_local_port => "1000#{seg_id}",
                  :libvirt__tunnel_ip => "127.1.22.2",
                  :libvirt__tunnel_port => "1000#{seg_id}",
                  :libvirt__iface_name => "vgif_re_dp#{seg_id}",
                  auto_config: false
    end
  end

  # PFE
  config.vm.define "pfe" do |pfe|
    pfe.vm.provider :libvirt do |domain|
      domain.qemu_use_session = false
    end
    
    pfe.vm.box = "juniper/vqfx10k-pfe"
    pfe.vm.guest = :freebsd
    pfe.vm.boot_timeout = 360
    pfe.ssh.insert_key = false
    pfe.ssh.username = "tc"
    
    pfe.vm.synced_folder '.', '/vagrant', disabled: true
    
    pfe.vm.provider :libvirt do |domain|
      domain.cpus = 2
      domain.memory = 2048
      domain.nic_model_type = "e1000"
    end
    
    # First Virtual Network, link to RE
    pfe.vm.network :private_network,
                  :libvirt__tunnel_type => "udp",
                  :libvirt__tunnel_local_ip => "127.1.254.2",
                  :libvirt__tunnel_local_port => "10001",
                  :libvirt__tunnel_ip => "127.1.254.1",
                  :libvirt__tunnel_port => "10001",
                  :libvirt__iface_name => "vgif_pfe_1",
                  auto_config: false
  end

end

Note: depending on the VM kind itself, the data ports are connected to the RE or to the PFE (i.e. vMX and vQFX have different behaviours)

@ipspace
Copy link
Owner

ipspace commented Jan 7, 2022

Create a proof-of-concept QDS in qfx branch:

  • Define PFE first (because it has no external links)
  • End VM definition, start new VM definition within the VM domain template
  • Add RE parameters
  • Vagrantfile.j2 will add MAC address and links

If it works, then I'll polish it to add a provider-specific parameter (ex: provider_template) meaning "for this VM execute a full-blown template that will do its own stuff", probably after #96.

Just in case: QDS == Quick and Dirty Solution

@ipspace ipspace added the enhancement New feature or request label Jan 9, 2022
@ipspace
Copy link
Owner

ipspace commented Dec 5, 2022

Forget about that QDS, aac8a03 adds support for "raw" Vagrantfile template -- a device-specific template that bypasses the standard way of configuring VMs. You could take the same vQFX setup, copy it into vqfx-raw.j2 and adapt it to use our templates for data-plane interfaces.

@ipspace
Copy link
Owner

ipspace commented Dec 22, 2022

The functionality is there if we ever need it, vMX is implemented as a container in #670 -- it requires multiple disks and that could get really messy with Vagrant boxes.

@ipspace ipspace closed this as completed Dec 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants