mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-30 18:50:18 +03:00
Remove virConnectPtr from LXC driver
This commit is contained in:
parent
caa805ea64
commit
c39554bf49
@ -63,8 +63,8 @@ struct __lxc_driver {
|
||||
int lxcLoadDriverConfig(lxc_driver_t *driver);
|
||||
virCapsPtr lxcCapsInit(void);
|
||||
|
||||
#define lxcError(conn, dom, code, fmt...) \
|
||||
virReportErrorHelper(conn, VIR_FROM_LXC, code, __FILE__, \
|
||||
__FUNCTION__, __LINE__, fmt)
|
||||
#define lxcError(code, fmt...) \
|
||||
virReportErrorHelper(NULL, VIR_FROM_LXC, code, __FILE__, \
|
||||
__FUNCTION__, __LINE__, fmt)
|
||||
|
||||
#endif /* LXC_CONF_H */
|
||||
|
@ -684,13 +684,13 @@ static int lxcContainerDropCapabilities(void)
|
||||
CAP_AUDIT_CONTROL, /* No messing with auditing status */
|
||||
CAP_MAC_ADMIN, /* No messing with LSM config */
|
||||
-1 /* sentinal */)) < 0) {
|
||||
lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Failed to remove capabilities: %d"), ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((ret = capng_apply(CAPNG_SELECT_BOTH)) < 0) {
|
||||
lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Failed to apply capabilities: %d"), ret);
|
||||
return -1;
|
||||
}
|
||||
@ -729,7 +729,7 @@ static int lxcContainerChild( void *data )
|
||||
virDomainFSDefPtr root;
|
||||
|
||||
if (NULL == vmDef) {
|
||||
lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("lxcChild() passed invalid vm definition"));
|
||||
return -1;
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ static int lxcMonitorServer(const char *sockpath)
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sun_family = AF_UNIX;
|
||||
if (virStrcpyStatic(addr.sun_path, sockpath) == NULL) {
|
||||
lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Socket path %s too long for destination"), sockpath);
|
||||
goto error;
|
||||
}
|
||||
@ -253,7 +253,7 @@ static int lxcControllerClearCapabilities(void)
|
||||
capng_clear(CAPNG_SELECT_BOTH);
|
||||
|
||||
if ((ret = capng_apply(CAPNG_SELECT_BOTH)) < 0) {
|
||||
lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("failed to apply capabilities: %d"), ret);
|
||||
return -1;
|
||||
}
|
||||
@ -380,7 +380,7 @@ static int lxcControllerMain(int monitor,
|
||||
DEBUG("EPOLLHUP from fd %d", epollEvent.data.fd);
|
||||
continue;
|
||||
} else {
|
||||
lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("error event %d"), epollEvent.events);
|
||||
goto cleanup;
|
||||
}
|
||||
@ -451,7 +451,7 @@ static int lxcControllerMoveInterfaces(unsigned int nveths,
|
||||
unsigned int i;
|
||||
for (i = 0 ; i < nveths ; i++)
|
||||
if (moveInterfaceToNetNs(veths[i], container) < 0) {
|
||||
lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Failed to move interface %s to ns %d"),
|
||||
veths[i], container);
|
||||
return -1;
|
||||
@ -476,7 +476,7 @@ static int lxcControllerCleanupInterfaces(unsigned int nveths,
|
||||
unsigned int i;
|
||||
for (i = 0 ; i < nveths ; i++)
|
||||
if (vethDelete(veths[i]) < 0)
|
||||
lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Failed to delete veth: %s"), veths[i]);
|
||||
/* will continue to try to cleanup any other interfaces */
|
||||
|
||||
|
@ -127,7 +127,7 @@ static virDrvOpenStatus lxcOpen(virConnectPtr conn,
|
||||
|
||||
/* If path isn't '/' then they typoed, tell them correct path */
|
||||
if (STRNEQ(conn->uri->path, "/")) {
|
||||
lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Unexpected LXC URI path '%s', try lxc:///"),
|
||||
conn->uri->path);
|
||||
return VIR_DRV_OPEN_ERROR;
|
||||
@ -135,7 +135,7 @@ static virDrvOpenStatus lxcOpen(virConnectPtr conn,
|
||||
|
||||
/* URI was good, but driver isn't active */
|
||||
if (lxc_driver == NULL) {
|
||||
lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("lxc state driver is not active"));
|
||||
return VIR_DRV_OPEN_ERROR;
|
||||
}
|
||||
@ -198,7 +198,7 @@ static virDomainPtr lxcDomainLookupByID(virConnectPtr conn,
|
||||
lxcDriverUnlock(driver);
|
||||
|
||||
if (!vm) {
|
||||
lxcError(conn, NULL, VIR_ERR_NO_DOMAIN, NULL);
|
||||
lxcError(VIR_ERR_NO_DOMAIN, NULL);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ static virDomainPtr lxcDomainLookupByUUID(virConnectPtr conn,
|
||||
lxcDriverUnlock(driver);
|
||||
|
||||
if (!vm) {
|
||||
lxcError(conn, NULL, VIR_ERR_NO_DOMAIN, NULL);
|
||||
lxcError(VIR_ERR_NO_DOMAIN, NULL);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -249,7 +249,7 @@ static virDomainPtr lxcDomainLookupByName(virConnectPtr conn,
|
||||
vm = virDomainFindByName(&driver->domains, name);
|
||||
lxcDriverUnlock(driver);
|
||||
if (!vm) {
|
||||
lxcError(conn, NULL, VIR_ERR_NO_DOMAIN, NULL);
|
||||
lxcError(VIR_ERR_NO_DOMAIN, NULL);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -274,7 +274,7 @@ static int lxcDomainIsActive(virDomainPtr dom)
|
||||
obj = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||
lxcDriverUnlock(driver);
|
||||
if (!obj) {
|
||||
lxcError(dom->conn, NULL, VIR_ERR_NO_DOMAIN, NULL);
|
||||
lxcError(VIR_ERR_NO_DOMAIN, NULL);
|
||||
goto cleanup;
|
||||
}
|
||||
ret = virDomainObjIsActive(obj);
|
||||
@ -296,7 +296,7 @@ static int lxcDomainIsPersistent(virDomainPtr dom)
|
||||
obj = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||
lxcDriverUnlock(driver);
|
||||
if (!obj) {
|
||||
lxcError(dom->conn, NULL, VIR_ERR_NO_DOMAIN, NULL);
|
||||
lxcError(VIR_ERR_NO_DOMAIN, NULL);
|
||||
goto cleanup;
|
||||
}
|
||||
ret = obj->persistent;
|
||||
@ -374,7 +374,7 @@ static virDomainPtr lxcDomainDefine(virConnectPtr conn, const char *xml)
|
||||
goto cleanup;
|
||||
|
||||
if ((def->nets != NULL) && !(driver->have_netns)) {
|
||||
lxcError(conn, NULL, VIR_ERR_NO_SUPPORT,
|
||||
lxcError(VIR_ERR_NO_SUPPORT,
|
||||
"%s", _("System lacks NETNS support"));
|
||||
goto cleanup;
|
||||
}
|
||||
@ -423,19 +423,19 @@ static int lxcDomainUndefine(virDomainPtr dom)
|
||||
lxcDriverLock(driver);
|
||||
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||
if (!vm) {
|
||||
lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN,
|
||||
lxcError(VIR_ERR_INVALID_DOMAIN,
|
||||
"%s", _("No domain with matching uuid"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virDomainObjIsActive(vm)) {
|
||||
lxcError(dom->conn, dom, VIR_ERR_OPERATION_INVALID,
|
||||
lxcError(VIR_ERR_OPERATION_INVALID,
|
||||
"%s", _("Cannot delete active domain"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!vm->persistent) {
|
||||
lxcError(dom->conn, dom, VIR_ERR_OPERATION_INVALID,
|
||||
lxcError(VIR_ERR_OPERATION_INVALID,
|
||||
"%s", _("Cannot undefine transient domain"));
|
||||
goto cleanup;
|
||||
}
|
||||
@ -475,7 +475,7 @@ static int lxcDomainGetInfo(virDomainPtr dom,
|
||||
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||
|
||||
if (!vm) {
|
||||
lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN,
|
||||
lxcError(VIR_ERR_INVALID_DOMAIN,
|
||||
"%s", _("No domain with matching uuid"));
|
||||
goto cleanup;
|
||||
}
|
||||
@ -487,18 +487,18 @@ static int lxcDomainGetInfo(virDomainPtr dom,
|
||||
info->memory = vm->def->memory;
|
||||
} else {
|
||||
if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) {
|
||||
lxcError(dom->conn, dom, VIR_ERR_INTERNAL_ERROR,
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Unable to get cgroup for %s"), vm->def->name);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virCgroupGetCpuacctUsage(cgroup, &(info->cpuTime)) < 0) {
|
||||
lxcError(dom->conn, dom, VIR_ERR_OPERATION_FAILED,
|
||||
lxcError(VIR_ERR_OPERATION_FAILED,
|
||||
"%s", _("Cannot read cputime for domain"));
|
||||
goto cleanup;
|
||||
}
|
||||
if (virCgroupGetMemoryUsage(cgroup, &(info->memory)) < 0) {
|
||||
lxcError(dom->conn, dom, VIR_ERR_OPERATION_FAILED,
|
||||
lxcError(VIR_ERR_OPERATION_FAILED,
|
||||
"%s", _("Cannot read memory usage for domain"));
|
||||
goto cleanup;
|
||||
}
|
||||
@ -528,7 +528,7 @@ static char *lxcGetOSType(virDomainPtr dom)
|
||||
lxcDriverUnlock(driver);
|
||||
|
||||
if (!vm) {
|
||||
lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN,
|
||||
lxcError(VIR_ERR_INVALID_DOMAIN,
|
||||
"%s", _("No domain with matching uuid"));
|
||||
goto cleanup;
|
||||
}
|
||||
@ -557,7 +557,7 @@ static unsigned long lxcDomainGetMaxMemory(virDomainPtr dom) {
|
||||
if (!vm) {
|
||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||
virUUIDFormat(dom->uuid, uuidstr);
|
||||
lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN,
|
||||
lxcError(VIR_ERR_NO_DOMAIN,
|
||||
_("No domain with matching uuid '%s'"), uuidstr);
|
||||
goto cleanup;
|
||||
}
|
||||
@ -582,13 +582,13 @@ static int lxcDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax) {
|
||||
if (!vm) {
|
||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||
virUUIDFormat(dom->uuid, uuidstr);
|
||||
lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN,
|
||||
lxcError(VIR_ERR_NO_DOMAIN,
|
||||
_("No domain with matching uuid '%s'"), uuidstr);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (newmax < vm->def->memory) {
|
||||
lxcError(dom->conn, dom, VIR_ERR_INVALID_ARG,
|
||||
lxcError(VIR_ERR_INVALID_ARG,
|
||||
"%s", _("Cannot set max memory lower than current memory"));
|
||||
goto cleanup;
|
||||
}
|
||||
@ -614,26 +614,26 @@ static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem) {
|
||||
if (!vm) {
|
||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||
virUUIDFormat(dom->uuid, uuidstr);
|
||||
lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN,
|
||||
lxcError(VIR_ERR_NO_DOMAIN,
|
||||
_("No domain with matching uuid '%s'"), uuidstr);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (newmem > vm->def->maxmem) {
|
||||
lxcError(dom->conn, dom, VIR_ERR_INVALID_ARG,
|
||||
lxcError(VIR_ERR_INVALID_ARG,
|
||||
"%s", _("Cannot set memory higher than max memory"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virDomainObjIsActive(vm)) {
|
||||
if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) {
|
||||
lxcError(dom->conn, dom, VIR_ERR_INTERNAL_ERROR,
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Unable to get cgroup for %s\n"), vm->def->name);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virCgroupSetMemory(cgroup, newmem) < 0) {
|
||||
lxcError(dom->conn, dom, VIR_ERR_OPERATION_FAILED,
|
||||
lxcError(VIR_ERR_OPERATION_FAILED,
|
||||
"%s", _("Failed to set memory for domain"));
|
||||
goto cleanup;
|
||||
}
|
||||
@ -662,7 +662,7 @@ static char *lxcDomainDumpXML(virDomainPtr dom,
|
||||
lxcDriverUnlock(driver);
|
||||
|
||||
if (!vm) {
|
||||
lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN,
|
||||
lxcError(VIR_ERR_INVALID_DOMAIN,
|
||||
"%s", _("No domain with matching uuid"));
|
||||
goto cleanup;
|
||||
}
|
||||
@ -691,8 +691,7 @@ cleanup:
|
||||
*
|
||||
* Returns 0 on success or -1 in case of error
|
||||
*/
|
||||
static int lxcVmCleanup(virConnectPtr conn,
|
||||
lxc_driver_t *driver,
|
||||
static int lxcVmCleanup(lxc_driver_t *driver,
|
||||
virDomainObjPtr vm)
|
||||
{
|
||||
int rc = -1;
|
||||
@ -723,7 +722,7 @@ static int lxcVmCleanup(virConnectPtr conn,
|
||||
close(priv->monitor);
|
||||
|
||||
virFileDeletePid(driver->stateDir, vm->def->name);
|
||||
virDomainDeleteConfig(conn, driver->stateDir, NULL, vm);
|
||||
virDomainDeleteConfig(NULL, driver->stateDir, NULL, vm);
|
||||
|
||||
vm->state = VIR_DOMAIN_SHUTOFF;
|
||||
vm->pid = -1;
|
||||
@ -801,7 +800,7 @@ static int lxcSetupInterfaces(virConnectPtr conn,
|
||||
|
||||
DEBUG("bridge: %s", bridge);
|
||||
if (NULL == bridge) {
|
||||
lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("Failed to get bridge for interface"));
|
||||
goto error_exit;
|
||||
}
|
||||
@ -812,7 +811,7 @@ static int lxcSetupInterfaces(virConnectPtr conn,
|
||||
}
|
||||
DEBUG("parentVeth: %s, containerVeth: %s", parentVeth, containerVeth);
|
||||
if (0 != (rc = vethCreate(parentVeth, PATH_MAX, containerVeth, PATH_MAX))) {
|
||||
lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Failed to create veth device pair: %d"), rc);
|
||||
goto error_exit;
|
||||
}
|
||||
@ -869,8 +868,7 @@ error_exit:
|
||||
}
|
||||
|
||||
|
||||
static int lxcMonitorClient(virConnectPtr conn,
|
||||
lxc_driver_t * driver,
|
||||
static int lxcMonitorClient(lxc_driver_t * driver,
|
||||
virDomainObjPtr vm)
|
||||
{
|
||||
char *sockpath = NULL;
|
||||
@ -892,7 +890,7 @@ static int lxcMonitorClient(virConnectPtr conn,
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sun_family = AF_UNIX;
|
||||
if (virStrcpyStatic(addr.sun_path, sockpath) == NULL) {
|
||||
lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Socket path %s too big for destination"), sockpath);
|
||||
goto error;
|
||||
}
|
||||
@ -914,8 +912,7 @@ error:
|
||||
}
|
||||
|
||||
|
||||
static int lxcVmTerminate(virConnectPtr conn,
|
||||
lxc_driver_t *driver,
|
||||
static int lxcVmTerminate(lxc_driver_t *driver,
|
||||
virDomainObjPtr vm,
|
||||
int signum)
|
||||
{
|
||||
@ -923,7 +920,7 @@ static int lxcVmTerminate(virConnectPtr conn,
|
||||
signum = SIGINT;
|
||||
|
||||
if (vm->pid <= 0) {
|
||||
lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Invalid PID %d for container"), vm->pid);
|
||||
return -1;
|
||||
}
|
||||
@ -939,7 +936,7 @@ static int lxcVmTerminate(virConnectPtr conn,
|
||||
|
||||
vm->state = VIR_DOMAIN_SHUTDOWN;
|
||||
|
||||
return lxcVmCleanup(conn, driver, vm);
|
||||
return lxcVmCleanup(driver, vm);
|
||||
}
|
||||
|
||||
static void lxcMonitorEvent(int watch,
|
||||
@ -963,7 +960,7 @@ static void lxcMonitorEvent(int watch,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (lxcVmTerminate(NULL, driver, vm, SIGINT) < 0) {
|
||||
if (lxcVmTerminate(driver, vm, SIGINT) < 0) {
|
||||
virEventRemoveHandle(watch);
|
||||
} else {
|
||||
event = virDomainEventNewFromObj(vm,
|
||||
@ -986,7 +983,7 @@ cleanup:
|
||||
}
|
||||
|
||||
|
||||
static int lxcControllerStart(virConnectPtr conn,
|
||||
static int lxcControllerStart(lxc_driver_t *driver,
|
||||
virDomainObjPtr vm,
|
||||
int nveths,
|
||||
char **veths,
|
||||
@ -1008,7 +1005,6 @@ static int lxcControllerStart(virConnectPtr conn,
|
||||
fd_set keepfd;
|
||||
char appPtyStr[30];
|
||||
const char *emulator;
|
||||
lxc_driver_t *driver = conn->privateData;
|
||||
|
||||
FD_ZERO(&keepfd);
|
||||
|
||||
@ -1138,7 +1134,7 @@ static int lxcControllerStart(virConnectPtr conn,
|
||||
}
|
||||
|
||||
if (!(WIFEXITED(status) && WEXITSTATUS(status) == 0)) {
|
||||
lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Container '%s' unexpectedly shutdown during startup"),
|
||||
largv[0]);
|
||||
goto cleanup;
|
||||
@ -1235,7 +1231,7 @@ static int lxcVmStart(virConnectPtr conn,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (lxcControllerStart(conn,
|
||||
if (lxcControllerStart(driver,
|
||||
vm,
|
||||
nveths, veths,
|
||||
parentTty, logfd) < 0)
|
||||
@ -1244,7 +1240,7 @@ static int lxcVmStart(virConnectPtr conn,
|
||||
/* Connect to the controller as a client *first* because
|
||||
* this will block until the child has written their
|
||||
* pid file out to disk */
|
||||
if ((priv->monitor = lxcMonitorClient(conn, driver, vm)) < 0)
|
||||
if ((priv->monitor = lxcMonitorClient(driver, vm)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
/* And get its pid */
|
||||
@ -1263,7 +1259,7 @@ static int lxcVmStart(virConnectPtr conn,
|
||||
VIR_EVENT_HANDLE_ERROR | VIR_EVENT_HANDLE_HANGUP,
|
||||
lxcMonitorEvent,
|
||||
vm, NULL)) < 0) {
|
||||
lxcVmTerminate(conn, driver, vm, 0);
|
||||
lxcVmTerminate(driver, vm, 0);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -1305,13 +1301,13 @@ static int lxcDomainStart(virDomainPtr dom)
|
||||
lxcDriverLock(driver);
|
||||
vm = virDomainFindByName(&driver->domains, dom->name);
|
||||
if (!vm) {
|
||||
lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN,
|
||||
lxcError(VIR_ERR_INVALID_DOMAIN,
|
||||
_("No domain named %s"), dom->name);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if ((vm->def->nets != NULL) && !(driver->have_netns)) {
|
||||
lxcError(dom->conn, NULL, VIR_ERR_NO_SUPPORT,
|
||||
lxcError(VIR_ERR_NO_SUPPORT,
|
||||
"%s", _("System lacks NETNS support"));
|
||||
goto cleanup;
|
||||
}
|
||||
@ -1361,7 +1357,7 @@ lxcDomainCreateAndStart(virConnectPtr conn,
|
||||
goto cleanup;
|
||||
|
||||
if ((def->nets != NULL) && !(driver->have_netns)) {
|
||||
lxcError(conn, NULL, VIR_ERR_NO_SUPPORT,
|
||||
lxcError(VIR_ERR_NO_SUPPORT,
|
||||
"%s", _("System lacks NETNS support"));
|
||||
goto cleanup;
|
||||
}
|
||||
@ -1414,12 +1410,12 @@ static int lxcDomainShutdown(virDomainPtr dom)
|
||||
lxcDriverLock(driver);
|
||||
vm = virDomainFindByID(&driver->domains, dom->id);
|
||||
if (!vm) {
|
||||
lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN,
|
||||
lxcError(VIR_ERR_INVALID_DOMAIN,
|
||||
_("No domain with id %d"), dom->id);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = lxcVmTerminate(dom->conn, driver, vm, 0);
|
||||
ret = lxcVmTerminate(driver, vm, 0);
|
||||
event = virDomainEventNewFromObj(vm,
|
||||
VIR_DOMAIN_EVENT_STOPPED,
|
||||
VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN);
|
||||
@ -1547,12 +1543,12 @@ static int lxcDomainDestroy(virDomainPtr dom)
|
||||
lxcDriverLock(driver);
|
||||
vm = virDomainFindByID(&driver->domains, dom->id);
|
||||
if (!vm) {
|
||||
lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN,
|
||||
lxcError(VIR_ERR_INVALID_DOMAIN,
|
||||
_("No domain with id %d"), dom->id);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = lxcVmTerminate(dom->conn, driver, vm, SIGKILL);
|
||||
ret = lxcVmTerminate(driver, vm, SIGKILL);
|
||||
event = virDomainEventNewFromObj(vm,
|
||||
VIR_DOMAIN_EVENT_STOPPED,
|
||||
VIR_DOMAIN_EVENT_STOPPED_DESTROYED);
|
||||
@ -1650,7 +1646,7 @@ lxcReconnectVM(void *payload, const char *name ATTRIBUTE_UNUSED, void *opaque)
|
||||
virDomainObjLock(vm);
|
||||
|
||||
priv = vm->privateData;
|
||||
if ((priv->monitor = lxcMonitorClient(NULL, driver, vm)) < 0) {
|
||||
if ((priv->monitor = lxcMonitorClient(driver, vm)) < 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -1683,7 +1679,7 @@ lxcReconnectVM(void *payload, const char *name ATTRIBUTE_UNUSED, void *opaque)
|
||||
VIR_EVENT_HANDLE_ERROR | VIR_EVENT_HANDLE_HANGUP,
|
||||
lxcMonitorEvent,
|
||||
vm, NULL)) < 0) {
|
||||
lxcVmTerminate(NULL, driver, vm, 0);
|
||||
lxcVmTerminate(driver, vm, 0);
|
||||
goto cleanup;
|
||||
}
|
||||
} else {
|
||||
@ -1870,7 +1866,7 @@ lxcActive(void) {
|
||||
return active;
|
||||
}
|
||||
|
||||
static int lxcVersion(virConnectPtr conn, unsigned long *version)
|
||||
static int lxcVersion(virConnectPtr conn ATTRIBUTE_UNUSED, unsigned long *version)
|
||||
{
|
||||
struct utsname ver;
|
||||
int maj;
|
||||
@ -1880,7 +1876,7 @@ static int lxcVersion(virConnectPtr conn, unsigned long *version)
|
||||
uname(&ver);
|
||||
|
||||
if (sscanf(ver.release, "%i.%i.%i", &maj, &min, &rev) != 3) {
|
||||
lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Unknown release: %s"), ver.release);
|
||||
return -1;
|
||||
}
|
||||
@ -1923,7 +1919,7 @@ static int lxcSetSchedulerParameters(virDomainPtr domain,
|
||||
vm = virDomainFindByUUID(&driver->domains, domain->uuid);
|
||||
|
||||
if (vm == NULL) {
|
||||
lxcError(NULL, domain, VIR_ERR_INTERNAL_ERROR,
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("No such domain %s"), domain->uuid);
|
||||
goto cleanup;
|
||||
}
|
||||
@ -1934,7 +1930,7 @@ static int lxcSetSchedulerParameters(virDomainPtr domain,
|
||||
for (i = 0; i < nparams; i++) {
|
||||
virSchedParameterPtr param = ¶ms[i];
|
||||
if (param->type != VIR_DOMAIN_SCHED_FIELD_ULLONG) {
|
||||
lxcError(NULL, domain, VIR_ERR_INVALID_ARG, "%s",
|
||||
lxcError(VIR_ERR_INVALID_ARG, "%s",
|
||||
_("Invalid type for cpu_shares tunable, expected a 'ullong'"));
|
||||
goto cleanup;
|
||||
}
|
||||
@ -1943,7 +1939,7 @@ static int lxcSetSchedulerParameters(virDomainPtr domain,
|
||||
if (virCgroupSetCpuShares(group, params[i].value.ul) != 0)
|
||||
goto cleanup;
|
||||
} else {
|
||||
lxcError(NULL, domain, VIR_ERR_INVALID_ARG,
|
||||
lxcError(VIR_ERR_INVALID_ARG,
|
||||
_("Invalid parameter `%s'"), param->field);
|
||||
goto cleanup;
|
||||
}
|
||||
@ -1972,7 +1968,7 @@ static int lxcGetSchedulerParameters(virDomainPtr domain,
|
||||
return -1;
|
||||
|
||||
if ((*nparams) != 1) {
|
||||
lxcError(NULL, domain, VIR_ERR_INVALID_ARG,
|
||||
lxcError(VIR_ERR_INVALID_ARG,
|
||||
"%s", _("Invalid parameter count"));
|
||||
return -1;
|
||||
}
|
||||
@ -1981,7 +1977,7 @@ static int lxcGetSchedulerParameters(virDomainPtr domain,
|
||||
vm = virDomainFindByUUID(&driver->domains, domain->uuid);
|
||||
|
||||
if (vm == NULL) {
|
||||
lxcError(NULL, domain, VIR_ERR_INTERNAL_ERROR,
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("No such domain %s"), domain->uuid);
|
||||
goto cleanup;
|
||||
}
|
||||
@ -1993,7 +1989,7 @@ static int lxcGetSchedulerParameters(virDomainPtr domain,
|
||||
goto cleanup;
|
||||
params[0].value.ul = val;
|
||||
if (virStrcpyStatic(params[0].field, "cpu_shares") == NULL) {
|
||||
lxcError(NULL, domain, VIR_ERR_INTERNAL_ERROR,
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("Field cpu_shares too big for destination"));
|
||||
goto cleanup;
|
||||
}
|
||||
@ -2027,13 +2023,13 @@ lxcDomainInterfaceStats(virDomainPtr dom,
|
||||
if (!vm) {
|
||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||
virUUIDFormat(dom->uuid, uuidstr);
|
||||
lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN,
|
||||
lxcError(VIR_ERR_NO_DOMAIN,
|
||||
_("No domain with matching uuid '%s'"), uuidstr);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!virDomainObjIsActive(vm)) {
|
||||
lxcError(dom->conn, dom, VIR_ERR_OPERATION_INVALID,
|
||||
lxcError(VIR_ERR_OPERATION_INVALID,
|
||||
"%s", _("Domain is not running"));
|
||||
goto cleanup;
|
||||
}
|
||||
@ -2050,7 +2046,7 @@ lxcDomainInterfaceStats(virDomainPtr dom,
|
||||
if (ret == 0)
|
||||
ret = linuxDomainInterfaceStats(path, stats);
|
||||
else
|
||||
lxcError(dom->conn, dom, VIR_ERR_INVALID_ARG,
|
||||
lxcError(VIR_ERR_INVALID_ARG,
|
||||
_("Invalid path, '%s' is not a known interface"), path);
|
||||
|
||||
cleanup:
|
||||
@ -2063,7 +2059,7 @@ static int
|
||||
lxcDomainInterfaceStats(virDomainPtr dom,
|
||||
const char *path ATTRIBUTE_UNUSED,
|
||||
struct _virDomainInterfaceStats *stats ATTRIBUTE_UNUSED)
|
||||
lxcError(dom->conn, dom, VIR_ERR_NO_SUPPORT, "%s", __FUNCTION__);
|
||||
lxcError(VIR_ERR_NO_SUPPORT, "%s", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
@ -2081,7 +2077,7 @@ static int lxcDomainGetAutostart(virDomainPtr dom,
|
||||
if (!vm) {
|
||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||
virUUIDFormat(dom->uuid, uuidstr);
|
||||
lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN,
|
||||
lxcError(VIR_ERR_NO_DOMAIN,
|
||||
_("No domain with matching uuid '%s'"), uuidstr);
|
||||
goto cleanup;
|
||||
}
|
||||
@ -2108,13 +2104,13 @@ static int lxcDomainSetAutostart(virDomainPtr dom,
|
||||
if (!vm) {
|
||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||
virUUIDFormat(dom->uuid, uuidstr);
|
||||
lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN,
|
||||
lxcError(VIR_ERR_NO_DOMAIN,
|
||||
_("No domain with matching uuid '%s'"), uuidstr);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!vm->persistent) {
|
||||
lxcError(dom->conn, dom, VIR_ERR_INTERNAL_ERROR,
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("Cannot set autostart for transient domain"));
|
||||
goto cleanup;
|
||||
}
|
||||
@ -2277,20 +2273,20 @@ static int lxcDomainSuspend(virDomainPtr dom)
|
||||
if (!vm) {
|
||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||
virUUIDFormat(dom->uuid, uuidstr);
|
||||
lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN,
|
||||
lxcError(VIR_ERR_NO_DOMAIN,
|
||||
_("No domain with matching uuid '%s'"), uuidstr);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!virDomainObjIsActive(vm)) {
|
||||
lxcError(dom->conn, dom, VIR_ERR_OPERATION_INVALID,
|
||||
lxcError(VIR_ERR_OPERATION_INVALID,
|
||||
"%s", _("Domain is not running"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (vm->state != VIR_DOMAIN_PAUSED) {
|
||||
if (lxcFreezeContainer(driver, vm) < 0) {
|
||||
lxcError(dom->conn, dom, VIR_ERR_OPERATION_FAILED,
|
||||
lxcError(VIR_ERR_OPERATION_FAILED,
|
||||
"%s", _("Suspend operation failed"));
|
||||
goto cleanup;
|
||||
}
|
||||
@ -2342,20 +2338,20 @@ static int lxcDomainResume(virDomainPtr dom)
|
||||
if (!vm) {
|
||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||
virUUIDFormat(dom->uuid, uuidstr);
|
||||
lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN,
|
||||
lxcError(VIR_ERR_NO_DOMAIN,
|
||||
_("No domain with matching uuid '%s'"), uuidstr);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!virDomainObjIsActive(vm)) {
|
||||
lxcError(dom->conn, dom, VIR_ERR_OPERATION_INVALID,
|
||||
lxcError(VIR_ERR_OPERATION_INVALID,
|
||||
"%s", _("Domain is not running"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (vm->state == VIR_DOMAIN_PAUSED) {
|
||||
if (lxcUnfreezeContainer(driver, vm) < 0) {
|
||||
lxcError(dom->conn, dom, VIR_ERR_OPERATION_FAILED,
|
||||
lxcError(VIR_ERR_OPERATION_FAILED,
|
||||
"%s", _("Resume operation failed"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user