From nobody Sat May 18 23:44:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1604984739; cv=none; d=zohomail.com; s=zohoarc; b=AsUCQ8ZheofbHJgWvcp11+8XSagIVsGbPsq05NDOEF9lExGbEfNNP8bkYaQfkKeL365D+Bw7qlxzIwIg4cd0vkLunpuRXw7TmPNi1CUASRwuH/F6VnYl+PlUfXU+L2wtmv6EK5aN+NQCGVD7ja/Q3TvKyoaK8EiLZRgbI4R+OpE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604984739; h=Content-Type:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=6YcsqN3QdfnTxkyV2BwCfiglmxmdt1FpN3mP9mmTTHQ=; b=Wv1+vUEENZIXlgGaCVjiys+0o+qeelGmf8KcnBYX4i6ENSUUDU2jt1fL1tnopgHk6BoqqpIIrSoMHtdvDjLTOFRowuUKuNNCx6VukX5iyJ+jdl+c8tCd3MM/uxL5KYCtGemqru4rMZhzOse03a9RLplgAWQ7OnJPmFfxFyMMrn0= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1604984739555163.31874467320586; Mon, 9 Nov 2020 21:05:39 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-412-UsUXyYAvPam-YSFO2ivCzw-1; Tue, 10 Nov 2020 00:05:35 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BEE041074655; Tue, 10 Nov 2020 05:05:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8998D10027AB; Tue, 10 Nov 2020 05:05:24 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 306D6180C5A2; Tue, 10 Nov 2020 05:05:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0AA54NEa009402 for ; Tue, 10 Nov 2020 00:04:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id D47F22166BCC; Tue, 10 Nov 2020 05:04:23 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CF5AA2166BA4 for ; Tue, 10 Nov 2020 05:04:20 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6AEDE85829F for ; Tue, 10 Nov 2020 05:04:20 +0000 (UTC) Received: from mail-io1-f68.google.com (mail-io1-f68.google.com [209.85.166.68]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-550-bsa2OQraN-mkv_kAqHoGiw-1; Tue, 10 Nov 2020 00:04:17 -0500 Received: by mail-io1-f68.google.com with SMTP id o11so12465720ioo.11 for ; Mon, 09 Nov 2020 21:04:17 -0800 (PST) Received: from localhost (209-6-122-159.s2973.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [209.6.122.159]) by smtp.gmail.com with ESMTPSA id d142sm6852333iof.43.2020.11.09.21.04.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2020 21:04:16 -0800 (PST) X-MC-Unique: UsUXyYAvPam-YSFO2ivCzw-1 X-MC-Unique: bsa2OQraN-mkv_kAqHoGiw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=6YcsqN3QdfnTxkyV2BwCfiglmxmdt1FpN3mP9mmTTHQ=; b=FKXrtitfLdxT9pqLhpX5k7Hf8vANOhgohalev8zLh5dKR2xUsuxWontHZ10fOJ0znm 1TTrfeNavqfYuRnClFB4yx1ZBwK5BsqlsVE/mT/zrsorJ7M7Sl7I+x3+c43XB04NMdHB hVGyfYTYShpjryb6gAXhyE2ryanF/CqkQPBi2EnlBBhx9KuhXw8nV/H+CexOJIP6FLMC 1MR08q0kb9GhLdg2JGE3+BvkgZezYTyYp+fWVJwm2MulIwcb1xRytpVckKBi5FWL1Iln X8027YGjvLwnC9tGbQtUA1QhrE2fCkN/Itlkfo4vgmeR8zddyJFMs6TJc71yMUt4KJSp j6fg== X-Gm-Message-State: AOAM530I9OHB6bQqzjz4MAQQcsJ7Rc0RJu3MxvUpxKv8NSWQXcU9FDMs 9Rsxcsil26uUa0Nw0n9RIJvtEP4vhQ== X-Google-Smtp-Source: ABdhPJzWSCfa48UtADVReoAUbl9A2YqpVbCFX0kXsNTcpEu8MJzPfDYe/hfWu5zX8E+Z6+Yq1aVbHQ== X-Received: by 2002:a05:6638:508:: with SMTP id i8mr13969101jar.5.1604984656744; Mon, 09 Nov 2020 21:04:16 -0800 (PST) From: Masayoshi Mizuma To: libvir-list@redhat.com Subject: [PATCH] qemu: virtiofs: Stop virtiofsd when the qemu guest fails to start Date: Tue, 10 Nov 2020 00:04:00 -0500 Message-Id: <20201110050400.29742-1-msys.mizuma@gmail.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Masayoshi Mizuma , Masayoshi Mizuma X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 2 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Masayoshi Mizuma A qemu guest which has virtiofs config fails to start if the previous starting failed because of invalid option or something. For example of the reproduction: # virsh start guest error: Failed to start domain guest error: internal error: process exited while connecting to monitor: qemu-s= ystem-x86_64: -foo: invalid option ... fix the option ... # virsh start guest error: Failed to start domain guest error: Cannot open log file: '/var/log/libvirt/qemu/guest-fs0-virtiofsd.l= og': Device or resource busy #=20 That's because the virtiofsd which was executed on the former staring remai= ns and virtlogd keeps to opening the log file. Stop virtiofsd when the qemu guest fails to start. Signed-off-by: Masayoshi Mizuma --- src/qemu/qemu_domain.h | 1 + src/qemu/qemu_virtiofs.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index ca041e207b..7d47c030bd 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -426,6 +426,7 @@ struct _qemuDomainFSPrivate { virObject parent; =20 char *vhostuser_fs_sock; + pid_t virtiofsd_pid; }; =20 =20 diff --git a/src/qemu/qemu_virtiofs.c b/src/qemu/qemu_virtiofs.c index 2e239cad66..8684219915 100644 --- a/src/qemu/qemu_virtiofs.c +++ b/src/qemu/qemu_virtiofs.c @@ -250,6 +250,7 @@ qemuVirtioFSStart(virLogManagerPtr logManager, } =20 QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock =3D g_steal_pointer(&soc= ket_path); + QEMU_DOMAIN_FS_PRIVATE(fs)->virtiofsd_pid =3D pid; ret =3D 0; =20 cleanup: @@ -273,6 +274,7 @@ qemuVirtioFSStop(virQEMUDriverPtr driver G_GNUC_UNUSED, { g_autofree char *pidfile =3D NULL; virErrorPtr orig_err; + pid_t pid =3D QEMU_DOMAIN_FS_PRIVATE(fs)->virtiofsd_pid; =20 virErrorPreserveLast(&orig_err); =20 @@ -286,6 +288,9 @@ qemuVirtioFSStop(virQEMUDriverPtr driver G_GNUC_UNUSED, unlink(QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock); } =20 + if (virProcessKill(pid, 0) =3D=3D 0) + virProcessKillPainfully(pid, true); + cleanup: virErrorRestore(&orig_err); } --=20 2.27.0