mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
openvz: Remove virConnectPtr from openvzError
Also remove unused enum values OPENVZ_WARN and OPENVZ_ERR.
This commit is contained in:
parent
a4f9af057a
commit
fcd103bb2a
@ -122,15 +122,14 @@ rewait:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int openvzExtractVersion(virConnectPtr conn,
|
int openvzExtractVersion(struct openvz_driver *driver)
|
||||||
struct openvz_driver *driver)
|
|
||||||
{
|
{
|
||||||
if (driver->version > 0)
|
if (driver->version > 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (openvzExtractVersionInfo(VZCTL, &driver->version) < 0) {
|
if (openvzExtractVersionInfo(VZCTL, &driver->version) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Could not extract vzctl version"));
|
_("Could not extract vzctl version"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,8 +180,7 @@ no_memory:
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
openvzReadNetworkConf(virConnectPtr conn,
|
openvzReadNetworkConf(virDomainDefPtr def,
|
||||||
virDomainDefPtr def,
|
|
||||||
int veid) {
|
int veid) {
|
||||||
int ret;
|
int ret;
|
||||||
virDomainNetDefPtr net = NULL;
|
virDomainNetDefPtr net = NULL;
|
||||||
@ -196,7 +194,7 @@ openvzReadNetworkConf(virConnectPtr conn,
|
|||||||
*/
|
*/
|
||||||
ret = openvzReadVPSConfigParam(veid, "IP_ADDRESS", temp, sizeof(temp));
|
ret = openvzReadVPSConfigParam(veid, "IP_ADDRESS", temp, sizeof(temp));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not read 'IP_ADDRESS' from config for container %d"),
|
_("Could not read 'IP_ADDRESS' from config for container %d"),
|
||||||
veid);
|
veid);
|
||||||
goto error;
|
goto error;
|
||||||
@ -228,7 +226,7 @@ openvzReadNetworkConf(virConnectPtr conn,
|
|||||||
*/
|
*/
|
||||||
ret = openvzReadVPSConfigParam(veid, "NETIF", temp, sizeof(temp));
|
ret = openvzReadVPSConfigParam(veid, "NETIF", temp, sizeof(temp));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not read 'NETIF' from config for container %d"),
|
_("Could not read 'NETIF' from config for container %d"),
|
||||||
veid);
|
veid);
|
||||||
goto error;
|
goto error;
|
||||||
@ -254,8 +252,8 @@ openvzReadNetworkConf(virConnectPtr conn,
|
|||||||
p += 12;
|
p += 12;
|
||||||
len = next - p;
|
len = next - p;
|
||||||
if (len > 16) {
|
if (len > 16) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Too long network device name"));
|
_("Too long network device name"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,7 +261,7 @@ openvzReadNetworkConf(virConnectPtr conn,
|
|||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
if (virStrncpy(net->ifname, p, len, len+1) == NULL) {
|
if (virStrncpy(net->ifname, p, len, len+1) == NULL) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Network ifname %s too long for destination"), p);
|
_("Network ifname %s too long for destination"), p);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -271,8 +269,8 @@ openvzReadNetworkConf(virConnectPtr conn,
|
|||||||
p += 7;
|
p += 7;
|
||||||
len = next - p;
|
len = next - p;
|
||||||
if (len > 16) {
|
if (len > 16) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Too long bridge device name"));
|
_("Too long bridge device name"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,7 +278,7 @@ openvzReadNetworkConf(virConnectPtr conn,
|
|||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
if (virStrncpy(net->data.bridge.brname, p, len, len+1) == NULL) {
|
if (virStrncpy(net->data.bridge.brname, p, len, len+1) == NULL) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Bridge name %s too long for destination"), p);
|
_("Bridge name %s too long for destination"), p);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -288,18 +286,18 @@ openvzReadNetworkConf(virConnectPtr conn,
|
|||||||
p += 4;
|
p += 4;
|
||||||
len = next - p;
|
len = next - p;
|
||||||
if (len != 17) { //should be 17
|
if (len != 17) { //should be 17
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Wrong length MAC address"));
|
_("Wrong length MAC address"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (virStrncpy(cpy_temp, p, len, sizeof(cpy_temp)) == NULL) {
|
if (virStrncpy(cpy_temp, p, len, sizeof(cpy_temp)) == NULL) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("MAC address %s too long for destination"), p);
|
_("MAC address %s too long for destination"), p);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (virParseMacAddr(cpy_temp, net->mac) < 0) {
|
if (virParseMacAddr(cpy_temp, net->mac) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Wrong MAC address"));
|
_("Wrong MAC address"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -359,8 +357,7 @@ openvz_replace(const char* str,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
openvzReadFSConf(virConnectPtr conn,
|
openvzReadFSConf(virDomainDefPtr def,
|
||||||
virDomainDefPtr def,
|
|
||||||
int veid) {
|
int veid) {
|
||||||
int ret;
|
int ret;
|
||||||
virDomainFSDefPtr fs = NULL;
|
virDomainFSDefPtr fs = NULL;
|
||||||
@ -369,7 +366,7 @@ openvzReadFSConf(virConnectPtr conn,
|
|||||||
|
|
||||||
ret = openvzReadVPSConfigParam(veid, "OSTEMPLATE", temp, sizeof(temp));
|
ret = openvzReadVPSConfigParam(veid, "OSTEMPLATE", temp, sizeof(temp));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not read 'OSTEMPLATE' from config for container %d"),
|
_("Could not read 'OSTEMPLATE' from config for container %d"),
|
||||||
veid);
|
veid);
|
||||||
goto error;
|
goto error;
|
||||||
@ -383,7 +380,7 @@ openvzReadFSConf(virConnectPtr conn,
|
|||||||
/* OSTEMPLATE was not found, VE was booted from a private dir directly */
|
/* OSTEMPLATE was not found, VE was booted from a private dir directly */
|
||||||
ret = openvzReadVPSConfigParam(veid, "VE_PRIVATE", temp, sizeof(temp));
|
ret = openvzReadVPSConfigParam(veid, "VE_PRIVATE", temp, sizeof(temp));
|
||||||
if (ret <= 0) {
|
if (ret <= 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not read 'VE_PRIVATE' from config for container %d"),
|
_("Could not read 'VE_PRIVATE' from config for container %d"),
|
||||||
veid);
|
veid);
|
||||||
goto error;
|
goto error;
|
||||||
@ -446,7 +443,7 @@ int openvzLoadDomains(struct openvz_driver *driver) {
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if ((fp = popen(VZLIST " -a -ovpsid,status -H 2>/dev/null", "r")) == NULL) {
|
if ((fp = popen(VZLIST " -a -ovpsid,status -H 2>/dev/null", "r")) == NULL) {
|
||||||
openvzError(NULL, VIR_ERR_INTERNAL_ERROR, "%s", _("popen failed"));
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s", _("popen failed"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,8 +452,8 @@ int openvzLoadDomains(struct openvz_driver *driver) {
|
|||||||
if (feof(fp))
|
if (feof(fp))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
openvzError(NULL, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Failed to parse vzlist output"));
|
_("Failed to parse vzlist output"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,8 +461,8 @@ int openvzLoadDomains(struct openvz_driver *driver) {
|
|||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
if (virMutexInit(&dom->lock) < 0) {
|
if (virMutexInit(&dom->lock) < 0) {
|
||||||
openvzError(NULL, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("cannot initialize mutex"));
|
_("cannot initialize mutex"));
|
||||||
VIR_FREE(dom);
|
VIR_FREE(dom);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -493,8 +490,8 @@ int openvzLoadDomains(struct openvz_driver *driver) {
|
|||||||
ret = virUUIDParse(uuidstr, dom->def->uuid);
|
ret = virUUIDParse(uuidstr, dom->def->uuid);
|
||||||
|
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
openvzError(NULL, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("UUID in config file malformed"));
|
_("UUID in config file malformed"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -505,7 +502,7 @@ int openvzLoadDomains(struct openvz_driver *driver) {
|
|||||||
|
|
||||||
ret = openvzReadVPSConfigParam(veid, "CPUS", temp, sizeof(temp));
|
ret = openvzReadVPSConfigParam(veid, "CPUS", temp, sizeof(temp));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
openvzError(NULL, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not read config for container %d"),
|
_("Could not read config for container %d"),
|
||||||
veid);
|
veid);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -518,8 +515,8 @@ int openvzLoadDomains(struct openvz_driver *driver) {
|
|||||||
|
|
||||||
/* XXX load rest of VM config data .... */
|
/* XXX load rest of VM config data .... */
|
||||||
|
|
||||||
openvzReadNetworkConf(NULL, dom->def, veid);
|
openvzReadNetworkConf(dom->def, veid);
|
||||||
openvzReadFSConf(NULL, dom->def, veid);
|
openvzReadFSConf(dom->def, veid);
|
||||||
|
|
||||||
virUUIDFormat(dom->def->uuid, uuidstr);
|
virUUIDFormat(dom->def->uuid, uuidstr);
|
||||||
if (virHashAddEntry(driver->domains.objs, uuidstr, dom) < 0)
|
if (virHashAddEntry(driver->domains.objs, uuidstr, dom) < 0)
|
||||||
@ -914,8 +911,8 @@ openvzSetUUID(int vpsid){
|
|||||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||||
|
|
||||||
if (virUUIDGenerate(uuid)) {
|
if (virUUIDGenerate(uuid)) {
|
||||||
openvzError(NULL, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Failed to generate UUID"));
|
_("Failed to generate UUID"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -972,7 +969,7 @@ int openvzGetVEID(const char *name) {
|
|||||||
bool ok;
|
bool ok;
|
||||||
|
|
||||||
if (virAsprintf(&cmd, "%s %s -ovpsid -H", VZLIST, name) < 0) {
|
if (virAsprintf(&cmd, "%s %s -ovpsid -H", VZLIST, name) < 0) {
|
||||||
openvzError(NULL, VIR_ERR_INTERNAL_ERROR, "%s",
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("virAsprintf failed"));
|
_("virAsprintf failed"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -981,7 +978,7 @@ int openvzGetVEID(const char *name) {
|
|||||||
VIR_FREE(cmd);
|
VIR_FREE(cmd);
|
||||||
|
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
openvzError(NULL, VIR_ERR_INTERNAL_ERROR, "%s", _("popen failed"));
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s", _("popen failed"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -990,7 +987,7 @@ int openvzGetVEID(const char *name) {
|
|||||||
if (ok && veid >= 0)
|
if (ok && veid >= 0)
|
||||||
return veid;
|
return veid;
|
||||||
|
|
||||||
openvzError(NULL, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Failed to parse vzlist output"));
|
_("Failed to parse vzlist output"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -33,10 +33,8 @@
|
|||||||
# include "domain_conf.h"
|
# include "domain_conf.h"
|
||||||
# include "threads.h"
|
# include "threads.h"
|
||||||
|
|
||||||
enum { OPENVZ_WARN, OPENVZ_ERR };
|
# define openvzError(code, ...) \
|
||||||
|
virReportErrorHelper(NULL, VIR_FROM_OPENVZ, code, __FILE__, \
|
||||||
# define openvzError(conn, code, ...) \
|
|
||||||
virReportErrorHelper(conn, VIR_FROM_OPENVZ, code, __FILE__, \
|
|
||||||
__FUNCTION__, __LINE__, __VA_ARGS__)
|
__FUNCTION__, __LINE__, __VA_ARGS__)
|
||||||
|
|
||||||
|
|
||||||
@ -56,8 +54,7 @@ struct openvz_driver {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int openvz_readline(int fd, char *ptr, int maxlen);
|
int openvz_readline(int fd, char *ptr, int maxlen);
|
||||||
int openvzExtractVersion(virConnectPtr conn,
|
int openvzExtractVersion(struct openvz_driver *driver);
|
||||||
struct openvz_driver *driver);
|
|
||||||
int openvzReadVPSConfigParam(int vpsid ,const char * param, char *value, int maxlen);
|
int openvzReadVPSConfigParam(int vpsid ,const char * param, char *value, int maxlen);
|
||||||
int openvzWriteVPSConfigParam(int vpsid, const char *param, const char *value);
|
int openvzWriteVPSConfigParam(int vpsid, const char *param, const char *value);
|
||||||
int openvzCopyDefaultConfig(int vpsid);
|
int openvzCopyDefaultConfig(int vpsid);
|
||||||
|
@ -68,11 +68,9 @@ static int openvzGetProcessInfo(unsigned long long *cpuTime, int vpsid);
|
|||||||
static int openvzGetMaxVCPUs(virConnectPtr conn, const char *type);
|
static int openvzGetMaxVCPUs(virConnectPtr conn, const char *type);
|
||||||
static int openvzDomainGetMaxVcpus(virDomainPtr dom);
|
static int openvzDomainGetMaxVcpus(virDomainPtr dom);
|
||||||
static int openvzDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus);
|
static int openvzDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus);
|
||||||
static int openvzDomainSetVcpusInternal(virConnectPtr conn,
|
static int openvzDomainSetVcpusInternal(virDomainObjPtr vm,
|
||||||
virDomainObjPtr vm,
|
|
||||||
unsigned int nvcpus);
|
unsigned int nvcpus);
|
||||||
static int openvzDomainSetMemoryInternal(virConnectPtr conn,
|
static int openvzDomainSetMemoryInternal(virDomainObjPtr vm,
|
||||||
virDomainObjPtr vm,
|
|
||||||
unsigned long memory);
|
unsigned long memory);
|
||||||
|
|
||||||
static void openvzDriverLock(struct openvz_driver *driver)
|
static void openvzDriverLock(struct openvz_driver *driver)
|
||||||
@ -101,8 +99,7 @@ static void cmdExecFree(const char *cmdExec[])
|
|||||||
0 - OK
|
0 - OK
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
openvzDomainDefineCmd(virConnectPtr conn,
|
openvzDomainDefineCmd(const char *args[],
|
||||||
const char *args[],
|
|
||||||
int maxarg, virDomainDefPtr vmdef)
|
int maxarg, virDomainDefPtr vmdef)
|
||||||
{
|
{
|
||||||
int narg;
|
int narg;
|
||||||
@ -115,8 +112,8 @@ openvzDomainDefineCmd(virConnectPtr conn,
|
|||||||
args[narg] = NULL;
|
args[narg] = NULL;
|
||||||
|
|
||||||
if (vmdef == NULL) {
|
if (vmdef == NULL) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Container is not defined"));
|
_("Container is not defined"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#define ADD_ARG(thisarg) \
|
#define ADD_ARG(thisarg) \
|
||||||
@ -140,7 +137,7 @@ openvzDomainDefineCmd(virConnectPtr conn,
|
|||||||
ADD_ARG_LIT("create");
|
ADD_ARG_LIT("create");
|
||||||
|
|
||||||
if ((fp = popen(VZLIST " -a -ovpsid -H 2>/dev/null", "r")) == NULL) {
|
if ((fp = popen(VZLIST " -a -ovpsid -H 2>/dev/null", "r")) == NULL) {
|
||||||
openvzError(NULL, VIR_ERR_INTERNAL_ERROR, "%s",
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("popen failed"));
|
_("popen failed"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -150,8 +147,8 @@ openvzDomainDefineCmd(virConnectPtr conn,
|
|||||||
if (feof(fp))
|
if (feof(fp))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
openvzError(NULL, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Failed to parse vzlist output"));
|
_("Failed to parse vzlist output"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (veid > max_veid) {
|
if (veid > max_veid) {
|
||||||
@ -188,7 +185,7 @@ openvzDomainDefineCmd(virConnectPtr conn,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
no_memory:
|
no_memory:
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not put argument to %s"), VZCTL);
|
_("Could not put argument to %s"), VZCTL);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -201,8 +198,7 @@ cleanup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int openvzSetInitialConfig(virConnectPtr conn,
|
static int openvzSetInitialConfig(virDomainDefPtr vmdef)
|
||||||
virDomainDefPtr vmdef)
|
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int vpsid;
|
int vpsid;
|
||||||
@ -211,8 +207,8 @@ static int openvzSetInitialConfig(virConnectPtr conn,
|
|||||||
prog[0] = NULL;
|
prog[0] = NULL;
|
||||||
|
|
||||||
if (vmdef->nfss > 1) {
|
if (vmdef->nfss > 1) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("only one filesystem supported"));
|
_("only one filesystem supported"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,8 +216,8 @@ static int openvzSetInitialConfig(virConnectPtr conn,
|
|||||||
vmdef->fss[0]->type != VIR_DOMAIN_FS_TYPE_TEMPLATE &&
|
vmdef->fss[0]->type != VIR_DOMAIN_FS_TYPE_TEMPLATE &&
|
||||||
vmdef->fss[0]->type != VIR_DOMAIN_FS_TYPE_MOUNT)
|
vmdef->fss[0]->type != VIR_DOMAIN_FS_TYPE_MOUNT)
|
||||||
{
|
{
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("filesystem is not of type 'template' or 'mount'"));
|
_("filesystem is not of type 'template' or 'mount'"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,33 +227,33 @@ static int openvzSetInitialConfig(virConnectPtr conn,
|
|||||||
{
|
{
|
||||||
|
|
||||||
if(virStrToLong_i(vmdef->name, NULL, 10, &vpsid) < 0) {
|
if(virStrToLong_i(vmdef->name, NULL, 10, &vpsid) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Could not convert domain name to VEID"));
|
_("Could not convert domain name to VEID"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openvzCopyDefaultConfig(vpsid) < 0) {
|
if (openvzCopyDefaultConfig(vpsid) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Could not copy default config"));
|
_("Could not copy default config"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openvzWriteVPSConfigParam(vpsid, "VE_PRIVATE", vmdef->fss[0]->src) < 0) {
|
if (openvzWriteVPSConfigParam(vpsid, "VE_PRIVATE", vmdef->fss[0]->src) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Could not set the source dir for the filesystem"));
|
_("Could not set the source dir for the filesystem"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (openvzDomainDefineCmd(conn, prog, OPENVZ_MAX_ARG, vmdef) < 0) {
|
if (openvzDomainDefineCmd(prog, OPENVZ_MAX_ARG, vmdef) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Error creating command for container"));
|
_("Error creating command for container"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virRun(prog, NULL) < 0) {
|
if (virRun(prog, NULL) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not exec %s"), VZCTL);
|
_("Could not exec %s"), VZCTL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -283,7 +279,7 @@ static virDomainPtr openvzDomainLookupByID(virConnectPtr conn,
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(conn, VIR_ERR_NO_DOMAIN, NULL);
|
openvzError(VIR_ERR_NO_DOMAIN, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,7 +312,7 @@ static char *openvzGetOSType(virDomainPtr dom)
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
|
openvzError(VIR_ERR_NO_DOMAIN, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,7 +337,7 @@ static virDomainPtr openvzDomainLookupByUUID(virConnectPtr conn,
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(conn, VIR_ERR_NO_DOMAIN, NULL);
|
openvzError(VIR_ERR_NO_DOMAIN, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,7 +362,7 @@ static virDomainPtr openvzDomainLookupByName(virConnectPtr conn,
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(conn, VIR_ERR_NO_DOMAIN, NULL);
|
openvzError(VIR_ERR_NO_DOMAIN, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,8 +387,8 @@ static int openvzDomainGetInfo(virDomainPtr dom,
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(dom->conn, VIR_ERR_INVALID_DOMAIN,
|
openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
|
||||||
"%s", _("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,7 +398,7 @@ static int openvzDomainGetInfo(virDomainPtr dom,
|
|||||||
info->cpuTime = 0;
|
info->cpuTime = 0;
|
||||||
} else {
|
} else {
|
||||||
if (openvzGetProcessInfo(&(info->cpuTime), dom->id) < 0) {
|
if (openvzGetProcessInfo(&(info->cpuTime), dom->id) < 0) {
|
||||||
openvzError(dom->conn, VIR_ERR_OPERATION_FAILED,
|
openvzError(VIR_ERR_OPERATION_FAILED,
|
||||||
_("cannot read cputime for domain %d"), dom->id);
|
_("cannot read cputime for domain %d"), dom->id);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -430,7 +426,7 @@ static int openvzDomainIsActive(virDomainPtr dom)
|
|||||||
obj = virDomainFindByUUID(&driver->domains, dom->uuid);
|
obj = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
openvzError(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
|
openvzError(VIR_ERR_NO_DOMAIN, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
ret = virDomainObjIsActive(obj);
|
ret = virDomainObjIsActive(obj);
|
||||||
@ -452,7 +448,7 @@ static int openvzDomainIsPersistent(virDomainPtr dom)
|
|||||||
obj = virDomainFindByUUID(&driver->domains, dom->uuid);
|
obj = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
openvzError(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
|
openvzError(VIR_ERR_NO_DOMAIN, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
ret = obj->persistent;
|
ret = obj->persistent;
|
||||||
@ -474,8 +470,8 @@ static char *openvzDomainDumpXML(virDomainPtr dom, int flags) {
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(dom->conn, VIR_ERR_INVALID_DOMAIN,
|
openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
|
||||||
"%s", _("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -518,15 +514,15 @@ static int openvzDomainShutdown(virDomainPtr dom) {
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(dom->conn, VIR_ERR_INVALID_DOMAIN,
|
openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
|
||||||
"%s", _("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
openvzSetProgramSentinal(prog, vm->def->name);
|
openvzSetProgramSentinal(prog, vm->def->name);
|
||||||
if (vm->state != VIR_DOMAIN_RUNNING) {
|
if (vm->state != VIR_DOMAIN_RUNNING) {
|
||||||
openvzError(dom->conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("domain is not in running state"));
|
_("domain is not in running state"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -555,15 +551,15 @@ static int openvzDomainReboot(virDomainPtr dom,
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(dom->conn, VIR_ERR_INVALID_DOMAIN,
|
openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
|
||||||
"%s", _("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
openvzSetProgramSentinal(prog, vm->def->name);
|
openvzSetProgramSentinal(prog, vm->def->name);
|
||||||
if (vm->state != VIR_DOMAIN_RUNNING) {
|
if (vm->state != VIR_DOMAIN_RUNNING) {
|
||||||
openvzError(dom->conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("domain is not in running state"));
|
_("domain is not in running state"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -642,8 +638,8 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
|
|||||||
if (net == NULL)
|
if (net == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
if (vpsid == NULL) {
|
if (vpsid == NULL) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Container ID is not specified"));
|
_("Container ID is not specified"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -675,8 +671,8 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
|
|||||||
/* generate interface name in ve and copy it to options */
|
/* generate interface name in ve and copy it to options */
|
||||||
dev_name_ve = openvzGenerateContainerVethName(veid);
|
dev_name_ve = openvzGenerateContainerVethName(veid);
|
||||||
if (dev_name_ve == NULL) {
|
if (dev_name_ve == NULL) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Could not generate eth name for container"));
|
_("Could not generate eth name for container"));
|
||||||
rc = -1;
|
rc = -1;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@ -686,8 +682,8 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
|
|||||||
if (net->ifname == NULL) {
|
if (net->ifname == NULL) {
|
||||||
net->ifname = openvzGenerateVethName(veid, dev_name_ve);
|
net->ifname = openvzGenerateVethName(veid, dev_name_ve);
|
||||||
if (net->ifname == NULL) {
|
if (net->ifname == NULL) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Could not generate veth name"));
|
_("Could not generate veth name"));
|
||||||
rc = -1;
|
rc = -1;
|
||||||
VIR_FREE(dev_name_ve);
|
VIR_FREE(dev_name_ve);
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -728,7 +724,7 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
|
|||||||
if (prog[0] != NULL){
|
if (prog[0] != NULL){
|
||||||
ADD_ARG_LIT("--save");
|
ADD_ARG_LIT("--save");
|
||||||
if (virRun(prog, NULL) < 0) {
|
if (virRun(prog, NULL) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not exec %s"), VZCTL);
|
_("Could not exec %s"), VZCTL);
|
||||||
rc = -1;
|
rc = -1;
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -741,7 +737,7 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
|
|||||||
|
|
||||||
no_memory:
|
no_memory:
|
||||||
VIR_FREE(opt);
|
VIR_FREE(opt);
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not put argument to %s"), VZCTL);
|
_("Could not put argument to %s"), VZCTL);
|
||||||
cmdExecFree(prog);
|
cmdExecFree(prog);
|
||||||
return -1;
|
return -1;
|
||||||
@ -770,8 +766,8 @@ openvzDomainSetNetworkConfig(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (openvzDomainSetNetwork(conn, def->name, def->nets[i], &buf) < 0) {
|
if (openvzDomainSetNetwork(conn, def->name, def->nets[i], &buf) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Could not configure network"));
|
_("Could not configure network"));
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -781,8 +777,8 @@ openvzDomainSetNetworkConfig(virConnectPtr conn,
|
|||||||
if (param) {
|
if (param) {
|
||||||
if (openvzWriteVPSConfigParam(strtoI(def->name), "NETIF", param) < 0) {
|
if (openvzWriteVPSConfigParam(strtoI(def->name), "NETIF", param) < 0) {
|
||||||
VIR_FREE(param);
|
VIR_FREE(param);
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("cannot replace NETIF config"));
|
_("cannot replace NETIF config"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
VIR_FREE(param);
|
VIR_FREE(param);
|
||||||
@ -819,7 +815,7 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml)
|
|||||||
|
|
||||||
vm = virDomainFindByName(&driver->domains, vmdef->name);
|
vm = virDomainFindByName(&driver->domains, vmdef->name);
|
||||||
if (vm) {
|
if (vm) {
|
||||||
openvzError(conn, VIR_ERR_OPERATION_FAILED,
|
openvzError(VIR_ERR_OPERATION_FAILED,
|
||||||
_("Already an OPENVZ VM active with the id '%s'"),
|
_("Already an OPENVZ VM active with the id '%s'"),
|
||||||
vmdef->name);
|
vmdef->name);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -830,17 +826,17 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml)
|
|||||||
vmdef = NULL;
|
vmdef = NULL;
|
||||||
vm->persistent = 1;
|
vm->persistent = 1;
|
||||||
|
|
||||||
if (openvzSetInitialConfig(conn, vm->def) < 0) {
|
if (openvzSetInitialConfig(vm->def) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Error creating initial configuration"));
|
_("Error creating initial configuration"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: set quota
|
//TODO: set quota
|
||||||
|
|
||||||
if (openvzSetDefinedUUID(strtoI(vm->def->name), vm->def->uuid) < 0) {
|
if (openvzSetDefinedUUID(strtoI(vm->def->name), vm->def->uuid) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Could not set UUID"));
|
_("Could not set UUID"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -848,17 +844,17 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (vm->def->vcpus > 0) {
|
if (vm->def->vcpus > 0) {
|
||||||
if (openvzDomainSetVcpusInternal(conn, vm, vm->def->vcpus) < 0) {
|
if (openvzDomainSetVcpusInternal(vm, vm->def->vcpus) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Could not set number of virtual cpu"));
|
_("Could not set number of virtual cpu"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm->def->memory > 0) {
|
if (vm->def->memory > 0) {
|
||||||
if (openvzDomainSetMemoryInternal(conn, vm, vm->def->memory) < 0) {
|
if (openvzDomainSetMemoryInternal(vm, vm->def->memory) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Could not set memory size"));
|
_("Could not set memory size"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -899,7 +895,7 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
|
|||||||
|
|
||||||
vm = virDomainFindByName(&driver->domains, vmdef->name);
|
vm = virDomainFindByName(&driver->domains, vmdef->name);
|
||||||
if (vm) {
|
if (vm) {
|
||||||
openvzError(conn, VIR_ERR_OPERATION_FAILED,
|
openvzError(VIR_ERR_OPERATION_FAILED,
|
||||||
_("Already an OPENVZ VM defined with the id '%s'"),
|
_("Already an OPENVZ VM defined with the id '%s'"),
|
||||||
vmdef->name);
|
vmdef->name);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -912,15 +908,15 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
|
|||||||
* of this libvirt API which is intended for transient domain creation */
|
* of this libvirt API which is intended for transient domain creation */
|
||||||
vm->persistent = 1;
|
vm->persistent = 1;
|
||||||
|
|
||||||
if (openvzSetInitialConfig(conn, vm->def) < 0) {
|
if (openvzSetInitialConfig(vm->def) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Error creating initial configuration"));
|
_("Error creating initial configuration"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openvzSetDefinedUUID(strtoI(vm->def->name), vm->def->uuid) < 0) {
|
if (openvzSetDefinedUUID(strtoI(vm->def->name), vm->def->uuid) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Could not set UUID"));
|
_("Could not set UUID"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -930,7 +926,7 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
|
|||||||
openvzSetProgramSentinal(progstart, vm->def->name);
|
openvzSetProgramSentinal(progstart, vm->def->name);
|
||||||
|
|
||||||
if (virRun(progstart, NULL) < 0) {
|
if (virRun(progstart, NULL) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not exec %s"), VZCTL);
|
_("Could not exec %s"), VZCTL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -940,9 +936,9 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
|
|||||||
vm->state = VIR_DOMAIN_RUNNING;
|
vm->state = VIR_DOMAIN_RUNNING;
|
||||||
|
|
||||||
if (vm->def->vcpus > 0) {
|
if (vm->def->vcpus > 0) {
|
||||||
if (openvzDomainSetVcpusInternal(conn, vm, vm->def->vcpus) < 0) {
|
if (openvzDomainSetVcpusInternal(vm, vm->def->vcpus) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Could not set number of virtual cpu"));
|
_("Could not set number of virtual cpu"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -972,20 +968,20 @@ openvzDomainCreate(virDomainPtr dom)
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(dom->conn, VIR_ERR_INVALID_DOMAIN,
|
openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
|
||||||
"%s", _("no domain with matching id"));
|
_("no domain with matching id"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm->state != VIR_DOMAIN_SHUTOFF) {
|
if (vm->state != VIR_DOMAIN_SHUTOFF) {
|
||||||
openvzError(dom->conn, VIR_ERR_OPERATION_DENIED,
|
openvzError(VIR_ERR_OPERATION_DENIED, "%s",
|
||||||
"%s", _("domain is not in shutoff state"));
|
_("domain is not in shutoff state"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
openvzSetProgramSentinal(prog, vm->def->name);
|
openvzSetProgramSentinal(prog, vm->def->name);
|
||||||
if (virRun(prog, NULL) < 0) {
|
if (virRun(prog, NULL) < 0) {
|
||||||
openvzError(dom->conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not exec %s"), VZCTL);
|
_("Could not exec %s"), VZCTL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -1012,18 +1008,20 @@ openvzDomainUndefine(virDomainPtr dom)
|
|||||||
openvzDriverLock(driver);
|
openvzDriverLock(driver);
|
||||||
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(dom->conn, VIR_ERR_INVALID_DOMAIN, "%s", _("no domain with matching uuid"));
|
openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
|
||||||
|
_("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainObjIsActive(vm)) {
|
if (virDomainObjIsActive(vm)) {
|
||||||
openvzError(dom->conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot delete active domain"));
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
_("cannot delete active domain"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
openvzSetProgramSentinal(prog, vm->def->name);
|
openvzSetProgramSentinal(prog, vm->def->name);
|
||||||
if (virRun(prog, NULL) < 0) {
|
if (virRun(prog, NULL) < 0) {
|
||||||
openvzError(dom->conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not exec %s"), VZCTL);
|
_("Could not exec %s"), VZCTL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -1054,13 +1052,15 @@ openvzDomainSetAutostart(virDomainPtr dom, int autostart)
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(dom->conn, VIR_ERR_INVALID_DOMAIN, "%s", _("no domain with matching uuid"));
|
openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
|
||||||
|
_("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
openvzSetProgramSentinal(prog, vm->def->name);
|
openvzSetProgramSentinal(prog, vm->def->name);
|
||||||
if (virRun(prog, NULL) < 0) {
|
if (virRun(prog, NULL) < 0) {
|
||||||
openvzError(dom->conn, VIR_ERR_INTERNAL_ERROR, _("Could not exec %s"), VZCTL);
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("Could not exec %s"), VZCTL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -1084,14 +1084,14 @@ openvzDomainGetAutostart(virDomainPtr dom, int *autostart)
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(dom->conn, VIR_ERR_INVALID_DOMAIN,
|
openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
|
||||||
"%s", _("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openvzReadVPSConfigParam(strtoI(vm->def->name), "ONBOOT", value, sizeof(value)) < 0) {
|
if (openvzReadVPSConfigParam(strtoI(vm->def->name), "ONBOOT", value, sizeof(value)) < 0) {
|
||||||
openvzError(dom->conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("Could not read container config"));
|
_("Could not read container config"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1106,22 +1106,23 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int openvzGetMaxVCPUs(virConnectPtr conn, const char *type)
|
static int openvzGetMaxVCPUs(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||||
|
const char *type)
|
||||||
{
|
{
|
||||||
if (type == NULL || STRCASEEQ(type, "openvz"))
|
if (type == NULL || STRCASEEQ(type, "openvz"))
|
||||||
return 1028; /* OpenVZ has no limitation */
|
return 1028; /* OpenVZ has no limitation */
|
||||||
|
|
||||||
openvzError(conn, VIR_ERR_INVALID_ARG,
|
openvzError(VIR_ERR_INVALID_ARG,
|
||||||
_("unknown type '%s'"), type);
|
_("unknown type '%s'"), type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int openvzDomainGetMaxVcpus(virDomainPtr dom) {
|
static int openvzDomainGetMaxVcpus(virDomainPtr dom ATTRIBUTE_UNUSED) {
|
||||||
return openvzGetMaxVCPUs(dom->conn, "openvz");
|
return openvzGetMaxVCPUs(NULL, "openvz");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int openvzDomainSetVcpusInternal(virConnectPtr conn, virDomainObjPtr vm,
|
static int openvzDomainSetVcpusInternal(virDomainObjPtr vm,
|
||||||
unsigned int nvcpus)
|
unsigned int nvcpus)
|
||||||
{
|
{
|
||||||
char str_vcpus[32];
|
char str_vcpus[32];
|
||||||
@ -1137,7 +1138,7 @@ static int openvzDomainSetVcpusInternal(virConnectPtr conn, virDomainObjPtr vm,
|
|||||||
|
|
||||||
openvzSetProgramSentinal(prog, vm->def->name);
|
openvzSetProgramSentinal(prog, vm->def->name);
|
||||||
if (virRun(prog, NULL) < 0) {
|
if (virRun(prog, NULL) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not exec %s"), VZCTL);
|
_("Could not exec %s"), VZCTL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1157,18 +1158,18 @@ static int openvzDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus)
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(dom->conn, VIR_ERR_INVALID_DOMAIN,
|
openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
|
||||||
"%s", _("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nvcpus <= 0) {
|
if (nvcpus <= 0) {
|
||||||
openvzError(dom->conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"%s", _("VCPUs should be >= 1"));
|
_("VCPUs should be >= 1"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
openvzDomainSetVcpusInternal(dom->conn, vm, nvcpus);
|
openvzDomainSetVcpusInternal(vm, nvcpus);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -1208,20 +1209,20 @@ static virDrvOpenStatus openvzOpen(virConnectPtr conn,
|
|||||||
/* If path isn't /system, then they typoed, so tell them correct path */
|
/* If path isn't /system, then they typoed, so tell them correct path */
|
||||||
if (conn->uri->path == NULL ||
|
if (conn->uri->path == NULL ||
|
||||||
STRNEQ (conn->uri->path, "/system")) {
|
STRNEQ (conn->uri->path, "/system")) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unexpected OpenVZ URI path '%s', try openvz:///system"),
|
_("unexpected OpenVZ URI path '%s', try openvz:///system"),
|
||||||
conn->uri->path);
|
conn->uri->path);
|
||||||
return VIR_DRV_OPEN_ERROR;
|
return VIR_DRV_OPEN_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!virFileExists("/proc/vz")) {
|
if (!virFileExists("/proc/vz")) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("OpenVZ control file /proc/vz does not exist"));
|
_("OpenVZ control file /proc/vz does not exist"));
|
||||||
return VIR_DRV_OPEN_ERROR;
|
return VIR_DRV_OPEN_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (access("/proc/vz", W_OK) < 0) {
|
if (access("/proc/vz", W_OK) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
|
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("OpenVZ control file /proc/vz is not accessible"));
|
_("OpenVZ control file /proc/vz is not accessible"));
|
||||||
return VIR_DRV_OPEN_ERROR;
|
return VIR_DRV_OPEN_ERROR;
|
||||||
}
|
}
|
||||||
@ -1244,7 +1245,7 @@ static virDrvOpenStatus openvzOpen(virConnectPtr conn,
|
|||||||
if (openvzLoadDomains(driver) < 0)
|
if (openvzLoadDomains(driver) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (openvzExtractVersion(conn, driver) < 0)
|
if (openvzExtractVersion(driver) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
conn->privateData = driver;
|
conn->privateData = driver;
|
||||||
@ -1290,7 +1291,8 @@ static char *openvzGetCapabilities(virConnectPtr conn) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int openvzListDomains(virConnectPtr conn, int *ids, int nids) {
|
static int openvzListDomains(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||||
|
int *ids, int nids) {
|
||||||
int got = 0;
|
int got = 0;
|
||||||
int veid;
|
int veid;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
@ -1304,7 +1306,7 @@ static int openvzListDomains(virConnectPtr conn, int *ids, int nids) {
|
|||||||
ret = virExec(cmd, NULL, NULL,
|
ret = virExec(cmd, NULL, NULL,
|
||||||
&pid, -1, &outfd, &errfd, VIR_EXEC_NONE);
|
&pid, -1, &outfd, &errfd, VIR_EXEC_NONE);
|
||||||
if(ret == -1) {
|
if(ret == -1) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not exec %s"), VZLIST);
|
_("Could not exec %s"), VZLIST);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1313,7 +1315,7 @@ static int openvzListDomains(virConnectPtr conn, int *ids, int nids) {
|
|||||||
ret = openvz_readline(outfd, buf, 32);
|
ret = openvz_readline(outfd, buf, 32);
|
||||||
if(!ret) break;
|
if(!ret) break;
|
||||||
if (virStrToLong_i(buf, &endptr, 10, &veid) < 0) {
|
if (virStrToLong_i(buf, &endptr, 10, &veid) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not parse VPS ID %s"), buf);
|
_("Could not parse VPS ID %s"), buf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1336,7 +1338,7 @@ static int openvzNumDomains(virConnectPtr conn) {
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int openvzListDefinedDomains(virConnectPtr conn,
|
static int openvzListDefinedDomains(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||||
char **const names, int nnames) {
|
char **const names, int nnames) {
|
||||||
int got = 0;
|
int got = 0;
|
||||||
int veid, outfd = -1, errfd = -1, ret;
|
int veid, outfd = -1, errfd = -1, ret;
|
||||||
@ -1350,7 +1352,7 @@ static int openvzListDefinedDomains(virConnectPtr conn,
|
|||||||
ret = virExec(cmd, NULL, NULL,
|
ret = virExec(cmd, NULL, NULL,
|
||||||
&pid, -1, &outfd, &errfd, VIR_EXEC_NONE);
|
&pid, -1, &outfd, &errfd, VIR_EXEC_NONE);
|
||||||
if(ret == -1) {
|
if(ret == -1) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not exec %s"), VZLIST);
|
_("Could not exec %s"), VZLIST);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1359,7 +1361,7 @@ static int openvzListDefinedDomains(virConnectPtr conn,
|
|||||||
ret = openvz_readline(outfd, buf, 32);
|
ret = openvz_readline(outfd, buf, 32);
|
||||||
if(!ret) break;
|
if(!ret) break;
|
||||||
if (virStrToLong_i(buf, &endptr, 10, &veid) < 0) {
|
if (virStrToLong_i(buf, &endptr, 10, &veid) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not parse VPS ID %s"), buf);
|
_("Could not parse VPS ID %s"), buf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1435,7 +1437,7 @@ static int openvzNumDefinedDomains(virConnectPtr conn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
openvzDomainSetMemoryInternal(virConnectPtr conn, virDomainObjPtr vm,
|
openvzDomainSetMemoryInternal(virDomainObjPtr vm,
|
||||||
unsigned long mem)
|
unsigned long mem)
|
||||||
{
|
{
|
||||||
char str_mem[16];
|
char str_mem[16];
|
||||||
@ -1448,7 +1450,7 @@ openvzDomainSetMemoryInternal(virConnectPtr conn, virDomainObjPtr vm,
|
|||||||
|
|
||||||
openvzSetProgramSentinal(prog, vm->def->name);
|
openvzSetProgramSentinal(prog, vm->def->name);
|
||||||
if (virRun(prog, NULL) < 0) {
|
if (virRun(prog, NULL) < 0) {
|
||||||
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
|
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not exec %s"), VZCTL);
|
_("Could not exec %s"), VZCTL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user