提交 3ec34fd7 编写于 作者: J Ján Tomko

esx: use virCryptoHashBuf

Instead of using md5_buffer from gnulib directly.
Signed-off-by: NJán Tomko <jtomko@redhat.com>
上级 0eeedd61
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "esx_vi.h" #include "esx_vi.h"
#include "esx_vi_methods.h" #include "esx_vi_methods.h"
#include "esx_util.h" #include "esx_util.h"
#include "vircrypto.h"
#include "virstring.h" #include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_ESX #define VIR_FROM_THIS VIR_FROM_ESX
...@@ -152,7 +153,8 @@ esxNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid) ...@@ -152,7 +153,8 @@ esxNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
for (hostVirtualSwitch = hostVirtualSwitchList; hostVirtualSwitch; for (hostVirtualSwitch = hostVirtualSwitchList; hostVirtualSwitch;
hostVirtualSwitch = hostVirtualSwitch->_next) { hostVirtualSwitch = hostVirtualSwitch->_next) {
md5_buffer(hostVirtualSwitch->key, strlen(hostVirtualSwitch->key), md5); if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, hostVirtualSwitch->key, md5) < 0)
goto cleanup;
if (memcmp(uuid, md5, VIR_UUID_BUFLEN) == 0) if (memcmp(uuid, md5, VIR_UUID_BUFLEN) == 0)
break; break;
...@@ -201,7 +203,8 @@ esxNetworkLookupByName(virConnectPtr conn, const char *name) ...@@ -201,7 +203,8 @@ esxNetworkLookupByName(virConnectPtr conn, const char *name)
* The MD5 sum of the key can be used as UUID, assuming MD5 is considered * The MD5 sum of the key can be used as UUID, assuming MD5 is considered
* to be collision-free enough for this use case. * to be collision-free enough for this use case.
*/ */
md5_buffer(hostVirtualSwitch->key, strlen(hostVirtualSwitch->key), md5); if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, hostVirtualSwitch->key, md5) < 0)
return NULL;
network = virGetNetwork(conn, hostVirtualSwitch->name, md5); network = virGetNetwork(conn, hostVirtualSwitch->name, md5);
...@@ -464,7 +467,8 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml) ...@@ -464,7 +467,8 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
goto cleanup; goto cleanup;
} }
md5_buffer(hostVirtualSwitch->key, strlen(hostVirtualSwitch->key), md5); if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, hostVirtualSwitch->key, md5) < 0)
goto cleanup;
network = virGetNetwork(conn, hostVirtualSwitch->name, md5); network = virGetNetwork(conn, hostVirtualSwitch->name, md5);
...@@ -655,7 +659,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags) ...@@ -655,7 +659,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
goto cleanup; goto cleanup;
} }
md5_buffer(hostVirtualSwitch->key, strlen(hostVirtualSwitch->key), def->uuid); if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, hostVirtualSwitch->key, def->uuid) < 0)
goto cleanup;
if (VIR_STRDUP(def->name, hostVirtualSwitch->name) < 0) if (VIR_STRDUP(def->name, hostVirtualSwitch->name) < 0)
goto cleanup; goto cleanup;
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "esx_vi.h" #include "esx_vi.h"
#include "esx_vi_methods.h" #include "esx_vi_methods.h"
#include "esx_util.h" #include "esx_util.h"
#include "vircrypto.h"
#include "virstring.h" #include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_ESX #define VIR_FROM_THIS VIR_FROM_ESX
...@@ -180,7 +181,8 @@ esxStoragePoolLookupByName(virConnectPtr conn, ...@@ -180,7 +181,8 @@ esxStoragePoolLookupByName(virConnectPtr conn,
* but iScsiName (or widely known as IQN) is unique across the multiple * but iScsiName (or widely known as IQN) is unique across the multiple
* hosts, using it to compute key * hosts, using it to compute key
*/ */
md5_buffer(target->iScsiName, strlen(target->iScsiName), md5); if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, target->iScsiName, md5) < 0)
goto cleanup;
pool = virGetStoragePool(conn, name, md5, &esxStorageBackendISCSI, NULL); pool = virGetStoragePool(conn, name, md5, &esxStorageBackendISCSI, NULL);
...@@ -218,7 +220,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn, ...@@ -218,7 +220,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn,
for (target = hostInternetScsiHba->configuredStaticTarget; for (target = hostInternetScsiHba->configuredStaticTarget;
target; target = target->_next) { target; target = target->_next) {
md5_buffer(target->iScsiName, strlen(target->iScsiName), md5); if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, target->iScsiName, md5) < 0)
goto cleanup;
if (memcmp(uuid, md5, VIR_UUID_BUFLEN) == 0) if (memcmp(uuid, md5, VIR_UUID_BUFLEN) == 0)
break; break;
...@@ -456,7 +459,8 @@ esxStorageVolLookupByName(virStoragePoolPtr pool, ...@@ -456,7 +459,8 @@ esxStorageVolLookupByName(virStoragePoolPtr pool,
* compute MD5 hash to transform it to an acceptable * compute MD5 hash to transform it to an acceptable
* libvirt format * libvirt format
*/ */
md5_buffer(scsiLun->uuid, strlen(scsiLun->uuid), md5); if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, scsiLun->uuid, md5) < 0)
goto cleanup;
virUUIDFormat(md5, uuid_string); virUUIDFormat(md5, uuid_string);
/* /*
...@@ -507,7 +511,8 @@ esxStorageVolLookupByPath(virConnectPtr conn, const char *path) ...@@ -507,7 +511,8 @@ esxStorageVolLookupByPath(virConnectPtr conn, const char *path)
goto cleanup; goto cleanup;
} }
md5_buffer(scsiLun->uuid, strlen(scsiLun->uuid), md5); if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, scsiLun->uuid, md5) < 0)
goto cleanup;
virUUIDFormat(md5, uuid_string); virUUIDFormat(md5, uuid_string);
volume = virGetStorageVol(conn, poolName, path, uuid_string, volume = virGetStorageVol(conn, poolName, path, uuid_string,
...@@ -549,7 +554,8 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key) ...@@ -549,7 +554,8 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
memset(uuid_string, '\0', sizeof(uuid_string)); memset(uuid_string, '\0', sizeof(uuid_string));
memset(md5, '\0', sizeof(md5)); memset(md5, '\0', sizeof(md5));
md5_buffer(scsiLun->uuid, strlen(scsiLun->uuid), md5); if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, scsiLun->uuid, md5) < 0)
goto cleanup;
virUUIDFormat(md5, uuid_string); virUUIDFormat(md5, uuid_string);
if (STREQ(key, uuid_string)) { if (STREQ(key, uuid_string)) {
...@@ -697,7 +703,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, ...@@ -697,7 +703,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume,
def.name = volume->name; def.name = volume->name;
md5_buffer(scsiLun->uuid, strlen(scsiLun->uuid), md5); if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, scsiLun->uuid, md5) < 0)
goto cleanup;
virUUIDFormat(md5, uuid_string); virUUIDFormat(md5, uuid_string);
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "esx_vi.h" #include "esx_vi.h"
#include "esx_vi_methods.h" #include "esx_vi_methods.h"
#include "esx_util.h" #include "esx_util.h"
#include "vircrypto.h"
#include "virstring.h" #include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_ESX #define VIR_FROM_THIS VIR_FROM_ESX
...@@ -236,8 +237,8 @@ esxStoragePoolLookupByName(virConnectPtr conn, ...@@ -236,8 +237,8 @@ esxStoragePoolLookupByName(virConnectPtr conn,
goto cleanup; goto cleanup;
} }
md5_buffer(hostMount->mountInfo->path, if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, hostMount->mountInfo->path, md5) < 0)
strlen(hostMount->mountInfo->path), md5); goto cleanup;
pool = virGetStoragePool(conn, name, md5, &esxStorageBackendVMFS, NULL); pool = virGetStoragePool(conn, name, md5, &esxStorageBackendVMFS, NULL);
...@@ -289,8 +290,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn, ...@@ -289,8 +290,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn,
goto cleanup; goto cleanup;
} }
md5_buffer(hostMount->mountInfo->path, if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, hostMount->mountInfo->path, md5) < 0)
strlen(hostMount->mountInfo->path), md5); goto cleanup;
if (memcmp(uuid, md5, VIR_UUID_BUFLEN) == 0) if (memcmp(uuid, md5, VIR_UUID_BUFLEN) == 0)
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册