saving UUID of new OpenVZ domains

* 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.
Daniel
This commit is contained in:
Daniel Veillard 2008-08-05 10:53:05 +00:00
parent 6d72e14178
commit 063679580d
4 changed files with 33 additions and 5 deletions

View File

@ -1,3 +1,9 @@
Tue Aug 5 12:51:11 CEST 2008 Daniel Veillard <veillard@redhat.com>
* 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 <meyering@redhat.com>
make distclean: remove generated source files

View File

@ -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

View File

@ -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 */

View File

@ -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"));