bhyveload.c (284539) | bhyveload.c (289001) |
---|---|
1/*- 2 * Copyright (c) 2011 NetApp, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 2011 NetApp, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/usr.sbin/bhyveload/bhyveload.c 284539 2015-06-18 06:00:17Z neel $ | 26 * $FreeBSD: head/usr.sbin/bhyveload/bhyveload.c 289001 2015-10-08 02:28:22Z marcel $ |
27 */ 28 29/*- 30 * Copyright (c) 2011 Google, Inc. 31 * All rights reserved. 32 * 33 * Redistribution and use in source and binary forms, with or without 34 * modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 46 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 47 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 48 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 49 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 50 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 51 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 52 * SUCH DAMAGE. 53 * | 27 */ 28 29/*- 30 * Copyright (c) 2011 Google, Inc. 31 * All rights reserved. 32 * 33 * Redistribution and use in source and binary forms, with or without 34 * modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 46 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 47 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 48 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 49 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 50 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 51 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 52 * SUCH DAMAGE. 53 * |
54 * $FreeBSD: head/usr.sbin/bhyveload/bhyveload.c 284539 2015-06-18 06:00:17Z neel $ | 54 * $FreeBSD: head/usr.sbin/bhyveload/bhyveload.c 289001 2015-10-08 02:28:22Z marcel $ |
55 */ 56 57#include <sys/cdefs.h> | 55 */ 56 57#include <sys/cdefs.h> |
58__FBSDID("$FreeBSD: head/usr.sbin/bhyveload/bhyveload.c 284539 2015-06-18 06:00:17Z neel $"); | 58__FBSDID("$FreeBSD: head/usr.sbin/bhyveload/bhyveload.c 289001 2015-10-08 02:28:22Z marcel $"); |
59 60#include <sys/ioctl.h> 61#include <sys/stat.h> 62#include <sys/disk.h> 63#include <sys/queue.h> 64 65#include <machine/specialreg.h> 66#include <machine/vmm.h> --- 567 unchanged lines hidden (view full) --- 634 progname, 635 (int)strlen(progname), ""); 636 exit(1); 637} 638 639int 640main(int argc, char** argv) 641{ | 59 60#include <sys/ioctl.h> 61#include <sys/stat.h> 62#include <sys/disk.h> 63#include <sys/queue.h> 64 65#include <machine/specialreg.h> 66#include <machine/vmm.h> --- 567 unchanged lines hidden (view full) --- 634 progname, 635 (int)strlen(progname), ""); 636 exit(1); 637} 638 639int 640main(int argc, char** argv) 641{ |
642 char *loader; |
|
642 void *h; 643 void (*func)(struct loader_callbacks *, void *, int, int); 644 uint64_t mem_size; 645 int opt, error, need_reinit, memflags; 646 647 progname = basename(argv[0]); 648 | 643 void *h; 644 void (*func)(struct loader_callbacks *, void *, int, int); 645 uint64_t mem_size; 646 int opt, error, need_reinit, memflags; 647 648 progname = basename(argv[0]); 649 |
650 loader = NULL; 651 |
|
649 memflags = 0; 650 mem_size = 256 * MB; 651 652 consin_fd = STDIN_FILENO; 653 consout_fd = STDOUT_FILENO; 654 | 652 memflags = 0; 653 mem_size = 256 * MB; 654 655 consin_fd = STDIN_FILENO; 656 consout_fd = STDOUT_FILENO; 657 |
655 while ((opt = getopt(argc, argv, "Sc:d:e:h:m:")) != -1) { | 658 while ((opt = getopt(argc, argv, "Sc:d:e:h:l:m:")) != -1) { |
656 switch (opt) { 657 case 'c': 658 error = altcons_open(optarg); 659 if (error != 0) 660 errx(EX_USAGE, "Could not open '%s'", optarg); 661 break; 662 663 case 'd': --- 5 unchanged lines hidden (view full) --- 669 case 'e': 670 addenv(optarg); 671 break; 672 673 case 'h': 674 host_base = optarg; 675 break; 676 | 659 switch (opt) { 660 case 'c': 661 error = altcons_open(optarg); 662 if (error != 0) 663 errx(EX_USAGE, "Could not open '%s'", optarg); 664 break; 665 666 case 'd': --- 5 unchanged lines hidden (view full) --- 672 case 'e': 673 addenv(optarg); 674 break; 675 676 case 'h': 677 host_base = optarg; 678 break; 679 |
680 case 'l': 681 if (loader != NULL) 682 errx(EX_USAGE, "-l can only be given once"); 683 loader = strdup(optarg); 684 if (loader == NULL) 685 err(EX_OSERR, "malloc"); 686 break; 687 |
|
677 case 'm': 678 error = vm_parse_memsize(optarg, &mem_size); 679 if (error != 0) 680 errx(EX_USAGE, "Invalid memsize '%s'", optarg); 681 break; 682 case 'S': 683 memflags |= VM_MEM_F_WIRED; 684 break; --- 36 unchanged lines hidden (view full) --- 721 722 vm_set_memflags(ctx, memflags); 723 error = vm_setup_memory(ctx, mem_size, VM_MMAP_ALL); 724 if (error) { 725 perror("vm_setup_memory"); 726 exit(1); 727 } 728 | 688 case 'm': 689 error = vm_parse_memsize(optarg, &mem_size); 690 if (error != 0) 691 errx(EX_USAGE, "Invalid memsize '%s'", optarg); 692 break; 693 case 'S': 694 memflags |= VM_MEM_F_WIRED; 695 break; --- 36 unchanged lines hidden (view full) --- 732 733 vm_set_memflags(ctx, memflags); 734 error = vm_setup_memory(ctx, mem_size, VM_MMAP_ALL); 735 if (error) { 736 perror("vm_setup_memory"); 737 exit(1); 738 } 739 |
729 tcgetattr(consout_fd, &term); 730 oldterm = term; 731 cfmakeraw(&term); 732 term.c_cflag |= CLOCAL; 733 734 tcsetattr(consout_fd, TCSAFLUSH, &term); 735 736 h = dlopen("/boot/userboot.so", RTLD_LOCAL); | 740 if (loader == NULL) { 741 loader = strdup("/boot/userboot.so"); 742 if (loader == NULL) 743 err(EX_OSERR, "malloc"); 744 } 745 h = dlopen(loader, RTLD_LOCAL); |
737 if (!h) { 738 printf("%s\n", dlerror()); | 746 if (!h) { 747 printf("%s\n", dlerror()); |
748 free(loader); |
|
739 return (1); 740 } 741 func = dlsym(h, "loader_main"); 742 if (!func) { 743 printf("%s\n", dlerror()); | 749 return (1); 750 } 751 func = dlsym(h, "loader_main"); 752 if (!func) { 753 printf("%s\n", dlerror()); |
754 free(loader); |
|
744 return (1); 745 } 746 | 755 return (1); 756 } 757 |
758 tcgetattr(consout_fd, &term); 759 oldterm = term; 760 cfmakeraw(&term); 761 term.c_cflag |= CLOCAL; 762 763 tcsetattr(consout_fd, TCSAFLUSH, &term); 764 |
|
747 addenv("smbios.bios.vendor=BHYVE"); 748 addenv("boot_serial=1"); 749 750 func(&cb, NULL, USERBOOT_VERSION_3, ndisks); | 765 addenv("smbios.bios.vendor=BHYVE"); 766 addenv("boot_serial=1"); 767 768 func(&cb, NULL, USERBOOT_VERSION_3, ndisks); |
769 770 free(loader); 771 return (0); |
|
751} | 772} |