]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: gpu: Get pid without binary validation
authorVasiliy Ulyanov <vulyanov@suse.de>
Wed, 2 Feb 2022 16:28:17 +0000 (17:28 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 4 Feb 2022 09:27:43 +0000 (10:27 +0100)
The binary validation in virPidFileReadPathIfAlive may fail with EACCES
if the calling process does not have CAP_SYS_PTRACE capability.
Therefore instead do only the check that the pidfile is locked by the
correct process.

Fixes the same issue as with swtpm.

Signed-off-by: Vasiliy Ulyanov <vulyanov@suse.de>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_vhost_user_gpu.c

index ef198a4820d8792e412052da1a74ab4e3b187378..f7d444e8515113c522abd5e4fcc603762e9d1228 100644 (file)
@@ -54,7 +54,6 @@ qemuVhostUserGPUCreatePidFilename(const char *stateDir,
 
 /*
  * qemuVhostUserGPUGetPid:
- * @binpath: path of executable associated with the pidfile
  * @stateDir: the directory where vhost-user-gpu writes the pidfile into
  * @shortName: short name of the domain
  * @alias: video device alias
@@ -65,8 +64,7 @@ qemuVhostUserGPUCreatePidFilename(const char *stateDir,
  * set to -1;
  */
 static int
-qemuVhostUserGPUGetPid(const char *binPath,
-                       const char *stateDir,
+qemuVhostUserGPUGetPid(const char *stateDir,
                        const char *shortName,
                        const char *alias,
                        pid_t *pid)
@@ -76,7 +74,7 @@ qemuVhostUserGPUGetPid(const char *binPath,
     if (!(pidfile = qemuVhostUserGPUCreatePidFilename(stateDir, shortName, alias)))
         return -1;
 
-    if (virPidFileReadPathIfAlive(pidfile, pid, binPath) < 0)
+    if (virPidFileReadPathIfLocked(pidfile, pid) < 0)
         return -1;
 
     return 0;
@@ -253,8 +251,7 @@ qemuExtVhostUserGPUSetupCgroup(virQEMUDriver *driver,
     if (!shortname)
         return -1;
 
-    rc = qemuVhostUserGPUGetPid(video->driver->vhost_user_binary,
-                                cfg->stateDir, shortname, video->info.alias, &pid);
+    rc = qemuVhostUserGPUGetPid(cfg->stateDir, shortname, video->info.alias, &pid);
     if (rc < 0 || (rc == 0 && pid == (pid_t)-1)) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Could not get process id of vhost-user-gpu"));