aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Levon <john.levon@nutanix.com>2021-04-07 09:54:00 +0100
committerGitHub <noreply@github.com>2021-04-07 09:54:00 +0100
commit293e1a92ffdbd794c3e23f528589e532b9b1e73a (patch)
treeb84f7dfabdf0c1d19119e9f537ffe3557eaed459
parented6deba2b8a496e5c3047d3d46208109ac762e4b (diff)
downloadlibvfio-user-293e1a92ffdbd794c3e23f528589e532b9b1e73a.zip
libvfio-user-293e1a92ffdbd794c3e23f528589e532b9b1e73a.tar.gz
libvfio-user-293e1a92ffdbd794c3e23f528589e532b9b1e73a.tar.bz2
clean up newlines in logs (#423)
vfu_log() and err() should not take newlines. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
-rw-r--r--include/libvfio-user.h6
-rw-r--r--lib/dma.c19
-rw-r--r--lib/dma.h4
-rw-r--r--lib/irq.c6
-rw-r--r--lib/pci.c52
-rw-r--r--lib/pci_caps.c70
-rw-r--r--samples/client.c6
-rw-r--r--samples/server.c14
8 files changed, 90 insertions, 87 deletions
diff --git a/include/libvfio-user.h b/include/libvfio-user.h
index 90dd21a..a43f38a 100644
--- a/include/libvfio-user.h
+++ b/include/libvfio-user.h
@@ -181,7 +181,8 @@ vfu_get_private(vfu_ctx_t *vfu_ctx);
typedef void (vfu_log_fn_t)(vfu_ctx_t *vfu_ctx, int level, const char *msg);
/**
- * Log to the logging function configured for this context.
+ * Log to the logging function configured for this context. The format should
+ * not include a new line.
*/
void
vfu_log(vfu_ctx_t *vfu_ctx, int level, const char *fmt, ...) \
@@ -192,6 +193,9 @@ vfu_log(vfu_ctx_t *vfu_ctx, int level, const char *fmt, ...) \
* @vfu_ctx: the libvfio-user context
* @log: logging function
* @level: logging level as defined in syslog(3)
+ *
+ * The log handler is expected to add a newline (that is, log messages do not
+ * include a newline).
*/
int
vfu_setup_log(vfu_ctx_t *vfu_ctx, vfu_log_fn_t *log, int level);
diff --git a/lib/dma.c b/lib/dma.c
index 4390b5a..34c8bec 100644
--- a/lib/dma.c
+++ b/lib/dma.c
@@ -103,7 +103,7 @@ MOCK_DEFINE(dma_controller_unmap_region)(dma_controller_t *dma,
err = munmap(region->info.mapping.iov_base, region->info.mapping.iov_len);
if (err != 0) {
vfu_log(dma->vfu_ctx, LOG_DEBUG, "failed to unmap fd=%d "
- "mapping=[%p, %p): %m\n",
+ "mapping=[%p, %p): %m",
region->fd, region->info.mapping.iov_base,
iov_end(&region->info.mapping));
}
@@ -111,7 +111,7 @@ MOCK_DEFINE(dma_controller_unmap_region)(dma_controller_t *dma,
assert(region->fd != -1);
if (close(region->fd) == -1) {
- vfu_log(dma->vfu_ctx, LOG_WARNING, "failed to close fd %d: %m\n",
+ vfu_log(dma->vfu_ctx, LOG_WARNING, "failed to close fd %d: %m",
region->fd);
}
}
@@ -157,7 +157,7 @@ MOCK_DEFINE(dma_controller_remove_region)(dma_controller_t *dma,
err = dma_unregister(data, &region->info);
if (err != 0) {
vfu_log(dma->vfu_ctx, LOG_ERR,
- "failed to dma_unregister() DMA region [%p, %p): %s\n",
+ "failed to dma_unregister() DMA region [%p, %p): %s",
region->info.iova.iov_base, iov_end(&region->info.iova),
strerror(err));
return err;
@@ -273,7 +273,7 @@ MOCK_DEFINE(dma_controller_add_region)(dma_controller_t *dma,
region->info.iova.iov_len == size) {
if (offset != region->offset) {
vfu_log(dma->vfu_ctx, LOG_ERR, "bad offset for new DMA region "
- "%s; existing=%#lx\n", rstr, region->offset);
+ "%s; existing=%#lx", rstr, region->offset);
goto err;
}
if (!fds_are_same_file(region->fd, fd)) {
@@ -284,7 +284,7 @@ MOCK_DEFINE(dma_controller_add_region)(dma_controller_t *dma,
* using a single fd.
*/
vfu_log(dma->vfu_ctx, LOG_ERR, "bad fd for new DMA region %s; "
- "existing=%d\n", rstr, region->fd);
+ "existing=%d", rstr, region->fd);
goto err;
}
if (region->info.prot != prot) {
@@ -309,8 +309,7 @@ MOCK_DEFINE(dma_controller_add_region)(dma_controller_t *dma,
if (dma->nregions == dma->max_regions) {
idx = dma->max_regions;
- vfu_log(dma->vfu_ctx, LOG_ERR, "hit max regions %d\n",
- dma->max_regions);
+ vfu_log(dma->vfu_ctx, LOG_ERR, "hit max regions %d", dma->max_regions);
goto err;
}
@@ -320,7 +319,7 @@ MOCK_DEFINE(dma_controller_add_region)(dma_controller_t *dma,
if (fd != -1) {
page_size = fd_get_blocksize(fd);
if (page_size < 0) {
- vfu_log(dma->vfu_ctx, LOG_ERR, "bad page size %d\n", page_size);
+ vfu_log(dma->vfu_ctx, LOG_ERR, "bad page size %d", page_size);
goto err;
}
}
@@ -340,12 +339,12 @@ MOCK_DEFINE(dma_controller_add_region)(dma_controller_t *dma,
if (ret != 0) {
vfu_log(dma->vfu_ctx, LOG_ERR,
- "failed to memory map DMA region %s: %s\n", rstr,
+ "failed to memory map DMA region %s: %s", rstr,
strerror(-ret));
if (close(region->fd) == -1) {
vfu_log(dma->vfu_ctx, LOG_WARNING,
- "failed to close fd %d: %m\n", region->fd);
+ "failed to close fd %d: %m", region->fd);
}
goto err;
}
diff --git a/lib/dma.h b/lib/dma.h
index 7ff5f13..dd8b3be 100644
--- a/lib/dma.h
+++ b/lib/dma.h
@@ -270,7 +270,7 @@ dma_map_sg(dma_controller_t *dma, const dma_sg_t *sg, struct iovec *iov,
return -EFAULT;
}
- vfu_log(dma->vfu_ctx, LOG_DEBUG, "map %p-%p\n",
+ vfu_log(dma->vfu_ctx, LOG_DEBUG, "map %p-%p",
sg->dma_addr + sg->offset,
sg->dma_addr + sg->offset + sg->length);
iov[i].iov_base = region->info.vaddr + sg[i].offset;
@@ -301,7 +301,7 @@ dma_unmap_sg(dma_controller_t *dma, const dma_sg_t *sg,
/* bad region */
continue;
}
- vfu_log(dma->vfu_ctx, LOG_DEBUG, "unmap %p-%p\n",
+ vfu_log(dma->vfu_ctx, LOG_DEBUG, "unmap %p-%p",
sg[i].dma_addr + sg[i].offset,
sg[i].dma_addr + sg[i].offset + sg[i].length);
r->refcnt--;
diff --git a/lib/irq.c b/lib/irq.c
index 9e0a428..bc48d4f 100644
--- a/lib/irq.c
+++ b/lib/irq.c
@@ -64,7 +64,7 @@ dev_get_irqinfo(vfu_ctx_t *vfu_ctx, struct vfio_irq_info *irq_info_in,
// Ensure provided argsz is sufficiently big and index is within bounds.
if ((irq_info_in->argsz < sizeof(struct vfio_irq_info)) ||
(irq_info_in->index >= VFU_DEV_NUM_IRQS)) {
- vfu_log(vfu_ctx, LOG_DEBUG, "bad irq_info (size=%d index=%d)\n",
+ vfu_log(vfu_ctx, LOG_DEBUG, "bad irq_info (size=%d index=%d)",
irq_info_in->argsz, irq_info_in->index);
return -EINVAL;
}
@@ -380,7 +380,7 @@ validate_irq_subindex(vfu_ctx_t *vfu_ctx, uint32_t subindex)
}
if ((subindex >= vfu_ctx->irqs->max_ivs)) {
- vfu_log(vfu_ctx, LOG_ERR, "bad IRQ %d, max=%d\n", subindex,
+ vfu_log(vfu_ctx, LOG_ERR, "bad IRQ %d, max=%d", subindex,
vfu_ctx->irqs->max_ivs);
return false;
}
@@ -398,7 +398,7 @@ vfu_irq_trigger(vfu_ctx_t *vfu_ctx, uint32_t subindex)
}
if (vfu_ctx->irqs->efds[subindex] == -1) {
- vfu_log(vfu_ctx, LOG_ERR, "no fd for interrupt %d\n", subindex);
+ vfu_log(vfu_ctx, LOG_ERR, "no fd for interrupt %d", subindex);
return ERROR_INT(ENOENT);
}
diff --git a/lib/pci.c b/lib/pci.c
index 0cb041b..39470d9 100644
--- a/lib/pci.c
+++ b/lib/pci.c
@@ -60,7 +60,7 @@ pci_hdr_write_bar(vfu_ctx_t *vfu_ctx, uint16_t bar_index, const char *buf)
cfg_addr = *(uint32_t *) buf;
- vfu_log(vfu_ctx, LOG_DEBUG, "BAR%d addr 0x%x\n", bar_index, cfg_addr);
+ vfu_log(vfu_ctx, LOG_DEBUG, "BAR%d addr 0x%x", bar_index, cfg_addr);
if (cfg_addr == 0xffffffff) {
cfg_addr = ~(reg_info[bar_index].size) + 1;
@@ -87,7 +87,7 @@ handle_command_write(vfu_ctx_t *ctx, vfu_pci_config_space_t *pci,
assert(ctx != NULL);
if (count != 2) {
- vfu_log(ctx, LOG_ERR, "bad write command size %lu\n", count);
+ vfu_log(ctx, LOG_ERR, "bad write command size %lu", count);
return -EINVAL;
}
@@ -99,72 +99,72 @@ handle_command_write(vfu_ctx_t *ctx, vfu_pci_config_space_t *pci,
if ((v & PCI_COMMAND_IO) == PCI_COMMAND_IO) {
if (!pci->hdr.cmd.iose) {
pci->hdr.cmd.iose = 0x1;
- vfu_log(ctx, LOG_INFO, "I/O space enabled\n");
+ vfu_log(ctx, LOG_INFO, "I/O space enabled");
}
v &= ~PCI_COMMAND_IO;
} else {
if (pci->hdr.cmd.iose) {
pci->hdr.cmd.iose = 0x0;
- vfu_log(ctx, LOG_INFO, "I/O space disabled\n");
+ vfu_log(ctx, LOG_INFO, "I/O space disabled");
}
}
if ((v & PCI_COMMAND_MEMORY) == PCI_COMMAND_MEMORY) {
if (!pci->hdr.cmd.mse) {
pci->hdr.cmd.mse = 0x1;
- vfu_log(ctx, LOG_INFO, "memory space enabled\n");
+ vfu_log(ctx, LOG_INFO, "memory space enabled");
}
v &= ~PCI_COMMAND_MEMORY;
} else {
if (pci->hdr.cmd.mse) {
pci->hdr.cmd.mse = 0x0;
- vfu_log(ctx, LOG_INFO, "memory space disabled\n");
+ vfu_log(ctx, LOG_INFO, "memory space disabled");
}
}
if ((v & PCI_COMMAND_MASTER) == PCI_COMMAND_MASTER) {
if (!pci->hdr.cmd.bme) {
pci->hdr.cmd.bme = 0x1;
- vfu_log(ctx, LOG_INFO, "bus master enabled\n");
+ vfu_log(ctx, LOG_INFO, "bus master enabled");
}
v &= ~PCI_COMMAND_MASTER;
} else {
if (pci->hdr.cmd.bme) {
pci->hdr.cmd.bme = 0x0;
- vfu_log(ctx, LOG_INFO, "bus master disabled\n");
+ vfu_log(ctx, LOG_INFO, "bus master disabled");
}
}
if ((v & PCI_COMMAND_SERR) == PCI_COMMAND_SERR) {
if (!pci->hdr.cmd.see) {
pci->hdr.cmd.see = 0x1;
- vfu_log(ctx, LOG_INFO, "SERR# enabled\n");
+ vfu_log(ctx, LOG_INFO, "SERR# enabled");
}
v &= ~PCI_COMMAND_SERR;
} else {
if (pci->hdr.cmd.see) {
pci->hdr.cmd.see = 0x0;
- vfu_log(ctx, LOG_INFO, "SERR# disabled\n");
+ vfu_log(ctx, LOG_INFO, "SERR# disabled");
}
}
if ((v & PCI_COMMAND_INTX_DISABLE) == PCI_COMMAND_INTX_DISABLE) {
if (!pci->hdr.cmd.id) {
pci->hdr.cmd.id = 0x1;
- vfu_log(ctx, LOG_INFO, "INTx emulation disabled\n");
+ vfu_log(ctx, LOG_INFO, "INTx emulation disabled");
}
v &= ~PCI_COMMAND_INTX_DISABLE;
} else {
if (pci->hdr.cmd.id) {
pci->hdr.cmd.id = 0x0;
- vfu_log(ctx, LOG_INFO, "INTx emulation enabled\n");
+ vfu_log(ctx, LOG_INFO, "INTx emulation enabled");
}
}
if ((v & PCI_COMMAND_INVALIDATE) == PCI_COMMAND_INVALIDATE) {
if (!pci->hdr.cmd.mwie) {
pci->hdr.cmd.mwie = 1U;
- vfu_log(ctx, LOG_INFO, "memory write and invalidate enabled\n");
+ vfu_log(ctx, LOG_INFO, "memory write and invalidate enabled");
}
v &= ~PCI_COMMAND_INVALIDATE;
} else {
@@ -175,12 +175,12 @@ handle_command_write(vfu_ctx_t *ctx, vfu_pci_config_space_t *pci,
}
if ((v & PCI_COMMAND_VGA_PALETTE) == PCI_COMMAND_VGA_PALETTE) {
- vfu_log(ctx, LOG_INFO, "enabling VGA palette snooping ignored\n");
+ vfu_log(ctx, LOG_INFO, "enabling VGA palette snooping ignored");
v &= ~PCI_COMMAND_VGA_PALETTE;
}
if (v != 0) {
- vfu_log(ctx, LOG_ERR, "unconsumed command flags %x\n", v);
+ vfu_log(ctx, LOG_ERR, "unconsumed command flags %x", v);
return -EINVAL;
}
@@ -197,20 +197,20 @@ handle_erom_write(vfu_ctx_t *ctx, vfu_pci_config_space_t *pci,
assert(pci != NULL);
if (count != 0x4) {
- vfu_log(ctx, LOG_ERR, "bad EROM count %lu\n", count);
+ vfu_log(ctx, LOG_ERR, "bad EROM count %lu", count);
return -EINVAL;
}
v = *(uint32_t*)buf;
if (v == (uint32_t)PCI_ROM_ADDRESS_MASK) {
- vfu_log(ctx, LOG_INFO, "write mask to EROM ignored\n");
+ vfu_log(ctx, LOG_INFO, "write mask to EROM ignored");
} else if (v == 0) {
- vfu_log(ctx, LOG_INFO, "cleared EROM\n");
+ vfu_log(ctx, LOG_INFO, "cleared EROM");
pci->hdr.erom = 0;
} else if (v == (uint32_t)~PCI_ROM_ADDRESS_ENABLE) {
- vfu_log(ctx, LOG_INFO, "EROM disable ignored\n");
+ vfu_log(ctx, LOG_INFO, "EROM disable ignored");
} else {
- vfu_log(ctx, LOG_ERR, "bad write to EROM 0x%x bytes\n", v);
+ vfu_log(ctx, LOG_ERR, "bad write to EROM 0x%x bytes", v);
return -EINVAL;
}
return 0;
@@ -232,19 +232,19 @@ pci_hdr_write(vfu_ctx_t *vfu_ctx, const char *buf, size_t count, loff_t offset)
ret = handle_command_write(vfu_ctx, cfg_space, buf, count);
break;
case PCI_STATUS:
- vfu_log(vfu_ctx, LOG_INFO, "write to status ignored\n");
+ vfu_log(vfu_ctx, LOG_INFO, "write to status ignored");
break;
case PCI_INTERRUPT_PIN:
- vfu_log(vfu_ctx, LOG_ERR, "attempt to write read-only field IPIN\n");
+ vfu_log(vfu_ctx, LOG_ERR, "attempt to write read-only field IPIN");
ret = -EINVAL;
break;
case PCI_INTERRUPT_LINE:
cfg_space->hdr.intr.iline = buf[0];
- vfu_log(vfu_ctx, LOG_DEBUG, "ILINE=%0x\n", cfg_space->hdr.intr.iline);
+ vfu_log(vfu_ctx, LOG_DEBUG, "ILINE=%0x", cfg_space->hdr.intr.iline);
break;
case PCI_LATENCY_TIMER:
cfg_space->hdr.mlt = (uint8_t)buf[0];
- vfu_log(vfu_ctx, LOG_INFO, "set to latency timer to %hhx\n",
+ vfu_log(vfu_ctx, LOG_INFO, "set to latency timer to %hhx",
cfg_space->hdr.mlt);
break;
case PCI_BASE_ADDRESS_0:
@@ -259,7 +259,7 @@ pci_hdr_write(vfu_ctx_t *vfu_ctx, const char *buf, size_t count, loff_t offset)
ret = handle_erom_write(vfu_ctx, cfg_space, buf, count);
break;
default:
- vfu_log(vfu_ctx, LOG_INFO, "PCI config write %#lx-%#lx not handled\n",
+ vfu_log(vfu_ctx, LOG_INFO, "PCI config write %#lx-%#lx not handled",
offset, offset + count);
ret = -EINVAL;
}
@@ -316,7 +316,7 @@ pci_nonstd_access(vfu_ctx_t *vfu_ctx, char *buf, size_t count,
if (is_write) {
vfu_log(vfu_ctx, LOG_ERR, "no callback for write to config space "
- "offset %lu size %zu\n", offset, count);
+ "offset %lu size %zu", offset, count);
return -EINVAL;
}
diff --git a/lib/pci_caps.c b/lib/pci_caps.c
index 58165c7..7ea8be2 100644
--- a/lib/pci_caps.c
+++ b/lib/pci_caps.c
@@ -88,7 +88,7 @@ cap_size(vfu_ctx_t *vfu_ctx, void *data, bool extended)
case PCI_EXT_CAP_ID_VNDR:
return ((struct pcie_ext_cap_vsc_hdr *)data)->len;
default:
- vfu_log(vfu_ctx, LOG_ERR, "invalid cap id %u\n", id);
+ vfu_log(vfu_ctx, LOG_ERR, "invalid cap id %u", id);
abort();
}
} else {
@@ -104,7 +104,7 @@ cap_size(vfu_ctx_t *vfu_ctx, void *data, bool extended)
case PCI_CAP_ID_VNDR:
return ((struct vsc *)data)->size;
default:
- vfu_log(vfu_ctx, LOG_ERR, "invalid cap id %u\n", id);
+ vfu_log(vfu_ctx, LOG_ERR, "invalid cap id %u", id);
abort();
}
}
@@ -115,16 +115,16 @@ handle_pmcs_write(vfu_ctx_t *vfu_ctx, struct pmcap *pm,
const struct pmcs *const pmcs)
{
if (pm->pmcs.ps != pmcs->ps) {
- vfu_log(vfu_ctx, LOG_DEBUG, "power state set to %#x\n", pmcs->ps);
+ vfu_log(vfu_ctx, LOG_DEBUG, "power state set to %#x", pmcs->ps);
}
if (pm->pmcs.pmee != pmcs->pmee) {
- vfu_log(vfu_ctx, LOG_DEBUG, "PME enable set to %#x\n", pmcs->pmee);
+ vfu_log(vfu_ctx, LOG_DEBUG, "PME enable set to %#x", pmcs->pmee);
}
if (pm->pmcs.dse != pmcs->dse) {
- vfu_log(vfu_ctx, LOG_DEBUG, "data select set to %#x\n", pmcs->dse);
+ vfu_log(vfu_ctx, LOG_DEBUG, "data select set to %#x", pmcs->dse);
}
if (pm->pmcs.pmes != pmcs->pmes) {
- vfu_log(vfu_ctx, LOG_DEBUG, "PME status set to %#x\n", pmcs->pmes);
+ vfu_log(vfu_ctx, LOG_DEBUG, "PME status set to %#x", pmcs->pmes);
}
pm->pmcs = *pmcs;
return 0;
@@ -161,17 +161,17 @@ handle_mxc_write(vfu_ctx_t *vfu_ctx, struct msixcap *msix,
assert(mxc != NULL);
if (mxc->mxe != msix->mxc.mxe) {
- vfu_log(vfu_ctx, LOG_DEBUG, "%s MSI-X\n",
+ vfu_log(vfu_ctx, LOG_DEBUG, "%s MSI-X",
mxc->mxe ? "enable" : "disable");
msix->mxc.mxe = mxc->mxe;
}
if (mxc->fm != msix->mxc.fm) {
if (mxc->fm) {
- vfu_log(vfu_ctx, LOG_DEBUG, "all MSI-X vectors masked\n");
+ vfu_log(vfu_ctx, LOG_DEBUG, "all MSI-X vectors masked");
} else {
vfu_log(vfu_ctx, LOG_DEBUG,
- "vector's mask bit determines whether vector is masked\n");
+ "vector's mask bit determines whether vector is masked");
}
msix->mxc.fm = mxc->fm;
}
@@ -191,11 +191,11 @@ cap_write_msix(vfu_ctx_t *vfu_ctx, struct pci_cap *cap, char *buf,
return handle_mxc_write(vfu_ctx, msix, (struct mxc *)buf);
default:
vfu_log(vfu_ctx, LOG_ERR,
- "invalid MSI-X write offset %ld\n", offset);
+ "invalid MSI-X write offset %ld", offset);
return -EINVAL;
}
}
- vfu_log(vfu_ctx, LOG_ERR, "invalid MSI-X write size %lu\n", count);
+ vfu_log(vfu_ctx, LOG_ERR, "invalid MSI-X write size %lu", count);
return -EINVAL;
}
@@ -208,64 +208,64 @@ handle_px_pxdc_write(vfu_ctx_t *vfu_ctx, struct pxcap *px,
if (p->cere != px->pxdc.cere) {
px->pxdc.cere = p->cere;
- vfu_log(vfu_ctx, LOG_DEBUG, "CERE %s\n", p->cere ? "enable" : "disable");
+ vfu_log(vfu_ctx, LOG_DEBUG, "CERE %s", p->cere ? "enable" : "disable");
}
if (p->nfere != px->pxdc.nfere) {
px->pxdc.nfere = p->nfere;
- vfu_log(vfu_ctx, LOG_DEBUG, "NFERE %s\n",
+ vfu_log(vfu_ctx, LOG_DEBUG, "NFERE %s",
p->nfere ? "enable" : "disable");
}
if (p->fere != px->pxdc.fere) {
px->pxdc.fere = p->fere;
- vfu_log(vfu_ctx, LOG_DEBUG, "FERE %s\n", p->fere ? "enable" : "disable");
+ vfu_log(vfu_ctx, LOG_DEBUG, "FERE %s", p->fere ? "enable" : "disable");
}
if (p->urre != px->pxdc.urre) {
px->pxdc.urre = p->urre;
- vfu_log(vfu_ctx, LOG_DEBUG, "URRE %s\n", p->urre ? "enable" : "disable");
+ vfu_log(vfu_ctx, LOG_DEBUG, "URRE %s", p->urre ? "enable" : "disable");
}
if (p->ero != px->pxdc.ero) {
px->pxdc.ero = p->ero;
- vfu_log(vfu_ctx, LOG_DEBUG, "ERO %s\n", p->ero ? "enable" : "disable");
+ vfu_log(vfu_ctx, LOG_DEBUG, "ERO %s", p->ero ? "enable" : "disable");
}
if (p->mps != px->pxdc.mps) {
px->pxdc.mps = p->mps;
- vfu_log(vfu_ctx, LOG_DEBUG, "MPS set to %d\n", p->mps);
+ vfu_log(vfu_ctx, LOG_DEBUG, "MPS set to %d", p->mps);
}
if (p->ete != px->pxdc.ete) {
px->pxdc.ete = p->ete;
- vfu_log(vfu_ctx, LOG_DEBUG, "ETE %s\n", p->ete ? "enable" : "disable");
+ vfu_log(vfu_ctx, LOG_DEBUG, "ETE %s", p->ete ? "enable" : "disable");
}
if (p->pfe != px->pxdc.pfe) {
px->pxdc.pfe = p->pfe;
- vfu_log(vfu_ctx, LOG_DEBUG, "PFE %s\n", p->pfe ? "enable" : "disable");
+ vfu_log(vfu_ctx, LOG_DEBUG, "PFE %s", p->pfe ? "enable" : "disable");
}
if (p->appme != px->pxdc.appme) {
px->pxdc.appme = p->appme;
- vfu_log(vfu_ctx, LOG_DEBUG, "APPME %s\n",
+ vfu_log(vfu_ctx, LOG_DEBUG, "APPME %s",
p->appme ? "enable" : "disable");
}
if (p->ens != px->pxdc.ens) {
px->pxdc.ens = p->ens;
- vfu_log(vfu_ctx, LOG_DEBUG, "ENS %s\n", p->ens ? "enable" : "disable");
+ vfu_log(vfu_ctx, LOG_DEBUG, "ENS %s", p->ens ? "enable" : "disable");
}
if (p->mrrs != px->pxdc.mrrs) {
px->pxdc.mrrs = p->mrrs;
- vfu_log(vfu_ctx, LOG_DEBUG, "MRRS set to %d\n", p->mrrs);
+ vfu_log(vfu_ctx, LOG_DEBUG, "MRRS set to %d", p->mrrs);
}
if (p->iflr) {
vfu_log(vfu_ctx, LOG_DEBUG,
- "initiate function level reset\n");
+ "initiate function level reset");
}
return 0;
@@ -312,7 +312,7 @@ static ssize_t
ext_cap_write_dsn(vfu_ctx_t *vfu_ctx, struct pci_cap *cap, char *buf UNUSED,
size_t count UNUSED, loff_t offset UNUSED)
{
- vfu_log(vfu_ctx, LOG_ERR, "%s capability is read-only\n", cap->name);
+ vfu_log(vfu_ctx, LOG_ERR, "%s capability is read-only", cap->name);
return -EPERM;
}
@@ -363,7 +363,7 @@ pci_cap_access(vfu_ctx_t *vfu_ctx, char *buf, size_t count, loff_t offset,
if (is_write && (cap->flags & VFU_CAP_FLAG_READONLY)) {
vfu_log(vfu_ctx, LOG_ERR, "write of %zu bytes to read-only capability "
- "%u (%s)\n", count, cap->id, cap->name);
+ "%u (%s)", count, cap->id, cap->name);
return -EPERM;
}
@@ -378,7 +378,7 @@ pci_cap_access(vfu_ctx_t *vfu_ctx, char *buf, size_t count, loff_t offset,
if (offset - cap->off < cap->hdr_size) {
vfu_log(vfu_ctx, LOG_ERR,
- "disallowed write to header for cap %d (%s)\n",
+ "disallowed write to header for cap %d (%s)",
cap->id, cap->name);
return -EPERM;
}
@@ -409,13 +409,13 @@ cap_place(vfu_ctx_t *vfu_ctx, struct pci_cap *cap, void *data)
if (cap->off != 0) {
if (cap->off < PCI_STD_HEADER_SIZEOF) {
vfu_log(vfu_ctx, LOG_ERR, "invalid offset %#lx for capability "
- "%u (%s)\n", cap->off, cap->id, cap->name);
+ "%u (%s)", cap->off, cap->id, cap->name);
return EINVAL;
}
if (cap_find_by_offset(vfu_ctx, cap->off, cap->size) != NULL) {
vfu_log(vfu_ctx, LOG_ERR, "overlap found for capability "
- "%u (%s)\n", cap->id, cap->name);
+ "%u (%s)", cap->id, cap->name);
return EINVAL;
}
@@ -441,7 +441,7 @@ cap_place(vfu_ctx_t *vfu_ctx, struct pci_cap *cap, void *data)
if (cap->off + cap->size > pci_config_space_size(vfu_ctx)) {
vfu_log(vfu_ctx, LOG_ERR, "no config space left for capability "
- "%u (%s) of size %zu bytes at offset %#lx\n", cap->id,
+ "%u (%s) of size %zu bytes at offset %#lx", cap->id,
cap->name, cap->size, cap->off);
return ENOSPC;
}
@@ -473,19 +473,19 @@ ext_cap_place(vfu_ctx_t *vfu_ctx, struct pci_cap *cap, void *data)
if (cap->off != 0) {
if (cap->off < PCI_CFG_SPACE_SIZE) {
vfu_log(vfu_ctx, LOG_ERR, "invalid offset %#lx for capability "
- "%u (%s)\n", cap->off, cap->id, cap->name);
+ "%u (%s)", cap->off, cap->id, cap->name);
return EINVAL;
}
if (cap_find_by_offset(vfu_ctx, cap->off, cap->size) != NULL) {
vfu_log(vfu_ctx, LOG_ERR, "overlap found for capability "
- "%u (%s)\n", cap->id, cap->name);
+ "%u (%s)", cap->id, cap->name);
return EINVAL;
}
if (hdr->id == 0x0 && cap->off != PCI_CFG_SPACE_SIZE) {
vfu_log(vfu_ctx, LOG_ERR, "first extended capability must be at "
- "%#x\n", PCI_CFG_SPACE_SIZE);
+ "%#x", PCI_CFG_SPACE_SIZE);
return EINVAL;
}
@@ -506,7 +506,7 @@ ext_cap_place(vfu_ctx_t *vfu_ctx, struct pci_cap *cap, void *data)
if (cap->off + cap->size > pci_config_space_size(vfu_ctx)) {
vfu_log(vfu_ctx, LOG_ERR, "no config space left for capability "
- "%u (%s) of size %zu bytes at offset %#lx\n", cap->id,
+ "%u (%s) of size %zu bytes at offset %#lx", cap->id,
cap->name, cap->size, cap->off);
return ENOSPC;
}
@@ -574,7 +574,7 @@ vfu_pci_add_capability(vfu_ctx_t *vfu_ctx, size_t pos, int flags, void *data)
cap.hdr_size = sizeof(struct pcie_ext_cap_vsc_hdr);
break;
default:
- vfu_log(vfu_ctx, LOG_ERR, "unsupported capability %#x\n", cap.id);
+ vfu_log(vfu_ctx, LOG_ERR, "unsupported capability %#x", cap.id);
return ERROR_INT(ENOTSUP);
}
@@ -613,7 +613,7 @@ vfu_pci_add_capability(vfu_ctx_t *vfu_ctx, size_t pos, int flags, void *data)
cap.hdr_size = sizeof(struct vsc);
break;
default:
- vfu_log(vfu_ctx, LOG_ERR, "unsupported capability %#x\n", cap.id);
+ vfu_log(vfu_ctx, LOG_ERR, "unsupported capability %#x", cap.id);
return ERROR_INT(ENOTSUP);
}
diff --git a/samples/client.c b/samples/client.c
index 8a03f84..ea0c73e 100644
--- a/samples/client.c
+++ b/samples/client.c
@@ -203,7 +203,7 @@ send_device_reset(int sock)
int ret = tran_sock_msg(sock, 1, VFIO_USER_DEVICE_RESET,
NULL, 0, NULL, NULL, 0);
if (ret < 0) {
- errx(EXIT_FAILURE, "failed to reset device: %s\n", strerror(-ret));
+ errx(EXIT_FAILURE, "failed to reset device: %s", strerror(-ret));
}
}
@@ -904,7 +904,7 @@ migrate_from(int sock, int migr_reg_index, size_t *nr_iters,
_nr_iters += do_migrate(sock, migr_reg_index, 1, (*migr_iters) + _nr_iters);
if (_nr_iters != 2) {
errx(EXIT_FAILURE,
- "expected 2 iterations instead of %ld while in stop-and-copy state\n",
+ "expected 2 iterations instead of %ld while in stop-and-copy state",
_nr_iters);
}
@@ -1155,7 +1155,7 @@ int main(int argc, char *argv[])
ret = access_region(sock, VFU_PCI_DEV_CFG_REGION_IDX, false, 0, &config_space,
sizeof(config_space));
if (ret < 0) {
- errx(EXIT_FAILURE, "failed to read PCI configuration space: %s\n",
+ errx(EXIT_FAILURE, "failed to read PCI configuration space: %s",
strerror(-ret));
}
diff --git a/samples/server.c b/samples/server.c
index a299c87..f77b255 100644
--- a/samples/server.c
+++ b/samples/server.c
@@ -162,7 +162,7 @@ dma_register(vfu_ctx_t *vfu_ctx, vfu_dma_info_t *info)
break;
}
if (idx >= NR_DMA_REGIONS) {
- errx(EXIT_FAILURE, "Failed to add dma region, slots full\n");
+ errx(EXIT_FAILURE, "Failed to add dma region, slots full");
}
server_data->regions[idx].iova = info->iova;
@@ -219,7 +219,7 @@ static void do_dma_io(vfu_ctx_t *vfu_ctx, struct server_data *server_data)
(vfu_dma_addr_t)server_data->regions[0].iova.iov_base,
count, &sg, 1, PROT_WRITE);
if (ret < 0) {
- errx(EXIT_FAILURE, "failed to map %p-%p: %s\n",
+ errx(EXIT_FAILURE, "failed to map %p-%p: %s",
server_data->regions[0].iova.iov_base,
server_data->regions[0].iova.iov_base + count -1,
strerror(-ret));
@@ -231,7 +231,7 @@ static void do_dma_io(vfu_ctx_t *vfu_ctx, struct server_data *server_data)
server_data->regions[0].iova.iov_base, count);
ret = vfu_dma_write(vfu_ctx, &sg, buf);
if (ret < 0) {
- errx(EXIT_FAILURE, "vfu_dma_write failed: %s\n", strerror(-ret));
+ errx(EXIT_FAILURE, "vfu_dma_write failed: %s", strerror(-ret));
}
memset(buf, 0, count);
@@ -239,12 +239,12 @@ static void do_dma_io(vfu_ctx_t *vfu_ctx, struct server_data *server_data)
server_data->regions[0].iova.iov_base, count);
ret = vfu_dma_read(vfu_ctx, &sg, buf);
if (ret < 0) {
- errx(EXIT_FAILURE, "vfu_dma_read failed: %s\n", strerror(-ret));
+ errx(EXIT_FAILURE, "vfu_dma_read failed: %s", strerror(-ret));
}
get_md5sum(buf, count, md5sum2);
for(i = 0; i < MD5_DIGEST_LENGTH; i++) {
if (md5sum2[i] != md5sum1[i]) {
- errx(EXIT_FAILURE, "DMA write and DMA read mismatch\n");
+ errx(EXIT_FAILURE, "DMA write and DMA read mismatch");
}
}
}
@@ -445,7 +445,7 @@ int main(int argc, char *argv[])
verbose = true;
break;
default: /* '?' */
- errx(EXIT_FAILURE, "Usage: %s [-v] <socketpath>\n", argv[0]);
+ errx(EXIT_FAILURE, "Usage: %s [-v] <socketpath>", argv[0]);
}
}
@@ -461,7 +461,7 @@ int main(int argc, char *argv[])
vfu_ctx = vfu_create_ctx(VFU_TRANS_SOCK, argv[optind], 0, &server_data,
VFU_DEV_TYPE_PCI);
if (vfu_ctx == NULL) {
- err(EXIT_FAILURE, "failed to initialize device emulation\n");
+ err(EXIT_FAILURE, "failed to initialize device emulation");
}
ret = vfu_setup_log(vfu_ctx, _log, verbose ? LOG_DEBUG : LOG_ERR);