Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Feb 2020 21:48:36 +0000 (UTC)
From:      Vincenzo Maffione <vmaffione@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r358184 - stable/12/usr.sbin/bhyve
Message-ID:  <202002202148.01KLmag8021607@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: vmaffione
Date: Thu Feb 20 21:48:36 2020
New Revision: 358184
URL: https://svnweb.freebsd.org/changeset/base/358184

Log:
  MFC r356523
  
  bhyve: add wrapper for debug printf statements
  
  Add printf() wrapper to use CR/CRLF terminators depending on whether
  stdio is mapped to a tty open in raw mode.
  Try to use the wrapper everywhere.
  For now we leave the custom DPRINTF/WPRINTF defined by device
  models, but we may remove them in the future.
  
  Reviewed by:    grehan, jhb
  Differential Revision:  https://reviews.freebsd.org/D22657

Added:
  stable/12/usr.sbin/bhyve/debug.h
     - copied unchanged from r356523, head/usr.sbin/bhyve/debug.h
Modified:
  stable/12/usr.sbin/bhyve/bhyverun.c
  stable/12/usr.sbin/bhyve/block_if.c
  stable/12/usr.sbin/bhyve/bootrom.c
  stable/12/usr.sbin/bhyve/consport.c
  stable/12/usr.sbin/bhyve/mptbl.c
  stable/12/usr.sbin/bhyve/net_backends.c
  stable/12/usr.sbin/bhyve/net_utils.c
  stable/12/usr.sbin/bhyve/pci_e82545.c
  stable/12/usr.sbin/bhyve/pci_emul.c
  stable/12/usr.sbin/bhyve/pci_fbuf.c
  stable/12/usr.sbin/bhyve/pci_lpc.c
  stable/12/usr.sbin/bhyve/pci_nvme.c
  stable/12/usr.sbin/bhyve/pci_uart.c
  stable/12/usr.sbin/bhyve/pci_virtio_block.c
  stable/12/usr.sbin/bhyve/pci_virtio_console.c
  stable/12/usr.sbin/bhyve/pci_virtio_net.c
  stable/12/usr.sbin/bhyve/pci_virtio_rnd.c
  stable/12/usr.sbin/bhyve/pci_virtio_scsi.c
  stable/12/usr.sbin/bhyve/pci_xhci.c
  stable/12/usr.sbin/bhyve/ps2kbd.c
  stable/12/usr.sbin/bhyve/ps2mouse.c
  stable/12/usr.sbin/bhyve/rfb.c
  stable/12/usr.sbin/bhyve/smbiostbl.c
  stable/12/usr.sbin/bhyve/task_switch.c
  stable/12/usr.sbin/bhyve/uart_emul.c
  stable/12/usr.sbin/bhyve/usb_mouse.c
  stable/12/usr.sbin/bhyve/virtio.c
  stable/12/usr.sbin/bhyve/xmsr.c

Modified: stable/12/usr.sbin/bhyve/bhyverun.c
==============================================================================
--- stable/12/usr.sbin/bhyve/bhyverun.c	Thu Feb 20 21:29:59 2020	(r358183)
+++ stable/12/usr.sbin/bhyve/bhyverun.c	Thu Feb 20 21:48:36 2020	(r358184)
@@ -167,6 +167,8 @@ uint16_t cores, maxcpus, sockets, threads;
 
 char *guest_uuid_str;
 
+int raw_stdio = 0;
+
 static int guest_vmexit_on_hlt, guest_vmexit_on_pause;
 static int virtio_msix = 1;
 static int x2apic_mode = 0;	/* default is xAPIC */

Modified: stable/12/usr.sbin/bhyve/block_if.c
==============================================================================
--- stable/12/usr.sbin/bhyve/block_if.c	Thu Feb 20 21:29:59 2020	(r358183)
+++ stable/12/usr.sbin/bhyve/block_if.c	Thu Feb 20 21:48:36 2020	(r358184)
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/atomic.h>
 
 #include "bhyverun.h"
+#include "debug.h"
 #include "mevent.h"
 #include "block_if.h"
 
@@ -442,7 +443,7 @@ blockif_open(const char *optstr, const char *ident)
 		else if (sscanf(cp, "sectorsize=%d", &ssopt) == 1)
 			pssopt = ssopt;
 		else {
-			fprintf(stderr, "Invalid device option \"%s\"\n", cp);
+			EPRINTLN("Invalid device option \"%s\"", cp);
 			goto err;
 		}
 	}
