[libvirt] [PATCH 0/3] LXC misc fixes and cleanups

This patch series fix and cleanup over whole lxc codes. I want to clean up before adding more in them. Thanks, ozaki-r Ryota Ozaki (3): LXC fix wrong or out-of-date function descriptions LXC cleanup and fix lxcError LXC cleanup deep indentation in lxcDomainSetAutostart src/lxc/lxc_container.c | 85 +++++++++++----------- src/lxc/lxc_controller.c | 40 ++++++----- src/lxc/lxc_driver.c | 177 +++++++++++++++++++++++++--------------------- src/lxc/veth.c | 8 +- 4 files changed, 164 insertions(+), 146 deletions(-)

--- src/lxc/lxc_container.c | 26 +++++++++++++++----------- src/lxc/lxc_controller.c | 12 +++++++----- src/lxc/lxc_driver.c | 15 ++++++++++----- src/lxc/veth.c | 4 ++-- 4 files changed, 34 insertions(+), 23 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index f4381e7..2910efc 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -91,7 +91,7 @@ struct __lxc_child_argv { /** * lxcContainerExecInit: - * @vmDef: Ptr to vm definition structure + * @vmDef: pointer to vm definition structure * * Exec the container init string. The container init will replace then * be running in the current process @@ -110,8 +110,8 @@ static int lxcContainerExecInit(virDomainDefPtr vmDef) /** * lxcContainerSetStdio: - * @control: the conrol FD - * @ttyPath: Name of tty to set as the container console + * @control: control FD from parent + * @ttyfd: FD of tty to set as the container console * * Sets the given tty as the primary conosole for the container as well as * stdout, stdin and stderr. @@ -168,7 +168,7 @@ cleanup: /** * lxcContainerSendContinue: - * @monitor: control FD to child + * @control: control FD to child * * Sends the continue message via the socket pair stored in the vm * structure. @@ -196,7 +196,7 @@ error_out: /** * lxcContainerWaitForContinue: - * @control: control FD from parent + * @control: Control FD from parent * * This function will wait for the container continue message from the * parent process. It will send this message on the socket pair stored in @@ -225,8 +225,9 @@ static int lxcContainerWaitForContinue(int control) /** - * lxcEnableInterfaces: - * @vm: Pointer to vm structure + * lxcContainerEnableInterfaces: + * @nveths: number of interfaces + * @veths: interface names * * This function will enable the interfaces for this container. * @@ -696,8 +697,8 @@ static int lxcContainerDropCapabilities(void) /** - * lxcChild: - * @argv: Pointer to container arguments + * lxcContainerChild: + * @data: pointer to container arguments * * This function is run in the process clone()'d in lxcStartContainer. * Perform a number of container setup tasks: @@ -776,8 +777,11 @@ static int userns_supported(void) /** * lxcContainerStart: - * @driver: pointer to driver structure - * @vm: pointer to virtual machine structure + * @def: pointer to virtual machine structure + * @nveths: number of interfaces + * @veths: interface names + * @control: control FD to the container + * @ttyPath: path of tty to set as the container console * * Starts a container process by calling clone() with the namespace flags * diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 545f718..f5e0a5a 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -269,9 +269,11 @@ typedef struct _lxcTtyForwardFd_t { } lxcTtyForwardFd_t; /** - * lxcTtyForward: - * @appPty: Open fd for application facing Pty - * @contPty: Open fd for container facing Pty + * lxcControllerMain + * @monitor: server socket fd to accept client requests + * @client: initial client which is the libvirtd daemon + * @appPty: open fd for application facing Pty + * @contPty: open fd for container facing Pty * * Forwards traffic between fds. Data read from appPty will be written to contPty * This process loops forever. @@ -461,8 +463,8 @@ static int lxcControllerMoveInterfaces(unsigned int nveths, /** * lxcCleanupInterfaces: - * @conn: pointer to connection - * @vm: pointer to virtual machine structure + * @nveths: number of interfaces + * @veths: interface names * * Cleans up the container interfaces by deleting the veth device pairs. * diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 9ab94bf..0dd3a08 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -614,7 +614,9 @@ cleanup: /** * lxcVmCleanup: - * @vm: Ptr to VM to clean up + * @conn: pointer to connection + * @driver: pointer to driver structure + * @vm: pointer to VM to clean up * * waitpid() on the container process. kill and wait the tty process * This is called by both lxcDomainDestroy and lxcSigHandler when a @@ -622,7 +624,7 @@ cleanup: * * Returns 0 on success or -1 in case of error */ -static int lxcVMCleanup(virConnectPtr conn, +static int lxcVmCleanup(virConnectPtr conn, lxc_driver_t *driver, virDomainObjPtr vm) { @@ -683,7 +685,10 @@ static int lxcVMCleanup(virConnectPtr conn, /** * lxcSetupInterfaces: + * @conn: pointer to connection * @def: pointer to virtual machine structure + * @nveths: number of interfaces + * @veths: interface names * * Sets up the container interfaces by creating the veth device pairs and * attaching the parent end to the appropriate bridge. The container end @@ -860,7 +865,7 @@ static int lxcVmTerminate(virConnectPtr conn, vm->state = VIR_DOMAIN_SHUTDOWN; - return lxcVMCleanup(conn, driver, vm); + return lxcVmCleanup(conn, driver, vm); } static void lxcMonitorEvent(int watch, @@ -1344,7 +1349,7 @@ cleanup: /** * lxcDomainShutdown: - * @dom: Ptr to domain to shutdown + * @dom: pointer to domain to shutdown * * Sends SIGINT to container root process to request it to shutdown * @@ -1477,7 +1482,7 @@ static void lxcDomainEventQueue(lxc_driver_t *driver, /** * lxcDomainDestroy: - * @dom: Ptr to domain to destroy + * @dom: pointer to domain to destroy * * Sends SIGKILL to container root process to terminate the container * diff --git a/src/lxc/veth.c b/src/lxc/veth.c index b15df8d..5984950 100644 --- a/src/lxc/veth.c +++ b/src/lxc/veth.c @@ -182,12 +182,12 @@ error_out: /** * moveInterfaceToNetNs: - * @interface: name of device + * @iface: name of device * @pidInNs: PID of process in target net namespace * * Moves the given device into the target net namespace specified by the given * pid using this command: - * ip link set interface netns pidInNs + * ip link set @iface netns @pidInNs * * Returns 0 on success or -1 in case of error */ -- 1.6.2.5

On Thu, Nov 05, 2009 at 02:19:12AM +0900, Ryota Ozaki wrote:
--- src/lxc/lxc_container.c | 26 +++++++++++++++----------- src/lxc/lxc_controller.c | 12 +++++++----- src/lxc/lxc_driver.c | 15 ++++++++++----- src/lxc/veth.c | 4 ++-- 4 files changed, 34 insertions(+), 23 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index f4381e7..2910efc 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -91,7 +91,7 @@ struct __lxc_child_argv {
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

Most of cleanups are just capitalizing their messages though, some fixes wrong error messages and awkward indentations, and improves error messages. --- src/lxc/lxc_container.c | 59 +++++++++++++------------- src/lxc/lxc_controller.c | 28 ++++++------ src/lxc/lxc_driver.c | 103 +++++++++++++++++++++++----------------------- src/lxc/veth.c | 4 +- 4 files changed, 97 insertions(+), 97 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 2910efc..2419345 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -184,7 +184,7 @@ int lxcContainerSendContinue(int control) writeCount = safewrite(control, &msg, sizeof(msg)); if (writeCount != sizeof(msg)) { virReportSystemError(NULL, errno, "%s", - _("unable to send container continue message")); + _("Unable to send container continue message")); goto error_out; } @@ -295,7 +295,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root) /* root->parent must be private, so make / private. */ if (mount("", "/", NULL, MS_PRIVATE|MS_REC, NULL) < 0) { virReportSystemError(NULL, errno, "%s", - _("failed to make root private")); + _("Failed to make root private")); goto err; } @@ -306,7 +306,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root) if ((rc = virFileMakePath(oldroot)) < 0) { virReportSystemError(NULL, rc, - _("failed to create %s"), + _("Failed to create %s"), oldroot); goto err; } @@ -315,7 +315,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root) * on separate filesystems */ if (mount("tmprootfs", oldroot, "tmpfs", 0, NULL) < 0) { virReportSystemError(NULL, errno, - _("failed to mount empty tmpfs at %s"), + _("Failed to mount empty tmpfs at %s"), oldroot); goto err; } @@ -328,7 +328,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root) if ((rc = virFileMakePath(newroot)) < 0) { virReportSystemError(NULL, rc, - _("failed to create %s"), + _("Failed to create %s"), newroot); goto err; } @@ -336,7 +336,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root) /* ... and mount our root onto it */ if (mount(root->src, newroot, NULL, MS_BIND|MS_REC, NULL) < 0) { virReportSystemError(NULL, errno, - _("failed to bind new root %s into tmpfs"), + _("Failed to bind new root %s into tmpfs"), root->src); goto err; } @@ -345,7 +345,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root) * root->src bind-mounted onto '/new' */ if (chdir(newroot) < 0) { virReportSystemError(NULL, errno, - _("failed to chroot into %s"), newroot); + _("Failed to chroot into %s"), newroot); goto err; } @@ -353,7 +353,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root) * this and will soon be unmounted completely */ if (pivot_root(".", ".oldroot") < 0) { virReportSystemError(NULL, errno, "%s", - _("failed to pivot root")); + _("Failed to pivot root")); goto err; } @@ -396,13 +396,13 @@ static int lxcContainerMountBasicFS(virDomainFSDefPtr root) for (i = 0 ; i < ARRAY_CARDINALITY(mnts) ; i++) { if (virFileMakePath(mnts[i].dst) < 0) { virReportSystemError(NULL, errno, - _("failed to mkdir %s"), + _("Failed to mkdir %s"), mnts[i].src); goto cleanup; } if (mount(mnts[i].src, mnts[i].dst, mnts[i].type, 0, NULL) < 0) { virReportSystemError(NULL, errno, - _("failed to mount %s on %s"), + _("Failed to mount %s on %s"), mnts[i].type, mnts[i].type); goto cleanup; } @@ -410,14 +410,14 @@ static int lxcContainerMountBasicFS(virDomainFSDefPtr root) if ((rc = virFileMakePath("/dev/pts") < 0)) { virReportSystemError(NULL, rc, "%s", - _("cannot create /dev/pts")); + _("Cannot create /dev/pts")); goto cleanup; } VIR_DEBUG("Trying to move %s to %s", devpts, "/dev/pts"); if ((rc = mount(devpts, "/dev/pts", NULL, MS_MOVE, NULL)) < 0) { virReportSystemError(NULL, errno, "%s", - _("failed to mount /dev/pts in container")); + _("Failed to mount /dev/pts in container")); goto cleanup; } @@ -452,7 +452,7 @@ static int lxcContainerPopulateDevices(void) if (mknod(devs[i].path, S_IFCHR, dev) < 0 || chmod(devs[i].path, devs[i].mode)) { virReportSystemError(NULL, errno, - _("failed to make device %s"), + _("Failed to make device %s"), devs[i].path); return -1; } @@ -461,7 +461,7 @@ static int lxcContainerPopulateDevices(void) if (access("/dev/pts/ptmx", W_OK) == 0) { if (symlink("/dev/pts/ptmx", "/dev/ptmx") < 0) { virReportSystemError(NULL, errno, "%s", - _("failed to create symlink /dev/ptmx to /dev/pts/ptmx")); + _("Failed to create symlink /dev/ptmx to /dev/pts/ptmx")); return -1; } } else { @@ -469,7 +469,7 @@ static int lxcContainerPopulateDevices(void) if (mknod("/dev/ptmx", S_IFCHR, dev) < 0 || chmod("/dev/ptmx", 0666)) { virReportSystemError(NULL, errno, "%s", - _("failed to make device /dev/ptmx")); + _("Failed to make device /dev/ptmx")); return -1; } } @@ -499,17 +499,16 @@ static int lxcContainerMountNewFS(virDomainDefPtr vmDef) if (virFileMakePath(vmDef->fss[i]->dst) < 0) { virReportSystemError(NULL, errno, - _("failed to create %s"), + _("Failed to create %s"), vmDef->fss[i]->dst); VIR_FREE(src); return -1; } if (mount(src, vmDef->fss[i]->dst, NULL, MS_BIND, NULL) < 0) { - VIR_FREE(src); virReportSystemError(NULL, errno, - _("failed to mount %s at %s"), - vmDef->fss[i]->src, - vmDef->fss[i]->dst); + _("Failed to mount %s at %s"), + src, vmDef->fss[i]->dst); + VIR_FREE(src); return -1; } VIR_FREE(src); @@ -530,7 +529,7 @@ static int lxcContainerUnmountOldFS(void) if (!(procmnt = setmntent("/proc/mounts", "r"))) { virReportSystemError(NULL, errno, "%s", - _("failed to read /proc/mounts")); + _("Failed to read /proc/mounts")); return -1; } while (getmntent_r(procmnt, &mntent, mntbuf, sizeof(mntbuf)) != NULL) { @@ -559,7 +558,7 @@ static int lxcContainerUnmountOldFS(void) VIR_DEBUG("Umount %s", mounts[i]); if (umount(mounts[i]) < 0) { virReportSystemError(NULL, errno, - _("failed to unmount '%s'"), + _("Failed to unmount '%s'"), mounts[i]); return -1; } @@ -609,7 +608,7 @@ static int lxcContainerSetupExtraMounts(virDomainDefPtr vmDef) if (mount("", "/", NULL, MS_SLAVE|MS_REC, NULL) < 0) { virReportSystemError(NULL, errno, "%s", - _("failed to make / slave")); + _("Failed to make / slave")); return -1; } for (i = 0 ; i < vmDef->nfss ; i++) { @@ -623,7 +622,7 @@ static int lxcContainerSetupExtraMounts(virDomainDefPtr vmDef) MS_BIND, NULL) < 0) { virReportSystemError(NULL, errno, - _("failed to mount %s at %s"), + _("Failed to mount %s at %s"), vmDef->fss[i]->src, vmDef->fss[i]->dst); return -1; @@ -633,7 +632,7 @@ static int lxcContainerSetupExtraMounts(virDomainDefPtr vmDef) /* mount /proc */ if (mount("lxcproc", "/proc", "proc", 0, NULL) < 0) { virReportSystemError(NULL, errno, "%s", - _("failed to mount /proc")); + _("Failed to mount /proc")); return -1; } @@ -672,20 +671,20 @@ static int lxcContainerDropCapabilities(void) CAP_MAC_ADMIN, /* No messing with LSM config */ -1 /* sentinal */)) < 0) { lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("failed to remove capabilities %d"), ret); + _("Failed to remove capabilities: %d"), ret); return -1; } if ((ret = capng_apply(CAPNG_SELECT_BOTH)) < 0) { lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("failed to apply capabilities: %d"), ret); + _("Failed to apply capabilities: %d"), ret); return -1; } /* Need to prevent them regaining any caps on exec */ if ((ret = capng_lock()) < 0) { lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("failed to lock capabilities: %d"), ret); + _("Failed to lock capabilities: %d"), ret); return -1; } @@ -739,7 +738,7 @@ static int lxcContainerChild( void *data ) ttyfd = open(ttyPath, O_RDWR|O_NOCTTY); if (ttyfd < 0) { virReportSystemError(NULL, errno, - _("failed to open tty %s"), + _("Failed to open tty %s"), ttyPath); return -1; } @@ -820,7 +819,7 @@ int lxcContainerStart(virDomainDefPtr def, if (pid < 0) { virReportSystemError(NULL, errno, "%s", - _("failed to run clone container")); + _("Failed to run clone container")); return -1; } diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index f5e0a5a..0b104a1 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -330,7 +330,7 @@ static int lxcControllerMain(int monitor, epollEvent.data.fd = monitor; if (0 > epoll_ctl(epollFd, EPOLL_CTL_ADD, monitor, &epollEvent)) { virReportSystemError(NULL, errno, "%s", - _("epoll_ctl(contPty) failed")); + _("epoll_ctl(monitor) failed")); goto cleanup; } @@ -338,7 +338,7 @@ static int lxcControllerMain(int monitor, epollEvent.data.fd = client; if (0 > epoll_ctl(epollFd, EPOLL_CTL_ADD, client, &epollEvent)) { virReportSystemError(NULL, errno, "%s", - _("epoll_ctl(contPty) failed")); + _("epoll_ctl(client) failed")); goto cleanup; } @@ -358,13 +358,13 @@ static int lxcControllerMain(int monitor, epollEvent.data.fd = client; if (0 > epoll_ctl(epollFd, EPOLL_CTL_ADD, client, &epollEvent)) { virReportSystemError(NULL, errno, "%s", - _("epoll_ctl(contPty) failed")); + _("epoll_ctl(client) failed")); goto cleanup; } } else if (client != -1 && epollEvent.data.fd == client) { if (0 > epoll_ctl(epollFd, EPOLL_CTL_DEL, client, &epollEvent)) { virReportSystemError(NULL, errno, "%s", - _("epoll_ctl(contPty) failed")); + _("epoll_ctl(client) failed")); goto cleanup; } close(client); @@ -452,7 +452,7 @@ static int lxcControllerMoveInterfaces(unsigned int nveths, for (i = 0 ; i < nveths ; i++) if (moveInterfaceToNetNs(veths[i], container) < 0) { lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("failed to move interface %s to ns %d"), + _("Failed to move interface %s to ns %d"), veths[i], container); return -1; } @@ -477,7 +477,7 @@ static int lxcControllerCleanupInterfaces(unsigned int nveths, for (i = 0 ; i < nveths ; i++) if (vethDelete(veths[i]) < 0) lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("failed to delete veth: %s"), veths[i]); + _("Failed to delete veth: %s"), veths[i]); /* will continue to try to cleanup any other interfaces */ return 0; @@ -540,13 +540,13 @@ lxcControllerRun(virDomainDefPtr def, VIR_DEBUG0("Setting up private /dev/pts"); if (unshare(CLONE_NEWNS) < 0) { virReportSystemError(NULL, errno, "%s", - _("cannot unshare mount namespace")); + _("Cannot unshare mount namespace")); goto cleanup; } if (mount("", "/", NULL, MS_SLAVE|MS_REC, NULL) < 0) { virReportSystemError(NULL, errno, "%s", - _("failed to switch root mount into slave mode")); + _("Failed to switch root mount into slave mode")); goto cleanup; } @@ -558,7 +558,7 @@ lxcControllerRun(virDomainDefPtr def, if (virFileMakePath(devpts) < 0) { virReportSystemError(NULL, errno, - _("failed to make path %s"), + _("Failed to make path %s"), devpts); goto cleanup; } @@ -566,13 +566,13 @@ lxcControllerRun(virDomainDefPtr def, VIR_DEBUG("Mouting 'devpts' on %s", devpts); if (mount("devpts", devpts, "devpts", 0, "newinstance,ptmxmode=0666") < 0) { virReportSystemError(NULL, errno, - _("failed to mount devpts on %s"), + _("Failed to mount devpts on %s"), devpts); goto cleanup; } if (access(devptmx, R_OK) < 0) { - VIR_WARN0("kernel does not support private devpts, using shared devpts"); + VIR_WARN0("Kernel does not support private devpts, using shared devpts"); VIR_FREE(devptmx); } } @@ -584,7 +584,7 @@ lxcControllerRun(virDomainDefPtr def, &containerPtyPath, 0) < 0) { virReportSystemError(NULL, errno, "%s", - _("failed to allocate tty")); + _("Failed to allocate tty")); goto cleanup; } } else { @@ -593,7 +593,7 @@ lxcControllerRun(virDomainDefPtr def, &containerPtyPath, 0) < 0) { virReportSystemError(NULL, errno, "%s", - _("failed to allocate tty")); + _("Failed to allocate tty")); goto cleanup; } } @@ -801,7 +801,7 @@ int main(int argc, char *argv[]) /* Accept initial client which is the libvirtd daemon */ if ((client = accept(monitor, NULL, 0)) < 0) { virReportSystemError(NULL, errno, "%s", - _("Failed connection from LXC driver")); + _("Failed to accept a connection from driver")); goto cleanup; } diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 0dd3a08..9f20d05 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -98,7 +98,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, - _("unexpected LXC URI path '%s', try lxc:///"), + _("Unexpected LXC URI path '%s', try lxc:///"), conn->uri->path); return VIR_DRV_OPEN_ERROR; } @@ -288,7 +288,7 @@ static virDomainPtr lxcDomainDefine(virConnectPtr conn, const char *xml) char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(vm->def->uuid, uuidstr); lxcError(conn, NULL, VIR_ERR_OPERATION_FAILED, - _("domain '%s' is already defined with uuid %s"), + _("Domain '%s' is already defined with uuid %s"), vm->def->name, uuidstr); goto cleanup; } @@ -303,7 +303,7 @@ static virDomainPtr lxcDomainDefine(virConnectPtr conn, const char *xml) char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(vm->def->uuid, uuidstr); lxcError(conn, NULL, VIR_ERR_OPERATION_FAILED, - _("domain '%s' is already defined with uuid %s"), + _("Domain '%s' is already defined with uuid %s"), def->name, uuidstr); goto cleanup; } @@ -360,19 +360,19 @@ static int lxcDomainUndefine(virDomainPtr dom) vm = virDomainFindByUUID(&driver->domains, dom->uuid); if (!vm) { lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN, - "%s", _("no domain with matching uuid")); + "%s", _("No domain with matching uuid")); goto cleanup; } if (virDomainObjIsActive(vm)) { lxcError(dom->conn, dom, VIR_ERR_OPERATION_INVALID, - "%s", _("cannot delete active domain")); + "%s", _("Cannot delete active domain")); goto cleanup; } if (!vm->persistent) { lxcError(dom->conn, dom, VIR_ERR_OPERATION_INVALID, - "%s", _("cannot undefine transient domain")); + "%s", _("Cannot undefine transient domain")); goto cleanup; } @@ -412,7 +412,7 @@ static int lxcDomainGetInfo(virDomainPtr dom, if (!vm) { lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN, - "%s", _("no domain with matching uuid")); + "%s", _("No domain with matching uuid")); goto cleanup; } @@ -424,18 +424,18 @@ static int lxcDomainGetInfo(virDomainPtr dom, } else { if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) { lxcError(dom->conn, dom, VIR_ERR_INTERNAL_ERROR, - _("Unable to get cgroup for %s\n"), vm->def->name); + _("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, - "%s", _("cannot read cputime for domain")); + "%s", _("Cannot read cputime for domain")); goto cleanup; } if (virCgroupGetMemoryUsage(cgroup, &(info->memory)) < 0) { lxcError(dom->conn, dom, VIR_ERR_OPERATION_FAILED, - "%s", _("cannot read memory usage for domain")); + "%s", _("Cannot read memory usage for domain")); goto cleanup; } } @@ -465,7 +465,7 @@ static char *lxcGetOSType(virDomainPtr dom) if (!vm) { lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN, - "%s", _("no domain with matching uuid")); + "%s", _("No domain with matching uuid")); goto cleanup; } @@ -491,7 +491,7 @@ static unsigned long lxcDomainGetMaxMemory(virDomainPtr dom) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -516,13 +516,13 @@ static int lxcDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (newmax < vm->def->memory) { lxcError(dom->conn, dom, VIR_ERR_INVALID_ARG, - "%s", _("cannot set max memory lower than current memory")); + "%s", _("Cannot set max memory lower than current memory")); goto cleanup; } @@ -548,13 +548,13 @@ static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (newmem > vm->def->maxmem) { lxcError(dom->conn, dom, VIR_ERR_INVALID_ARG, - "%s", _("cannot set memory higher than max memory")); + "%s", _("Cannot set memory higher than max memory")); goto cleanup; } @@ -567,7 +567,7 @@ static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem) { if (virCgroupSetMemory(cgroup, newmem) < 0) { lxcError(dom->conn, dom, VIR_ERR_OPERATION_FAILED, - "%s", _("cannot set memory for domain")); + "%s", _("Failed to set memory for domain")); goto cleanup; } } else { @@ -596,7 +596,7 @@ static char *lxcDomainDumpXML(virDomainPtr dom, if (!vm) { lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN, - "%s", _("no domain with matching uuid")); + "%s", _("No domain with matching uuid")); goto cleanup; } @@ -733,7 +733,7 @@ static int lxcSetupInterfaces(virConnectPtr conn, DEBUG("bridge: %s", bridge); if (NULL == bridge) { lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("failed to get bridge for interface")); + "%s", _("Failed to get bridge for interface")); goto error_exit; } @@ -744,7 +744,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, - _("failed to create veth device pair: %d"), rc); + _("Failed to create veth device pair: %d"), rc); goto error_exit; } if (NULL == def->nets[i]->ifname) { @@ -757,7 +757,7 @@ static int lxcSetupInterfaces(virConnectPtr conn, if (NULL == def->nets[i]->ifname) { lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("failed to allocate veth names")); + "%s", _("Failed to allocate veth names")); goto error_exit; } @@ -766,7 +766,7 @@ static int lxcSetupInterfaces(virConnectPtr conn, virFormatMacAddr(def->nets[i]->mac, macaddr); if (0 != (rc = setMacAddr(containerVeth, macaddr))) { virReportSystemError(conn, rc, - _("failed to set %s to %s"), + _("Failed to set %s to %s"), macaddr, containerVeth); goto error_exit; } @@ -774,14 +774,15 @@ static int lxcSetupInterfaces(virConnectPtr conn, if (0 != (rc = brAddInterface(brctl, bridge, parentVeth))) { virReportSystemError(conn, rc, - _("failed to add %s device to %s"), + _("Failed to add %s device to %s"), parentVeth, bridge); goto error_exit; } if (0 != (rc = vethInterfaceUpOrDown(parentVeth, 1))) { - virReportSystemError(conn, rc, "%s", - _("failed to enable parent ns veth device")); + virReportSystemError(conn, rc, + _("Failed to enable %s device"), + parentVeth); goto error_exit; } @@ -811,7 +812,7 @@ static int lxcMonitorClient(virConnectPtr conn, if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) { virReportSystemError(conn, errno, "%s", - _("failed to create client socket")); + _("Failed to create client socket")); goto error; } @@ -825,7 +826,7 @@ static int lxcMonitorClient(virConnectPtr conn, if (connect(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { virReportSystemError(conn, errno, "%s", - _("failed to connect to client socket")); + _("Failed to connect to client socket")); goto error; } @@ -850,14 +851,14 @@ static int lxcVmTerminate(virConnectPtr conn, if (vm->pid <= 0) { lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR, - _("invalid PID %d for container"), vm->pid); + _("Invalid PID %d for container"), vm->pid); return -1; } if (kill(vm->pid, signum) < 0) { if (errno != ESRCH) { virReportSystemError(conn, errno, - _("failed to kill pid %d"), + _("Failed to kill pid %d"), vm->pid); return -1; } @@ -1054,14 +1055,14 @@ static int lxcControllerStart(virConnectPtr conn, while ((rc = waitpid(child, &status, 0) == -1) && errno == EINTR); if (rc == -1) { virReportSystemError(conn, errno, - _("cannot wait for '%s'"), + _("Cannot wait for '%s'"), largv[0]); goto cleanup; } if (!(WIFEXITED(status) && WEXITSTATUS(status) == 0)) { lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR, - _("container '%s' unexpectedly shutdown during startup"), + _("Container '%s' unexpectedly shutdown during startup"), largv[0]); goto cleanup; } @@ -1116,7 +1117,7 @@ static int lxcVmStart(virConnectPtr conn, if ((r = virFileMakePath(driver->logDir)) < 0) { virReportSystemError(conn, r, - _("cannot create log directory '%s'"), + _("Cannot create log directory '%s'"), driver->logDir); return -1; } @@ -1130,7 +1131,7 @@ static int lxcVmStart(virConnectPtr conn, /* open parent tty */ if (virFileOpenTty(&parentTty, &parentTtyPath, 1) < 0) { virReportSystemError(conn, errno, "%s", - _("failed to allocate tty")); + _("Failed to allocate tty")); goto cleanup; } if (vm->def->console && @@ -1151,7 +1152,7 @@ static int lxcVmStart(virConnectPtr conn, if ((logfd = open(logfile, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR|S_IWUSR)) < 0) { virReportSystemError(conn, errno, - _("failed to open '%s'"), + _("Failed to open '%s'"), logfile); goto cleanup; } @@ -1227,7 +1228,7 @@ static int lxcDomainStart(virDomainPtr dom) vm = virDomainFindByName(&driver->domains, dom->name); if (!vm) { lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN, - _("no domain named %s"), dom->name); + _("No domain named %s"), dom->name); goto cleanup; } @@ -1286,7 +1287,7 @@ lxcDomainCreateAndStart(virConnectPtr conn, char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(vm->def->uuid, uuidstr); lxcError(conn, NULL, VIR_ERR_OPERATION_FAILED, - _("domain '%s' is already defined with uuid %s"), + _("Domain '%s' is already defined with uuid %s"), vm->def->name, uuidstr); goto cleanup; } @@ -1294,7 +1295,7 @@ lxcDomainCreateAndStart(virConnectPtr conn, /* UUID & name match, but if VM is already active, refuse it */ if (virDomainObjIsActive(vm)) { lxcError(conn, NULL, VIR_ERR_OPERATION_FAILED, - _("domain is already active as '%s'"), vm->def->name); + _("Domain is already active as '%s'"), vm->def->name); goto cleanup; } virDomainObjUnlock(vm); @@ -1305,7 +1306,7 @@ lxcDomainCreateAndStart(virConnectPtr conn, char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(vm->def->uuid, uuidstr); lxcError(conn, NULL, VIR_ERR_OPERATION_FAILED, - _("domain '%s' is already defined with uuid %s"), + _("Domain '%s' is already defined with uuid %s"), def->name, uuidstr); goto cleanup; } @@ -1366,7 +1367,7 @@ static int lxcDomainShutdown(virDomainPtr dom) vm = virDomainFindByID(&driver->domains, dom->id); if (!vm) { lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN, - _("no domain with id %d"), dom->id); + _("No domain with id %d"), dom->id); goto cleanup; } @@ -1499,7 +1500,7 @@ static int lxcDomainDestroy(virDomainPtr dom) vm = virDomainFindByID(&driver->domains, dom->id); if (!vm) { lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN, - _("no domain with id %d"), dom->id); + _("No domain with id %d"), dom->id); goto cleanup; } @@ -1864,7 +1865,7 @@ static int lxcSetSchedulerParameters(virDomainPtr domain, virSchedParameterPtr param = ¶ms[i]; if (param->type != VIR_DOMAIN_SCHED_FIELD_ULLONG) { lxcError(NULL, domain, VIR_ERR_INVALID_ARG, "%s", - _("invalid type for cpu_shares tunable, expected a 'ullong'")); + _("Invalid type for cpu_shares tunable, expected a 'ullong'")); goto cleanup; } @@ -1952,7 +1953,7 @@ static int lxcDomainGetAutostart(virDomainPtr dom, char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -1979,13 +1980,13 @@ static int lxcDomainSetAutostart(virDomainPtr dom, char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (!vm->persistent) { lxcError(dom->conn, dom, VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot set autostart for transient domain")); + "%s", _("Cannot set autostart for transient domain")); goto cleanup; } @@ -2002,7 +2003,7 @@ static int lxcDomainSetAutostart(virDomainPtr dom, if ((err = virFileMakePath(driver->autostartDir))) { virReportSystemError(dom->conn, err, - _("cannot create autostart directory %s"), + _("Cannot create autostart directory %s"), driver->autostartDir); goto cleanup; } @@ -2141,20 +2142,20 @@ static int lxcDomainSuspend(virDomainPtr dom) char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (!virDomainObjIsActive(vm)) { lxcError(dom->conn, dom, VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + "%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, - "%s", _("suspend operation failed")); + "%s", _("Suspend operation failed")); goto cleanup; } vm->state = VIR_DOMAIN_PAUSED; @@ -2206,20 +2207,20 @@ static int lxcDomainResume(virDomainPtr dom) char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(dom->uuid, uuidstr); lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN, - _("no domain with matching uuid '%s'"), uuidstr); + _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } if (!virDomainObjIsActive(vm)) { lxcError(dom->conn, dom, VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + "%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, - "%s", _("resume operation failed")); + "%s", _("Resume operation failed")); goto cleanup; } vm->state = VIR_DOMAIN_RUNNING; diff --git a/src/lxc/veth.c b/src/lxc/veth.c index 5984950..8617cf7 100644 --- a/src/lxc/veth.c +++ b/src/lxc/veth.c @@ -92,13 +92,13 @@ int vethCreate(char* veth1, int veth1MaxLen, while ((1 > strlen(veth1)) || STREQ(veth1, veth2)) { vethDev = getFreeVethName(veth1, veth1MaxLen, 0); ++vethDev; - DEBUG("assigned veth1: %s", veth1); + DEBUG("Assigned veth1: %s", veth1); } while ((1 > strlen(veth2)) || STREQ(veth1, veth2)) { vethDev = getFreeVethName(veth2, veth2MaxLen, vethDev); ++vethDev; - DEBUG("assigned veth2: %s", veth2); + DEBUG("Assigned veth2: %s", veth2); } DEBUG("veth1: %s veth2: %s", veth1, veth2); -- 1.6.2.5

On Thu, Nov 05, 2009 at 02:19:13AM +0900, Ryota Ozaki wrote:
Most of cleanups are just capitalizing their messages though, some fixes wrong error messages and awkward indentations, and improves error messages. --- src/lxc/lxc_container.c | 59 +++++++++++++------------- src/lxc/lxc_controller.c | 28 ++++++------ src/lxc/lxc_driver.c | 103 +++++++++++++++++++++++----------------------- src/lxc/veth.c | 4 +- 4 files changed, 97 insertions(+), 97 deletions(-)
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--- src/lxc/lxc_driver.c | 61 +++++++++++++++++++++++++++---------------------- 1 files changed, 34 insertions(+), 27 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 9f20d05..a917a46 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1992,39 +1992,46 @@ static int lxcDomainSetAutostart(virDomainPtr dom, autostart = (autostart != 0); - if (vm->autostart != autostart) { - if ((configFile = virDomainConfigFile(dom->conn, driver->configDir, vm->def->name)) == NULL) - goto cleanup; - if ((autostartLink = virDomainConfigFile(dom->conn, driver->autostartDir, vm->def->name)) == NULL) - goto cleanup; + if (vm->autostart == autostart) { + ret = 0; + goto cleanup; + } - if (autostart) { - int err; + configFile = virDomainConfigFile(dom->conn, driver->configDir, + vm->def->name); + if (configFile == NULL) + goto cleanup; + autostartLink = virDomainConfigFile(dom->conn, driver->autostartDir, + vm->def->name); + if (autostartLink == NULL) + goto cleanup; - if ((err = virFileMakePath(driver->autostartDir))) { - virReportSystemError(dom->conn, err, - _("Cannot create autostart directory %s"), - driver->autostartDir); - goto cleanup; - } + if (autostart) { + int err; - if (symlink(configFile, autostartLink) < 0) { - virReportSystemError(dom->conn, errno, - _("Failed to create symlink '%s to '%s'"), - autostartLink, configFile); - goto cleanup; - } - } else { - if (unlink(autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) { - virReportSystemError(dom->conn, errno, - _("Failed to delete symlink '%s'"), - autostartLink); - goto cleanup; - } + if ((err = virFileMakePath(driver->autostartDir))) { + virReportSystemError(dom->conn, err, + _("Cannot create autostart directory %s"), + driver->autostartDir); + goto cleanup; } - vm->autostart = autostart; + if (symlink(configFile, autostartLink) < 0) { + virReportSystemError(dom->conn, errno, + _("Failed to create symlink '%s to '%s'"), + autostartLink, configFile); + goto cleanup; + } + } else { + if (unlink(autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) { + virReportSystemError(dom->conn, errno, + _("Failed to delete symlink '%s'"), + autostartLink); + goto cleanup; + } } + + vm->autostart = autostart; ret = 0; cleanup: -- 1.6.2.5

On Thu, Nov 05, 2009 at 02:19:14AM +0900, Ryota Ozaki wrote:
--- src/lxc/lxc_driver.c | 61 +++++++++++++++++++++++++++---------------------- 1 files changed, 34 insertions(+), 27 deletions(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 9f20d05..a917a46 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1992,39 +1992,46 @@ static int lxcDomainSetAutostart(virDomainPtr dom,
autostart = (autostart != 0);
- if (vm->autostart != autostart) { - if ((configFile = virDomainConfigFile(dom->conn, driver->configDir, vm->def->name)) == NULL) - goto cleanup; - if ((autostartLink = virDomainConfigFile(dom->conn, driver->autostartDir, vm->def->name)) == NULL) - goto cleanup; + if (vm->autostart == autostart) { + ret = 0; + goto cleanup; + }
- if (autostart) { - int err; + configFile = virDomainConfigFile(dom->conn, driver->configDir, + vm->def->name); + if (configFile == NULL) + goto cleanup; + autostartLink = virDomainConfigFile(dom->conn, driver->autostartDir, + vm->def->name); + if (autostartLink == NULL) + goto cleanup;
- if ((err = virFileMakePath(driver->autostartDir))) { - virReportSystemError(dom->conn, err, - _("Cannot create autostart directory %s"), - driver->autostartDir); - goto cleanup; - } + if (autostart) { + int err;
- if (symlink(configFile, autostartLink) < 0) { - virReportSystemError(dom->conn, errno, - _("Failed to create symlink '%s to '%s'"), - autostartLink, configFile); - goto cleanup; - } - } else { - if (unlink(autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) { - virReportSystemError(dom->conn, errno, - _("Failed to delete symlink '%s'"), - autostartLink); - goto cleanup; - } + if ((err = virFileMakePath(driver->autostartDir))) { + virReportSystemError(dom->conn, err, + _("Cannot create autostart directory %s"), + driver->autostartDir); + goto cleanup; }
- vm->autostart = autostart; + if (symlink(configFile, autostartLink) < 0) { + virReportSystemError(dom->conn, errno, + _("Failed to create symlink '%s to '%s'"), + autostartLink, configFile); + goto cleanup; + } + } else { + if (unlink(autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) { + virReportSystemError(dom->conn, errno, + _("Failed to delete symlink '%s'"), + autostartLink); + goto cleanup; + } } + + vm->autostart = autostart; ret = 0;
cleanup:
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Thu, Nov 05, 2009 at 02:19:11AM +0900, Ryota Ozaki wrote:
This patch series fix and cleanup over whole lxc codes. I want to clean up before adding more in them.
A lot of cleanups indeed ! Applied and pushed to git head :-) thanks ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (3)
-
Daniel P. Berrange
-
Daniel Veillard
-
Ryota Ozaki