It was used for error reporting only. --- daemon/libvirtd.c | 2 +- daemon/remote.c | 2 +- ...-Step-7-of-8-Implement-the-driver-methods.patch | 4 +- src/lxc/lxc_driver.c | 4 +- src/lxc/veth.c | 12 +- src/network/bridge_driver.c | 4 +- src/node_device/node_device_driver.c | 2 +- src/openvz/openvz_conf.c | 2 +- src/openvz/openvz_driver.c | 24 ++-- src/phyp/phyp_driver.c | 2 +- src/qemu/qemu_conf.c | 10 +- src/qemu/qemu_driver.c | 6 +- src/remote/remote_driver.c | 6 +- src/secret/secret_driver.c | 2 +- src/security/security_apparmor.c | 8 +- src/security/virt-aa-helper.c | 2 +- src/storage/storage_backend.c | 15 ++-- src/storage/storage_backend_disk.c | 12 +- src/storage/storage_backend_fs.c | 4 +- src/storage/storage_backend_iscsi.c | 20 ++-- src/storage/storage_backend_logical.c | 35 +++--- src/storage/storage_backend_mpath.c | 2 +- src/storage/storage_backend_scsi.c | 7 +- src/storage/storage_backend_scsi.h | 3 +- src/storage/storage_driver.c | 2 +- src/uml/uml_driver.c | 4 +- src/util/bridge.c | 4 +- src/util/cgroup.c | 2 +- src/util/ebtables.c | 2 +- src/util/iptables.c | 2 +- src/util/pci.c | 10 +- src/util/util.c | 111 ++++++++----------- src/util/util.h | 27 ++--- src/xen/proxy_internal.c | 2 +- tools/virsh.c | 4 +- 35 files changed, 166 insertions(+), 194 deletions(-) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index 1c7e791..fefa7aa 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -755,7 +755,7 @@ static int qemudInitPaths(struct qemud_server *server, goto snprintf_error; } else { uid_t uid = geteuid(); - dir_prefix = virGetUserDirectory(NULL, uid); + dir_prefix = virGetUserDirectory(uid); if (dir_prefix == NULL) { /* Do not diagnose here; virGetUserDirectory does that. */ goto snprintf_error; diff --git a/daemon/remote.c b/daemon/remote.c index 09a51b7..07c4c5f 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -3370,7 +3370,7 @@ remoteDispatchAuthPolkit (struct qemud_server *server, goto authfail; } - if (virRun(NULL, pkcheck, &status) < 0) { + if (virRun(pkcheck, &status) < 0) { VIR_ERROR(_("Cannot invoke %s"), PKCHECK_PATH); goto authfail; } diff --git a/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch b/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch index 09ddc65..807ed78 100644 --- a/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch +++ b/docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch @@ -478,7 +478,7 @@ index b84729f..4f73baf 100644 + * If this fails for any reason, we still have the backup of polling for + * 5 seconds for device nodes. + */ -+ virRun(conn, settleprog, &exitstatus); ++ virRun(settleprog, &exitstatus); +} +#else +void virNodeDeviceWaitForDevices(virConnectPtr conn ATTRIBUTE_UNUSED) {} @@ -1131,7 +1131,7 @@ index b154140..74759cf 100644 - * If this fails for any reason, we still have the backup of polling for - * 5 seconds for device nodes. - */ -- virRun(conn, settleprog, &exitstatus); +- virRun(settleprog, &exitstatus); + virNodeDeviceWaitForDevices(conn); + return; } diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index a4143f5..80a4935 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1120,7 +1120,7 @@ static int lxcControllerStart(virConnectPtr conn, FD_SET(appPty, &keepfd); - if (virExec(conn, largv, lenv, &keepfd, &child, + if (virExec(largv, lenv, &keepfd, &child, -1, &logfd, &logfd, VIR_EXEC_NONE) < 0) goto cleanup; @@ -1575,7 +1575,7 @@ static int lxcCheckNetNsSupport(void) const char *argv[] = {"ip", "link", "set", "lo", "netns", "-1", NULL}; int ip_rc; - if (virRun(NULL, argv, &ip_rc) < 0 || + if (virRun(argv, &ip_rc) < 0 || !(WIFEXITED(ip_rc) && (WEXITSTATUS(ip_rc) != 255))) return 0; diff --git a/src/lxc/veth.c b/src/lxc/veth.c index ede85ce..34f7faa 100644 --- a/src/lxc/veth.c +++ b/src/lxc/veth.c @@ -102,7 +102,7 @@ int vethCreate(char* veth1, int veth1MaxLen, } DEBUG("veth1: %s veth2: %s", veth1, veth2); - rc = virRun(NULL, argv, &cmdResult); + rc = virRun(argv, &cmdResult); if (0 == rc) { rc = cmdResult; @@ -135,7 +135,7 @@ int vethDelete(const char *veth) DEBUG("veth: %s", veth); - rc = virRun(NULL, argv, &cmdResult); + rc = virRun(argv, &cmdResult); if (0 == rc) { rc = cmdResult; @@ -170,7 +170,7 @@ int vethInterfaceUpOrDown(const char* veth, int upOrDown) else argv[2] = "up"; - rc = virRun(NULL, argv, &cmdResult); + rc = virRun(argv, &cmdResult); if (0 == rc) { rc = cmdResult; @@ -208,7 +208,7 @@ int moveInterfaceToNetNs(const char* iface, int pidInNs) goto error_out; argv[5] = pid; - rc = virRun(NULL, argv, &cmdResult); + rc = virRun(argv, &cmdResult); if (0 == rc) rc = cmdResult; @@ -240,7 +240,7 @@ int setMacAddr(const char* iface, const char* macaddr) goto error_out; } - rc = virRun(NULL, argv, &cmdResult); + rc = virRun(argv, &cmdResult); if (0 == rc) rc = cmdResult; @@ -271,7 +271,7 @@ int setInterfaceName(const char* iface, const char* new) goto error_out; } - rc = virRun(NULL, argv, &cmdResult); + rc = virRun(argv, &cmdResult); if (0 == rc) rc = cmdResult; diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 63cd53e..a3c6b9c 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -211,7 +211,7 @@ networkStartup(int privileged) { if ((base = strdup (SYSCONF_DIR "/libvirt")) == NULL) goto out_of_memory; } else { - char *userdir = virGetUserDirectory(NULL, uid); + char *userdir = virGetUserDirectory(uid); if (!userdir) goto error; @@ -562,7 +562,7 @@ dhcpStartDhcpDaemon(virConnectPtr conn, return -1; } - if (virRun(conn, argv, NULL) < 0) + if (virRun(argv, NULL) < 0) goto cleanup; /* diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index fd96874..ad5503b 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -510,7 +510,7 @@ find_new_device(virConnectPtr conn, const char *wwnn, const char *wwpn) while ((now - start) < LINUX_NEW_DEVICE_WAIT_TIME) { - virFileWaitForDevices(conn); + virFileWaitForDevices(); dev = nodeDeviceLookupByWWN(conn, wwnn, wwpn); diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 6baaea2..f4b8199 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -84,7 +84,7 @@ openvzExtractVersionInfo(const char *cmd, int *retversion) if (retversion) *retversion = 0; - if (virExec(NULL, vzarg, vzenv, NULL, + if (virExec(vzarg, vzenv, NULL, &child, -1, &newstdout, NULL, VIR_EXEC_NONE) < 0) return -1; diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 49a7bd2..8535f18 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -256,7 +256,7 @@ static int openvzSetInitialConfig(virConnectPtr conn, goto cleanup; } - if (virRun(conn, prog, NULL) < 0) { + if (virRun(prog, NULL) < 0) { openvzError(conn, VIR_ERR_INTERNAL_ERROR, _("Could not exec %s"), VZCTL); goto cleanup; @@ -530,7 +530,7 @@ static int openvzDomainShutdown(virDomainPtr dom) { goto cleanup; } - if (virRun(dom->conn, prog, NULL) < 0) + if (virRun(prog, NULL) < 0) goto cleanup; vm->def->id = -1; @@ -567,7 +567,7 @@ static int openvzDomainReboot(virDomainPtr dom, goto cleanup; } - if (virRun(dom->conn, prog, NULL) < 0) + if (virRun(prog, NULL) < 0) goto cleanup; ret = 0; @@ -727,7 +727,7 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid, if (prog[0] != NULL){ ADD_ARG_LIT("--save"); - if (virRun(conn, prog, NULL) < 0) { + if (virRun(prog, NULL) < 0) { openvzError(conn, VIR_ERR_INTERNAL_ERROR, _("Could not exec %s"), VZCTL); rc = -1; @@ -929,7 +929,7 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml, openvzSetProgramSentinal(progstart, vm->def->name); - if (virRun(conn, progstart, NULL) < 0) { + if (virRun(progstart, NULL) < 0) { openvzError(conn, VIR_ERR_INTERNAL_ERROR, _("Could not exec %s"), VZCTL); goto cleanup; @@ -984,7 +984,7 @@ openvzDomainCreate(virDomainPtr dom) } openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(dom->conn, prog, NULL) < 0) { + if (virRun(prog, NULL) < 0) { openvzError(dom->conn, VIR_ERR_INTERNAL_ERROR, _("Could not exec %s"), VZCTL); goto cleanup; @@ -1022,7 +1022,7 @@ openvzDomainUndefine(virDomainPtr dom) } openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(dom->conn, prog, NULL) < 0) { + if (virRun(prog, NULL) < 0) { openvzError(dom->conn, VIR_ERR_INTERNAL_ERROR, _("Could not exec %s"), VZCTL); goto cleanup; @@ -1059,7 +1059,7 @@ openvzDomainSetAutostart(virDomainPtr dom, int autostart) } openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(dom->conn, prog, NULL) < 0) { + if (virRun(prog, NULL) < 0) { openvzError(dom->conn, VIR_ERR_INTERNAL_ERROR, _("Could not exec %s"), VZCTL); goto cleanup; } @@ -1136,7 +1136,7 @@ static int openvzDomainSetVcpusInternal(virConnectPtr conn, virDomainObjPtr vm, str_vcpus[31] = '\0'; openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(conn, prog, NULL) < 0) { + if (virRun(prog, NULL) < 0) { openvzError(conn, VIR_ERR_INTERNAL_ERROR, _("Could not exec %s"), VZCTL); return -1; @@ -1301,7 +1301,7 @@ static int openvzListDomains(virConnectPtr conn, int *ids, int nids) { char *endptr; const char *cmd[] = {VZLIST, "-ovpsid", "-H" , NULL}; - ret = virExec(conn, cmd, NULL, NULL, + ret = virExec(cmd, NULL, NULL, &pid, -1, &outfd, &errfd, VIR_EXEC_NONE); if(ret == -1) { openvzError(conn, VIR_ERR_INTERNAL_ERROR, @@ -1347,7 +1347,7 @@ static int openvzListDefinedDomains(virConnectPtr conn, const char *cmd[] = {VZLIST, "-ovpsid", "-H", "-S", NULL}; /* the -S options lists only stopped domains */ - ret = virExec(conn, cmd, NULL, NULL, + ret = virExec(cmd, NULL, NULL, &pid, -1, &outfd, &errfd, VIR_EXEC_NONE); if(ret == -1) { openvzError(conn, VIR_ERR_INTERNAL_ERROR, @@ -1447,7 +1447,7 @@ openvzDomainSetMemoryInternal(virConnectPtr conn, virDomainObjPtr vm, snprintf(str_mem, sizeof(str_mem), "%lu", mem * 1024); openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(conn, prog, NULL) < 0) { + if (virRun(prog, NULL) < 0) { openvzError(conn, VIR_ERR_INTERNAL_ERROR, _("Could not exec %s"), VZCTL); goto cleanup; diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 80ed4b9..f5de9b0 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -253,7 +253,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth, int ret; char *pubkey = NULL; char *pvtkey = NULL; - char *userhome = virGetUserDirectory(NULL, geteuid()); + char *userhome = virGetUserDirectory(geteuid()); struct stat pvt_stat, pub_stat; if (userhome == NULL) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 3d16ed9..257b4a4 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -217,7 +217,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, virConfFree(conf); return -1; } - if (virGetUserID(NULL, user, &driver->user) < 0) { + if (virGetUserID(user, &driver->user) < 0) { VIR_FREE(user); virConfFree(conf); return -1; @@ -232,7 +232,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, virConfFree(conf); return -1; } - if (virGetGroupID(NULL, group, &driver->group) < 0) { + if (virGetGroupID(group, &driver->group) < 0) { VIR_FREE(group); virConfFree(conf); return -1; @@ -485,7 +485,7 @@ qemudProbeMachineTypes(const char *binary, int newstdout = -1, len; int ret = -1, status; - if (virExec(NULL, qemuarg, qemuenv, NULL, + if (virExec(qemuarg, qemuenv, NULL, &child, -1, &newstdout, NULL, VIR_EXEC_CLEAR_CAPS) < 0) return -1; @@ -719,7 +719,7 @@ qemudProbeCPUModels(const char *qemu, return 0; } - if (virExec(NULL, qemuarg, qemuenv, NULL, + if (virExec(qemuarg, qemuenv, NULL, &child, -1, &newstdout, NULL, VIR_EXEC_CLEAR_CAPS) < 0) return -1; @@ -1330,7 +1330,7 @@ int qemudExtractVersionInfo(const char *qemu, if (retversion) *retversion = 0; - if (virExec(NULL, qemuarg, qemuenv, NULL, + if (virExec(qemuarg, qemuenv, NULL, &child, -1, &newstdout, NULL, VIR_EXEC_CLEAR_CAPS) < 0) return -1; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 149fad3..8d121a7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1033,7 +1033,7 @@ qemudStartup(int privileged) { goto out_of_memory; } else { uid_t uid = geteuid(); - char *userdir = virGetUserDirectory(NULL, uid); + char *userdir = virGetUserDirectory(uid); if (!userdir) goto error; @@ -2691,7 +2691,7 @@ static int qemudStartVMDaemon(virConnectPtr conn, for (i = 0 ; i < ntapfds ; i++) FD_SET(tapfds[i], &keepfd); - ret = virExecDaemonize(conn, argv, progenv, &keepfd, &child, + ret = virExecDaemonize(argv, progenv, &keepfd, &child, stdin_fd, &logfile, &logfile, VIR_EXEC_NONBLOCK | VIR_EXEC_CLEAR_CAPS, qemudSecurityHook, &hookData, @@ -4556,7 +4556,7 @@ static int qemudDomainRestore(virConnectPtr conn, intermediate_argv[0] = prog; intermediatefd = fd; fd = -1; - if (virExec(conn, intermediate_argv, NULL, NULL, + if (virExec(intermediate_argv, NULL, NULL, &intermediate_pid, intermediatefd, &fd, NULL, 0) < 0) { qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, _("Failed to start decompression binary %s"), diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index c5ed859..17f1fcc 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -330,7 +330,7 @@ remoteForkDaemon(virConnectPtr conn) return -1; } - if (virExecDaemonize(NULL, daemonargs, NULL, NULL, + if (virExecDaemonize(daemonargs, NULL, NULL, &pid, -1, NULL, NULL, VIR_EXEC_CLEAR_CAPS, NULL, NULL, NULL) < 0) @@ -656,7 +656,7 @@ doRemoteOpen (virConnectPtr conn, case trans_unix: { if (!sockname) { if (flags & VIR_DRV_OPEN_REMOTE_USER) { - char *userdir = virGetUserDirectory(conn, getuid()); + char *userdir = virGetUserDirectory(getuid()); if (!userdir) goto failed; @@ -793,7 +793,7 @@ doRemoteOpen (virConnectPtr conn, goto failed; } - if (virExec(conn, (const char**)cmd_argv, NULL, NULL, + if (virExec((const char**)cmd_argv, NULL, NULL, &pid, sv[1], &(sv[1]), NULL, VIR_EXEC_CLEAR_CAPS) < 0) goto failed; diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index f4c8aef..85c7e7c 100644 --- a/src/secret/secret_driver.c +++ b/src/secret/secret_driver.c @@ -1003,7 +1003,7 @@ secretDriverStartup(int privileged) goto out_of_memory; } else { uid_t uid = geteuid(); - char *userdir = virGetUserDirectory(NULL, uid); + char *userdir = virGetUserDirectory(uid); if (!userdir) goto error; diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c index b67df3f..2d5f944 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -173,19 +173,19 @@ load_profile(virConnectPtr conn, const char *profile, virDomainObjPtr vm, const char *const argv[] = { VIRT_AA_HELPER, "-c", "-u", profile, NULL }; - ret = virExec(conn, argv, NULL, NULL, &child, + ret = virExec(argv, NULL, NULL, &child, pipefd[0], NULL, NULL, VIR_EXEC_CLEAR_CAPS); } else if (disk && disk->src) { const char *const argv[] = { VIRT_AA_HELPER, "-r", "-u", profile, "-f", disk->src, NULL }; - ret = virExec(conn, argv, NULL, NULL, &child, + ret = virExec(argv, NULL, NULL, &child, pipefd[0], NULL, NULL, VIR_EXEC_CLEAR_CAPS); } else { const char *const argv[] = { VIRT_AA_HELPER, "-r", "-u", profile, NULL }; - ret = virExec(conn, argv, NULL, NULL, &child, + ret = virExec(argv, NULL, NULL, &child, pipefd[0], NULL, NULL, VIR_EXEC_CLEAR_CAPS); } if (ret < 0) @@ -230,7 +230,7 @@ remove_profile(const char *profile) VIRT_AA_HELPER, "-R", "-u", profile, NULL }; - if (virRun(NULL, argv, NULL) == 0) + if (virRun(argv, NULL) == 0) rc = 0; return rc; diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 3e7481d..81ba1ae 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -203,7 +203,7 @@ parserCommand(const char *profile_name, const char cmd) const char * const argv[] = { "/sbin/apparmor_parser", flag, profile, NULL }; - if (virRun(NULL, argv, NULL) != 0) { + if (virRun(argv, NULL) != 0) { vah_error(NULL, 0, "failed to run apparmor_parser"); return -1; } diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index 2e78168..8d85de8 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -509,8 +509,7 @@ static int virStorageBuildSetUIDHook(void *data) { return 0; } -static int virStorageBackendCreateExecCommand(virConnectPtr conn, - virStoragePoolObjPtr pool, +static int virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, const char **cmdargv) { struct stat st; @@ -521,7 +520,7 @@ static int virStorageBackendCreateExecCommand(virConnectPtr conn, if ((pool->def->type == VIR_STORAGE_POOL_NETFS) && (getuid() == 0) && ((vol->target.perms.uid != 0) || (vol->target.perms.gid != 0))) { - if (virRunWithHook(conn, cmdargv, + if (virRunWithHook(cmdargv, virStorageBuildSetUIDHook, vol, NULL) == 0) { /* command was successfully run, check if the file was created */ if (stat(vol->target.path, &st) >=0) @@ -529,7 +528,7 @@ static int virStorageBackendCreateExecCommand(virConnectPtr conn, } } if (!filecreated) { - if (virRun(conn, cmdargv, NULL) < 0) { + if (virRun(cmdargv, NULL) < 0) { virReportSystemError(errno, _("Cannot run %s to create %s"), cmdargv[0], vol->target.path); @@ -727,7 +726,7 @@ virStorageBackendCreateQemuImg(virConnectPtr conn, /* Size in KB */ snprintf(size, sizeof(size), "%lluK", vol->capacity/1024); - ret = virStorageBackendCreateExecCommand(conn, pool, vol, imgargv); + ret = virStorageBackendCreateExecCommand(pool, vol, imgargv); VIR_FREE(imgargv[0]); return ret; @@ -781,7 +780,7 @@ virStorageBackendCreateQcowCreate(virConnectPtr conn, imgargv[2] = vol->target.path; imgargv[3] = NULL; - ret = virStorageBackendCreateExecCommand(conn, pool, vol, imgargv); + ret = virStorageBackendCreateExecCommand(pool, vol, imgargv); VIR_FREE(imgargv[0]); return ret; @@ -1250,7 +1249,7 @@ virStorageBackendRunProgRegex(virConnectPtr conn, /* Run the program and capture its output */ - if (virExec(conn, prog, NULL, NULL, + if (virExec(prog, NULL, NULL, &child, -1, &fd, NULL, VIR_EXEC_NONE) < 0) { goto cleanup; } @@ -1386,7 +1385,7 @@ virStorageBackendRunProgNul(virConnectPtr conn, v[i] = NULL; /* Run the program and capture its output */ - if (virExec(conn, prog, NULL, NULL, + if (virExec(prog, NULL, NULL, &child, -1, &fd, NULL, VIR_EXEC_NONE) < 0) { goto cleanup; } diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c index a86c193..2082841 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -323,7 +323,7 @@ virStorageBackendDiskRefreshPool(virConnectPtr conn, VIR_FREE(pool->def->source.devices[0].freeExtents); pool->def->source.devices[0].nfreeExtent = 0; - virFileWaitForDevices(conn); + virFileWaitForDevices(); if (virStorageBackendDiskReadGeometry(conn, pool) != 0) { return -1; @@ -337,7 +337,7 @@ virStorageBackendDiskRefreshPool(virConnectPtr conn, * Write a new partition table header */ static int -virStorageBackendDiskBuildPool(virConnectPtr conn, +virStorageBackendDiskBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool, unsigned int flags ATTRIBUTE_UNUSED) { @@ -352,7 +352,7 @@ virStorageBackendDiskBuildPool(virConnectPtr conn, NULL, }; - if (virRun(conn, prog, NULL) < 0) + if (virRun(prog, NULL) < 0) return -1; return 0; @@ -577,11 +577,11 @@ virStorageBackendDiskCreateVol(virConnectPtr conn, snprintf(end, sizeof(end)-1, "%lluB", endOffset); end[sizeof(end)-1] = '\0'; - if (virRun(conn, cmdargv, NULL) < 0) + if (virRun(cmdargv, NULL) < 0) return -1; /* wait for device node to show up */ - virFileWaitForDevices(conn); + virFileWaitForDevices(); /* Blow away free extent info, as we're about to re-populate it */ VIR_FREE(pool->def->source.devices[0].freeExtents); @@ -662,7 +662,7 @@ virStorageBackendDiskDeleteVol(virConnectPtr conn, NULL, }; - if (virRun(conn, prog, NULL) < 0) + if (virRun(prog, NULL) < 0) goto cleanup; rc = 0; diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c index f1e1371..dcc5bf9 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -403,7 +403,7 @@ virStorageBackendFileSystemMount(virConnectPtr conn, mntargv[option_index] = options; } - if (virRun(conn, mntargv, NULL) < 0) { + if (virRun(mntargv, NULL) < 0) { VIR_FREE(src); return -1; } @@ -457,7 +457,7 @@ virStorageBackendFileSystemUnmount(virConnectPtr conn, mntargv[1] = pool->def->target.path; mntargv[2] = NULL; - if (virRun(conn, mntargv, NULL) < 0) { + if (virRun(mntargv, NULL) < 0) { return -1; } return 0; diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c index 8a93edc..4e2a75e 100644 --- a/src/storage/storage_backend_iscsi.c +++ b/src/storage/storage_backend_iscsi.c @@ -182,7 +182,7 @@ virStorageBackendIQNFound(virConnectPtr conn, memset(line, 0, LINE_SIZE); - if (virExec(conn, prog, NULL, NULL, &child, -1, &fd, NULL, VIR_EXEC_NONE) < 0) { + if (virExec(prog, NULL, NULL, &child, -1, &fd, NULL, VIR_EXEC_NONE) < 0) { virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, _("Failed to run '%s' when looking for existing interface with IQN '%s'"), prog[0], pool->def->source.initiator.iqn); @@ -279,7 +279,7 @@ virStorageBackendCreateIfaceIQN(virConnectPtr conn, * tools returned an exit status of > 0, even if they succeeded. * We will just rely on whether the interface got created * properly. */ - if (virRun(conn, cmdargv1, &exitstatus) < 0) { + if (virRun(cmdargv1, &exitstatus) < 0) { virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, _("Failed to run command '%s' to create new iscsi interface"), cmdargv1[0]); @@ -295,7 +295,7 @@ virStorageBackendCreateIfaceIQN(virConnectPtr conn, /* Note that we ignore the exitstatus. Older versions of iscsiadm tools * returned an exit status of > 0, even if they succeeded. We will just * rely on whether iface file got updated properly. */ - if (virRun(conn, cmdargv2, &exitstatus) < 0) { + if (virRun(cmdargv2, &exitstatus) < 0) { virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, _("Failed to run command '%s' to update iscsi interface with IQN '%s'"), cmdargv1[0], pool->def->source.initiator.iqn); @@ -348,7 +348,7 @@ virStorageBackendISCSIConnectionIQN(virConnectPtr conn, const char *const sendtargets[] = { ISCSIADM, "--mode", "discovery", "--type", "sendtargets", "--portal", portal, NULL }; - if (virRun(conn, sendtargets, NULL) < 0) { + if (virRun(sendtargets, NULL) < 0) { virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, _("Failed to run %s to get target list"), sendtargets[0]); @@ -361,7 +361,7 @@ virStorageBackendISCSIConnectionIQN(virConnectPtr conn, ifacename, action, NULL }; - if (virRun(conn, cmdargv, NULL) < 0) { + if (virRun(cmdargv, NULL) < 0) { virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, _("Failed to run command '%s' with action '%s'"), cmdargv[0], action); @@ -395,7 +395,7 @@ virStorageBackendISCSIConnection(virConnectPtr conn, "--targetname", pool->def->source.devices[0].path, action, NULL }; - if (virRun(conn, cmdargv, NULL) < 0) { + if (virRun(cmdargv, NULL) < 0) { ret = -1; } @@ -417,7 +417,7 @@ virStorageBackendISCSIFindLUs(virConnectPtr conn, snprintf(sysfs_path, PATH_MAX, "/sys/class/iscsi_session/session%s/device", session); - if (virStorageBackendSCSIGetHostNumber(conn, sysfs_path, &host) < 0) { + if (virStorageBackendSCSIGetHostNumber(sysfs_path, &host) < 0) { virReportSystemError(errno, _("Failed to get host number for iSCSI session " "with path '%s'"), @@ -435,7 +435,7 @@ virStorageBackendISCSIFindLUs(virConnectPtr conn, } static int -virStorageBackendISCSIRescanLUNs(virConnectPtr conn, +virStorageBackendISCSIRescanLUNs(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, const char *session) { @@ -443,7 +443,7 @@ virStorageBackendISCSIRescanLUNs(virConnectPtr conn, ISCSIADM, "--mode", "session", "-r", session, "-R", NULL, }; - if (virRun(conn, cmdargv, NULL) < 0) + if (virRun(cmdargv, NULL) < 0) return -1; return 0; @@ -460,7 +460,7 @@ virStorageBackendISCSILogin(virConnectPtr conn, "--portal", portal, NULL }; - if (virRun(conn, cmdsendtarget, NULL) < 0) + if (virRun(cmdsendtarget, NULL) < 0) return -1; return virStorageBackendISCSIConnection(conn, pool, portal, "--login"); diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c index 06ae865..35bedc0 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -44,8 +44,7 @@ static int -virStorageBackendLogicalSetActive(virConnectPtr conn, - virStoragePoolObjPtr pool, +virStorageBackendLogicalSetActive(virStoragePoolObjPtr pool, int on) { const char *cmdargv[4]; @@ -55,7 +54,7 @@ virStorageBackendLogicalSetActive(virConnectPtr conn, cmdargv[2] = pool->def->source.name; cmdargv[3] = NULL; - if (virRun(conn, cmdargv, NULL) < 0) + if (virRun(cmdargv, NULL) < 0) return -1; return 0; @@ -337,7 +336,7 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr conn, * that might be hanging around, so if this fails for some reason, the * worst that happens is that scanning doesn't pick everything up */ - if (virRun(conn, scanprog, &exitstatus) < 0) { + if (virRun(scanprog, &exitstatus) < 0) { VIR_WARN0("Failure when running vgscan to refresh physical volumes"); } @@ -367,10 +366,10 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr conn, static int -virStorageBackendLogicalStartPool(virConnectPtr conn, +virStorageBackendLogicalStartPool(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool) { - if (virStorageBackendLogicalSetActive(conn, pool, 1) < 0) + if (virStorageBackendLogicalSetActive(pool, 1) < 0) return -1; return 0; @@ -378,7 +377,7 @@ virStorageBackendLogicalStartPool(virConnectPtr conn, static int -virStorageBackendLogicalBuildPool(virConnectPtr conn, +virStorageBackendLogicalBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool, unsigned int flags ATTRIBUTE_UNUSED) { @@ -431,14 +430,14 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn, */ vgargv[n++] = pool->def->source.devices[i].path; pvargv[1] = pool->def->source.devices[i].path; - if (virRun(conn, pvargv, NULL) < 0) + if (virRun(pvargv, NULL) < 0) goto cleanup; } vgargv[n] = NULL; /* Now create the volume group itself */ - if (virRun(conn, vgargv, NULL) < 0) + if (virRun(vgargv, NULL) < 0) goto cleanup; VIR_FREE(vgargv); @@ -476,7 +475,7 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn, }; int exitstatus; - virFileWaitForDevices(conn); + virFileWaitForDevices(); /* Get list of all logical volumes */ if (virStorageBackendLogicalFindLVs(conn, pool, NULL) < 0) { @@ -512,17 +511,17 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn, * "Can't deactivate volume group "VolGroup00" with 3 open logical volume(s)" */ static int -virStorageBackendLogicalStopPool(virConnectPtr conn, +virStorageBackendLogicalStopPool(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool) { - if (virStorageBackendLogicalSetActive(conn, pool, 0) < 0) + if (virStorageBackendLogicalSetActive(pool, 0) < 0) return -1; return 0; } static int -virStorageBackendLogicalDeletePool(virConnectPtr conn, +virStorageBackendLogicalDeletePool(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool, unsigned int flags ATTRIBUTE_UNUSED) { @@ -533,7 +532,7 @@ virStorageBackendLogicalDeletePool(virConnectPtr conn, int i, error; /* first remove the volume group */ - if (virRun(conn, cmdargv, NULL) < 0) + if (virRun(cmdargv, NULL) < 0) return -1; /* now remove the pv devices and clear them out */ @@ -542,7 +541,7 @@ virStorageBackendLogicalDeletePool(virConnectPtr conn, pvargv[2] = NULL; for (i = 0 ; i < pool->def->source.ndevice ; i++) { pvargv[1] = pool->def->source.devices[i].path; - if (virRun(conn, pvargv, NULL) < 0) { + if (virRun(pvargv, NULL) < 0) { error = -1; virReportSystemError(errno, _("cannot remove PV device '%s'"), @@ -607,7 +606,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, return -1; } - if (virRun(conn, cmdargv, NULL) < 0) + if (virRun(cmdargv, NULL) < 0) return -1; if ((fd = open(vol->target.path, O_RDONLY)) < 0) { @@ -675,7 +674,7 @@ virStorageBackendLogicalBuildVolFrom(virConnectPtr conn, } static int -virStorageBackendLogicalDeleteVol(virConnectPtr conn, +virStorageBackendLogicalDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED, virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, virStorageVolDefPtr vol, unsigned int flags ATTRIBUTE_UNUSED) @@ -684,7 +683,7 @@ virStorageBackendLogicalDeleteVol(virConnectPtr conn, LVREMOVE, "-f", vol->target.path, NULL }; - if (virRun(conn, cmdargv, NULL) < 0) + if (virRun(cmdargv, NULL) < 0) return -1; return 0; diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_backend_mpath.c index 87e0fc8..8b8fba5 100644 --- a/src/storage/storage_backend_mpath.c +++ b/src/storage/storage_backend_mpath.c @@ -329,7 +329,7 @@ virStorageBackendMpathRefreshPool(virConnectPtr conn, pool->def->allocation = pool->def->capacity = pool->def->available = 0; - virFileWaitForDevices(conn); + virFileWaitForDevices(); virStorageBackendGetMaps(conn, pool); diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c index 505175d..9c13dee 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -505,7 +505,7 @@ virStorageBackendSCSIFindLUs(virConnectPtr conn, VIR_DEBUG(_("Discovering LUs on host %u"), scanhost); - virFileWaitForDevices(conn); + virFileWaitForDevices(); if (virAsprintf(&device_path, "/sys/bus/scsi/devices") < 0) { virReportOOMError(); @@ -543,8 +543,7 @@ out: int -virStorageBackendSCSIGetHostNumber(virConnectPtr conn, - const char *sysfs_path, +virStorageBackendSCSIGetHostNumber(const char *sysfs_path, uint32_t *host) { int retval = 0; @@ -553,7 +552,7 @@ virStorageBackendSCSIGetHostNumber(virConnectPtr conn, VIR_DEBUG(_("Finding host number from '%s'"), sysfs_path); - virFileWaitForDevices(conn); + virFileWaitForDevices(); sysdir = opendir(sysfs_path); diff --git a/src/storage/storage_backend_scsi.h b/src/storage/storage_backend_scsi.h index d130086..8467993 100644 --- a/src/storage/storage_backend_scsi.h +++ b/src/storage/storage_backend_scsi.h @@ -33,8 +33,7 @@ extern virStorageBackend virStorageBackendSCSI; int -virStorageBackendSCSIGetHostNumber(virConnectPtr conn, - const char *sysfs_path, +virStorageBackendSCSIGetHostNumber(const char *sysfs_path, uint32_t *host); int virStorageBackendSCSIFindLUs(virConnectPtr conn, diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 09153a2..fd5e51d 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -124,7 +124,7 @@ storageDriverStartup(int privileged) { goto out_of_memory; } else { uid_t uid = geteuid(); - char *userdir = virGetUserDirectory(NULL, uid); + char *userdir = virGetUserDirectory(uid); if (!userdir) goto error; diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 732c3d4..a1e09ba 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -365,7 +365,7 @@ umlStartup(int privileged) { if (virDomainObjListInit(¨_driver->domains) < 0) goto error; - userdir = virGetUserDirectory(NULL, uid); + userdir = virGetUserDirectory(uid); if (!userdir) goto error; @@ -899,7 +899,7 @@ static int umlStartVMDaemon(virConnectPtr conn, priv->monitor = -1; - ret = virExecDaemonize(conn, argv, progenv, &keepfd, &pid, + ret = virExecDaemonize(argv, progenv, &keepfd, &pid, -1, &logfd, &logfd, VIR_EXEC_CLEAR_CAPS, NULL, NULL, NULL); diff --git a/src/util/bridge.c b/src/util/bridge.c index f9a7668..4a5ab4b 100644 --- a/src/util/bridge.c +++ b/src/util/bridge.c @@ -792,7 +792,7 @@ brSetForwardDelay(brControl *ctl ATTRIBUTE_UNUSED, snprintf(delayStr, sizeof(delayStr), "%d", delay); - if (virRun(NULL, progargv, NULL) < 0) + if (virRun(progargv, NULL) < 0) return -1; return 0; @@ -819,7 +819,7 @@ brSetEnableSTP(brControl *ctl ATTRIBUTE_UNUSED, BRCTL, "stp", bridge, setting, NULL }; - if (virRun(NULL, progargv, NULL) < 0) + if (virRun(progargv, NULL) < 0) return -1; return 0; diff --git a/src/util/cgroup.c b/src/util/cgroup.c index c80cf50..5d62d38 100644 --- a/src/util/cgroup.c +++ b/src/util/cgroup.c @@ -531,7 +531,7 @@ static int virCgroupAppRoot(int privileged, } else { char *rootname; char *username; - username = virGetUserName(NULL, getuid()); + username = virGetUserName(getuid()); if (!username) { rc = -ENOMEM; goto cleanup; diff --git a/src/util/ebtables.c b/src/util/ebtables.c index 4244adc..dba9f82 100644 --- a/src/util/ebtables.c +++ b/src/util/ebtables.c @@ -228,7 +228,7 @@ ebtablesAddRemoveRule(ebtRules *rules, int action, const char *arg, ...) goto error; } - if (virRun(NULL, argv, NULL) < 0) { + if (virRun(argv, NULL) < 0) { retval = errno; goto error; } diff --git a/src/util/iptables.c b/src/util/iptables.c index 3c02ea6..b579173 100644 --- a/src/util/iptables.c +++ b/src/util/iptables.c @@ -146,7 +146,7 @@ iptablesAddRemoveRule(iptRules *rules, int action, const char *arg, ...) va_end(args); - if (virRun(NULL, argv, NULL) < 0) { + if (virRun(argv, NULL) < 0) { retval = errno; goto error; } diff --git a/src/util/pci.c b/src/util/pci.c index bbaf235..88d163f 100644 --- a/src/util/pci.c +++ b/src/util/pci.c @@ -699,7 +699,7 @@ pciDeviceFile(char *buf, size_t buflen, const char *device, const char *file) static const char * -pciFindStubDriver(virConnectPtr conn) +pciFindStubDriver(void) { char drvpath[PATH_MAX]; int probed = 0; @@ -723,8 +723,8 @@ recheck: * On Xen though, we want to prefer pciback, so probe * for that first, because that will only work on Xen */ - if (virRun(conn, backprobe, NULL) < 0 && - virRun(conn, stubprobe, NULL) < 0) { + if (virRun(backprobe, NULL) < 0 && + virRun(stubprobe, NULL) < 0) { char ebuf[1024]; VIR_WARN(_("failed to load pci-stub or pciback drivers: %s"), virStrerror(errno, ebuf, sizeof ebuf)); @@ -812,7 +812,7 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver) int pciDettachDevice(virConnectPtr conn, pciDevice *dev) { - const char *driver = pciFindStubDriver(conn); + const char *driver = pciFindStubDriver(); if (!driver) { pciReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot find any PCI stub module")); @@ -873,7 +873,7 @@ pciUnBindDeviceFromStub(pciDevice *dev, const char *driver) int pciReAttachDevice(virConnectPtr conn, pciDevice *dev) { - const char *driver = pciFindStubDriver(conn); + const char *driver = pciFindStubDriver(); if (!driver) { pciReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s", _("cannot find any PCI stub module")); diff --git a/src/util/util.c b/src/util/util.c index 92b2958..f1550e0 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -84,9 +84,9 @@ #define VIR_FROM_THIS VIR_FROM_NONE -#define ReportError(conn, code, fmt...) \ - virReportErrorHelper(conn, VIR_FROM_NONE, code, __FILE__, \ - __FUNCTION__, __LINE__, fmt) +#define virUtilError(code, fmt...) \ + virReportErrorHelper(NULL, VIR_FROM_NONE, code, __FILE__, \ + __FUNCTION__, __LINE__, fmt) /* Like read(), but restarts after EINTR */ int saferead(int fd, void *buf, size_t count) @@ -297,7 +297,6 @@ static int virClearCapabilities(void) #endif /* - * @conn Connection to report errors against * @argv argv to exec * @envp optional environment to use for exec * @keepfd options fd_ret to keep open for child process @@ -318,8 +317,7 @@ static int virClearCapabilities(void) * @pidfile path to use as pidfile for daemonized process (needs DAEMON flag) */ static int -__virExec(virConnectPtr conn, - const char *const*argv, +__virExec(const char *const*argv, const char *const*envp, const fd_set *keepfd, pid_t *retpid, @@ -454,9 +452,6 @@ __virExec(virConnectPtr conn, /* child */ - /* Don't want to report errors against this accidentally, so - just discard it */ - conn = NULL; /* Remove any error callback too, so errors in child now get sent to stderr where they stand a fighting chance of being seen / logged */ @@ -593,7 +588,7 @@ __virExec(virConnectPtr conn, /* This is cleanup of parent process only - child should never jump here on error */ - /* NB we don't ReportError() on any failures here + /* NB we don't virUtilError() on any failures here because the code which jumped hre already raised an error condition which we must not overwrite */ if (pipeerr[0] > 0) @@ -610,8 +605,7 @@ __virExec(virConnectPtr conn, } int -virExecWithHook(virConnectPtr conn, - const char *const*argv, +virExecWithHook(const char *const*argv, const char *const*envp, const fd_set *keepfd, pid_t *retpid, @@ -641,7 +635,7 @@ virExecWithHook(virConnectPtr conn, } VIR_FREE(argv_str); - return __virExec(conn, argv, envp, keepfd, retpid, infd, outfd, errfd, + return __virExec(argv, envp, keepfd, retpid, infd, outfd, errfd, flags, hook, data, pidfile); } @@ -653,15 +647,14 @@ virExecWithHook(virConnectPtr conn, * list. */ int -virExec(virConnectPtr conn, - const char *const*argv, +virExec(const char *const*argv, const char *const*envp, const fd_set *keepfd, pid_t *retpid, int infd, int *outfd, int *errfd, int flags) { - return virExecWithHook(conn, argv, envp, keepfd, retpid, + return virExecWithHook(argv, envp, keepfd, retpid, infd, outfd, errfd, flags, NULL, NULL, NULL); } @@ -680,8 +673,7 @@ virExec(virConnectPtr conn, * occured and when in the process occured, the error output * could have gone to stderr or the passed errfd). */ -int virExecDaemonize(virConnectPtr conn, - const char *const*argv, +int virExecDaemonize(const char *const*argv, const char *const*envp, const fd_set *keepfd, pid_t *retpid, @@ -693,7 +685,7 @@ int virExecDaemonize(virConnectPtr conn, int ret; int childstat = 0; - ret = virExecWithHook(conn, argv, envp, keepfd, retpid, + ret = virExecWithHook(argv, envp, keepfd, retpid, infd, outfd, errfd, flags | VIR_EXEC_DAEMON, hook, data, pidfile); @@ -707,9 +699,9 @@ int virExecDaemonize(virConnectPtr conn, errno == EINTR); if (childstat != 0) { - ReportError(conn, VIR_ERR_INTERNAL_ERROR, - _("Intermediate daemon process exited with status %d."), - WEXITSTATUS(childstat)); + virUtilError(VIR_ERR_INTERNAL_ERROR, + _("Intermediate daemon process exited with status %d."), + WEXITSTATUS(childstat)); ret = -2; } @@ -717,7 +709,7 @@ int virExecDaemonize(virConnectPtr conn, } static int -virPipeReadUntilEOF(virConnectPtr conn, int outfd, int errfd, +virPipeReadUntilEOF(int outfd, int errfd, char **outbuf, char **errbuf) { struct pollfd fds[2]; @@ -752,8 +744,8 @@ virPipeReadUntilEOF(virConnectPtr conn, int outfd, int errfd, if (fds[i].revents & POLLHUP) continue; - ReportError(conn, VIR_ERR_INTERNAL_ERROR, - "%s", _("Unknown poll response.")); + virUtilError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Unknown poll response.")); goto error; } @@ -797,7 +789,6 @@ error: } /** - * @conn connection to report errors against * @argv NULL terminated argv to run * @status optional variable to return exit status in * @@ -812,8 +803,7 @@ error: * only if the command could not be run. */ int -virRunWithHook(virConnectPtr conn, - const char *const*argv, +virRunWithHook(const char *const*argv, virExecHook hook, void *data, int *status) { @@ -831,14 +821,14 @@ virRunWithHook(virConnectPtr conn, } DEBUG0(argv_str); - if ((execret = __virExec(conn, argv, NULL, NULL, + if ((execret = __virExec(argv, NULL, NULL, &childpid, -1, &outfd, &errfd, VIR_EXEC_NONE, hook, data, NULL)) < 0) { ret = execret; goto error; } - if (virPipeReadUntilEOF(conn, outfd, errfd, &outbuf, &errbuf) < 0) { + if (virPipeReadUntilEOF(outfd, errfd, &outbuf, &errbuf) < 0) { while (waitpid(childpid, &exitstatus, 0) == -1 && errno == EINTR) ; goto error; @@ -861,12 +851,12 @@ virRunWithHook(virConnectPtr conn, if (status == NULL) { errno = EINVAL; if (WIFEXITED(exitstatus) && WEXITSTATUS(exitstatus) != 0) { - ReportError(conn, VIR_ERR_INTERNAL_ERROR, - _("'%s' exited with non-zero status %d and " - "signal %d: %s"), argv_str, - WIFEXITED(exitstatus) ? WEXITSTATUS(exitstatus) : 0, - WIFSIGNALED(exitstatus) ? WTERMSIG(exitstatus) : 0, - (errbuf ? errbuf : "")); + virUtilError(VIR_ERR_INTERNAL_ERROR, + _("'%s' exited with non-zero status %d and " + "signal %d: %s"), argv_str, + WIFEXITED(exitstatus) ? WEXITSTATUS(exitstatus) : 0, + WIFSIGNALED(exitstatus) ? WTERMSIG(exitstatus) : 0, + (errbuf ? errbuf : "")); goto error; } } else { @@ -889,8 +879,7 @@ virRunWithHook(virConnectPtr conn, #else /* __MINGW32__ */ int -virRunWithHook(virConnectPtr conn, - const char *const *argv ATTRIBUTE_UNUSED, +virRunWithHook(const char *const *argv ATTRIBUTE_UNUSED, virExecHook hook ATTRIBUTE_UNUSED, void *data ATTRIBUTE_UNUSED, int *status) @@ -898,13 +887,12 @@ virRunWithHook(virConnectPtr conn, if (status) *status = ENOTSUP; else - ReportError (conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__); + virUtilError(VIR_ERR_INTERNAL_ERROR, __FUNCTION__); return -1; } int -virExec(virConnectPtr conn, - const char *const*argv ATTRIBUTE_UNUSED, +virExec(const char *const*argv ATTRIBUTE_UNUSED, const char *const*envp ATTRIBUTE_UNUSED, const fd_set *keepfd ATTRIBUTE_UNUSED, int *retpid ATTRIBUTE_UNUSED, @@ -913,17 +901,16 @@ virExec(virConnectPtr conn, int *errfd ATTRIBUTE_UNUSED, int flags ATTRIBUTE_UNUSED) { - ReportError (conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__); + virUtilError(VIR_ERR_INTERNAL_ERROR, __FUNCTION__); return -1; } #endif /* __MINGW32__ */ int -virRun(virConnectPtr conn, - const char *const*argv, +virRun(const char *const*argv, int *status) { - return virRunWithHook(conn, argv, NULL, NULL, status); + return virRunWithHook(argv, NULL, NULL, status); } /* Like gnulib's fread_file, but read no more than the specified maximum @@ -2177,8 +2164,8 @@ char *virIndexToDiskName(int idx, const char *prefix) int i, k, offset; if (idx < 0) { - ReportError(NULL, VIR_ERR_INTERNAL_ERROR, - _("Disk index %d is negative"), idx); + virUtilError(VIR_ERR_INTERNAL_ERROR, + _("Disk index %d is negative"), idx); return NULL; } @@ -2205,7 +2192,7 @@ char *virIndexToDiskName(int idx, const char *prefix) #define AI_CANONIDN 0 #endif -char *virGetHostname(virConnectPtr conn) +char *virGetHostname(virConnectPtr conn ATTRIBUTE_UNUSED) { int r; char hostname[HOST_NAME_MAX+1], *result; @@ -2224,14 +2211,14 @@ char *virGetHostname(virConnectPtr conn) hints.ai_family = AF_UNSPEC; r = getaddrinfo(hostname, NULL, &hints, &info); if (r != 0) { - ReportError(conn, VIR_ERR_INTERNAL_ERROR, - _("getaddrinfo failed for '%s': %s"), - hostname, gai_strerror(r)); + virUtilError(VIR_ERR_INTERNAL_ERROR, + _("getaddrinfo failed for '%s': %s"), + hostname, gai_strerror(r)); return NULL; } if (info->ai_canonname == NULL) { - ReportError(conn, VIR_ERR_INTERNAL_ERROR, - "%s", _("could not determine canonical host name")); + virUtilError(VIR_ERR_INTERNAL_ERROR, + "%s", _("could not determine canonical host name")); freeaddrinfo(info); return NULL; } @@ -2385,21 +2372,18 @@ static char *virGetUserEnt(uid_t uid, return ret; } -char *virGetUserDirectory(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, - uid_t uid) +char *virGetUserDirectory(uid_t uid) { return virGetUserEnt(uid, VIR_USER_ENT_DIRECTORY); } -char *virGetUserName(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, - uid_t uid) +char *virGetUserName(uid_t uid) { return virGetUserEnt(uid, VIR_USER_ENT_NAME); } -int virGetUserID(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, - const char *name, +int virGetUserID(const char *name, uid_t *uid) { char *strbuf; @@ -2441,8 +2425,7 @@ int virGetUserID(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, } -int virGetGroupID(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/, - const char *name, +int virGetGroupID(const char *name, gid_t *gid) { char *strbuf; @@ -2520,7 +2503,7 @@ cleanup: #ifndef PROXY #if defined(UDEVADM) || defined(UDEVSETTLE) -void virFileWaitForDevices(virConnectPtr conn) +void virFileWaitForDevices(void) { #ifdef UDEVADM const char *const settleprog[] = { UDEVADM, "settle", NULL }; @@ -2538,11 +2521,11 @@ void virFileWaitForDevices(virConnectPtr conn) * If this fails for any reason, we still have the backup of polling for * 5 seconds for device nodes. */ - if (virRun(conn, settleprog, &exitstatus) < 0) + if (virRun(settleprog, &exitstatus) < 0) {} } #else -void virFileWaitForDevices(virConnectPtr conn ATTRIBUTE_UNUSED) {} +void virFileWaitForDevices(void) {} #endif #endif diff --git a/src/util/util.h b/src/util/util.h index b0219cc..bb545ac 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -49,8 +49,7 @@ int virSetCloseExec(int fd) ATTRIBUTE_RETURN_CHECK; * after fork() but before execve() */ typedef int (*virExecHook)(void *data); -int virExecDaemonize(virConnectPtr conn, - const char *const*argv, +int virExecDaemonize(const char *const*argv, const char *const*envp, const fd_set *keepfd, pid_t *retpid, @@ -59,8 +58,7 @@ int virExecDaemonize(virConnectPtr conn, virExecHook hook, void *data, char *pidfile) ATTRIBUTE_RETURN_CHECK; -int virExecWithHook(virConnectPtr conn, - const char *const*argv, +int virExecWithHook(const char *const*argv, const char *const*envp, const fd_set *keepfd, int *retpid, @@ -71,8 +69,7 @@ int virExecWithHook(virConnectPtr conn, virExecHook hook, void *data, char *pidfile) ATTRIBUTE_RETURN_CHECK; -int virExec(virConnectPtr conn, - const char *const*argv, +int virExec(const char *const*argv, const char *const*envp, const fd_set *keepfd, pid_t *retpid, @@ -80,8 +77,8 @@ int virExec(virConnectPtr conn, int *outfd, int *errfd, int flags) ATTRIBUTE_RETURN_CHECK; -int virRun(virConnectPtr conn, const char *const*argv, int *status) ATTRIBUTE_RETURN_CHECK; -int virRunWithHook(virConnectPtr conn, const char *const*argv, +int virRun(const char *const*argv, int *status) ATTRIBUTE_RETURN_CHECK; +int virRunWithHook(const char *const*argv, virExecHook hook, void *data, int *status) ATTRIBUTE_RETURN_CHECK; @@ -241,15 +238,11 @@ char *virGetHostname(virConnectPtr conn); int virKillProcess(pid_t pid, int sig); #ifdef HAVE_GETPWUID_R -char *virGetUserDirectory(virConnectPtr conn, - uid_t uid); -char *virGetUserName(virConnectPtr conn, - uid_t uid); -int virGetUserID(virConnectPtr conn, - const char *name, +char *virGetUserDirectory(uid_t uid); +char *virGetUserName(uid_t uid); +int virGetUserID(const char *name, uid_t *uid) ATTRIBUTE_RETURN_CHECK; -int virGetGroupID(virConnectPtr conn, - const char *name, +int virGetGroupID(const char *name, gid_t *gid) ATTRIBUTE_RETURN_CHECK; #endif @@ -260,7 +253,7 @@ int virRandom(int max); char *virFileFindMountPoint(const char *type); #endif -void virFileWaitForDevices(virConnectPtr conn); +void virFileWaitForDevices(void); #define virBuildPath(path, ...) virBuildPathInternal(path, __VA_ARGS__, NULL) int virBuildPathInternal(char **path, ...) ATTRIBUTE_SENTINEL; diff --git a/src/xen/proxy_internal.c b/src/xen/proxy_internal.c index 300618b..63df442 100644 --- a/src/xen/proxy_internal.c +++ b/src/xen/proxy_internal.c @@ -155,7 +155,7 @@ virProxyForkServer(void) proxyarg[0] = proxyPath; proxyarg[1] = NULL; - if (virExecDaemonize(NULL, proxyarg, NULL, NULL, + if (virExecDaemonize(proxyarg, NULL, NULL, &pid, -1, NULL, NULL, 0, NULL, NULL, NULL) < 0) VIR_ERROR0("Failed to fork libvirt_proxy"); diff --git a/tools/virsh.c b/tools/virsh.c index 01d2038..761d145 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -7105,7 +7105,7 @@ cmdCd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) dir = vshCommandOptString(cmd, "dir", &found); if (!found) { uid_t uid = geteuid(); - dir = virGetUserDirectory(NULL, uid); + dir = virGetUserDirectory(uid); } if (!dir) dir = "/"; @@ -8706,7 +8706,7 @@ vshReadlineInit(vshControl *ctl) stifle_history(500); /* Prepare to read/write history from/to the ~/.virsh/history file */ - userdir = virGetUserDirectory(NULL, getuid()); + userdir = virGetUserDirectory(getuid()); if (userdir == NULL) return -1; -- 1.6.3.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list