virThread thread;
g_autoptr(libxlDriverConfig) cfg = NULL;
int ret = -1;
+ g_autofree char *name = NULL;
if (event->type != LIBXL_EVENT_TYPE_DOMAIN_SHUTDOWN &&
event->type != LIBXL_EVENT_TYPE_DOMAIN_DEATH) {
shutdown_info->driver = driver;
shutdown_info->event = (libxl_event *)event;
+ name = g_strdup_printf("ev-%d", event->domid);
if (event->type == LIBXL_EVENT_TYPE_DOMAIN_SHUTDOWN)
- ret = virThreadCreate(&thread, false, libxlDomainShutdownThread,
- shutdown_info);
+ ret = virThreadCreateFull(&thread, false, libxlDomainShutdownThread,
+ name, false, shutdown_info);
else if (event->type == LIBXL_EVENT_TYPE_DOMAIN_DEATH)
- ret = virThreadCreate(&thread, false, libxlDomainDeathThread,
- shutdown_info);
+ ret = virThreadCreateFull(&thread, false, libxlDomainDeathThread,
+ name, false, shutdown_info);
if (ret < 0) {
/*
virNetSocketPtr client_sock;
int recvfd = -1;
size_t i;
+ g_autofree char *name = NULL;
/* Accept migration connection */
if (virNetSocketAccept(sock, &client_sock) < 0 || !client_sock) {
VIR_FREE(priv->migrationDstReceiveThr);
if (VIR_ALLOC(priv->migrationDstReceiveThr) < 0)
goto fail;
- if (virThreadCreate(priv->migrationDstReceiveThr, true,
- libxlDoMigrateDstReceive, args) < 0) {
+
+ name = g_strdup_printf("mig-%s", args->vm->def->name);
+ if (virThreadCreateFull(priv->migrationDstReceiveThr, true,
+ libxlDoMigrateDstReceive,
+ name,
+ false,
+ args) < 0) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to create thread for receiving migration data"));
goto fail;
char *xmlout = NULL;
int dataFD[2] = { -1, -1 };
int ret = -1;
+ g_autofree char *name = NULL;
if (libxlDomainMigrationPrepareAny(dconn, def, cookiein, cookieinlen,
&mig, &xmlout, &taint_hook) < 0)
VIR_FREE(priv->migrationDstReceiveThr);
if (VIR_ALLOC(priv->migrationDstReceiveThr) < 0)
goto error;
- if (virThreadCreate(priv->migrationDstReceiveThr, true, libxlDoMigrateDstReceive, args) < 0) {
+ name = g_strdup_printf("mig-%s", args->vm->def->name);
+ if (virThreadCreateFull(priv->migrationDstReceiveThr, true,
+ libxlDoMigrateDstReceive,
+ name, false, args) < 0) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to create thread for receiving migration data"));
goto endjob;
struct libxlTunnelControl *tc = NULL;
libxlTunnelMigrationThread *arg = NULL;
int ret = -1;
+ g_autofree char *name = NULL;
if (VIR_ALLOC(tc) < 0)
goto out;
arg->srcFD = tc->dataFD[0];
/* Write to dest stream */
arg->st = st;
- if (virThreadCreate(&tc->thread, true,
- libxlTunnel3MigrationSrcFunc, arg) < 0) {
+ name = g_strdup_printf("mig-%s", vm->def->name);
+ if (virThreadCreateFull(&tc->thread, true,
+ libxlTunnel3MigrationSrcFunc,
+ name, false, arg) < 0) {
virReportError(errno, "%s",
_("Unable to create tunnel migration thread"));
goto out;
int lxcStartFuse(virLXCFusePtr fuse)
{
- if (virThreadCreate(&fuse->thread, false, lxcFuseRun,
- (void *)fuse) < 0) {
+ if (virThreadCreateFull(&fuse->thread, false, lxcFuseRun,
+ "lxc-fuse", false, (void *)fuse) < 0) {
lxcFuseDestroy(fuse);
return -1;
}
udev_monitor_set_receive_buffer_size(priv->udev_monitor,
128 * 1024 * 1024);
- if (virThreadCreate(&priv->th, true, udevEventHandleThread, NULL) < 0) {
+ if (virThreadCreateFull(&priv->th, true, udevEventHandleThread,
+ "udev-event", false, NULL) < 0) {
virReportSystemError(errno, "%s",
_("failed to create udev handler thread"));
goto unlock;
if (udevSetupSystemDev() != 0)
goto cleanup;
- if (virThreadCreate(&enumThread, false, nodeStateInitializeEnumerate,
- udev) < 0) {
+ if (virThreadCreateFull(&enumThread, false, nodeStateInitializeEnumerate,
+ "nodedev-init", false, udev) < 0) {
virReportSystemError(errno, "%s",
_("failed to create udev enumerate thread"));
goto cleanup;
}
tmp = virNetDevGetIndex(req->binding->portdevname, &ifindex);
threadkey = g_strdup(req->threadkey);
- worker = virThreadPoolNew(1, 1, 0,
- virNWFilterDHCPDecodeWorker,
- req);
+ worker = virThreadPoolNewFull(1, 1, 0,
+ virNWFilterDHCPDecodeWorker,
+ "dhcp-decode",
+ req);
}
/* let creator know how well we initialized */
/* prevent thread from holding req */
virNWFilterSnoopReqLock(req);
- if (virThreadCreate(&thread, false, virNWFilterDHCPSnoopThread,
- req) != 0) {
+ if (virThreadCreateFull(&thread, false, virNWFilterDHCPSnoopThread,
+ "dhcp-snoop", false, req) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("virNWFilterDHCPSnoopReq virThreadCreate "
"failed on interface '%s'"), binding->portdevname);
if (rc < 0)
goto err_free_req;
- if (virThreadCreate(&thread,
- false,
- learnIPAddressThread,
- req) != 0)
+ if (virThreadCreateFull(&thread,
+ false,
+ learnIPAddressThread,
+ "ip-learn",
+ false,
+ req) != 0)
goto err_dereg_req;
return 0;
/* must be initialized before trying to reconnect to all the
* running domains since there might occur some QEMU monitor
* events that will be dispatched to the worker pool */
- qemu_driver->workerPool = virThreadPoolNew(0, 1, 0, qemuProcessEventHandler, qemu_driver);
+ qemu_driver->workerPool = virThreadPoolNewFull(0, 1, 0, qemuProcessEventHandler,
+ "qemu-event", qemu_driver);
if (!qemu_driver->workerPool)
goto error;
io->wakeupRecvFD = wakeupFD[0];
io->wakeupSendFD = wakeupFD[1];
- if (virThreadCreate(&io->thread, true,
- qemuMigrationSrcIOFunc,
- io) < 0) {
+ if (virThreadCreateFull(&io->thread, true,
+ qemuMigrationSrcIOFunc,
+ "qemu-mig-tunnel",
+ false,
+ io) < 0) {
virReportSystemError(errno, "%s",
_("Unable to create migration thread"));
goto error;
qemuDomainObjPrivatePtr priv = vm->privateData;
if (priv->fakeReboot) {
+ g_autofree char *name = g_strdup_printf("reboot-%s", vm->def->name);
qemuDomainSetFakeReboot(driver, vm, false);
virObjectRef(vm);
virThread th;
- if (virThreadCreate(&th,
- false,
- qemuProcessFakeReboot,
- vm) < 0) {
+ if (virThreadCreateFull(&th,
+ false,
+ qemuProcessFakeReboot,
+ name,
+ false,
+ vm) < 0) {
VIR_ERROR(_("Failed to create reboot thread, killing domain"));
ignore_value(qemuProcessKill(vm, VIR_QEMU_PROCESS_KILL_NOWAIT));
priv->pausedShutdown = false;
virThread thread;
struct qemuProcessReconnectData *src = opaque;
struct qemuProcessReconnectData *data;
+ g_autofree char *name = NULL;
/* If the VM was inactive, we don't need to reconnect */
if (!obj->pid)
virObjectLock(obj);
virObjectRef(obj);
- if (virThreadCreate(&thread, false, qemuProcessReconnect, data) < 0) {
+ name = g_strdup_printf("init-%s", obj->def->name);
+
+ if (virThreadCreateFull(&thread, false, qemuProcessReconnect,
+ name, false, data) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not create thread. QEMU initialization "
"might be incomplete"));
return;
}
- if (virThreadCreate(&thr, false, daemonReloadHandlerThread, NULL) < 0) {
+ if (virThreadCreateFull(&thr, false, daemonReloadHandlerThread,
+ "daemon-reload", false, NULL) < 0) {
/*
* Not much we can do on error here except log it.
*/
{
virThread thr;
virObjectRef(dmn);
- if (virThreadCreate(&thr, false, daemonStopWorker, dmn) < 0)
+ if (virThreadCreateFull(&thr, false, daemonStopWorker,
+ "daemon-stop", false, dmn) < 0)
virObjectUnref(dmn);
}
{
virThread thr;
virObjectRef(dmn);
- if (virThreadCreate(&thr, false, daemonRunStateInit, dmn) < 0) {
+ if (virThreadCreateFull(&thr, false, daemonRunStateInit,
+ "daemon-init", false, dmn) < 0) {
virObjectUnref(dmn);
return -1;
}
if (!(srv = virObjectLockableNew(virNetServerClass)))
return NULL;
- if (!(srv->workers = virThreadPoolNew(min_workers, max_workers,
- priority_workers,
- virNetServerHandleJob,
- srv)))
+ if (!(srv->workers = virThreadPoolNewFull(min_workers, max_workers,
+ priority_workers,
+ virNetServerHandleJob,
+ "rpc-worker",
+ srv)))
goto error;
srv->name = g_strdup(name);
memcpy(cbdata->pool_uuid, def->uuid, VIR_UUID_BUFLEN);
cbdata->fchost_name = g_steal_pointer(&name);
- if (virThreadCreate(&thread, false, virStoragePoolFCRefreshThread,
- cbdata) < 0) {
+ if (virThreadCreateFull(&thread, false, virStoragePoolFCRefreshThread,
+ "scsi-refresh", false, cbdata) < 0) {
/* Oh well - at least someone can still refresh afterwards */
VIR_DEBUG("Failed to create FC Pool Refresh Thread");
virStoragePoolFCRefreshDataFree(cbdata);
{
virThread thread;
- if (virThreadCreate(&thread, false, virStorageVolPoolRefreshThread,
- opaque) < 0) {
+ if (virThreadCreateFull(&thread, false, virStorageVolPoolRefreshThread,
+ "vol-refresh", false, opaque) < 0) {
/* Not much else can be done */
VIR_ERROR(_("Failed to create thread to handle pool refresh"));
goto error;
/* clear any error so we can catch if the helper thread reports one */
cmd->has_error = 0;
if (VIR_ALLOC(cmd->asyncioThread) < 0 ||
- virThreadCreate(cmd->asyncioThread, true,
- virCommandDoAsyncIOHelper, cmd) < 0) {
+ virThreadCreateFull(cmd->asyncioThread, true,
+ virCommandDoAsyncIOHelper,
+ "cmd-async-io", false, cmd) < 0) {
virReportSystemError(errno, "%s",
_("Unable to create thread "
"to process command's IO"));
goto error;
}
- if (virThreadCreate(fdst->thread,
- true,
- virFDStreamThread,
- threadData) < 0)
+ if (virThreadCreateFull(fdst->thread,
+ true,
+ virFDStreamThread,
+ "fd-stream",
+ false,
+ threadData) < 0)
goto error;
}
if (virNodeSuspendSetNodeWakeup(duration) < 0)
goto cleanup;
- if (virThreadCreate(&thread, false,
- virNodeSuspendHelper,
- (void *)cmdString) < 0) {
+ if (virThreadCreateFull(&thread, false,
+ virNodeSuspendHelper,
+ "node-suspend",
+ false,
+ (void *)cmdString) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to create thread to suspend the host"));
goto cleanup;
bool quit;
virThreadPoolJobFunc jobFunc;
- const char *jobFuncName;
+ const char *jobName;
void *jobOpaque;
virThreadPoolJobList jobList;
size_t jobQueueDepth;
return -1;
for (i = 0; i < gain; i++) {
+ g_autofree char *name = NULL;
if (VIR_ALLOC(data) < 0)
goto error;
data->cond = priority ? &pool->prioCond : &pool->cond;
data->priority = priority;
+ if (priority)
+ name = g_strdup_printf("prio-%s", pool->jobName);
+ else
+ name = g_strdup(pool->jobName);
+
if (virThreadCreateFull(&(*workers)[i],
false,
virThreadPoolWorker,
- pool->jobFuncName,
+ name,
true,
data) < 0) {
VIR_FREE(data);
size_t maxWorkers,
size_t prioWorkers,
virThreadPoolJobFunc func,
- const char *funcName,
+ const char *name,
void *opaque)
{
virThreadPoolPtr pool;
pool->jobList.tail = pool->jobList.head = NULL;
pool->jobFunc = func;
- pool->jobFuncName = funcName;
+ pool->jobName = name;
pool->jobOpaque = opaque;
if (virMutexInit(&pool->mutex) < 0)
size_t maxWorkers,
size_t prioWorkers,
virThreadPoolJobFunc func,
- const char *funcName,
+ const char *name,
void *opaque) ATTRIBUTE_NONNULL(4);
size_t virThreadPoolGetMinWorkers(virThreadPoolPtr pool);