1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

qemu: Enable SCHED_CORE for helper processes

For QEMU_SCHED_CORE_FULL case, all helper processes should be
placed into the same scheduling group as the QEMU process they
serve. It may happen though, that a helper process is started
before QEMU (cold start of a domain). But we have the dummy
process running from which the QEMU process will inherit the
scheduling group, so we can use the dummy process PID as an
argument to virCommandSetRunAmong().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Michal Privoznik 2022-08-11 16:12:24 +02:00
parent 279527334d
commit 000477115e
3 changed files with 31 additions and 0 deletions

View File

@ -2848,6 +2848,15 @@ qemuProcessStartManagedPRDaemon(virDomainObj *vm)
* qemu (so that it shares the same view of the system). */
virCommandSetPreExecHook(cmd, qemuProcessStartPRDaemonHook, vm);
if (cfg->schedCore == QEMU_SCHED_CORE_FULL) {
pid_t cookie_pid = vm->pid;
if (cookie_pid <= 0)
cookie_pid = priv->schedCoreChildPID;
virCommandSetRunAmong(cmd, cookie_pid);
}
if (virCommandRun(cmd, NULL) < 0)
goto cleanup;

View File

@ -683,6 +683,9 @@ qemuSecurityCommandRun(virQEMUDriver *driver,
int *exitstatus,
int *cmdret)
{
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
qemuDomainObjPrivate *priv = vm->privateData;
if (virSecurityManagerSetChildProcessLabel(driver->securityManager,
vm->def, cmd) < 0)
return -1;
@ -691,6 +694,14 @@ qemuSecurityCommandRun(virQEMUDriver *driver,
virCommandSetUID(cmd, uid);
if (gid != (gid_t) -1)
virCommandSetGID(cmd, gid);
if (cfg->schedCore == QEMU_SCHED_CORE_FULL) {
pid_t pid = vm->pid;
if (pid <= 0)
pid = priv->schedCoreChildPID;
virCommandSetRunAmong(cmd, pid);
}
if (virSecurityManagerPreFork(driver->securityManager) < 0)
return -1;

View File

@ -178,6 +178,7 @@ qemuVirtioFSStart(virQEMUDriver *driver,
virDomainFSDef *fs)
{
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
qemuDomainObjPrivate *priv = vm->privateData;
g_autoptr(virCommand) cmd = NULL;
g_autofree char *socket_path = NULL;
g_autofree char *pidfile = NULL;
@ -251,6 +252,16 @@ qemuVirtioFSStart(virQEMUDriver *driver,
virCommandNonblockingFDs(cmd);
virCommandDaemonize(cmd);
if (cfg->schedCore == QEMU_SCHED_CORE_FULL) {
pid_t cookie_pid = vm->pid;
if (cookie_pid <= 0)
cookie_pid = priv->schedCoreChildPID;
virCommandSetRunAmong(cmd, cookie_pid);
}
if (qemuExtDeviceLogCommand(driver, vm, cmd, "virtiofsd") < 0)
goto error;