提交 a8db4dc3 编写于 作者: M Michal Privoznik

qemuVirtioFSStop: Simplify daemon kill

Now, that we know that the virtiofsd will have the pidfile open
and locked we can use virPidFileForceCleanupPath() to kill it and
unlink the pidfile.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
上级 1566be99
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#define VIR_FROM_THIS VIR_FROM_QEMU #define VIR_FROM_THIS VIR_FROM_QEMU
VIR_LOG_INIT("qemu.virtiofs");
char * char *
qemuVirtioFSCreatePidFilename(virDomainObjPtr vm, qemuVirtioFSCreatePidFilename(virDomainObjPtr vm,
...@@ -271,28 +273,19 @@ qemuVirtioFSStop(virQEMUDriverPtr driver G_GNUC_UNUSED, ...@@ -271,28 +273,19 @@ qemuVirtioFSStop(virQEMUDriverPtr driver G_GNUC_UNUSED,
{ {
g_autofree char *pidfile = NULL; g_autofree char *pidfile = NULL;
virErrorPtr orig_err; virErrorPtr orig_err;
pid_t pid = -1;
int rc;
virErrorPreserveLast(&orig_err); virErrorPreserveLast(&orig_err);
if (!(pidfile = qemuVirtioFSCreatePidFilename(vm, fs->info.alias))) if (!(pidfile = qemuVirtioFSCreatePidFilename(vm, fs->info.alias)))
goto cleanup; goto cleanup;
rc = virPidFileReadPathIfAlive(pidfile, &pid, NULL); if (virPidFileForceCleanupPath(pidfile) < 0) {
if (rc >= 0 && pid != (pid_t) -1) VIR_WARN("Unable to kill virtiofsd process");
virProcessKillPainfully(pid, true); } else {
if (QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock)
if (unlink(pidfile) < 0 && unlink(QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock);
errno != ENOENT) {
virReportSystemError(errno,
_("Unable to remove stale pidfile %s"),
pidfile);
} }
if (QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock)
unlink(QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock);
cleanup: cleanup:
virErrorRestore(&orig_err); virErrorRestore(&orig_err);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册