-/* $OpenBSD: vioqcow2.c,v 1.1 2018/09/09 04:09:32 ccardenas Exp $ */
+/* $OpenBSD: vioqcow2.c,v 1.2 2018/09/11 04:06:32 ccardenas Exp $ */
/*
* Copyright (c) 2018 Ori Bernstein <ori@eigenstate.org>
if (diskp == NULL)
return -1;
if (qc2_open(diskp, fd) == -1) {
- log_warnx("could not open qcow2 disk");
+ log_warnx("%s: could not open qcow2 disk", __func__);
free(diskp);
return -1;
}
int version;
if (pread(fd, &header, sizeof header, 0) != sizeof header) {
- log_warn("short read on header");
+ log_warn("%s: short read on header", __func__);
return -1;
}
if (strncmp(header.magic, "QFI\xfb", 4) != 0) {
- log_warn("invalid magic numbers");
+ log_warn("%s: invalid magic numbers", __func__);
return -1;
}
pthread_rwlock_init(&disk->lock, NULL);
* We only know about the dirty or corrupt bits here.
*/
if (disk->incompatfeatures & ~(QCOW2_DIRTY|QCOW2_CORRUPT)) {
- log_warn("%s: unsupported features %llx", __progname,
+ log_warn("%s: unsupported features %llx", __func__,
disk->incompatfeatures & ~(QCOW2_DIRTY|QCOW2_CORRUPT));
return -1;
}
disk->l1[i] = be64toh(disk->l1[i]);
version = be32toh(header.version);
if (version != 2 && version != 3) {
- log_warn("%s: unknown qcow2 version %d", __progname, version);
+ log_warn("%s: unknown qcow2 version %d", __func__, version);
return -1;
}
* FIXME: we need to figure out a way of opening these things,
* otherwise we just crash with a pledge violation.
*/
- log_warn("unsupported external snapshot images");
+ log_warn("%s: unsupported external snapshot images", __func__);
return -1;
if (backingsz >= sizeof basepath - 1) {
- log_warn("%s: snapshot path too long", __progname);
+ log_warn("%s: snapshot path too long", __func__);
return -1;
}
if (pread(fd, basepath, backingsz, backingoff) != backingsz) {
log_warn("%s: could not read snapshot base name",
- __progname);
+ __func__);
return -1;
}
basepath[backingsz] = 0;
}
if (disk->base->clustersz != disk->clustersz) {
log_warn("%s: all disks must share clustersize",
- __progname);
+ __func__);
free(disk->base);
return -1;
}
if (inplace)
*inplace = !!(cluster & QCOW2_INPLACE);
if (cluster & QCOW2_COMPRESSED) {
- log_warn("%s: compressed clusters unsupported", __progname);
+ log_warn("%s: compressed clusters unsupported", __func__);
goto err;
}
pthread_rwlock_unlock(&disk->lock);
l2cluster = disk->end;
disk->end += disk->clustersz;
if (ftruncate(disk->fd, disk->end) < 0) {
- log_warn("refs block grow fail ");
+ log_warn("%s: refs block grow fail", __func__);
return -1;
}
buf = htobe64(l2cluster);
}
refs = htobe16(refs);
if (pwrite(disk->fd, &refs, sizeof refs, l2cluster + 2*l2idx) != 2) {
- log_warn("could not write ref block");
+ log_warn("%s: could not write ref block", __func__);
+ return -1;
}
return 0;
}
-/* $OpenBSD: virtio.c,v 1.65 2018/09/09 04:09:32 ccardenas Exp $ */
+/* $OpenBSD: virtio.c,v 1.66 2018/09/11 04:06:32 ccardenas Exp $ */
/*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
case VMDF_RAW: return virtio_init_raw(file, sz, fd);
case VMDF_QCOW2: return virtio_init_qcow2(file, sz, fd);
}
- log_warnx("%s: invalid disk format", __progname);
+ log_warnx("%s: invalid disk format", __func__);
return -1;
}
vioblk[i].vm_id = vcp->vcp_id;
vioblk[i].irq = pci_get_dev_irq(id);
if (virtio_init_disk(&vioblk[i].file, &vioblk[i].sz,
- child_disks[i], vmc->vmc_disktypes[i]) == -1)
- continue;
+ child_disks[i], vmc->vmc_disktypes[i]) == -1) {
+ log_warnx("%s: unable to determine disk fmt",
+ __func__);
+ return;
+ }
vioblk[i].sz /= 512;
}
}
vioscsi->vq[i].last_avail = 0;
}
if (virtio_init_disk(&vioscsi->file, &vioscsi->sz,
- child_cdrom, VMDF_RAW) == -1)
+ child_cdrom, VMDF_RAW) == -1) {
+ log_warnx("%s: unable to determine iso fmt", __func__);
return;
+ }
vioscsi->locked = 0;
vioscsi->lba = 0;
vioscsi->n_blocks = vioscsi->sz >> 11; /* num of 2048 blocks in file */
return (-1);
}
if (virtio_init_disk(&vioblk[i].file, &vioblk[i].sz,
- child_disks[i], vmc->vmc_disktypes[i]) == -1)
- continue;
+ child_disks[i], vmc->vmc_disktypes[i]) == -1) {
+ log_warnx("%s: unable to determine disk fmt",
+ __func__);
+ return (-1);
+ }
}
return (0);
}
return (-1);
}
- virtio_init_disk(&vioscsi->file, &vioscsi->sz, child_cdrom, VMDF_RAW);
+ if (virtio_init_disk(&vioscsi->file, &vioscsi->sz, child_cdrom,
+ VMDF_RAW) == -1) {
+ log_warnx("%s: unable to determine iso fmt", __func__);
+ return (-1);
+ }
return (0);
}