From: Peter Krempa <[email protected]> Replace use of 'qemuStorageLimitsRefresh' by 'qemuDomainStorageSourceProbeSize'.
Signed-off-by: Peter Krempa <[email protected]> --- src/qemu/qemu_driver.c | 93 ++++-------------------------------------- 1 file changed, 7 insertions(+), 86 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c6e35c58a4..13988d6568 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10633,87 +10633,6 @@ qemuDomainMemoryPeek(virDomainPtr dom, } -/** - * @cfg: driver configuration data - * @vm: domain object - * @src: storage source data - * @skipInaccessible: Suppress reporting of common errors when accessing @src - * - * Refresh the capacity and allocation limits of a given storage source. - * - * Assumes that the caller has already obtained a domain job and only - * called for an offline domain. Being offline is particularly important - * since reading a file while qemu is writing it risks the reader seeing - * bogus data or avoiding opening a file in order to get stat data. - * - * We always want to check current on-disk statistics (as users have been - * known to change offline images behind our backs). - * - * For read-only disks, nothing should be changing unless the user has - * requested a block-commit action. For read-write disks, we know some - * special cases: capacity should not change without a block-resize (where - * capacity is the only stat that requires reading a file, and even then, - * only for non-raw files); and physical size of a raw image or of a - * block device should likewise not be changing without block-resize. - * On the other hand, allocation of a raw file can change (if the file - * is sparse, but the amount of sparseness changes due to writes or - * punching holes), and physical size of a non-raw file can change. - * - * Returns 1 if @src was successfully updated, 0 if @src can't be opened and - * @skipInaccessible is true (no errors are reported) or -1 otherwise (errors - * are reported). - */ -static int -qemuStorageLimitsRefresh(virQEMUDriverConfig *cfg, - virDomainObj *vm, - virStorageSource *src, - bool skipInaccessible) -{ - int rc; - int ret = -1; - int fd = -1; - struct stat sb; - g_autofree char *buf = NULL; - ssize_t len; - - if ((rc = qemuDomainStorageOpenStat(cfg, vm, src, &fd, &sb, - skipInaccessible)) <= 0) - return rc; - - if (virStorageSourceIsLocalStorage(src)) { - if ((len = virFileReadHeaderFD(fd, VIR_STORAGE_MAX_HEADER, &buf)) < 0) { - virReportSystemError(errno, _("cannot read header '%1$s'"), - src->path); - goto cleanup; - } - } else { - if ((len = virStorageSourceRead(src, 0, VIR_STORAGE_MAX_HEADER, &buf)) < 0) - goto cleanup; - } - - if (virStorageSourceUpdateBackingSizes(src, fd, &sb) < 0) - goto cleanup; - - if (virStorageSourceUpdateCapacity(src, buf, len) < 0) - goto cleanup; - - /* If guest is not using raw disk format and is on a host block - * device, then leave the value unspecified, so caller knows to - * query the highest allocated extent from QEMU - */ - if (virStorageSourceGetActualType(src) == VIR_STORAGE_TYPE_BLOCK && - !qemuBlockStorageSourceIsRaw(src) && - S_ISBLK(sb.st_mode)) - src->allocation = 0; - - ret = 1; - - cleanup: - qemuDomainStorageCloseStat(src, &fd); - return ret; -} - - static int qemuDomainGetBlockInfo(virDomainPtr dom, const char *path, @@ -10767,12 +10686,14 @@ qemuDomainGetBlockInfo(virDomainPtr dom, /* for inactive domains we have to peek into the files */ if (!virDomainObjIsActive(vm)) { - if ((qemuStorageLimitsRefresh(cfg, vm, disk->src, false)) < 0) + if (qemuDomainStorageSourceProbeSize(cfg, vm, disk->src, + &info->allocation, + &info->capacity, + &info->physical) < 0) { + virReportError(VIR_ERR_OPERATION_FAILED, + _("failed to fetch size data for '%1$s'"), path); goto endjob; - - info->capacity = disk->src->capacity; - info->allocation = disk->src->allocation; - info->physical = disk->src->physical; + } ret = 0; goto endjob; -- 2.54.0
