From nobody Mon Feb 9 10:25:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 15300278821361014.770233095416; Tue, 26 Jun 2018 08:44:42 -0700 (PDT) Received: from localhost ([::1]:53492 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXq8w-0002cY-Am for importer@patchew.org; Tue, 26 Jun 2018 11:44:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34311) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXq57-0008Ni-C8 for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:40:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXq54-0005db-A0 for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:40:37 -0400 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:45951) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fXq54-0005dE-3y for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:40:34 -0400 Received: by mail-wr0-x241.google.com with SMTP id u7-v6so2464136wrn.12 for ; Tue, 26 Jun 2018 08:40:33 -0700 (PDT) Received: from donizetti.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id y129-v6sm2308490wmy.4.2018.06.26.08.40.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jun 2018 08:40:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=96biIez6FAxOL31AY4N49qv0/0Av9Z2JUgt5p2MySOM=; b=oEaXfg9mnxCK75Q0dkNfIMDG/8g5P4B/LzVmJAP8J8gW2XjfBkYaBT0vsLxTpLQDg8 knBSVuV39oz2fPY2ZJG5zrlboK66C/PQHC8jzVq0yQLTpJknfGaPI8bNtnqLOlYuqVbP Sqrjc/vUP8KU0nKRB+eaRjhsNXJdTwuhchhC8KtwSK68fjG6d3GtdnInk3XggKpN2mrS r3n5UJeiztqUFewosxC/5ashYqvojEP3SmPSFHuCm8iLQKC39kb2d0SQWN65UV8imktF BeWoPl4frdFFwfhG1MeSOm5ei08n2KCsZF+3Xur70UnUcTjZ0uPxz8djSEEhksLCVcXU 95/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=96biIez6FAxOL31AY4N49qv0/0Av9Z2JUgt5p2MySOM=; b=X0XI0A86WV6uvFm0kv28iNeGn/qTBYyoAt2s3QaYv84R/dfdVXo81IAMxXpLw1CYEQ TSNgFdytcNCkxDvBmtkH7hnkxucb+ycpffnfjeT4P8tJ06Wq8G0+lLZQLXsQsiaZ7FmM x6tV+TC8ygzU4kCGJLsi0WpbZVOewI0hmll3IgNF0WO8d9zmPhVLjS0ZfqN1EIKZ3Ji8 fA9WLUYDqE1ZSVJeN54nzstY8sCZxh3KsYrv9gy/74DGY5PbccnXft+LFI2OKy1DmshV IBEq+l8G6a1Woqv3W8ix/zaUmV1Z4SAsm1Dcz/d+UdIIwPp8+hjU+0l5pKdLhcjbbuOc KseQ== X-Gm-Message-State: APt69E3eUV9KtRAG5N8SF4g2cW98bM0uO3/cQcB4zcE81nj4ciwUSpmB 1V4XuJx0Hw4MPvyfQuUDRezzOXKy X-Google-Smtp-Source: AAOMgpe2j/z2NNPTqFeidV3bUd3TQXh/ORgIUoFEKMP75bsnUv3e3Jy17pbKAWQtmax8b1zQK6UqYQ== X-Received: by 2002:adf:f50f:: with SMTP id q15-v6mr1836607wro.241.1530027632758; Tue, 26 Jun 2018 08:40:32 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 26 Jun 2018 17:40:24 +0200 Message-Id: <20180626154028.11133-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626154028.11133-1-pbonzini@redhat.com> References: <20180626154028.11133-1-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PATCH 1/5] pr-helper: fix --socket-path default in help X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mprivozn@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Currently --help shows "(default '(null)')" for the -k/--socket-path option. Fix it by getting the default path in /var/run. Signed-off-by: Paolo Bonzini Reviewed-by: Michal Privoznik Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- scsi/qemu-pr-helper.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c index d0f83176e1..4057cf355c 100644 --- a/scsi/qemu-pr-helper.c +++ b/scsi/qemu-pr-helper.c @@ -74,8 +74,16 @@ static int uid =3D -1; static int gid =3D -1; #endif =20 +static void compute_default_paths(void) +{ + if (!socket_path) { + socket_path =3D qemu_get_local_state_pathname("run/qemu-pr-helper.= sock"); + } +} + static void usage(const char *name) { + compute_default_paths(); (printf) ( "Usage: %s [OPTIONS] FILE\n" "Persistent Reservation helper program for QEMU\n" @@ -845,13 +853,6 @@ static const char *socket_activation_validate_opts(voi= d) return NULL; } =20 -static void compute_default_paths(void) -{ - if (!socket_path) { - socket_path =3D qemu_get_local_state_pathname("run/qemu-pr-helper.= sock"); - } -} - static void termsig_handler(int signum) { atomic_cmpxchg(&state, RUNNING, TERMINATE); --=20 2.17.1 From nobody Mon Feb 9 10:25:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530027891099839.4026075874831; Tue, 26 Jun 2018 08:44:51 -0700 (PDT) Received: from localhost ([::1]:53493 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXq9C-0002rw-BI for importer@patchew.org; Tue, 26 Jun 2018 11:44:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34309) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXq57-0008Ng-BG for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:40:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXq55-0005e2-G6 for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:40:37 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:39511) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fXq55-0005dj-8Y for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:40:35 -0400 Received: by mail-wm0-x242.google.com with SMTP id p11-v6so2326108wmc.4 for ; Tue, 26 Jun 2018 08:40:35 -0700 (PDT) Received: from donizetti.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id y129-v6sm2308490wmy.4.2018.06.26.08.40.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jun 2018 08:40:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=DzC6uCTcx4CCx2z6nGcG134Pqn0i9bF9cO9eJKhbPpU=; b=HQhDXDhlf5f8eEi+LFVqwNuVjIFyTsXjhmbzyRDOfrqumdMfxBN8BB8CJZ2A7vBCwt HC5bvuegQomRFIF2Y1n2YKWkJRYg8hn18mF+Cxi/uwziHdwFdxtNhyfbhxfDxIo3LrWV 1P7jT27q3vhuUH5lki6HZ6xbzfn+Q7tegmQgt0J42c+1avOFeH4N470HECusoG+5UNyV PpbZcWcD1cgafhwq/SaJpWwYRjnP0X749xupUGJwx+WgNB97F3nCjjThpDKFtxs/xuMS Y4T0MVpSQ31brMtPxEIBZ+el9dAucSeNFW8+dmGFim6zUgd5tEY8h0s6cOVtyTOPuvdq EkiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=DzC6uCTcx4CCx2z6nGcG134Pqn0i9bF9cO9eJKhbPpU=; b=LXL1xU5nw/Dpvy9jqQLzBfzTgklyC2KHtR5JyKcsmSV4q1LZOUvdDRK7skHNbpTxf3 ScyiqTtfyl0/BU+NGGEeTjFI/iC++UflCrW8kbWkSnbncEJ2Ncnq+Z4+Ld23By2lwzYn Zu42wb20pYW7bQMB9qH3TPW1Apc3EbH7I9G1ji4o+uBwRboh9zSIXzV5qdzMYwuan9ik HPYtDSwpfdGSRwmolCxwxINbivqJJEVr6vjsr2fjz1byx27mrqByZ2IFEur5105SxZPa soxjPnFDe+Vo1NHwbVI/rX+MzsYcme4Ayqohncv5Xj3Rb7M5kWjQYJIY67nq+b1NNHhm /tkA== X-Gm-Message-State: APt69E1jh5AZisU7pCaXy3NvC8vbjjXp7LF+DlD0X7Jw0yQhydzi/vDW /FtDtVvCPFrEyDkQgro+omWy7dYk X-Google-Smtp-Source: AAOMgpdXZCtgUBD5JCVHjz5V8RqWgjs8JhxiJ2xygcAzhKyo9UUuoyMq5AR2Qlq/9AONTqG0YKdNPg== X-Received: by 2002:a1c:387:: with SMTP id 129-v6mr2069141wmd.53.1530027633814; Tue, 26 Jun 2018 08:40:33 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 26 Jun 2018 17:40:25 +0200 Message-Id: <20180626154028.11133-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626154028.11133-1-pbonzini@redhat.com> References: <20180626154028.11133-1-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PATCH 2/5] pr-helper: fix assertion failure on failed multipath PERSISTENT RESERVE IN X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mprivozn@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The response size is expected to be zero if the SCSI status is not "GOOD", but nothing was resetting it. This can be reproduced simply by "sg_persist -s /dev/sdb" where /dev/sdb in the guest is a scsi-block device corresponding to a multipath device on the host. Before: PR in (Read full status): Aborted command and on the host: prh_write_response: Assertion `resp->sz =3D=3D 0' failed. After: PR in (Read full status): bad field in cdb or parameter list (perhaps unsupported service action) Reported-by: Jiri Belka Signed-off-by: Paolo Bonzini Reviewed-by: Michal Privoznik Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- scsi/qemu-pr-helper.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c index 4057cf355c..0218d65bbf 100644 --- a/scsi/qemu-pr-helper.c +++ b/scsi/qemu-pr-helper.c @@ -558,7 +558,11 @@ static int do_pr_in(int fd, const uint8_t *cdb, uint8_= t *sense, #ifdef CONFIG_MPATH if (is_mpath(fd)) { /* multipath_pr_in fills the whole input buffer. */ - return multipath_pr_in(fd, cdb, sense, data, *resp_sz); + int r =3D multipath_pr_in(fd, cdb, sense, data, *resp_sz); + if (r !=3D GOOD) { + *resp_sz =3D 0; + } + return r; } #endif =20 --=20 2.17.1 From nobody Mon Feb 9 10:25:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530027987219827.8716963497151; Tue, 26 Jun 2018 08:46:27 -0700 (PDT) Received: from localhost ([::1]:53506 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXqAk-0004Sb-Fd for importer@patchew.org; Tue, 26 Jun 2018 11:46:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34314) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXq57-0008Nl-DU for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:40:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXq56-0005eV-Al for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:40:37 -0400 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:40361) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fXq56-0005e6-32 for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:40:36 -0400 Received: by mail-wr0-x241.google.com with SMTP id g18-v6so17734564wro.7 for ; Tue, 26 Jun 2018 08:40:35 -0700 (PDT) Received: from donizetti.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id y129-v6sm2308490wmy.4.2018.06.26.08.40.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jun 2018 08:40:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=fTipQ78m3ZW8pWlMHJPp+9G7GF/v8QQRPNK3J+DsODw=; b=FdDeQOpJ7GCunXK5dMvAdliRIb2bhMYQ9EEvHgTt49jKOotn871D2GIDRqhfD4StWI 00N+ZMLZePBza9nVK2Bs5WEOz758Rof9NYBh9bjW6FAZM+Tqkcvm80uJEvO332Xtb5Wt KPVmvgycOd90vtaNxjjEHEM6dUFtRYG4DgQxM/h7kUYe1iTH/7aRDFwMXF5MFx1LiglA xuudaw+I0KYdAYsNA6Mh5PlaC6YLrTF4ngM1YzY6XdARLXyuYCDRF/FlcBHJ7idcvkPj dRTFmuctWWT7X57HCK6ov53yVYFlatVKm0k1jXbUc1aO+sQ2l2mvenrjPFec9N31TMvA JdOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=fTipQ78m3ZW8pWlMHJPp+9G7GF/v8QQRPNK3J+DsODw=; b=eQPu24TKamu5zKWhXr/vSWOI2MvPa9FJT6PEPOBnNHNIZcOfS0xtcL7ZePSU3A7AZ1 gUV6WtqW5r58nRKq277d+WNUx+TV0zZFSI2vdaYirFU9/IJeB72Auo3k45v+HIO3RQmg HByI++nBClH5dsrlnB4XxH4YA3m7AA6Eu33G2m7FvcvfObGjpzPxcNzgJ3JmdmJdB8rD Lnyf/sZ6uVN5CC3aL/zETuK69AmMzN3cYk+9VQ2yhiLHBA/WNepde9dbtbfHhLwD4Zxt O8hP20n8nraVXrMSmkX3egr7C/m5OHDu0RTTyKZYX8deM2tgi9VbRYqEhRTjU41GImD+ Z/ow== X-Gm-Message-State: APt69E18I0KZjthi70Owy6Nj18icMKc3aRrJldEhMCCT+Q6uVKbrG3Ib 05L5JhiGkBZLvDQp3J5t0EyJV0gq X-Google-Smtp-Source: AAOMgpcGqpymaHpgwuXF3nNY30CliEMJNB4cnyl3DbcohLYH1vjbA0PBEAIP53wpPvzsh2Zj+hIb9A== X-Received: by 2002:adf:8610:: with SMTP id 16-v6mr1909174wrv.255.1530027634819; Tue, 26 Jun 2018 08:40:34 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 26 Jun 2018 17:40:26 +0200 Message-Id: <20180626154028.11133-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626154028.11133-1-pbonzini@redhat.com> References: <20180626154028.11133-1-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PATCH 3/5] pr-manager-helper: avoid SIGSEGV when writing to the socket fail X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mprivozn@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When writing to the qemu-pr-helper socket failed, the persistent reservation manager was correctly disconnecting the socket, but it did not clear pr_mgr->ioc. So the rest of the code did not know that the socket had been disconnected, accessed pr_mgr->ioc and happily caused a crash. To reproduce, it is enough to stop qemu-pr-helper between QEMU startup and executing e.g. sg_persist -k /dev/sdb. Signed-off-by: Paolo Bonzini Reviewed-by: Michal Privoznik --- scsi/pr-manager-helper.c | 1 + 1 file changed, 1 insertion(+) diff --git a/scsi/pr-manager-helper.c b/scsi/pr-manager-helper.c index 82ff6b6123..0c0fe389b7 100644 --- a/scsi/pr-manager-helper.c +++ b/scsi/pr-manager-helper.c @@ -71,6 +71,7 @@ static int pr_manager_helper_write(PRManagerHelper *pr_mg= r, if (n_written <=3D 0) { assert(n_written !=3D QIO_CHANNEL_ERR_BLOCK); object_unref(OBJECT(pr_mgr->ioc)); + pr_mgr->ioc =3D NULL; return n_written < 0 ? -EINVAL : 0; } =20 --=20 2.17.1 From nobody Mon Feb 9 10:25:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530027746174643.3707077978424; Tue, 26 Jun 2018 08:42:26 -0700 (PDT) Received: from localhost ([::1]:53484 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXq6r-00010G-8S for importer@patchew.org; Tue, 26 Jun 2018 11:42:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXq59-0008PD-1R for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:40:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXq57-0005fa-Qg for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:40:39 -0400 Received: from mail-wr0-x232.google.com ([2a00:1450:400c:c0c::232]:43517) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fXq57-0005el-GE for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:40:37 -0400 Received: by mail-wr0-x232.google.com with SMTP id c5-v6so6578567wrs.10 for ; Tue, 26 Jun 2018 08:40:37 -0700 (PDT) Received: from donizetti.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id y129-v6sm2308490wmy.4.2018.06.26.08.40.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jun 2018 08:40:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=6MGkYy7Cz0pDzxHed6+uAku0acR/2AjxTtOVW41C0y4=; b=o4V4UQu+jN7aaCvqg+0nHPG3CnrYBLzZCzU9SiwLGErdhDK7XVRJoOOSnigh+zyK+Y fY1VZGootvs58rL0Nw4HDSH8ROekErK0Q3ni9QBXxrzNeypcerlqETvOr3pZG6byZQbR BjnSueuUJ2RUhQApQuM+zOt/zJFhYCyalW8aWExzYyFH30V6lqMHHpMmg7MoU9hDnu7r zhE/FLQyQylZV9TknSn1/CuUZn4102KHE7zg42o70MFBjCRAe+cz4wHjNhmF/gwej+kx 93fGd085NJ5a/KojHVGL5S71EglWBa7xKxEd1ZQvbOqrBJN/rqmCHnfP9Mf6XkrSnGDs eA+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=6MGkYy7Cz0pDzxHed6+uAku0acR/2AjxTtOVW41C0y4=; b=WlrxCHUf3sFMOj/Spv4Mo2UwrHIe1f8C3yIdnD6WCwUoM/R4tFWuQ98aanmDTKCmbl ByIRGKPBO3bAcGDx/ZeolUpgwrRXpoqJlZ593hERGz5hOFg6oBrSsl7wAsS6K3mgGr22 La+uEValqg2IsUctqEhZNNlSYqXmtg6qmp/4nPyu1ZjXysrIGoOTCWyKSkJdeXKiOMyK HI0CopCCT+FXMzvONPmxkg/KxKREGOGcNk/aTMWsa0ADwnQ0OOQVSywenFdJw7F4weYy o1kda5krsIBjF2Zz+Yd70jMMxf37Zq23u9f34QZtHweuZ5QEQxMPNAIMQLVYQS4XGfsT 057A== X-Gm-Message-State: APt69E2ekK/G8OvEFY7WVggwTalfgqUaaDJjBYzWtT7MRwGHGy+03NgP HJsEJusEmoEZ0fOObm5YRwF1Buc3 X-Google-Smtp-Source: AAOMgpdubayaGHTAwJe2FhJDG0Ss0oYnKX02YTNnmy/LaDKr6+rOFC92tn5/uhB9cY4B4du14ru0oQ== X-Received: by 2002:a5d:470b:: with SMTP id y11-v6mr1940673wrq.107.1530027636151; Tue, 26 Jun 2018 08:40:36 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 26 Jun 2018 17:40:27 +0200 Message-Id: <20180626154028.11133-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626154028.11133-1-pbonzini@redhat.com> References: <20180626154028.11133-1-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::232 Subject: [Qemu-devel] [PATCH 4/5] pr-manager: add query-pr-managers QMP command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mprivozn@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This command lets you query the connection status of each pr-manager-helper object. Signed-off-by: Paolo Bonzini --- include/scsi/pr-manager.h | 2 ++ qapi/block.json | 27 +++++++++++++++++++++++ scsi/pr-manager-helper.c | 13 +++++++++++ scsi/pr-manager.c | 45 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+) diff --git a/include/scsi/pr-manager.h b/include/scsi/pr-manager.h index 5d2f13a5e4..adadca7954 100644 --- a/include/scsi/pr-manager.h +++ b/include/scsi/pr-manager.h @@ -33,8 +33,10 @@ typedef struct PRManagerClass { =20 /* */ int (*run)(PRManager *pr_mgr, int fd, struct sg_io_hdr *hdr); + bool (*is_connected)(PRManager *pr_mgr); } PRManagerClass; =20 +bool pr_manager_is_connected(PRManager *pr_mgr); BlockAIOCB *pr_manager_execute(PRManager *pr_mgr, AioContext *ctx, int fd, struct sg_io_hdr *hdr, diff --git a/qapi/block.json b/qapi/block.json index c694524002..dc3323c954 100644 --- a/qapi/block.json +++ b/qapi/block.json @@ -77,6 +77,33 @@ { 'struct': 'BlockdevSnapshotInternal', 'data': { 'device': 'str', 'name': 'str' } } =20 +## +# @PRManagerInfo: +# +# Information about a persistent reservation manager +# +# @id: the identifier of the persistent reservation manager +# +# @is-connected: whether the persistent reservation manager is connected to +# the underlying storage or helper +# +# Since: 3.0 +## +{ 'struct': 'PRManagerInfo', + 'data': {'id': 'str', 'is-connected': 'bool'} } + +## +# @query-pr-managers: +# +# Returns a list of information about each persistent reservation manager. +# +# Returns: a list of @PRManagerInfo for each persistent reservation manager +# +# Since: 3.0 +## +{ 'command': 'query-pr-managers', 'returns': ['PRManagerInfo'] } + + ## # @blockdev-snapshot-internal-sync: # diff --git a/scsi/pr-manager-helper.c b/scsi/pr-manager-helper.c index 0c0fe389b7..b11481be9e 100644 --- a/scsi/pr-manager-helper.c +++ b/scsi/pr-manager-helper.c @@ -235,6 +235,18 @@ out: return ret; } =20 +static bool pr_manager_helper_is_connected(PRManager *p) +{ + PRManagerHelper *pr_mgr =3D PR_MANAGER_HELPER(p); + bool result; + + qemu_mutex_lock(&pr_mgr->lock); + result =3D (pr_mgr->ioc !=3D NULL); + qemu_mutex_unlock(&pr_mgr->lock); + + return result; +} + static void pr_manager_helper_complete(UserCreatable *uc, Error **errp) { PRManagerHelper *pr_mgr =3D PR_MANAGER_HELPER(uc); @@ -284,6 +296,7 @@ static void pr_manager_helper_class_init(ObjectClass *k= lass, &error_abort); uc_klass->complete =3D pr_manager_helper_complete; prmgr_klass->run =3D pr_manager_helper_run; + prmgr_klass->is_connected =3D pr_manager_helper_is_connected; } =20 static const TypeInfo pr_manager_helper_info =3D { diff --git a/scsi/pr-manager.c b/scsi/pr-manager.c index 87c45db5d4..b6c3056cc3 100644 --- a/scsi/pr-manager.c +++ b/scsi/pr-manager.c @@ -17,6 +17,10 @@ #include "block/thread-pool.h" #include "scsi/pr-manager.h" #include "trace.h" +#include "qapi/qapi-types-block.h" +#include "qapi/qapi-commands-block.h" + +#define PR_MANAGER_PATH "/objects" =20 typedef struct PRManagerData { PRManager *pr_mgr; @@ -64,6 +68,14 @@ BlockAIOCB *pr_manager_execute(PRManager *pr_mgr, data, complete, opaque); } =20 +bool pr_manager_is_connected(PRManager *pr_mgr) +{ + PRManagerClass *pr_mgr_class =3D + PR_MANAGER_GET_CLASS(pr_mgr); + + return !pr_mgr_class->is_connected || pr_mgr_class->is_connected(pr_mg= r); +} + static const TypeInfo pr_manager_info =3D { .parent =3D TYPE_OBJECT, .name =3D TYPE_PR_MANAGER, @@ -105,5 +117,38 @@ pr_manager_register_types(void) type_register_static(&pr_manager_info); } =20 +static int query_one_pr_manager(Object *object, void *opaque) +{ + PRManagerInfoList ***prev =3D opaque; + PRManagerInfoList *elem; + PRManagerInfo *info; + PRManager *pr_mgr; + + pr_mgr =3D (PRManager *)object_dynamic_cast(object, TYPE_PR_MANAGER); + if (!pr_mgr) { + return 0; + } + + elem =3D g_new0(PRManagerInfoList, 1); + info =3D g_new0(PRManagerInfo, 1); + info->id =3D object_get_canonical_path_component(object); + info->is_connected =3D pr_manager_is_connected(pr_mgr); + elem->value =3D info; + elem->next =3D NULL; + + **prev =3D elem; + *prev =3D &elem->next; + return 0; +} + +PRManagerInfoList *qmp_query_pr_managers(Error **errp) +{ + PRManagerInfoList *head =3D NULL; + PRManagerInfoList **prev =3D &head; + Object *container =3D container_get(object_get_root(), PR_MANAGER_PATH= ); + + object_child_foreach(container, query_one_pr_manager, &prev); + return head; +} =20 type_init(pr_manager_register_types); --=20 2.17.1 From nobody Mon Feb 9 10:25:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15300278995411010.8522476197853; Tue, 26 Jun 2018 08:44:59 -0700 (PDT) Received: from localhost ([::1]:53495 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXq9K-0002yd-O3 for importer@patchew.org; Tue, 26 Jun 2018 11:44:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34357) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXq5A-0008Qe-7g for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:40:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXq59-0005g1-3i for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:40:40 -0400 Received: from mail-wr0-x231.google.com ([2a00:1450:400c:c0c::231]:42318) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fXq58-0005fi-Sp for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:40:39 -0400 Received: by mail-wr0-x231.google.com with SMTP id p1-v6so2144900wrs.9 for ; Tue, 26 Jun 2018 08:40:38 -0700 (PDT) Received: from donizetti.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id y129-v6sm2308490wmy.4.2018.06.26.08.40.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jun 2018 08:40:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Rdq2ZWzUUibrViMPIPeu4P/dV3V6oKeCkCyS1NxEGH4=; b=ClNvB26yvpKl5tRhHHSg+0Qv5ZFhBS7aTOQAtu6riCNUO/Sx3TGh6liXZxaFnzsm13 V+ZWDsrkBmZbtY7k8wcVUA/yA2SU5V80hEqocXHGMnhR1Tp3Q3wz0U8u7ed6tX6eFmBE V4Dsfh3htb9cKyrpCiyEsvnBs5VGZ2KnnylIlmxK6W/8ngmc26QJWqEEMOuN2U1NRIwE qs4wovjrGzM+GUW9LkaVbOujdXeKPT3gcATYZyTI6hfLLB8bh3QkWiDyTHM8a7eDnF2h RyWfS9fUrvljW/Kl8nTRar34n1eDMAr323iGZwuVcxEKY98bS9zl/xRXSnbnniMFNRHe dCTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Rdq2ZWzUUibrViMPIPeu4P/dV3V6oKeCkCyS1NxEGH4=; b=kQ3CxckV55vqh48ZB13xv2YItzSkYbWTXJ+8snb4tLbBy+uz5qujaHEqV3aeozdfCU ipauDVIIngK3Wez1e5BUPC+TQBznSJhy/g1Bcm+6mw++KwICkXpUq0f3iB04tk7oDGif ilVDfit7S+wtkSJSEJ6FU4Gxw+FiKrlb2/IgyoX47lPQzhuDX0oCJ0lGj6d1QTMIGv5E kHt/5mYU6fTVltOR+pOPj7aOXUr0gOXepMAvfubpAIz54F3H3C54DMYY8EdbfLIo50+F o0XizEYLaEGa36jLiLvVJZFBYY2WcaHJx97FkkWlLkqtMrLYL3CWoYP23IlbD/K3EhzC +gww== X-Gm-Message-State: APt69E0xG3T53peqQ70c/aqtCeeZLeM5BrsKxyBl4lrkhP2UNG5h+brN YCCo4w+DVW1Rr4b62yEKwqxIi4FT X-Google-Smtp-Source: AAOMgpfRQ1o1Kv/ga5/GJxf55TUWrXNcW+pzGcLcnxkCWIhI3BqUHPxZXYFrXACkbXe3rjQvpr29sA== X-Received: by 2002:adf:e94a:: with SMTP id m10-v6mr1980155wrn.126.1530027637530; Tue, 26 Jun 2018 08:40:37 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 26 Jun 2018 17:40:28 +0200 Message-Id: <20180626154028.11133-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626154028.11133-1-pbonzini@redhat.com> References: <20180626154028.11133-1-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::231 Subject: [Qemu-devel] [PATCH 5/5] pr-manager-helper: report event on connection/disconnection X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mprivozn@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Let management know if there were any problems communicating with qemu-pr-helper. The event is edge-triggered, and is sent every time the connection status of the pr-manager-helper object changes. Signed-off-by: Paolo Bonzini --- qapi/block.json | 24 ++++++++++++++++++++++++ scsi/pr-manager-helper.c | 25 +++++++++++++++++++------ 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/qapi/block.json b/qapi/block.json index dc3323c954..1882a8d107 100644 --- a/qapi/block.json +++ b/qapi/block.json @@ -334,6 +334,30 @@ { 'event': 'DEVICE_TRAY_MOVED', 'data': { 'device': 'str', 'id': 'str', 'tray-open': 'bool' } } =20 +## +# @PR_MANAGER_STATUS_CHANGED: +# +# Emitted whenever the connected status of a persistent reservation +# manager changes. +# +# @id: The QOM path of the PR manager object +# +# @connected: true if the PR manager is connected to a backend +# +# Since: 2.12 +# +# Example: +# +# <- { "event": "PR_MANAGER_STATUS_CHANGED", +# "data": { "id": "/object/pr-helper0", +# "connected": true +# }, +# "timestamp": { "seconds": 1519840375, "microseconds": 450486 } } +# +## +{ 'event': 'PR_MANAGER_STATUS_CHANGED', + 'data': { 'id': 'str', 'connected': 'bool' } } + ## # @QuorumOpType: # diff --git a/scsi/pr-manager-helper.c b/scsi/pr-manager-helper.c index b11481be9e..6643caf4cf 100644 --- a/scsi/pr-manager-helper.c +++ b/scsi/pr-manager-helper.c @@ -17,6 +17,7 @@ #include "io/channel.h" #include "io/channel-socket.h" #include "pr-helper.h" +#include "qapi/qapi-events-block.h" =20 #include =20 @@ -33,6 +34,7 @@ typedef struct PRManagerHelper { PRManager parent; =20 char *path; + char *qom_path; =20 QemuMutex lock; QIOChannel *ioc; @@ -127,6 +129,8 @@ static int pr_manager_helper_initialize(PRManagerHelper= *pr_mgr, goto out_close; } =20 + qapi_event_send_pr_manager_status_changed(pr_mgr->qom_path, true, + &error_abort); return 0; =20 out_close: @@ -142,9 +146,11 @@ static int pr_manager_helper_run(PRManager *p, =20 uint32_t len; PRHelperResponse resp; + int sense_len; int ret; int expected_dir; int attempts; + bool was_connected =3D pr_mgr->ioc !=3D NULL; uint8_t cdb[PR_HELPER_CDB_SIZE] =3D { 0 }; =20 if (!io_hdr->cmd_len || io_hdr->cmd_len > PR_HELPER_CDB_SIZE) { @@ -222,15 +228,19 @@ static int pr_manager_helper_run(PRManager *p, io_hdr->sb_len_wr =3D MIN(io_hdr->mx_sb_len, PR_HELPER_SENSE_SIZE); memcpy(io_hdr->sbp, resp.sense, io_hdr->sb_len_wr); } + qemu_mutex_unlock(&pr_mgr->lock); + return ret; =20 out: - if (ret < 0) { - int sense_len =3D scsi_build_sense(io_hdr->sbp, - SENSE_CODE(LUN_COMM_FAILURE)); - io_hdr->driver_status =3D SG_ERR_DRIVER_SENSE; - io_hdr->sb_len_wr =3D MIN(io_hdr->mx_sb_len, sense_len); - io_hdr->status =3D CHECK_CONDITION; + if (was_connected) { + qapi_event_send_pr_manager_status_changed(pr_mgr->qom_path, false, + &error_abort); } + + sense_len =3D scsi_build_sense(io_hdr->sbp, SENSE_CODE(LUN_COMM_FAILUR= E)); + io_hdr->driver_status =3D SG_ERR_DRIVER_SENSE; + io_hdr->sb_len_wr =3D MIN(io_hdr->mx_sb_len, sense_len); + io_hdr->status =3D CHECK_CONDITION; qemu_mutex_unlock(&pr_mgr->lock); return ret; } @@ -251,6 +261,8 @@ static void pr_manager_helper_complete(UserCreatable *u= c, Error **errp) { PRManagerHelper *pr_mgr =3D PR_MANAGER_HELPER(uc); =20 + pr_mgr->qom_path =3D object_get_canonical_path(OBJECT(pr_mgr)); + qemu_mutex_lock(&pr_mgr->lock); pr_manager_helper_initialize(pr_mgr, errp); qemu_mutex_unlock(&pr_mgr->lock); @@ -276,6 +288,7 @@ static void pr_manager_helper_instance_finalize(Object = *obj) PRManagerHelper *pr_mgr =3D PR_MANAGER_HELPER(obj); =20 object_unref(OBJECT(pr_mgr->ioc)); + g_free(pr_mgr->qom_path); qemu_mutex_destroy(&pr_mgr->lock); } =20 --=20 2.17.1