mirror of https://gitee.com/openkylin/libvirt.git
Rename UUID functions
This commit is contained in:
parent
b63f8cc9f9
commit
3d6a119de8
|
@ -1,3 +1,8 @@
|
||||||
|
Tue Jun 26 18:10:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
|
* qemud/conf.c, qemud/uuid.c, qemud/uuid.h: Rename the
|
||||||
|
UUID functions to not include QEMU in name.
|
||||||
|
|
||||||
Tue Jun 26 18:10:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
|
Tue Jun 26 18:10:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
* qemud/conf.c, qemud/conf.h, qemud/dispatch.c, qemud/driver.c,
|
* qemud/conf.c, qemud/conf.h, qemud/dispatch.c, qemud/driver.c,
|
||||||
|
|
|
@ -823,12 +823,12 @@ static struct qemud_vm_def *qemudParseXML(struct qemud_driver *driver,
|
||||||
if ((obj == NULL) || (obj->type != XPATH_STRING) ||
|
if ((obj == NULL) || (obj->type != XPATH_STRING) ||
|
||||||
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
|
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
|
||||||
int err;
|
int err;
|
||||||
if ((err = qemudGenerateUUID(def->uuid))) {
|
if ((err = virUUIDGenerate(def->uuid))) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||||
"Failed to generate UUID: %s", strerror(err));
|
"Failed to generate UUID: %s", strerror(err));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
} else if (qemudParseUUID((const char *)obj->stringval, def->uuid) < 0) {
|
} else if (virUUIDParse((const char *)obj->stringval, def->uuid) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "malformed uuid element");
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "malformed uuid element");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -1936,12 +1936,12 @@ static struct qemud_network_def *qemudParseNetworkXML(struct qemud_driver *drive
|
||||||
if ((obj == NULL) || (obj->type != XPATH_STRING) ||
|
if ((obj == NULL) || (obj->type != XPATH_STRING) ||
|
||||||
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
|
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
|
||||||
int err;
|
int err;
|
||||||
if ((err = qemudGenerateUUID(def->uuid))) {
|
if ((err = virUUIDGenerate(def->uuid))) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||||
"Failed to generate UUID: %s", strerror(err));
|
"Failed to generate UUID: %s", strerror(err));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
} else if (qemudParseUUID((const char *)obj->stringval, def->uuid) < 0) {
|
} else if (virUUIDParse((const char *)obj->stringval, def->uuid) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "malformed uuid element");
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "malformed uuid element");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
16
qemud/uuid.c
16
qemud/uuid.c
|
@ -35,8 +35,8 @@
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemudGenerateRandomBytes(unsigned char *buf,
|
virUUIDGenerateRandomBytes(unsigned char *buf,
|
||||||
int buflen)
|
int buflen)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
|
@ -63,8 +63,8 @@ qemudGenerateRandomBytes(unsigned char *buf,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemudGeneratePseudoRandomBytes(unsigned char *buf,
|
virUUIDGeneratePseudoRandomBytes(unsigned char *buf,
|
||||||
int buflen)
|
int buflen)
|
||||||
{
|
{
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
while (buflen > 0) {
|
while (buflen > 0) {
|
||||||
|
@ -76,20 +76,20 @@ qemudGeneratePseudoRandomBytes(unsigned char *buf,
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
qemudGenerateUUID(unsigned char *uuid)
|
virUUIDGenerate(unsigned char *uuid)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if ((err = qemudGenerateRandomBytes(uuid, QEMUD_UUID_RAW_LEN)))
|
if ((err = virUUIDGenerateRandomBytes(uuid, VIR_UUID_RAW_LEN)))
|
||||||
qemudLog(QEMUD_WARN,
|
qemudLog(QEMUD_WARN,
|
||||||
"Falling back to pseudorandom UUID, "
|
"Falling back to pseudorandom UUID, "
|
||||||
"failed to generate random bytes: %s", strerror(err));
|
"failed to generate random bytes: %s", strerror(err));
|
||||||
|
|
||||||
return qemudGeneratePseudoRandomBytes(uuid, QEMUD_UUID_RAW_LEN);
|
return virUUIDGeneratePseudoRandomBytes(uuid, VIR_UUID_RAW_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
qemudParseUUID(const char *uuid, unsigned char *rawuuid) {
|
virUUIDParse(const char *uuid, unsigned char *rawuuid) {
|
||||||
const char *cur;
|
const char *cur;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
14
qemud/uuid.h
14
qemud/uuid.h
|
@ -19,12 +19,14 @@
|
||||||
* Mark McLoughlin <markmc@redhat.com>
|
* Mark McLoughlin <markmc@redhat.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __QEMUD_UUID_H__
|
#ifndef __VIR_UUID_H__
|
||||||
#define __QEMUD_UUID_H__
|
#define __VIR_UUID_H__
|
||||||
|
|
||||||
int qemudGenerateUUID(unsigned char *uuid);
|
#define VIR_UUID_RAW_LEN 16
|
||||||
|
|
||||||
int qemudParseUUID (const char *uuid,
|
int virUUIDGenerate(unsigned char *uuid);
|
||||||
unsigned char *rawuuid);
|
|
||||||
|
|
||||||
#endif /* __QEMUD_UUID_H__ */
|
int virUUIDParse(const char *uuid,
|
||||||
|
unsigned char *rawuuid);
|
||||||
|
|
||||||
|
#endif /* __VIR_UUID_H__ */
|
||||||
|
|
Loading…
Reference in New Issue