summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Gilligan <gilligan@vyatta.com>2011-08-12 17:27:21 -0700
committerBob Gilligan <gilligan@vyatta.com>2011-08-12 17:27:21 -0700
commit806e7fb314fc7f8723070bf51f0961590372f90c (patch)
tree864fa9fab6826ae1074f23fff55488f32b6b3f87
parentd891558527fdc077b8c0b37c24cb8b17a2ae7043 (diff)
parent4c880822e64eb22c0a91357b987ae096d848a84c (diff)
downloadvyatta-cfg-system-806e7fb314fc7f8723070bf51f0961590372f90c.tar.gz
vyatta-cfg-system-806e7fb314fc7f8723070bf51f0961590372f90c.zip
Merge branch 'napa' of http://git.vyatta.com/vyatta-cfg-system into napa
-rw-r--r--.frlog1
-rw-r--r--.gitignore1
-rw-r--r--Makefile.am2
-rw-r--r--debian/changelog59
-rw-r--r--debian/vyatta-cfg-system.postinst.in1
-rwxr-xr-xscripts/install/install-functions1
-rwxr-xr-xscripts/install/install-image-existing10
-rwxr-xr-xscripts/vyatta-interfaces.pl8
-rw-r--r--src/hypervisor_vendor.c193
9 files changed, 267 insertions, 9 deletions
diff --git a/.frlog b/.frlog
index 9a5a7c12..a644ec5b 100644
--- a/.frlog
+++ b/.frlog
@@ -1 +1,2 @@
Tue Dec 28 13:47:50 PST 2010: [new branch] at [debian/0.19.24]
+Thu Jul 7 20:47:43 PDT 2011: [new branch] at [debian/0.19.99]
diff --git a/.gitignore b/.gitignore
index 3c8b8c29..830bb7d1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,3 +28,4 @@ Makefile.in
Makefile
src/valid_address
src/local_ip
+src/hypervisor_vendor
diff --git a/Makefile.am b/Makefile.am
index 23bdc3a1..3a05c0a5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -76,9 +76,11 @@ sbin_SCRIPTS += scripts/vyatta-update-grub.pl
sbin_PROGRAMS = src/valid_address
sbin_PROGRAMS += src/local_ip
+sbin_PROGRAMS += src/hypervisor_vendor
src_valid_address = src/valid_address.c
src_local_ip = src/local_ip.c
+src_hypervisor_vendor = src/hypervisor_vendor.c
share_perl5_DATA = lib/Vyatta/Login/User.pm
share_perl5_DATA += lib/Vyatta/Login/RadiusServer.pm
diff --git a/debian/changelog b/debian/changelog
index 00a08119..95613688 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,62 @@
+vyatta-cfg-system (0.19.99+napa2) unstable; urgency=low
+
+ * Bugfix 7326: add /config/support directory by default
+
+ -- John Southworth <john.southworth@vyatta.com> Wed, 13 Jul 2011 15:49:50 -0500
+
+vyatta-cfg-system (0.19.99+napa1) unstable; urgency=low
+
+ * new branch
+
+ -- Deepti Kulkarni <deepti@vyatta.com> Thu, 07 Jul 2011 20:47:45 -0700
+
+vyatta-cfg-system (0.19.99) unstable; urgency=low
+
+ * Add more hypervisor detection logic
+
+ -- Stephen Hemminger <stephen.hemminger@vyatta.com> Wed, 06 Jul 2011 10:20:24 -0700
+
+vyatta-cfg-system (0.19.98) unstable; urgency=low
+
+ * Move the is_uniq_address function to Interface.pm
+
+ -- John Southworth <john.southworth@vyatta.com> Tue, 05 Jul 2011 16:21:46 -0500
+
+vyatta-cfg-system (0.19.97) unstable; urgency=low
+
+ * bugfix 6801: check to see if the same address is configured on
+ another interface in the working config before allowing an address
+ to be set on an interface, allows for swapping addresses in the same
+ commit
+
+ -- John Southworth <john.southworth@vyatta.com> Fri, 01 Jul 2011 17:32:25 -0700
+
+vyatta-cfg-system (0.19.96) unstable; urgency=low
+
+ * Make add system image use the new config directory for copying files
+
+ -- John Southworth <john.southworth@vyatta.com> Fri, 24 Jun 2011 17:56:26 -0500
+
+vyatta-cfg-system (0.19.95) unstable; urgency=low
+
+ * Add better hypervisor detect logic
+
+ -- Stephen Hemminger <stephen.hemminger@vyatta.com> Thu, 23 Jun 2011 16:26:27 -0700
+
+vyatta-cfg-system (0.19.94) unstable; urgency=low
+
+ * Revert "bonding: remove requirement of slaves existing before vif"
+ * Ignore new hypervisor_vendor binary
+
+ -- Stephen Hemminger <stephen.hemminger@vyatta.com> Thu, 16 Jun 2011 18:28:11 -0400
+
+vyatta-cfg-system (0.19.93) unstable; urgency=low
+
+ * bonding: remove requirement of slaves existing before vif
+ * Add utility to find hypervisor vendor
+
+ -- Stephen Hemminger <stephen.hemminger@vyatta.com> Thu, 16 Jun 2011 17:53:43 -0400
+
vyatta-cfg-system (0.19.92) unstable; urgency=low
* Bugfix 5856: Add username and password options.
diff --git a/debian/vyatta-cfg-system.postinst.in b/debian/vyatta-cfg-system.postinst.in
index 4648d29c..ac5618f5 100644
--- a/debian/vyatta-cfg-system.postinst.in
+++ b/debian/vyatta-cfg-system.postinst.in
@@ -170,6 +170,7 @@ mkdir -p /var/core
mkdir -p /opt/vyatta/etc/config/auth
mkdir -p /opt/vyatta/etc/config/scripts
mkdir -p /opt/vyatta/etc/config/user-data
+mkdir -p /opt/vyatta/etc/config/support
# create /opt/vyatta/etc/config/scripts/vyatta-postconfig-bootup.script
# this should be after 'mkdir -p /opt/vyatta/etc/config/scripts' above
diff --git a/scripts/install/install-functions b/scripts/install/install-functions
index 5670f82a..5e24a921 100755
--- a/scripts/install/install-functions
+++ b/scripts/install/install-functions
@@ -41,6 +41,7 @@ CD_SQUASH_ROOT=/mnt/cdsquash
# the vyatta config dir
VYATTA_CFG_DIR=${vyatta_sysconfdir}/config
+VYATTA_NEW_CFG_DIR=/config
# the floppy config dir
FD_CFG_DIR=/media/floppy/config
diff --git a/scripts/install/install-image-existing b/scripts/install/install-image-existing
index d75a62b6..7c75b35b 100755
--- a/scripts/install/install-image-existing
+++ b/scripts/install/install-image-existing
@@ -175,12 +175,12 @@ fi
# Check to make sure we have enough space to copy the config and data dirs...
#
space_avail=`df -k / | tail -1 | awk '{ print $4 }'`
-if [ -e $${VYATTA_CFG_DIR}/data ]; then
- space_needed_data=`du -s ${VYATTA_CFG_DIR}/data | awk '{ print $1 }'`
+if [ -e $${VYATTA_NEW_CFG_DIR}/data ]; then
+ space_needed_data=`du -s ${VYATTA_NEW_CFG_DIR}/data | awk '{ print $1 }'`
else
space_needed_data=0
fi
-space_needed_configdata=`du -s ${VYATTA_CFG_DIR} | awk '{ print $1 }'`
+space_needed_configdata=`du -s ${VYATTA_NEW_CFG_DIR} | awk '{ print $1 }'`
space_needed_config=$(($space_needed_configdata - $space_needed_data))
DEMO_MIGRATE_SCRIPT=/opt/vyatta/sbin/demo-to-vse.pl
@@ -194,9 +194,9 @@ if [ $space_avail -gt $space_needed_configdata ]; then
resp=$(get_response "Yes" "Yes No Y N")
if [ "$resp" == 'yes' ] || [ "$resp" == 'y' ]; then
echo 'Copying current configuration...'
- ndir=${INST_ROOT}/config
+ ndir=${INST_ROOT}/${VYATTA_NEW_CFG_DIR}
mkdir -p $ndir
- find $VYATTA_CFG_DIR -maxdepth 1 -mindepth 1 \
+ find $VYATTA_NEW_CFG_DIR -maxdepth 1 -mindepth 1 \
-exec cp '-a' '{}' "$ndir/" ';'
chgrp -R vyattacfg $ndir
chmod -R 775 $ndir
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl
index 26f2791a..a5bb2553 100755
--- a/scripts/vyatta-interfaces.pl
+++ b/scripts/vyatta-interfaces.pl
@@ -290,12 +290,12 @@ sub is_valid_addr_commit {
my ($dhcp, $static_v4);
foreach my $addr (@addrs) {
next if ($addr eq 'dhcpv6');
-
if ($addr eq 'dhcp') {
$dhcp = 1;
- } elsif ($ipaddr_hash{$addr} && !is_ip_configured($ifname, $addr)) {
- my $h = Vyatta::Misc::get_ipnet_intf_hash();
- print "Warning: possible duplicate address $addr on $h->{$addr}\n";
+ } elsif (!Vyatta::Interface::is_uniq_address($addr)) {
+ my $h = Vyatta::Misc::get_ipnet_intf_hash();
+ print "Error: duplicate address $addr on $h->{$addr}\n";
+ exit 1;
} elsif ( is_ipv4($addr) ) {
$static_v4 = 1;
}
diff --git a/src/hypervisor_vendor.c b/src/hypervisor_vendor.c
new file mode 100644
index 00000000..eade6c66
--- /dev/null
+++ b/src/hypervisor_vendor.c
@@ -0,0 +1,193 @@
+/*
+ * Identify hypervisor vendor
+ *
+ * This is based on code from lscpu and virt-what. Unfortunately, neither
+ * of those is sufficient. lscpu doesn't detect many VM's,
+ * and virt-what is a shell script that has to be run as root.
+ *
+ * **** License ****
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ * #
+ * A copy of the GNU General Public License is available as
+ * `/usr/share/common-licenses/GPL' in the Debian GNU/Linux distribution
+ * or on the World Wide Web at `http://www.gnu.org/copyleft/gpl.html'.
+ * You can also obtain it by writing to the Free Software Foundation,
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * Portions created by Vyatta are Copyright (C) 2011 Vyatta, Inc.
+ * All Rights Reserved.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#define PROC_XEN "/proc/xen"
+#define PROC_XENCAP PROC_XEN "/capabilities"
+#define PROC_PCIDEVS "/proc/bus/pci/devices"
+#define SYS_HYPERVISOR "/sys/hypervisor/type"
+#define SYS_DMI_VENDOR "/sys/class/dmi/id/sys_vendor"
+
+/*
+ * This CPUID leaf returns the information about the hypervisor.
+ * EAX : maximum input value for CPUID supported by the hypervisor.
+ * EBX, ECX, EDX : Hypervisor vendor ID signature. E.g. VMwareVMware.
+ */
+#define HYPERVISOR_INFO_LEAF 0x40000000
+
+static inline void
+cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx,
+ unsigned int *ecx, unsigned int *edx)
+{
+ __asm__(
+#if defined(__PIC__) && defined(__i386__)
+ /* x86 PIC cannot clobber ebx -- gcc bitches */
+ "pushl %%ebx;"
+ "cpuid;"
+ "movl %%ebx, %%esi;"
+ "popl %%ebx;"
+ : "=S" (*ebx),
+#else
+ "cpuid;"
+ : "=b" (*ebx),
+#endif
+ "=a" (*eax),
+ "=c" (*ecx),
+ "=d" (*edx)
+ : "1" (op), "c"(0));
+}
+
+
+/* Use CPUID instruction to find hypervisor vendor.
+ * This is the preferred method, but doesn't work with older
+ * hypervisors.
+ */
+static const char *get_hypervisor_cpuid(void)
+{
+ unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0;
+ char hyper_vendor_id[13];
+
+ memset(hyper_vendor_id, 0, sizeof(hyper_vendor_id));
+
+ cpuid(HYPERVISOR_INFO_LEAF, &eax, &ebx, &ecx, &edx);
+ memcpy(hyper_vendor_id + 0, &ebx, 4);
+ memcpy(hyper_vendor_id + 4, &ecx, 4);
+ memcpy(hyper_vendor_id + 8, &edx, 4);
+ hyper_vendor_id[12] = '\0';
+
+ if (!hyper_vendor_id[0])
+ return NULL;
+
+ else if (!strncmp("XenVMMXenVMM", hyper_vendor_id, 12))
+ return "Xen hvm";
+ else if (!strncmp("KVMKVMKVM", hyper_vendor_id, 9))
+ return "KVM";
+ else if (!strncmp("Microsoft Hv", hyper_vendor_id, 12))
+ return "Microsoft HyperV";
+ else if (!strncmp("VMwareVMware", hyper_vendor_id, 12))
+ return "VMware";
+ else
+ return NULL;
+}
+
+/* Use DMI vendor information */
+static const char *get_hypervisor_dmi(void)
+{
+ FILE *f = fopen(SYS_DMI_VENDOR, "r");
+ char vendor_id[128];
+
+ if (!f)
+ return NULL;
+
+ if (fgets(vendor_id, sizeof(vendor_id), f) == NULL) {
+ fclose(f);
+ return NULL;
+ }
+ fclose(f);
+
+ if (!strncmp(vendor_id, "VMware", 6))
+ return "VMware";
+ /* Note: Hyper-V has same DMI, but different CPUID */
+ else if (!strncmp(vendor_id, "Microsoft Corporation", 21))
+ return "VirtualPC";
+ else if (!strncmp(vendor_id, "innotek GmbH", 12))
+ return "VirtualBox";
+ else if (!strncmp(vendor_id, "Parallels", 9))
+ return "Parallels";
+ else
+ return NULL;
+}
+
+static int
+has_pci_device(int vendor, int device)
+{
+ FILE *f;
+ int num, fn, ven, dev;
+ int res = 1;
+
+ f = fopen(PROC_PCIDEVS, "r");
+ if (!f)
+ return 0;
+
+ /* for more details about bus/pci/devices format see
+ * drivers/pci/proc.c in linux kernel
+ */
+ while(fscanf(f, "%02x%02x\t%04x%04x\t%*[^\n]",
+ &num, &fn, &ven, &dev) == 4) {
+
+ if (ven == vendor && dev == device)
+ goto found;
+ }
+
+ res = 0;
+found:
+ fclose(f);
+ return res;
+}
+
+int main(int argc, char **argv)
+{
+ FILE *f;
+ const char *hvm;
+ char buf[256];
+
+ hvm = get_hypervisor_cpuid();
+ if (hvm)
+ printf("%s\n", hvm);
+
+ hvm = get_hypervisor_dmi();
+ if (hvm)
+ printf("%s\n", hvm);
+
+ /* Grotty code to look for old Xen */
+ else if ((f = fopen(PROC_XENCAP, "r")) != NULL) {
+ int dom0 = 0;
+
+ if (fscanf(f, "%s", buf) == 1 &&
+ !strcmp(buf, "control_d"))
+ dom0 = 1;
+ printf("Xen %s\n", dom0 ? "dom0" : "domU");
+ fclose(f);
+ }
+ else if ((f = fopen(SYS_HYPERVISOR, "r")) != NULL) {
+ if (fgets(buf, sizeof(buf), f) != NULL
+ && !strncmp(buf, "xen", 3))
+ printf("Xen\n");
+ fclose(f);
+ }
+ else if (has_pci_device(0x5853, 0x0001)) {
+ /* Xen full-virt on non-x86_64 */
+ printf("Xen full\n");
+ }
+
+ /* print nothing if in real mode */
+ return 0;
+}