mirror of https://gitee.com/openkylin/libvirt.git
Mon Jan 23 14:36:18 IST 2007 Mark McLoughlin <markmc@redhat.com>
* include/libvirt/libvirt.h.in: add VIR_UUID_BUFLEN and VIR_UUID_STRING_BUFLEN * libvirt/proxy/libvirt_proxy.c, libvirt/src/hash.c, libvirt/src/internal.h, libvirt/src/libvirt.c, libvirt/src/proxy_internal.c, libvirt/src/test.c, libvirt/src/virsh.c, libvirt/src/xend_internal.c, libvirt/src/xm_internal.c, libvirt/src/xml.c, libvirt/python/libvir.c: use them
This commit is contained in:
parent
dab5d10763
commit
6d153563be
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
Mon Jan 23 14:36:18 IST 2007 Mark McLoughlin <markmc@redhat.com>
|
||||
|
||||
* include/libvirt/libvirt.h.in: add VIR_UUID_BUFLEN and
|
||||
VIR_UUID_STRING_BUFLEN
|
||||
|
||||
* libvirt/proxy/libvirt_proxy.c, libvirt/src/hash.c,
|
||||
libvirt/src/internal.h, libvirt/src/libvirt.c,
|
||||
libvirt/src/proxy_internal.c, libvirt/src/test.c,
|
||||
libvirt/src/virsh.c, libvirt/src/xend_internal.c,
|
||||
libvirt/src/xm_internal.c, libvirt/src/xml.c,
|
||||
libvirt/python/libvir.c: use them
|
||||
|
||||
Mon Jan 23 12:28:42 IST 2007 Mark McLoughlin <markmc@redhat.com>
|
||||
|
||||
Issues pointed out by Karel Zak <kzak@redhat.com>
|
||||
|
|
|
@ -187,6 +187,24 @@ struct _virNodeInfo {
|
|||
|
||||
typedef virNodeInfo *virNodeInfoPtr;
|
||||
|
||||
/**
|
||||
* VIR_UUID_STRING_BUFLEN:
|
||||
*
|
||||
* This macro provides the length of the buffer required
|
||||
* for virDomainGetUUID()
|
||||
*/
|
||||
|
||||
#define VIR_UUID_BUFLEN (16)
|
||||
|
||||
/**
|
||||
* VIR_UUID_STRING_BUFLEN:
|
||||
*
|
||||
* This macro provides the length of the buffer required
|
||||
* for virDomainGetUUIDString()
|
||||
*/
|
||||
|
||||
#define VIR_UUID_STRING_BUFLEN (36+1)
|
||||
|
||||
/* library versionning */
|
||||
|
||||
/**
|
||||
|
|
|
@ -462,7 +462,7 @@ retry2:
|
|||
break;
|
||||
case VIR_PROXY_LOOKUP_ID: {
|
||||
char *name = NULL;
|
||||
unsigned char uuid[16];
|
||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||
int len;
|
||||
|
||||
if (req->len != sizeof(virProxyPacket))
|
||||
|
@ -476,9 +476,9 @@ retry2:
|
|||
len = 1000;
|
||||
name[1000] = 0;
|
||||
}
|
||||
req->len += 16 + len + 1;
|
||||
memcpy(&request.extra.str[0], uuid, 16);
|
||||
strcpy(&request.extra.str[16], name);
|
||||
req->len += VIR_UUID_BUFLEN + len + 1;
|
||||
memcpy(&request.extra.str[0], uuid, VIR_UUID_BUFLEN);
|
||||
strcpy(&request.extra.str[VIR_UUID_BUFLEN], name);
|
||||
}
|
||||
if (name)
|
||||
free(name);
|
||||
|
@ -489,9 +489,9 @@ retry2:
|
|||
char **tmp;
|
||||
int ident, len;
|
||||
char *name = NULL;
|
||||
unsigned char uuid[16];
|
||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||
|
||||
if (req->len != sizeof(virProxyPacket) + 16)
|
||||
if (req->len != sizeof(virProxyPacket) + VIR_UUID_BUFLEN)
|
||||
goto comm_error;
|
||||
|
||||
/*
|
||||
|
@ -504,7 +504,7 @@ retry2:
|
|||
if (names != NULL) {
|
||||
while (*tmp != NULL) {
|
||||
ident = xenDaemonDomainLookupByName_ids(conn, *tmp, &uuid[0]);
|
||||
if (!memcmp(uuid, &request.extra.str[0], 16)) {
|
||||
if (!memcmp(uuid, &request.extra.str[0], VIR_UUID_BUFLEN)) {
|
||||
name = *tmp;
|
||||
break;
|
||||
}
|
||||
|
@ -530,7 +530,7 @@ retry2:
|
|||
}
|
||||
case VIR_PROXY_LOOKUP_NAME: {
|
||||
int ident;
|
||||
unsigned char uuid[16];
|
||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||
|
||||
if (req->len > sizeof(virProxyPacket) + 1000)
|
||||
goto comm_error;
|
||||
|
@ -542,8 +542,8 @@ retry2:
|
|||
req->data.arg = -1;
|
||||
req->len = sizeof(virProxyPacket);
|
||||
} else {
|
||||
req->len = sizeof(virProxyPacket) + 16;
|
||||
memcpy(&request.extra.str[0], uuid, 16);
|
||||
req->len = sizeof(virProxyPacket) + VIR_UUID_BUFLEN;
|
||||
memcpy(&request.extra.str[0], uuid, VIR_UUID_BUFLEN);
|
||||
req->data.arg = ident;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -349,7 +349,7 @@ libvirt_virNodeGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
|
|||
PyObject *
|
||||
libvirt_virDomainGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
|
||||
PyObject *py_retval;
|
||||
unsigned char uuid[16];
|
||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||
virDomainPtr domain;
|
||||
PyObject *pyobj_domain;
|
||||
int c_retval;
|
||||
|
@ -370,7 +370,7 @@ libvirt_virDomainGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
|
|||
Py_INCREF(Py_None);
|
||||
return(Py_None);
|
||||
}
|
||||
py_retval = PyString_FromStringAndSize((char *) &uuid[0], 16);
|
||||
py_retval = PyString_FromStringAndSize((char *) &uuid[0], VIR_UUID_BUFLEN);
|
||||
|
||||
return(py_retval);
|
||||
}
|
||||
|
@ -388,7 +388,7 @@ libvirt_virDomainLookupByUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
|
|||
return(NULL);
|
||||
conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
|
||||
|
||||
if ((uuid == NULL) || (len != 16)) {
|
||||
if ((uuid == NULL) || (len != VIR_UUID_BUFLEN)) {
|
||||
Py_INCREF(Py_None);
|
||||
return(Py_None);
|
||||
}
|
||||
|
|
|
@ -759,7 +759,7 @@ virGetDomain(virConnectPtr conn, const char *name, const unsigned char *uuid) {
|
|||
ret->conn = conn;
|
||||
ret->id = -1;
|
||||
if (uuid != NULL)
|
||||
memcpy(&(ret->uuid[0]), uuid, 16);
|
||||
memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN);
|
||||
|
||||
if (virHashAddEntry(conn->domains, name, ret) < 0) {
|
||||
virHashError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
|
|
|
@ -145,15 +145,15 @@ enum {
|
|||
* Internal structure associated to a domain
|
||||
*/
|
||||
struct _virDomain {
|
||||
unsigned int magic; /* specific value to check */
|
||||
int uses; /* reference count */
|
||||
virConnectPtr conn; /* pointer back to the connection */
|
||||
char *name; /* the domain external name */
|
||||
char *path; /* the domain internal path */
|
||||
int id; /* the domain ID */
|
||||
int flags; /* extra flags */
|
||||
unsigned char uuid[16]; /* the domain unique identifier */
|
||||
char *xml; /* the XML description for defined domains */
|
||||
unsigned int magic; /* specific value to check */
|
||||
int uses; /* reference count */
|
||||
virConnectPtr conn; /* pointer back to the connection */
|
||||
char *name; /* the domain external name */
|
||||
char *path; /* the domain internal path */
|
||||
int id; /* the domain ID */
|
||||
int flags; /* extra flags */
|
||||
unsigned char uuid[VIR_UUID_BUFLEN]; /* the domain unique identifier */
|
||||
char *xml; /* the XML description for defined domains */
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -645,8 +645,8 @@ virDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
|
|||
virDomainPtr
|
||||
virDomainLookupByUUIDString(virConnectPtr conn, const char *uuidstr)
|
||||
{
|
||||
int raw[16], i;
|
||||
unsigned char uuid[16];
|
||||
int raw[VIR_UUID_BUFLEN], i;
|
||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||
int ret;
|
||||
|
||||
if (!VIR_IS_CONNECT(conn)) {
|
||||
|
@ -672,11 +672,11 @@ virDomainLookupByUUIDString(virConnectPtr conn, const char *uuidstr)
|
|||
raw + 8, raw + 9, raw + 10, raw + 11,
|
||||
raw + 12, raw + 13, raw + 14, raw + 15);
|
||||
|
||||
if (ret!=16) {
|
||||
if (ret!=VIR_UUID_BUFLEN) {
|
||||
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
||||
return (NULL);
|
||||
}
|
||||
for (i = 0; i < 16; i++)
|
||||
for (i = 0; i < VIR_UUID_BUFLEN; i++)
|
||||
uuid[i] = raw[i] & 0xFF;
|
||||
|
||||
return virDomainLookupByUUID(conn, &uuid[0]);
|
||||
|
@ -1205,7 +1205,7 @@ virDomainGetName(virDomainPtr domain)
|
|||
/**
|
||||
* virDomainGetUUID:
|
||||
* @domain: a domain object
|
||||
* @uuid: pointer to a 16 bytes array
|
||||
* @uuid: pointer to a VIR_UUID_BUFLEN bytes array
|
||||
*
|
||||
* Get the UUID for a domain
|
||||
*
|
||||
|
@ -1224,7 +1224,7 @@ virDomainGetUUID(virDomainPtr domain, unsigned char *uuid)
|
|||
}
|
||||
|
||||
if (domain->id == 0) {
|
||||
memset(uuid, 0, 16);
|
||||
memset(uuid, 0, VIR_UUID_BUFLEN);
|
||||
} else {
|
||||
if ((domain->uuid[0] == 0) && (domain->uuid[1] == 0) &&
|
||||
(domain->uuid[2] == 0) && (domain->uuid[3] == 0) &&
|
||||
|
@ -1236,7 +1236,7 @@ virDomainGetUUID(virDomainPtr domain, unsigned char *uuid)
|
|||
(domain->uuid[14] == 0) && (domain->uuid[15] == 0))
|
||||
xenDaemonDomainLookupByName_ids(domain->conn, domain->name,
|
||||
&domain->uuid[0]);
|
||||
memcpy(uuid, &domain->uuid[0], 16);
|
||||
memcpy(uuid, &domain->uuid[0], VIR_UUID_BUFLEN);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
@ -1244,7 +1244,7 @@ virDomainGetUUID(virDomainPtr domain, unsigned char *uuid)
|
|||
/**
|
||||
* virDomainGetUUIDString:
|
||||
* @domain: a domain object
|
||||
* @buf: pointer to a 37 bytes array
|
||||
* @buf: pointer to a VIR_UUID_STRING_BUFLEN bytes array
|
||||
*
|
||||
* Get the UUID for a domain as string. For more information about
|
||||
* UUID see RFC4122.
|
||||
|
@ -1254,7 +1254,7 @@ virDomainGetUUID(virDomainPtr domain, unsigned char *uuid)
|
|||
int
|
||||
virDomainGetUUIDString(virDomainPtr domain, char *buf)
|
||||
{
|
||||
unsigned char uuid[16];
|
||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||
|
||||
if (!VIR_IS_DOMAIN(domain)) {
|
||||
virLibDomainError(domain, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
|
||||
|
@ -1268,7 +1268,7 @@ virDomainGetUUIDString(virDomainPtr domain, char *buf)
|
|||
if (virDomainGetUUID(domain, &uuid[0]))
|
||||
return (-1);
|
||||
|
||||
snprintf(buf, 37,
|
||||
snprintf(buf, VIR_UUID_STRING_BUFLEN,
|
||||
"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
uuid[0], uuid[1], uuid[2], uuid[3],
|
||||
uuid[4], uuid[5], uuid[6], uuid[7],
|
||||
|
|
|
@ -761,7 +761,7 @@ xenProxyLookupByID(virConnectPtr conn, int id)
|
|||
{
|
||||
virProxyPacket req;
|
||||
virProxyFullPacket ans;
|
||||
unsigned char uuid[16];
|
||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||
const char *name;
|
||||
int ret;
|
||||
virDomainPtr res;
|
||||
|
@ -786,8 +786,8 @@ xenProxyLookupByID(virConnectPtr conn, int id)
|
|||
if (ans.data.arg == -1) {
|
||||
return(NULL);
|
||||
}
|
||||
memcpy(uuid, &ans.extra.str[0], 16);
|
||||
name = &ans.extra.str[16];
|
||||
memcpy(uuid, &ans.extra.str[0], VIR_UUID_BUFLEN);
|
||||
name = &ans.extra.str[VIR_UUID_BUFLEN];
|
||||
res = virGetDomain(conn, name, uuid);
|
||||
|
||||
if (res == NULL)
|
||||
|
@ -825,7 +825,7 @@ xenProxyLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
|
|||
}
|
||||
memset(&req, 0, sizeof(virProxyPacket));
|
||||
req.command = VIR_PROXY_LOOKUP_UUID;
|
||||
req.len = sizeof(virProxyPacket) + 16;
|
||||
req.len = sizeof(virProxyPacket) + VIR_UUID_BUFLEN;
|
||||
ret = xenProxyCommand(conn, (virProxyPacketPtr) &req, &req, 0);
|
||||
if (ret < 0) {
|
||||
xenProxyClose(conn);
|
||||
|
|
10
src/test.c
10
src/test.c
|
@ -139,7 +139,7 @@ typedef struct _testDom {
|
|||
int active;
|
||||
int id;
|
||||
char name[20];
|
||||
unsigned char uuid[16];
|
||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||
virDomainKernel kernel;
|
||||
virDomainInfo info;
|
||||
unsigned int maxVCPUs;
|
||||
|
@ -247,7 +247,7 @@ static int testLoadDomain(virConnectPtr conn,
|
|||
xmlXPathContextPtr ctxt = NULL;
|
||||
xmlXPathObjectPtr obj = NULL;
|
||||
char *name = NULL;
|
||||
unsigned char rawuuid[16];
|
||||
unsigned char rawuuid[VIR_UUID_BUFLEN];
|
||||
char *dst_uuid;
|
||||
testCon *con;
|
||||
struct timeval tv;
|
||||
|
@ -397,7 +397,7 @@ static int testLoadDomain(virConnectPtr conn,
|
|||
if (memory > maxMem)
|
||||
memory = maxMem;
|
||||
|
||||
memmove(con->domains[handle].uuid, rawuuid, 16);
|
||||
memmove(con->domains[handle].uuid, rawuuid, VIR_UUID_BUFLEN);
|
||||
con->domains[handle].info.maxMem = maxMem;
|
||||
con->domains[handle].info.memory = memory;
|
||||
con->domains[handle].info.state = domid < 0 ? VIR_DOMAIN_SHUTOFF : VIR_DOMAIN_RUNNING;
|
||||
|
@ -487,7 +487,7 @@ static int testOpenDefault(virConnectPtr conn,
|
|||
node->connections[connid].domains[0].onCrash = VIR_DOMAIN_RESTART;
|
||||
node->connections[connid].domains[0].onPoweroff = VIR_DOMAIN_DESTROY;
|
||||
strcpy(node->connections[connid].domains[0].name, "test");
|
||||
for (u = 0 ; u < 16 ; u++) {
|
||||
for (u = 0 ; u < VIR_UUID_BUFLEN ; u++) {
|
||||
node->connections[connid].domains[0].uuid[u] = (u * 75)%255;
|
||||
}
|
||||
node->connections[connid].domains[0].info.maxMem = 8192 * 1024;
|
||||
|
@ -901,7 +901,7 @@ virDomainPtr testLookupDomainByUUID(virConnectPtr conn,
|
|||
int i, idx = -1;
|
||||
for (i = 0 ; i < MAX_DOMAINS ; i++) {
|
||||
if (con->domains[i].active &&
|
||||
memcmp(uuid, con->domains[i].uuid, 16) == 0) {
|
||||
memcmp(uuid, con->domains[i].uuid, VIR_UUID_BUFLEN) == 0) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1030,7 +1030,7 @@ cmdDominfo(vshControl * ctl, vshCmd * cmd)
|
|||
virDomainPtr dom;
|
||||
int ret = TRUE;
|
||||
unsigned int id;
|
||||
char *str, uuid[37];
|
||||
char *str, uuid[VIR_UUID_STRING_BUFLEN];
|
||||
|
||||
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
|
||||
return FALSE;
|
||||
|
@ -1535,7 +1535,7 @@ static int
|
|||
cmdDomuuid(vshControl * ctl, vshCmd * cmd)
|
||||
{
|
||||
virDomainPtr dom;
|
||||
char uuid[37];
|
||||
char uuid[VIR_UUID_STRING_BUFLEN];
|
||||
|
||||
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
|
||||
return FALSE;
|
||||
|
@ -1943,7 +1943,7 @@ vshCommandOptDomainBy(vshControl * ctl, vshCmd * cmd, const char *optname,
|
|||
}
|
||||
}
|
||||
/* try it by UUID */
|
||||
if (dom==NULL && (flag & VSH_DOMBYUUID) && strlen(n)==36) {
|
||||
if (dom==NULL && (flag & VSH_DOMBYUUID) && strlen(n)==VIR_UUID_STRING_BUFLEN-1) {
|
||||
vshDebug(ctl, 5, "%s: <%s> tring as domain UUID\n",
|
||||
cmd->def->name, optname);
|
||||
dom = virDomainLookupByUUIDString(ctl->conn, n);
|
||||
|
|
|
@ -1100,7 +1100,7 @@ xenDaemonDomainLookupByName_ids(virConnectPtr xend, const char *domname,
|
|||
int ret = -1;
|
||||
|
||||
if (uuid != NULL)
|
||||
memset(uuid, 0, 16);
|
||||
memset(uuid, 0, VIR_UUID_BUFLEN);
|
||||
root = sexpr_get(xend, "/xend/domain/%s?detail=1", domname);
|
||||
if (root == NULL)
|
||||
goto error;
|
||||
|
@ -1152,7 +1152,7 @@ xenDaemonDomainLookupByID(virConnectPtr xend,
|
|||
char *dst_uuid;
|
||||
struct sexpr *root;
|
||||
|
||||
memset(uuid, 0, 16);
|
||||
memset(uuid, 0, VIR_UUID_BUFLEN);
|
||||
|
||||
root = sexpr_get(xend, "/xend/domain/%d?detail=1", id);
|
||||
if (root == NULL)
|
||||
|
@ -1939,7 +1939,7 @@ sexpr_to_domain(virConnectPtr conn, struct sexpr *root)
|
|||
{
|
||||
virDomainPtr ret = NULL;
|
||||
char *dst_uuid = NULL;
|
||||
char uuid[16];
|
||||
char uuid[VIR_UUID_BUFLEN];
|
||||
const char *name;
|
||||
const char *tmp;
|
||||
|
||||
|
@ -2728,7 +2728,7 @@ error:
|
|||
static virDomainPtr
|
||||
xenDaemonLookupByID(virConnectPtr conn, int id) {
|
||||
char *name = NULL;
|
||||
unsigned char uuid[16];
|
||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||
virDomainPtr ret;
|
||||
|
||||
if (xenDaemonDomainLookupByID(conn, id, &name, uuid) < 0) {
|
||||
|
@ -2762,7 +2762,7 @@ xenDaemonLookupByID(virConnectPtr conn, int id) {
|
|||
int
|
||||
xenDaemonDomainSetVcpus(virDomainPtr domain, unsigned int vcpus)
|
||||
{
|
||||
char buf[16];
|
||||
char buf[VIR_UUID_BUFLEN];
|
||||
|
||||
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)
|
||||
|| (vcpus < 1)) {
|
||||
|
@ -2793,7 +2793,7 @@ int
|
|||
xenDaemonDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
|
||||
unsigned char *cpumap, int maplen)
|
||||
{
|
||||
char buf[16], mapstr[sizeof(cpumap_t) * 64] = "[";
|
||||
char buf[VIR_UUID_BUFLEN], mapstr[sizeof(cpumap_t) * 64] = "[";
|
||||
int i, j;
|
||||
|
||||
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)
|
||||
|
@ -2929,7 +2929,7 @@ xenDaemonLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
|
|||
char *name = NULL;
|
||||
char **names;
|
||||
char **tmp;
|
||||
unsigned char ident[16];
|
||||
unsigned char ident[VIR_UUID_BUFLEN];
|
||||
int id = -1;
|
||||
|
||||
names = xenDaemonListDomainsOld(conn);
|
||||
|
@ -2942,7 +2942,7 @@ xenDaemonLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
|
|||
while (*tmp != NULL) {
|
||||
id = xenDaemonDomainLookupByName_ids(conn, *tmp, &ident[0]);
|
||||
if (id >= 0) {
|
||||
if (!memcmp(uuid, ident, 16)) {
|
||||
if (!memcmp(uuid, ident, VIR_UUID_BUFLEN)) {
|
||||
name = strdup(*tmp);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -209,7 +209,7 @@ static int xenXMConfigGetUUID(virConfPtr conf, const char *name, unsigned char *
|
|||
have one in its config */
|
||||
static void xenXMConfigGenerateUUID(unsigned char *uuid) {
|
||||
int i;
|
||||
for (i = 0 ; i < 16 ; i++) {
|
||||
for (i = 0 ; i < VIR_UUID_BUFLEN ; i++) {
|
||||
uuid[i] = (unsigned char)(1 + (int) (256.0 * (rand() / (RAND_MAX + 1.0))));
|
||||
}
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ static void xenXMConfigGenerateUUID(unsigned char *uuid) {
|
|||
/* Ensure that a config object has a valid UUID in it,
|
||||
if it doesn't then (re-)generate one */
|
||||
static int xenXMConfigEnsureIdentity(virConfPtr conf, const char *filename) {
|
||||
unsigned char uuid[16];
|
||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||
const char *name;
|
||||
|
||||
/* Had better have a name...*/
|
||||
|
@ -242,7 +242,7 @@ static int xenXMConfigEnsureIdentity(virConfPtr conf, const char *filename) {
|
|||
/* If there is no uuid...*/
|
||||
if (xenXMConfigGetUUID(conf, "uuid", uuid) < 0) {
|
||||
virConfValuePtr value;
|
||||
char uuidstr[37];
|
||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||
|
||||
value = malloc(sizeof(virConfValue));
|
||||
if (!value) {
|
||||
|
@ -251,13 +251,13 @@ static int xenXMConfigEnsureIdentity(virConfPtr conf, const char *filename) {
|
|||
|
||||
/* ... then generate one */
|
||||
xenXMConfigGenerateUUID(uuid);
|
||||
snprintf(uuidstr, 37,
|
||||
snprintf(uuidstr, VIR_UUID_STRING_BUFLEN,
|
||||
"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x</uuid>\n",
|
||||
uuid[0], uuid[1], uuid[2], uuid[3],
|
||||
uuid[4], uuid[5], uuid[6], uuid[7],
|
||||
uuid[8], uuid[9], uuid[10], uuid[11],
|
||||
uuid[12], uuid[13], uuid[14], uuid[15]);
|
||||
uuidstr[36] = '\0';
|
||||
uuidstr[VIR_UUID_STRING_BUFLEN-1] = '\0';
|
||||
|
||||
value->type = VIR_CONF_STRING;
|
||||
value->str = strdup(uuidstr);
|
||||
|
@ -565,7 +565,7 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
|
|||
virBufferPtr buf;
|
||||
char *xml;
|
||||
const char *name;
|
||||
unsigned char uuid[16];
|
||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||
const char *str;
|
||||
int hvm = 0;
|
||||
long val;
|
||||
|
@ -1168,7 +1168,7 @@ virDomainPtr xenXMDomainLookupByName(virConnectPtr conn, const char *domname) {
|
|||
const char *filename;
|
||||
xenXMConfCachePtr entry;
|
||||
virDomainPtr ret;
|
||||
unsigned char uuid[16];
|
||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||
if (!VIR_IS_CONNECT(conn)) {
|
||||
xenXMError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
|
||||
return (NULL);
|
||||
|
@ -1209,7 +1209,7 @@ virDomainPtr xenXMDomainLookupByName(virConnectPtr conn, const char *domname) {
|
|||
* Hash table iterator to search for a domain based on UUID
|
||||
*/
|
||||
static int xenXMDomainSearchForUUID(const void *payload, const char *name ATTRIBUTE_UNUSED, const void *data) {
|
||||
unsigned char uuid[16];
|
||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||
const unsigned char *wantuuid = (const unsigned char *)data;
|
||||
const xenXMConfCachePtr entry = (const xenXMConfCachePtr)payload;
|
||||
|
||||
|
@ -1217,7 +1217,7 @@ static int xenXMDomainSearchForUUID(const void *payload, const char *name ATTRIB
|
|||
return (0);
|
||||
}
|
||||
|
||||
if (!memcmp(uuid, wantuuid, 16))
|
||||
if (!memcmp(uuid, wantuuid, VIR_UUID_BUFLEN))
|
||||
return (1);
|
||||
|
||||
return (0);
|
||||
|
@ -1271,7 +1271,7 @@ int xenXMDomainCreate(virDomainPtr domain) {
|
|||
char *xml;
|
||||
char *sexpr;
|
||||
int ret;
|
||||
unsigned char uuid[16];
|
||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||
|
||||
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
|
||||
xenXMError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
|
||||
|
@ -2046,7 +2046,7 @@ virConfPtr xenXMParseXMLToConfig(virConnectPtr conn, const char *xml) {
|
|||
virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml) {
|
||||
virDomainPtr ret;
|
||||
char filename[PATH_MAX];
|
||||
unsigned char uuid[16];
|
||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||
virConfPtr conf = NULL;
|
||||
xenXMConfCachePtr entry = NULL;
|
||||
virConfValuePtr value;
|
||||
|
|
|
@ -525,7 +525,7 @@ char *
|
|||
virDomainGetXMLDesc(virDomainPtr domain, int flags)
|
||||
{
|
||||
char *ret = NULL;
|
||||
unsigned char uuid[16];
|
||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||
virBuffer buf;
|
||||
virDomainInfo info;
|
||||
|
||||
|
@ -1533,7 +1533,7 @@ virDomainParseXMLDesc(const char *xmldesc, char **name, int xendConfigVersion)
|
|||
|
||||
|
||||
unsigned char *virParseUUID(char **ptr, const char *uuid) {
|
||||
int rawuuid[16];
|
||||
int rawuuid[VIR_UUID_BUFLEN];
|
||||
const char *cur;
|
||||
unsigned char *dst_uuid = NULL;
|
||||
int i;
|
||||
|
@ -1546,7 +1546,7 @@ unsigned char *virParseUUID(char **ptr, const char *uuid) {
|
|||
* pairs as long as there is 32 of them in the end.
|
||||
*/
|
||||
cur = uuid;
|
||||
for (i = 0;i < 16;) {
|
||||
for (i = 0;i < VIR_UUID_BUFLEN;) {
|
||||
rawuuid[i] = 0;
|
||||
if (*cur == 0)
|
||||
goto error;
|
||||
|
@ -1581,7 +1581,7 @@ unsigned char *virParseUUID(char **ptr, const char *uuid) {
|
|||
dst_uuid = (unsigned char *) *ptr;
|
||||
*ptr += 16;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
for (i = 0; i < VIR_UUID_BUFLEN; i++)
|
||||
dst_uuid[i] = rawuuid[i] & 0xFF;
|
||||
|
||||
error:
|
||||
|
|
Loading…
Reference in New Issue