[libvirt] [PATCH 0/2] Directory shouldn't be listed as type 'file' with vol-list command

After adding option to have directiories as storage volumes virsh reported type of this storage volumes as 'file'. This patch fixes this type in data structures and fixes the virsh output. https://bugzilla.redhat.com/show_bug.cgi?id=727088 Peter Krempa (2): storage: Directory shouldn't be listed as type 'file' virsh: Add dir type for listing volumes with vol-list include/libvirt/libvirt.h.in | 1 + src/storage/storage_backend_fs.c | 4 ++++ tools/virsh.c | 17 +++++++++++++---- 3 files changed, 18 insertions(+), 4 deletions(-) -- 1.7.6

Fix internals of libvirt for new storage volume type. Libvirt reported an invalid type of the volume. BZ #727088 --- include/libvirt/libvirt.h.in | 1 + src/storage/storage_backend_fs.c | 4 ++++ 2 files changed, 5 insertions(+), 0 deletions(-) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index b1bda31..aa29fb6 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -1705,6 +1705,7 @@ typedef virStorageVol *virStorageVolPtr; typedef enum { VIR_STORAGE_VOL_FILE = 0, /* Regular file based volumes */ VIR_STORAGE_VOL_BLOCK = 1, /* Block based volumes */ + VIR_STORAGE_VOL_DIR = 2, /* Directory-passthrough based volume */ } virStorageVolType; typedef enum { diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c index 058e00c..ff5afaa 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -675,6 +675,10 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED, goto cleanup; } + /* directory based volume */ + if (vol->target.format == VIR_STORAGE_FILE_DIR) + vol->type = VIR_STORAGE_VOL_DIR; + if (backingStore != NULL) { vol->backingStore.path = backingStore; vol->backingStore.format = backingStoreFormat; -- 1.7.6

Fix of output of detailed volume list. BZ #727088 --- tools/virsh.c | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index 1d660d0..5d88d84 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -8989,10 +8989,19 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) /* Convert the returned volume info into output strings */ /* Volume type */ - if (volumeInfo.type == VIR_STORAGE_VOL_FILE) - volInfoTexts[i].type = vshStrdup(ctl, _("file")); - else - volInfoTexts[i].type = vshStrdup(ctl, _("block")); + switch (volumeInfo.type) { + case VIR_STORAGE_VOL_FILE: + volInfoTexts[i].type = vshStrdup(ctl, _("file")); + break; + case VIR_STORAGE_VOL_BLOCK: + volInfoTexts[i].type = vshStrdup(ctl, _("block")); + break; + case VIR_STORAGE_VOL_DIR: + volInfoTexts[i].type = vshStrdup(ctl, _("dir")); + break; + default: + volInfoTexts[i].type = vshStrdup(ctl, _("unknown")); + } /* Create the capacity output string */ val = prettyCapacity(volumeInfo.capacity, &unit); -- 1.7.6

On 08/11/2011 03:37 AM, Peter Krempa wrote:
After adding option to have directiories as storage volumes virsh reported type of this storage volumes as 'file'. This patch fixes this type in data structures and fixes the virsh output.
https://bugzilla.redhat.com/show_bug.cgi?id=727088
Peter Krempa (2): storage: Directory shouldn't be listed as type 'file' virsh: Add dir type for listing volumes with vol-list
ACK and series pushed. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Peter Krempa