Re: [PATCH v4 09/13] parallels: split parallelsStorageVolumeDelete function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 04, 2012 at 05:43:09PM +0400, Dmitry Guryanov wrote:
> Move part, which deletes existing volume, to a new function
> parallelsStorageVolumeDefRemove so that we can use it later
> in parallels_driver.c
> 
> Signed-off-by: Dmitry Guryanov <dguryanov@xxxxxxxxxxxxx>
> ---
>  src/parallels/parallels_storage.c |   83 +++++++++++++++++++++---------------
>  src/parallels/parallels_utils.h   |    2 +
>  2 files changed, 50 insertions(+), 35 deletions(-)
> 
> diff --git a/src/parallels/parallels_storage.c b/src/parallels/parallels_storage.c
> index 1448a74..ad15687 100644
> --- a/src/parallels/parallels_storage.c
> +++ b/src/parallels/parallels_storage.c
> @@ -1443,48 +1443,17 @@ cleanup:
>      return ret;
>  }
>  
> -static int
> -parallelsStorageVolumeDelete(virStorageVolPtr vol, unsigned int flags)
> +int parallelsStorageVolumeDefRemove(virStoragePoolObjPtr privpool,
> +                                    virStorageVolDefPtr privvol)
>  {
> -    parallelsConnPtr privconn = vol->conn->privateData;
> -    virStoragePoolObjPtr privpool;
> -    virStorageVolDefPtr privvol;
> -    size_t i;
>      int ret = -1;
>      char *xml_path = NULL;
>  
> -    virCheckFlags(0, -1);
> -
> -    parallelsDriverLock(privconn);
> -    privpool = virStoragePoolObjFindByName(&privconn->pools, vol->pool);
> -    parallelsDriverUnlock(privconn);
> -
> -    if (privpool == NULL) {
> -        parallelsPoolNotFoundError(vol->pool);
> -        goto cleanup;
> -    }
> -
> -
> -    privvol = virStorageVolDefFindByName(privpool, vol->name);
> -
> -    if (privvol == NULL) {
> -        virReportError(VIR_ERR_NO_STORAGE_VOL,
> -                       _("no storage vol with matching name '%s'"), vol->name);
> -        goto cleanup;
> -    }
> -
> -    if (!virStoragePoolObjIsActive(privpool)) {
> -        virReportError(VIR_ERR_OPERATION_INVALID,
> -                       _("storage pool '%s' is not active"), vol->pool);
> -        goto cleanup;
> -    }
> -
> -
>      privpool->def->allocation -= privvol->allocation;
>      privpool->def->available = (privpool->def->capacity -
>                                  privpool->def->allocation);
>  
> -    for (i = 0; i < privpool->volumes.count; i++) {
> +    for (size_t i = 0; i < privpool->volumes.count; i++) {

  Again variable decalration goes in block start, so squashing in
the following:

diff --git a/src/parallels/parallels_storage.c b/src/parallels/parallels_storage.c
index ad15687..90fa104 100644
--- a/src/parallels/parallels_storage.c
+++ b/src/parallels/parallels_storage.c
@@ -1448,12 +1448,13 @@ int parallelsStorageVolumeDefRemove(virStoragePoolObjPtr privpool,
 {
     int ret = -1;
     char *xml_path = NULL;
+    size_t i;
 
     privpool->def->allocation -= privvol->allocation;
     privpool->def->available = (privpool->def->capacity -
                                 privpool->def->allocation);
 
-    for (size_t i = 0; i < privpool->volumes.count; i++) {
+    for (i = 0; i < privpool->volumes.count; i++) {
         if (privpool->volumes.objs[i] == privvol) {
             xml_path = parallelsAddFileExt(privvol->target.path, ".xml");
             if (!xml_path)

Daniel

-- 
Daniel Veillard      | Open Source and Standards, Red Hat
veillard@xxxxxxxxxx  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]