qemu: gpu: Get pid without binary validation

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>
This commit is contained in:
Vasiliy Ulyanov 2022-02-02 17:28:17 +01:00 committed by Michal Privoznik
parent a9c500d2b5
commit e3dfa52d26

View 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"));