summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/vmd/loadfile_elf.c18
-rw-r--r--usr.sbin/vmd/pci.c4
-rw-r--r--usr.sbin/vmd/proc.h18
-rw-r--r--usr.sbin/vmd/virtio.c38
-rw-r--r--usr.sbin/vmd/virtio.h4
-rw-r--r--usr.sbin/vmd/vmd.h14
-rw-r--r--usr.sbin/vmd/vmm.c32
7 files changed, 66 insertions, 62 deletions
diff --git a/usr.sbin/vmd/loadfile_elf.c b/usr.sbin/vmd/loadfile_elf.c
index 29e88de556c..ef91e7e5338 100644
--- a/usr.sbin/vmd/loadfile_elf.c
+++ b/usr.sbin/vmd/loadfile_elf.c
@@ -1,5 +1,5 @@
/* $NetBSD: loadfile.c,v 1.10 2000/12/03 02:53:04 tsutsui Exp $ */
-/* $OpenBSD: loadfile_elf.c,v 1.2 2015/11/23 13:04:49 reyk Exp $ */
+/* $OpenBSD: loadfile_elf.c,v 1.3 2015/12/03 08:42:11 reyk Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -220,7 +220,7 @@ loadelf_main(int fd, int vm_id_in, int mem_sz)
vm_id = vm_id_in;
- if ((r = read(fd, &hdr, sizeof(hdr))) != sizeof(hdr))
+ if ((r = read(fd, &hdr, sizeof(hdr))) != sizeof(hdr))
return 1;
bzero(&marks, sizeof(marks));
@@ -376,7 +376,7 @@ mread(int fd, uint32_t addr, size_t sz)
osz = sz;
if ((addr & PAGE_MASK) != 0) {
bzero(buf, sizeof(buf));
- if (sz > PAGE_SIZE)
+ if (sz > PAGE_SIZE)
ct = PAGE_SIZE - (addr & PAGE_MASK);
else
ct = sz;
@@ -590,7 +590,8 @@ elf64_exec(int fd, Elf64_Ehdr *elf, u_long *marks, int flags)
for (pos = 0; pos < phdr[i].p_filesz;
pos += m) {
m = phdr[i].p_filesz - pos;
- marc4random_buf(phdr[i].p_paddr + pos, m);
+ marc4random_buf(phdr[i].p_paddr + pos,
+ m);
}
}
if (flags & (LOAD_RANDOM | COUNT_RANDOM)) {
@@ -615,7 +616,8 @@ elf64_exec(int fd, Elf64_Ehdr *elf, u_long *marks, int flags)
(IS_DATA(phdr[i]) && (flags & LOAD_DATA))) {
/* Read in segment. */
- if (lseek(fd, (off_t)phdr[i].p_offset, SEEK_SET) == -1) {
+ if (lseek(fd, (off_t)phdr[i].p_offset,
+ SEEK_SET) == -1) {
free(phdr);
return 1;
}
@@ -811,7 +813,8 @@ elf32_exec(int fd, Elf32_Ehdr *elf, u_long *marks, int flags)
for (pos = 0; pos < phdr[i].p_filesz;
pos += m) {
m = phdr[i].p_filesz - pos;
- marc4random_buf(phdr[i].p_paddr + pos, m);
+ marc4random_buf(phdr[i].p_paddr + pos,
+ m);
}
}
if (flags & (LOAD_RANDOM | COUNT_RANDOM)) {
@@ -836,7 +839,8 @@ elf32_exec(int fd, Elf32_Ehdr *elf, u_long *marks, int flags)
(IS_DATA(phdr[i]) && (flags & LOAD_DATA))) {
/* Read in segment. */
- if (lseek(fd, (off_t)phdr[i].p_offset, SEEK_SET) == -1) {
+ if (lseek(fd, (off_t)phdr[i].p_offset,
+ SEEK_SET) == -1) {
free(phdr);
return 1;
}
diff --git a/usr.sbin/vmd/pci.c b/usr.sbin/vmd/pci.c
index c8ff945a8b4..613d7574d68 100644
--- a/usr.sbin/vmd/pci.c
+++ b/usr.sbin/vmd/pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci.c,v 1.3 2015/11/23 13:04:49 reyk Exp $ */
+/* $OpenBSD: pci.c,v 1.4 2015/12/03 08:42:11 reyk Exp $ */
/*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
@@ -233,7 +233,7 @@ pci_handle_io(struct vm_run_params *vrp)
if (k >= 0 && l >= 0) {
fn = (pci_iobar_fn_t)pci.pci_devices[l].pd_barfunc[k];
- if (fn(vei->vei.vei_dir, reg -
+ if (fn(vei->vei.vei_dir, reg -
PCI_MAPREG_IO_ADDR(pci.pci_devices[l].pd_bar[k]),
&vei->vei.vei_data, &intr,
pci.pci_devices[l].pd_bar_cookie[k])) {
diff --git a/usr.sbin/vmd/proc.h b/usr.sbin/vmd/proc.h
index 9cd1b5ba9bf..b9228afed36 100644
--- a/usr.sbin/vmd/proc.h
+++ b/usr.sbin/vmd/proc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.h,v 1.4 2015/12/02 22:19:11 reyk Exp $ */
+/* $OpenBSD: proc.h,v 1.5 2015/12/03 08:42:11 reyk Exp $ */
/*
* Copyright (c) 2010-2015 Reyk Floeter <reyk@openbsd.org>
@@ -26,7 +26,7 @@
#define _PROC_H
enum {
- IMSG_NONE,
+ IMSG_NONE,
IMSG_CTL_OK,
IMSG_CTL_FAIL,
IMSG_CTL_VERBOSE,
@@ -72,8 +72,8 @@ struct {
struct ctl_conn {
TAILQ_ENTRY(ctl_conn) entry;
- u_int8_t flags;
- u_int waiting;
+ uint8_t flags;
+ unsigned int waiting;
#define CTL_CONN_NOTIFY 0x01
struct imsgev iev;
@@ -104,7 +104,7 @@ struct privsep {
struct imsgev *ps_ievs[PROC_MAX];
const char *ps_title[PROC_MAX];
pid_t ps_pid[PROC_MAX];
- u_int8_t ps_what[PROC_MAX];
+ uint8_t ps_what[PROC_MAX];
struct passwd *ps_pw;
int ps_noaction;
@@ -112,9 +112,9 @@ struct privsep {
struct control_sock ps_csock;
struct control_socks ps_rcsocks;
- u_int ps_instances[PROC_MAX];
- u_int ps_ninstances;
- u_int ps_instance;
+ unsigned int ps_instances[PROC_MAX];
+ unsigned int ps_ninstances;
+ unsigned int ps_instance;
/* Event and signal handlers */
struct event ps_evsigint;
@@ -138,7 +138,7 @@ struct privsep_proc {
struct privsep *p_ps;
void *p_env;
void (*p_shutdown)(void);
- u_int p_instance;
+ unsigned int p_instance;
};
/* proc.c */
diff --git a/usr.sbin/vmd/virtio.c b/usr.sbin/vmd/virtio.c
index 1dfdbf52670..3020e743296 100644
--- a/usr.sbin/vmd/virtio.c
+++ b/usr.sbin/vmd/virtio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: virtio.c,v 1.3 2015/11/23 13:04:49 reyk Exp $ */
+/* $OpenBSD: virtio.c,v 1.4 2015/12/03 08:42:11 reyk Exp $ */
/*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
@@ -50,7 +50,7 @@ int nr_vionet;
const char *
vioblk_cmd_name(uint32_t type)
{
- switch(type) {
+ switch (type) {
case VIRTIO_BLK_T_IN: return "read";
case VIRTIO_BLK_T_OUT: return "write";
case VIRTIO_BLK_T_SCSI_CMD: return "scsi read";
@@ -89,7 +89,7 @@ dump_descriptor_chain(struct vring_desc *desc, int16_t dxx)
static const char *
virtio_reg_name(uint8_t reg)
{
- switch(reg) {
+ switch (reg) {
case VIRTIO_CONFIG_DEVICE_FEATURES: return "device feature";
case VIRTIO_CONFIG_GUEST_FEATURES: return "guest feature";
case VIRTIO_CONFIG_QUEUE_ADDRESS: return "queue address";
@@ -125,7 +125,7 @@ void
viornd_update_qs(void)
{
/* Invalid queue? */
- if (viornd.cfg.queue_select > 0)
+ if (viornd.cfg.queue_select > 0)
return;
/* Update queue address/size based on queue select */
@@ -223,7 +223,6 @@ viornd_notifyq(void)
if (push_virtio_ring(buf, q_gpa, vr_sz)) {
log_warnx("viornd: error writing vio ring");
}
-
}
free(rnd_data);
}
@@ -240,7 +239,7 @@ virtio_rnd_io(int dir, uint16_t reg, uint32_t *data, uint8_t *intr,
*intr = 0xFF;
if (dir == 0) {
- switch(reg) {
+ switch (reg) {
case VIRTIO_CONFIG_DEVICE_FEATURES:
case VIRTIO_CONFIG_QUEUE_SIZE:
case VIRTIO_CONFIG_ISR_STATUS:
@@ -268,7 +267,7 @@ virtio_rnd_io(int dir, uint16_t reg, uint32_t *data, uint8_t *intr,
break;
}
} else {
- switch(reg) {
+ switch (reg) {
case VIRTIO_CONFIG_DEVICE_FEATURES:
*data = viornd.cfg.device_feature;
break;
@@ -337,7 +336,7 @@ vioblk_do_read(struct vioblk_dev *dev, off_t sector, ssize_t sz)
free(buf);
return (NULL);
}
-
+
if (read(dev->fd, buf, sz) != sz) {
log_warn("vioblk read error");
free(buf);
@@ -474,7 +473,7 @@ vioblk_notifyq(struct vioblk_dev *dev)
free(vr);
return (0);
}
-
+
j = 0;
while (j < secdata_desc->len) {
if (secdata_desc->len - j >= PAGE_SIZE)
@@ -487,14 +486,15 @@ vioblk_notifyq(struct vioblk_dev *dev)
log_warnx("can't write sector "
"data to gpa @ 0x%llx",
secdata_desc->addr);
- dump_descriptor_chain(desc, cmd_desc_idx);
+ dump_descriptor_chain(desc,
+ cmd_desc_idx);
free(vr);
free(secdata);
return (0);
}
j += PAGE_SIZE;
- }
+ }
free(secdata);
@@ -537,7 +537,7 @@ vioblk_notifyq(struct vioblk_dev *dev)
if ((secdata_desc->flags & VRING_DESC_F_NEXT) == 0) {
log_warnx("wr vioblk: unchained vioblk data "
- "descriptor received (idx %d)", cmd_desc_idx);
+ "descriptor received (idx %d)", cmd_desc_idx);
free(vr);
return (0);
}
@@ -571,7 +571,7 @@ vioblk_notifyq(struct vioblk_dev *dev)
}
j += PAGE_SIZE;
- }
+ }
if (vioblk_do_write(dev, cmd.sector + secbias,
secdata, (ssize_t)secdata_desc->len)) {
@@ -657,7 +657,7 @@ virtio_blk_io(int dir, uint16_t reg, uint32_t *data, uint8_t *intr,
*intr = 0xFF;
if (dir == 0) {
- switch(reg) {
+ switch (reg) {
case VIRTIO_CONFIG_DEVICE_FEATURES:
case VIRTIO_CONFIG_QUEUE_SIZE:
case VIRTIO_CONFIG_ISR_STATUS:
@@ -687,7 +687,7 @@ virtio_blk_io(int dir, uint16_t reg, uint32_t *data, uint8_t *intr,
break;
}
} else {
- switch(reg) {
+ switch (reg) {
case VIRTIO_CONFIG_DEVICE_CONFIG_NOMSI + 4:
*data = (uint32_t)(dev->sz >> 32);
break;
@@ -732,7 +732,7 @@ virtio_net_io(int dir, uint16_t reg, uint32_t *data, uint8_t *intr,
*intr = 0xFF;
if (dir == 0) {
- switch(reg) {
+ switch (reg) {
case VIRTIO_CONFIG_DEVICE_FEATURES:
case VIRTIO_CONFIG_QUEUE_SIZE:
case VIRTIO_CONFIG_ISR_STATUS:
@@ -762,7 +762,7 @@ virtio_net_io(int dir, uint16_t reg, uint32_t *data, uint8_t *intr,
break;
}
} else {
- switch(reg) {
+ switch (reg) {
case VIRTIO_CONFIG_DEVICE_CONFIG_NOMSI:
case VIRTIO_CONFIG_DEVICE_CONFIG_NOMSI + 1:
case VIRTIO_CONFIG_DEVICE_CONFIG_NOMSI + 2:
@@ -815,7 +815,7 @@ void
vionet_update_qs(struct vionet_dev *dev)
{
/* Invalid queue? */
- if (dev->cfg.queue_select > 1)
+ if (dev->cfg.queue_select > 1)
return;
/* Update queue address/size based on queue select */
@@ -1100,7 +1100,7 @@ vionet_notifyq(struct vionet_dev *dev)
ofs = 0;
pkt_desc_idx = hdr_desc->next & VIONET_QUEUE_MASK;
pkt_desc = &desc[pkt_desc_idx];
-
+
while (pkt_desc->flags & VRING_DESC_F_NEXT) {
/* must be not writable */
if (pkt_desc->flags & VRING_DESC_F_WRITE) {
diff --git a/usr.sbin/vmd/virtio.h b/usr.sbin/vmd/virtio.h
index fbc0e1c327c..5d886dadbfa 100644
--- a/usr.sbin/vmd/virtio.h
+++ b/usr.sbin/vmd/virtio.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: virtio.h,v 1.2 2015/11/22 21:51:32 reyk Exp $ */
+/* $OpenBSD: virtio.h,v 1.3 2015/12/03 08:42:11 reyk Exp $ */
/*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
@@ -72,7 +72,7 @@ struct vionet_dev {
struct virtio_io_cfg cfg;
struct virtio_vq_info vq[VIRTIO_MAX_QUEUES];
-
+
int fd, rx_added;
uint8_t mac[6];
};
diff --git a/usr.sbin/vmd/vmd.h b/usr.sbin/vmd/vmd.h
index 1f16ba39934..4252e2fdfe2 100644
--- a/usr.sbin/vmd/vmd.h
+++ b/usr.sbin/vmd/vmd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmd.h,v 1.6 2015/12/02 23:33:43 reyk Exp $ */
+/* $OpenBSD: vmd.h,v 1.7 2015/12/03 08:42:11 reyk Exp $ */
/*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
@@ -49,12 +49,12 @@ enum imsg_type {
IMSG_VMDOP_DISABLE_VMM_RESPONSE,
IMSG_VMDOP_ENABLE_VMM_REQUEST,
IMSG_VMDOP_ENABLE_VMM_RESPONSE,
- IMSG_VMDOP_START_VM_REQUEST,
- IMSG_VMDOP_START_VM_DISK,
- IMSG_VMDOP_START_VM_IF,
- IMSG_VMDOP_START_VM_END,
+ IMSG_VMDOP_START_VM_REQUEST,
+ IMSG_VMDOP_START_VM_DISK,
+ IMSG_VMDOP_START_VM_IF,
+ IMSG_VMDOP_START_VM_END,
IMSG_VMDOP_START_VM_RESPONSE,
- IMSG_VMDOP_TERMINATE_VM_REQUEST,
+ IMSG_VMDOP_TERMINATE_VM_REQUEST,
IMSG_VMDOP_TERMINATE_VM_RESPONSE,
IMSG_VMDOP_GET_INFO_VM_REQUEST,
IMSG_VMDOP_GET_INFO_VM_DATA,
@@ -104,7 +104,7 @@ int opentap(void);
/* control.c */
int config_init(struct vmd *);
-void config_purge(struct vmd *, u_int);
+void config_purge(struct vmd *, unsigned int);
int config_setreset(struct vmd *, unsigned int);
int config_getreset(struct vmd *, struct imsg *);
int config_getvm(struct privsep *, struct imsg *);
diff --git a/usr.sbin/vmd/vmm.c b/usr.sbin/vmd/vmm.c
index 7a5d44420b8..718a2db0e86 100644
--- a/usr.sbin/vmd/vmm.c
+++ b/usr.sbin/vmd/vmm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmm.c,v 1.4 2015/12/02 22:19:11 reyk Exp $ */
+/* $OpenBSD: vmm.c,v 1.5 2015/12/03 08:42:11 reyk Exp $ */
/*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
@@ -234,7 +234,7 @@ terminate_vm(struct imsg *imsg)
vtp = (struct vm_terminate_params *)imsg->data;
if (ioctl(env->vmd_fd, VMM_IOC_TERM, vtp) < 0)
- return (errno);
+ return (errno);
return (0);
}
@@ -252,7 +252,7 @@ opentap(void)
{
int i, fd;
char path[PATH_MAX];
-
+
for (i = 0; i < MAX_TAP; i++) {
snprintf(path, PATH_MAX, "/dev/tap%d", i);
fd = open(path, O_RDWR | O_NONBLOCK);
@@ -356,7 +356,7 @@ start_vm(struct imsg *imsg)
close(vm->vm_kernel);
con_fd = vm->vm_tty;
- if (fcntl(con_fd, F_SETFL, O_NONBLOCK) == -1)
+ if (fcntl(con_fd, F_SETFL, O_NONBLOCK) == -1)
fatal("failed to set nonblocking mode on console");
/* Execute the vcpu run loop(s) for this VM */
@@ -364,7 +364,7 @@ start_vm(struct imsg *imsg)
_exit(ret != 0);
}
-
+
return (0);
err:
@@ -703,7 +703,7 @@ vcpu_exit_i8253(union vm_exit *vei)
__progname, sel);
return;
}
-
+
rw = vei->vei.vei_data &
(TIMER_LATCH | TIMER_LSB |
TIMER_MSB | TIMER_16BIT);
@@ -734,7 +734,7 @@ vcpu_exit_i8253(union vm_exit *vei)
i8253_counter[sel].tv.tv_sec;
delta.tv_usec = now.tv_usec -
i8253_counter[sel].tv.tv_usec;
- if (delta.tv_usec < 0) {
+ if (delta.tv_usec < 0) {
delta.tv_sec--;
delta.tv_usec += 1000000;
}
@@ -782,7 +782,7 @@ vcpu_exit_i8253(union vm_exit *vei)
data = i8253_counter[sel].olatch & 0xFF;
vei->vei.vei_data = data;
i8253_counter[sel].last_w = 0;
- }
+ }
}
}
}
@@ -1089,7 +1089,7 @@ vcpu_exit_com(struct vm_run_params *vrp)
{
union vm_exit *vei = vrp->vrp_exit;
- switch(vei->vei.vei_port) {
+ switch (vei->vei.vei_port) {
case COM1_LCR:
vcpu_process_com_lcr(vei);
break;
@@ -1110,7 +1110,7 @@ vcpu_exit_com(struct vm_run_params *vrp)
break;
case COM1_SCR:
vcpu_process_com_scr(vei);
- break;
+ break;
case COM1_DATA:
vcpu_process_com_data(vei);
break;
@@ -1137,7 +1137,7 @@ vcpu_exit_pci(struct vm_run_params *vrp)
intr = 0xFF;
- switch(vei->vei.vei_port) {
+ switch (vei->vei.vei_port) {
case PCI_MODE1_ADDRESS_REG:
pci_handle_address_reg(vrp);
break;
@@ -1146,7 +1146,7 @@ vcpu_exit_pci(struct vm_run_params *vrp)
break;
case VMM_PCI_IO_BAR_BASE ... VMM_PCI_IO_BAR_END:
intr = pci_handle_io(vrp);
- break;
+ break;
default:
log_warnx("%s: unknown PCI register 0x%llx",
__progname, (uint64_t)vei->vei.vei_port);
@@ -1171,7 +1171,7 @@ vcpu_exit_inout(struct vm_run_params *vrp)
union vm_exit *vei = vrp->vrp_exit;
uint8_t intr;
- switch(vei->vei.vei_port) {
+ switch (vei->vei.vei_port) {
case TIMER_CTRL:
case (TIMER_CNTR0 + TIMER_BASE):
case (TIMER_CNTR1 + TIMER_BASE):
@@ -1241,7 +1241,7 @@ vcpu_exit(struct vm_run_params *vrp)
}
/* XXX interrupt priority */
- if (vionet_process_rx())
+ if (vionet_process_rx())
vrp->vrp_injint = 9;
/*
@@ -1312,7 +1312,7 @@ write_page(uint32_t dst, void *buf, uint32_t len, int do_mask)
*/
if (do_mask)
dst &= 0xFFFFFFF;
-
+
vwp.vwp_paddr = (paddr_t)dst;
vwp.vwp_data = buf;
vwp.vwp_vm_id = vm_id;
@@ -1353,7 +1353,7 @@ read_page(uint32_t src, void *buf, uint32_t len, int do_mask)
*/
if (do_mask)
src &= 0xFFFFFFF;
-
+
vrp.vrp_paddr = (paddr_t)src;
vrp.vrp_data = buf;
vrp.vrp_vm_id = vm_id;