提交 9de5d69c 编写于 作者: J Ján Tomko

qemu: put virtiofsd in the emulator cgroup

Wire up the code to put virtiofsd in the emulator cgroup on domain
startup.
Signed-off-by: NJán Tomko <jtomko@redhat.com>
Reviewed-by: NPeter Krempa <pkrempa@redhat.com>
Tested-by: NAndrea Bolognani <abologna@redhat.com>
上级 f0f986ef
......@@ -248,6 +248,13 @@ qemuExtDevicesHasDevice(virDomainDefPtr def)
if (def->tpm && def->tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR)
return true;
for (i = 0; i < def->nfss; i++) {
virDomainFSDefPtr fs = def->fss[i];
if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS)
return true;
}
return false;
}
......@@ -272,5 +279,13 @@ qemuExtDevicesSetupCgroup(virQEMUDriverPtr driver,
qemuExtTPMSetupCgroup(driver, def, cgroup) < 0)
return -1;
for (i = 0; i < def->nfss; i++) {
virDomainFSDefPtr fs = def->fss[i];
if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS &&
qemuVirtioFSSetupCgroup(vm, fs, cgroup) < 0)
return -1;
}
return 0;
}
......@@ -299,3 +299,29 @@ qemuVirtioFSStop(virQEMUDriverPtr driver G_GNUC_UNUSED,
cleanup:
virErrorRestore(&orig_err);
}
int
qemuVirtioFSSetupCgroup(virDomainObjPtr vm,
virDomainFSDefPtr fs,
virCgroupPtr cgroup)
{
g_autofree char *pidfile = NULL;
pid_t pid = -1;
int rc;
if (!(pidfile = qemuVirtioFSCreatePidFilename(vm, fs->info.alias)))
return -1;
rc = virPidFileReadPathIfAlive(pidfile, &pid, NULL);
if (rc < 0 || pid == (pid_t) -1) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("virtiofsd died unexpectedly"));
return -1;
}
if (virCgroupAddProcess(cgroup, pid) < 0)
return -1;
return 0;
}
......@@ -35,3 +35,8 @@ void
qemuVirtioFSStop(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainFSDefPtr fs);
int
qemuVirtioFSSetupCgroup(virDomainObjPtr vm,
virDomainFSDefPtr fs,
virCgroupPtr cgroup);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册