From nobody Tue Nov 4 15:14:11 2025 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530652124344110.91855904935028; Tue, 3 Jul 2018 14:08:44 -0700 (PDT) Received: from localhost ([::1]:42663 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSXT-0002N2-HA for importer@patchew.org; Tue, 03 Jul 2018 17:08:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSJ1-0008Qw-Vk for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faSIw-0000zO-Ld for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:47 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:60442) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faSIw-0000yj-DH for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:42 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w63KnEUj088419 for ; Tue, 3 Jul 2018 16:53:41 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2k0dpa6kfq-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 03 Jul 2018 16:53:41 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 3 Jul 2018 14:53:40 -0600 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 3 Jul 2018 14:53:38 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w63Krbrm4129154 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 3 Jul 2018 13:53:37 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1AB787805C; Tue, 3 Jul 2018 14:53:37 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 01B627805E; Tue, 3 Jul 2018 14:53:37 -0600 (MDT) Received: from localhost (unknown [9.53.92.156]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 3 Jul 2018 14:53:36 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 3 Jul 2018 15:52:08 -0500 X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> References: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18070320-8235-0000-0000-00000DCCCF6A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009303; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01056103; UDB=6.00541729; IPR=6.00834025; MB=3.00021980; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-03 20:53:39 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18070320-8236-0000-0000-000041C0779C Message-Id: <20180703205221.24788-2-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-03_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=897 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807030235 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PULL 01/14] qga: unset frozen state if no mount points are frozen 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: peter.maydell@linaro.org, Chen Hanxiao Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Chen Hanxiao If we set mountpoints to qmp_guest_fsfreeze_freeze_list, we may got nothing to freeze as all mountpoints are not valid. So call ga_unset_frozen in this senario. Also, if we return 0 frozen fs, there is no need to call guest-fsfreeze-thaw. Cc: Michael Roth Signed-off-by: Chen Hanxiao Signed-off-by: Michael Roth --- qga/commands-posix.c | 6 ++++++ qga/qapi-schema.json | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index eae817191b..594d21ef3e 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -1274,6 +1274,12 @@ int64_t qmp_guest_fsfreeze_freeze_list(bool has_moun= tpoints, } =20 free_fs_mount_list(&mounts); + /* We may not issue any FIFREEZE here. + * Just unset ga_state here and ready for the next call. + */ + if (i =3D=3D 0) { + ga_unset_frozen(ga_state); + } return i; =20 error: diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index 17884c7c70..1045cef386 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -435,7 +435,9 @@ # for up to 10 seconds by VSS. # # Returns: Number of file systems currently frozen. On error, all filesyst= ems -# will be thawed. +# will be thawed. If no filesystems are frozen as a result of this call, +# then @guest-fsfreeze-status will remain "thawed" and calling +# @guest-fsfreeze-thaw is not necessary. # # Since: 0.15.0 ## --=20 2.11.0 From nobody Tue Nov 4 15:14:11 2025 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530651540485714.7919743638255; Tue, 3 Jul 2018 13:59:00 -0700 (PDT) Received: from localhost ([::1]:42610 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSNz-0003qE-GN for importer@patchew.org; Tue, 03 Jul 2018 16:58:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSIz-0008QJ-KC for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faSIv-0000yV-Jo for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:45 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:45494 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faSIv-0000yL-EJ for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:41 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w63KnGAw095182 for ; Tue, 3 Jul 2018 16:53:40 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0a-001b2d01.pphosted.com with ESMTP id 2k0dpdpdmg-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 03 Jul 2018 16:53:40 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 3 Jul 2018 14:53:40 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 3 Jul 2018 14:53:38 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w63KrbRd7995858 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 3 Jul 2018 13:53:37 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7C9C57805C; Tue, 3 Jul 2018 14:53:37 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6389C7805E; Tue, 3 Jul 2018 14:53:37 -0600 (MDT) Received: from localhost (unknown [9.53.92.156]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 3 Jul 2018 14:53:37 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 3 Jul 2018 15:52:09 -0500 X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> References: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18070320-0036-0000-0000-00000A0A947B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009303; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01056103; UDB=6.00541730; IPR=6.00834025; MB=3.00021980; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-03 20:53:39 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18070320-0037-0000-0000-000047F959E0 Message-Id: <20180703205221.24788-3-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-03_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807030235 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PULL 02/14] qga: check bytes count read by guest-file-read 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: peter.maydell@linaro.org, Prasad J Pandit , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Prasad J Pandit While reading file content via 'guest-file-read' command, 'qmp_guest_file_read' routine allocates buffer of count+1 bytes. It could overflow for large values of 'count'. Add check to avoid it. Reported-by: Fakhri Zulkifli Signed-off-by: Prasad J Pandit Cc: qemu-stable@nongnu.org Signed-off-by: Michael Roth --- qga/commands-posix.c | 2 +- qga/commands-win32.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 594d21ef3e..9284e71666 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -458,7 +458,7 @@ struct GuestFileRead *qmp_guest_file_read(int64_t handl= e, bool has_count, =20 if (!has_count) { count =3D QGA_READ_COUNT_DEFAULT; - } else if (count < 0) { + } else if (count < 0 || count >=3D UINT32_MAX) { error_setg(errp, "value '%" PRId64 "' is invalid for argument coun= t", count); return NULL; diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 70ee5379f6..73f31fa8c2 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -318,7 +318,7 @@ GuestFileRead *qmp_guest_file_read(int64_t handle, bool= has_count, } if (!has_count) { count =3D QGA_READ_COUNT_DEFAULT; - } else if (count < 0) { + } else if (count < 0 || count >=3D UINT32_MAX) { error_setg(errp, "value '%" PRId64 "' is invalid for argument count", count); return NULL; --=20 2.11.0 From nobody Tue Nov 4 15:14:11 2025 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530651605882273.65403557648165; Tue, 3 Jul 2018 14:00:05 -0700 (PDT) Received: from localhost ([::1]:42613 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSP7-0004mT-7O for importer@patchew.org; Tue, 03 Jul 2018 17:00:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41337) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSJ1-0008Qv-SC for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faSIx-000106-L6 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:47 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:36010) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faSIx-0000zS-CB for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:43 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w63KnBuS069462 for ; Tue, 3 Jul 2018 16:53:42 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2k0dpc66aw-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 03 Jul 2018 16:53:42 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 3 Jul 2018 14:53:41 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 3 Jul 2018 14:53:38 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w63KrbZ3721166 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 3 Jul 2018 13:53:38 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DF5BE78063; Tue, 3 Jul 2018 14:53:37 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C66957805E; Tue, 3 Jul 2018 14:53:37 -0600 (MDT) Received: from localhost (unknown [9.53.92.156]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 3 Jul 2018 14:53:37 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 3 Jul 2018 15:52:10 -0500 X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> References: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18070320-8235-0000-0000-00000DCCCF6B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009303; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01056103; UDB=6.00541729; IPR=6.00834025; MB=3.00021980; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-03 20:53:40 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18070320-8236-0000-0000-000041C0779D Message-Id: <20180703205221.24788-4-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-03_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807030235 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id w63KnBuS069462 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PULL 03/14] qga: add mountpoint usage info to GuestFilesystemInfo 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: peter.maydell@linaro.org, Chen Hanxiao Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Chen Hanxiao This patch adds support for getting the usage of mounted filesystem. The usage of fs stored as used_bytes and total_bytes. It's very useful when we try to monitor guest's filesystem. Cc: Michael Roth Cc: Daniel P. Berrang=C3=A9 Reviewed-by: Eric Blake Signed-off-by: Chen Hanxiao Signed-off-by: Michael Roth --- qga/commands-posix.c | 15 +++++++++++++++ qga/qapi-schema.json | 3 +++ 2 files changed, 18 insertions(+) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 9284e71666..ae8535e497 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -46,6 +46,7 @@ extern char **environ; #include #include #include +#include =20 #ifdef FIFREEZE #define CONFIG_FSFREEZE @@ -1072,6 +1073,8 @@ static GuestFilesystemInfo *build_guest_fsinfo(struct= FsMount *mount, Error **errp) { GuestFilesystemInfo *fs =3D g_malloc0(sizeof(*fs)); + struct statvfs buf; + unsigned long used, nonroot_total, fr_size; char *devpath =3D g_strdup_printf("/sys/dev/block/%u:%u", mount->devmajor, mount->devminor); =20 @@ -1079,7 +1082,19 @@ static GuestFilesystemInfo *build_guest_fsinfo(struc= t FsMount *mount, fs->type =3D g_strdup(mount->devtype); build_guest_fsinfo_for_device(devpath, fs, errp); =20 + if (statvfs(fs->mountpoint, &buf) =3D=3D 0) { + fr_size =3D buf.f_frsize; + used =3D buf.f_blocks - buf.f_bfree; + nonroot_total =3D used + buf.f_bavail; + fs->used_bytes =3D used * fr_size; + fs->total_bytes =3D nonroot_total * fr_size; + + fs->has_total_bytes =3D true; + fs->has_used_bytes =3D true; + } + g_free(devpath); + return fs; } =20 diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index 1045cef386..2df6356b8c 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -848,6 +848,8 @@ # @name: disk name # @mountpoint: mount point path # @type: file system type string +# @used-bytes: file system used bytes (since 3.0) +# @total-bytes: non-root file system total bytes (since 3.0) # @disk: an array of disk hardware information that the volume lies on, # which may be empty if the disk type is not supported # @@ -855,6 +857,7 @@ ## { 'struct': 'GuestFilesystemInfo', 'data': {'name': 'str', 'mountpoint': 'str', 'type': 'str', + '*used-bytes': 'uint64', '*total-bytes': 'uint64', 'disk': ['GuestDiskAddress']} } =20 ## --=20 2.11.0 From nobody Tue Nov 4 15:14:11 2025 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530651358414814.3193360130866; Tue, 3 Jul 2018 13:55:58 -0700 (PDT) Received: from localhost ([::1]:42596 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSL7-0001Ya-Gg for importer@patchew.org; Tue, 03 Jul 2018 16:55:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSIz-0008QO-VX for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faSIx-0000zz-HR for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:45 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:46126 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faSIx-0000zd-Bp for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:43 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w63KnB5D041206 for ; Tue, 3 Jul 2018 16:53:42 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 2k0dp9pc0v-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 03 Jul 2018 16:53:42 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 3 Jul 2018 14:53:42 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 3 Jul 2018 14:53:39 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w63Krcsh10289418 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 3 Jul 2018 13:53:38 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 688C77805E; Tue, 3 Jul 2018 14:53:38 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4CBDE7805C; Tue, 3 Jul 2018 14:53:38 -0600 (MDT) Received: from localhost (unknown [9.53.92.156]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 3 Jul 2018 14:53:38 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 3 Jul 2018 15:52:11 -0500 X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> References: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18070320-0016-0000-0000-000009038D45 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009303; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01056103; UDB=6.00541729; IPR=6.00834026; MB=3.00021980; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-03 20:53:40 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18070320-0017-0000-0000-00003F813A87 Message-Id: <20180703205221.24788-5-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-03_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=984 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807030235 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PULL 04/14] qga-win: add driver path usage to GuestFilesystemInfo 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: peter.maydell@linaro.org, Chen Hanxiao Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Chen Hanxiao This patch adds support for getting the usage of windows driver path. The usage of fs stored as used_bytes and total_bytes. Cc: Michael Roth Signed-off-by: Chen Hanxiao Signed-off-by: Michael Roth --- qga/commands-win32.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 73f31fa8c2..318d760a74 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -670,6 +670,7 @@ static GuestFilesystemInfo *build_guest_fsinfo(char *gu= id, Error **errp) char fs_name[32]; char vol_info[MAX_PATH+1]; size_t len; + uint64_t i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes; GuestFilesystemInfo *fs =3D NULL; =20 GetVolumePathNamesForVolumeName(guid, (LPCH)&mnt, 0, &info_size); @@ -699,10 +700,21 @@ static GuestFilesystemInfo *build_guest_fsinfo(char *= guid, Error **errp) fs_name[sizeof(fs_name) - 1] =3D 0; fs =3D g_malloc(sizeof(*fs)); fs->name =3D g_strdup(guid); + fs->has_total_bytes =3D false; + fs->has_used_bytes =3D false; if (len =3D=3D 0) { fs->mountpoint =3D g_strdup("System Reserved"); } else { fs->mountpoint =3D g_strndup(mnt_point, len); + if (GetDiskFreeSpaceEx(fs->mountpoint, + (PULARGE_INTEGER) & i64FreeBytesToCaller, + (PULARGE_INTEGER) & i64TotalBytes, + (PULARGE_INTEGER) & i64FreeBytes)) { + fs->used_bytes =3D i64TotalBytes - i64FreeBytes; + fs->total_bytes =3D i64TotalBytes; + fs->has_total_bytes =3D true; + fs->has_used_bytes =3D true; + } } fs->type =3D g_strdup(fs_name); fs->disk =3D build_guest_disk_info(guid, errp); --=20 2.11.0 From nobody Tue Nov 4 15:14:11 2025 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530651726508192.14364973287343; Tue, 3 Jul 2018 14:02:06 -0700 (PDT) Received: from localhost ([::1]:42633 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSQz-0006LS-CS for importer@patchew.org; Tue, 03 Jul 2018 17:02:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41293) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSJ0-0008QS-Pq for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faSIy-00010l-Kk for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:46 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:48386 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faSIy-00010P-Fo for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:44 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w63KnBw5132823 for ; Tue, 3 Jul 2018 16:53:43 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0b-001b2d01.pphosted.com with ESMTP id 2k0gcs0cy0-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 03 Jul 2018 16:53:43 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 3 Jul 2018 14:53:43 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 3 Jul 2018 14:53:39 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w63Krc8t12124566 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 3 Jul 2018 13:53:39 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DE6EB7805E; Tue, 3 Jul 2018 14:53:38 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C2BF97805C; Tue, 3 Jul 2018 14:53:38 -0600 (MDT) Received: from localhost (unknown [9.53.92.156]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 3 Jul 2018 14:53:38 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 3 Jul 2018 15:52:12 -0500 X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> References: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18070320-0012-0000-0000-000016869C4B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009303; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01056103; UDB=6.00541730; IPR=6.00834026; MB=3.00021980; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-03 20:53:41 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18070320-0013-0000-0000-0000538B80E1 Message-Id: <20180703205221.24788-6-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-03_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807030235 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx0b-001b2d01.pphosted.com id w63KnBw5132823 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PULL 05/14] test-qga: add trivial tests for some commands 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: peter.maydell@linaro.org, =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD These commands did not get their tests in the original commits: - guest-get-host-name - guest-get-timezone - guest-get-users Trivial tests that mostly only call the commands were added. Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD Reviewed-by: Marc-Andr=C3=A9 Lureau * replace QDECREF() with qobject_unref() Signed-off-by: Michael Roth --- tests/test-qga.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++= ++ 1 file changed, 54 insertions(+) diff --git a/tests/test-qga.c b/tests/test-qga.c index 30c9643257..350f27812a 100644 --- a/tests/test-qga.c +++ b/tests/test-qga.c @@ -854,6 +854,54 @@ static void test_qga_guest_exec_invalid(gconstpointer = fix) qobject_unref(ret); } =20 +static void test_qga_guest_get_host_name(gconstpointer fix) +{ + const TestFixture *fixture =3D fix; + QDict *ret, *val; + + ret =3D qmp_fd(fixture->fd, "{'execute': 'guest-get-host-name'}"); + g_assert_nonnull(ret); + qmp_assert_no_error(ret); + + val =3D qdict_get_qdict(ret, "return"); + g_assert(qdict_haskey(val, "host-name")); + + qobject_unref(ret); +} + +static void test_qga_guest_get_timezone(gconstpointer fix) +{ + const TestFixture *fixture =3D fix; + QDict *ret, *val; + + ret =3D qmp_fd(fixture->fd, "{'execute': 'guest-get-timezone'}"); + g_assert_nonnull(ret); + qmp_assert_no_error(ret); + + /* Make sure there's at least offset */ + val =3D qdict_get_qdict(ret, "return"); + g_assert(qdict_haskey(val, "offset")); + + qobject_unref(ret); +} + +static void test_qga_guest_get_users(gconstpointer fix) +{ + const TestFixture *fixture =3D fix; + QDict *ret; + QList *val; + + ret =3D qmp_fd(fixture->fd, "{'execute': 'guest-get-users'}"); + g_assert_nonnull(ret); + qmp_assert_no_error(ret); + + /* There is not much to test here */ + val =3D qdict_get_qlist(ret, "return"); + g_assert_nonnull(val); + + qobject_unref(ret); +} + static void test_qga_guest_get_osinfo(gconstpointer data) { TestFixture fixture; @@ -946,6 +994,12 @@ int main(int argc, char **argv) test_qga_guest_exec_invalid); g_test_add_data_func("/qga/guest-get-osinfo", &fix, test_qga_guest_get_osinfo); + g_test_add_data_func("/qga/guest-get-host-name", &fix, + test_qga_guest_get_host_name); + g_test_add_data_func("/qga/guest-get-timezone", &fix, + test_qga_guest_get_timezone); + g_test_add_data_func("/qga/guest-get-users", &fix, + test_qga_guest_get_users); =20 ret =3D g_test_run(); =20 --=20 2.11.0 From nobody Tue Nov 4 15:14:11 2025 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530651358421513.1955111021576; Tue, 3 Jul 2018 13:55:58 -0700 (PDT) Received: from localhost ([::1]:42594 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSL4-0001Vz-Oe for importer@patchew.org; Tue, 03 Jul 2018 16:55:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSJ0-0008QP-6H for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faSIy-000113-PB for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:46 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:59186) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faSIy-00010K-Gl for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:44 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w63KnAP7013136 for ; Tue, 3 Jul 2018 16:53:43 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0a-001b2d01.pphosted.com with ESMTP id 2k0dpd6jnq-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 03 Jul 2018 16:53:43 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 3 Jul 2018 14:53:42 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 3 Jul 2018 14:53:40 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w63KrdZ412190198 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 3 Jul 2018 13:53:39 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 60CD978060; Tue, 3 Jul 2018 14:53:39 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 455857805F; Tue, 3 Jul 2018 14:53:39 -0600 (MDT) Received: from localhost (unknown [9.53.92.156]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 3 Jul 2018 14:53:39 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 3 Jul 2018 15:52:13 -0500 X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> References: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18070320-0036-0000-0000-00000A0A947E X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009303; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01056103; UDB=6.00541730; IPR=6.00834025; MB=3.00021980; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-03 20:53:41 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18070320-0037-0000-0000-000047F959E3 Message-Id: <20180703205221.24788-7-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-03_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=872 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807030235 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id w63KnAP7013136 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PULL 06/14] qga/schema: fix documentation for GuestOSInfo 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: peter.maydell@linaro.org, =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD The documentation for kernel-version and kernel-release on Windows was swapped. Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Michael Roth --- qga/qapi-schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index 2df6356b8c..dfbc4a5e32 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -1173,10 +1173,10 @@ # # @kernel-release: # * POSIX: release field returned by uname(2) -# * Windows: version number of the OS +# * Windows: build number of the OS # @kernel-version: # * POSIX: version field returned by uname(2) -# * Windows: build number of the OS +# * Windows: version number of the OS # @machine: # * POSIX: machine field returned by uname(2) # * Windows: one of x86, x86_64, arm, ia64 --=20 2.11.0 From nobody Tue Nov 4 15:14:11 2025 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530651962113908.3326141657743; Tue, 3 Jul 2018 14:06:02 -0700 (PDT) Received: from localhost ([::1]:42654 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSUr-0000f0-HV for importer@patchew.org; Tue, 03 Jul 2018 17:06:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSJ1-0008Qe-I3 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faSIy-00010W-CI for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:47 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:49052 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faSIy-00010L-6T for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:44 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w63KnCv3079645 for ; Tue, 3 Jul 2018 16:53:43 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0b-001b2d01.pphosted.com with ESMTP id 2k0eqakyc2-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 03 Jul 2018 16:53:43 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 3 Jul 2018 14:53:42 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 3 Jul 2018 14:53:40 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w63KrdAI8847818 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 3 Jul 2018 13:53:39 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C93A178060; Tue, 3 Jul 2018 14:53:39 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B0DF67805E; Tue, 3 Jul 2018 14:53:39 -0600 (MDT) Received: from localhost (unknown [9.53.92.156]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 3 Jul 2018 14:53:39 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 3 Jul 2018 15:52:14 -0500 X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> References: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18070320-0004-0000-0000-0000145E564B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009303; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01056103; UDB=6.00541729; IPR=6.00834026; MB=3.00021980; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-03 20:53:42 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18070320-0005-0000-0000-000087F5C3AD Message-Id: <20180703205221.24788-8-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-03_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807030235 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PULL 07/14] qga-win: Fixing msi upgrade disallow in WiX file 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: Bishara AbuHattoum , peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Bishara AbuHattoum Issue: When upgrading qemu-ga using the msi from an old version to a newer one, the upgrade is not allowed by the msi showing this error message "Another version of this product is already installed." BZ# 1536331: https://bugzilla.redhat.com/show_bug.cgi?id=3D1536331 Fix: For the upgrade to be allowed by the msi the WiX file must provide three things: 1. Changing product's Id. (assigning it to "*") 2. Constant product's UpgradeId. (exists) 3. Changing version. (exists) Reference: http://wixtoolset.org/documentation/manual/v3/howtos/updates/maj= or_upgrade.html Signed-off-by: Bishara AbuHattoum Signed-off-by: Michael Roth --- qga/installer/qemu-ga.wxs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qga/installer/qemu-ga.wxs b/qga/installer/qemu-ga.wxs index 5af11627f8..f751a7e9f7 100644 --- a/qga/installer/qemu-ga.wxs +++ b/qga/installer/qemu-ga.wxs @@ -41,7 +41,7 @@ =20 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530651360842278.9910330591458; Tue, 3 Jul 2018 13:56:00 -0700 (PDT) Received: from localhost ([::1]:42598 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSLA-0001bW-47 for importer@patchew.org; Tue, 03 Jul 2018 16:56:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41336) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSJ1-0008Qu-S1 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faSIy-00010s-Lx for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:47 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:59176) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faSIy-00010C-Dv for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:44 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w63KnAuE013156 for ; Tue, 3 Jul 2018 16:53:43 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2k0dpd6jnp-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 03 Jul 2018 16:53:43 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 3 Jul 2018 14:53:42 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 3 Jul 2018 14:53:41 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w63KreNS12124578 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 3 Jul 2018 13:53:40 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4A34378060; Tue, 3 Jul 2018 14:53:40 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2EF4F7805F; Tue, 3 Jul 2018 14:53:40 -0600 (MDT) Received: from localhost (unknown [9.53.92.156]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 3 Jul 2018 14:53:40 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 3 Jul 2018 15:52:15 -0500 X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> References: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18070320-8235-0000-0000-00000DCCCF6C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009303; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01056103; UDB=6.00541729; IPR=6.00834025; MB=3.00021980; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-03 20:53:42 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18070320-8236-0000-0000-000041C077A3 Message-Id: <20180703205221.24788-9-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-03_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=944 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807030235 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id w63KnAuE013156 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PULL 08/14] qemu-ga: make get-fsinfo work over pci bridges 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: peter.maydell@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Marc-Andr=C3=A9 Lureau Iterate over the PCI bridges to lookup the PCI device associated with the block device. This allows to lookup the driver under the following syspath: /sys/devices/pci0000:00/0000:00:02.2/0000:03:00.0/virtio2/block/vda/vda3 It also works with an "old-style" Q35 libvirt hierarchy: root complex -> DMI-PCI bridge -> PCI-PCI bridge -> virtio controller, ex: /sys/devices/pci0000:00/0000:00:03.0/0000:01:01.0/0000:02:01.0/virtio1/bloc= k/vda/vda3 The setup can be reproduced with the following qemu command line (Thanks Marcel for help): qemu-system-x86_64 -M q35 \ -device i82801b11-bridge,id=3Ddmi2pci_bridge,bus=3Dpcie.0 -device pci-bridge,id=3Dpci_bridge,bus=3Ddmi2pci_bridge,addr=3D0x1,chassi= s_nr=3D1 -device virtio-blk-pci,scsi=3Doff,drive=3Ddrive-virtio-disk0,id=3Dvirtio-= disk0,bootindex=3D1,bus=3Dpci_bridge,addr=3D0x1 For consistency with other syspath-related debug messages, replace a \"%s\" in the message with '%s'. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D1567041 Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Laszlo Ersek Signed-off-by: Michael Roth --- qga/commands-posix.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index ae8535e497..7b7c78d85a 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -876,13 +876,28 @@ static void build_guest_fsinfo_for_real_device(char c= onst *syspath, p =3D strstr(syspath, "/devices/pci"); if (!p || sscanf(p + 12, "%*x:%*x/%x:%x:%x.%x%n", pci, pci + 1, pci + 2, pci + 3, &pcilen) < 4) { - g_debug("only pci device is supported: sysfs path \"%s\"", syspath= ); + g_debug("only pci device is supported: sysfs path '%s'", syspath); return; } =20 - driver =3D get_pci_driver(syspath, (p + 12 + pcilen) - syspath, errp); - if (!driver) { - goto cleanup; + p +=3D 12 + pcilen; + while (true) { + driver =3D get_pci_driver(syspath, p - syspath, errp); + if (driver && (g_str_equal(driver, "ata_piix") || + g_str_equal(driver, "sym53c8xx") || + g_str_equal(driver, "virtio-pci") || + g_str_equal(driver, "ahci"))) { + break; + } + + if (sscanf(p, "/%x:%x:%x.%x%n", + pci, pci + 1, pci + 2, pci + 3, &pcilen) =3D=3D = 4) { + p +=3D pcilen; + continue; + } + + g_debug("unsupported driver or sysfs path '%s'", syspath); + return; } =20 p =3D strstr(syspath, "/target"); --=20 2.11.0 From nobody Tue Nov 4 15:14:11 2025 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530651726572161.32733167002232; Tue, 3 Jul 2018 14:02:06 -0700 (PDT) Received: from localhost ([::1]:42634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSR3-0006Ou-Oj for importer@patchew.org; Tue, 03 Jul 2018 17:02:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41273) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSIz-0008QM-P6 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faSIu-0000xu-OC for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:45 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58590) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faSIu-0000wt-FT for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:40 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w63KnBfc013220 for ; Tue, 3 Jul 2018 16:53:38 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 2k0dpd6jkg-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 03 Jul 2018 16:53:37 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 3 Jul 2018 14:53:37 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 3 Jul 2018 14:53:34 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w63KrX2266977994 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 3 Jul 2018 13:53:34 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DDF157805C; Tue, 3 Jul 2018 14:53:33 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C354978060; Tue, 3 Jul 2018 14:53:33 -0600 (MDT) Received: from localhost (unknown [9.53.92.156]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 3 Jul 2018 14:53:33 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 3 Jul 2018 15:52:16 -0500 X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> References: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18070320-0020-0000-0000-00000E396829 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009303; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01056103; UDB=6.00541729; IPR=6.00834026; MB=3.00021980; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-03 20:53:36 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18070320-0021-0000-0000-000062282E4C Message-Id: <20180703205221.24788-10-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-03_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807030235 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PULL 09/14] qga: refactoring qmp_guest_suspend_* functions 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: peter.maydell@linaro.org, Daniel Henrique Barboza Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza To be able to add new suspend mechanisms we need to detach the existing QMP functions from the current implementation specifics. At this moment we have functions such as qmp_guest_suspend_ram calling bios_suspend_mode and guest_suspend passing the pmutils command and arguments as parameters. This patch removes this logic from the QMP functions, moving them to the respective functions that will have to deal with which binary to use. Signed-off-by: Daniel Henrique Barboza Signed-off-by: Michael Roth --- qga/commands-posix.c | 87 +++++++++++++++++++++++++++++++++---------------= ---- 1 file changed, 55 insertions(+), 32 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 7b7c78d85a..bd2c3514d8 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -1474,15 +1474,38 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum,= Error **errp) #define LINUX_SYS_STATE_FILE "/sys/power/state" #define SUSPEND_SUPPORTED 0 #define SUSPEND_NOT_SUPPORTED 1 +#define SUSPEND_MODE_DISK 1 +#define SUSPEND_MODE_RAM 2 +#define SUSPEND_MODE_HYBRID 3 =20 -static void bios_supports_mode(const char *pmutils_bin, const char *pmutil= s_arg, - const char *sysfile_str, Error **errp) +static void bios_supports_mode(int suspend_mode, Error **errp) { Error *local_err =3D NULL; + const char *pmutils_arg, *sysfile_str; + const char *pmutils_bin =3D "pm-is-supported"; char *pmutils_path; pid_t pid; int status; =20 + switch (suspend_mode) { + + case SUSPEND_MODE_DISK: + pmutils_arg =3D "--hibernate"; + sysfile_str =3D "disk"; + break; + case SUSPEND_MODE_RAM: + pmutils_arg =3D "--suspend"; + sysfile_str =3D "mem"; + break; + case SUSPEND_MODE_HYBRID: + pmutils_arg =3D "--suspend-hybrid"; + sysfile_str =3D NULL; + break; + default: + error_setg(errp, "guest suspend mode not supported"); + return; + } + pmutils_path =3D g_find_program_in_path(pmutils_bin); =20 pid =3D fork(); @@ -1559,14 +1582,39 @@ out: g_free(pmutils_path); } =20 -static void guest_suspend(const char *pmutils_bin, const char *sysfile_str, - Error **errp) +static void guest_suspend(int suspend_mode, Error **errp) { Error *local_err =3D NULL; + const char *pmutils_bin, *sysfile_str; char *pmutils_path; pid_t pid; int status; =20 + bios_supports_mode(suspend_mode, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + switch (suspend_mode) { + + case SUSPEND_MODE_DISK: + pmutils_bin =3D "pm-hibernate"; + sysfile_str =3D "disk"; + break; + case SUSPEND_MODE_RAM: + pmutils_bin =3D "pm-suspend"; + sysfile_str =3D "mem"; + break; + case SUSPEND_MODE_HYBRID: + pmutils_bin =3D "pm-suspend-hybrid"; + sysfile_str =3D NULL; + break; + default: + error_setg(errp, "unknown guest suspend mode"); + return; + } + pmutils_path =3D g_find_program_in_path(pmutils_bin); =20 pid =3D fork(); @@ -1629,42 +1677,17 @@ out: =20 void qmp_guest_suspend_disk(Error **errp) { - Error *local_err =3D NULL; - - bios_supports_mode("pm-is-supported", "--hibernate", "disk", &local_er= r); - if (local_err) { - error_propagate(errp, local_err); - return; - } - - guest_suspend("pm-hibernate", "disk", errp); + guest_suspend(SUSPEND_MODE_DISK, errp); } =20 void qmp_guest_suspend_ram(Error **errp) { - Error *local_err =3D NULL; - - bios_supports_mode("pm-is-supported", "--suspend", "mem", &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } - - guest_suspend("pm-suspend", "mem", errp); + guest_suspend(SUSPEND_MODE_RAM, errp); } =20 void qmp_guest_suspend_hybrid(Error **errp) { - Error *local_err =3D NULL; - - bios_supports_mode("pm-is-supported", "--suspend-hybrid", NULL, - &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } - - guest_suspend("pm-suspend-hybrid", NULL, errp); + guest_suspend(SUSPEND_MODE_HYBRID, errp); } =20 static GuestNetworkInterfaceList * --=20 2.11.0 From nobody Tue Nov 4 15:14:11 2025 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530651540868460.5143582029501; Tue, 3 Jul 2018 13:59:00 -0700 (PDT) Received: from localhost ([::1]:42612 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSO4-0003u9-4O for importer@patchew.org; Tue, 03 Jul 2018 16:59:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41265) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSIz-0008QK-Kc for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faSIu-0000xh-K6 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:45 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:60146) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faSIu-0000xD-55 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:40 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w63KnERk088367 for ; Tue, 3 Jul 2018 16:53:39 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0a-001b2d01.pphosted.com with ESMTP id 2k0dpa6kec-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 03 Jul 2018 16:53:38 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 3 Jul 2018 14:53:38 -0600 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 3 Jul 2018 14:53:35 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w63KrYa321954874 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 3 Jul 2018 13:53:34 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5CB547805C; Tue, 3 Jul 2018 14:53:34 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4087D7805E; Tue, 3 Jul 2018 14:53:34 -0600 (MDT) Received: from localhost (unknown [9.53.92.156]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 3 Jul 2018 14:53:34 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 3 Jul 2018 15:52:17 -0500 X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> References: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18070320-0036-0000-0000-00000A0A947A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009303; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01056103; UDB=6.00541730; IPR=6.00834025; MB=3.00021980; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-03 20:53:36 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18070320-0037-0000-0000-000047F959D9 Message-Id: <20180703205221.24788-11-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-03_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807030235 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PULL 10/14] qga: bios_supports_mode: decoupling pm-utils and sys logic 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: peter.maydell@linaro.org, Daniel Henrique Barboza Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza In bios_supports_mode there is a verification to assert if the chosen suspend mode is supported by the pmutils tools and, if not, we see if the Linux sys state files supports it. This verification is done in the same function, one after the other, and it works for now. But, when adding a new suspend mechanism that will not necessarily follow the same return 0 or 1 logic of pmutils, this code will be hard to deal with. This patch decouple the two existing logics into their own functions, pmutils_supports_mode and linux_sys_state_supports_mode, which in turn are used inside bios_support_mode. The existing logic is kept but now it's easier to extend it. Signed-off-by: Daniel Henrique Barboza Signed-off-by: Michael Roth --- qga/commands-posix.c | 116 ++++++++++++++++++++++++++++++-----------------= ---- 1 file changed, 68 insertions(+), 48 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index bd2c3514d8..a8299ecc77 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -1478,75 +1478,43 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum,= Error **errp) #define SUSPEND_MODE_RAM 2 #define SUSPEND_MODE_HYBRID 3 =20 -static void bios_supports_mode(int suspend_mode, Error **errp) +static bool pmutils_supports_mode(int suspend_mode, Error **errp) { Error *local_err =3D NULL; - const char *pmutils_arg, *sysfile_str; + const char *pmutils_arg; const char *pmutils_bin =3D "pm-is-supported"; char *pmutils_path; pid_t pid; int status; + bool ret =3D false; =20 switch (suspend_mode) { =20 case SUSPEND_MODE_DISK: pmutils_arg =3D "--hibernate"; - sysfile_str =3D "disk"; break; case SUSPEND_MODE_RAM: pmutils_arg =3D "--suspend"; - sysfile_str =3D "mem"; break; case SUSPEND_MODE_HYBRID: pmutils_arg =3D "--suspend-hybrid"; - sysfile_str =3D NULL; break; default: - error_setg(errp, "guest suspend mode not supported"); - return; + return ret; } =20 pmutils_path =3D g_find_program_in_path(pmutils_bin); + if (!pmutils_path) { + return ret; + } =20 pid =3D fork(); if (!pid) { - char buf[32]; /* hopefully big enough */ - ssize_t ret; - int fd; - setsid(); - reopen_fd_to_null(0); - reopen_fd_to_null(1); - reopen_fd_to_null(2); - - if (pmutils_path) { - execle(pmutils_path, pmutils_bin, pmutils_arg, NULL, environ); - } - + execle(pmutils_path, pmutils_bin, pmutils_arg, NULL, environ); /* - * If we get here either pm-utils is not installed or execle() has - * failed. Let's try the manual method if the caller wants it. + * If we get here execle() has failed. */ - - if (!sysfile_str) { - _exit(SUSPEND_NOT_SUPPORTED); - } - - fd =3D open(LINUX_SYS_STATE_FILE, O_RDONLY); - if (fd < 0) { - _exit(SUSPEND_NOT_SUPPORTED); - } - - ret =3D read(fd, buf, sizeof(buf)-1); - if (ret <=3D 0) { - _exit(SUSPEND_NOT_SUPPORTED); - } - buf[ret] =3D '\0'; - - if (strstr(buf, sysfile_str)) { - _exit(SUSPEND_SUPPORTED); - } - _exit(SUSPEND_NOT_SUPPORTED); } else if (pid < 0) { error_setg_errno(errp, errno, "failed to create child process"); @@ -1559,17 +1527,11 @@ static void bios_supports_mode(int suspend_mode, Er= ror **errp) goto out; } =20 - if (!WIFEXITED(status)) { - error_setg(errp, "child process has terminated abnormally"); - goto out; - } - switch (WEXITSTATUS(status)) { case SUSPEND_SUPPORTED: + ret =3D true; goto out; case SUSPEND_NOT_SUPPORTED: - error_setg(errp, - "the requested suspend mode is not supported by the gue= st"); goto out; default: error_setg(errp, @@ -1580,6 +1542,64 @@ static void bios_supports_mode(int suspend_mode, Err= or **errp) =20 out: g_free(pmutils_path); + return ret; +} + +static bool linux_sys_state_supports_mode(int suspend_mode, Error **errp) +{ + const char *sysfile_str; + char buf[32]; /* hopefully big enough */ + int fd; + ssize_t ret; + + switch (suspend_mode) { + + case SUSPEND_MODE_DISK: + sysfile_str =3D "disk"; + break; + case SUSPEND_MODE_RAM: + sysfile_str =3D "mem"; + break; + default: + return false; + } + + fd =3D open(LINUX_SYS_STATE_FILE, O_RDONLY); + if (fd < 0) { + return false; + } + + ret =3D read(fd, buf, sizeof(buf) - 1); + if (ret <=3D 0) { + return false; + } + buf[ret] =3D '\0'; + + if (strstr(buf, sysfile_str)) { + return true; + } + return false; +} + +static void bios_supports_mode(int suspend_mode, Error **errp) +{ + Error *local_err =3D NULL; + bool ret; + + ret =3D pmutils_supports_mode(suspend_mode, &local_err); + if (ret) { + return; + } + if (local_err) { + error_propagate(errp, local_err); + return; + } + ret =3D linux_sys_state_supports_mode(suspend_mode, errp); + if (!ret) { + error_setg(errp, + "the requested suspend mode is not supported by the gue= st"); + return; + } } =20 static void guest_suspend(int suspend_mode, Error **errp) --=20 2.11.0 From nobody Tue Nov 4 15:14:11 2025 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530651864195335.4083110715135; Tue, 3 Jul 2018 14:04:24 -0700 (PDT) Received: from localhost ([::1]:42642 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSTF-0007r8-77 for importer@patchew.org; Tue, 03 Jul 2018 17:04:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41257) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSIz-0008QH-IC for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faSIu-0000xo-Ma for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:45 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:45562 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faSIu-0000xH-FZ for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:40 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w63KnBfL041238 for ; Tue, 3 Jul 2018 16:53:39 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 2k0dp9pbym-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 03 Jul 2018 16:53:39 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 3 Jul 2018 14:53:38 -0600 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 3 Jul 2018 14:53:36 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w63KrZB418743680 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 3 Jul 2018 13:53:35 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5430C7805C; Tue, 3 Jul 2018 14:53:35 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3B96A7805F; Tue, 3 Jul 2018 14:53:35 -0600 (MDT) Received: from localhost (unknown [9.53.92.156]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 3 Jul 2018 14:53:35 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 3 Jul 2018 15:52:18 -0500 X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> References: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18070320-0016-0000-0000-000009038D41 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009303; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01056103; UDB=6.00541729; IPR=6.00834025; MB=3.00021980; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-03 20:53:37 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18070320-0017-0000-0000-00003F813A7E Message-Id: <20180703205221.24788-12-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-03_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807030235 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PULL 11/14] qga: guest_suspend: decoupling pm-utils and sys logic 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: peter.maydell@linaro.org, Daniel Henrique Barboza Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza Following the same logic of the previous patch, let's also decouple the suspend logic from guest_suspend into specialized functions, one for each strategy we support at this moment. Signed-off-by: Daniel Henrique Barboza Signed-off-by: Michael Roth --- qga/commands-posix.c | 170 ++++++++++++++++++++++++++++++++---------------= ---- 1 file changed, 108 insertions(+), 62 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index a8299ecc77..9ebd77b894 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -1545,6 +1545,65 @@ out: return ret; } =20 +static void pmutils_suspend(int suspend_mode, Error **errp) +{ + Error *local_err =3D NULL; + const char *pmutils_bin; + char *pmutils_path; + pid_t pid; + int status; + + switch (suspend_mode) { + + case SUSPEND_MODE_DISK: + pmutils_bin =3D "pm-hibernate"; + break; + case SUSPEND_MODE_RAM: + pmutils_bin =3D "pm-suspend"; + break; + case SUSPEND_MODE_HYBRID: + pmutils_bin =3D "pm-suspend-hybrid"; + break; + default: + error_setg(errp, "unknown guest suspend mode"); + return; + } + + pmutils_path =3D g_find_program_in_path(pmutils_bin); + if (!pmutils_path) { + error_setg(errp, "the helper program '%s' was not found", pmutils_= bin); + return; + } + + pid =3D fork(); + if (!pid) { + setsid(); + execle(pmutils_path, pmutils_bin, NULL, environ); + /* + * If we get here execle() has failed. + */ + _exit(EXIT_FAILURE); + } else if (pid < 0) { + error_setg_errno(errp, errno, "failed to create child process"); + goto out; + } + + ga_wait_child(pid, &status, &local_err); + if (local_err) { + error_propagate(errp, local_err); + goto out; + } + + if (WEXITSTATUS(status)) { + error_setg(errp, + "the helper program '%s' returned an unexpected exit st= atus" + " code (%d)", pmutils_path, WEXITSTATUS(status)); + } + +out: + g_free(pmutils_path); +} + static bool linux_sys_state_supports_mode(int suspend_mode, Error **errp) { const char *sysfile_str; @@ -1581,64 +1640,28 @@ static bool linux_sys_state_supports_mode(int suspe= nd_mode, Error **errp) return false; } =20 -static void bios_supports_mode(int suspend_mode, Error **errp) -{ - Error *local_err =3D NULL; - bool ret; - - ret =3D pmutils_supports_mode(suspend_mode, &local_err); - if (ret) { - return; - } - if (local_err) { - error_propagate(errp, local_err); - return; - } - ret =3D linux_sys_state_supports_mode(suspend_mode, errp); - if (!ret) { - error_setg(errp, - "the requested suspend mode is not supported by the gue= st"); - return; - } -} - -static void guest_suspend(int suspend_mode, Error **errp) +static void linux_sys_state_suspend(int suspend_mode, Error **errp) { Error *local_err =3D NULL; - const char *pmutils_bin, *sysfile_str; - char *pmutils_path; + const char *sysfile_str; pid_t pid; int status; =20 - bios_supports_mode(suspend_mode, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } - switch (suspend_mode) { =20 case SUSPEND_MODE_DISK: - pmutils_bin =3D "pm-hibernate"; sysfile_str =3D "disk"; break; case SUSPEND_MODE_RAM: - pmutils_bin =3D "pm-suspend"; sysfile_str =3D "mem"; break; - case SUSPEND_MODE_HYBRID: - pmutils_bin =3D "pm-suspend-hybrid"; - sysfile_str =3D NULL; - break; default: error_setg(errp, "unknown guest suspend mode"); return; } =20 - pmutils_path =3D g_find_program_in_path(pmutils_bin); - pid =3D fork(); - if (pid =3D=3D 0) { + if (!pid) { /* child */ int fd; =20 @@ -1647,19 +1670,6 @@ static void guest_suspend(int suspend_mode, Error **= errp) reopen_fd_to_null(1); reopen_fd_to_null(2); =20 - if (pmutils_path) { - execle(pmutils_path, pmutils_bin, NULL, environ); - } - - /* - * If we get here either pm-utils is not installed or execle() has - * failed. Let's try the manual method if the caller wants it. - */ - - if (!sysfile_str) { - _exit(EXIT_FAILURE); - } - fd =3D open(LINUX_SYS_STATE_FILE, O_WRONLY); if (fd < 0) { _exit(EXIT_FAILURE); @@ -1672,27 +1682,63 @@ static void guest_suspend(int suspend_mode, Error *= *errp) _exit(EXIT_SUCCESS); } else if (pid < 0) { error_setg_errno(errp, errno, "failed to create child process"); - goto out; + return; } =20 ga_wait_child(pid, &status, &local_err); if (local_err) { error_propagate(errp, local_err); - goto out; - } - - if (!WIFEXITED(status)) { - error_setg(errp, "child process has terminated abnormally"); - goto out; + return; } =20 if (WEXITSTATUS(status)) { error_setg(errp, "child process has failed to suspend"); - goto out; } =20 -out: - g_free(pmutils_path); +} + +static void bios_supports_mode(int suspend_mode, Error **errp) +{ + Error *local_err =3D NULL; + bool ret; + + ret =3D pmutils_supports_mode(suspend_mode, &local_err); + if (ret) { + return; + } + if (local_err) { + error_propagate(errp, local_err); + return; + } + ret =3D linux_sys_state_supports_mode(suspend_mode, errp); + if (!ret) { + error_setg(errp, + "the requested suspend mode is not supported by the gue= st"); + return; + } +} + +static void guest_suspend(int suspend_mode, Error **errp) +{ + Error *local_err =3D NULL; + + bios_supports_mode(suspend_mode, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + pmutils_suspend(suspend_mode, &local_err); + if (!local_err) { + return; + } + + error_free(local_err); + + linux_sys_state_suspend(suspend_mode, &local_err); + if (local_err) { + error_propagate(errp, local_err); + } } =20 void qmp_guest_suspend_disk(Error **errp) --=20 2.11.0 From nobody Tue Nov 4 15:14:11 2025 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530651753279704.8183801157605; Tue, 3 Jul 2018 14:02:33 -0700 (PDT) Received: from localhost ([::1]:42635 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSRU-0006fC-ID for importer@patchew.org; Tue, 03 Jul 2018 17:02:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSIz-0008QN-R4 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faSIw-0000z7-DD for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:45 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:53676) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faSIw-0000yR-3o for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:42 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w63KnB7p056052 for ; Tue, 3 Jul 2018 16:53:40 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0a-001b2d01.pphosted.com with ESMTP id 2k0dpjxhrc-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 03 Jul 2018 16:53:40 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 3 Jul 2018 14:53:39 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 3 Jul 2018 14:53:36 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w63KrZWL12190178 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 3 Jul 2018 13:53:35 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CEF697805E; Tue, 3 Jul 2018 14:53:35 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A8F197805C; Tue, 3 Jul 2018 14:53:35 -0600 (MDT) Received: from localhost (unknown [9.53.92.156]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 3 Jul 2018 14:53:35 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 3 Jul 2018 15:52:19 -0500 X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> References: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18070320-0012-0000-0000-000016869C49 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009303; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01056103; UDB=6.00541729; IPR=6.00834026; MB=3.00021980; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-03 20:53:38 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18070320-0013-0000-0000-0000538B80D7 Message-Id: <20180703205221.24788-13-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-03_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807030235 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PULL 12/14] qga: removing switch statements, adding run_process_child 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: peter.maydell@linaro.org, Daniel Henrique Barboza Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza This is a cleanup of the resulting code after detaching pmutils and Linux sys state file logic: - remove the SUSPEND_MODE_* macros and use an enumeration instead. At the same time, drop the switch statements at the start of each function and use the enumeration index to get the right binary/argument; - create a new function called run_process_child(). This function uses g_spawn_sync() to execute a shell command, returning the exit code. This is a common operation in the pmutils functions and will be used in the systemd implementation as well, so this function will avoid code repetition. There are more places inside commands-posix.c where this new run_process_child function can also be used, but one step at a time. Signed-off-by: Daniel Henrique Barboza *check/propagate local_err before setting errp directly Signed-off-by: Michael Roth --- qga/commands-posix.c | 215 +++++++++++++++++++++--------------------------= ---- 1 file changed, 88 insertions(+), 127 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 9ebd77b894..1559753d85 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -1474,152 +1474,117 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimu= m, Error **errp) #define LINUX_SYS_STATE_FILE "/sys/power/state" #define SUSPEND_SUPPORTED 0 #define SUSPEND_NOT_SUPPORTED 1 -#define SUSPEND_MODE_DISK 1 -#define SUSPEND_MODE_RAM 2 -#define SUSPEND_MODE_HYBRID 3 =20 -static bool pmutils_supports_mode(int suspend_mode, Error **errp) +typedef enum { + SUSPEND_MODE_DISK =3D 0, + SUSPEND_MODE_RAM =3D 1, + SUSPEND_MODE_HYBRID =3D 2, +} SuspendMode; + +/* + * Executes a command in a child process using g_spawn_sync, + * returning an int >=3D 0 representing the exit status of the + * process. + * + * If the program wasn't found in path, returns -1. + * + * If a problem happened when creating the child process, + * returns -1 and errp is set. + */ +static int run_process_child(const char *command[], Error **errp) { - Error *local_err =3D NULL; - const char *pmutils_arg; - const char *pmutils_bin =3D "pm-is-supported"; - char *pmutils_path; - pid_t pid; - int status; - bool ret =3D false; + int exit_status, spawn_flag; + GError *g_err =3D NULL; + bool success; =20 - switch (suspend_mode) { + spawn_flag =3D G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL | + G_SPAWN_STDERR_TO_DEV_NULL; =20 - case SUSPEND_MODE_DISK: - pmutils_arg =3D "--hibernate"; - break; - case SUSPEND_MODE_RAM: - pmutils_arg =3D "--suspend"; - break; - case SUSPEND_MODE_HYBRID: - pmutils_arg =3D "--suspend-hybrid"; - break; - default: - return ret; + success =3D g_spawn_sync(NULL, (char **)command, environ, spawn_flag, + NULL, NULL, NULL, NULL, + &exit_status, &g_err); + + if (success) { + return WEXITSTATUS(exit_status); } =20 - pmutils_path =3D g_find_program_in_path(pmutils_bin); - if (!pmutils_path) { - return ret; + if (g_err && (g_err->code !=3D G_SPAWN_ERROR_NOENT)) { + error_setg(errp, "failed to create child process, error '%s'", + g_err->message); } =20 - pid =3D fork(); - if (!pid) { - setsid(); - execle(pmutils_path, pmutils_bin, pmutils_arg, NULL, environ); - /* - * If we get here execle() has failed. - */ - _exit(SUSPEND_NOT_SUPPORTED); - } else if (pid < 0) { - error_setg_errno(errp, errno, "failed to create child process"); - goto out; + g_error_free(g_err); + return -1; +} + +static bool pmutils_supports_mode(SuspendMode mode, Error **errp) +{ + Error *local_err =3D NULL; + const char *pmutils_args[3] =3D {"--hibernate", "--suspend", + "--suspend-hybrid"}; + const char *cmd[3] =3D {"pm-is-supported", pmutils_args[mode], NULL}; + int status; + + status =3D run_process_child(cmd, &local_err); + + if (status =3D=3D SUSPEND_SUPPORTED) { + return true; } =20 - ga_wait_child(pid, &status, &local_err); - if (local_err) { - error_propagate(errp, local_err); - goto out; + if ((status =3D=3D -1) && !local_err) { + return false; } =20 - switch (WEXITSTATUS(status)) { - case SUSPEND_SUPPORTED: - ret =3D true; - goto out; - case SUSPEND_NOT_SUPPORTED: - goto out; - default: + if (local_err) { + error_propagate(errp, local_err); + } else { error_setg(errp, - "the helper program '%s' returned an unexpected exit st= atus" - " code (%d)", pmutils_path, WEXITSTATUS(status)); - goto out; + "the helper program '%s' returned an unexpected exit" + " status code (%d)", "pm-is-supported", status); } =20 -out: - g_free(pmutils_path); - return ret; + return false; } =20 -static void pmutils_suspend(int suspend_mode, Error **errp) +static void pmutils_suspend(SuspendMode mode, Error **errp) { Error *local_err =3D NULL; - const char *pmutils_bin; - char *pmutils_path; - pid_t pid; + const char *pmutils_binaries[3] =3D {"pm-hibernate", "pm-suspend", + "pm-suspend-hybrid"}; + const char *cmd[2] =3D {pmutils_binaries[mode], NULL}; int status; =20 - switch (suspend_mode) { - - case SUSPEND_MODE_DISK: - pmutils_bin =3D "pm-hibernate"; - break; - case SUSPEND_MODE_RAM: - pmutils_bin =3D "pm-suspend"; - break; - case SUSPEND_MODE_HYBRID: - pmutils_bin =3D "pm-suspend-hybrid"; - break; - default: - error_setg(errp, "unknown guest suspend mode"); - return; - } + status =3D run_process_child(cmd, &local_err); =20 - pmutils_path =3D g_find_program_in_path(pmutils_bin); - if (!pmutils_path) { - error_setg(errp, "the helper program '%s' was not found", pmutils_= bin); + if (status =3D=3D 0) { return; } =20 - pid =3D fork(); - if (!pid) { - setsid(); - execle(pmutils_path, pmutils_bin, NULL, environ); - /* - * If we get here execle() has failed. - */ - _exit(EXIT_FAILURE); - } else if (pid < 0) { - error_setg_errno(errp, errno, "failed to create child process"); - goto out; + if ((status =3D=3D -1) && !local_err) { + error_setg(errp, "the helper program '%s' was not found", + pmutils_binaries[mode]); + return; } =20 - ga_wait_child(pid, &status, &local_err); if (local_err) { error_propagate(errp, local_err); - goto out; - } - - if (WEXITSTATUS(status)) { + } else { error_setg(errp, - "the helper program '%s' returned an unexpected exit st= atus" - " code (%d)", pmutils_path, WEXITSTATUS(status)); + "the helper program '%s' returned an unexpected exit" + " status code (%d)", pmutils_binaries[mode], status); } - -out: - g_free(pmutils_path); } =20 -static bool linux_sys_state_supports_mode(int suspend_mode, Error **errp) +static bool linux_sys_state_supports_mode(SuspendMode mode, Error **errp) { - const char *sysfile_str; + const char *sysfile_strs[3] =3D {"disk", "mem", NULL}; + const char *sysfile_str =3D sysfile_strs[mode]; char buf[32]; /* hopefully big enough */ int fd; ssize_t ret; =20 - switch (suspend_mode) { - - case SUSPEND_MODE_DISK: - sysfile_str =3D "disk"; - break; - case SUSPEND_MODE_RAM: - sysfile_str =3D "mem"; - break; - default: + if (!sysfile_str) { + error_setg(errp, "unknown guest suspend mode"); return false; } =20 @@ -1640,22 +1605,15 @@ static bool linux_sys_state_supports_mode(int suspe= nd_mode, Error **errp) return false; } =20 -static void linux_sys_state_suspend(int suspend_mode, Error **errp) +static void linux_sys_state_suspend(SuspendMode mode, Error **errp) { Error *local_err =3D NULL; - const char *sysfile_str; + const char *sysfile_strs[3] =3D {"disk", "mem", NULL}; + const char *sysfile_str =3D sysfile_strs[mode]; pid_t pid; int status; =20 - switch (suspend_mode) { - - case SUSPEND_MODE_DISK: - sysfile_str =3D "disk"; - break; - case SUSPEND_MODE_RAM: - sysfile_str =3D "mem"; - break; - default: + if (!sysfile_str) { error_setg(errp, "unknown guest suspend mode"); return; } @@ -1697,12 +1655,12 @@ static void linux_sys_state_suspend(int suspend_mod= e, Error **errp) =20 } =20 -static void bios_supports_mode(int suspend_mode, Error **errp) +static void bios_supports_mode(SuspendMode mode, Error **errp) { Error *local_err =3D NULL; bool ret; =20 - ret =3D pmutils_supports_mode(suspend_mode, &local_err); + ret =3D pmutils_supports_mode(mode, &local_err); if (ret) { return; } @@ -1710,32 +1668,35 @@ static void bios_supports_mode(int suspend_mode, Er= ror **errp) error_propagate(errp, local_err); return; } - ret =3D linux_sys_state_supports_mode(suspend_mode, errp); + ret =3D linux_sys_state_supports_mode(mode, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } if (!ret) { error_setg(errp, "the requested suspend mode is not supported by the gue= st"); - return; } } =20 -static void guest_suspend(int suspend_mode, Error **errp) +static void guest_suspend(SuspendMode mode, Error **errp) { Error *local_err =3D NULL; =20 - bios_supports_mode(suspend_mode, &local_err); + bios_supports_mode(mode, &local_err); if (local_err) { error_propagate(errp, local_err); return; } =20 - pmutils_suspend(suspend_mode, &local_err); + pmutils_suspend(mode, &local_err); if (!local_err) { return; } =20 error_free(local_err); =20 - linux_sys_state_suspend(suspend_mode, &local_err); + linux_sys_state_suspend(mode, &local_err); if (local_err) { error_propagate(errp, local_err); } --=20 2.11.0 From nobody Tue Nov 4 15:14:11 2025 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; 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 Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530651545819143.77739043130634; Tue, 3 Jul 2018 13:59:05 -0700 (PDT) Received: from localhost ([::1]:42611 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSO2-0003sl-1s for importer@patchew.org; Tue, 03 Jul 2018 16:58:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSIz-0008QI-It for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faSIu-0000y4-TR for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:45 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:45664 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faSIu-0000xW-Ny for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:40 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w63KnAub041155 for ; Tue, 3 Jul 2018 16:53:40 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0a-001b2d01.pphosted.com with ESMTP id 2k0dp9pbyu-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 03 Jul 2018 16:53:39 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 3 Jul 2018 14:53:39 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 3 Jul 2018 14:53:37 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w63KraqP10289660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 3 Jul 2018 13:53:36 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4C6637805F; Tue, 3 Jul 2018 14:53:36 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 339D77805E; Tue, 3 Jul 2018 14:53:36 -0600 (MDT) Received: from localhost (unknown [9.53.92.156]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 3 Jul 2018 14:53:36 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 3 Jul 2018 15:52:20 -0500 X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> References: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18070320-0012-0000-0000-000016869C4A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009303; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01056103; UDB=6.00541729; IPR=6.00834026; MB=3.00021980; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-03 20:53:38 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18070320-0013-0000-0000-0000538B80D9 Message-Id: <20180703205221.24788-14-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-03_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=911 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807030235 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PULL 13/14] qga: systemd hibernate/suspend/hybrid-sleep support 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: peter.maydell@linaro.org, Daniel Henrique Barboza Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza pmutils isn't being supported by newer OSes like Fedora 27 or Mint. This means that the only suspend option QGA offers for these guests are writing directly into the Linux sys state file. This also means that QGA also loses the ability to do hybrid suspend in those guests - this suspend mode is only available when using pmutils. Newer guests can use systemd facilities to do all the suspend types QGA supports. The mapping in comparison with pmutils is: - pm-hibernate -> systemctl hibernate - pm-suspend -> systemctl suspend - pm-suspend-hybrid -> systemctl hybrid-sleep To discover whether systemd supports these functions, we inspect the status of the services that implements them. With this patch, we can offer hybrid suspend again for newer guests that do not have pmutils support anymore. Signed-off-by: Daniel Henrique Barboza Signed-off-by: Michael Roth --- qga/commands-posix.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 72 insertions(+) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 1559753d85..cdb825993f 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -1517,6 +1517,63 @@ static int run_process_child(const char *command[], = Error **errp) return -1; } =20 +static bool systemd_supports_mode(SuspendMode mode, Error **errp) +{ + Error *local_err =3D NULL; + const char *systemctl_args[3] =3D {"systemd-hibernate", "systemd-suspe= nd", + "systemd-hybrid-sleep"}; + const char *cmd[4] =3D {"systemctl", "status", systemctl_args[mode], N= ULL}; + int status; + + status =3D run_process_child(cmd, &local_err); + + /* + * systemctl status uses LSB return codes so we can expect + * status > 0 and be ok. To assert if the guest has support + * for the selected suspend mode, status should be < 4. 4 is + * the code for unknown service status, the return value when + * the service does not exist. A common value is status =3D 3 + * (program is not running). + */ + if (status > 0 && status < 4) { + return true; + } + + if (local_err) { + error_propagate(errp, local_err); + } + + return false; +} + +static void systemd_suspend(SuspendMode mode, Error **errp) +{ + Error *local_err =3D NULL; + const char *systemctl_args[3] =3D {"hibernate", "suspend", "hybrid-sle= ep"}; + const char *cmd[3] =3D {"systemctl", systemctl_args[mode], NULL}; + int status; + + status =3D run_process_child(cmd, &local_err); + + if (status =3D=3D 0) { + return; + } + + if ((status =3D=3D -1) && !local_err) { + error_setg(errp, "the helper program 'systemctl %s' was not found", + systemctl_args[mode]); + return; + } + + if (local_err) { + error_propagate(errp, local_err); + } else { + error_setg(errp, "the helper program 'systemctl %s' returned an " + "unexpected exit status code (%d)", + systemctl_args[mode], status); + } +} + static bool pmutils_supports_mode(SuspendMode mode, Error **errp) { Error *local_err =3D NULL; @@ -1660,6 +1717,14 @@ static void bios_supports_mode(SuspendMode mode, Err= or **errp) Error *local_err =3D NULL; bool ret; =20 + ret =3D systemd_supports_mode(mode, &local_err); + if (ret) { + return; + } + if (local_err) { + error_propagate(errp, local_err); + return; + } ret =3D pmutils_supports_mode(mode, &local_err); if (ret) { return; @@ -1689,6 +1754,13 @@ static void guest_suspend(SuspendMode mode, Error **= errp) return; } =20 + systemd_suspend(mode, &local_err); + if (!local_err) { + return; + } + + error_free(local_err); + pmutils_suspend(mode, &local_err); if (!local_err) { return; --=20 2.11.0 From nobody Tue Nov 4 15:14:11 2025 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530651888124973.1733175436832; Tue, 3 Jul 2018 14:04:48 -0700 (PDT) Received: from localhost ([::1]:42643 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSTc-00084p-47 for importer@patchew.org; Tue, 03 Jul 2018 17:04:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faSJ1-0008Qc-GD for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faSIw-0000yv-27 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:47 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:56956 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faSIv-0000yb-SQ for qemu-devel@nongnu.org; Tue, 03 Jul 2018 16:53:41 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w63KnCd7063035 for ; Tue, 3 Jul 2018 16:53:41 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0b-001b2d01.pphosted.com with ESMTP id 2k0ft1snua-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 03 Jul 2018 16:53:41 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 3 Jul 2018 14:53:40 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 3 Jul 2018 14:53:37 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w63KraEf2687442 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 3 Jul 2018 13:53:36 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AD4D57805F; Tue, 3 Jul 2018 14:53:36 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 943AC7805E; Tue, 3 Jul 2018 14:53:36 -0600 (MDT) Received: from localhost (unknown [9.53.92.156]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 3 Jul 2018 14:53:36 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 3 Jul 2018 15:52:21 -0500 X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> References: <20180703205221.24788-1-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18070320-0004-0000-0000-0000145E5648 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009303; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01056103; UDB=6.00541729; IPR=6.00834026; MB=3.00021980; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-03 20:53:38 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18070320-0005-0000-0000-000087F5C3A4 Message-Id: <20180703205221.24788-15-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-03_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807030235 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PULL 14/14] qga: removing bios_supports_mode 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: peter.maydell@linaro.org, Daniel Henrique Barboza Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza bios_support_mode verifies if the guest has support for a certain suspend mode but it doesn't inform back which suspend tool provides it. The caller, guest_suspend, executes all suspend strategies in order again. After adding systemd suspend support, bios_support_mode now will verify for support for systemd, then pmutils, then Linux sys state file. In a worst case scenario where both systemd and pmutils isn't supported but Linux sys state is: - bios_supports_mode will check for systemd, then pmutils, then Linux sys state. It will tell guest_suspend that there is support, but it will not tell who provides it; - guest_suspend will try to execute (and fail) systemd suspend, then pmutils suspend, to only then use the Linux sys suspend. The time spent executing systemd and pmutils suspend was wasted and could be avoided, but only bios_support_mode knew it but didn't inform it back. A quicker approach is to nuke bios_supports_mode and control whether we found support at all with a bool flag inside guest_suspend. guest_suspend will search for suspend support and execute it as soon as possible. If the a given suspend mechanism fails, continue to the next. If no suspend support is found, the "not supported" message is still being sent back to the user. Signed-off-by: Daniel Henrique Barboza Signed-off-by: Michael Roth --- qga/commands-posix.c | 58 ++++++++++++++++--------------------------------= ---- 1 file changed, 18 insertions(+), 40 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index cdb825993f..233f78a406 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -1712,64 +1712,42 @@ static void linux_sys_state_suspend(SuspendMode mod= e, Error **errp) =20 } =20 -static void bios_supports_mode(SuspendMode mode, Error **errp) -{ - Error *local_err =3D NULL; - bool ret; - - ret =3D systemd_supports_mode(mode, &local_err); - if (ret) { - return; - } - if (local_err) { - error_propagate(errp, local_err); - return; - } - ret =3D pmutils_supports_mode(mode, &local_err); - if (ret) { - return; - } - if (local_err) { - error_propagate(errp, local_err); - return; - } - ret =3D linux_sys_state_supports_mode(mode, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } - if (!ret) { - error_setg(errp, - "the requested suspend mode is not supported by the gue= st"); - } -} - static void guest_suspend(SuspendMode mode, Error **errp) { Error *local_err =3D NULL; + bool mode_supported =3D false; =20 - bios_supports_mode(mode, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; + if (systemd_supports_mode(mode, &local_err)) { + mode_supported =3D true; + systemd_suspend(mode, &local_err); } =20 - systemd_suspend(mode, &local_err); if (!local_err) { return; } =20 error_free(local_err); =20 - pmutils_suspend(mode, &local_err); + if (pmutils_supports_mode(mode, &local_err)) { + mode_supported =3D true; + pmutils_suspend(mode, &local_err); + } + if (!local_err) { return; } =20 error_free(local_err); =20 - linux_sys_state_suspend(mode, &local_err); - if (local_err) { + if (linux_sys_state_supports_mode(mode, &local_err)) { + mode_supported =3D true; + linux_sys_state_suspend(mode, &local_err); + } + + if (!mode_supported) { + error_setg(errp, + "the requested suspend mode is not supported by the gue= st"); + } else if (local_err) { error_propagate(errp, local_err); } } --=20 2.11.0