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

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



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 parallels com>
> ---
>  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 redhat com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | virtualization library  http://libvirt.org/


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