diff --git a/ChangeLog b/ChangeLog index 133bde6c15..318a9f09e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Aug 5 12:51:11 CEST 2008 Daniel Veillard + + * src/openvz_conf.c src/openvz_conf.h src/openvz_driver.c: patch + from Evgeniy Sokolov saving the UUID when creating or defining + a domain. + Tue Aug 5 10:43:42 CEST 2008 Jim Meyering make distclean: remove generated source files diff --git a/src/openvz_conf.c b/src/openvz_conf.c index 45de36b806..4628c8e884 100644 --- a/src/openvz_conf.c +++ b/src/openvz_conf.c @@ -736,13 +736,14 @@ openvzGetVPSUUID(int vpsid, char *uuidstr) /* Do actual checking for UUID presence in conf file, * assign if not present. */ - -static int -openvzSetUUID(int vpsid) +int +openvzSetDefinedUUID(int vpsid, unsigned char *uuid) { char conf_file[PATH_MAX]; char uuidstr[VIR_UUID_STRING_BUFLEN]; - unsigned char uuid[VIR_UUID_BUFLEN]; + + if (uuid == NULL) + return -1; if (openvzLocateConfFile(vpsid, conf_file, PATH_MAX)<0) return -1; @@ -755,7 +756,6 @@ openvzSetUUID(int vpsid) if (fp == NULL) return -1; - virUUIDGenerate(uuid); virUUIDFormat(uuid, uuidstr); /* Record failure if fprintf or fclose fails, @@ -768,6 +768,15 @@ openvzSetUUID(int vpsid) return 0; } +static int +openvzSetUUID(int vpsid){ + unsigned char uuid[VIR_UUID_BUFLEN]; + + virUUIDGenerate(uuid); + + return openvzSetDefinedUUID(vpsid, uuid); +} + /* * Scan VPS config files and see if they have a UUID. * If not, assign one. Just append one to the config diff --git a/src/openvz_conf.h b/src/openvz_conf.h index 5f0d3a461c..da18407985 100644 --- a/src/openvz_conf.h +++ b/src/openvz_conf.h @@ -119,5 +119,6 @@ void openvzFreeVMDef(struct openvz_vm_def *def); int strtoI(const char *str); int openvzCheckEmptyMac(const unsigned char *mac); char *openvzMacToString(const unsigned char *mac); +int openvzSetDefinedUUID(int vpsid, unsigned char *uuid); #endif /* OPENVZ_CONF_H */ diff --git a/src/openvz_driver.c b/src/openvz_driver.c index 981fd8a2a9..e09b093ee1 100644 --- a/src/openvz_driver.c +++ b/src/openvz_driver.c @@ -459,6 +459,12 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml) goto exit; } + if (openvzSetDefinedUUID(strtoI(vmdef->name), vmdef->uuid) < 0) { + openvzError(conn, VIR_ERR_INTERNAL_ERROR, + _("Could not set UUID")); + goto exit; + } + dom = virGetDomain(conn, vm->vmdef->name, vm->vmdef->uuid); if (dom) dom->id = vm->vpsid; @@ -514,6 +520,12 @@ openvzDomainCreateLinux(virConnectPtr conn, const char *xml, goto exit; } + if (openvzSetDefinedUUID(strtoI(vmdef->name), vmdef->uuid) < 0) { + openvzError(conn, VIR_ERR_INTERNAL_ERROR, + _("Could not set UUID")); + goto exit; + } + if (openvzDomainSetNetwork(conn, vmdef->name, vmdef->net) < 0) { openvzError(conn, VIR_ERR_INTERNAL_ERROR, _("Could not configure network"));