mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-06-08 18:14:53 +00:00
dm:use acrn-dm logger function instread of fprintf
use acrn-dm logger function instread of fprintf, this helps the stability testing log capture. Tracked-On: #4098 Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Reviewed-by: Cao Minggui <minggui.cao@intel.com> Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
This commit is contained in:
@@ -64,7 +64,7 @@ virtio_start_timer(struct acrn_timer *timer, time_t sec, time_t nsec)
|
||||
ts.it_value.tv_sec = sec;
|
||||
ts.it_value.tv_nsec = nsec;
|
||||
if (acrn_timer_settime(timer, &ts) != 0) {
|
||||
fprintf(stderr, "acrn timer set time failed\n");
|
||||
pr_err("acrn timer set time failed\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -98,8 +98,7 @@ virtio_poll_timer(void *arg, uint64_t nexp)
|
||||
else if (vops->qnotify)
|
||||
(*vops->qnotify)(DEV_STRUCT(base), vq);
|
||||
else
|
||||
fprintf(stderr,
|
||||
"%s: qnotify queue %d: missing vq/vops notify\r\n",
|
||||
pr_err("%s: qnotify queue %d: missing vq/vops notify\r\n",
|
||||
name, i);
|
||||
}
|
||||
|
||||
@@ -131,8 +130,7 @@ virtio_linkup(struct virtio_base *base, struct virtio_ops *vops,
|
||||
|
||||
/* base and pci_virtio_dev addresses must match */
|
||||
if ((void *)base != pci_virtio_dev) {
|
||||
fprintf(stderr,
|
||||
"virtio_base and pci_virtio_dev addresses don't match!\n");
|
||||
pr_err("virtio_base and pci_virtio_dev addresses don't match!\n");
|
||||
return;
|
||||
}
|
||||
base->vops = vops;
|
||||
@@ -461,8 +459,7 @@ vq_getchain(struct virtio_vq_info *vq, uint16_t *pidx,
|
||||
return 0;
|
||||
if (ndesc > vq->qsize) {
|
||||
/* XXX need better way to diagnose issues */
|
||||
fprintf(stderr,
|
||||
"%s: ndesc (%u) out of range, driver confused?\r\n",
|
||||
pr_err("%s: ndesc (%u) out of range, driver confused?\r\n",
|
||||
name, (u_int)ndesc);
|
||||
return -1;
|
||||
}
|
||||
@@ -480,8 +477,7 @@ vq_getchain(struct virtio_vq_info *vq, uint16_t *pidx,
|
||||
vq->last_avail++;
|
||||
for (i = 0; i < VQ_MAX_DESCRIPTORS; next = vdir->next) {
|
||||
if (next >= vq->qsize) {
|
||||
fprintf(stderr,
|
||||
"%s: descriptor index %u out of range, "
|
||||
pr_err("%s: descriptor index %u out of range, "
|
||||
"driver confused?\r\n",
|
||||
name, next);
|
||||
return -1;
|
||||
@@ -492,16 +488,14 @@ vq_getchain(struct virtio_vq_info *vq, uint16_t *pidx,
|
||||
i++;
|
||||
} else if ((base->device_caps &
|
||||
(1 << VIRTIO_RING_F_INDIRECT_DESC)) == 0) {
|
||||
fprintf(stderr,
|
||||
"%s: descriptor has forbidden INDIRECT flag, "
|
||||
pr_err("%s: descriptor has forbidden INDIRECT flag, "
|
||||
"driver confused?\r\n",
|
||||
name);
|
||||
return -1;
|
||||
} else {
|
||||
n_indir = vdir->len / 16;
|
||||
if ((vdir->len & 0xf) || n_indir == 0) {
|
||||
fprintf(stderr,
|
||||
"%s: invalid indir len 0x%x, "
|
||||
pr_err("%s: invalid indir len 0x%x, "
|
||||
"driver confused?\r\n",
|
||||
name, (u_int)vdir->len);
|
||||
return -1;
|
||||
@@ -519,8 +513,7 @@ vq_getchain(struct virtio_vq_info *vq, uint16_t *pidx,
|
||||
for (;;) {
|
||||
vp = &vindir[next];
|
||||
if (vp->flags & VRING_DESC_F_INDIRECT) {
|
||||
fprintf(stderr,
|
||||
"%s: indirect desc has INDIR flag,"
|
||||
pr_err("%s: indirect desc has INDIR flag,"
|
||||
" driver confused?\r\n",
|
||||
name);
|
||||
return -1;
|
||||
@@ -532,8 +525,7 @@ vq_getchain(struct virtio_vq_info *vq, uint16_t *pidx,
|
||||
break;
|
||||
next = vp->next;
|
||||
if (next >= n_indir) {
|
||||
fprintf(stderr,
|
||||
"%s: invalid next %u > %u, "
|
||||
pr_err("%s: invalid next %u > %u, "
|
||||
"driver confused?\r\n",
|
||||
name, (u_int)next, n_indir);
|
||||
return -1;
|
||||
@@ -544,8 +536,7 @@ vq_getchain(struct virtio_vq_info *vq, uint16_t *pidx,
|
||||
return i;
|
||||
}
|
||||
loopy:
|
||||
fprintf(stderr,
|
||||
"%s: descriptor loop? count > %d - driver confused?\r\n",
|
||||
pr_err("%s: descriptor loop? count > %d - driver confused?\r\n",
|
||||
name, i);
|
||||
return -1;
|
||||
}
|
||||
@@ -811,12 +802,10 @@ bad:
|
||||
if (cr == NULL || cr->size != size) {
|
||||
if (cr != NULL) {
|
||||
/* offset must be OK, so size must be bad */
|
||||
fprintf(stderr,
|
||||
"%s: read from %s: bad size %d\r\n",
|
||||
pr_err("%s: read from %s: bad size %d\r\n",
|
||||
name, cr->name, size);
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"%s: read from bad offset/size %jd/%d\r\n",
|
||||
pr_err("%s: read from bad offset/size %jd/%d\r\n",
|
||||
name, (uintmax_t)offset, size);
|
||||
}
|
||||
goto done;
|
||||
@@ -922,16 +911,13 @@ bad:
|
||||
if (cr != NULL) {
|
||||
/* offset must be OK, wrong size and/or reg is R/O */
|
||||
if (cr->size != size)
|
||||
fprintf(stderr,
|
||||
"%s: write to %s: bad size %d\r\n",
|
||||
pr_err("%s: write to %s: bad size %d\r\n",
|
||||
name, cr->name, size);
|
||||
if (cr->ro)
|
||||
fprintf(stderr,
|
||||
"%s: write to read-only reg %s\r\n",
|
||||
pr_err("%s: write to read-only reg %s\r\n",
|
||||
name, cr->name);
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"%s: write to bad offset/size %jd/%d\r\n",
|
||||
pr_err("%s: write to bad offset/size %jd/%d\r\n",
|
||||
name, (uintmax_t)offset, size);
|
||||
}
|
||||
goto done;
|
||||
@@ -959,7 +945,7 @@ bad:
|
||||
break;
|
||||
case VIRTIO_PCI_QUEUE_NOTIFY:
|
||||
if (value >= vops->nvq) {
|
||||
fprintf(stderr, "%s: queue %d notify out of range\r\n",
|
||||
pr_err("%s: queue %d notify out of range\r\n",
|
||||
name, (int)value);
|
||||
goto done;
|
||||
}
|
||||
@@ -969,8 +955,7 @@ bad:
|
||||
else if (vops->qnotify)
|
||||
(*vops->qnotify)(DEV_STRUCT(base), vq);
|
||||
else
|
||||
fprintf(stderr,
|
||||
"%s: qnotify queue %d: missing vq/vops notify\r\n",
|
||||
pr_err("%s: qnotify queue %d: missing vq/vops notify\r\n",
|
||||
name, (int)value);
|
||||
break;
|
||||
case VIRTIO_PCI_STATUS:
|
||||
@@ -1004,8 +989,7 @@ bad:
|
||||
goto done;
|
||||
|
||||
bad_qindex:
|
||||
fprintf(stderr,
|
||||
"%s: write config reg %s: curq %d >= max %d\r\n",
|
||||
pr_err("%s: write config reg %s: curq %d >= max %d\r\n",
|
||||
name, cr->name, base->curq, vops->nvq);
|
||||
done:
|
||||
if (base->mtx)
|
||||
@@ -1065,8 +1049,7 @@ virtio_set_modern_mmio_bar(struct virtio_base *base, int barnum)
|
||||
vops = base->vops;
|
||||
|
||||
if (vops->cfgsize > VIRTIO_CAP_DEVICE_SIZE) {
|
||||
fprintf(stderr,
|
||||
"%s: cfgsize %lu > max %d\r\n",
|
||||
pr_err("%s: cfgsize %lu > max %d\r\n",
|
||||
vops->name, vops->cfgsize, VIRTIO_CAP_DEVICE_SIZE);
|
||||
return -1;
|
||||
}
|
||||
@@ -1077,8 +1060,7 @@ virtio_set_modern_mmio_bar(struct virtio_base *base, int barnum)
|
||||
cap.length = VIRTIO_CAP_COMMON_SIZE;
|
||||
rc = pci_emul_add_capability(base->dev, (u_char *)&cap, sizeof(cap));
|
||||
if (rc != 0) {
|
||||
fprintf(stderr,
|
||||
"pci emulation add common configuration capability failed\n");
|
||||
pr_err("pci emulation add common configuration capability failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1088,8 +1070,7 @@ virtio_set_modern_mmio_bar(struct virtio_base *base, int barnum)
|
||||
cap.length = VIRTIO_CAP_ISR_SIZE;
|
||||
rc = pci_emul_add_capability(base->dev, (u_char *)&cap, sizeof(cap));
|
||||
if (rc != 0) {
|
||||
fprintf(stderr,
|
||||
"pci emulation add isr status capability failed\n");
|
||||
pr_err("pci emulation add isr status capability failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1099,8 +1080,7 @@ virtio_set_modern_mmio_bar(struct virtio_base *base, int barnum)
|
||||
cap.length = VIRTIO_CAP_DEVICE_SIZE;
|
||||
rc = pci_emul_add_capability(base->dev, (u_char *)&cap, sizeof(cap));
|
||||
if (rc != 0) {
|
||||
fprintf(stderr,
|
||||
"pci emulation add device specific configuration capability failed\n");
|
||||
pr_err("pci emulation add device specific configuration capability failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1108,16 +1088,14 @@ virtio_set_modern_mmio_bar(struct virtio_base *base, int barnum)
|
||||
rc = pci_emul_add_capability(base->dev, (u_char *)¬ify,
|
||||
sizeof(notify));
|
||||
if (rc != 0) {
|
||||
fprintf(stderr,
|
||||
"pci emulation add notification capability failed\n");
|
||||
pr_err("pci emulation add notification capability failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* pci alternative configuration access capability */
|
||||
rc = pci_emul_add_capability(base->dev, (u_char *)&cfg, sizeof(cfg));
|
||||
if (rc != 0) {
|
||||
fprintf(stderr,
|
||||
"pci emulation add alternative configuration access capability failed\n");
|
||||
pr_err("pci emulation add alternative configuration access capability failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1125,15 +1103,13 @@ virtio_set_modern_mmio_bar(struct virtio_base *base, int barnum)
|
||||
rc = pci_emul_alloc_bar(base->dev, barnum, PCIBAR_MEM64,
|
||||
VIRTIO_MODERN_MEM_BAR_SIZE);
|
||||
if (rc != 0) {
|
||||
fprintf(stderr,
|
||||
"allocate and register modern memory bar failed\n");
|
||||
pr_err("allocate and register modern memory bar failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
base->cfg_coff = virtio_find_capability(base, VIRTIO_PCI_CAP_PCI_CFG);
|
||||
if (base->cfg_coff < 0) {
|
||||
fprintf(stderr,
|
||||
"%s: VIRTIO_PCI_CAP_PCI_CFG not found\r\n",
|
||||
pr_err("%s: VIRTIO_PCI_CAP_PCI_CFG not found\r\n",
|
||||
vops->name);
|
||||
return -1;
|
||||
}
|
||||
@@ -1164,16 +1140,14 @@ virtio_set_modern_pio_bar(struct virtio_base *base, int barnum)
|
||||
rc = pci_emul_add_capability(base->dev, (u_char *)¬ify_pio,
|
||||
sizeof(notify_pio));
|
||||
if (rc != 0) {
|
||||
fprintf(stderr,
|
||||
"pci emulation add notification capability for virtio modern PIO BAR failed\n");
|
||||
pr_err("pci emulation add notification capability for virtio modern PIO BAR failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* allocate and register modern pio bar */
|
||||
rc = pci_emul_alloc_bar(base->dev, barnum, PCIBAR_IO, 4);
|
||||
if (rc != 0) {
|
||||
fprintf(stderr,
|
||||
"allocate and register modern pio bar failed\n");
|
||||
pr_err("allocate and register modern pio bar failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1261,12 +1235,10 @@ virtio_common_cfg_read(struct pci_vdev *dev, uint64_t offset, int size)
|
||||
if (cr == NULL || cr->size != size) {
|
||||
if (cr != NULL) {
|
||||
/* offset must be OK, so size must be bad */
|
||||
fprintf(stderr,
|
||||
"%s: read from %s: bad size %d\r\n",
|
||||
pr_err("%s: read from %s: bad size %d\r\n",
|
||||
name, cr->name, size);
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"%s: read from bad offset/size %jd/%d\r\n",
|
||||
pr_err("%s: read from bad offset/size %jd/%d\r\n",
|
||||
name, (uintmax_t)offset, size);
|
||||
}
|
||||
|
||||
@@ -1378,16 +1350,13 @@ virtio_common_cfg_write(struct pci_vdev *dev, uint64_t offset, int size,
|
||||
if (cr != NULL) {
|
||||
/* offset must be OK, wrong size and/or reg is R/O */
|
||||
if (cr->size != size)
|
||||
fprintf(stderr,
|
||||
"%s: write to %s: bad size %d\r\n",
|
||||
pr_err("%s: write to %s: bad size %d\r\n",
|
||||
name, cr->name, size);
|
||||
if (cr->ro)
|
||||
fprintf(stderr,
|
||||
"%s: write to read-only reg %s\r\n",
|
||||
pr_err("%s: write to read-only reg %s\r\n",
|
||||
name, cr->name);
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"%s: write to bad offset/size %jd/%d\r\n",
|
||||
pr_err("%s: write to bad offset/size %jd/%d\r\n",
|
||||
name, (uintmax_t)offset, size);
|
||||
}
|
||||
|
||||
@@ -1491,8 +1460,7 @@ virtio_common_cfg_write(struct pci_vdev *dev, uint64_t offset, int size,
|
||||
return;
|
||||
|
||||
bad_qindex:
|
||||
fprintf(stderr,
|
||||
"%s: write config reg %s: curq %d >= max %d\r\n",
|
||||
pr_err("%s: write config reg %s: curq %d >= max %d\r\n",
|
||||
name, cr->name, base->curq, vops->nvq);
|
||||
}
|
||||
|
||||
@@ -1527,16 +1495,14 @@ virtio_device_cfg_read(struct pci_vdev *dev, uint64_t offset, int size)
|
||||
max = vops->cfgsize ? vops->cfgsize : 0x100000000;
|
||||
|
||||
if (offset + size > max) {
|
||||
fprintf(stderr,
|
||||
"%s: reading from 0x%lx size %d exceeds limit\r\n",
|
||||
pr_err("%s: reading from 0x%lx size %d exceeds limit\r\n",
|
||||
name, offset, size);
|
||||
return value;
|
||||
}
|
||||
|
||||
error = (*vops->cfgread)(DEV_STRUCT(base), offset, size, &value);
|
||||
if (error) {
|
||||
fprintf(stderr,
|
||||
"%s: reading from 0x%lx size %d failed %d\r\n",
|
||||
pr_err("%s: reading from 0x%lx size %d failed %d\r\n",
|
||||
name, offset, size, error);
|
||||
value = size == 1 ? 0xff : size == 2 ? 0xffff : 0xffffffff;
|
||||
}
|
||||
@@ -1559,16 +1525,14 @@ virtio_device_cfg_write(struct pci_vdev *dev, uint64_t offset, int size,
|
||||
max = vops->cfgsize ? vops->cfgsize : 0x100000000;
|
||||
|
||||
if (offset + size > max) {
|
||||
fprintf(stderr,
|
||||
"%s: writing to 0x%lx size %d exceeds limit\r\n",
|
||||
pr_err("%s: writing to 0x%lx size %d exceeds limit\r\n",
|
||||
name, offset, size);
|
||||
return;
|
||||
}
|
||||
|
||||
error = (*vops->cfgwrite)(DEV_STRUCT(base), offset, size, value);
|
||||
if (error)
|
||||
fprintf(stderr,
|
||||
"%s: writing ot 0x%lx size %d failed %d\r\n",
|
||||
pr_err("%s: writing ot 0x%lx size %d failed %d\r\n",
|
||||
name, offset, size, error);
|
||||
}
|
||||
|
||||
@@ -1591,8 +1555,7 @@ virtio_notify_cfg_write(struct pci_vdev *dev, uint64_t offset, int size,
|
||||
name = vops->name;
|
||||
|
||||
if (idx >= vops->nvq) {
|
||||
fprintf(stderr,
|
||||
"%s: queue %lu notify out of range\r\n", name, idx);
|
||||
pr_err("%s: queue %lu notify out of range\r\n", name, idx);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1602,8 +1565,7 @@ virtio_notify_cfg_write(struct pci_vdev *dev, uint64_t offset, int size,
|
||||
else if (vops->qnotify)
|
||||
(*vops->qnotify)(DEV_STRUCT(base), vq);
|
||||
else
|
||||
fprintf(stderr,
|
||||
"%s: qnotify queue %lu: missing vq/vops notify\r\n",
|
||||
pr_err("%s: qnotify queue %lu: missing vq/vops notify\r\n",
|
||||
name, idx);
|
||||
}
|
||||
|
||||
@@ -1623,16 +1585,14 @@ virtio_pci_modern_mmio_read(struct vmctx *ctx, int vcpu, struct pci_vdev *dev,
|
||||
value = size == 1 ? 0xff : size == 2 ? 0xffff : 0xffffffff;
|
||||
|
||||
if (size != 1 && size != 2 && size != 4) {
|
||||
fprintf(stderr,
|
||||
"%s: read from [%d:0x%lx] bad size %d\r\n",
|
||||
pr_err("%s: read from [%d:0x%lx] bad size %d\r\n",
|
||||
name, baridx, offset, size);
|
||||
return value;
|
||||
}
|
||||
|
||||
capid = virtio_get_cap_id(offset, size);
|
||||
if (capid < 0) {
|
||||
fprintf(stderr,
|
||||
"%s: read from [%d:0x%lx] bad range %d\r\n",
|
||||
pr_err("%s: read from [%d:0x%lx] bad range %d\r\n",
|
||||
name, baridx, offset, size);
|
||||
return value;
|
||||
}
|
||||
@@ -1654,8 +1614,7 @@ virtio_pci_modern_mmio_read(struct vmctx *ctx, int vcpu, struct pci_vdev *dev,
|
||||
value = virtio_device_cfg_read(dev, offset, size);
|
||||
break;
|
||||
default: /* guest driver should not read from notify region */
|
||||
fprintf(stderr,
|
||||
"%s: read from [%d:0x%lx] size %d not supported\r\n",
|
||||
pr_err("%s: read from [%d:0x%lx] size %d not supported\r\n",
|
||||
name, baridx, offset, size);
|
||||
}
|
||||
|
||||
@@ -1679,16 +1638,14 @@ virtio_pci_modern_mmio_write(struct vmctx *ctx, int vcpu, struct pci_vdev *dev,
|
||||
name = vops->name;
|
||||
|
||||
if (size != 1 && size != 2 && size != 4) {
|
||||
fprintf(stderr,
|
||||
"%s: write to [%d:0x%lx] bad size %d\r\n",
|
||||
pr_err("%s: write to [%d:0x%lx] bad size %d\r\n",
|
||||
name, baridx, offset, size);
|
||||
return;
|
||||
}
|
||||
|
||||
capid = virtio_get_cap_id(offset, size);
|
||||
if (capid < 0) {
|
||||
fprintf(stderr,
|
||||
"%s: write to [%d:0x%lx] bad range %d\r\n",
|
||||
pr_err("%s: write to [%d:0x%lx] bad range %d\r\n",
|
||||
name, baridx, offset, size);
|
||||
return;
|
||||
}
|
||||
@@ -1710,8 +1667,7 @@ virtio_pci_modern_mmio_write(struct vmctx *ctx, int vcpu, struct pci_vdev *dev,
|
||||
virtio_notify_cfg_write(dev, offset, size, value);
|
||||
break;
|
||||
default: /* guest driver should not write to ISR region */
|
||||
fprintf(stderr,
|
||||
"%s: write to [%d:0x%lx] size %d not supported\r\n",
|
||||
pr_err("%s: write to [%d:0x%lx] size %d not supported\r\n",
|
||||
name, baridx, offset, size);
|
||||
}
|
||||
|
||||
@@ -1744,15 +1700,13 @@ virtio_pci_modern_pio_write(struct vmctx *ctx, int vcpu, struct pci_vdev *dev,
|
||||
idx = value;
|
||||
|
||||
if (size != 1 && size != 2 && size != 4) {
|
||||
fprintf(stderr,
|
||||
"%s: write to [%d:0x%lx] bad size %d\r\n",
|
||||
pr_err("%s: write to [%d:0x%lx] bad size %d\r\n",
|
||||
name, baridx, offset, size);
|
||||
return;
|
||||
}
|
||||
|
||||
if (idx >= vops->nvq) {
|
||||
fprintf(stderr,
|
||||
"%s: queue %lu notify out of range\r\n", name, idx);
|
||||
pr_err("%s: queue %lu notify out of range\r\n", name, idx);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1765,8 +1719,7 @@ virtio_pci_modern_pio_write(struct vmctx *ctx, int vcpu, struct pci_vdev *dev,
|
||||
else if (vops->qnotify)
|
||||
(*vops->qnotify)(DEV_STRUCT(base), vq);
|
||||
else
|
||||
fprintf(stderr,
|
||||
"%s: qnotify queue %lu: missing vq/vops notify\r\n",
|
||||
pr_err("%s: qnotify queue %lu: missing vq/vops notify\r\n",
|
||||
name, idx);
|
||||
|
||||
if (base->mtx)
|
||||
@@ -1813,7 +1766,7 @@ virtio_pci_read(struct vmctx *ctx, int vcpu, struct pci_vdev *dev,
|
||||
return virtio_pci_modern_pio_read(ctx, vcpu, dev, baridx,
|
||||
offset, size);
|
||||
|
||||
fprintf(stderr, "%s: read unexpected baridx %d\r\n",
|
||||
pr_err("%s: read unexpected baridx %d\r\n",
|
||||
base->vops->name, baridx);
|
||||
return size == 1 ? 0xff : size == 2 ? 0xffff : 0xffffffff;
|
||||
}
|
||||
@@ -1866,7 +1819,7 @@ virtio_pci_write(struct vmctx *ctx, int vcpu, struct pci_vdev *dev,
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stderr, "%s: write unexpected baridx %d\r\n",
|
||||
pr_err("%s: write unexpected baridx %d\r\n",
|
||||
base->vops->name, baridx);
|
||||
}
|
||||
|
||||
|
||||
@@ -565,7 +565,7 @@ virtio_blk_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
||||
register_vm_monitor_blkrescan = true;
|
||||
if (monitor_register_vm_ops(&virtio_blk_rescan_ops, ctx,
|
||||
"virtio_blk_rescan") < 0)
|
||||
fprintf(stderr, "Rescan registration to VM monitor failed\n");
|
||||
pr_err("Rescan registration to VM monitor failed\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -654,24 +654,24 @@ virtio_blk_rescan(struct vmctx *ctx, struct pci_vdev *dev, char *newpath)
|
||||
struct virtio_blk *blk = (struct virtio_blk *) dev->arg;
|
||||
|
||||
if (!blk) {
|
||||
fprintf(stderr, "Invalid virtio_blk device!\n");
|
||||
pr_err("Invalid virtio_blk device!\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* validate inputs for virtio-blk blockrescan */
|
||||
if (newpath == NULL) {
|
||||
fprintf(stderr, "no path info available\n");
|
||||
pr_err("no path info available\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (strstr(newpath, "nodisk") != NULL) {
|
||||
fprintf(stderr, "no valid backend file found\n");
|
||||
pr_err("no valid backend file found\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (snprintf(bident, sizeof(bident), "%d:%d",
|
||||
dev->slot, dev->func) >= sizeof(bident)) {
|
||||
fprintf(stderr, "bident error, please check slot and func\n");
|
||||
pr_err("bident error, please check slot and func\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -680,15 +680,15 @@ virtio_blk_rescan(struct vmctx *ctx, struct pci_vdev *dev, char *newpath)
|
||||
* If this is the case, blk->bc would be null.
|
||||
*/
|
||||
if (blk->bc) {
|
||||
fprintf(stderr, "Replacing valid backend file not supported!\n");
|
||||
pr_err("Replacing valid backend file not supported!\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
fprintf(stderr, "name=%s, Path=%s, ident=%s\n", dev->name, newpath, bident);
|
||||
pr_err("name=%s, Path=%s, ident=%s\n", dev->name, newpath, bident);
|
||||
/* update the bctxt for the virtio-blk device */
|
||||
bctxt = blockif_open(newpath, bident);
|
||||
if (bctxt == NULL) {
|
||||
fprintf(stderr, "Error opening backing file\n");
|
||||
pr_err("Error opening backing file\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -725,30 +725,30 @@ vm_monitor_blkrescan(void *arg, char *devargs)
|
||||
if ((str_slot != NULL) && (str_newpath != NULL)) {
|
||||
error = dm_strtoi(str_slot, &str_slot, 10, &slot);
|
||||
if (error) {
|
||||
fprintf(stderr, "Incorrect slot, error=0x%x!\n", error);
|
||||
pr_err("Incorrect slot, error=0x%x!\n", error);
|
||||
goto end;
|
||||
}
|
||||
|
||||
} else {
|
||||
fprintf(stderr, "Slot info or path not available!");
|
||||
pr_err("Slot info or path not available!");
|
||||
error = -1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
dev = pci_get_vdev_info(slot);
|
||||
if (dev == NULL) {
|
||||
fprintf(stderr, "vdev info failed for Slot %d\n!", slot);
|
||||
pr_err("vdev info failed for Slot %d\n!", slot);
|
||||
error = -1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (strstr(dev->name, "virtio-blk") == NULL) {
|
||||
error = -1;
|
||||
fprintf(stderr, "virtio-blk only supports rescan: found %s at slot %d\n", dev->name, slot);
|
||||
pr_err("virtio-blk only supports rescan: found %s at slot %d\n", dev->name, slot);
|
||||
} else {
|
||||
error = virtio_blk_rescan(ctx, dev, str_newpath);
|
||||
if (error) {
|
||||
fprintf(stderr, "virtio-blk rescan failed!");
|
||||
pr_err("virtio-blk rescan failed!");
|
||||
}
|
||||
}
|
||||
end:
|
||||
|
||||
@@ -639,7 +639,7 @@ virtio_net_parsemac(char *mac_str, uint8_t *mac_addr)
|
||||
if (ea == NULL || ETHER_IS_MULTICAST(ea->ether_addr_octet) ||
|
||||
memcmp(ea->ether_addr_octet, zero_addr, ETHER_ADDR_LEN)
|
||||
== 0) {
|
||||
fprintf(stderr, "Invalid MAC %s\n", mac_str);
|
||||
pr_err("Invalid MAC %s\n", mac_str);
|
||||
return -1;
|
||||
}
|
||||
memcpy(mac_addr, ea->ether_addr_octet, ETHER_ADDR_LEN);
|
||||
@@ -998,7 +998,7 @@ virtio_net_teardown(void *param)
|
||||
close(net->tapfd);
|
||||
net->tapfd = -1;
|
||||
} else
|
||||
fprintf(stderr, "net->tapfd is -1!\n");
|
||||
pr_err("net->tapfd is -1!\n");
|
||||
|
||||
free(net);
|
||||
}
|
||||
@@ -1027,7 +1027,7 @@ virtio_net_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
||||
|
||||
DPRINTF(("%s: done\n", __func__));
|
||||
} else
|
||||
fprintf(stderr, "%s: NULL!\n", __func__);
|
||||
pr_err("%s: NULL!\n", __func__);
|
||||
}
|
||||
|
||||
static struct vhost_net *
|
||||
|
||||
Reference in New Issue
Block a user