]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Enable SCHED_CORE for helper processes
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 11 Aug 2022 14:12:24 +0000 (16:12 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 20 Oct 2022 07:00:02 +0000 (09:00 +0200)
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>
src/qemu/qemu_process.c
src/qemu/qemu_security.c
src/qemu/qemu_virtiofs.c

index d55686afd1d2ff56319e14fd051e07facb28073b..5ce181fea715dcf052b0635b5b85ed8edd990fee 100644 (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;
 
index 3be1766764a8ae22de5cf8a3cb7863b4e2234ec1..5b7d5f30c2a3535bd44f44d2eb0496d606cede04 100644 (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;
index a04aa08e39df0b0aa7ed494441e505436e16b5f4..cd947bebfd07e8fd2631a15c6064a0e1c3e222d7 100644 (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;