aboutsummaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorDave Wallace <dwallacelf@gmail.com>2017-09-25 16:12:16 -0400
committerFlorin Coras <florin.coras@gmail.com>2017-09-25 22:09:19 +0000
commitd4c623eea44ed779b044edb706858044300ccb44 (patch)
tree7f9e691d7f0e0f541a108fe6270e2d230b25e355 /extras
parent3d67449de523521a9bdbcd2e3a092ffc0e2281f7 (diff)
Vagrant fails if Vagrantfile is a symlink on Windows 10.
- Revert Vagrantfile symlink to the default - Update README and env.sh Change-Id: Ib1a557b897e0217b162c31118a4c265769dd1760 Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Diffstat (limited to 'extras')
-rw-r--r--extras/vagrant/README23
-rw-r--r--[l---------]extras/vagrant/Vagrantfile112
-rw-r--r--extras/vagrant/Vagrantfile.default111
-rw-r--r--extras/vagrant/env.sh2
4 files changed, 131 insertions, 117 deletions
diff --git a/extras/vagrant/README b/extras/vagrant/README
index 238c90ce99c..4b7c7aa1f36 100644
--- a/extras/vagrant/README
+++ b/extras/vagrant/README
@@ -4,21 +4,21 @@ This is a vagrant environment for VPP.
VPP currently works under Linux and has support for:
-- Ubuntu 14.04, Ubuntu 16.04 and Centos7.2
+- Ubuntu 16.04 and Centos7.2
The VM builds VPP from source which can be located at /vpp
VM PARTICULARS:
This vagrant environment creates a VM based on environment variables found in ./env.sh
-To use, edit env.sh then
+To customize the vm for your use case, edit env.sh then
source ./env.sh
vagrant up
By default, the VM created is/has:
-- Ubuntu 14.04
+- Ubuntu 16.04
- 2 vCPUs
- 4G of RAM
-- 2 NICs (1 x NAT - host access, 1 x VPP DPDK enabled)
+- 3 NICs (1 x NAT - host access, 2 x VPP DPDK enabled)
PROVIDERS:
@@ -26,3 +26,18 @@ Supported vagrant providers are:
- Virtualbox, VMware Fusion/Workstation, Libvirt
+ALTERNATE CONFIGURATIONS
+
+The following Vagrantfiles provide alternate configurations for specific testing purposes. To use them,
+
+1. Copy the desired configuration to Vagrantfile
+2. Run "vagrant up"
+3. vagrant ssh <vm name>
+
+When testing is complete
+4. Run "vagrant destroy" to stop the VM's and delete files.
+5. Run "git checkout -- Vagrantfile" to restore the default configuration
+
+Available Vagrantfiles:
+
+Vagrantfile.vcl_test - Create two vm's for multi-host VppCommLib testing
diff --git a/extras/vagrant/Vagrantfile b/extras/vagrant/Vagrantfile
index a0bc225254d..8d6d02a6370 120000..100644
--- a/extras/vagrant/Vagrantfile
+++ b/extras/vagrant/Vagrantfile
@@ -1 +1,111 @@
-Vagrantfile.default \ No newline at end of file
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+Vagrant.configure(2) do |config|
+
+ # Pick the right distro and bootstrap, default is ubuntu1604
+ distro = ( ENV['VPP_VAGRANT_DISTRO'] || "ubuntu1604")
+ if distro == 'centos7'
+ config.vm.box = "puppetlabs/centos-7.2-64-nocm"
+ config.ssh.insert_key = false
+ else
+ config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
+ end
+ config.vm.box_check_update = false
+
+ config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"update.sh")
+ config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"build.sh"), :args => "/vpp vagrant"
+
+ post_build = ( ENV['VPP_VAGRANT_POST_BUILD'] )
+ if post_build == "test"
+ config.vm.provision "shell", inline: "echo Testing VPP; cd /vpp; make test"
+ elsif post_build == "install"
+ config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"install.sh"), :args => "/vpp"
+ config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"clearinterfaces.sh")
+ config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"run.sh")
+ end
+
+ # Add .gnupg dir in so folks can sign patches
+ # Note, as gnupg puts socket files in that dir, we have
+ # to be cautious and make sure we are dealing with a plain file
+ homedir = File.expand_path("~/")
+ Dir["#{homedir}/.gnupg/**/*"].each do |fname|
+ if File.file?(fname)
+ destname = fname.sub(Regexp.escape("#{homedir}/"),'')
+ config.vm.provision "file", source: fname, destination: destname
+ end
+ end
+
+ # Copy in the .gitconfig if it exists
+ if File.file?(File.expand_path("~/.gitconfig"))
+ config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig"
+ end
+
+ # vagrant-cachier caches apt/yum etc to speed subsequent
+ # vagrant up
+ # to enable, run
+ # vagrant plugin install vagrant-cachier
+ #
+ if Vagrant.has_plugin?("vagrant-cachier")
+ config.cache.scope = :box
+ end
+
+ # Define some physical ports for your VMs to be used by DPDK
+ nics = (ENV['VPP_VAGRANT_NICS'] || "2").to_i(10)
+ for i in 1..nics
+ config.vm.network "private_network", type: "dhcp"
+ end
+
+ # use http proxy if avaiable
+ if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
+ config.proxy.http = ENV['http_proxy']
+ config.proxy.https = ENV['https_proxy']
+ config.proxy.no_proxy = "localhost,127.0.0.1"
+ end
+
+ vmcpu=(ENV['VPP_VAGRANT_VMCPU'] || 2)
+ vmram=(ENV['VPP_VAGRANT_VMRAM'] || 4096)
+
+ config.ssh.forward_agent = true
+ config.ssh.forward_x11 = true
+
+ config.vm.provider "virtualbox" do |vb|
+ vb.customize ["modifyvm", :id, "--ioapic", "on"]
+ vb.memory = "#{vmram}"
+ vb.cpus = "#{vmcpu}"
+
+ # rsync the vpp directory if provision hasn't happened yet
+ unless File.exist? (".vagrant/machines/default/virtualbox/action_provision")
+ config.vm.synced_folder "../../", "/vpp", type: "rsync",
+ rsync__auto: false,
+ rsync__exclude: [
+ "build-root/build*/",
+ "build-root/install*/",
+ "build-root/images*/",
+ "build-root/*.deb",
+ "build-root/*.rpm",
+ "build-root/*.changes",
+ "build-root/python",
+ "build-root/deb/debian/*.dkms",
+ "build-root/deb/debian/*.install",
+ "build-root/deb/debian/changes",
+ "build-root/tools"]
+ end
+
+ #support for the SSE4.x instruction is required in some versions of VB.
+ vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.1", "1"]
+ vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.2", "1"]
+ end
+ config.vm.provider "vmware_fusion" do |fusion,override|
+ fusion.vmx["memsize"] = "#{vmram}"
+ fusion.vmx["numvcpus"] = "#{vmcpu}"
+ end
+ config.vm.provider "libvirt" do |lv|
+ lv.memory = "#{vmram}"
+ lv.cpus = "#{vmcpu}"
+ end
+ config.vm.provider "vmware_workstation" do |vws,override|
+ vws.vmx["memsize"] = "#{vmram}"
+ vws.vmx["numvcpus"] = "#{vmcpu}"
+ end
+end
diff --git a/extras/vagrant/Vagrantfile.default b/extras/vagrant/Vagrantfile.default
deleted file mode 100644
index 8d6d02a6370..00000000000
--- a/extras/vagrant/Vagrantfile.default
+++ /dev/null
@@ -1,111 +0,0 @@
-# -*- mode: ruby -*-
-# vi: set ft=ruby :
-
-Vagrant.configure(2) do |config|
-
- # Pick the right distro and bootstrap, default is ubuntu1604
- distro = ( ENV['VPP_VAGRANT_DISTRO'] || "ubuntu1604")
- if distro == 'centos7'
- config.vm.box = "puppetlabs/centos-7.2-64-nocm"
- config.ssh.insert_key = false
- else
- config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
- end
- config.vm.box_check_update = false
-
- config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"update.sh")
- config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"build.sh"), :args => "/vpp vagrant"
-
- post_build = ( ENV['VPP_VAGRANT_POST_BUILD'] )
- if post_build == "test"
- config.vm.provision "shell", inline: "echo Testing VPP; cd /vpp; make test"
- elsif post_build == "install"
- config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"install.sh"), :args => "/vpp"
- config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"clearinterfaces.sh")
- config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"run.sh")
- end
-
- # Add .gnupg dir in so folks can sign patches
- # Note, as gnupg puts socket files in that dir, we have
- # to be cautious and make sure we are dealing with a plain file
- homedir = File.expand_path("~/")
- Dir["#{homedir}/.gnupg/**/*"].each do |fname|
- if File.file?(fname)
- destname = fname.sub(Regexp.escape("#{homedir}/"),'')
- config.vm.provision "file", source: fname, destination: destname
- end
- end
-
- # Copy in the .gitconfig if it exists
- if File.file?(File.expand_path("~/.gitconfig"))
- config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig"
- end
-
- # vagrant-cachier caches apt/yum etc to speed subsequent
- # vagrant up
- # to enable, run
- # vagrant plugin install vagrant-cachier
- #
- if Vagrant.has_plugin?("vagrant-cachier")
- config.cache.scope = :box
- end
-
- # Define some physical ports for your VMs to be used by DPDK
- nics = (ENV['VPP_VAGRANT_NICS'] || "2").to_i(10)
- for i in 1..nics
- config.vm.network "private_network", type: "dhcp"
- end
-
- # use http proxy if avaiable
- if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
- config.proxy.http = ENV['http_proxy']
- config.proxy.https = ENV['https_proxy']
- config.proxy.no_proxy = "localhost,127.0.0.1"
- end
-
- vmcpu=(ENV['VPP_VAGRANT_VMCPU'] || 2)
- vmram=(ENV['VPP_VAGRANT_VMRAM'] || 4096)
-
- config.ssh.forward_agent = true
- config.ssh.forward_x11 = true
-
- config.vm.provider "virtualbox" do |vb|
- vb.customize ["modifyvm", :id, "--ioapic", "on"]
- vb.memory = "#{vmram}"
- vb.cpus = "#{vmcpu}"
-
- # rsync the vpp directory if provision hasn't happened yet
- unless File.exist? (".vagrant/machines/default/virtualbox/action_provision")
- config.vm.synced_folder "../../", "/vpp", type: "rsync",
- rsync__auto: false,
- rsync__exclude: [
- "build-root/build*/",
- "build-root/install*/",
- "build-root/images*/",
- "build-root/*.deb",
- "build-root/*.rpm",
- "build-root/*.changes",
- "build-root/python",
- "build-root/deb/debian/*.dkms",
- "build-root/deb/debian/*.install",
- "build-root/deb/debian/changes",
- "build-root/tools"]
- end
-
- #support for the SSE4.x instruction is required in some versions of VB.
- vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.1", "1"]
- vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.2", "1"]
- end
- config.vm.provider "vmware_fusion" do |fusion,override|
- fusion.vmx["memsize"] = "#{vmram}"
- fusion.vmx["numvcpus"] = "#{vmcpu}"
- end
- config.vm.provider "libvirt" do |lv|
- lv.memory = "#{vmram}"
- lv.cpus = "#{vmcpu}"
- end
- config.vm.provider "vmware_workstation" do |vws,override|
- vws.vmx["memsize"] = "#{vmram}"
- vws.vmx["numvcpus"] = "#{vmcpu}"
- end
-end
diff --git a/extras/vagrant/env.sh b/extras/vagrant/env.sh
index f0edfd884ed..bd329ea7ce9 100644
--- a/extras/vagrant/env.sh
+++ b/extras/vagrant/env.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-export VPP_VAGRANT_DISTRO="ubuntu1404"
+export VPP_VAGRANT_DISTRO="ubuntu1604"
export VPP_VAGRANT_NICS=2
export VPP_VAGRANT_VMCPU=4
export VPP_VAGRANT_VMRAM=4096
y queues * * Copyright (c) 2009 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *------------------------------------------------------------------ */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #include <vppinfra/mem.h> #include <vppinfra/format.h> #include <vppinfra/cache.h> #include <svm/queue.h> #include <vppinfra/time.h> #include <signal.h> /* * svm_queue_init * * nels = number of elements on the queue * elsize = element size, presumably 4 and cacheline-size will * be popular choices. * pid = consumer pid * * The idea is to call this function in the queue consumer, * and e-mail the queue pointer to the producer(s). * * The vpp process / main thread allocates one of these * at startup; its main input queue. The vpp main input queue * has a pointer to it in the shared memory segment header. * * You probably want to be on an svm data heap before calling this * function. */ svm_queue_t * svm_queue_init (int nels, int elsize, int consumer_pid, int signal_when_queue_non_empty) { svm_queue_t *q; pthread_mutexattr_t attr; pthread_condattr_t cattr; q = clib_mem_alloc_aligned (sizeof (svm_queue_t) + nels * elsize, CLIB_CACHE_LINE_BYTES); memset (q, 0, sizeof (*q)); q->elsize = elsize; q->maxsize = nels; q->consumer_pid = consumer_pid; q->signal_when_queue_non_empty = signal_when_queue_non_empty; memset (&attr, 0, sizeof (attr)); memset (&cattr, 0, sizeof (cattr)); if (pthread_mutexattr_init (&attr)) clib_unix_warning ("mutexattr_init"); if (pthread_mutexattr_setpshared (&attr, PTHREAD_PROCESS_SHARED)) clib_unix_warning ("pthread_mutexattr_setpshared"); if (pthread_mutex_init (&q->mutex, &attr)) clib_unix_warning ("mutex_init"); if (pthread_mutexattr_destroy (&attr)) clib_unix_warning ("mutexattr_destroy"); if (pthread_condattr_init (&cattr)) clib_unix_warning ("condattr_init"); /* prints funny-looking messages in the Linux target */ if (pthread_condattr_setpshared (&cattr, PTHREAD_PROCESS_SHARED)) clib_unix_warning ("condattr_setpshared"); if (pthread_cond_init (&q->condvar, &cattr)) clib_unix_warning ("cond_init1"); if (pthread_condattr_destroy (&cattr)) clib_unix_warning ("cond_init2"); return (q); } /* * svm_queue_free */ void svm_queue_free (svm_queue_t * q) { (void) pthread_mutex_destroy (&q->mutex); (void) pthread_cond_destroy (&q->condvar); clib_mem_free (q); } void svm_queue_lock (svm_queue_t * q) { pthread_mutex_lock (&q->mutex); } void svm_queue_unlock (svm_queue_t * q) { pthread_mutex_unlock (&q->mutex); } int svm_queue_is_full (svm_queue_t * q) { return q->cursize == q->maxsize; } /* * svm_queue_add_nolock */ int svm_queue_add_nolock (svm_queue_t * q, u8 * elem) { i8 *tailp; int need_broadcast = 0; if (PREDICT_FALSE (q->cursize == q->maxsize)) { while (q->cursize == q->maxsize) { (void) pthread_cond_wait (&q->condvar, &q->mutex); } } tailp = (i8 *) (&q->data[0] + q->elsize * q->tail); clib_memcpy (tailp, elem, q->elsize); q->tail++; q->cursize++; need_broadcast = (q->cursize == 1); if (q->tail == q->maxsize) q->tail = 0; if (need_broadcast) { (void) pthread_cond_broadcast (&q->condvar); if (q->signal_when_queue_non_empty) kill (q->consumer_pid, q->signal_when_queue_non_empty); } return 0; } int svm_queue_add_raw (svm_queue_t * q, u8 * elem) { i8 *tailp; if (PREDICT_FALSE (q->cursize == q->maxsize)) { while (q->cursize == q->maxsize) ; } tailp = (i8 *) (&q->data[0] + q->elsize * q->tail); clib_memcpy (tailp, elem, q->elsize); q->tail++; q->cursize++; if (q->tail == q->maxsize) q->tail = 0; return 0; } /* * svm_queue_add */ int svm_queue_add (svm_queue_t * q, u8 * elem, int nowait) { i8 *tailp; int need_broadcast = 0; if (nowait) { /* zero on success */ if (pthread_mutex_trylock (&q->mutex)) { return (-1); } } else pthread_mutex_lock (&q->mutex); if (PREDICT_FALSE (q->cursize == q->maxsize)) { if (nowait) { pthread_mutex_unlock (&q->mutex); return (-2); } while (q->cursize == q->maxsize) { (void) pthread_cond_wait (&q->condvar, &q->mutex); } } tailp = (i8 *) (&q->data[0] + q->elsize * q->tail); clib_memcpy (tailp, elem, q->elsize); q->tail++; q->cursize++; need_broadcast = (q->cursize == 1); if (q->tail == q->maxsize) q->tail = 0; if (need_broadcast) { (void) pthread_cond_broadcast (&q->condvar); if (q->signal_when_queue_non_empty) kill (q->consumer_pid, q->signal_when_queue_non_empty); } pthread_mutex_unlock (&q->mutex); return 0; } /* * svm_queue_add2 */ int svm_queue_add2 (svm_queue_t * q, u8 * elem, u8 * elem2, int nowait) { i8 *tailp; int need_broadcast = 0; if (nowait) { /* zero on success */ if (pthread_mutex_trylock (&q->mutex)) { return (-1); } } else pthread_mutex_lock (&q->mutex); if (PREDICT_FALSE (q->cursize + 1 == q->maxsize)) { if (nowait) { pthread_mutex_unlock (&q->mutex); return (-2); } while (q->cursize + 1 == q->maxsize) { (void) pthread_cond_wait (&q->condvar, &q->mutex); } } tailp = (i8 *) (&q->data[0] + q->elsize * q->tail); clib_memcpy (tailp, elem, q->elsize); q->tail++; q->cursize++; if (q->tail == q->maxsize) q->tail = 0; need_broadcast = (q->cursize == 1); tailp = (i8 *) (&q->data[0] + q->elsize * q->tail); clib_memcpy (tailp, elem2, q->elsize); q->tail++; q->cursize++; if (q->tail == q->maxsize) q->tail = 0; if (need_broadcast) { (void) pthread_cond_broadcast (&q->condvar); if (q->signal_when_queue_non_empty) kill (q->consumer_pid, q->signal_when_queue_non_empty); } pthread_mutex_unlock (&q->mutex); return 0; } /* * svm_queue_sub */ int svm_queue_sub (svm_queue_t * q, u8 * elem, svm_q_conditional_wait_t cond, u32 time) { i8 *headp; int need_broadcast = 0; int rc = 0; if (cond == SVM_Q_NOWAIT) { /* zero on success */ if (pthread_mutex_trylock (&q->mutex)) { return (-1); } } else pthread_mutex_lock (&q->mutex); if (PREDICT_FALSE (q->cursize == 0)) { if (cond == SVM_Q_NOWAIT) { pthread_mutex_unlock (&q->mutex); return (-2); } else if (cond == SVM_Q_TIMEDWAIT) { struct timespec ts; ts.tv_sec = unix_time_now () + time; ts.tv_nsec = 0; while (q->cursize == 0 && rc == 0) { rc = pthread_cond_timedwait (&q->condvar, &q->mutex, &ts); } if (rc == ETIMEDOUT) { pthread_mutex_unlock (&q->mutex); return ETIMEDOUT; } } else { while (q->cursize == 0) { (void) pthread_cond_wait (&q->condvar, &q->mutex); } } } headp = (i8 *) (&q->data[0] + q->elsize * q->head); clib_memcpy (elem, headp, q->elsize); q->head++; /* $$$$ JFC shouldn't this be == 0? */ if (q->cursize == q->maxsize) need_broadcast = 1; q->cursize--; if (q->head == q->maxsize) q->head = 0; if (need_broadcast) (void) pthread_cond_broadcast (&q->condvar); pthread_mutex_unlock (&q->mutex); return 0; } int svm_queue_sub2 (svm_queue_t * q, u8 * elem) { int need_broadcast; i8 *headp; pthread_mutex_lock (&q->mutex); if (q->cursize == 0) { pthread_mutex_unlock (&q->mutex); return -1; } headp = (i8 *) (&q->data[0] + q->elsize * q->head); clib_memcpy (elem, headp, q->elsize); q->head++; need_broadcast = (q->cursize == q->maxsize / 2); q->cursize--; if (PREDICT_FALSE (q->head == q->maxsize)) q->head = 0; pthread_mutex_unlock (&q->mutex); if (need_broadcast) (void) pthread_cond_broadcast (&q->condvar); return 0; } int svm_queue_sub_raw (svm_queue_t * q, u8 * elem) { i8 *headp; if (PREDICT_FALSE (q->cursize == 0)) { while (q->cursize == 0) ; } headp = (i8 *) (&q->data[0] + q->elsize * q->head); clib_memcpy (elem, headp, q->elsize); q->head++; q->cursize--; if (q->head == q->maxsize) q->head = 0; return 0; } /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */