From patchwork Fri Apr 15 21:21:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 65974 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp152759qge; Fri, 15 Apr 2016 14:25:24 -0700 (PDT) X-Received: by 10.55.71.143 with SMTP id u137mr29361624qka.1.1460755524706; Fri, 15 Apr 2016 14:25:24 -0700 (PDT) Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com. [209.132.183.24]) by mx.google.com with ESMTPS id 89si25516321qkq.5.2016.04.15.14.25.23 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 15 Apr 2016 14:25:24 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u3FLLYJg010149; Fri, 15 Apr 2016 17:21:35 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u3FLLWJN019271 for ; Fri, 15 Apr 2016 17:21:32 -0400 Received: from colepc.redhat.com (ovpn-113-40.phx2.redhat.com [10.3.113.40]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3FLLTt0007154; Fri, 15 Apr 2016 17:21:31 -0400 From: Cole Robinson To: libvirt-list@redhat.com Date: Fri, 15 Apr 2016 17:21:28 -0400 Message-Id: <4d42921e4b11f46b7c4ad4fb39c1cd1d01d8cdd0.1460755236.git.crobinso@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/3] storage: drop the plumbing needed for kvm-img/qcow-create X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com Remove all the plumbing needed for the different qcow-create/kvm-img non-raw file creation. We can drop the error messages because CreateQemuImg will thrown an error for us but with slightly less fidelity (unable to find qemu-img), which I think is acceptable given the unlikeliness of that error in practice. --- src/storage/storage_backend.c | 50 ++-------------------------------------- src/storage/storage_backend.h | 9 +++++--- src/storage/storage_backend_fs.c | 11 +-------- 3 files changed, 9 insertions(+), 61 deletions(-) -- 2.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index e4b9b39..a71b838 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -151,10 +151,6 @@ static virStorageFileBackendPtr fileBackends[] = { }; -enum { - TOOL_QEMU_IMG, -}; - #define READ_BLOCK_SIZE_DEFAULT (1024 * 1024) #define WRITE_BLOCK_SIZE_DEFAULT (4 * 1024) @@ -1219,7 +1215,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virConnectPtr conn, return cmd; } -static int +int virStorageBackendCreateQemuImg(virConnectPtr conn, virStoragePoolObjPtr pool, virStorageVolDefPtr vol, @@ -1258,43 +1254,9 @@ virStorageBackendCreateQemuImg(virConnectPtr conn, } virStorageBackendBuildVolFrom -virStorageBackendFSImageToolTypeToFunc(int tool_type) -{ - switch (tool_type) { - case TOOL_QEMU_IMG: - return virStorageBackendCreateQemuImg; - default: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown file create tool type '%d'."), - tool_type); - } - - return NULL; -} - -int -virStorageBackendFindFSImageTool(char **tool) -{ - int tool_type = -1; - char *tmp = NULL; - - if ((tmp = virFindFileInPath("qemu-img")) != NULL) - tool_type = TOOL_QEMU_IMG; - - if (tool) - *tool = tmp; - else - VIR_FREE(tmp); - - return tool_type; -} - -virStorageBackendBuildVolFrom virStorageBackendGetBuildVolFromFunction(virStorageVolDefPtr vol, virStorageVolDefPtr inputvol) { - int tool_type; - if (!inputvol) return NULL; @@ -1305,15 +1267,7 @@ virStorageBackendGetBuildVolFromFunction(virStorageVolDefPtr vol, vol->target.format != VIR_STORAGE_FILE_RAW) || (inputvol->type == VIR_STORAGE_VOL_FILE && inputvol->target.format != VIR_STORAGE_FILE_RAW)) { - - if ((tool_type = virStorageBackendFindFSImageTool(NULL)) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("creation of non-raw file images is " - "not supported without qemu-img.")); - return NULL; - } - - return virStorageBackendFSImageToolTypeToFunc(tool_type); + return virStorageBackendCreateQemuImg; } if (vol->type == VIR_STORAGE_VOL_PLOOP) diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h index a1e39c5..5bc622c 100644 --- a/src/storage/storage_backend.h +++ b/src/storage/storage_backend.h @@ -109,6 +109,12 @@ int virStorageBackendCreateRaw(virConnectPtr conn, virStorageVolDefPtr inputvol, unsigned int flags); +int virStorageBackendCreateQemuImg(virConnectPtr conn, + virStoragePoolObjPtr pool, + virStorageVolDefPtr vol, + virStorageVolDefPtr inputvol, + unsigned int flags); + int virStorageBackendCreatePloop(virConnectPtr conn, virStoragePoolObjPtr pool, virStorageVolDefPtr vol, @@ -126,9 +132,6 @@ bool virStorageBackendIsPloopDir(char *path); virStorageBackendBuildVolFrom virStorageBackendGetBuildVolFromFunction(virStorageVolDefPtr vol, virStorageVolDefPtr inputvol); -int virStorageBackendFindFSImageTool(char **tool); -virStorageBackendBuildVolFrom -virStorageBackendFSImageToolTypeToFunc(int tool_type); int virStorageBackendFindGlusterPoolSources(const char *host, int pooltype, diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c index 47d0f54..02a129e 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -1170,7 +1170,6 @@ _virStorageBackendFileSystemVolBuild(virConnectPtr conn, unsigned int flags) { virStorageBackendBuildVolFrom create_func; - int tool_type; if (inputvol) { if (vol->target.encryption != NULL) { @@ -1190,16 +1189,8 @@ _virStorageBackendFileSystemVolBuild(virConnectPtr conn, create_func = createFileDir; } else if (vol->target.format == VIR_STORAGE_FILE_PLOOP) { create_func = virStorageBackendCreatePloop; - } else if ((tool_type = virStorageBackendFindFSImageTool(NULL)) != -1) { - create_func = virStorageBackendFSImageToolTypeToFunc(tool_type); - - if (!create_func) - return -1; } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("creation of non-raw images " - "is not supported without qemu-img")); - return -1; + create_func = virStorageBackendCreateQemuImg; } if (create_func(conn, pool, vol, inputvol, flags) < 0)