This function is going to be made static in used in
virStoragePoolObjAssignDef(). Therefore move it a few lines up.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/conf/virstorageobj.c | 124 +++++++++++++++++++++++------------------------
1 file changed, 62 insertions(+), 62 deletions(-)
diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c
index 6f1e14ed3e..185822451b 100644
--- a/src/conf/virstorageobj.c
+++ b/src/conf/virstorageobj.c
@@ -1047,6 +1047,68 @@ virStoragePoolObjVolumeListExport(virConnectPtr conn,
}
+/*
+ * virStoragePoolObjIsDuplicate:
+ * @doms : virStoragePoolObjListPtr to search
+ * @def : virStoragePoolDefPtr definition of pool to lookup
+ * @check_active: If true, ensure that pool is not active
+ *
+ * Returns: -1 on error
+ * 0 if pool is new
+ * 1 if pool is a duplicate
+ */
+int
+virStoragePoolObjIsDuplicate(virStoragePoolObjListPtr pools,
+ virStoragePoolDefPtr def,
+ bool check_active)
+{
+ int ret = -1;
+ virStoragePoolObjPtr obj = NULL;
+
+ /* See if a Pool with matching UUID already exists */
+ obj = virStoragePoolObjFindByUUID(pools, def->uuid);
+ if (obj) {
+ /* UUID matches, but if names don't match, refuse it */
+ if (STRNEQ(obj->def->name, def->name)) {
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+ virUUIDFormat(obj->def->uuid, uuidstr);
+ virReportError(VIR_ERR_OPERATION_FAILED,
+ _("pool '%s' is already defined with uuid
%s"),
+ obj->def->name, uuidstr);
+ goto cleanup;
+ }
+
+ if (check_active) {
+ /* UUID & name match, but if Pool is already active, refuse it */
+ if (virStoragePoolObjIsActive(obj)) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ _("pool is already active as '%s'"),
+ obj->def->name);
+ goto cleanup;
+ }
+ }
+
+ ret = 1;
+ } else {
+ /* UUID does not match, but if a name matches, refuse it */
+ obj = virStoragePoolObjFindByName(pools, def->name);
+ if (obj) {
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+ virUUIDFormat(obj->def->uuid, uuidstr);
+ virReportError(VIR_ERR_OPERATION_FAILED,
+ _("pool '%s' already exists with uuid %s"),
+ def->name, uuidstr);
+ goto cleanup;
+ }
+ ret = 0;
+ }
+
+ cleanup:
+ virStoragePoolObjEndAPI(&obj);
+ return ret;
+}
+
+
/**
* virStoragePoolObjAssignDef:
* @pools: Storage Pool object list pointer
@@ -1452,68 +1514,6 @@ virStoragePoolObjGetNames(virStoragePoolObjListPtr pools,
}
-/*
- * virStoragePoolObjIsDuplicate:
- * @doms : virStoragePoolObjListPtr to search
- * @def : virStoragePoolDefPtr definition of pool to lookup
- * @check_active: If true, ensure that pool is not active
- *
- * Returns: -1 on error
- * 0 if pool is new
- * 1 if pool is a duplicate
- */
-int
-virStoragePoolObjIsDuplicate(virStoragePoolObjListPtr pools,
- virStoragePoolDefPtr def,
- bool check_active)
-{
- int ret = -1;
- virStoragePoolObjPtr obj = NULL;
-
- /* See if a Pool with matching UUID already exists */
- obj = virStoragePoolObjFindByUUID(pools, def->uuid);
- if (obj) {
- /* UUID matches, but if names don't match, refuse it */
- if (STRNEQ(obj->def->name, def->name)) {
- char uuidstr[VIR_UUID_STRING_BUFLEN];
- virUUIDFormat(obj->def->uuid, uuidstr);
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("pool '%s' is already defined with uuid
%s"),
- obj->def->name, uuidstr);
- goto cleanup;
- }
-
- if (check_active) {
- /* UUID & name match, but if Pool is already active, refuse it */
- if (virStoragePoolObjIsActive(obj)) {
- virReportError(VIR_ERR_OPERATION_INVALID,
- _("pool is already active as '%s'"),
- obj->def->name);
- goto cleanup;
- }
- }
-
- ret = 1;
- } else {
- /* UUID does not match, but if a name matches, refuse it */
- obj = virStoragePoolObjFindByName(pools, def->name);
- if (obj) {
- char uuidstr[VIR_UUID_STRING_BUFLEN];
- virUUIDFormat(obj->def->uuid, uuidstr);
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("pool '%s' already exists with uuid %s"),
- def->name, uuidstr);
- goto cleanup;
- }
- ret = 0;
- }
-
- cleanup:
- virStoragePoolObjEndAPI(&obj);
- return ret;
-}
-
-
static int
getSCSIHostNumber(virStorageAdapterSCSIHostPtr scsi_host,
unsigned int *hostnum)
--
2.16.4