[libvirt] [PATCH 6/7] storage:dir: adapts .refreshVol .refreshPool for ploop volumes
Ján Tomko
jtomko at redhat.com
Tue Apr 5 15:01:24 UTC 2016
On Mon, Mar 14, 2016 at 07:00:39PM +0300, Olga Krishtal wrote:
> Refreshes meta-information such as allocation, capacity, format, etc.
> Ploop volumes differ from other volume types. Path to volume is the path
> to directory with image file root.hds and DiskDescriptor.xml.
> https://openvz.org/Ploop/format
> Due to this fact, operations of opening the volume have to be done once
> again. get the information.
>
> To decide whether the given volume is ploops one, it is necessary to check
> the presence of root.hds and DiskDescriptor.xml files in volumes' directory.
> Only in this case the volume can be manipulated as the ploops one.
> Such strategy helps us to resolve problems that might occure, when we
> upload some other volume type from ploop source.
>
> Signed-off-by: Olga Krishtal <okrishtal at virtuozzo.com>
> ---
> src/storage/storage_backend.c | 62 ++++++++++++++++++++++++++++++++++++--
> src/storage/storage_backend.h | 5 ++++
> src/storage/storage_backend_fs.c | 64 +++++++++++++++++++++++++++++++++++++---
> src/util/virstoragefile.c | 7 +++--
> 4 files changed, 129 insertions(+), 9 deletions(-)
>
> @@ -69,6 +109,7 @@ virStorageBackendProbeTarget(virStorageSourcePtr target,
> int fd = -1;
> int ret = -1;
> int rc;
> + int format = VIR_STORAGE_FILE_AUTO;
> virStorageSourcePtr meta = NULL;
> struct stat sb;
>
> @@ -84,14 +125,26 @@ virStorageBackendProbeTarget(virStorageSourcePtr target,
> goto cleanup;
>
> if (S_ISDIR(sb.st_mode)) {
> - target->format = VIR_STORAGE_FILE_DIR;
> - ret = 0;
> - goto cleanup;
> + if (virStorageBackendIsPloopDir(target->path)) {
> + if (virStorageBackendRedoPloopUpdate(target, &sb, &fd,
> + VIR_STORAGE_VOL_FS_PROBE_FLAGS)
> + < 0)
> + goto cleanup;
> + /* Refresh information stored in DiskDescriptor.xml according
> + * to ploop image file content.*/
> + if (virStorageBackendPloopRestoreDesc(target->path) < 0)
> + goto cleanup;
Probing a volume should not change its contents - libvirt should only
refresh this XML when it changed the volume.
The rest looks good to me.
Jan
More information about the libvir-list
mailing list