const char *nodename = NULL;
virDomainDiskDef *disk = NULL;
virDomainDiskDef *persistDisk = NULL;
+ virStorageSource *size_src = NULL;
virCheckFlags(VIR_DOMAIN_BLOCK_RESIZE_BYTES |
VIR_DOMAIN_BLOCK_RESIZE_CAPACITY |
goto endjob;
}
- /* The physical capacity is needed both when automatic sizing is requested
- * and when a slice is used on top of a block device.
+ /* When resizing to capacity (or when resizing a device with a storage slice
+ * -> effectively removing the slice) it's possible that we're dealing with
+ * a qcow2 image using the 'data-file' feature in which case we want to use
+ * the size of the data file. Similarly all limitations about the support of
+ * VIR_DOMAIN_BLOCK_RESIZE_CAPACITY are based on the actual 'data-file'
+ * which stores the actual blocks and thus represents the capacity.
*/
- if (virStorageSourceIsBlockLocal(disk->src) &&
- ((flags & VIR_DOMAIN_BLOCK_RESIZE_CAPACITY) ||
- disk->src->sliceStorage)) {
+ if ((flags & VIR_DOMAIN_BLOCK_RESIZE_CAPACITY) || disk->src->sliceStorage) {
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(priv->driver);
- if (qemuDomainStorageUpdatePhysical(cfg, vm, disk->src) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("failed to update capacity of '%1$s'"), disk->src->path);
- goto endjob;
+ if (disk->src->dataFileStore)
+ size_src = disk->src->dataFileStore;
+ else
+ size_src = disk->src;
+
+ if (flags & VIR_DOMAIN_BLOCK_RESIZE_CAPACITY) {
+ if (!qemuBlockStorageSourceIsRaw(size_src) ||
+ !virStorageSourceIsBlockLocal(size_src)) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("block resize to full capacity supported only with 'raw' or local block-based disks"));
+ goto endjob;
+ }
}
+ if (virStorageSourceIsBlockLocal(size_src)) {
+ if (qemuDomainStorageUpdatePhysical(cfg, vm, size_src) < 0) {
+ virReportError(VIR_ERR_OPERATION_FAILED,
+ _("failed to update capacity of '%1$s'"), size_src->path);
+ goto endjob;
+ }
+ }
}
if (flags & VIR_DOMAIN_BLOCK_RESIZE_CAPACITY) {
- if (!qemuBlockStorageSourceIsRaw(disk->src) ||
- !virStorageSourceIsBlockLocal(disk->src)) {
- virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
- _("block resize to full capacity supported only with 'raw' local block-based disks"));
- goto endjob;
- }
-
if (size == 0) {
- size = disk->src->physical;
- } else if (size != disk->src->physical) {
+ size = size_src->physical;
+ } else if (size != size_src->physical) {
virReportError(VIR_ERR_INVALID_ARG,
_("Requested resize to '%1$llu' but device size is '%2$llu'"),
- size, disk->src->physical);
+ size, size_src->physical);
goto endjob;
}
}