]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuVirtioFSStop: Simplify daemon kill
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 13 Mar 2020 16:03:10 +0000 (17:03 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 24 Mar 2020 14:54:31 +0000 (15:54 +0100)
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: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
src/qemu/qemu_virtiofs.c

index d9ace4aafed4e9764ef81e3cee80dcc416ba1429..2e239cad66e0e5907e046ffe432993771ce7d47b 100644 (file)
@@ -36,6 +36,8 @@
 
 #define VIR_FROM_THIS VIR_FROM_QEMU
 
+VIR_LOG_INIT("qemu.virtiofs");
+
 
 char *
 qemuVirtioFSCreatePidFilename(virDomainObjPtr vm,
@@ -271,28 +273,19 @@ qemuVirtioFSStop(virQEMUDriverPtr driver G_GNUC_UNUSED,
 {
     g_autofree char *pidfile = NULL;
     virErrorPtr orig_err;
-    pid_t pid = -1;
-    int rc;
 
     virErrorPreserveLast(&orig_err);
 
     if (!(pidfile = qemuVirtioFSCreatePidFilename(vm, fs->info.alias)))
         goto cleanup;
 
-    rc = virPidFileReadPathIfAlive(pidfile, &pid, NULL);
-    if (rc >= 0 && pid != (pid_t) -1)
-        virProcessKillPainfully(pid, true);
-
-    if (unlink(pidfile) < 0 &&
-        errno != ENOENT) {
-        virReportSystemError(errno,
-                             _("Unable to remove stale pidfile %s"),
-                             pidfile);
+    if (virPidFileForceCleanupPath(pidfile) < 0) {
+        VIR_WARN("Unable to kill virtiofsd process");
+    } else {
+        if (QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock)
+            unlink(QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock);
     }
 
-    if (QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock)
-        unlink(QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock);
-
  cleanup:
     virErrorRestore(&orig_err);
 }