diff --git a/ChangeLog b/ChangeLog index 886c6e59ee92d09b210aad8f418c6f8aa4ca3fa5..1eaf897d72b80828197472c0ba9d4cf7caa5d832 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Mon Jan 23 14:36:18 IST 2007 Mark McLoughlin + + * 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 Issues pointed out by Karel Zak diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index aa0e93d31521ad2eeda2333d5921c65b6c62ccd2..489a83d4576d1fa653e2b92014b11667d30cb789 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -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 */ /** diff --git a/proxy/libvirt_proxy.c b/proxy/libvirt_proxy.c index 22b1ac08a98ca424f779e42b6f7087ed1ae7a673..c5d501f577c58f634d3093e1ef32d938c1b00d7a 100644 --- a/proxy/libvirt_proxy.c +++ b/proxy/libvirt_proxy.c @@ -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; diff --git a/python/libvir.c b/python/libvir.c index 1d8e422f2ff75b699f46733b5514a9c66cf5f094..50a44241ef6dc008ec5218989f1919a15adfabf2 100644 --- a/python/libvir.c +++ b/python/libvir.c @@ -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); } diff --git a/src/hash.c b/src/hash.c index 45ecb9735dd91753f0573c0421a64125135354fa..6c39918c5dd618b2dcb95762d20a263a7d252a57 100644 --- a/src/hash.c +++ b/src/hash.c @@ -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, diff --git a/src/internal.h b/src/internal.h index e629de31125cbd9a8ecd637e38a24d6156329f48..a8938cd02fb74daf9352a6fdba1d481a524db358 100644 --- a/src/internal.h +++ b/src/internal.h @@ -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 */ }; /* diff --git a/src/libvirt.c b/src/libvirt.c index 90b555affe6bc037febb7215376d010060244873..b06bf43ff600458273f72feb1ff4dd6faae16a94 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -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], diff --git a/src/proxy_internal.c b/src/proxy_internal.c index bfa6de2c9610f5edea646f847acaa280c2f669ee..1323b3db2ed294216091e54ce3891e27aab80373 100644 --- a/src/proxy_internal.c +++ b/src/proxy_internal.c @@ -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); diff --git a/src/test.c b/src/test.c index 91776978739bb5da9e6db7e9bed812a63a346aa2..6762ec89178638072df34d4ea1250055d21e5f73 100644 --- a/src/test.c +++ b/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; } diff --git a/src/virsh.c b/src/virsh.c index 857c60436ec741bc70c1f9ed102e06cea819b857..469d79431da79b4c1d8f6999c8d65dba3929e091 100644 --- a/src/virsh.c +++ b/src/virsh.c @@ -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); diff --git a/src/xend_internal.c b/src/xend_internal.c index c80cdbb4cdf429cd156ce893c395ba07014ac5fb..de818bb4679de68d176dccf5760780edbd7e40ce 100644 --- a/src/xend_internal.c +++ b/src/xend_internal.c @@ -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; } diff --git a/src/xm_internal.c b/src/xm_internal.c index daf3ebaf4a7b5a37d7b4fac74c9e69532bbcac31..7ad64b51a1dffd961fa4ac5c4c651b29eefa2738 100644 --- a/src/xm_internal.c +++ b/src/xm_internal.c @@ -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\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; diff --git a/src/xml.c b/src/xml.c index cd3faee62a24e093d763292dc0b3e1478a945f62..f1b3082a5365dbab668b9a1a9f3f775cfe80c174 100644 --- a/src/xml.c +++ b/src/xml.c @@ -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: