Page MenuHomeFreeBSD

D16161.id45049.diff
No OneTemporary

D16161.id45049.diff

Index: usr.sbin/bhyve/bhyverun.c
===================================================================
--- usr.sbin/bhyve/bhyverun.c
+++ usr.sbin/bhyve/bhyverun.c
@@ -396,8 +396,7 @@
{
if (!CPU_ISSET(vcpu, &cpumask)) {
- fprintf(stderr, "Attempting to delete unknown cpu %d\n", vcpu);
- exit(1);
+ errx(EX_OSERR, "Attempting to delete unknown cpu %d", vcpu);
}
CPU_CLR_ATOMIC(vcpu, &cpumask);
@@ -683,8 +682,7 @@
case VM_SUSPEND_TRIPLEFAULT:
exit(3);
default:
- fprintf(stderr, "vmexit_suspend: invalid reason %d\n", how);
- exit(100);
+ errx(EX_OSERR, "vmexit_suspend: invalid reason %d", how);
}
return (0); /* NOTREACHED */
}
@@ -740,9 +738,8 @@
exitcode = vmexit[vcpu].exitcode;
if (exitcode >= VM_EXITCODE_MAX || handler[exitcode] == NULL) {
- fprintf(stderr, "vm_loop: unexpected exitcode 0x%x\n",
+ errx(EX_SOFTWARE, "vm_loop: unexpected exitcode 0x%x",
exitcode);
- exit(1);
}
rc = (*handler[exitcode])(ctx, &vmexit[vcpu], &vcpu);
@@ -753,7 +750,7 @@
case VMEXIT_ABORT:
abort();
default:
- exit(1);
+ exit(EX_UNAVAILABLE);
}
}
fprintf(stderr, "vm_run error %d, errno %d\n", error, errno);
@@ -784,8 +781,7 @@
if (fbsdrun_vmexit_on_hlt()) {
err = vm_get_capability(ctx, cpu, VM_CAP_HALT_EXIT, &tmp);
if (err < 0) {
- fprintf(stderr, "VM exit on HLT not supported\n");
- exit(1);
+ errx(EX_SOFTWARE, "VM exit on HLT not support");
}
vm_set_capability(ctx, cpu, VM_CAP_HALT_EXIT, 1);
if (cpu == BSP)
@@ -798,9 +794,7 @@
*/
err = vm_get_capability(ctx, cpu, VM_CAP_PAUSE_EXIT, &tmp);
if (err < 0) {
- fprintf(stderr,
- "SMP mux requested, no pause support\n");
- exit(1);
+ errx(EX_NOPERM, "SMP mux requested, no pause support");
}
vm_set_capability(ctx, cpu, VM_CAP_PAUSE_EXIT, 1);
if (cpu == BSP)
@@ -813,8 +807,7 @@
err = vm_set_x2apic_state(ctx, cpu, X2APIC_DISABLED);
if (err) {
- fprintf(stderr, "Unable to set x2apic state (%d)\n", err);
- exit(1);
+ errx(EX_SOFTWARE, "Unable to set x2apic state (%d)", err);
}
vm_set_capability(ctx, cpu, VM_CAP_ENABLE_INVPCID, 1);
@@ -849,8 +842,7 @@
*/
}
} else {
- perror("vm_create");
- exit(1);
+ err(errno, "vm_create");
}
} else {
if (!romboot) {
@@ -858,15 +850,13 @@
* If the virtual machine was just created then a
* bootrom must be configured to boot it.
*/
- fprintf(stderr, "virtual machine cannot be booted\n");
- exit(1);
+ errx(EX_USAGE, "virtual machine cannot be booted");
}
}
ctx = vm_open(vmname);
if (ctx == NULL) {
- perror("vm_open");
- exit(1);
+ err(errno, "vm_open");
}
#ifndef WITHOUT_CAPSICUM
@@ -887,8 +877,7 @@
if (reinit) {
error = vm_reinit(ctx);
if (error) {
- perror("vm_reinit");
- exit(1);
+ err(errno, "vm_reinit");
}
}
error = vm_set_topology(ctx, sockets, cores, threads, maxcpus);
@@ -967,7 +956,7 @@
break;
case 's':
if (pci_parse_slot(optarg) != 0)
- exit(1);
+ errx(EX_USAGE, "invalid pci slot");
else
break;
case 'S':
@@ -1031,9 +1020,8 @@
max_vcpus = num_vcpus_allowed(ctx);
if (guest_ncpus > max_vcpus) {
- fprintf(stderr, "%d vCPUs requested but only %d available\n",
- guest_ncpus, max_vcpus);
- exit(1);
+ errx(EX_SOFTWARE, "%d vCPUs requested but only %d available",
+ guest_ncpus, max_vcpus);
}
fbsdrun_set_capabilities(ctx, BSP);
@@ -1041,14 +1029,12 @@
vm_set_memflags(ctx, memflags);
err = vm_setup_memory(ctx, memsize, VM_MMAP_ALL);
if (err) {
- fprintf(stderr, "Unable to setup memory (%d)\n", errno);
- exit(1);
+ errx(EX_NOPERM, "Unable to setup memory (%d)", errno);
}
error = init_msr();
if (error) {
- fprintf(stderr, "init_msr error %d", error);
- exit(1);
+ errx(EX_SOFTWARE, "init_msr error %d", error);
}
init_mem();
@@ -1064,7 +1050,8 @@
* Exit if a device emulation finds an error in its initilization
*/
if (init_pci(ctx) != 0)
- exit(1);
+ errx(EX_UNAVAILABLE,
+ "device emulation initialization error");
if (dbg_port != 0)
init_dbgport(dbg_port);
@@ -1077,9 +1064,8 @@
if (lpc_bootrom()) {
if (vm_set_capability(ctx, BSP, VM_CAP_UNRESTRICTED_GUEST, 1)) {
- fprintf(stderr, "ROM boot failed: unrestricted guest "
- "capability not available\n");
- exit(1);
+ errx(EX_UNAVAILABLE, "ROM boot failed: unrestricted "
+ "guest capability not available");
}
error = vcpu_reset(ctx, BSP);
assert(error == 0);
@@ -1094,7 +1080,7 @@
if (mptgen) {
error = mptable_build(ctx, guest_ncpus);
if (error)
- exit(1);
+ errx(EX_SOFTWARE, "build the guest tables");
}
error = smbios_build(ctx);
@@ -1133,5 +1119,5 @@
*/
mevent_dispatch();
- exit(1);
+ errx(EX_SOFTWARE, "internal software error");
}
Index: usr.sbin/bhyve/dbgport.c
===================================================================
--- usr.sbin/bhyve/dbgport.c
+++ usr.sbin/bhyve/dbgport.c
@@ -139,8 +139,7 @@
conn_fd = -1;
if ((listen_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- perror("socket");
- exit(1);
+ err(errno, "cannot create a socket");
}
sin.sin_len = sizeof(sin);
@@ -151,18 +150,15 @@
reuse = 1;
if (setsockopt(listen_fd, SOL_SOCKET, SO_REUSEADDR, &reuse,
sizeof(reuse)) < 0) {
- perror("setsockopt");
- exit(1);
+ err(errno, "cannot set socket options");
}
if (bind(listen_fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
- perror("bind");
- exit(1);
+ err(errno, "cannot bind to the socket");
}
if (listen(listen_fd, 1) < 0) {
- perror("listen");
- exit(1);
+ err(errno, "cannot listen socket");
}
#ifndef WITHOUT_CAPSICUM
Index: usr.sbin/bhyve/fwctl.c
===================================================================
--- usr.sbin/bhyve/fwctl.c
+++ usr.sbin/bhyve/fwctl.c
@@ -41,9 +41,11 @@
#include <sys/uio.h>
#include <assert.h>
+#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sysexits.h>
#include "bhyverun.h"
#include "inout.h"
@@ -374,8 +376,7 @@
case 0:
/* Verify size */
if (value < 12) {
- printf("msg size error");
- exit(1);
+ errx(EX_SOFTWARE, "msg size error");
}
rinfo.req_size = value;
rinfo.req_count = 1;
Index: usr.sbin/bhyve/mevent_test.c
===================================================================
--- usr.sbin/bhyve/mevent_test.c
+++ usr.sbin/bhyve/mevent_test.c
@@ -42,8 +42,10 @@
#include <netinet/in.h>
#include <machine/cpufunc.h>
+#include <err.h>
#include <stdio.h>
#include <stdlib.h>
+#include <sysexits.h>
#include <pthread.h>
#include <unistd.h>
@@ -142,8 +144,7 @@
mev = mevent_add(fd, EVF_READ, echoer_callback, &sync);
if (mev == NULL) {
- printf("Could not allocate echoer event\n");
- exit(1);
+ errx(EX_OSERR, "Could not allocate echoer event");
}
while (!pthread_cond_wait(&sync.e_cond, &sync.e_mt)) {
@@ -200,8 +201,7 @@
static int first;
if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- perror("socket");
- exit(1);
+ err(errno, "socket");
}
sin.sin_len = sizeof(sin);
@@ -210,13 +210,11 @@
sin.sin_port = htons(TEST_PORT);
if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
- perror("bind");
- exit(1);
+ err(errno, "bind");
}
if (listen(s, 1) < 0) {
- perror("listen");
- exit(1);
+ err(errno, "listen");
}
(void) mevent_add(s, EVF_READ, acceptor_callback, NULL);
Index: usr.sbin/bhyve/pci_e82545.c
===================================================================
--- usr.sbin/bhyve/pci_e82545.c
+++ usr.sbin/bhyve/pci_e82545.c
@@ -2223,8 +2223,7 @@
sc->esc_tapfd = open(tbuf, O_RDWR);
if (sc->esc_tapfd == -1) {
- DPRINTF("unable to open tap device %s\n", opts);
- exit(1);
+ errx(EX_OSFILE, "unable to open tap device %s", opts);
}
/*

File Metadata

Mime Type
text/plain
Expires
Mon, Mar 16, 11:02 PM (15 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29792424
Default Alt Text
D16161.id45049.diff (7 KB)

Event Timeline