It was used for error reporting only.
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;
goto authfail;
}
- if (virRun(NULL, pkcheck, &status) < 0) {
+ if (virRun(pkcheck, &status) < 0) {
VIR_ERROR(_("Cannot invoke %s"), PKCHECK_PATH);
goto authfail;
}
+ * 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) {}
- * 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;
}
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;
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;
}
DEBUG("veth1: %s veth2: %s", veth1, veth2);
- rc = virRun(NULL, argv, &cmdResult);
+ rc = virRun(argv, &cmdResult);
if (0 == rc) {
rc = cmdResult;
DEBUG("veth: %s", veth);
- rc = virRun(NULL, argv, &cmdResult);
+ rc = virRun(argv, &cmdResult);
if (0 == rc) {
rc = cmdResult;
else
argv[2] = "up";
- rc = virRun(NULL, argv, &cmdResult);
+ rc = virRun(argv, &cmdResult);
if (0 == rc) {
rc = cmdResult;
goto error_out;
argv[5] = pid;
- rc = virRun(NULL, argv, &cmdResult);
+ rc = virRun(argv, &cmdResult);
if (0 == rc)
rc = cmdResult;
goto error_out;
}
- rc = virRun(NULL, argv, &cmdResult);
+ rc = virRun(argv, &cmdResult);
if (0 == rc)
rc = cmdResult;
goto error_out;
}
- rc = virRun(NULL, argv, &cmdResult);
+ rc = virRun(argv, &cmdResult);
if (0 == rc)
rc = cmdResult;
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;
return -1;
}
- if (virRun(conn, argv, NULL) < 0)
+ if (virRun(argv, NULL) < 0)
goto cleanup;
/*
while ((now - start) < LINUX_NEW_DEVICE_WAIT_TIME) {
- virFileWaitForDevices(conn);
+ virFileWaitForDevices();
dev = nodeDeviceLookupByWWN(conn, wwnn, wwpn);
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;
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;
goto cleanup;
}
- if (virRun(dom->conn, prog, NULL) < 0)
+ if (virRun(prog, NULL) < 0)
goto cleanup;
vm->def->id = -1;
goto cleanup;
}
- if (virRun(dom->conn, prog, NULL) < 0)
+ if (virRun(prog, NULL) < 0)
goto cleanup;
ret = 0;
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;
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;
}
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;
}
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;
}
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;
}
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;
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,
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,
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;
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)
virConfFree(conf);
return -1;
}
- if (virGetUserID(NULL, user, &driver->user) < 0) {
+ if (virGetUserID(user, &driver->user) < 0) {
VIR_FREE(user);
virConfFree(conf);
return -1;
virConfFree(conf);
return -1;
}
- if (virGetGroupID(NULL, group, &driver->group) < 0) {
+ if (virGetGroupID(group, &driver->group) < 0) {
VIR_FREE(group);
virConfFree(conf);
return -1;
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;
return 0;
}
- if (virExec(NULL, qemuarg, qemuenv, NULL,
+ if (virExec(qemuarg, qemuenv, NULL,
&child, -1, &newstdout, NULL, VIR_EXEC_CLEAR_CAPS) < 0)
return -1;
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;
goto out_of_memory;
} else {
uid_t uid = geteuid();
- char *userdir = virGetUserDirectory(NULL, uid);
+ char *userdir = virGetUserDirectory(uid);
if (!userdir)
goto error;
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,
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"),
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)
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;
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;
goto out_of_memory;
} else {
uid_t uid = geteuid();
- char *userdir = virGetUserDirectory(NULL, uid);
+ char *userdir = virGetUserDirectory(uid);
if (!userdir)
goto error;
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)
VIRT_AA_HELPER, "-R", "-u", profile, NULL
};
- if (virRun(NULL, argv, NULL) == 0)
+ if (virRun(argv, NULL) == 0)
rc = 0;
return rc;
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;
}
return 0;
}
-static int virStorageBackendCreateExecCommand(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+static int virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
const char **cmdargv) {
struct stat st;
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)
}
}
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);
/* 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;
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;
/* 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;
}
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;
}
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;
* Write a new partition table header
*/
static int
-virStorageBackendDiskBuildPool(virConnectPtr conn,
+virStorageBackendDiskBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
virStoragePoolObjPtr pool,
unsigned int flags ATTRIBUTE_UNUSED)
{
NULL,
};
- if (virRun(conn, prog, NULL) < 0)
+ if (virRun(prog, NULL) < 0)
return -1;
return 0;
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);
NULL,
};
- if (virRun(conn, prog, NULL) < 0)
+ if (virRun(prog, NULL) < 0)
goto cleanup;
rc = 0;
mntargv[option_index] = options;
}
- if (virRun(conn, mntargv, NULL) < 0) {
+ if (virRun(mntargv, NULL) < 0) {
VIR_FREE(src);
return -1;
}
mntargv[1] = pool->def->target.path;
mntargv[2] = NULL;
- if (virRun(conn, mntargv, NULL) < 0) {
+ if (virRun(mntargv, NULL) < 0) {
return -1;
}
return 0;
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);
* 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]);
/* 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);
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]);
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);
"--targetname", pool->def->source.devices[0].path, action, NULL
};
- if (virRun(conn, cmdargv, NULL) < 0) {
+ if (virRun(cmdargv, NULL) < 0) {
ret = -1;
}
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'"),
}
static int
-virStorageBackendISCSIRescanLUNs(virConnectPtr conn,
+virStorageBackendISCSIRescanLUNs(virConnectPtr conn ATTRIBUTE_UNUSED,
virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
const char *session)
{
ISCSIADM, "--mode", "session", "-r", session, "-R", NULL,
};
- if (virRun(conn, cmdargv, NULL) < 0)
+ if (virRun(cmdargv, NULL) < 0)
return -1;
return 0;
"--portal", portal, NULL
};
- if (virRun(conn, cmdsendtarget, NULL) < 0)
+ if (virRun(cmdsendtarget, NULL) < 0)
return -1;
return virStorageBackendISCSIConnection(conn, pool, portal, "--login");
static int
-virStorageBackendLogicalSetActive(virConnectPtr conn,
- virStoragePoolObjPtr pool,
+virStorageBackendLogicalSetActive(virStoragePoolObjPtr pool,
int on)
{
const char *cmdargv[4];
cmdargv[2] = pool->def->source.name;
cmdargv[3] = NULL;
- if (virRun(conn, cmdargv, NULL) < 0)
+ if (virRun(cmdargv, NULL) < 0)
return -1;
return 0;
* 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");
}
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;
static int
-virStorageBackendLogicalBuildPool(virConnectPtr conn,
+virStorageBackendLogicalBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
virStoragePoolObjPtr pool,
unsigned int flags ATTRIBUTE_UNUSED)
{
*/
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);
};
int exitstatus;
- virFileWaitForDevices(conn);
+ virFileWaitForDevices();
/* Get list of all logical volumes */
if (virStorageBackendLogicalFindLVs(conn, pool, NULL) < 0) {
* "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)
{
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 */
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'"),
return -1;
}
- if (virRun(conn, cmdargv, NULL) < 0)
+ if (virRun(cmdargv, NULL) < 0)
return -1;
if ((fd = open(vol->target.path, O_RDONLY)) < 0) {
}
static int
-virStorageBackendLogicalDeleteVol(virConnectPtr conn,
+virStorageBackendLogicalDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
virStorageVolDefPtr vol,
unsigned int flags ATTRIBUTE_UNUSED)
LVREMOVE, "-f", vol->target.path, NULL
};
- if (virRun(conn, cmdargv, NULL) < 0)
+ if (virRun(cmdargv, NULL) < 0)
return -1;
return 0;
pool->def->allocation = pool->def->capacity = pool->def->available = 0;
- virFileWaitForDevices(conn);
+ virFileWaitForDevices();
virStorageBackendGetMaps(conn, pool);
VIR_DEBUG(_("Discovering LUs on host %u"), scanhost);
- virFileWaitForDevices(conn);
+ virFileWaitForDevices();
if (virAsprintf(&device_path, "/sys/bus/scsi/devices") < 0) {
virReportOOMError();
int
-virStorageBackendSCSIGetHostNumber(virConnectPtr conn,
- const char *sysfs_path,
+virStorageBackendSCSIGetHostNumber(const char *sysfs_path,
uint32_t *host)
{
int retval = 0;
VIR_DEBUG(_("Finding host number from '%s'"), sysfs_path);
- virFileWaitForDevices(conn);
+ virFileWaitForDevices();
sysdir = opendir(sysfs_path);
extern virStorageBackend virStorageBackendSCSI;
int
-virStorageBackendSCSIGetHostNumber(virConnectPtr conn,
- const char *sysfs_path,
+virStorageBackendSCSIGetHostNumber(const char *sysfs_path,
uint32_t *host);
int
virStorageBackendSCSIFindLUs(virConnectPtr conn,
goto out_of_memory;
} else {
uid_t uid = geteuid();
- char *userdir = virGetUserDirectory(NULL, uid);
+ char *userdir = virGetUserDirectory(uid);
if (!userdir)
goto error;
if (virDomainObjListInit(¨_driver->domains) < 0)
goto error;
- userdir = virGetUserDirectory(NULL, uid);
+ userdir = virGetUserDirectory(uid);
if (!userdir)
goto error;
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);
snprintf(delayStr, sizeof(delayStr), "%d", delay);
- if (virRun(NULL, progargv, NULL) < 0)
+ if (virRun(progargv, NULL) < 0)
return -1;
return 0;
BRCTL, "stp", bridge, setting, NULL
};
- if (virRun(NULL, progargv, NULL) < 0)
+ if (virRun(progargv, NULL) < 0)
return -1;
return 0;
} else {
char *rootname;
char *username;
- username = virGetUserName(NULL, getuid());
+ username = virGetUserName(getuid());
if (!username) {
rc = -ENOMEM;
goto cleanup;
goto error;
}
- if (virRun(NULL, argv, NULL) < 0) {
+ if (virRun(argv, NULL) < 0) {
retval = errno;
goto error;
}
va_end(args);
- if (virRun(NULL, argv, NULL) < 0) {
+ if (virRun(argv, NULL) < 0) {
retval = errno;
goto error;
}
static const char *
-pciFindStubDriver(virConnectPtr conn)
+pciFindStubDriver(void)
{
char drvpath[PATH_MAX];
int probed = 0;
* 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));
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"));
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"));
#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)
#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
* @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,
/* 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 */
/* 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)
}
int
-virExecWithHook(virConnectPtr conn,
- const char *const*argv,
+virExecWithHook(const char *const*argv,
const char *const*envp,
const fd_set *keepfd,
pid_t *retpid,
}
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);
}
* 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);
}
* 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,
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);
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;
}
}
static int
-virPipeReadUntilEOF(virConnectPtr conn, int outfd, int errfd,
+virPipeReadUntilEOF(int outfd, int errfd,
char **outbuf, char **errbuf) {
struct pollfd fds[2];
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;
}
}
/**
- * @conn connection to report errors against
* @argv NULL terminated argv to run
* @status optional variable to return exit status in
*
* 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) {
}
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;
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 {
#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)
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,
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
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;
}
#define AI_CANONIDN 0
#endif
-char *virGetHostname(virConnectPtr conn)
+char *virGetHostname(virConnectPtr conn ATTRIBUTE_UNUSED)
{
int r;
char hostname[HOST_NAME_MAX+1], *result;
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;
}
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;
}
-int virGetGroupID(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/,
- const char *name,
+int virGetGroupID(const char *name,
gid_t *gid)
{
char *strbuf;
#ifndef PROXY
#if defined(UDEVADM) || defined(UDEVSETTLE)
-void virFileWaitForDevices(virConnectPtr conn)
+void virFileWaitForDevices(void)
{
#ifdef UDEVADM
const char *const settleprog[] = { UDEVADM, "settle", NULL };
* 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
* 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,
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,
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,
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;
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
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;
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");
dir = vshCommandOptString(cmd, "dir", &found);
if (!found) {
uid_t uid = geteuid();
- dir = virGetUserDirectory(NULL, uid);
+ dir = virGetUserDirectory(uid);
}
if (!dir)
dir = "/";
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;