@@ -514,7 +515,7 @@ blockif_open(const char *optstr, const char *ident)
 	if (ssopt != 0) {
 		if (!powerof2(ssopt) || !powerof2(pssopt) || ssopt < 512 ||
 		    ssopt > pssopt) {
-			fprintf(stderr, "Invalid sector size %d/%d\n",
+			EPRINTLN("Invalid sector size %d/%d",
 			    ssopt, pssopt);
 			goto err;
 		}
@@ -528,8 +529,8 @@ blockif_open(const char *optstr, const char *ident)
 		 */
 		if (S_ISCHR(sbuf.st_mode)) {
 			if (ssopt < sectsz || (ssopt % sectsz) != 0) {
-				fprintf(stderr, "Sector size %d incompatible "
-				    "with underlying device sector size %d\n",
+				EPRINTLN("Sector size %d incompatible "
+				    "with underlying device sector size %d",
 				    ssopt, sectsz);
 				goto err;
 			}

Modified: stable/12/usr.sbin/bhyve/bootrom.c
==============================================================================
--- stable/12/usr.sbin/bhyve/bootrom.c	Thu Feb 20 21:29:59 2020	(r358183)
+++ stable/12/usr.sbin/bhyve/bootrom.c	Thu Feb 20 21:48:36 2020	(r358184)
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
 #include <vmmapi.h>
 #include "bhyverun.h"
 #include "bootrom.h"
+#include "debug.h"
 
 #define	MAX_BOOTROM_SIZE	(16 * 1024 * 1024)	/* 16 MB */
 
@@ -60,13 +61,13 @@ bootrom_init(struct vmctx *ctx, const char *romfile)
 	rv = -1;
 	fd = open(romfile, O_RDONLY);
 	if (fd < 0) {
-		fprintf(stderr, "Error opening bootrom \"%s\": %s\n",
+		EPRINTLN("Error opening bootrom \"%s\": %s",
 		    romfile, strerror(errno));
 		goto done;
 	}
 
         if (fstat(fd, &sbuf) < 0) {
-		fprintf(stderr, "Could not fstat bootrom file \"%s\": %s\n",
+		EPRINTLN("Could not fstat bootrom file \"%s\": %s",
 		    romfile, strerror(errno));
 		goto done;
         }
@@ -76,13 +77,13 @@ bootrom_init(struct vmctx *ctx, const char *romfile)
 	 * MMIO space (e.g. APIC, HPET, MSI).
 	 */
 	if (sbuf.st_size > MAX_BOOTROM_SIZE || sbuf.st_size < PAGE_SIZE) {
-		fprintf(stderr, "Invalid bootrom size %ld\n", sbuf.st_size);
+		EPRINTLN("Invalid bootrom size %ld", sbuf.st_size);
 		goto done;
 	}
 
 	if (sbuf.st_size & PAGE_MASK) {
-		fprintf(stderr, "Bootrom size %ld is not a multiple of the "
-		    "page size\n", sbuf.st_size);
+		EPRINTLN("Bootrom size %ld is not a multiple of the "
+		    "page size", sbuf.st_size);
 		goto done;
 	}
 
@@ -100,8 +101,8 @@ bootrom_init(struct vmctx *ctx, const char *romfile)
 	for (i = 0; i < sbuf.st_size / PAGE_SIZE; i++) {
 		rlen = read(fd, ptr + i * PAGE_SIZE, PAGE_SIZE);
 		if (rlen != PAGE_SIZE) {
-			fprintf(stderr, "Incomplete read of page %d of bootrom "
-			    "file %s: %ld bytes\n", i, romfile, rlen);
+			EPRINTLN("Incomplete read of page %d of bootrom "
+			    "file %s: %ld bytes", i, romfile, rlen);
 			goto done;
 		}
 	}

Modified: stable/12/usr.sbin/bhyve/consport.c
==============================================================================
--- stable/12/usr.sbin/bhyve/consport.c	Thu Feb 20 21:29:59 2020	(r358183)
+++ stable/12/usr.sbin/bhyve/consport.c	Thu Feb 20 21:48:36 2020	(r358184)
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
 
 #include "inout.h"
 #include "pci_lpc.h"
+#include "debug.h"
 
 #define	BVM_CONSOLE_PORT	0x220
 #define	BVM_CONS_SIG		('b' << 8 | 'v')
@@ -70,6 +71,7 @@ ttyopen(void)
 
 	cfmakeraw(&tio_new);
 	tcsetattr(STDIN_FILENO, TCSANOW, &tio_new);	
+	raw_stdio = 1;
 
 	atexit(ttyclose);
 }

Copied: stable/12/usr.sbin/bhyve/debug.h (from r356523, head/usr.sbin/bhyve/debug.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/12/usr.sbin/bhyve/debug.h	Thu Feb 20 21:48:36 2020	(r358184, copy of r356523, head/usr.sbin/bhyve/debug.h)
@@ -0,0 +1,47 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2019 Vincenzo Maffione <vmaffione@freebsd.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _DEBUG_H_
+#define _DEBUG_H_
+
+
+extern int raw_stdio;
+
+#define FPRINTLN(filep, fmt, arg...)				\
+	do {							\
+		if (raw_stdio)					\
+			fprintf(filep, fmt "\r\n", ##arg);	\
+		else						\
+			fprintf(filep, fmt "\n", ##arg);	\
+	} while (0)
+
+#define PRINTLN(fmt, arg...)	FPRINTLN(stdout, fmt, ##arg)
+#define EPRINTLN(fmt, arg...)	FPRINTLN(stderr, fmt, ##arg)
+
+#endif

Modified: stable/12/usr.sbin/bhyve/mptbl.c
==============================================================================
--- stable/12/usr.sbin/bhyve/mptbl.c	Thu Feb 20 21:29:59 2020	(r358183)
+++ stable/12/usr.sbin/bhyve/mptbl.c	Thu Feb 20 21:48:36 2020	(r358184)
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
 #include <string.h>
 
 #include "acpi.h"
+#include "debug.h"
 #include "bhyverun.h"
 #include "mptbl.h"
 #include "pci_emul.h"
@@ -312,7 +313,7 @@ mptable_build(struct vmctx *ctx, int ncpu)
 
 	startaddr = paddr_guest2host(ctx, MPTABLE_BASE, MPTABLE_MAX_LENGTH);
 	if (startaddr == NULL) {
-		fprintf(stderr, "mptable requires mapped mem\n");
+		EPRINTLN("mptable requires mapped mem");
 		return (ENOMEM);
 	}
 
@@ -323,10 +324,10 @@ mptable_build(struct vmctx *ctx, int ncpu)
 	 */
 	for (bus = 1; bus <= PCI_BUSMAX; bus++) {
 		if (pci_bus_configured(bus)) {
-			fprintf(stderr, "MPtable is incompatible with "
-			    "multiple PCI hierarchies.\r\n");
-			fprintf(stderr, "MPtable generation can be disabled "
-			    "by passing the -Y option to bhyve(8).\r\n");
+			EPRINTLN("MPtable is incompatible with "
+			    "multiple PCI hierarchies.");
+			EPRINTLN("MPtable generation can be disabled "
+			    "by passing the -Y option to bhyve(8).");
 			return (EINVAL);
 		}
 	}

Modified: stable/12/usr.sbin/bhyve/net_backends.c
==============================================================================
--- stable/12/usr.sbin/bhyve/net_backends.c	Thu Feb 20 21:29:59 2020	(r358183)
+++ stable/12/usr.sbin/bhyve/net_backends.c	Thu Feb 20 21:48:36 2020	(r358184)
@@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$");
 #include <assert.h>
 
 
+#include "debug.h"
 #include "iov.h"
 #include "mevent.h"
 #include "net_backends.h"
@@ -156,7 +157,7 @@ SET_DECLARE(net_backend_set, struct net_backend);
 
 #define VNET_HDR_LEN	sizeof(struct virtio_net_rxhdr)
 
-#define WPRINTF(params) printf params
+#define WPRINTF(params) PRINTLN params
 
 /*
  * The tap backend
@@ -192,7 +193,7 @@ tap_init(struct net_backend *be, const char *devname,
 #endif
 
 	if (cb == NULL) {
-		WPRINTF(("TAP backend requires non-NULL callback\n"));
+		WPRINTF(("TAP backend requires non-NULL callback"));
 		return (-1);
 	}
 
@@ -201,7 +202,7 @@ tap_init(struct net_backend *be, const char *devname,
 
 	be->fd = open(tbuf, O_RDWR);
 	if (be->fd == -1) {
-		WPRINTF(("open of tap device %s failed\n", tbuf));
+		WPRINTF(("open of tap device %s failed", tbuf));
 		goto error;
 	}
 
@@ -210,7 +211,7 @@ tap_init(struct net_backend *be, const char *devname,
 	 * notifications with the event loop
 	 */
 	if (ioctl(be->fd, FIONBIO, &opt) < 0) {
-		WPRINTF(("tap device O_NONBLOCK failed\n"));
+		WPRINTF(("tap device O_NONBLOCK failed"));
 		goto error;
 	}
 
@@ -222,7 +223,7 @@ tap_init(struct net_backend *be, const char *devname,
 
 	priv->mevp = mevent_add_disabled(be->fd, EVF_READ, cb, param);
 	if (priv->mevp == NULL) {
-		WPRINTF(("Could not register event\n"));
+		WPRINTF(("Could not register event"));
 		goto error;
 	}
 
@@ -363,7 +364,7 @@ netmap_set_vnet_hdr_len(struct net_backend *be, int vn
 	req.nr_arg1 = vnet_hdr_len;
 	err = ioctl(be->fd, NIOCREGIF, &req);
 	if (err) {
-		WPRINTF(("Unable to set vnet header length %d\n",
+		WPRINTF(("Unable to set vnet header length %d",
 				vnet_hdr_len));
 		return (err);
 	}
@@ -420,7 +421,7 @@ netmap_init(struct net_backend *be, const char *devnam
 
 	priv->nmd = nm_open(priv->ifname, NULL, NETMAP_NO_TX_POLL, NULL);
 	if (priv->nmd == NULL) {
-		WPRINTF(("Unable to nm_open(): interface '%s', errno (%s)\n",
+		WPRINTF(("Unable to nm_open(): interface '%s', errno (%s)",
 			devname, strerror(errno)));
 		free(priv);
 		return (-1);
@@ -435,7 +436,7 @@ netmap_init(struct net_backend *be, const char *devnam
 
 	priv->mevp = mevent_add_disabled(be->fd, EVF_READ, cb, param);
 	if (priv->mevp == NULL) {
-		WPRINTF(("Could not register event\n"));
+		WPRINTF(("Could not register event"));
 		return (-1);
 	}
 
@@ -472,7 +473,7 @@ netmap_send(struct net_backend *be, struct iovec *iov,
 	ring = priv->tx;
 	head = ring->head;
 	if (head == ring->tail) {
-		WPRINTF(("No space, drop %zu bytes\n", count_iov(iov, iovcnt)));
+		WPRINTF(("No space, drop %zu bytes", count_iov(iov, iovcnt)));
 		goto txsync;
 	}
 	nm_buf = NETMAP_BUF(ring, ring->slot[head].buf_idx);
@@ -513,7 +514,7 @@ netmap_send(struct net_backend *be, struct iovec *iov,
 				 * We ran out of netmap slots while
 				 * splitting the iovec fragments.
 				 */
-				WPRINTF(("No space, drop %zu bytes\n",
+				WPRINTF(("No space, drop %zu bytes",
 				   count_iov(iov, iovcnt)));
 				goto txsync;
 			}
@@ -585,7 +586,7 @@ netmap_recv(struct net_backend *be, struct iovec *iov,
 			iovcnt--;
 			if (iovcnt == 0) {
 				/* No space to receive. */
-				WPRINTF(("Short iov, drop %zd bytes\n",
+				WPRINTF(("Short iov, drop %zd bytes",
 				    totlen));
 				return (-ENOSPC);
 			}

Modified: stable/12/usr.sbin/bhyve/net_utils.c
==============================================================================
--- stable/12/usr.sbin/bhyve/net_utils.c	Thu Feb 20 21:29:59 2020	(r358183)
+++ stable/12/usr.sbin/bhyve/net_utils.c	Thu Feb 20 21:48:36 2020	(r358184)
@@ -35,6 +35,10 @@
 #include <stdio.h>
 #include <errno.h>
 
+#include "bhyverun.h"
+#include "debug.h"
+#include "net_utils.h"
+
 int
 net_parsemac(char *mac_str, uint8_t *mac_addr)
 {
@@ -49,7 +53,7 @@ net_parsemac(char *mac_str, uint8_t *mac_addr)
 
                 if (ea == NULL || ETHER_IS_MULTICAST(ea->octet) ||
                     memcmp(ea->octet, zero_addr, ETHER_ADDR_LEN) == 0) {
-			fprintf(stderr, "Invalid MAC %s\n", mac_str);
+			EPRINTLN("Invalid MAC %s", mac_str);
                         return (EINVAL);
                 } else
                         memcpy(mac_addr, ea->octet, ETHER_ADDR_LEN);

Modified: stable/12/usr.sbin/bhyve/pci_e82545.c
==============================================================================
--- stable/12/usr.sbin/bhyve/pci_e82545.c	Thu Feb 20 21:29:59 2020	(r358183)
+++ stable/12/usr.sbin/bhyve/pci_e82545.c	Thu Feb 20 21:48:36 2020	(r358184)
@@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$");
 #include "mii.h"
 
 #include "bhyverun.h"
+#include "debug.h"
 #include "pci_emul.h"
 #include "mevent.h"
 #include "net_utils.h"
@@ -229,8 +230,8 @@ struct ck_info {
  * Debug printf
  */
 static int e82545_debug = 0;
-#define DPRINTF(msg,params...) if (e82545_debug) fprintf(stderr, "e82545: " msg, params)
-#define WPRINTF(msg,params...) fprintf(stderr, "e82545: " msg, params)
+#define WPRINTF(msg,params...) PRINTLN("e82545: " msg, params)
+#define DPRINTF(msg,params...) if (e82545_debug) WPRINTF(msg, params)
 
 #define	MIN(a,b) (((a)<(b))?(a):(b))
 #define	MAX(a,b) (((a)>(b))?(a):(b))
@@ -399,21 +400,21 @@ e82545_init_eeprom(struct e82545_softc *sc)
 	}
 	checksum = NVM_SUM - checksum;
 	sc->eeprom_data[NVM_CHECKSUM_REG] = checksum;
-	DPRINTF("eeprom checksum: 0x%x\r\n", checksum);
+	DPRINTF("eeprom checksum: 0x%x", checksum);
 }
 
 static void
 e82545_write_mdi(struct e82545_softc *sc, uint8_t reg_addr,
 			uint8_t phy_addr, uint32_t data)
 {
-	DPRINTF("Write mdi reg:0x%x phy:0x%x data: 0x%x\r\n", reg_addr, phy_addr, data);
+	DPRINTF("Write mdi reg:0x%x phy:0x%x data: 0x%x", reg_addr, phy_addr, data);
 }
 
 static uint32_t
 e82545_read_mdi(struct e82545_softc *sc, uint8_t reg_addr,
 			uint8_t phy_addr)
 {
-	//DPRINTF("Read mdi reg:0x%x phy:0x%x\r\n", reg_addr, phy_addr);
+	//DPRINTF("Read mdi reg:0x%x phy:0x%x", reg_addr, phy_addr);
 	switch (reg_addr) {
 	case PHY_STATUS:
 		return (MII_SR_LINK_STATUS | MII_SR_AUTONEG_CAPS |
@@ -430,7 +431,7 @@ e82545_read_mdi(struct e82545_softc *sc, uint8_t reg_a
 	case PHY_ID2:
 		return (M88E1011_I_PHY_ID | E82545_REVISION_4) & 0xFFFF;
 	default:
-		DPRINTF("Unknown mdi read reg:0x%x phy:0x%x\r\n", reg_addr, phy_addr);
+		DPRINTF("Unknown mdi read reg:0x%x phy:0x%x", reg_addr, phy_addr);
 		return 0;
 	}
 	/* not reached */
@@ -442,13 +443,13 @@ e82545_eecd_strobe(struct e82545_softc *sc)
 	/* Microwire state machine */
 	/*
 	DPRINTF("eeprom state machine srtobe "
-		"0x%x 0x%x 0x%x 0x%x\r\n",
+		"0x%x 0x%x 0x%x 0x%x",
 		sc->nvm_mode, sc->nvm_bits,
 		sc->nvm_opaddr, sc->nvm_data);*/
 
 	if (sc->nvm_bits == 0) {
 		DPRINTF("eeprom state machine not expecting data! "
-			"0x%x 0x%x 0x%x 0x%x\r\n",
+			"0x%x 0x%x 0x%x 0x%x",
 			sc->nvm_mode, sc->nvm_bits,
 			sc->nvm_opaddr, sc->nvm_data);
 		return;
@@ -479,13 +480,13 @@ e82545_eecd_strobe(struct e82545_softc *sc)
 			uint16_t op = sc->nvm_opaddr & E82545_NVM_OPCODE_MASK;
 			uint16_t addr = sc->nvm_opaddr & E82545_NVM_ADDR_MASK;
 			if (op != E82545_NVM_OPCODE_WRITE) {
-				DPRINTF("Illegal eeprom write op 0x%x\r\n",
+				DPRINTF("Illegal eeprom write op 0x%x",
 					sc->nvm_opaddr);
 			} else if (addr >= E82545_NVM_EEPROM_SIZE) {
-				DPRINTF("Illegal eeprom write addr 0x%x\r\n",
+				DPRINTF("Illegal eeprom write addr 0x%x",
 					sc->nvm_opaddr);
 			} else {
-				DPRINTF("eeprom write eeprom[0x%x] = 0x%x\r\n",
+				DPRINTF("eeprom write eeprom[0x%x] = 0x%x",
 				addr, sc->nvm_data);
 				sc->eeprom_data[addr] = sc->nvm_data;
 			}
@@ -503,7 +504,7 @@ e82545_eecd_strobe(struct e82545_softc *sc)
 			uint16_t op = sc->nvm_opaddr & E82545_NVM_OPCODE_MASK;
 			switch (op) {
 			case E82545_NVM_OPCODE_EWEN:
-				DPRINTF("eeprom write enable: 0x%x\r\n",
+				DPRINTF("eeprom write enable: 0x%x",
 					sc->nvm_opaddr);
 				/* back to opcode mode */
 				sc->nvm_opaddr = 0;
@@ -518,10 +519,10 @@ e82545_eecd_strobe(struct e82545_softc *sc)
 				sc->nvm_bits = E82545_NVM_DATA_BITS;
 				if (addr < E82545_NVM_EEPROM_SIZE) {
 					sc->nvm_data = sc->eeprom_data[addr];
-					DPRINTF("eeprom read: eeprom[0x%x] = 0x%x\r\n",
+					DPRINTF("eeprom read: eeprom[0x%x] = 0x%x",
 						addr, sc->nvm_data);
 				} else {
-					DPRINTF("eeprom illegal read: 0x%x\r\n",
+					DPRINTF("eeprom illegal read: 0x%x",
 						sc->nvm_opaddr);
 					sc->nvm_data = 0;
 				}
@@ -533,7 +534,7 @@ e82545_eecd_strobe(struct e82545_softc *sc)
 				sc->nvm_data = 0;
 				break;
 			default:
-				DPRINTF("eeprom unknown op: 0x%x\r\r",
+				DPRINTF("eeprom unknown op: 0x%x",
 					sc->nvm_opaddr);
 				/* back to opcode mode */
 				sc->nvm_opaddr = 0;
@@ -543,7 +544,7 @@ e82545_eecd_strobe(struct e82545_softc *sc)
 		}
 	} else {
 		DPRINTF("eeprom state machine wrong state! "
-			"0x%x 0x%x 0x%x 0x%x\r\n",
+			"0x%x 0x%x 0x%x 0x%x",
 			sc->nvm_mode, sc->nvm_bits,
 			sc->nvm_opaddr, sc->nvm_data);
 	}
@@ -558,7 +559,7 @@ e82545_itr_callback(int fd, enum ev_type type, void *p
 	pthread_mutex_lock(&sc->esc_mtx);
 	new = sc->esc_ICR & sc->esc_IMS;
 	if (new && !sc->esc_irq_asserted) {
-		DPRINTF("itr callback: lintr assert %x\r\n", new);
+		DPRINTF("itr callback: lintr assert %x", new);
 		sc->esc_irq_asserted = 1;
 		pci_lintr_assert(sc->esc_pi);
 	} else {
@@ -573,7 +574,7 @@ e82545_icr_assert(struct e82545_softc *sc, uint32_t bi
 {
 	uint32_t new;
 
-	DPRINTF("icr assert: 0x%x\r\n", bits);
+	DPRINTF("icr assert: 0x%x", bits);
 	
 	/*
 	 * An interrupt is only generated if bits are set that
@@ -584,11 +585,11 @@ e82545_icr_assert(struct e82545_softc *sc, uint32_t bi
 	sc->esc_ICR |= bits;
 
 	if (new == 0) {
-		DPRINTF("icr assert: masked %x, ims %x\r\n", new, sc->esc_IMS);
+		DPRINTF("icr assert: masked %x, ims %x", new, sc->esc_IMS);
 	} else if (sc->esc_mevpitr != NULL) {
-		DPRINTF("icr assert: throttled %x, ims %x\r\n", new, sc->esc_IMS);
+		DPRINTF("icr assert: throttled %x, ims %x", new, sc->esc_IMS);
 	} else if (!sc->esc_irq_asserted) {
-		DPRINTF("icr assert: lintr assert %x\r\n", new);
+		DPRINTF("icr assert: lintr assert %x", new);
 		sc->esc_irq_asserted = 1;
 		pci_lintr_assert(sc->esc_pi);
 		if (sc->esc_ITR != 0) {
@@ -612,11 +613,11 @@ e82545_ims_change(struct e82545_softc *sc, uint32_t bi
 	sc->esc_IMS |= bits;
 
 	if (new == 0) {
-		DPRINTF("ims change: masked %x, ims %x\r\n", new, sc->esc_IMS);
+		DPRINTF("ims change: masked %x, ims %x", new, sc->esc_IMS);
 	} else if (sc->esc_mevpitr != NULL) {
-		DPRINTF("ims change: throttled %x, ims %x\r\n", new, sc->esc_IMS);
+		DPRINTF("ims change: throttled %x, ims %x", new, sc->esc_IMS);
 	} else if (!sc->esc_irq_asserted) {
-		DPRINTF("ims change: lintr assert %x\n\r", new);
+		DPRINTF("ims change: lintr assert %x", new);
 		sc->esc_irq_asserted = 1;
 		pci_lintr_assert(sc->esc_pi);
 		if (sc->esc_ITR != 0) {
@@ -631,7 +632,7 @@ static void
 e82545_icr_deassert(struct e82545_softc *sc, uint32_t bits)
 {
 
-	DPRINTF("icr deassert: 0x%x\r\n", bits);
+	DPRINTF("icr deassert: 0x%x", bits);
 	sc->esc_ICR &= ~bits;
 
 	/*
@@ -639,7 +640,7 @@ e82545_icr_deassert(struct e82545_softc *sc, uint32_t 
 	 * was an asserted interrupt, clear it
 	 */
 	if (sc->esc_irq_asserted && !(sc->esc_ICR & sc->esc_IMS)) {
-		DPRINTF("icr deassert: lintr deassert %x\r\n", bits);
+		DPRINTF("icr deassert: lintr deassert %x", bits);
 		pci_lintr_deassert(sc->esc_pi);
 		sc->esc_irq_asserted = 0;
 	}
@@ -649,7 +650,7 @@ static void
 e82545_intr_write(struct e82545_softc *sc, uint32_t offset, uint32_t value)
 {
 
-	DPRINTF("intr_write: off %x, val %x\n\r", offset, value);
+	DPRINTF("intr_write: off %x, val %x", offset, value);
 	
 	switch (offset) {
 	case E1000_ICR:
@@ -683,7 +684,7 @@ e82545_intr_read(struct e82545_softc *sc, uint32_t off
 
 	retval = 0;
 
-	DPRINTF("intr_read: off %x\n\r", offset);
+	DPRINTF("intr_read: off %x", offset);
 	
 	switch (offset) {
 	case E1000_ICR:
@@ -717,7 +718,7 @@ e82545_devctl(struct e82545_softc *sc, uint32_t val)
 	sc->esc_CTRL = val & ~E1000_CTRL_RST;
 
 	if (val & E1000_CTRL_RST) {
-		DPRINTF("e1k: s/w reset, ctl %x\n", val);
+		DPRINTF("e1k: s/w reset, ctl %x", val);
 		e82545_reset(sc, 1);
 	}
 	/* XXX check for phy reset ? */
@@ -746,7 +747,7 @@ e82545_rx_ctl(struct e82545_softc *sc, uint32_t val)
 	/* Save RCTL after stripping reserved bits 31:27,24,21,14,11:10,0 */
 	sc->esc_RCTL = val & ~0xF9204c01;
 
-	DPRINTF("rx_ctl - %s RCTL %x, val %x\n",
+	DPRINTF("rx_ctl - %s RCTL %x, val %x",
 		on ? "on" : "off", sc->esc_RCTL, val);
 
 	/* state change requested */
@@ -836,10 +837,10 @@ e82545_rx_callback(int fd, enum ev_type type, void *pa
 	uint16_t *tp, tag, head;
 
 	pthread_mutex_lock(&sc->esc_mtx);
-	DPRINTF("rx_run: head %x, tail %x\r\n", sc->esc_RDH, sc->esc_RDT);
+	DPRINTF("rx_run: head %x, tail %x", sc->esc_RDH, sc->esc_RDT);
 
 	if (!sc->esc_rx_enabled || sc->esc_rx_loopback) {
-		DPRINTF("rx disabled (!%d || %d) -- packet(s) dropped\r\n",
+		DPRINTF("rx disabled (!%d || %d) -- packet(s) dropped",
 		    sc->esc_rx_enabled, sc->esc_rx_loopback);
 		while (netbe_rx_discard(sc->esc_be) > 0) {
 		}
@@ -852,7 +853,7 @@ e82545_rx_callback(int fd, enum ev_type type, void *pa
 	head = sc->esc_RDH;
 	left = (size + sc->esc_RDT - head) % size;
 	if (left < maxpktdesc) {
-		DPRINTF("rx overflow (%d < %d) -- packet(s) dropped\r\n",
+		DPRINTF("rx overflow (%d < %d) -- packet(s) dropped",
 		    left, maxpktdesc);
 		while (netbe_rx_discard(sc->esc_be) > 0) {
 		}
@@ -873,7 +874,7 @@ e82545_rx_callback(int fd, enum ev_type type, void *pa
 		}
 		len = netbe_recv(sc->esc_be, vec, maxpktdesc);
 		if (len <= 0) {
-			DPRINTF("netbe_recv() returned %d\n", len);
+			DPRINTF("netbe_recv() returned %d", len);
 			goto done;
 		}
 
@@ -888,7 +889,7 @@ e82545_rx_callback(int fd, enum ev_type type, void *pa
 			len += ETHER_CRC_LEN;
 		n = (len + bufsz - 1) / bufsz;
 
-		DPRINTF("packet read %d bytes, %d segs, head %d\r\n",
+		DPRINTF("packet read %d bytes, %d segs, head %d",
 		    len, n, head);
 
 		/* Apply VLAN filter. */
@@ -898,9 +899,9 @@ e82545_rx_callback(int fd, enum ev_type type, void *pa
 			tag = ntohs(tp[1]) & 0x0fff;
 			if ((sc->esc_fvlan[tag >> 5] &
 			    (1 << (tag & 0x1f))) != 0) {
-				DPRINTF("known VLAN %d\r\n", tag);
+				DPRINTF("known VLAN %d", tag);
 			} else {
-				DPRINTF("unknown VLAN %d\r\n", tag);
+				DPRINTF("unknown VLAN %d", tag);
 				n = 0;
 				continue;
 			}
@@ -951,7 +952,7 @@ done:
 	if (cause != 0)
 		e82545_icr_assert(sc, cause);
 done1:
-	DPRINTF("rx_run done: head %x, tail %x\r\n", sc->esc_RDH, sc->esc_RDT);
+	DPRINTF("rx_run done: head %x, tail %x", sc->esc_RDH, sc->esc_RDT);
 	pthread_mutex_unlock(&sc->esc_mtx);
 }
 
@@ -1037,7 +1038,7 @@ e82545_transmit_checksum(struct iovec *iov, int iovcnt
 	uint16_t cksum;
 	int cklen;
 
-	DPRINTF("tx cksum: iovcnt/s/off/len %d/%d/%d/%d\r\n",
+	DPRINTF("tx cksum: iovcnt/s/off/len %d/%d/%d/%d",
 	    iovcnt, ck->ck_start, ck->ck_off, ck->ck_len);
 	cklen = ck->ck_len ? ck->ck_len - ck->ck_start + 1 : INT_MAX;
 	cksum = e82545_iov_checksum(iov, iovcnt, ck->ck_start, cklen);
@@ -1108,14 +1109,14 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head
 			switch (dtype) {
 			case E1000_TXD_TYP_C:
 				DPRINTF("tx ctxt desc idx %d: %016jx "
-				    "%08x%08x\r\n",
+				    "%08x%08x",
 				    head, dsc->td.buffer_addr,
 				    dsc->td.upper.data, dsc->td.lower.data);
 				/* Save context and return */
 				sc->esc_txctx = dsc->cd;
 				goto done;
 			case E1000_TXD_TYP_L:
-				DPRINTF("tx legacy desc idx %d: %08x%08x\r\n",
+				DPRINTF("tx legacy desc idx %d: %08x%08x",
 				    head, dsc->td.upper.data, dsc->td.lower.data);
 				/*
 				 * legacy cksum start valid in first descriptor
@@ -1124,7 +1125,7 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head
 				ckinfo[0].ck_start = dsc->td.upper.fields.css;
 				break;
 			case E1000_TXD_TYP_D:
-				DPRINTF("tx data desc idx %d: %08x%08x\r\n",
+				DPRINTF("tx data desc idx %d: %08x%08x",
 				    head, dsc->td.upper.data, dsc->td.lower.data);
 				ntype = dtype;
 				break;
@@ -1134,7 +1135,7 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head
 		} else {
 			/* Descriptor type must be consistent */
 			assert(dtype == ntype);
-			DPRINTF("tx next desc idx %d: %08x%08x\r\n",
+			DPRINTF("tx next desc idx %d: %08x%08x",
 			    head, dsc->td.upper.data, dsc->td.lower.data);
 		}
 
@@ -1201,7 +1202,7 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head
 	}
 
 	if (iovcnt > I82545_MAX_TXSEGS) {
-		WPRINTF("tx too many descriptors (%d > %d) -- dropped\r\n",
+		WPRINTF("tx too many descriptors (%d > %d) -- dropped",
 		    iovcnt, I82545_MAX_TXSEGS);
 		goto done;
 	}
@@ -1232,7 +1233,7 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head
 		 * the Intel 82576EB (Rev 2.63) datasheet.
 		 */
 		if (hdrlen > 240) {
-			WPRINTF("TSO hdrlen too large: %d\r\n", hdrlen);
+			WPRINTF("TSO hdrlen too large: %d", hdrlen);
 			goto done;
 		}
 
@@ -1248,7 +1249,7 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head
 		 */
 		if (vlen != 0 && hdrlen < ETHER_ADDR_LEN*2) {
 			WPRINTF("TSO hdrlen too small for vlan insertion "
-			    "(%d vs %d) -- dropped\r\n", hdrlen,
+			    "(%d vs %d) -- dropped", hdrlen,
 			    ETHER_ADDR_LEN*2);
 			goto done;
 		}
@@ -1270,7 +1271,7 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head
 		if (hdrlen < ckinfo[0].ck_start + 6 ||
 		    hdrlen < ckinfo[0].ck_off + 2) {
 			WPRINTF("TSO hdrlen too small for IP fields (%d) "
-			    "-- dropped\r\n", hdrlen);
+			    "-- dropped", hdrlen);
 			goto done;
 		}
 		if (sc->esc_txctx.cmd_and_length & E1000_TXD_CMD_TCP) {
@@ -1278,13 +1279,13 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head
 			    (ckinfo[1].ck_valid &&
 			    hdrlen < ckinfo[1].ck_off + 2)) {
 				WPRINTF("TSO hdrlen too small for TCP fields "
-				    "(%d) -- dropped\r\n", hdrlen);
+				    "(%d) -- dropped", hdrlen);
 				goto done;
 			}
 		} else {
 			if (hdrlen < ckinfo[1].ck_start + 8) {
 				WPRINTF("TSO hdrlen too small for UDP fields "
-				    "(%d) -- dropped\r\n", hdrlen);
+				    "(%d) -- dropped", hdrlen);
 				goto done;
 			}
 		}
@@ -1349,7 +1350,7 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head
 	tcp = (sc->esc_txctx.cmd_and_length & E1000_TXD_CMD_TCP) != 0;
 	mss = sc->esc_txctx.tcp_seg_setup.fields.mss;
 	paylen = (sc->esc_txctx.cmd_and_length & 0x000fffff);
-	DPRINTF("tx %s segmentation offload %d+%d/%d bytes %d iovs\r\n",
+	DPRINTF("tx %s segmentation offload %d+%d/%d bytes %d iovs",
 	    tcp ? "TCP" : "UDP", hdrlen, paylen, mss, iovcnt);
 	ipid = ntohs(*(uint16_t *)&hdr[ckinfo[0].ck_start + 4]);
 	tcpseq = 0;
@@ -1380,7 +1381,7 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head
 			} else
 				pvoff += nnow;
 		}
-		DPRINTF("tx segment %d %d+%d bytes %d iovs\r\n",
+		DPRINTF("tx segment %d %d+%d bytes %d iovs",
 		    seg, hdrlen, now, tiovcnt);
 
 		/* Update IP header. */
@@ -1447,7 +1448,7 @@ e82545_tx_run(struct e82545_softc *sc)
 	head = sc->esc_TDH;
 	tail = sc->esc_TDT;
 	size = sc->esc_TDLEN / 16;
-	DPRINTF("tx_run: head %x, rhead %x, tail %x\r\n",
+	DPRINTF("tx_run: head %x, rhead %x, tail %x",
 	    sc->esc_TDH, sc->esc_TDHr, sc->esc_TDT);
 
 	pthread_mutex_unlock(&sc->esc_mtx);
@@ -1471,7 +1472,7 @@ e82545_tx_run(struct e82545_softc *sc)
 	if (cause)
 		e82545_icr_assert(sc, cause);
 
-	DPRINTF("tx_run done: head %x, rhead %x, tail %x\r\n",
+	DPRINTF("tx_run done: head %x, rhead %x, tail %x",
 	    sc->esc_TDH, sc->esc_TDHr, sc->esc_TDT);
 }
 
@@ -1598,10 +1599,10 @@ e82545_write_register(struct e82545_softc *sc, uint32_
 	int ridx;
 	
 	if (offset & 0x3) {
-		DPRINTF("Unaligned register write offset:0x%x value:0x%x\r\n", offset, value);
+		DPRINTF("Unaligned register write offset:0x%x value:0x%x", offset, value);
 		return;
 	}
-	DPRINTF("Register write: 0x%x value: 0x%x\r\n", offset, value);
+	DPRINTF("Register write: 0x%x value: 0x%x", offset, value);
 
 	switch (offset) {
 	case E1000_CTRL:
@@ -1745,7 +1746,7 @@ e82545_write_register(struct e82545_softc *sc, uint32_
 		break;		
 	case E1000_EECD:
 	{
-		//DPRINTF("EECD write 0x%x -> 0x%x\r\n", sc->eeprom_control, value);
+		//DPRINTF("EECD write 0x%x -> 0x%x", sc->eeprom_control, value);
 		/* edge triggered low->high */
 		uint32_t eecd_strobe = ((sc->eeprom_control & E1000_EECD_SK) ?
 			0 : (value & E1000_EECD_SK));
@@ -1773,7 +1774,7 @@ e82545_write_register(struct e82545_softc *sc, uint32_
 		sc->mdi_control =
 			(value & ~(E1000_MDIC_ERROR|E1000_MDIC_DEST));
 		if ((value & E1000_MDIC_READY) != 0) {
-			DPRINTF("Incorrect MDIC ready bit: 0x%x\r\n", value);
+			DPRINTF("Incorrect MDIC ready bit: 0x%x", value);
 			return;
 		}
 		switch (value & E82545_MDIC_OP_MASK) {
@@ -1786,7 +1787,7 @@ e82545_write_register(struct e82545_softc *sc, uint32_
 				value & E82545_MDIC_DATA_MASK);
 			break;
 		default:
-			DPRINTF("Unknown MDIC op: 0x%x\r\n", value);
+			DPRINTF("Unknown MDIC op: 0x%x", value);
 			return;
 		}
 		/* TODO: barrier? */
@@ -1800,7 +1801,7 @@ e82545_write_register(struct e82545_softc *sc, uint32_
 	case E1000_STATUS: 
 		return;
 	default:
-		DPRINTF("Unknown write register: 0x%x value:%x\r\n", offset, value);
+		DPRINTF("Unknown write register: 0x%x value:%x", offset, value);
 		return;
 	}
 }
@@ -1812,11 +1813,11 @@ e82545_read_register(struct e82545_softc *sc, uint32_t
 	int ridx;
 
 	if (offset & 0x3) {
-		DPRINTF("Unaligned register read offset:0x%x\r\n", offset);
+		DPRINTF("Unaligned register read offset:0x%x", offset);
 		return 0;
 	}
 
-	DPRINTF("Register read: 0x%x\r\n", offset);
+	DPRINTF("Register read: 0x%x", offset);
 
 	switch (offset) {
 	case E1000_CTRL:
@@ -1941,7 +1942,7 @@ e82545_read_register(struct e82545_softc *sc, uint32_t
 		retval = sc->esc_fvlan[(offset - E1000_VFTA) >> 2];
 		break;		
 	case E1000_EECD:
-		//DPRINTF("EECD read %x\r\n", sc->eeprom_control);
+		//DPRINTF("EECD read %x", sc->eeprom_control);
 		retval = sc->eeprom_control;
 		break;
 	case E1000_MDIC:
@@ -2071,7 +2072,7 @@ e82545_read_register(struct e82545_softc *sc, uint32_t
 		retval = 0;
 		break;
 	default:
-		DPRINTF("Unknown read register: 0x%x\r\n", offset);
+		DPRINTF("Unknown read register: 0x%x", offset);
 		retval = 0;
 		break;
 	}
@@ -2085,7 +2086,7 @@ e82545_write(struct vmctx *ctx, int vcpu, struct pci_d
 {
 	struct e82545_softc *sc;
 
-	//DPRINTF("Write bar:%d offset:0x%lx value:0x%lx size:%d\r\n", baridx, offset, value, size);
+	//DPRINTF("Write bar:%d offset:0x%lx value:0x%lx size:%d", baridx, offset, value, size);
 
 	sc = pi->pi_arg;
 
@@ -2096,33 +2097,33 @@ e82545_write(struct vmctx *ctx, int vcpu, struct pci_d
 		switch (offset) {
 		case E82545_IOADDR:
 			if (size != 4) {
-				DPRINTF("Wrong io addr write sz:%d value:0x%lx\r\n", size, value);
+				DPRINTF("Wrong io addr write sz:%d value:0x%lx", size, value);
 			} else
 				sc->io_addr = (uint32_t)value;
 			break;
 		case E82545_IODATA:
 			if (size != 4) {
-				DPRINTF("Wrong io data write size:%d value:0x%lx\r\n", size, value);
+				DPRINTF("Wrong io data write size:%d value:0x%lx", size, value);
 			} else if (sc->io_addr > E82545_IO_REGISTER_MAX) {
-				DPRINTF("Non-register io write addr:0x%x value:0x%lx\r\n", sc->io_addr, value);
+				DPRINTF("Non-register io write addr:0x%x value:0x%lx", sc->io_addr, value);
 			} else
 				e82545_write_register(sc, sc->io_addr,
 						      (uint32_t)value);
 			break;
 		default:
-			DPRINTF("Unknown io bar write offset:0x%lx value:0x%lx size:%d\r\n", offset, value, size);
+			DPRINTF("Unknown io bar write offset:0x%lx value:0x%lx size:%d", offset, value, size);
 			break;
 		}
 		break;
 	case E82545_BAR_REGISTER:
 		if (size != 4) {
-			DPRINTF("Wrong register write size:%d offset:0x%lx value:0x%lx\r\n", size, offset, value);
+			DPRINTF("Wrong register write size:%d offset:0x%lx value:0x%lx", size, offset, value);
 		} else
 			e82545_write_register(sc, (uint32_t)offset,
 					      (uint32_t)value);
 		break;
 	default:
-		DPRINTF("Unknown write bar:%d off:0x%lx val:0x%lx size:%d\r\n",
+		DPRINTF("Unknown write bar:%d off:0x%lx val:0x%lx size:%d",
 			baridx, offset, value, size);
 	}
 
@@ -2136,7 +2137,7 @@ e82545_read(struct vmctx *ctx, int vcpu, struct pci_de
 	struct e82545_softc *sc;
 	uint64_t retval;
 	
-	//DPRINTF("Read  bar:%d offset:0x%lx size:%d\r\n", baridx, offset, size);
+	//DPRINTF("Read  bar:%d offset:0x%lx size:%d", baridx, offset, size);
 	sc = pi->pi_arg;
 	retval = 0;
 
@@ -2147,35 +2148,35 @@ e82545_read(struct vmctx *ctx, int vcpu, struct pci_de
 		switch (offset) {
 		case E82545_IOADDR:
 			if (size != 4) {
-				DPRINTF("Wrong io addr read sz:%d\r\n", size);
+				DPRINTF("Wrong io addr read sz:%d", size);
 			} else
 				retval = sc->io_addr;
 			break;
 		case E82545_IODATA:
 			if (size != 4) {
-				DPRINTF("Wrong io data read sz:%d\r\n", size);
+				DPRINTF("Wrong io data read sz:%d", size);
 			}
 			if (sc->io_addr > E82545_IO_REGISTER_MAX) {
-				DPRINTF("Non-register io read addr:0x%x\r\n",
+				DPRINTF("Non-register io read addr:0x%x",
 					sc->io_addr);
 			} else
 				retval = e82545_read_register(sc, sc->io_addr);
 			break;
 		default:
-			DPRINTF("Unknown io bar read offset:0x%lx size:%d\r\n",
+			DPRINTF("Unknown io bar read offset:0x%lx size:%d",
 				offset, size);
 			break;
 		}
 		break;
 	case E82545_BAR_REGISTER:
 		if (size != 4) {
-			DPRINTF("Wrong register read size:%d offset:0x%lx\r\n",
+			DPRINTF("Wrong register read size:%d offset:0x%lx",
 				size, offset);
 		} else
 			retval = e82545_read_register(sc, (uint32_t)offset);
 		break;
 	default:
-		DPRINTF("Unknown read bar:%d offset:0x%lx size:%d\r\n",
+		DPRINTF("Unknown read bar:%d offset:0x%lx size:%d",
 			baridx, offset, size);
 		break;
 	}
@@ -2282,7 +2283,7 @@ e82545_init(struct vmctx *ctx, struct pci_devinst *pi,
 	char *vtopts;
 	int mac_provided;
 
-	DPRINTF("Loading with options: %s\r\n", opts);
+	DPRINTF("Loading with options: %s", opts);
 
 	/* Setup our softc */
 	sc = calloc(1, sizeof(*sc));

Modified: stable/12/usr.sbin/bhyve/pci_emul.c
==============================================================================
--- stable/12/usr.sbin/bhyve/pci_emul.c	Thu Feb 20 21:29:59 2020	(r358183)
+++ stable/12/usr.sbin/bhyve/pci_emul.c	Thu Feb 20 21:48:36 2020	(r358184)
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
 
 #include "acpi.h"
 #include "bhyverun.h"
+#include "debug.h"
 #include "inout.h"
 #include "ioapic.h"
 #include "mem.h"
@@ -162,7 +163,7 @@ static void
 pci_parse_slot_usage(char *aopt)
 {
 
-	fprintf(stderr, "Invalid PCI slot info field \"%s\"\n", aopt);
+	EPRINTLN("Invalid PCI slot info field \"%s\"", aopt);
 }
 
 int
@@ -215,13 +216,13 @@ pci_parse_slot(char *opt)
 	si = &bi->slotinfo[snum];
 
 	if (si->si_funcs[fnum].fi_name != NULL) {
-		fprintf(stderr, "pci slot %d:%d already occupied!\n",
+		EPRINTLN("pci slot %d:%d already occupied!",
 			snum, fnum);
 		goto done;
 	}
 
 	if (pci_emul_finddev(emul) == NULL) {
-		fprintf(stderr, "pci slot %d:%d: unknown device \"%s\"\n",
+		EPRINTLN("pci slot %d:%d: unknown device \"%s\"",
 			snum, fnum, emul);
 		goto done;
 	}

Modified: stable/12/usr.sbin/bhyve/pci_fbuf.c
==============================================================================
--- stable/12/usr.sbin/bhyve/pci_fbuf.c	Thu Feb 20 21:29:59 2020	(r358183)
+++ stable/12/usr.sbin/bhyve/pci_fbuf.c	Thu Feb 20 21:48:36 2020	(r358184)
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
 
 #include "bhyvegc.h"
 #include "bhyverun.h"
+#include "debug.h"
 #include "console.h"
 #include "inout.h"
 #include "pci_emul.h"
@@ -63,7 +64,7 @@ __FBSDID("$FreeBSD$");
 static int fbuf_debug = 1;
 #define	DEBUG_INFO	1
 #define	DEBUG_VERBOSE	4
-#define	DPRINTF(level, params)  if (level <= fbuf_debug) printf params

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002202148.01KLmag8021607>