|
|
d76c62 |
From 6c6f1a32c07941d6fe6208e1ad12dc137dbe7c41 Mon Sep 17 00:00:00 2001
|
|
|
d76c62 |
Message-Id: <6c6f1a32c07941d6fe6208e1ad12dc137dbe7c41@dist-git>
|
|
|
d76c62 |
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
|
|
|
d76c62 |
Date: Wed, 4 Mar 2020 12:42:47 +0100
|
|
|
d76c62 |
Subject: [PATCH] qemu: put virtiofsd in the emulator cgroup
|
|
|
d76c62 |
MIME-Version: 1.0
|
|
|
d76c62 |
Content-Type: text/plain; charset=UTF-8
|
|
|
d76c62 |
Content-Transfer-Encoding: 8bit
|
|
|
d76c62 |
|
|
|
d76c62 |
Wire up the code to put virtiofsd in the emulator cgroup on domain
|
|
|
d76c62 |
startup.
|
|
|
d76c62 |
|
|
|
d76c62 |
Signed-off-by: Ján Tomko <jtomko@redhat.com>
|
|
|
d76c62 |
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
d76c62 |
Tested-by: Andrea Bolognani <abologna@redhat.com>
|
|
|
d76c62 |
(cherry picked from commit 9de5d69c218faa0e25c5d6a56ab5f6bacbd1a132)
|
|
|
d76c62 |
Signed-off-by: Ján Tomko <jtomko@redhat.com>
|
|
|
d76c62 |
https://bugzilla.redhat.com/show_bug.cgi?id=1694166
|
|
|
d76c62 |
Message-Id: <7653ce933656c9a13c9afa2a019ef11fb192bdc4.1583322091.git.jtomko@redhat.com>
|
|
|
d76c62 |
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
d76c62 |
---
|
|
|
d76c62 |
src/qemu/qemu_extdevice.c | 15 +++++++++++++++
|
|
|
d76c62 |
src/qemu/qemu_virtiofs.c | 26 ++++++++++++++++++++++++++
|
|
|
d76c62 |
src/qemu/qemu_virtiofs.h | 5 +++++
|
|
|
d76c62 |
3 files changed, 46 insertions(+)
|
|
|
d76c62 |
|
|
|
d76c62 |
diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c
|
|
|
d76c62 |
index bfa770f45a..f66bafb62f 100644
|
|
|
d76c62 |
--- a/src/qemu/qemu_extdevice.c
|
|
|
d76c62 |
+++ b/src/qemu/qemu_extdevice.c
|
|
|
d76c62 |
@@ -248,6 +248,13 @@ qemuExtDevicesHasDevice(virDomainDefPtr def)
|
|
|
d76c62 |
if (def->tpm && def->tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR)
|
|
|
d76c62 |
return true;
|
|
|
d76c62 |
|
|
|
d76c62 |
+ for (i = 0; i < def->nfss; i++) {
|
|
|
d76c62 |
+ virDomainFSDefPtr fs = def->fss[i];
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS)
|
|
|
d76c62 |
+ return true;
|
|
|
d76c62 |
+ }
|
|
|
d76c62 |
+
|
|
|
d76c62 |
return false;
|
|
|
d76c62 |
}
|
|
|
d76c62 |
|
|
|
d76c62 |
@@ -272,5 +279,13 @@ qemuExtDevicesSetupCgroup(virQEMUDriverPtr driver,
|
|
|
d76c62 |
qemuExtTPMSetupCgroup(driver, def, cgroup) < 0)
|
|
|
d76c62 |
return -1;
|
|
|
d76c62 |
|
|
|
d76c62 |
+ for (i = 0; i < def->nfss; i++) {
|
|
|
d76c62 |
+ virDomainFSDefPtr fs = def->fss[i];
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS &&
|
|
|
d76c62 |
+ qemuVirtioFSSetupCgroup(vm, fs, cgroup) < 0)
|
|
|
d76c62 |
+ return -1;
|
|
|
d76c62 |
+ }
|
|
|
d76c62 |
+
|
|
|
d76c62 |
return 0;
|
|
|
d76c62 |
}
|
|
|
d76c62 |
diff --git a/src/qemu/qemu_virtiofs.c b/src/qemu/qemu_virtiofs.c
|
|
|
d76c62 |
index 09ab2cef27..194855ece8 100644
|
|
|
d76c62 |
--- a/src/qemu/qemu_virtiofs.c
|
|
|
d76c62 |
+++ b/src/qemu/qemu_virtiofs.c
|
|
|
d76c62 |
@@ -299,3 +299,29 @@ qemuVirtioFSStop(virQEMUDriverPtr driver G_GNUC_UNUSED,
|
|
|
d76c62 |
cleanup:
|
|
|
d76c62 |
virErrorRestore(&orig_err);
|
|
|
d76c62 |
}
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+int
|
|
|
d76c62 |
+qemuVirtioFSSetupCgroup(virDomainObjPtr vm,
|
|
|
d76c62 |
+ virDomainFSDefPtr fs,
|
|
|
d76c62 |
+ virCgroupPtr cgroup)
|
|
|
d76c62 |
+{
|
|
|
d76c62 |
+ g_autofree char *pidfile = NULL;
|
|
|
d76c62 |
+ pid_t pid = -1;
|
|
|
d76c62 |
+ int rc;
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ if (!(pidfile = qemuVirtioFSCreatePidFilename(vm, fs->info.alias)))
|
|
|
d76c62 |
+ return -1;
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ rc = virPidFileReadPathIfAlive(pidfile, &pid, NULL);
|
|
|
d76c62 |
+ if (rc < 0 || pid == (pid_t) -1) {
|
|
|
d76c62 |
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
d76c62 |
+ _("virtiofsd died unexpectedly"));
|
|
|
d76c62 |
+ return -1;
|
|
|
d76c62 |
+ }
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ if (virCgroupAddProcess(cgroup, pid) < 0)
|
|
|
d76c62 |
+ return -1;
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ return 0;
|
|
|
d76c62 |
+}
|
|
|
d76c62 |
diff --git a/src/qemu/qemu_virtiofs.h b/src/qemu/qemu_virtiofs.h
|
|
|
d76c62 |
index b2f0c57d0c..1db59917c6 100644
|
|
|
d76c62 |
--- a/src/qemu/qemu_virtiofs.h
|
|
|
d76c62 |
+++ b/src/qemu/qemu_virtiofs.h
|
|
|
d76c62 |
@@ -35,3 +35,8 @@ void
|
|
|
d76c62 |
qemuVirtioFSStop(virQEMUDriverPtr driver,
|
|
|
d76c62 |
virDomainObjPtr vm,
|
|
|
d76c62 |
virDomainFSDefPtr fs);
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+int
|
|
|
d76c62 |
+qemuVirtioFSSetupCgroup(virDomainObjPtr vm,
|
|
|
d76c62 |
+ virDomainFSDefPtr fs,
|
|
|
d76c62 |
+ virCgroupPtr cgroup);
|
|
|
d76c62 |
--
|
|
|
d76c62 |
2.25.1
|
|
|
d76c62 |
|