From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596123605; cv=none; d=zohomail.com; s=zohoarc; b=QC5SEszzc0c4N0VwugeFCYgZMj25HOTAVh/l9Zqk5eHyBvhpwf+fE6N2Ncisr+BuKNH1H3+/Vh6g4F9I4pNAzyWYhqjfg4mXVtml55kx6rocj1fZ8JIHgW3Bpzs6eeHqCZnCwWr3N18pEsPNMGToHkDE7JY0HTWGhVP0vxYySGA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596123605; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=dijgsEynUNDBNs0kElXjXPqxdC+9Litu30NacqUmQDQ=; b=J4uGbyZ7/nHcOfVb6cvxcbg6yYD5Ag/9a1dVLNIjdviS59awfKqwTXNJVDmrbna1qV7rNMOz/FB7/5eeZfkx8/0y/kGKFr4ddJOcbzb/dOIG3SPtbx8CC18vxYfYPk+in/AAjEwhxhCWlCB3P927L1VnBkl07y/cGmBFgv1pkZ4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596123605795953.5755965261505; Thu, 30 Jul 2020 08:40:05 -0700 (PDT) Received: from localhost ([::1]:59594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1Af5-0000N4-JM for importer@patchew.org; Thu, 30 Jul 2020 11:40:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53736) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1Ad8-00074l-Tt for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:02 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:36882) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1Ad6-00024X-CL for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:02 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXgGG156161; Thu, 30 Jul 2020 15:37:56 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 32hu1jmebr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:37:56 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXSkf130680; Thu, 30 Jul 2020 15:37:55 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 32hu5wwgj4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:37:55 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 06UFbr9c020268; Thu, 30 Jul 2020 15:37:53 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:37:53 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=dijgsEynUNDBNs0kElXjXPqxdC+9Litu30NacqUmQDQ=; b=hPC9FlqWro9zSXaKvl7HVagYvZ0cfce99DJvlCCTEXKsJgPIiQaqM4n/KqpK/Dq5HmPS nD5u0ZWrFqno7CIMd8apHQR1n/sPo3oJT1H+4JIFnO9HLAlONxtMPg3hoo3UcHRxlSow o3QxfeagyGranhO4S/ikXIacg614mrkGznQLLwBv96vwWVhLHkFbcE8wMPWB4x1VYnsp jGfGQEyG2s0THtc5Ys6c6+cVZOIe263YMTX5ktyE+wc14674Vm+DvD/M5lRxhKHlaI02 7FRj47BjxD7etHr+ruTwMctIsR7F1hafaClGHSJwHyjfzD3PBO4JY5ikVUW3eH2L5Bi6 iQ== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 01/32] savevm: add vmstate handler iterators Date: Thu, 30 Jul 2020 08:14:05 -0700 Message-Id: <1596122076-341293-2-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=3 bulkscore=0 malwarescore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 clxscore=1015 mlxscore=0 impostorscore=0 phishscore=0 adultscore=0 suspectscore=3 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=141.146.126.78; envelope-from=steven.sistare@oracle.com; helo=aserp2120.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:37:57 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Provide the SAVEVM_FOREACH and SAVEVM_FORALL macros to loop over all save VM state handlers. The former will filter handlers based on the operation in the later patch "savevm: VM handlers mode mask". The latter loops over all handlers. No functional change. Signed-off-by: Steve Sistare --- migration/savevm.c | 57 ++++++++++++++++++++++++++++++++++++--------------= ---- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 45c9dd9..a07fcad 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -266,6 +266,25 @@ static SaveState savevm_state =3D { .global_section_id =3D 0, }; =20 +/* + * The FOREACH macros will filter handlers based on the current operation = when + * additional conditions are added in a subsequent patch. + */ + +#define SAVEVM_FOREACH(se, entry) \ + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) \ + +#define SAVEVM_FOREACH_SAFE(se, entry, new_se) \ + QTAILQ_FOREACH_SAFE(se, &savevm_state.handlers, entry, new_se) \ + +/* The FORALL macros unconditionally loop over all handlers. */ + +#define SAVEVM_FORALL(se, entry) \ + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) + +#define SAVEVM_FORALL_SAFE(se, entry, new_se) \ + QTAILQ_FOREACH_SAFE(se, &savevm_state.handlers, entry, new_se) + static bool should_validate_capability(int capability) { assert(capability >=3D 0 && capability < MIGRATION_CAPABILITY__MAX); @@ -673,7 +692,7 @@ static uint32_t calculate_new_instance_id(const char *i= dstr) SaveStateEntry *se; uint32_t instance_id =3D 0; =20 - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + SAVEVM_FORALL(se, entry) { if (strcmp(idstr, se->idstr) =3D=3D 0 && instance_id <=3D se->instance_id) { instance_id =3D se->instance_id + 1; @@ -689,7 +708,7 @@ static int calculate_compat_instance_id(const char *ids= tr) SaveStateEntry *se; int instance_id =3D 0; =20 - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + SAVEVM_FORALL(se, entry) { if (!se->compat) { continue; } @@ -803,7 +822,7 @@ void unregister_savevm(VMStateIf *obj, const char *idst= r, void *opaque) } pstrcat(id, sizeof(id), idstr); =20 - QTAILQ_FOREACH_SAFE(se, &savevm_state.handlers, entry, new_se) { + SAVEVM_FORALL_SAFE(se, entry, new_se) { if (strcmp(se->idstr, id) =3D=3D 0 && se->opaque =3D=3D opaque) { savevm_state_handler_remove(se); g_free(se->compat); @@ -867,7 +886,7 @@ void vmstate_unregister(VMStateIf *obj, const VMStateDe= scription *vmsd, { SaveStateEntry *se, *new_se; =20 - QTAILQ_FOREACH_SAFE(se, &savevm_state.handlers, entry, new_se) { + SAVEVM_FORALL_SAFE(se, entry, new_se) { if (se->vmsd =3D=3D vmsd && se->opaque =3D=3D opaque) { savevm_state_handler_remove(se); g_free(se->compat); @@ -1119,7 +1138,7 @@ bool qemu_savevm_state_blocked(Error **errp) { SaveStateEntry *se; =20 - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + SAVEVM_FORALL(se, entry) { if (se->vmsd && se->vmsd->unmigratable) { error_setg(errp, "State blocked by non-migratable device '%s'", se->idstr); @@ -1145,7 +1164,7 @@ bool qemu_savevm_state_guest_unplug_pending(void) { SaveStateEntry *se; =20 - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + SAVEVM_FOREACH(se, entry) { if (se->vmsd && se->vmsd->dev_unplug_pending && se->vmsd->dev_unplug_pending(se->opaque)) { return true; @@ -1162,7 +1181,7 @@ void qemu_savevm_state_setup(QEMUFile *f) int ret; =20 trace_savevm_state_setup(); - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + SAVEVM_FOREACH(se, entry) { if (!se->ops || !se->ops->save_setup) { continue; } @@ -1193,7 +1212,7 @@ int qemu_savevm_state_resume_prepare(MigrationState *= s) =20 trace_savevm_state_resume_prepare(); =20 - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + SAVEVM_FOREACH(se, entry) { if (!se->ops || !se->ops->resume_prepare) { continue; } @@ -1223,7 +1242,7 @@ int qemu_savevm_state_iterate(QEMUFile *f, bool postc= opy) int ret =3D 1; =20 trace_savevm_state_iterate(); - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + SAVEVM_FOREACH(se, entry) { if (!se->ops || !se->ops->save_live_iterate) { continue; } @@ -1291,7 +1310,7 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f) SaveStateEntry *se; int ret; =20 - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + SAVEVM_FOREACH(se, entry) { if (!se->ops || !se->ops->save_live_complete_postcopy) { continue; } @@ -1324,7 +1343,7 @@ int qemu_savevm_state_complete_precopy_iterable(QEMUF= ile *f, bool in_postcopy) SaveStateEntry *se; int ret; =20 - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + SAVEVM_FOREACH(se, entry) { if (!se->ops || (in_postcopy && se->ops->has_postcopy && se->ops->has_postcopy(se->opaque)) || @@ -1366,7 +1385,7 @@ int qemu_savevm_state_complete_precopy_non_iterable(Q= EMUFile *f, vmdesc =3D qjson_new(); json_prop_int(vmdesc, "page_size", qemu_target_page_size()); json_start_array(vmdesc, "devices"); - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + SAVEVM_FOREACH(se, entry) { =20 if ((!se->ops || !se->ops->save_state) && !se->vmsd) { continue; @@ -1476,7 +1495,7 @@ void qemu_savevm_state_pending(QEMUFile *f, uint64_t = threshold_size, *res_postcopy_only =3D 0; =20 =20 - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + SAVEVM_FOREACH(se, entry) { if (!se->ops || !se->ops->save_live_pending) { continue; } @@ -1501,7 +1520,7 @@ void qemu_savevm_state_cleanup(void) } =20 trace_savevm_state_cleanup(); - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + SAVEVM_FOREACH(se, entry) { if (se->ops && se->ops->save_cleanup) { se->ops->save_cleanup(se->opaque); } @@ -1580,7 +1599,7 @@ int qemu_save_device_state(QEMUFile *f) } cpu_synchronize_all_states(); =20 - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + SAVEVM_FOREACH(se, entry) { int ret; =20 if (se->is_ram) { @@ -1612,7 +1631,7 @@ static SaveStateEntry *find_se(const char *idstr, uin= t32_t instance_id) { SaveStateEntry *se; =20 - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + SAVEVM_FORALL(se, entry) { if (!strcmp(se->idstr, idstr) && (instance_id =3D=3D se->instance_id || instance_id =3D=3D se->alias_id)) @@ -2334,7 +2353,7 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationIn= comingState *mis) } =20 trace_qemu_loadvm_state_section_partend(section_id); - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + SAVEVM_FOREACH(se, entry) { if (se->load_section_id =3D=3D section_id) { break; } @@ -2400,7 +2419,7 @@ static int qemu_loadvm_state_setup(QEMUFile *f) int ret; =20 trace_loadvm_state_setup(); - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + SAVEVM_FOREACH(se, entry) { if (!se->ops || !se->ops->load_setup) { continue; } @@ -2425,7 +2444,7 @@ void qemu_loadvm_state_cleanup(void) SaveStateEntry *se; =20 trace_loadvm_state_cleanup(); - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + SAVEVM_FOREACH(se, entry) { if (se->ops && se->ops->load_cleanup) { se->ops->load_cleanup(se->opaque); } --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596124654; cv=none; d=zohomail.com; s=zohoarc; b=W7ruA3SwO5SxeTUZ01IzVsd7tAKFXkmueUCFfdooIpT/KyUZX7FsUkNUxNyF8+MVqzkpdMHU8IxGq+fpscxCyxBgxJSFTZltAVUi0p5qlGs5QjiViJTSC5i8/OjMaWK7pLeWFaB/aMwqO2m0eSRoi1fcuhkPml2Fz6IZXPiCaNg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596124654; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=9yU3uF0G2s5qWsK/B3S+9s+ZnpI5bYaEDMA1bh3ly1A=; b=Jgtteb3gRask9+xzR3O7YM1ETs2xtQCW64T+myHn2Oe9IGtnOS8xgbIxhSsct0BrzA7twsVWT5/kIayg8DbabtNeFLBvm1x3mYRN1xm4YQ/rltBnNp5YRFyPxJpzmWIIvUHhO5P3vDaM5WyeWNTXT6AzL19d9nSM4+oov/RqZvg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596124654085279.6210681416128; Thu, 30 Jul 2020 08:57:34 -0700 (PDT) Received: from localhost ([::1]:34078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1Aw0-0000fJ-MO for importer@patchew.org; Thu, 30 Jul 2020 11:57:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1Af4-00019k-Oh for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:02 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:51750) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1Af1-0002Tl-5w for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:02 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXUoj007564; Thu, 30 Jul 2020 15:39:56 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 32hu1jmfsw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:39:56 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXSVk130767; Thu, 30 Jul 2020 15:37:55 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 32hu5wwgjp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:37:55 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 06UFbsQp001804; Thu, 30 Jul 2020 15:37:54 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:37:54 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=9yU3uF0G2s5qWsK/B3S+9s+ZnpI5bYaEDMA1bh3ly1A=; b=T/1swMwaDReppaREZ3DKXzoBsMTAo1crVZqkF5LvNqHCS3M/jzVpmronv4WUuwMZg16t EdhcrK1PTjRQToUEYZGVuTz2qlS4ooCSdqPXHk2bZZigUnT81pyllFNSj6RqVJsvrTUa hOkoCvn3Z6nprqMS06sq7Twvy10y8gG+/MXcD/kGVhHykr8klbjBsUx4/58pt5tzEeWx FRe2aAmqOcIlby767KqTLDWpgKdsQVES0/BdumyV85WrqaVyEaiq1EAIxoxVhhr6VLBK nrbIo0cfd6GZ3owxgow117wVItCvM2jeC7taVIswtN2CN3lHxY11k0xM2yJ2GBhBbiod 3Q== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 02/32] savevm: VM handlers mode mask Date: Thu, 30 Jul 2020 08:14:06 -0700 Message-Id: <1596122076-341293-3-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=1 bulkscore=0 malwarescore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 clxscore=1015 malwarescore=0 spamscore=0 suspectscore=1 bulkscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.86; envelope-from=steven.sistare@oracle.com; helo=userp2130.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:37:58 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a new mode argument to qemu_savevm_state() and qemu_loadvm_state() that can customize the operation. Define the VMS_MIGRATE and VMS_SNAPSHOT modes for the existing live migration and snapshot capabilities. Provide a mode mask for vmstate handlers. A handler is only processed by SAVEVM_FOREACH if its mask includes the savevm_state.mode. Unmodified handler declarations have a zero mask field, which implicitly enables the handler for all modes. No functional change for the VMS_MIGRATE and VMS_SNAPSHOT modes. Signed-off-by: Steve Sistare --- include/migration/register.h | 3 +++ include/migration/vmstate.h | 9 ++++++++ migration/migration.c | 4 ++-- migration/savevm.c | 51 +++++++++++++++++++++++++++++++++++-----= ---- migration/savevm.h | 4 +++- 5 files changed, 58 insertions(+), 13 deletions(-) diff --git a/include/migration/register.h b/include/migration/register.h index c1dcff0..c030a10 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -17,6 +17,9 @@ #include "hw/vmstate-if.h" =20 typedef struct SaveVMHandlers { + /* Mask of VMStateMode's that should use this handler */ + unsigned mode_mask; + /* This runs inside the iothread lock. */ SaveStateHandler *save_state; =20 diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index f68ed7d..fa575f9 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -158,6 +158,12 @@ typedef enum { MIG_PRI_MAX, } MigrationPriority; =20 +typedef enum { + VMS_MIGRATE =3D (1U << 1), + VMS_SNAPSHOT =3D (1U << 2), + VMS_MODE_ALL =3D ~0U +} VMStateMode; + struct VMStateField { const char *name; const char *err_hint; @@ -182,6 +188,7 @@ struct VMStateDescription { int minimum_version_id; int minimum_version_id_old; MigrationPriority priority; + unsigned mode_mask; LoadStateHandler *load_state_old; int (*pre_load)(void *opaque); int (*post_load)(void *opaque, int version_id); @@ -1215,4 +1222,6 @@ void vmstate_register_ram_global(struct MemoryRegion = *memory); =20 bool vmstate_check_only_migratable(const VMStateDescription *vmsd); =20 +void savevm_set_mode(VMStateMode mode); + #endif diff --git a/migration/migration.c b/migration/migration.c index 2ed9923..e3d0899 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -465,7 +465,7 @@ static void process_incoming_migration_co(void *opaque) postcopy_state_set(POSTCOPY_INCOMING_NONE); migrate_set_state(&mis->state, MIGRATION_STATUS_NONE, MIGRATION_STATUS_ACTIVE); - ret =3D qemu_loadvm_state(mis->from_src_file); + ret =3D qemu_loadvm_state(mis->from_src_file, VMS_MIGRATE); =20 ps =3D postcopy_state_get(); trace_process_incoming_migration_co_end(ret, ps); @@ -3414,7 +3414,7 @@ static void *migration_thread(void *opaque) =20 object_ref(OBJECT(s)); update_iteration_initial_status(s); - + savevm_set_mode(VMS_MIGRATE); qemu_savevm_state_header(s->to_dst_file); =20 /* diff --git a/migration/savevm.c b/migration/savevm.c index a07fcad..ce02b6b 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -256,6 +256,7 @@ typedef struct SaveState { const char *name; uint32_t target_page_bits; uint32_t caps_count; + VMStateMode mode; MigrationCapability *capabilities; QemuUUID uuid; } SaveState; @@ -266,16 +267,15 @@ static SaveState savevm_state =3D { .global_section_id =3D 0, }; =20 -/* - * The FOREACH macros will filter handlers based on the current operation = when - * additional conditions are added in a subsequent patch. - */ +/* The FOREACH macros filter handlers based on the current operation. */ =20 #define SAVEVM_FOREACH(se, entry) \ QTAILQ_FOREACH(se, &savevm_state.handlers, entry) \ + if (savevm_state.mode & mode_mask(se)) =20 #define SAVEVM_FOREACH_SAFE(se, entry, new_se) \ QTAILQ_FOREACH_SAFE(se, &savevm_state.handlers, entry, new_se) \ + if (savevm_state.mode & mode_mask(se)) =20 /* The FORALL macros unconditionally loop over all handlers. */ =20 @@ -285,6 +285,33 @@ static SaveState savevm_state =3D { #define SAVEVM_FORALL_SAFE(se, entry, new_se) \ QTAILQ_FOREACH_SAFE(se, &savevm_state.handlers, entry, new_se) =20 +/* + * Set the current mode to be used for filtering savevm handlers in + * SAVEVM_FOREACH. + */ +void savevm_set_mode(VMStateMode mode) +{ + savevm_state.mode =3D mode; +} + +/* + * A savevm handler is selected in SAVEVM_FOREACH if its mask overlaps the + * current mode. The mask is defined by either the new vmsd interface or = the + * legacy ops interface. If the mask is zero, it implicily includes all m= odes. + */ +static inline unsigned mode_mask(SaveStateEntry *se) +{ + const VMStateDescription *vmsd =3D se->vmsd; + unsigned mask =3D 0; + + if (vmsd) { + mask =3D vmsd->mode_mask; + } else if (se->ops) { + mask =3D se->ops->mode_mask; + } + return mask ? mask : VMS_MODE_ALL; +} + static bool should_validate_capability(int capability) { assert(capability >=3D 0 && capability < MIGRATION_CAPABILITY__MAX); @@ -1527,12 +1554,14 @@ void qemu_savevm_state_cleanup(void) } } =20 -static int qemu_savevm_state(QEMUFile *f, Error **errp) +static int qemu_savevm_state(QEMUFile *f, VMStateMode mode, Error **errp) { int ret; MigrationState *ms =3D migrate_get_current(); MigrationStatus status; =20 + savevm_set_mode(mode); + if (migration_is_running(ms->state)) { error_setg(errp, QERR_MIGRATION_ACTIVE); return -EINVAL; @@ -2557,13 +2586,14 @@ out: return ret; } =20 -int qemu_loadvm_state(QEMUFile *f) +int qemu_loadvm_state(QEMUFile *f, VMStateMode mode) { MigrationIncomingState *mis =3D migration_incoming_get_current(); Error *local_err =3D NULL; int ret; =20 - if (qemu_savevm_state_blocked(&local_err)) { + if ((mode & (VMS_SNAPSHOT | VMS_MIGRATE)) && + qemu_savevm_state_blocked(&local_err)) { error_report_err(local_err); return -EINVAL; } @@ -2736,7 +2766,7 @@ int save_snapshot(const char *name, Error **errp) error_setg(errp, "Could not open VM state file"); goto the_end; } - ret =3D qemu_savevm_state(f, errp); + ret =3D qemu_savevm_state(f, VMS_SNAPSHOT, errp); vm_state_size =3D qemu_ftell(f); ret2 =3D qemu_fclose(f); if (ret < 0) { @@ -2785,6 +2815,7 @@ void qmp_xen_save_devices_state(const char *filename,= bool has_live, bool live, int saved_vm_running; int ret; =20 + savevm_set_mode(VMS_MIGRATE); if (!has_live) { /* live default to true so old version of Xen tool stack can have a * successfull live migration */ @@ -2850,7 +2881,7 @@ void qmp_xen_load_devices_state(const char *filename,= Error **errp) f =3D qemu_fopen_channel_input(QIO_CHANNEL(ioc)); object_unref(OBJECT(ioc)); =20 - ret =3D qemu_loadvm_state(f); + ret =3D qemu_loadvm_state(f, VMS_MIGRATE); qemu_fclose(f); if (ret < 0) { error_setg(errp, QERR_IO_ERROR); @@ -2928,7 +2959,7 @@ int load_snapshot(const char *name, Error **errp) mis->from_src_file =3D f; =20 aio_context_acquire(aio_context); - ret =3D qemu_loadvm_state(f); + ret =3D qemu_loadvm_state(f, VMS_SNAPSHOT); migration_incoming_state_destroy(); aio_context_release(aio_context); =20 diff --git a/migration/savevm.h b/migration/savevm.h index ba64a7e..4b7ce91 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -14,6 +14,8 @@ #ifndef MIGRATION_SAVEVM_H #define MIGRATION_SAVEVM_H =20 +#include "migration/vmstate.h" + #define QEMU_VM_FILE_MAGIC 0x5145564d #define QEMU_VM_FILE_VERSION_COMPAT 0x00000002 #define QEMU_VM_FILE_VERSION 0x00000003 @@ -60,7 +62,7 @@ void qemu_savevm_send_colo_enable(QEMUFile *f); void qemu_savevm_live_state(QEMUFile *f); int qemu_save_device_state(QEMUFile *f); =20 -int qemu_loadvm_state(QEMUFile *f); +int qemu_loadvm_state(QEMUFile *f, VMStateMode mode); void qemu_loadvm_state_cleanup(void); int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis); int qemu_load_device_state(QEMUFile *f); --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596123616; cv=none; d=zohomail.com; s=zohoarc; b=gk6YkuNK5enAlzYYYc8ybIq0RKmxGgWxEmeYPJ5+4AZeDKd99TIBMn/XwExWl84lAITVfdWpGCzixwKxqwIXXoMPtEXECSqcwi40V+6yYwYZv1HvICYsq/P0oIXAYhqUPXvvPvBHvKvXDMTKSxjrF69jj46SyKDLV1RdR1mMmK8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596123616; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=NTT/O6BWx9NAiOeWb7X9irO+Oulxu74/KXA7hp5V6/k=; b=k+LIgGCehk1yofCbK0p8N2VSvjMyrRyyilYslgzOrJStfzX1a3U6dX8jTAoVwvkrz+tZhhbOQo/DO4P+RE5cLmqe67RLIiYGZF7vJGirTupbzj/CnEKzI2v0pcvWz4QTNYDUHbJWF6FRKTkjrrAEhr+RnDp8dHQ/pv1bgWDkTIA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596123616902405.8538833226248; Thu, 30 Jul 2020 08:40:16 -0700 (PDT) Received: from localhost ([::1]:59812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1AfH-0000Tb-H5 for importer@patchew.org; Thu, 30 Jul 2020 11:40:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdC-000770-Gs for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:06 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:49920) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1Ad7-00025A-Tr for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:06 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXaIp007640; Thu, 30 Jul 2020 15:37:57 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 32hu1jmfda-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:37:57 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFWpt3188405; Thu, 30 Jul 2020 15:37:56 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 32hu5xj9n9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:37:56 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 06UFbtAJ001812; Thu, 30 Jul 2020 15:37:55 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:37:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=NTT/O6BWx9NAiOeWb7X9irO+Oulxu74/KXA7hp5V6/k=; b=YVoVl/dTQMeSJSbSxIGf3e3TL5B9sj+n4Zdn/AdhPcwQWYz7e5yTW1DfX8+U2GeMV+YQ p3pVpCiY6tfapoxdyM3Hx/ReUdZA5SLlIwFehQYLN0TIFCwBywxW5/drg3LjvsR18TN/ 1JWa8jn0wsaXTU8qqX8AVERAXxEBjgxIkgI18wqvrIwqoMP51ktCMCnV1HXVtdOP4y+X MlK/VEGfdtJ1gY4Y1I7Fd2GoXIiAgPKJ0Tfhp5nkreoeyDTH+CHjW0qj+wGP6+jxF5Wk KZMfuY6ismCxZWOchu0R6JiUNxFQuteLkMpA8EyD4bc41Nvl457pM2NMA9Zq3p4sMsrN 7A== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 03/32] savevm: QMP command for cprsave Date: Thu, 30 Jul 2020 08:14:07 -0700 Message-Id: <1596122076-341293-4-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxscore=0 adultscore=0 spamscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 clxscore=1015 malwarescore=0 spamscore=0 suspectscore=1 bulkscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.86; envelope-from=steven.sistare@oracle.com; helo=userp2130.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:37:58 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" To enable live reboot, provide the cprsave QMP command and the VMS_REBOOT vmstate-saving operation, which saves the state of the virtual machine in a simple file. Syntax: {'command':'cprsave', 'data':{'file':'str', 'mode':'str'}} The mode argument must be 'reboot'. Additional modes will be defined in the future. Unlike the savevm command, cprsave supports any type of guest image and block device. cprsave stops the VM so that guest ram and block devices are not modified after state is saved. Guest ram must be mapped to a persistent memory file such as /dev/dax0.0. The ram object vmstate handler and block device handler do not apply to VMS_REBOOT, so restrict them to VMS_MIGRATE or VMS_SNAPSHOT. After cprsave completes successfully, qemu exits. After issuing cprsave, the caller may update qemu, update the host kernel, reboot, start qemu using the same arguments as the original process, and issue the cprload command to restore the guest. cprload is added by subsequent patches. If the caller suspends the guest instead of stopping the VM, such as by issuing guest-suspend-ram to the qemu guest agent, then cprsave and cprload support guests with vfio devices. The guest drivers suspend methods flush outstanding requests and re-initialize the devices, and thus there is no device state to save and restore. Signed-off-by: Steve Sistare Signed-off-by: Maran Wilson --- include/migration/vmstate.h | 1 + include/sysemu/sysemu.h | 2 ++ migration/block.c | 1 + migration/ram.c | 1 + migration/savevm.c | 59 +++++++++++++++++++++++++++++++++++++++++= ++++ monitor/qmp-cmds.c | 6 +++++ qapi/migration.json | 14 +++++++++++ 7 files changed, 84 insertions(+) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index fa575f9..c58551a 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -161,6 +161,7 @@ typedef enum { typedef enum { VMS_MIGRATE =3D (1U << 1), VMS_SNAPSHOT =3D (1U << 2), + VMS_REBOOT =3D (1U << 3), VMS_MODE_ALL =3D ~0U } VMStateMode; =20 diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 4b6a5c4..6fe86e6 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -24,6 +24,8 @@ extern bool machine_init_done; void qemu_add_machine_init_done_notifier(Notifier *notify); void qemu_remove_machine_init_done_notifier(Notifier *notify); =20 +void save_cpr_snapshot(const char *file, const char *mode, Error **errp); + extern int autostart; =20 typedef enum { diff --git a/migration/block.c b/migration/block.c index 737b649..a69accb 100644 --- a/migration/block.c +++ b/migration/block.c @@ -1023,6 +1023,7 @@ static SaveVMHandlers savevm_block_handlers =3D { .load_state =3D block_load, .save_cleanup =3D block_migration_cleanup, .is_active =3D block_is_active, + .mode_mask =3D VMS_MIGRATE | VMS_SNAPSHOT, }; =20 void blk_mig_init(void) diff --git a/migration/ram.c b/migration/ram.c index 76d4fee..f0d5d9f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3795,6 +3795,7 @@ static SaveVMHandlers savevm_ram_handlers =3D { .load_setup =3D ram_load_setup, .load_cleanup =3D ram_load_cleanup, .resume_prepare =3D ram_resume_prepare, + .mode_mask =3D VMS_MIGRATE | VMS_SNAPSHOT, }; =20 void ram_mig_init(void) diff --git a/migration/savevm.c b/migration/savevm.c index ce02b6b..ff1a46e 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2680,6 +2680,65 @@ int qemu_load_device_state(QEMUFile *f) return 0; } =20 +static QEMUFile *qf_file_open(const char *filename, int flags, int mode, + Error **errp) +{ + QIOChannel *ioc; + int fd =3D qemu_open(filename, flags, mode); + + if (fd < 0) { + error_setg_errno(errp, errno, "%s(%s)", __func__, filename); + return NULL; + } + + ioc =3D QIO_CHANNEL(qio_channel_file_new_fd(fd)); + + if (flags & O_WRONLY) { + return qemu_fopen_channel_output(ioc); + } + + return qemu_fopen_channel_input(ioc); +} + +void save_cpr_snapshot(const char *file, const char *mode, Error **errp) +{ + int ret =3D 0; + QEMUFile *f; + VMStateMode op; + + if (!strcmp(mode, "reboot")) { + op =3D VMS_REBOOT; + } else { + error_setg(errp, "cprsave: bad mode %s", mode); + return; + } + + f =3D qf_file_open(file, O_CREAT | O_WRONLY | O_TRUNC, 0600, errp); + if (!f) { + return; + } + + ret =3D global_state_store(); + if (ret) { + error_setg(errp, "Error saving global state"); + qemu_fclose(f); + return; + } + + vm_stop(RUN_STATE_SAVE_VM); + + ret =3D qemu_savevm_state(f, op, errp); + if ((ret < 0) && !*errp) { + error_setg(errp, "qemu_savevm_state failed"); + } + qemu_fclose(f); + + if (op =3D=3D VMS_REBOOT) { + no_shutdown =3D 0; + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); + } +} + int save_snapshot(const char *name, Error **errp) { BlockDriverState *bs, *bs1; diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 864cbfa..9ec7b88 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -35,6 +35,7 @@ #include "qapi/qapi-commands-machine.h" #include "qapi/qapi-commands-misc.h" #include "qapi/qapi-commands-ui.h" +#include "qapi/qapi-commands-migration.h" #include "qapi/qmp/qerror.h" #include "hw/mem/memory-device.h" #include "hw/acpi/acpi_dev_interface.h" @@ -161,6 +162,11 @@ void qmp_cont(Error **errp) } } =20 +void qmp_cprsave(const char *file, const char *mode, Error **errp) +{ + save_cpr_snapshot(file, mode, errp); +} + void qmp_system_wakeup(Error **errp) { if (!qemu_wakeup_suspend_enabled()) { diff --git a/qapi/migration.json b/qapi/migration.json index d500055..b61df1d 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1621,3 +1621,17 @@ ## { 'event': 'UNPLUG_PRIMARY', 'data': { 'device-id': 'str' } } + +## +# @cprsave: +# +# Create a checkpoint of the virtual machine device state in @file. +# Guest RAM and guest block device blocks are not saved. +# +# @file: name of checkpoint file +# @mode: 'reboot' : checkpoint can be cprload'ed after a host kexec reboot. +# +# Since 5.0 +## +{ 'command': 'cprsave', 'data': { 'file': 'str', 'mode': 'str' } } + --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596123606; cv=none; d=zohomail.com; s=zohoarc; b=S54z911F/uNwhj802YmJCN4QQM9ChLgZIBNkdd+FGGbDlZFS7Ap8F5iXFPFTRF+iEiURQN0kasF3Xqg3WaQk1g0jwm5pnN6eEHquHKswc1y0c6aFAimkeGjhf25Q7BuDG8VhLVM7asq19u49ynN0TbKxRWFRHTLrbQC+85eLZi4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596123606; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=hbOroEKaTxV0w6TXCHIDZ5gWaq360kaGUNlpSPZEzCw=; b=NakT3upG+Pvd0IZFHfeCfS98S5Gx4LCx60aRPcTMN9QV+rpUiWQd+paOnMY30CQGXEebxE916xU4fc8i67G5djNrzC+X7c7wenV9jgOJ+phCSif5Y8CW2J7wQ53X8x/POs0mW5AspR9bv3gzJamh36xOXIfrCpi9H1oLuTiPLfc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596123606477791.4364690116637; Thu, 30 Jul 2020 08:40:06 -0700 (PDT) Received: from localhost ([::1]:59758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1Af7-0000SA-58 for importer@patchew.org; Thu, 30 Jul 2020 11:40:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdB-00076G-GO for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:05 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:49936) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1Ad8-00025Z-Cr for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:05 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXqlU008034; Thu, 30 Jul 2020 15:37:58 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 32hu1jmfdk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:37:58 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFYj2Q172040; Thu, 30 Jul 2020 15:37:58 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 32hu5x0w2p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:37:57 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 06UFbu84001820; Thu, 30 Jul 2020 15:37:56 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:37:56 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=hbOroEKaTxV0w6TXCHIDZ5gWaq360kaGUNlpSPZEzCw=; b=VnmNKzPJh0AifsGIk2Ca/laONYb95ExHFi+JFYY74cFN9Mw20vYgRdwncN5kJlfLdyoB Bd0VrRfD7fLau2xoAGMS7GFBNlCYQi2C/cm6E6o8YOPJtx6m4fWfpUqij+JtFKuXG1IA JLfozkiGUqufd5h/7ro8yZX4q0pjPd2wY47rQiztOonGBe/yBfCHgYXYoG5JyQoaogPN qgpfw9ZHoc4OJ4ay6Ci+1lvyQdwVHY5j+fKEMGm7Ngnp5JZCbwRNpo9ViGFJl8g6oa9u iBBHzbnVUobDqGGg+EdVzqq+TP3WDPwNps7wHiG0MRpLblR9+TUS2MkCLD9rZq2xkVq4 8Q== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 04/32] savevm: HMP Command for cprsave Date: Thu, 30 Jul 2020 08:14:08 -0700 Message-Id: <1596122076-341293-5-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 suspectscore=3 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 clxscore=1015 malwarescore=0 spamscore=0 suspectscore=3 bulkscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.86; envelope-from=steven.sistare@oracle.com; helo=userp2130.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:37:58 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Enable HMP access to the cprsave QMP command. Usage: cprsave Signed-off-by: Maran Wilson Signed-off-by: Steve Sistare --- hmp-commands.hx | 18 ++++++++++++++++++ include/monitor/hmp.h | 1 + monitor/hmp-cmds.c | 10 ++++++++++ 3 files changed, 29 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 60f395c..c8defd9 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -354,6 +354,24 @@ SRST ERST =20 { + .name =3D "cprsave", + .args_type =3D "file:s,mode:s", + .params =3D "file 'reboot'", + .help =3D "create a checkpoint of the VM in file", + .cmd =3D hmp_cprsave, + }, + +SRST +``cprsave`` *tag* + Stop VCPUs, create a checkpoint of the whole virtual machine and save it + in *file*. + If *mode* is 'reboot', the checkpoint can be cprload'ed after a host kex= ec + reboot. + exec() /usr/bin/qemu-exec if it exists, else exec /usr/bin/qemu-system-x= 86_64, + passing all the original command line arguments. The VCPUs remain pause= d. +ERST + + { .name =3D "delvm", .args_type =3D "name:s", .params =3D "tag", diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index c986cfd..af8ee23 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -59,6 +59,7 @@ void hmp_balloon(Monitor *mon, const QDict *qdict); void hmp_loadvm(Monitor *mon, const QDict *qdict); void hmp_savevm(Monitor *mon, const QDict *qdict); void hmp_delvm(Monitor *mon, const QDict *qdict); +void hmp_cprsave(Monitor *mon, const QDict *qdict); void hmp_migrate_cancel(Monitor *mon, const QDict *qdict); void hmp_migrate_continue(Monitor *mon, const QDict *qdict); void hmp_migrate_incoming(Monitor *mon, const QDict *qdict); diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index ae4b6a4..59196ed 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1139,6 +1139,16 @@ void hmp_announce_self(Monitor *mon, const QDict *qd= ict) qapi_free_AnnounceParameters(params); } =20 +void hmp_cprsave(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + + qmp_cprsave(qdict_get_try_str(qdict, "file"), + qdict_get_try_str(qdict, "mode"), + &err); + hmp_handle_error(mon, err); +} + void hmp_migrate_cancel(Monitor *mon, const QDict *qdict) { qmp_migrate_cancel(NULL); --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596124235; cv=none; d=zohomail.com; s=zohoarc; b=lMPP4OFGfknzGuoyWCZ29msnbHNtpL34+a5GuXo7dem6VDafhB/v/ISZD7E4cjkbGZpbQMpyO561e3P8hszZ2mHj2Wu7DjPyc0e7FseZgTNiEPes4wlzUYSvX2ECWWCv/B08JJe7gis4wp/OZdNlDkjWoWLLQeryf8z+muuAdqA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596124235; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=d1OT3ty10GFpJwdnOpO08ryOwyf2KWtChB0Ypajkg9M=; b=ih65ps1aEfoRboX1X5R0UsGkSBslHPmozQxba30I4avF2gejrDZjYB4DF1M0qiGN+R/2hqTemk11wtAhTmlGW+In2tZjWjrIBPRAB2fRJcVPZOuWVcq1XdJYChvjvyiiLz2C9zy//yFh9yiohXFfcDSjpAFAbQXUxMgQqIyuM4M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596124235487457.0110134452176; Thu, 30 Jul 2020 08:50:35 -0700 (PDT) Received: from localhost ([::1]:39562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1ApG-0007dv-9U for importer@patchew.org; Thu, 30 Jul 2020 11:50:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1Af6-0001CJ-0o for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:04 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:47832) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1Af3-0002U1-Qz for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:03 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXTG9152212; Thu, 30 Jul 2020 15:39:58 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 32hu1jveb2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:39:58 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXSO3130733; Thu, 30 Jul 2020 15:37:58 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 32hu5wwgn1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:37:58 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 06UFbuT0001829; Thu, 30 Jul 2020 15:37:56 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:37:56 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=d1OT3ty10GFpJwdnOpO08ryOwyf2KWtChB0Ypajkg9M=; b=Emg4Uuw5rZONqvucdJs1QRfhNS/VSGS6ktxi6Fl0eaas4SWyKxs2/jXtQCYKSec9hn5R UdxaVYHTqAdFjL3djkWKp613Q3pT3XqMTxBzROxjajnw6bXWIBM9bt/aexroVagum4t3 OngfikS4/GMsMqMLfy5k6gWhv9rEXLbetxFz0R00Pf2HkER+sEJysMP9iohPbvArq5p9 TOUHZvQS4jvr7wsAjhOvrf/parVwHgdKVFVWAljc4Wb4EgfMvskxQ2TjRJsLzHKga7y0 jxq8E87vYQcKVYcf5X95e/bHdMGI1lnAnbsn2qASgaO3caSzn6i5ckMZgwgO7NtHlFaf QQ== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 05/32] savevm: QMP command for cprload Date: Thu, 30 Jul 2020 08:14:09 -0700 Message-Id: <1596122076-341293-6-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=1 bulkscore=0 malwarescore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxlogscore=999 malwarescore=0 impostorscore=0 priorityscore=1501 spamscore=0 phishscore=0 suspectscore=1 bulkscore=0 mlxscore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.85; envelope-from=steven.sistare@oracle.com; helo=userp2120.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:38:02 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Provide the cprload QMP command. The VM is created from the file produced by the cprsave command. Guest RAM is restored in-place from the shared memory backend file, and guest block devices are used as is. The contents of such devices must not be modified between the cprsave and cprload operations. If the VM was running at cprsave time, then VM execution resumes. Syntax: {'command':'cprload', 'data':{'file':'str'}} Signed-off-by: Steve Sistare Signed-off-by: Maran Wilson --- include/sysemu/sysemu.h | 2 ++ migration/savevm.c | 34 ++++++++++++++++++++++++++++++++++ monitor/qmp-cmds.c | 5 +++++ qapi/migration.json | 11 +++++++++++ softmmu/vl.c | 15 ++++++++++++++- 5 files changed, 66 insertions(+), 1 deletion(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 6fe86e6..5360da5 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -25,6 +25,7 @@ void qemu_add_machine_init_done_notifier(Notifier *notify= ); void qemu_remove_machine_init_done_notifier(Notifier *notify); =20 void save_cpr_snapshot(const char *file, const char *mode, Error **errp); +void load_cpr_snapshot(const char *file, Error **errp); =20 extern int autostart; =20 @@ -53,6 +54,7 @@ extern uint8_t *boot_splash_filedata; extern bool enable_mlock; extern bool enable_cpu_pm; extern QEMUClockType rtc_clock; +extern int start_on_wake; =20 #define MAX_OPTION_ROMS 16 typedef struct QEMUOptionRom { diff --git a/migration/savevm.c b/migration/savevm.c index ff1a46e..1509173 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2948,6 +2948,40 @@ void qmp_xen_load_devices_state(const char *filename= , Error **errp) migration_incoming_state_destroy(); } =20 +void load_cpr_snapshot(const char *file, Error **errp) +{ + QEMUFile *f; + int ret; + RunState state; + + if (runstate_is_running()) { + error_setg(errp, "cprload called for a running VM"); + return; + } + + f =3D qf_file_open(file, O_RDONLY, 0, errp); + if (!f) { + return; + } + + ret =3D qemu_loadvm_state(f, VMS_REBOOT); + qemu_fclose(f); + if (ret < 0) { + error_setg(errp, "Error %d while loading VM state", ret); + return; + } + + state =3D global_state_get_runstate(); + if (state =3D=3D RUN_STATE_RUNNING) { + vm_start(); + } else { + runstate_set(state); + if (runstate_check(RUN_STATE_SUSPENDED)) { + start_on_wake =3D 1; + } + } +} + int load_snapshot(const char *name, Error **errp) { BlockDriverState *bs, *bs_vm_state; diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 9ec7b88..81e6feb 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -167,6 +167,11 @@ void qmp_cprsave(const char *file, const char *mode, E= rror **errp) save_cpr_snapshot(file, mode, errp); } =20 +void qmp_cprload(const char *file, Error **errp) +{ + load_cpr_snapshot(file, errp); +} + void qmp_system_wakeup(Error **errp) { if (!qemu_wakeup_suspend_enabled()) { diff --git a/qapi/migration.json b/qapi/migration.json index b61df1d..ce4d32b 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1635,3 +1635,14 @@ ## { 'command': 'cprsave', 'data': { 'file': 'str', 'mode': 'str' } } =20 +## +# @cprload: +# +# Start virtual machine from checkpoint file that was created earlier using +# the cprsave command. +# +# @file: name of checkpoint file +# +# Since 5.0 +## +{ 'command': 'cprload', 'data': { 'file': 'str' } } diff --git a/softmmu/vl.c b/softmmu/vl.c index 660537a..8478778 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -137,6 +137,7 @@ static time_t rtc_ref_start_datetime; static int rtc_realtime_clock_offset; /* used only with QEMU_CLOCK_REALTIM= E */ static int rtc_host_datetime_offset =3D -1; /* valid & used only with RTC_BASE_DATETIME */ +int start_on_wake; QEMUClockType rtc_clock; int vga_interface_type =3D VGA_NONE; static DisplayOptions dpy; @@ -602,6 +603,8 @@ static const RunStateTransition runstate_transitions_de= f[] =3D { { RUN_STATE_PRELAUNCH, RUN_STATE_RUNNING }, { RUN_STATE_PRELAUNCH, RUN_STATE_FINISH_MIGRATE }, { RUN_STATE_PRELAUNCH, RUN_STATE_INMIGRATE }, + { RUN_STATE_PRELAUNCH, RUN_STATE_SUSPENDED }, + { RUN_STATE_PRELAUNCH, RUN_STATE_PAUSED }, =20 { RUN_STATE_FINISH_MIGRATE, RUN_STATE_RUNNING }, { RUN_STATE_FINISH_MIGRATE, RUN_STATE_PAUSED }, @@ -1519,7 +1522,17 @@ void qemu_system_wakeup_request(WakeupReason reason,= Error **errp) if (!(wakeup_reason_mask & (1 << reason))) { return; } - runstate_set(RUN_STATE_RUNNING); + + /* + * Must call vm_start if it has never been called, to invoke the state + * change callbacks for the first time. + */ + if (start_on_wake) { + start_on_wake =3D 0; + vm_start(); + } else { + runstate_set(RUN_STATE_RUNNING); + } wakeup_reason =3D reason; qemu_notify_event(); } --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596123778; cv=none; d=zohomail.com; s=zohoarc; b=Oobz8zEmmHfTRuX4vE+0pSv6p6hRpcH2jYNFG2l9gTsEnzQDPVw8eT4zQ2f1suGblHQLZ0zii5mIEJ1nqQqx586EpcXd3Q6Cdgcd2QftnRxaFLp8/MhtHEIsphYztFAvSlmycNOci9FONTUIQwl5uaXrINmU5oc1xeeS73krZu4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596123778; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=FhQZqmnrXiwORnkpYuq9o89R1YbrPjuI/aCeYDWM5Gs=; b=cXkswidhdcnyzBxEZjqD8KmAhjmpfHvLUyXvETm1zA0whHyc7voSfNPtErd1qP7RTYnFCb4Lhe9Zlkw1HPxVvuH5ltDaCaKo+yqw6tOJ1Ru08Qi+16zg0qmp1YqUb+Oq78tZmu26/Hk51IpfslB0LFX0G4bptGsxkwa8wCZ6EwU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596123778696341.1296533298963; Thu, 30 Jul 2020 08:42:58 -0700 (PDT) Received: from localhost ([::1]:40214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1Aht-0004Jy-BO for importer@patchew.org; Thu, 30 Jul 2020 11:42:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53790) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdB-000769-Bv for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:05 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:36938) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1Ad8-00025k-35 for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:04 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXbJh156082; Thu, 30 Jul 2020 15:38:00 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 32hu1jmec8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:37:59 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXSQJ130734; Thu, 30 Jul 2020 15:37:59 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 32hu5wwgp3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:37:59 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 06UFbvPD014430; Thu, 30 Jul 2020 15:37:57 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:37:57 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=FhQZqmnrXiwORnkpYuq9o89R1YbrPjuI/aCeYDWM5Gs=; b=zFCQdrwigoggttk5e8vZF0uCpMyx974zHqWu7Bx++ALp0YH4btozEmQ9bZjsklag/daH F6kwwnUktRtMLyB/LVFdW5tZwpvgN9I/+8jkU29r35LWEiIBMy0Ec0C68tK7zP8iDMd3 hLafR4LHQmkHqNhIyuW7BoGPKixWlYvJPvt2BH93+ZNA/L92xFpFEjHWi223NIsJguwm nFHnNLKLjaqckTx0OIi1oukCBoWWgp8RIr3Qc6cLkDmhBcuOX4PV2G7ys+OKZSfKmrOt rqCAV/pd6COEtwqtQC+/ouhNOmt+uzokpHZahRMa2dCgM1rq1eHoMJyfTLvtopMpUlOj Xw== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 06/32] savevm: HMP Command for cprload Date: Thu, 30 Jul 2020 08:14:10 -0700 Message-Id: <1596122076-341293-7-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=977 mlxscore=0 suspectscore=1 bulkscore=0 malwarescore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 mlxlogscore=993 lowpriorityscore=0 malwarescore=0 clxscore=1015 mlxscore=0 impostorscore=0 phishscore=0 adultscore=0 suspectscore=1 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=141.146.126.78; envelope-from=steven.sistare@oracle.com; helo=aserp2120.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:37:57 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Enable HMP access to the cprload QMP command. Usage: cprload Signed-off-bu: Maran Wilson Signed-off-by: Steve Sistare --- hmp-commands.hx | 13 +++++++++++++ include/monitor/hmp.h | 1 + monitor/hmp-cmds.c | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index c8defd9..cb67150 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -372,6 +372,19 @@ SRST ERST =20 { + .name =3D "cprload", + .args_type =3D "file:s", + .params =3D "file", + .help =3D "load VM checkpoint from file", + .cmd =3D hmp_cprload, + }, + +SRST +``cprload`` *tag* + Load a virtual machine from checkpoint file *file* and continue VCPUs. +ERST + + { .name =3D "delvm", .args_type =3D "name:s", .params =3D "tag", diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index af8ee23..7b8cdfd 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -60,6 +60,7 @@ void hmp_loadvm(Monitor *mon, const QDict *qdict); void hmp_savevm(Monitor *mon, const QDict *qdict); void hmp_delvm(Monitor *mon, const QDict *qdict); void hmp_cprsave(Monitor *mon, const QDict *qdict); +void hmp_cprload(Monitor *mon, const QDict *qdict); void hmp_migrate_cancel(Monitor *mon, const QDict *qdict); void hmp_migrate_continue(Monitor *mon, const QDict *qdict); void hmp_migrate_incoming(Monitor *mon, const QDict *qdict); diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 59196ed..ba95737 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1149,6 +1149,14 @@ void hmp_cprsave(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, err); } =20 +void hmp_cprload(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + + qmp_cprload(qdict_get_try_str(qdict, "file"), &err); + hmp_handle_error(mon, err); +} + void hmp_migrate_cancel(Monitor *mon, const QDict *qdict) { qmp_migrate_cancel(NULL); --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596123899; cv=none; d=zohomail.com; s=zohoarc; b=WbeuBNumItXJUTnNj0s9jJ80O2aJZuO8QhhpIPXfbhLAUlx0OV5MjMdrmpoyXYU11+BDI2FS3NmZoQgE+HswGDVWh4M03u6ND2K0Nj2/pArmpwu5SJdMa+kxZKuNIOeqFriHfZlDBbCASE8zV/aX9u6jVL7Abw92bHh/sdVxCUw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596123899; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=h6VW8WSg+pOehoYaPNZ8J01kel1i2awnl/tUOVeNh6I=; b=GawDB5q6MMkzPQFUNQ3Gn5mVV7slE5N4fxZttpEuSyY2JGf4xC1t8Oah0ug8trE1quyHc4o4QsZOIQtMAeTgxaKGV9zlIBLuGasJY4axoFJg5H3GaMcgS/MH4KN1UxBdwICsuFnmC1KEw6BgYPfeGgaJIDuJf83lmKt4lmMz1QI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596123899191998.5083998067832; Thu, 30 Jul 2020 08:44:59 -0700 (PDT) Received: from localhost ([::1]:48498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1Ajp-0007qU-Ta for importer@patchew.org; Thu, 30 Jul 2020 11:44:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdB-000764-78 for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:05 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:36958) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1Ad8-000263-VP for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:04 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXP0g155719; Thu, 30 Jul 2020 15:38:00 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 32hu1jmecc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:38:00 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXSWD130724; Thu, 30 Jul 2020 15:37:59 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 32hu5wwgph-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:37:59 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 06UFbwP1014433; Thu, 30 Jul 2020 15:37:58 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:37:58 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=h6VW8WSg+pOehoYaPNZ8J01kel1i2awnl/tUOVeNh6I=; b=IfjgW050F/XW/3Xml1jZsZnb0W1dQSCQF/9DB/nrLUJh6W5Dk0tHnwRJdgswj0Ngz10E +/LhlgfAITCh+4WcKCEe1srXgD9j60PZG5dqevaDfAfb0ug4TXIR7H4JSegXr4ScXMEu s/rwWaKwBa/Ejisj0kl9U/W82sk7cp/wsVlQgD7akIOEZ+Dcrd/nwwyKmykwC9tSujgD k1vHwI1Hq3rqHsfmo4RAGWIaoik/TEiiJDc5Rraz/QB99mtpW0OYmJQXm6LQPNEpysQc DPqFOGF3ln0BUBo2mKmuOL/IDdTe0WO7sbAHf4UL96+qtCXuxTHdZJ4NJzi6Xw0Gl8ju VA== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 07/32] savevm: QMP command for cprinfo Date: Thu, 30 Jul 2020 08:14:11 -0700 Message-Id: <1596122076-341293-8-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=1 bulkscore=0 malwarescore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 clxscore=1015 mlxscore=0 impostorscore=0 phishscore=0 adultscore=0 suspectscore=1 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=141.146.126.78; envelope-from=steven.sistare@oracle.com; helo=aserp2120.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:37:57 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Provide the cprinfo QMP command. This returns a string with a space- separated list of modes supported by cprsave, and can be used by clients as a feature test to check if the running QEMU instance supports cprsave. Syntax: {'command':'cprinfo', 'returns':'str'} Signed-off-by: Steve Sistare --- monitor/qmp-cmds.c | 5 +++++ qapi/migration.json | 9 +++++++++ qapi/pragma.json | 1 + 3 files changed, 15 insertions(+) diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 81e6feb..8c400e6 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -162,6 +162,11 @@ void qmp_cont(Error **errp) } } =20 +char *qmp_cprinfo(Error **errp) +{ + return g_strdup("reboot"); +} + void qmp_cprsave(const char *file, const char *mode, Error **errp) { save_cpr_snapshot(file, mode, errp); diff --git a/qapi/migration.json b/qapi/migration.json index ce4d32b..8190b16 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1623,6 +1623,15 @@ 'data': { 'device-id': 'str' } } =20 ## +# @cprinfo: +# +# Return a space-delimited list of modes supported by the cprsave command +# +# Since 5.0 +## +{ 'command': 'cprinfo', 'returns': 'str' } + +## # @cprsave: # # Create a checkpoint of the virtual machine device state in @file. diff --git a/qapi/pragma.json b/qapi/pragma.json index cffae27..43bdb39 100644 --- a/qapi/pragma.json +++ b/qapi/pragma.json @@ -5,6 +5,7 @@ { 'pragma': { # Commands allowed to return a non-dictionary: 'returns-whitelist': [ + 'cprinfo', 'human-monitor-command', 'qom-get', 'query-migrate-cache-size', --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596123618; cv=none; d=zohomail.com; s=zohoarc; b=FywGLfRw1126ERt91rxG9Xj7uj15H/Nx34oDlcNZqG5K2gV4y8atn7uQjiqklWof67QlJ1ec3YzqGOOrcXfmvxnvsXLXcYTzVbCaILUYigG7C0M8+gDoZGqbk5U5aMPN5QgLIf4+92ZeG9/rfNz9I8PDnGtVPwr2FgNQ5kzVY4g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596123618; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=aiKW6/1eRgMEg/BPEoaBrBmwEPrCXVYIEMzTQ/w6CR8=; b=Syp3b2wFEHZobW4XYP4MzeS7jGqo1gfp3beFAGyio8cgHnSIR0ESVYQ2Tu0hU9IfhqSY7bp/I0PQ1OtL/w/s1tUeeuP/kUeZWEHGmOkoAHzck41tbXvwAVidHdZWrmOgfCH5oj/VoiQURrw/s/DNx2C47t1Rs3J7l1JcffxvHuM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596123618404406.4108673642045; Thu, 30 Jul 2020 08:40:18 -0700 (PDT) Received: from localhost ([::1]:59844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1AfH-0000UM-TT for importer@patchew.org; Thu, 30 Jul 2020 11:40:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdD-00077o-CB for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:07 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:46036) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1Ad9-00026H-N9 for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:06 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXOTE152139; Thu, 30 Jul 2020 15:38:00 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 32hu1jvdxq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:38:00 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXSnY130844; Thu, 30 Jul 2020 15:38:00 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 32hu5wwgpn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:00 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 06UFbxD3001845; Thu, 30 Jul 2020 15:37:59 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:37:59 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=aiKW6/1eRgMEg/BPEoaBrBmwEPrCXVYIEMzTQ/w6CR8=; b=eMhrEBdmo9++yKbghcpVHAB4AVHoF7lWu1/6UVIL2SSwk93Ppl/Ispg+LgTR8NIjRm3v hybT9EOQuf+oqI+mqvCrRYQfDZwUvnOdbLnqTdxa9VR7ZbxdMPMErCq8Et9Ue6c/Fmbq lLjFp3P8980gcqq1mG4xKZATstl68t8zL9B0/4G52YbbXs3kWJfGwjIPqyl9ZQAKLPXB F1h+pWuRiGuAHYcT5Q1kX1OTzWnyC5761rHm6sJ8AkUofUXx9YTvy7o+QJ0zE+oRqtEC cXHXo6Edw5ET4hqM6apaUujbfbPbwmxs6i8SWdxLjGPKye7I4bEIkJoJN9a5V3o8Gbas pA== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 08/32] savevm: HMP command for cprinfo Date: Thu, 30 Jul 2020 08:14:12 -0700 Message-Id: <1596122076-341293-9-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=3 bulkscore=0 malwarescore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxlogscore=999 malwarescore=0 impostorscore=0 priorityscore=1501 spamscore=0 phishscore=0 suspectscore=3 bulkscore=0 mlxscore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.85; envelope-from=steven.sistare@oracle.com; helo=userp2120.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:38:02 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Enable HMP access to the cprinfo QMP command. Usage: cprinfo Signed-off-by: Steve Sistare --- hmp-commands.hx | 13 +++++++++++++ include/monitor/hmp.h | 1 + monitor/hmp-cmds.c | 10 ++++++++++ 3 files changed, 24 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index cb67150..7517876 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -354,6 +354,19 @@ SRST ERST =20 { + .name =3D "cprinfo", + .args_type =3D "", + .params =3D "", + .help =3D "return list of modes supported by cprsave", + .cmd =3D hmp_cprinfo, + }, + +SRST +``cprinfo`` *tag* + Return a space-delimited list of modes supported by cprsave. +ERST + + { .name =3D "cprsave", .args_type =3D "file:s,mode:s", .params =3D "file 'reboot'", diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index 7b8cdfd..919b9a9 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -59,6 +59,7 @@ void hmp_balloon(Monitor *mon, const QDict *qdict); void hmp_loadvm(Monitor *mon, const QDict *qdict); void hmp_savevm(Monitor *mon, const QDict *qdict); void hmp_delvm(Monitor *mon, const QDict *qdict); +void hmp_cprinfo(Monitor *mon, const QDict *qdict); void hmp_cprsave(Monitor *mon, const QDict *qdict); void hmp_cprload(Monitor *mon, const QDict *qdict); void hmp_migrate_cancel(Monitor *mon, const QDict *qdict); diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index ba95737..2f6af07 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1139,6 +1139,16 @@ void hmp_announce_self(Monitor *mon, const QDict *qd= ict) qapi_free_AnnounceParameters(params); } =20 +void hmp_cprinfo(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + char *res =3D qmp_cprinfo(&err); + + monitor_printf(mon, "%s\n", res); + g_free(res); + hmp_handle_error(mon, err); +} + void hmp_cprsave(Monitor *mon, const QDict *qdict) { Error *err =3D NULL; --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596123776; cv=none; d=zohomail.com; s=zohoarc; b=JaPZsEcdKJQfDfacfHhEfE7qnAM2bidvdTCKpTV8MJP55469XSKZYgBh+NAPekzTXYuZ6IHn7mU+X2Q8kWVSOvKm1s8olguK37LkLw4+x+oYlzkYdviNEyaahkN6kllupfRkxQeVoMCx9kuElR5PcMrR2T1FMz2UxRDyuhIRucU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596123776; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=Q6iOoNWsJ7EJZ/SrWzpci9KqugByM0dkae4gvLigMYc=; b=gb/SdqHN0iHP6q8g8sfR3sYMDWUmJ2KbH+hP/fsARKo1FTXPIYHX+w0KE2EKKWuf0vqrDshIcMVvIHhyy0PYnZUpw/eSbHjwj3VXJIuAzI6fM3NKgb6m5aUhN4ev7ohz/o15GzLA09cilT1deylygI2vfkAbVzHLNLqlb+wXbVc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15961237765142.4655555794968222; Thu, 30 Jul 2020 08:42:56 -0700 (PDT) Received: from localhost ([::1]:40150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1Ahr-0004IL-8S for importer@patchew.org; Thu, 30 Jul 2020 11:42:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54588) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1Af9-0001Gg-0U for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:11 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:51862) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1Af6-0002UV-JE for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:06 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXoQC008019; Thu, 30 Jul 2020 15:40:01 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 32hu1jmftp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:40:01 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXToC130863; Thu, 30 Jul 2020 15:38:01 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 32hu5wwgqe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:01 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 06UFc0rN020352; Thu, 30 Jul 2020 15:38:00 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:37:59 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=Q6iOoNWsJ7EJZ/SrWzpci9KqugByM0dkae4gvLigMYc=; b=0ZuMsyclxLoMaOJsBoTuEX47Rbk4rqe/Sf42FnCb55kX3MJDI7mFIC/mfQ46UScl4vFy jdzniQunw7hLOpIhK29xhzDFYe8W3Zz/VUWB0fA8fL0pAaCAwHVc2md9q91HWmIDsvch P7QE2dd8JbHtG2NsvDR3rAmA4MRWRG/mm3MFDAmWKu+00oJuvJ1AwUp1rVIpv2srp/3J vwyiSlQqyrMApoJD4T7oYmT15LyNfMosKMQbn6TS9iHckl2mtFrcnlSz2pEpoOG0lpww 9Mh2TiCcE3p5hIy889/ihUmXeFRepKlj6cj/vylASixogMHGGi0mTGOMswN+uXfTPeS1 UA== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 09/32] savevm: prevent cprsave if memory is volatile Date: Thu, 30 Jul 2020 08:14:13 -0700 Message-Id: <1596122076-341293-10-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=1 bulkscore=0 malwarescore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 clxscore=1015 malwarescore=0 spamscore=0 suspectscore=1 bulkscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.86; envelope-from=steven.sistare@oracle.com; helo=userp2130.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:37:58 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" cprsave and cprload require that guest ram be backed by an externally visible shared file. Check that in cprsave. Signed-off-by: Steve Sistare --- exec.c | 32 ++++++++++++++++++++++++++++++++ include/exec/memory.h | 2 ++ migration/savevm.c | 4 ++++ 3 files changed, 38 insertions(+) diff --git a/exec.c b/exec.c index 6f381f9..02160e0 100644 --- a/exec.c +++ b/exec.c @@ -2726,6 +2726,38 @@ ram_addr_t qemu_ram_addr_from_host(void *ptr) return block->offset + offset; } =20 +/* + * Return true if any memory regions are writable and not backed by shared + * memory. Exclude x86 option rom shadow "pc.rom" by name, even though it= is + * writable. + */ +bool qemu_ram_volatile(Error **errp) +{ + RAMBlock *block; + MemoryRegion *mr; + bool ret =3D false; + + rcu_read_lock(); + QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { + mr =3D block->mr; + if (mr && + memory_region_is_ram(mr) && + !memory_region_is_ram_device(mr) && + !memory_region_is_rom(mr) && + (!mr->name || strcmp(mr->name, "pc.rom")) && + (block->fd =3D=3D -1 || !qemu_ram_is_shared(block))) { + + error_setg(errp, "Memory region %s is volatile", + memory_region_name(mr)); + ret =3D true; + break; + } + } + + rcu_read_unlock(); + return ret; +} + /* Generate a debug exception if a watchpoint has been hit. */ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, MemTxAttrs attrs, int flags, uintptr_t ra) diff --git a/include/exec/memory.h b/include/exec/memory.h index 307e527..6aafbb0 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -2519,6 +2519,8 @@ bool ram_block_discard_is_disabled(void); */ bool ram_block_discard_is_required(void); =20 +bool qemu_ram_volatile(Error **errp); + #endif =20 #endif diff --git a/migration/savevm.c b/migration/savevm.c index 1509173..f101039 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2713,6 +2713,10 @@ void save_cpr_snapshot(const char *file, const char = *mode, Error **errp) return; } =20 + if (op =3D=3D VMS_REBOOT && qemu_ram_volatile(errp)) { + return; + } + f =3D qf_file_open(file, O_CREAT | O_WRONLY | O_TRUNC, 0600, errp); if (!f) { return; --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596123774; cv=none; d=zohomail.com; s=zohoarc; b=LXmc18GRwK6odfqhWHxcz60X5YTwIw0dMRmNDIn4Pq2GXKg5kq6GD2rBvqy3yjX2oCx101qGASISC+iPuwW9DGQzZ/70c9jduGHFhz6FV82vTL5CEfn9nw70NV80KemSyooJmMXuKnkZ0TkP7Ji5R8cUsb5maNl2QZW8EQgnJbs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596123774; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=b9FFmQWTlGqrcBgCjwNHHJqNdI4vPeyPId0JJEpNZUw=; b=R0XqrrPMVf3679B/1fjnW8LPsON856V85ux8e+yrTZn4M6QJE6WeSUYKssCh96PL3avQ3bzB3HI+VOGkA1KESB7RLZ6hWOUSz2Lm5Ay70LNz64/3mz29xOJ7MrhKVwtB4JaBONnzzCToVWxGb979BIjCRwztnV2n1ME4LNm6Lls= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596123774827810.8926689994656; Thu, 30 Jul 2020 08:42:54 -0700 (PDT) Received: from localhost ([::1]:40148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1Ahp-0004IC-II for importer@patchew.org; Thu, 30 Jul 2020 11:42:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdD-00077X-4t for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:07 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:46092) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdB-00026T-9R for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:06 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXQQp152168; Thu, 30 Jul 2020 15:38:02 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 32hu1jvdy0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:38:02 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFYjGo172130; Thu, 30 Jul 2020 15:38:02 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 32hu5x0w82-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:02 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 06UFc04Q020369; Thu, 30 Jul 2020 15:38:00 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:00 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=b9FFmQWTlGqrcBgCjwNHHJqNdI4vPeyPId0JJEpNZUw=; b=QW1mNHZLrKDI/TyJrxY+XfKmOOCm/o670xc2IK+Uk4v6pGxinNIgtDDfEUu5JbPsVewe u5v1pkp1N5LmEQXSSaGRJKPa2SEoRkUDtMbISHOsufdivMrOZ79nGWzbPcF9DBw1moDO e8589BC9YDDXt9AcsPJcDdhgPCOYcDT87IogVuLQKZts437c6sB2tWEsEclB8rtcxzj6 5icyMQMR9dMGwO3WCSuHEOLd+sIlIBU1NQFQdvJDG65F/CL1KWwLOJS8v3U7+JamxpJQ sZsGzZIPDUv3+ep1lJx78rrK7ivnOg+Uj/+FRfEESvNeOASDyJG6yf+VVfoNab/a6gb8 hg== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 10/32] kvmclock: restore paused KVM clock Date: Thu, 30 Jul 2020 08:14:14 -0700 Message-Id: <1596122076-341293-11-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 suspectscore=1 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxlogscore=999 malwarescore=0 impostorscore=0 priorityscore=1501 spamscore=0 phishscore=0 suspectscore=1 bulkscore=0 mlxscore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.85; envelope-from=steven.sistare@oracle.com; helo=userp2120.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:38:02 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If the VM is paused when the KVM clock is serialized to a file, record that the clock is valid, so the value will be reused rather than overwritten after cprload with a new call to KVM_GET_CLOCK here: kvmclock_vm_state_change() if (running) ... else if (s->clock_valid) return; <-- instead, return here kvm_update_clock() kvm_vm_ioctl(kvm_state, KVM_GET_CLOCK, &data) <-- overwritten Signed-off-by: Steve Sistare --- hw/i386/kvm/clock.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c index 6428335..161991a 100644 --- a/hw/i386/kvm/clock.c +++ b/hw/i386/kvm/clock.c @@ -285,18 +285,22 @@ static int kvmclock_pre_save(void *opaque) if (!s->runstate_paused) { kvm_update_clock(s); } + if (!runstate_is_running()) { + s->clock_valid =3D true; + } =20 return 0; } =20 static const VMStateDescription kvmclock_vmsd =3D { .name =3D "kvmclock", - .version_id =3D 1, + .version_id =3D 2, .minimum_version_id =3D 1, .pre_load =3D kvmclock_pre_load, .pre_save =3D kvmclock_pre_save, .fields =3D (VMStateField[]) { VMSTATE_UINT64(clock, KVMClockState), + VMSTATE_BOOL_V(clock_valid, KVMClockState, 2), VMSTATE_END_OF_LIST() }, .subsections =3D (const VMStateDescription * []) { --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596124034; cv=none; d=zohomail.com; s=zohoarc; b=OzewPSmQ02LbTJ8qkPbVRNv+HfXGhv8l9/3iRnHpFAQLK6PovNhupraqq/KH8XjLHalibJZPPA1pYEN0nwX4A1UZvXoa8+aI46pIj8ELpI9Iiww4RzTkUjxxy6kjhROPhHlioPZrMzsog6Silc9XyFyvVh+AFgP00z3S/zS/RpU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596124034; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=WIdUxn9OcuYCdzIU7jtF5oYpZlffe7b3B0nwEV0DcXQ=; b=FCumirJYU0qMn7j+8xAHZ3J1Cqac//HQwArPFqjj94hTKFnueRk3h+0k8Uh1kK5WdfAj7JfZfRloiPNcjlekfyPEkyGc+61gQu6joAQXjoMQfKuAWNQMDFff9Xf6hpa/ihxY70NaqbFGWMyUMFC5QiqFlyLY9knAOnt06fONXuI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596124034878983.1031512591609; Thu, 30 Jul 2020 08:47:14 -0700 (PDT) Received: from localhost ([::1]:57132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1Am0-00036x-R7 for importer@patchew.org; Thu, 30 Jul 2020 11:47:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53846) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdE-00079M-Ch for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:08 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50026) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdC-00026i-Fm for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:08 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXPfS007499; Thu, 30 Jul 2020 15:38:03 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 32hu1jmfe9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:38:03 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXSO7130733; Thu, 30 Jul 2020 15:38:03 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 32hu5wwgrs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:03 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 06UFc1a2001856; Thu, 30 Jul 2020 15:38:01 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:01 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=WIdUxn9OcuYCdzIU7jtF5oYpZlffe7b3B0nwEV0DcXQ=; b=Idqb+eb/kPVYcnaYIuBBMxCEsHywZyNZ5zR8eLlndIQT1SVl79keTdvaTz7EXyVJ1v8S 4mIXyqo3ed0Pu6scMS1pnwYxrtgv0k92hQEG6QST0OIoXw/q3d/SZFFa2ACEHWPgw1i/ zj0Ra5aO+7Hi+1ljZgw7dgllcUI4SEyj530lT4yvvJlp3Qttvf1VDgAHo5Btehjke1RE grDLuI6ajvkqQSkU5QmD8GZTC41h4IDBBcO7bk6E7k7cHq+6wglbn6aHI2uI3VIhKL22 rrs5t8U4RJbs56DPrNmzRoYv5aJ8KmI/rwy0cKhzc/W1Z5c6rffdY7XSP3jaMuzIePqu dA== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 11/32] cpu: disable ticks when suspended Date: Thu, 30 Jul 2020 08:14:15 -0700 Message-Id: <1596122076-341293-12-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=1 bulkscore=0 malwarescore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 clxscore=1015 malwarescore=0 spamscore=0 suspectscore=1 bulkscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.86; envelope-from=steven.sistare@oracle.com; helo=userp2130.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:37:58 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" After cprload, the guest console misbehaves. You must type 8 characters before any are echoed to the terminal. Qemu was not sending interrupts to the guest because the QEMU_CLOCK_VIRTUAL timers_state.cpu_clock_offset was bad. The offset is usually updated at cprsave time by the path save_cpr_snapshot() vm_stop() do_vm_stop() if (runstate_is_running()) cpu_disable_ticks(); timers_state.cpu_clock_offset =3D cpu_get_clock_locked(); However, if the guest is in RUN_STATE_SUSPENDED, then cpu_disable_ticks is not called. Further, the earlier transition to suspended in qemu_system_suspend did not disable ticks. To fix, call cpu_disable_ticks from save_cpr_snapshot. Signed-off-by: Steve Sistare --- migration/savevm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/migration/savevm.c b/migration/savevm.c index f101039..00f493b 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2729,6 +2729,11 @@ void save_cpr_snapshot(const char *file, const char = *mode, Error **errp) return; } =20 + /* Update timers_state before saving. Suspend did not so do. */ + if (runstate_check(RUN_STATE_SUSPENDED)) { + cpu_disable_ticks(); + } + vm_stop(RUN_STATE_SAVE_VM); =20 ret =3D qemu_savevm_state(f, op, errp); --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596123898; cv=none; d=zohomail.com; s=zohoarc; b=HxBEZLOupBDvwCfng4bGkFlwiOxrhqUA5wRWDlCRAYtJRMiUmXtPISxBUYMF0i1iKxfvZzrnkd034QCP/2TK1II9zVtOMDkhpvGH53I6n4MwGgrLGQsjReo8QvstVLQnHrHPm2YlnJcoHBTD8RUsVXhIKcCtmz53Z+gcWaXx/OM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596123898; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=pBOdcc2CBeYUKc86FdzgZ3jsx9sNsQgOjultivuhWfI=; b=gvANpoUMqThqn8DKzJibkoT33qgznU8uR+VtM5eeM4/zJ8Y22FMuXsgITe6BeCC0yY+yJ1ET2H7k+3sg7nyflQ5XhWsaJLTbNyA+dDyFXh+Z4TlhpCM1BL6HNwzyxuBM26Q8NcJoISWUZyzW/edn5cpkpHxgZYBioiHq36MI0cM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596123898450140.98484959727352; Thu, 30 Jul 2020 08:44:58 -0700 (PDT) Received: from localhost ([::1]:48434 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1Ajp-0007on-7B for importer@patchew.org; Thu, 30 Jul 2020 11:44:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdF-0007AK-1v for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:09 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:46116) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdD-00026o-1Q for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:08 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXSVG152193; Thu, 30 Jul 2020 15:38:04 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 32hu1jvdyb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:38:04 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFYjDR172050; Thu, 30 Jul 2020 15:38:03 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 32hu5x0wat-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:03 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 06UFc2t8014453; Thu, 30 Jul 2020 15:38:02 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:02 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=pBOdcc2CBeYUKc86FdzgZ3jsx9sNsQgOjultivuhWfI=; b=cGYDjR1GRjZh/vQl/QWcM8tVySYpzykPsAVYJnYc2EuRyDUJYbwcJrMMvvMimy/k/ptf dmzMdCEaSVMy6dYZOZULIYSlgAlajX4Y7ZG2cjDpG9LTGXy99CFZaPYc2KoW60ogYzS9 OUVVE8Uy7gb5nN7DuUXCXMS/lJ5tpuFPF6ZCZ5c+BttNM8PcVQGBH2d1Lj/YnLbIH5I2 /KspMc+8CTs4yl8B9rts6rwtYYMoZSuOw4ssrFMFDK8FuxiQjDXeUr05EkXlIvumgZpY DkuiTpqb5uZapYBgP58IN4vyqhnDKg+vvmUr+nU/SAIIGXuNMyeaJtPACi9Q5cWmnq6B Ig== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 12/32] vl: pause option Date: Thu, 30 Jul 2020 08:14:16 -0700 Message-Id: <1596122076-341293-13-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 suspectscore=1 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxlogscore=999 malwarescore=0 impostorscore=0 priorityscore=1501 spamscore=0 phishscore=0 suspectscore=1 bulkscore=0 mlxscore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.85; envelope-from=steven.sistare@oracle.com; helo=userp2120.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:38:02 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Provide the -pause command-line parameter and the QEMU_PAUSE environment variable to briefly pause QEMU in main and allow a developer to attach gdb. Useful when the developer does not invoke QEMU directly, such as when using libvirt. Usage: qemu -pause or export QEMU_PAUSE=3D Signed-off-by: Steve Sistare --- qemu-options.hx | 9 +++++++++ softmmu/vl.c | 15 ++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/qemu-options.hx b/qemu-options.hx index 708583b..8505cf2 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3668,6 +3668,15 @@ SRST option is experimental. ERST =20 +DEF("pause", HAS_ARG, QEMU_OPTION_pause, \ + "-pause secs Pause for secs seconds on entry to main.\n", QEMU_ARCH= _ALL) + +SRST +``--pause secs`` + Pause for a number of seconds on entry to main. Useful for attaching + a debugger after QEMU has been launched by some other entity. +ERST + DEF("S", 0, QEMU_OPTION_S, \ "-S freeze CPU at startup (use 'c' to start execution)\n", QEMU_ARCH_ALL) diff --git a/softmmu/vl.c b/softmmu/vl.c index 8478778..951994f 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2844,7 +2844,7 @@ static void create_default_memdev(MachineState *ms, c= onst char *path) =20 void qemu_init(int argc, char **argv, char **envp) { - int i; + int i, seconds; int snapshot, linux_boot; const char *initrd_filename; const char *kernel_filename, *kernel_cmdline; @@ -2882,6 +2882,13 @@ void qemu_init(int argc, char **argv, char **envp) QemuPluginList plugin_list =3D QTAILQ_HEAD_INITIALIZER(plugin_list); int mem_prealloc =3D 0; /* force preallocation of physical target memo= ry */ =20 + if (getenv("QEMU_PAUSE")) { + seconds =3D atoi(getenv("QEMU_PAUSE")); + printf("Pausing %d seconds for debugger. QEMU PID is %d\n", + seconds, getpid()); + sleep(seconds); + } + os_set_line_buffering(); =20 error_init(argv[0]); @@ -3204,6 +3211,12 @@ void qemu_init(int argc, char **argv, char **envp) case QEMU_OPTION_gdb: add_device_config(DEV_GDB, optarg); break; + case QEMU_OPTION_pause: + seconds =3D atoi(optarg); + printf("Pausing %d seconds for debugger. QEMU PID is %d\n", + seconds, getpid()); + sleep(seconds); + break; case QEMU_OPTION_L: if (is_help_option(optarg)) { list_data_dirs =3D true; --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596124770; cv=none; d=zohomail.com; s=zohoarc; b=c9XOPV7BBLN5gnK93K821DTYJuDHiBoLN6qItpBECccJFrYjO45uLCaEGXEAOzDCH/HMepZWSSKg4tzuArK2OC007Rsw00q1rHOV0HCkWPKT9eEYtDo0skhS3r1qnH51tiSpdudCW+pxJZhnmKyUfgEPu1gIS5VMZwfQj07+wdk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596124770; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=J39U91hwUcfjz6AYWlnaWvznYzeNFQTfjjlfc4yEwTc=; b=X/gCSpwMOqPLy4rwhCxJZUscrT9xvMM6Lzrbk6LgKWJ30LMuyrpcrPoQ68VWGXVgD3huqdbXo9mYu9b2DUeT+qf3sHbEtKC8wpVprahLPCcRnGvg++A4oA19kW/+OmpfmDwKt2QmGsmu6wmZNBcyt4GkY+91WeH+oJq+cCu5tQA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596124769878491.6203312977102; Thu, 30 Jul 2020 08:59:29 -0700 (PDT) Received: from localhost ([::1]:39448 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1Axq-00033n-ED for importer@patchew.org; Thu, 30 Jul 2020 11:59:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AfQ-0001U9-6N for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:24 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:51922) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AfD-0002Uz-Dm for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:23 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXSrw007533; Thu, 30 Jul 2020 15:40:06 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 32hu1jmfu8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:40:05 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFWZQ9176243; Thu, 30 Jul 2020 15:38:04 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 32hu61a1dc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:04 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 06UFc3LM007477; Thu, 30 Jul 2020 15:38:03 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:02 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=J39U91hwUcfjz6AYWlnaWvznYzeNFQTfjjlfc4yEwTc=; b=HATlcllz2geWSo0JhUch8jXfS1fmtj7O9TyiHsJYjFPaRVDZCeD9Tz5HgwVNuurK+n6o cXnAY0V139k71HxrTw9/UJoRxGXpspBaYq2SzfP2oeHxSnZDDjqh6jP+tr1EpiVJ/VDI pgg6nhMLZ9VaJY/y2A+qnoFYI8yLnxqtd1AiHCYLddNqnbufpztgHOc2QsngkAKx6fiY 0zPtXwz106C/Af2PXxoPgz2GpouL6XZHkRpNAN3qBs5fvTOJwkLYMcww5QK4M5rcQ7Z1 VTm2ybj3k2PWjTx8v0Mi3zjCEsyHCV56QouTqUqVaQvOq9DOjB8KZgfYFw6yhprbmfrA yw== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 13/32] gdbstub: gdb support for suspended state Date: Thu, 30 Jul 2020 08:14:17 -0700 Message-Id: <1596122076-341293-14-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 clxscore=1015 malwarescore=0 spamscore=0 suspectscore=1 bulkscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.86; envelope-from=steven.sistare@oracle.com; helo=userp2130.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:37:58 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Modify the gdb server so a continue command appears to resume execution when in RUN_STATE_SUSPENDED. Do not print the next gdb prompt, but do not actually resume instruction fetch. While in this "fake" running mode, a ctrl-C returns the user to the gdb prompt. Signed-off-by: Steve Sistare --- gdbstub.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index f3a318c..2f0d9ff 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -461,7 +461,9 @@ static inline void gdb_continue(void) #else if (!runstate_needs_reset()) { trace_gdbstub_op_continue(); - vm_start(); + if (!runstate_check(RUN_STATE_SUSPENDED)) { + vm_start(); + } } #endif } @@ -490,7 +492,7 @@ static int gdb_continue_partial(char *newstates) int flag =3D 0; =20 if (!runstate_needs_reset()) { - if (vm_prepare_start()) { + if (!runstate_check(RUN_STATE_SUSPENDED) && vm_prepare_start()) { return 0; } =20 @@ -2835,6 +2837,9 @@ static void gdb_read_byte(uint8_t ch) /* when the CPU is running, we cannot do anything except stop it when receiving a char */ vm_stop(RUN_STATE_PAUSED); + } else if (runstate_check(RUN_STATE_SUSPENDED) && ch =3D=3D 3) { + /* Received ctrl-c from gdb */ + gdb_vm_state_change(0, 0, RUN_STATE_PAUSED); } else #endif { @@ -3282,6 +3287,8 @@ static void gdb_sigterm_handler(int signal) { if (runstate_is_running()) { vm_stop(RUN_STATE_PAUSED); + } else if (runstate_check(RUN_STATE_SUSPENDED)) { + gdb_vm_state_change(0, 0, RUN_STATE_PAUSED); } } #endif --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596123957; cv=none; d=zohomail.com; s=zohoarc; b=PxANGLIimQR6t9ll5bS9C59P3fv991ixl1jALkLs5xBK9TbYF1a14NzpBjUJRxJfM67gY3r3nJNnUZ/bVmnsl365c9X+bZNzqJUKnTR2e7Mm8Dvja6d9Nb63pCvmJTQcVFpOn8fzFlTII+SkC8qhztXEUszRjljJSms9Gbv13qw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596123957; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=PujpgNBRqtJDW0eHkpwQ/PjdVFOXyApGGQ17TcFFI7A=; b=Bb/xLdqVBFzKbY7KmPN0lYjTho3BXVzs+Jne2OI++qnajtOP1XotA9H21utjunSBfIeJsWZD8s7OVoYHxM3mL7+wzLKeN+dvE0bI+pPB+JqsOD+4ftIBF/xRLL0AxjReZHgTVqcOzd2NLJCaX/yqXUivqJeELlWdusxBJOFEuWE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596123957812937.224405294705; Thu, 30 Jul 2020 08:45:57 -0700 (PDT) Received: from localhost ([::1]:51570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1Akm-0000iU-8T for importer@patchew.org; Thu, 30 Jul 2020 11:45:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdG-0007EE-Km for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:10 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50058) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdE-000279-Ie for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:10 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXTUh007545; Thu, 30 Jul 2020 15:38:05 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 32hu1jmfem-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:38:05 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFYkKR172346; Thu, 30 Jul 2020 15:38:05 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 32hu5x0wct-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:05 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 06UFc3BR007481; Thu, 30 Jul 2020 15:38:03 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:03 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=PujpgNBRqtJDW0eHkpwQ/PjdVFOXyApGGQ17TcFFI7A=; b=aEj6mFVU1tghb/4DWX+gv+Z7cCHY+DyW7tIrLybr0cWjqo5fueUL9bx2W9ehaBlYPgp2 NVoKnZOZaqGW5J4ekjaDBnWXMKxqPbcWCb9acb2VdEbCoBgmwzdN0goFyAufaUpnQymh psKloh3aTZHzp31nCeBIRTfi+gl1qbuJUxJ71+P7LikJ8PpmD/4vtd9og9WLjoGJohhN L5qUf+2lLbcHZiFhQuhpVXKAsY1o60yl31mFEWgXyS+TOOSqb8SPluSRGPpV1nOgozK0 jun6SwUcByLOUELRAT6FA7u7h+IdkJcHbU8RVpqOm3DQDGTXV+apy8fJ8liN/480h8eX IQ== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 14/32] savevm: VMS_RESTART and cprsave restart Date: Thu, 30 Jul 2020 08:14:18 -0700 Message-Id: <1596122076-341293-15-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 suspectscore=1 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 clxscore=1015 malwarescore=0 spamscore=0 suspectscore=1 bulkscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.86; envelope-from=steven.sistare@oracle.com; helo=userp2130.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:37:58 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add the VMS_RESTART variant of vmstate, for use when upgrading qemu in place on the same host without a reboot. Invoke it using: cprsave restart VMS_RESTART supports guest ram mapped by private anonymous memory, versus VMS_REBOOT which requires that guest ram be mapped by persistent shared memory. Subsequent patches complete its implementation. Signed-off-by: Steve Sistare --- hmp-commands.hx | 4 +++- include/migration/vmstate.h | 1 + migration/savevm.c | 4 +++- monitor/qmp-cmds.c | 2 +- qapi/migration.json | 1 + 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 7517876..11a2089 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -369,7 +369,7 @@ ERST { .name =3D "cprsave", .args_type =3D "file:s,mode:s", - .params =3D "file 'reboot'", + .params =3D "file 'restart'|'reboot'", .help =3D "create a checkpoint of the VM in file", .cmd =3D hmp_cprsave, }, @@ -380,6 +380,8 @@ SRST in *file*. If *mode* is 'reboot', the checkpoint can be cprload'ed after a host kex= ec reboot. + If *mode* is 'restart', the checkpoint can be cprload'ed after restarting + qemu. exec() /usr/bin/qemu-exec if it exists, else exec /usr/bin/qemu-system-x= 86_64, passing all the original command line arguments. The VCPUs remain pause= d. ERST diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index c58551a..8239b84 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -162,6 +162,7 @@ typedef enum { VMS_MIGRATE =3D (1U << 1), VMS_SNAPSHOT =3D (1U << 2), VMS_REBOOT =3D (1U << 3), + VMS_RESTART =3D (1U << 4), VMS_MODE_ALL =3D ~0U } VMStateMode; =20 diff --git a/migration/savevm.c b/migration/savevm.c index 00f493b..38cc63a 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2708,6 +2708,8 @@ void save_cpr_snapshot(const char *file, const char *= mode, Error **errp) =20 if (!strcmp(mode, "reboot")) { op =3D VMS_REBOOT; + } else if (!strcmp(mode, "restart")) { + op =3D VMS_RESTART; } else { error_setg(errp, "cprsave: bad mode %s", mode); return; @@ -2973,7 +2975,7 @@ void load_cpr_snapshot(const char *file, Error **errp) return; } =20 - ret =3D qemu_loadvm_state(f, VMS_REBOOT); + ret =3D qemu_loadvm_state(f, VMS_REBOOT | VMS_RESTART); qemu_fclose(f); if (ret < 0) { error_setg(errp, "Error %d while loading VM state", ret); diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 8c400e6..8a74c6e 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -164,7 +164,7 @@ void qmp_cont(Error **errp) =20 char *qmp_cprinfo(Error **errp) { - return g_strdup("reboot"); + return g_strdup("reboot restart"); } =20 void qmp_cprsave(const char *file, const char *mode, Error **errp) diff --git a/qapi/migration.json b/qapi/migration.json index 8190b16..d22992b 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1639,6 +1639,7 @@ # # @file: name of checkpoint file # @mode: 'reboot' : checkpoint can be cprload'ed after a host kexec reboot. +# 'restart': checkpoint can be cprload'ed after restarting qemu. # # Since 5.0 ## --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596124041; cv=none; d=zohomail.com; s=zohoarc; b=C0Os7ZRhee+eklaiySwCyWAC2NUM5BeAKXdkyM4ewgyaAnmNXSIkICc3Oz+6pQpuHdo/GfbBZDl7aa9ulyozjH7owij1soPEKglMBBwqMyxjYaXonkdPQLDH/tu/4JSN7yyR4PelhCYlfid3hqH0uDybkxrXG838s1rUuasdYsw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596124041; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=fYdkKNzUmAEAASFvyVOY1gxPGlabooBwhMTDAwC7ovs=; b=YCkuwNimQXv3i/M5WRYWjUzwHG7iRhuT6ofpamYarPB3SE9IkulNDZdRhq1i9Jm2bBJH96Zi7CT/sXmA4AEI3Abnd2alJZFwXFtSKRnqqomjAGCwZKHRMkZ4VDL6YI68updbbupOj8b+mFIZ7AF3wezXQ7biqUgbVgLvs+/cs34= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596124041038810.0695311732504; Thu, 30 Jul 2020 08:47:21 -0700 (PDT) Received: from localhost ([::1]:56924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1Aly-00031m-7Z for importer@patchew.org; Thu, 30 Jul 2020 11:47:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdH-0007FW-4w for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:11 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:46140) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdF-00027Q-5K for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:10 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXPHJ152152; Thu, 30 Jul 2020 15:38:06 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 32hu1jvdyg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:38:06 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFWZoc176171; Thu, 30 Jul 2020 15:38:05 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 32hu61a1em-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:05 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 06UFc4IN020459; Thu, 30 Jul 2020 15:38:04 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:04 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=fYdkKNzUmAEAASFvyVOY1gxPGlabooBwhMTDAwC7ovs=; b=yKTS0uk+3YFIJUctgZKyXWdl0SWovuzz/3cS88Uzl3kN83L/nLd9SDoijiapmDdL7BrE OUw1fRC3ZN78h3pOMSwFX8CuuBHJf4GTcLPAWg8jAnPcXVSlIpryuNbj9unJ4ajaSqzK FGeZ8ID4vmYXYc0Y5BBOCzu9xiNtZZT7Lzc/Y0/VbKCGQO8k7T9tN765LnqQjdidqdqB vzcO72BrUIE/g61TzXeLmTO748Z4+ihv6FQNSS8xP3RaS7ZcJkgjiJFEXP1yVsvmgBda hL/2nh6mJ5xFX2uMYbCqLGhzeXTCzLdQqqMEhNFxLvieEVoXWlq9MO9Ry578BPE0XSYQ 4g== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 15/32] vl: QEMU_START_FREEZE env var Date: Thu, 30 Jul 2020 08:14:19 -0700 Message-Id: <1596122076-341293-16-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxlogscore=999 malwarescore=0 impostorscore=0 priorityscore=1501 spamscore=0 phishscore=0 suspectscore=1 bulkscore=0 mlxscore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.85; envelope-from=steven.sistare@oracle.com; helo=userp2120.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:38:02 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For qemu upgrade and restart, we will re-exec() qemu with the same argv. However, qemu must start in a paused state and wait for the cprload command, and the original argv might not contain the -S option. To avoid modifying argv, provide the QEMU_START_FREEZE environment variable. If QEMU_START_FREEZE is set, then set autostart=3D0, like the -S option. Signed-off-by: Steve Sistare --- softmmu/vl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/softmmu/vl.c b/softmmu/vl.c index 951994f..7016e39 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -4501,6 +4501,11 @@ void qemu_init(int argc, char **argv, char **envp) exit(0); } =20 + if (getenv("QEMU_START_FREEZE")) { + unsetenv("QEMU_START_FREEZE"); + autostart =3D 0; + } + if (incoming) { Error *local_err =3D NULL; qemu_start_incoming_migration(incoming, &local_err); --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596124170; cv=none; d=zohomail.com; s=zohoarc; b=enlxlvJY6zeoDxdlwlF5fwOUruRHCzysLkfJe0g2NG6MpSQVrNa0qqz2Ra5a/qYgbIPfSomq6CT4DIYAujzFybvz2nR40W5o1B4vJ1P9qXyB1ournibocSMMY7CyKGwV/FTy6i9J/Gdl4GsRE9rPQ3lXBkgCWrmlLD2i8XE6bQs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596124170; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=zM458HGdyaODhwUhyFUAZDGWqeYgtjsyFhfbjis7N84=; b=XDnnciYMXaD3YVLcRp3nXawKcNG4lA0BTAvnYcsRon7gVwFM+Hne2Ozs4BZajQXiEmwunXNwsDF0dQoXyT/1LM1zMAIhhBEDwmLYDOENTYWQP1BJ+0jkRS/2DGDkIN1P4onyfYj7C1sC+N3v+oahZYhK2FzXtCJih46vC6qfK7g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596124170844719.657676065156; Thu, 30 Jul 2020 08:49:30 -0700 (PDT) Received: from localhost ([::1]:37210 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1AoD-0006fk-K5 for importer@patchew.org; Thu, 30 Jul 2020 11:49:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdI-0007H9-18 for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:12 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:37076) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdF-00028f-Nr for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:11 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXUnq155764; Thu, 30 Jul 2020 15:38:07 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 32hu1jmedf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:38:07 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFWZL3176147; Thu, 30 Jul 2020 15:38:07 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 32hu61a1h1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:07 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 06UFc5gj014470; Thu, 30 Jul 2020 15:38:05 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=zM458HGdyaODhwUhyFUAZDGWqeYgtjsyFhfbjis7N84=; b=uSb0dsIk/YqpNEEaFE+Hm0bhEDfB9TraPWhQzf8MtiCGvd2m9TZhimSEZqnBVqWNbBuA /DtYx+KERiBBTS6oH37vZfW9V3eMMOZqJA7Vdck0bgzV0V3VpMu0y4ltWREh666EkH7W fmHps+1wTKF0B1wVt3UOKH85w8jQR+EEAAr+EPUvQoMKPytaRP8ZxZJx08nl3NXPmJAc 7liEfkhl2B6GKP/7K5bIz2d4Ac4HA7rjYtF+F3BpDhByjsoQbFOsJJpaOnqnu57mjO4F mVd4dijeeQyWgR5p8U30uYWt4I3A6QL0+TsJVDd5xagABc+Wwc0VHFSKp15MO5oeLGi6 RA== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 16/32] oslib: add qemu_clr_cloexec Date: Thu, 30 Jul 2020 08:14:20 -0700 Message-Id: <1596122076-341293-17-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 clxscore=1015 mlxscore=0 impostorscore=0 phishscore=0 adultscore=0 suspectscore=1 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=141.146.126.78; envelope-from=steven.sistare@oracle.com; helo=aserp2120.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:37:57 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Steve Sistare Reviewed-by: Dr. David Alan Gilbert --- include/qemu/osdep.h | 1 + util/oslib-posix.c | 9 +++++++++ util/oslib-win32.c | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 45c217a..bb28df1 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -551,6 +551,7 @@ static inline void qemu_timersub(const struct timeval *= val1, #endif =20 void qemu_set_cloexec(int fd); +void qemu_clr_cloexec(int fd); =20 /* Starting on QEMU 2.5, qemu_hw_version() returns "2.5+" by default * instead of QEMU_VERSION, so setting hw_version on MachineClass diff --git a/util/oslib-posix.c b/util/oslib-posix.c index d923674..28fee45 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -314,6 +314,15 @@ void qemu_set_cloexec(int fd) assert(f !=3D -1); } =20 +void qemu_clr_cloexec(int fd) +{ + int f; + f =3D fcntl(fd, F_GETFD); + assert(f !=3D -1); + f =3D fcntl(fd, F_SETFD, f & ~FD_CLOEXEC); + assert(f !=3D -1); +} + /* * Creates a pipe with FD_CLOEXEC set on both file descriptors */ diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 7eedbe5..e5d0c7c 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -254,6 +254,10 @@ void qemu_set_cloexec(int fd) { } =20 +void qemu_clr_cloexec(int fd) +{ +} + /* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */ #define _W32_FT_OFFSET (116444736000000000ULL) =20 --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596124170; cv=none; d=zohomail.com; s=zohoarc; b=bL/C73RAJ3Dt3h2VYSKT+ukSUySTbtsRf3WZEF+3zQAUhs/V6YCTcNV5T4yNOUXSaOLj1Xq5kOiZ7s88ofQod3hcfR1mK+AqpPfenZY8XP7P4iHC3kZFd5Yl/nfOh8DuGU85mcY7hL1jjlTTQ0RbcyMJy1l1Z6w3U9rNm0D2So8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596124170; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=OOANDamxT/8UjVbukusZVM3EHUd5XIA23EDjTuSw9PA=; b=lCLSFcnX58WPrTTj89F+uJZ1kbueCUaceMuHNzgsLqfJO8S8+K3Pw9Gld0MXgBYGyuslCY6I032N7yOCJ1RmQF20YyFV5IZVo9s5y+gU/wpLe+hls8+OOhmYs3Hdehbof1clu1TTSrZOOt4fl3D0xVdqXzDtCllCpiU+pPNkqyc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596124170168146.1225428122125; Thu, 30 Jul 2020 08:49:30 -0700 (PDT) Received: from localhost ([::1]:37138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1AoC-0006e7-Fu for importer@patchew.org; Thu, 30 Jul 2020 11:49:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdJ-0007Kh-Bu for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:13 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:46170) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdH-00028y-5e for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:12 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXcEf152601; Thu, 30 Jul 2020 15:38:08 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 32hu1jvdyk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:38:08 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFWYbh176052; Thu, 30 Jul 2020 15:38:07 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 32hu61a1h0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:07 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 06UFc60G020470; Thu, 30 Jul 2020 15:38:06 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=OOANDamxT/8UjVbukusZVM3EHUd5XIA23EDjTuSw9PA=; b=x2cFeCgrSHq5pOZc51DK+4PxT5AyGmJa1UYZI4GZodfMOVbP/3yQi7y1zdgMjw5V5GY9 DJY4TjNOpceEDJ9WBZ6o12fvW3MsGZfSJirah7kD6RysIrBZYfRzNHpGCYBSASDEHZS0 gTuRco46r+9tGku9RH4Q+ILsi8tse3Y/M/cI5T4OjAl7Fv1nhT/yLoZXZX6/DS5130j3 xGQNOcg/LhFziRfoVW5p9c5RR6ACBCPdiD4OiBQVagmgqrpyrA92q5JOk659eaIMLgE1 r8F2vP+Nf0moGMJsi0nRCv9Nyq3lIbUb2qgTZqO2BRm1rqWqjiSyASC/CCeiKzMV8mqw 8Q== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 17/32] util: env var helpers Date: Thu, 30 Jul 2020 08:14:21 -0700 Message-Id: <1596122076-341293-18-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxlogscore=999 malwarescore=0 impostorscore=0 priorityscore=1501 spamscore=0 phishscore=0 suspectscore=1 bulkscore=0 mlxscore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.85; envelope-from=steven.sistare@oracle.com; helo=userp2120.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:38:02 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add functions for saving fd's and ram extents in the environment via setenv, and for reading them back via getenv. Signed-off-by: Steve Sistare Signed-off-by: Mark Kanda --- MAINTAINERS | 7 +++ include/qemu/cutils.h | 1 + include/qemu/env.h | 31 ++++++++++++ util/Makefile.objs | 2 +- util/env.c | 132 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ 5 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 include/qemu/env.h create mode 100644 util/env.c diff --git a/MAINTAINERS b/MAINTAINERS index 3395abd..8d377a7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3115,3 +3115,10 @@ Performance Tools and Tests M: Ahmed Karaman S: Maintained F: scripts/performance/ + +Environment variable helpers +M: Steve Sistare +M: Mark Kanda +S: Maintained +F: include/qemu/env.h +F: util/env.c diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index eb59852..d4c7d70 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -1,6 +1,7 @@ #ifndef QEMU_CUTILS_H #define QEMU_CUTILS_H =20 +#include "qemu/env.h" /** * pstrcpy: * @buf: buffer to copy string into diff --git a/include/qemu/env.h b/include/qemu/env.h new file mode 100644 index 0000000..53cc121 --- /dev/null +++ b/include/qemu/env.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef QEMU_ENV_H +#define QEMU_ENV_H + +#define FD_PREFIX "QEMU_FD_" +#define ADDR_PREFIX "QEMU_ADDR_" +#define LEN_PREFIX "QEMU_LEN_" +#define BOOL_PREFIX "QEMU_BOOL_" + +typedef int (*walkenv_cb)(const char *name, const char *val, void *handle); + +bool getenv_ram(const char *name, void **addrp, size_t *lenp); +void setenv_ram(const char *name, void *addr, size_t len); +void unsetenv_ram(const char *name); +int getenv_fd(const char *name); +void setenv_fd(const char *name, int fd); +void unsetenv_fd(const char *name); +bool getenv_bool(const char *name); +void setenv_bool(const char *name, bool val); +void unsetenv_bool(const char *name); +int walkenv(const char *prefix, walkenv_cb cb, void *handle); +void printenv(void); + +#endif diff --git a/util/Makefile.objs b/util/Makefile.objs index cc5e371..d357932 100644 --- a/util/Makefile.objs +++ b/util/Makefile.objs @@ -1,4 +1,4 @@ -util-obj-y =3D osdep.o cutils.o unicode.o qemu-timer-common.o +util-obj-y =3D osdep.o cutils.o unicode.o qemu-timer-common.o env.o util-obj-$(call lnot,$(CONFIG_ATOMIC64)) +=3D atomic64.o util-obj-$(CONFIG_POSIX) +=3D aio-posix.o util-obj-$(CONFIG_POSIX) +=3D fdmon-poll.o diff --git a/util/env.c b/util/env.c new file mode 100644 index 0000000..0cc4a9f --- /dev/null +++ b/util/env.c @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qemu/env.h" + +static uint64_t getenv_ulong(const char *prefix, const char *name, bool *f= ound) +{ + char var[80], *val; + uint64_t res; + + snprintf(var, sizeof(var), "%s%s", prefix, name); + val =3D getenv(var); + if (val) { + *found =3D true; + res =3D strtol(val, 0, 10); + } else { + *found =3D false; + res =3D 0; + } + return res; +} + +static void setenv_ulong(const char *prefix, const char *name, uint64_t va= l) +{ + char var[80], val_str[80]; + snprintf(var, sizeof(var), "%s%s", prefix, name); + snprintf(val_str, sizeof(val_str), "%"PRIu64, val); + setenv(var, val_str, 1); +} + +static void unsetenv_ulong(const char *prefix, const char *name) +{ + char var[80]; + snprintf(var, sizeof(var), "%s%s", prefix, name); + unsetenv(var); +} + +bool getenv_ram(const char *name, void **addrp, size_t *lenp) +{ + bool found1, found2; + *addrp =3D (void *) getenv_ulong(ADDR_PREFIX, name, &found1); + *lenp =3D getenv_ulong(LEN_PREFIX, name, &found2); + assert(found1 =3D=3D found2); + return found1; +} + +void setenv_ram(const char *name, void *addr, size_t len) +{ + setenv_ulong(ADDR_PREFIX, name, (uint64_t)addr); + setenv_ulong(LEN_PREFIX, name, len); +} + +void unsetenv_ram(const char *name) +{ + unsetenv_ulong(ADDR_PREFIX, name); + unsetenv_ulong(LEN_PREFIX, name); +} + +int getenv_fd(const char *name) +{ + bool found; + int fd =3D getenv_ulong(FD_PREFIX, name, &found); + if (!found) { + fd =3D -1; + } + return fd; +} + +void setenv_fd(const char *name, int fd) +{ + setenv_ulong(FD_PREFIX, name, fd); +} + +void unsetenv_fd(const char *name) +{ + unsetenv_ulong(FD_PREFIX, name); +} + +bool getenv_bool(const char *name) +{ + bool found; + bool val =3D getenv_ulong(BOOL_PREFIX, name, &found); + if (!found) { + val =3D -1; + } + return val; +} + +void setenv_bool(const char *name, bool val) +{ + setenv_ulong(BOOL_PREFIX, name, val); +} + +void unsetenv_bool(const char *name) +{ + unsetenv_ulong(BOOL_PREFIX, name); +} + +int walkenv(const char *prefix, walkenv_cb cb, void *handle) +{ + char *str, name[128]; + char **envp =3D environ; + size_t prefix_len =3D strlen(prefix); + + while (*envp) { + str =3D *envp++; + if (!strncmp(str, prefix, prefix_len)) { + char *val =3D strchr(str, '=3D'); + str +=3D prefix_len; + strncpy(name, str, val - str); + name[val - str] =3D 0; + if (cb(name, val + 1, handle)) { + return 1; + } + } + } + return 0; +} + +void printenv(void) +{ + char **ptr =3D environ; + while (*ptr) { + puts(*ptr++); + } +} --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596124701; cv=none; d=zohomail.com; s=zohoarc; b=GAyflaXQIZAx5W9fFGUuw+XtLcNUN44P9/qg9K8kQucSd5pyIVoktTrq14y6nAwuFLajwoeMw2KffCF8Q2Q0wJjrGHmm9nG4FzKVF3qQdGDqA66VSqVMS++1MKnaufUFcbDGpXgYmSh7CF0B0u1mRrDzo7bP7GBqLDB5pzIrTUk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596124701; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=ry5gpuR23eKIdEylleUh4be2sKRb+84pqqOoEO+MYg8=; b=jXeNySmR8FHDwRmYS5oqB+LYQYwxLyl8d6rU29ymdYZMeZWGOVwwRhKesUmBjGglB48zOdknalIbnEFyz8sFZeJRQ0HFh7HHuhLk0WZQIITCJel5Xke9xEDlMIUiRjSS0w/3BLXDYv4vvEaGjhD8l8O2fzeIazYJNyqLNlIbdqw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596124701276687.9415607134346; Thu, 30 Jul 2020 08:58:21 -0700 (PDT) Received: from localhost ([::1]:36280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1Awl-0001et-TP for importer@patchew.org; Thu, 30 Jul 2020 11:58:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AfK-0001Ni-M8 for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:18 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:51954) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AfD-0002V8-Ru for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:18 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXRow007525; Thu, 30 Jul 2020 15:40:08 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 32hu1jmfuj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:40:08 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFWa6v176315; Thu, 30 Jul 2020 15:38:07 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 32hu61a1hs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:07 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 06UFc6Gi020474; Thu, 30 Jul 2020 15:38:06 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:06 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=ry5gpuR23eKIdEylleUh4be2sKRb+84pqqOoEO+MYg8=; b=lsSyF+C/tqD3ISTZNiwNOPrib3QIAnPbkYJ8Mcp1rleIuVNIq8NWkYnoVynlQhJIUSTq wyqLQnPTN9FFoVkAm8VWFFClAOCo5SXuR6FrTL+ponj2ySn2eICSpcS0s4XnymR/nQbJ rVgYuNu19n5QvjKt/Z4VY1Lq138ulf6AhsCLvXP1vc+WURvmRRSQugpJ4LQ2L98s7QuY gKdBGcKaVlbHY9HOF1SAus7DCz9rsWpuzMmpBuZthLcDylZvtxtVHzlqGVPsRd7G48Wf pGQkNQKZ1SzreBKRpquYLoVHW+YFRwe4DNb4GuoFjX78U8iyjsgU/hPg6GYDxKw1BdZP Bg== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 18/32] osdep: import MADV_DOEXEC Date: Thu, 30 Jul 2020 08:14:22 -0700 Message-Id: <1596122076-341293-19-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 clxscore=1015 malwarescore=0 spamscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.86; envelope-from=steven.sistare@oracle.com; helo=userp2130.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:37:58 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Anonymous memory segments used by the guest are preserved across a re-exec of qemu, mapped at the same VA, via a proposed madvise(MADV_DOEXEC) option in the Linux kernel. For the madvise patches, see: https://lore.kernel.org/lkml/1595869887-23307-1-git-send-email-anthony.yzna= ga@oracle.com/ Signed-off-by: Steve Sistare --- include/qemu/osdep.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index bb28df1..7ce555a 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -390,6 +390,11 @@ void qemu_anon_ram_free(void *ptr, size_t size); #else #define QEMU_MADV_REMOVE QEMU_MADV_INVALID #endif +#ifdef MADV_DOEXEC +#define QEMU_MADV_DOEXEC MADV_DOEXEC +#else +#define QEMU_MADV_DOEXEC QEMU_MADV_INVALID +#endif =20 #elif defined(CONFIG_POSIX_MADVISE) =20 @@ -403,6 +408,7 @@ void qemu_anon_ram_free(void *ptr, size_t size); #define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID #define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID #define QEMU_MADV_REMOVE QEMU_MADV_INVALID +#define QEMU_MADV_DOEXEC QEMU_MADV_INVALID =20 #else /* no-op */ =20 @@ -416,6 +422,7 @@ void qemu_anon_ram_free(void *ptr, size_t size); #define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID #define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID #define QEMU_MADV_REMOVE QEMU_MADV_INVALID +#define QEMU_MADV_DOEXEC QEMU_MADV_INVALID =20 #endif =20 --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596124364; cv=none; d=zohomail.com; s=zohoarc; b=nomCxcbJjssZCK1JihRtshAc+WDDzByVhIfftXBwTSZ/2w1r4695yPoqPiYEG4JQJrc7+5CHm7VsxqbRaUSfgqiwtb432rtPK2iIJn7AuHUOHk5EYQPyp3D0fZGNDuKuBwecC03a2IvaRoqD//y7Ja50+U8y4k9u3E9yBQhFgks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596124364; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=Wd03TfXmai9NVMgUXNcCRPWvxEvO9M/ot786QtmLF84=; b=nXwffiKAr4gQyM/fDuQKxiD2Phr6mfK9MyKguWBu719qncDAil7PJ0CEVYHyv07sP6qz90WhXec9bY7S7dKQmSCYjYVo63L/Gf0IBiC2vPkSIIxoowB7TSwlF/S7TQekhLttVeptMoZBcs0PkNbxJLcPLrK1b16DZ5LPUGwbX6k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596124364034223.0670778657602; Thu, 30 Jul 2020 08:52:44 -0700 (PDT) Received: from localhost ([::1]:45918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1ArK-0001y5-Hg for importer@patchew.org; Thu, 30 Jul 2020 11:52:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54670) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AfK-0001Mp-2l for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:18 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48020) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AfG-0002VF-1c for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:17 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXPdm152163; Thu, 30 Jul 2020 15:40:10 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 32hu1jvecr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:40:10 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFWZQE176243; Thu, 30 Jul 2020 15:38:09 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 32hu61a1mb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:09 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 06UFc7lY007504; Thu, 30 Jul 2020 15:38:07 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:07 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=Wd03TfXmai9NVMgUXNcCRPWvxEvO9M/ot786QtmLF84=; b=caIpVjen6t/UHEre+7bHaGST8tTYb0s5QO9k0jZg1bga0vlGajfp65SNV2xee+JVEide iXwf05pih5aOVVnXcscu1J70cYZO6G5RaJcY5QEVhrSqaktjuLhsswuNOOl/vFyTYN56 Nwy6RM5rvFmM7d6caDYk7MjeEptlsbGllcy0Zo+eQVdljiHWRds3ZcA6iXzcqKfYUhor LhI3bZ4g8naUO+DFlldV8GgXWCjUNWILFDBkqXpWYEmSk9uRObH9tRgL1sgXVHp8MA9h 0m9JC20uW9FKuJC3m5NCxj8fjbQsLDqSfATkDyQT0bBzJDP8hc2rylz2PaG51tJASOQv 2Q== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 19/32] memory: ram_block_add cosmetic changes Date: Thu, 30 Jul 2020 08:14:23 -0700 Message-Id: <1596122076-341293-20-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxlogscore=999 malwarescore=0 impostorscore=0 priorityscore=1501 spamscore=0 phishscore=0 suspectscore=1 bulkscore=0 mlxscore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.85; envelope-from=steven.sistare@oracle.com; helo=userp2120.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:38:02 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Massage the code to simplify the later patch "exec, memory: exec(3) to restart". No functional change. Signed-off-by: Steve Sistare --- exec.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/exec.c b/exec.c index 02160e0..359e437 100644 --- a/exec.c +++ b/exec.c @@ -2233,32 +2233,37 @@ static void ram_block_add(RAMBlock *new_block, Erro= r **errp, bool shared) RAMBlock *last_block =3D NULL; ram_addr_t old_ram_size, new_ram_size; Error *err =3D NULL; + const char *name; + void *addr; + size_t maxlen; =20 old_ram_size =3D last_ram_page(); =20 qemu_mutex_lock_ramlist(); - new_block->offset =3D find_ram_offset(new_block->max_length); + maxlen =3D new_block->max_length; + new_block->offset =3D find_ram_offset(maxlen); =20 if (!new_block->host) { if (xen_enabled()) { - xen_ram_alloc(new_block->offset, new_block->max_length, - new_block->mr, &err); + xen_ram_alloc(new_block->offset, maxlen, new_block->mr, &err); if (err) { error_propagate(errp, err); qemu_mutex_unlock_ramlist(); return; } } else { - new_block->host =3D phys_mem_alloc(new_block->max_length, - &new_block->mr->align, shared= ); - if (!new_block->host) { + name =3D memory_region_name(new_block->mr); + addr =3D phys_mem_alloc(maxlen, &new_block->mr->align, shared); + + if (!addr) { error_setg_errno(errp, errno, "cannot set up guest memory '%s'", - memory_region_name(new_block->mr)); + name); qemu_mutex_unlock_ramlist(); return; } - memory_try_enable_merging(new_block->host, new_block->max_leng= th); + memory_try_enable_merging(addr, maxlen); + new_block->host =3D addr; } } =20 --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596124300; cv=none; d=zohomail.com; s=zohoarc; b=Gfai6/g+zNKLBq7eLxoyhNu81O5n5/BSop5Yvf3o8OReW3TQwtXnuoI7hAvXa4dcy2OHkFKSk1tDMdnXsXBKtBDwEnBi4U/Bx5ly05fDp0SF6fXxnFrCcP41Y3Wjxa2JepICiBQslXJabHmlDsk38NxgFB99den3uqgPYUn00Q0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596124300; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=T4ZfUEryyQOwpRw5tgVkPIpr18yCga2sggJCM6Ln6So=; b=c70x7xXUAYmOHvFRb2xf728Ry2GWFP0SFVaL/Ft3Gt8Z1S9zXZI14RjXLhdxscLhskbv0atYJ15HJgx7HiqO2xeEi19+Dtw/RjF4l/dnhaOqdTLBjyL3WzKYSdnjx8cLnGCFuE6zrVf/8+SYwXIaCS0nEhLyK2aqmaYH9rJXy8c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596124300471938.4044721394791; Thu, 30 Jul 2020 08:51:40 -0700 (PDT) Received: from localhost ([::1]:43470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1AqJ-0000wj-7E for importer@patchew.org; Thu, 30 Jul 2020 11:51:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53954) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdN-0007TZ-6M for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:17 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50150) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdK-0002Ag-6O for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:16 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXcGv007652; Thu, 30 Jul 2020 15:38:11 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 32hu1jmffa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:38:11 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFYjOR172108; Thu, 30 Jul 2020 15:38:11 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 32hu5x0wkd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:10 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 06UFc9lt001893; Thu, 30 Jul 2020 15:38:09 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:08 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=T4ZfUEryyQOwpRw5tgVkPIpr18yCga2sggJCM6Ln6So=; b=T+hVvyLGa2mk7Ry+Z6hgrlGP4fkKb4v1ky0CzCa0BLJcFTRl+IxZWlX9Wf95p6xy5Pb2 Y3kf6TTDIlfGjqQcjyoPxNkD/BS4aXJbdfoVir8qwdXwEhIWbA87KHOytlbDw1fTWANi IzHxhfwE1XjyzWmNAOmbGHaFoigaO51B34ylSJBKVEhz40YU5TAJFDAssp+ot6WysrL9 PYYmRluXRt2GvXfY7ScHoqvYW0TPZVU44FJGm4KVoLZUA9fPUQzpC28HHlMgvUE2fIOH ew2NZheeyvuwn8gkd7FU82Ua1np3YA5xFaXunSEDDgAs91AHUDIm5Ouyxo7siMWTqmD3 Rg== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 20/32] vl: add helper to request re-exec Date: Thu, 30 Jul 2020 08:14:24 -0700 Message-Id: <1596122076-341293-21-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 suspectscore=1 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 clxscore=1015 malwarescore=0 spamscore=0 suspectscore=1 bulkscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.86; envelope-from=steven.sistare@oracle.com; helo=userp2130.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:37:58 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a qemu_exec_requested() hook that causes the main loop to exit and re-exec qemu using the same initial arguments. If /usr/bin/qemu-exec exists, exec that instead. This is an optional site-specific trampoline that may alter the environment before exec'ing the qemu binary. Signed-off-by: Steve Sistare --- include/sysemu/sysemu.h | 1 + softmmu/vl.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 5360da5..4dfc4ca 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -15,6 +15,7 @@ extern QemuUUID qemu_uuid; extern bool qemu_uuid_set; =20 void qemu_add_data_dir(const char *path); +void qemu_system_exec_request(void); =20 void qemu_add_exit_notifier(Notifier *notify); void qemu_remove_exit_notifier(Notifier *notify); diff --git a/softmmu/vl.c b/softmmu/vl.c index 7016e39..72f0e08 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -116,6 +116,7 @@ =20 #define MAX_VIRTIO_CONSOLES 1 =20 +static char **argv_main; static const char *data_dir[16]; static int data_dir_idx; const char *bios_name =3D NULL; @@ -1296,6 +1297,7 @@ static ShutdownCause reset_requested; static ShutdownCause shutdown_requested; static int shutdown_signal; static pid_t shutdown_pid; +static int exec_requested; static int powerdown_requested; static int debug_requested; static int suspend_requested; @@ -1326,6 +1328,11 @@ static int qemu_shutdown_requested(void) return atomic_xchg(&shutdown_requested, SHUTDOWN_CAUSE_NONE); } =20 +static int qemu_exec_requested(void) +{ + return atomic_xchg(&exec_requested, 0); +} + static void qemu_kill_report(void) { if (!qtest_driver() && shutdown_signal) { @@ -1582,6 +1589,13 @@ void qemu_system_shutdown_request(ShutdownCause reas= on) qemu_notify_event(); } =20 +void qemu_system_exec_request(void) +{ + shutdown_requested =3D 1; + exec_requested =3D 1; + qemu_notify_event(); +} + static void qemu_system_powerdown(void) { qapi_event_send_powerdown(); @@ -1617,6 +1631,16 @@ void qemu_system_debug_request(void) qemu_notify_event(); } =20 +static void qemu_exec(void) +{ + const char *helper =3D "/usr/bin/qemu-exec"; + const char *bin =3D !access(helper, X_OK) ? helper : argv_main[0]; + + execvp(bin, argv_main); + error_report("execvp failed, errno %d.", errno); + exit(1); +} + static bool main_loop_should_exit(void) { RunState r; @@ -1637,6 +1661,11 @@ static bool main_loop_should_exit(void) } request =3D qemu_shutdown_requested(); if (request) { + + if (qemu_exec_requested()) { + qemu_exec(); + /* not reached */ + } qemu_kill_report(); qemu_system_shutdown(request); if (no_shutdown) { @@ -2891,6 +2920,7 @@ void qemu_init(int argc, char **argv, char **envp) =20 os_set_line_buffering(); =20 + argv_main =3D argv; error_init(argv[0]); module_call_init(MODULE_INIT_TRACE); =20 --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596124477; cv=none; d=zohomail.com; s=zohoarc; b=AXqNeeKgTVNf0YVEAlHIMQa4+opBGEt1p3rFty3YFPDftTD1oRuwqSyWPpRHGBLvthZrWUCIHrsnwMG7oRbMC5vFWqkMN+gM0bxN4gwwqzz5hJfG/umNviOZLhVXxFaG5AbLgR58dLIpR/iXvyNEB7SrV3Kg4ORdSs8RxL01oa4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596124477; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=micmSlORAvpi9yB3dc5wSQuxzyCBVgja6SS0xcqR81Y=; b=cSaXN9R8Jl4xMGj41RTC4+L+ESPwYLD3zhyFcYjHqyeCWsJT5aMyzApkMMYChMv05AkvF2NpnPVkE3dy4ebtytoD6E1tc6onO7C46wibngHxL5LBMAJjqx2nDLnrqL0HPHIe1WJ+1CNUCvG9CcXuTKCjVvvaVIONuor9YV2Qu+E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596124477720405.486023995133; Thu, 30 Jul 2020 08:54:37 -0700 (PDT) Received: from localhost ([::1]:52256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1AtA-0004fV-JD for importer@patchew.org; Thu, 30 Jul 2020 11:54:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AfP-0001SK-D3 for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:23 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48040) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AfH-0002VO-Rj for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:23 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXjA1152650; Thu, 30 Jul 2020 15:40:12 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 32hu1jvecx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:40:12 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFWp4K188370; Thu, 30 Jul 2020 15:38:11 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 32hu5xja3d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:11 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 06UFcA0c001907; Thu, 30 Jul 2020 15:38:10 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:10 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=micmSlORAvpi9yB3dc5wSQuxzyCBVgja6SS0xcqR81Y=; b=fVDW8D3NpBMq4/wzeoNpQ+NCTkZMkzsIs3oZ4PdsOoqqZ4/NaHt09iGxxqf5eNCHiGgf 4Acypv1qVUOEk1zWJeu46GgBHxMeWOD++EZz1IaedzaQhCDwhPfemElpRAzNzDoFS3zE 4AwgWj+nZpwFoC/0NvhS5We9JuU+RrjTR3zDrhXpuPc6fOBBdSS6OCHl3egFzrs3ai6a p4frav4DeCDKGmtHtyPxDrcy2U09ThmYnlwe+v8pFViKt3NK98pCplTArsvmOQffxKDQ qzJGfcr1HpV4OuTN39/4JzLrA9YXz8dBYDexKcA7rZm4irJjzv5YmhmJMPMWrq+BAavP /A== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 21/32] exec, memory: exec(3) to restart Date: Thu, 30 Jul 2020 08:14:25 -0700 Message-Id: <1596122076-341293-22-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 mlxscore=0 adultscore=0 spamscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxlogscore=999 malwarescore=0 impostorscore=0 priorityscore=1501 spamscore=0 phishscore=0 suspectscore=3 bulkscore=0 mlxscore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.85; envelope-from=steven.sistare@oracle.com; helo=userp2120.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:38:02 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use exec() to restart qemu to a potentially new version, while preserving guest RAM. The guest pauses briefly. cprsave saves the address and length of RAM blocks to the environment via setenv, tags the RAM with the new madvise(MADV_DOEXEC) option to preserve it across exec, then exec()'s the (typically updated) qemu binary with the original argv. On qemu restart, ram_block_add() finds the env vars that describe preserved RAM segments and does not reallocate them. Signed-off-by: Steve Sistare --- exec.c | 36 ++++++++++++++++++++++++++++++++++-- include/exec/memory.h | 2 ++ migration/savevm.c | 16 ++++++++++++++++ 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/exec.c b/exec.c index 359e437..5473c09 100644 --- a/exec.c +++ b/exec.c @@ -2235,7 +2235,7 @@ static void ram_block_add(RAMBlock *new_block, Error = **errp, bool shared) Error *err =3D NULL; const char *name; void *addr; - size_t maxlen; + size_t len, maxlen; =20 old_ram_size =3D last_ram_page(); =20 @@ -2253,7 +2253,12 @@ static void ram_block_add(RAMBlock *new_block, Error= **errp, bool shared) } } else { name =3D memory_region_name(new_block->mr); - addr =3D phys_mem_alloc(maxlen, &new_block->mr->align, shared); + if (getenv_ram(name, &addr, &len)) { + assert(len =3D=3D maxlen); + } else { + addr =3D phys_mem_alloc(maxlen, &new_block->mr->align, sha= red); + setenv_ram(name, addr, maxlen); + } =20 if (!addr) { error_setg_errno(errp, errno, @@ -2499,6 +2504,8 @@ void qemu_ram_free(RAMBlock *block) return; } =20 + unsetenv_ram(memory_region_name(block->mr)); + if (block->host) { ram_block_notify_remove(block->host, block->max_length); } @@ -2763,6 +2770,31 @@ bool qemu_ram_volatile(Error **errp) return ret; } =20 +static int preserve_ram(const char *name, const char *val, void *handle) +{ + void *addr; + size_t len; + Error **errp =3D handle; + + getenv_ram(name, &addr, &len); + if (qemu_madvise(addr, len, QEMU_MADV_DOEXEC)) { + error_setg_errno(errp, errno, + "MADV_DOEXEC failed on memory region %s", name); + return 1; + } + return 0; +} + + +int qemu_preserve_ram(Error **errp) +{ + int ret; + qemu_mutex_lock_ramlist(); + ret =3D walkenv(ADDR_PREFIX, preserve_ram, errp); + qemu_mutex_unlock_ramlist(); + return ret; +} + /* Generate a debug exception if a watchpoint has been hit. */ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, MemTxAttrs attrs, int flags, uintptr_t ra) diff --git a/include/exec/memory.h b/include/exec/memory.h index 6aafbb0..e2d297d 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -2521,6 +2521,8 @@ bool ram_block_discard_is_required(void); =20 bool qemu_ram_volatile(Error **errp); =20 +int qemu_preserve_ram(Error **errp); + #endif =20 #endif diff --git a/migration/savevm.c b/migration/savevm.c index 38cc63a..2902006 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2719,6 +2719,16 @@ void save_cpr_snapshot(const char *file, const char = *mode, Error **errp) return; } =20 + if (op =3D=3D VMS_RESTART && QEMU_MADV_DOEXEC =3D=3D QEMU_MADV_INVALID= ) { + error_setg(errp, "kernel does not support MADV_DOEXEC."); + return; + } + + if (op =3D=3D VMS_RESTART && xen_enabled()) { + error_setg(errp, "xen does not support cprsave restart"); + return; + } + f =3D qf_file_open(file, O_CREAT | O_WRONLY | O_TRUNC, 0600, errp); if (!f) { return; @@ -2747,6 +2757,12 @@ void save_cpr_snapshot(const char *file, const char = *mode, Error **errp) if (op =3D=3D VMS_REBOOT) { no_shutdown =3D 0; qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); + } else if (op =3D=3D VMS_RESTART) { + if (qemu_preserve_ram(errp)) { + return; + } + qemu_system_exec_request(); + putenv((char *)"QEMU_START_FREEZE=3D"); } } =20 --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596124302; cv=none; d=zohomail.com; s=zohoarc; b=mm3EOb8KozsFW5C3fERbWyuLx6ryq7SxaErPD78ciZU9G6nhcQ8vti9g3ew8b7zIsWnN4ayFx/UV20fYqC8D5BEEzyT7SLmmqU383rk2TRzmJ5X6xgzEGNXL+HNpRHZmQM3RhHcUt76Ph89fpwo0UduNGuG5+fDR95dAEcS1iO4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596124302; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=yiR9ky1zjTylsw8BvTXwpDDI6qX/bEvwcYOs2wTpK2g=; b=FQi4BGGYinmq/QOIl9WPZNia68MHUeZbFvKtWr3zdeuSVIcam2wLONqHIzTue9fasAj+CPqox/5QIuMMO7BD3GJIodBloVNcue+JLevnwyRQpJmWwT4lCz/945f+rmh+2+uLpJgeupQwqj0kqVgFyYsj2k7pzvi5RhQsk2RYDHs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596124302508225.89920398137986; Thu, 30 Jul 2020 08:51:42 -0700 (PDT) Received: from localhost ([::1]:43592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1AqL-0000zY-8A for importer@patchew.org; Thu, 30 Jul 2020 11:51:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdO-0007Wf-GE for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:18 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50186) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdM-0002Au-8i for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:18 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXbZP007647; Thu, 30 Jul 2020 15:38:13 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 32hu1jmffm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:38:13 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFYkbK172237; Thu, 30 Jul 2020 15:38:12 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 32hu5x0wnr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:12 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 06UFcBVv014547; Thu, 30 Jul 2020 15:38:11 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:11 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=yiR9ky1zjTylsw8BvTXwpDDI6qX/bEvwcYOs2wTpK2g=; b=jLeRnvBKmk3fqCsGN5XETuObcAsvUR0IfiKA5km8vUp+JKn0cppTODFVSB6dYeYthEdt SCMz+3CUnzDWohYmt7wHJJarex5WvRYBqy/7A5M2jFN/86Lq87gG/Tp7T0K8bdb8AmtJ VvcTchZ+6rLpqhY8svvt5b7/rLKiR43l6xPQfJFvH5vYm7t7WmgGNdtJffntuOO2uJuM 1gtL3AZLjAnUXBhtJPN2uJtMCthTNIEbvrFCoL7iq/8mx0ShHUL3WqPc6tsP7O2nYbsL UC0UCbKotxXIJQaQSFSHyfaRVwbecRUUo3xuFHyf12gHZbTjVYGBGiOqs+ytzIDadvER QA== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 22/32] char: qio_channel_socket_accept reuse fd Date: Thu, 30 Jul 2020 08:14:26 -0700 Message-Id: <1596122076-341293-23-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 suspectscore=1 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 clxscore=1015 malwarescore=0 spamscore=0 suspectscore=1 bulkscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.86; envelope-from=steven.sistare@oracle.com; helo=userp2130.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:37:58 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Mark Kanda Add an fd argument to qio_channel_socket_accept. If not -1, the channel uses that fd instead of accepting a new socket connection. All callers pass -1 in this patch, so no functional change. Signed-off-by: Mark Kanda Signed-off-by: Steve Sistare --- include/io/channel-socket.h | 3 ++- io/channel-socket.c | 12 +++++++++--- io/net-listener.c | 4 ++-- scsi/qemu-pr-helper.c | 2 +- tests/qtest/tpm-emu.c | 2 +- tests/test-char.c | 2 +- tests/test-io-channel-socket.c | 4 ++-- 7 files changed, 18 insertions(+), 11 deletions(-) diff --git a/include/io/channel-socket.h b/include/io/channel-socket.h index 777ff59..0ffc560 100644 --- a/include/io/channel-socket.h +++ b/include/io/channel-socket.h @@ -248,6 +248,7 @@ qio_channel_socket_get_remote_address(QIOChannelSocket = *ioc, /** * qio_channel_socket_accept: * @ioc: the socket channel object + * @reuse_fd: fd to reuse; -1 otherwise * @errp: pointer to a NULL-initialized error object * * If the socket represents a server, then this accepts @@ -258,7 +259,7 @@ qio_channel_socket_get_remote_address(QIOChannelSocket = *ioc, */ QIOChannelSocket * qio_channel_socket_accept(QIOChannelSocket *ioc, - Error **errp); + int reuse_fd, Error **errp); =20 =20 #endif /* QIO_CHANNEL_SOCKET_H */ diff --git a/io/channel-socket.c b/io/channel-socket.c index e1b4667..dde12bf 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -352,7 +352,7 @@ void qio_channel_socket_dgram_async(QIOChannelSocket *i= oc, =20 QIOChannelSocket * qio_channel_socket_accept(QIOChannelSocket *ioc, - Error **errp) + int reuse_fd, Error **errp) { QIOChannelSocket *cioc; =20 @@ -362,8 +362,14 @@ qio_channel_socket_accept(QIOChannelSocket *ioc, =20 retry: trace_qio_channel_socket_accept(ioc); - cioc->fd =3D qemu_accept(ioc->fd, (struct sockaddr *)&cioc->remoteAddr, - &cioc->remoteAddrLen); + + if (reuse_fd !=3D -1) { + cioc->fd =3D reuse_fd; + } else { + cioc->fd =3D qemu_accept(ioc->fd, (struct sockaddr *)&cioc->remote= Addr, + &cioc->remoteAddrLen); + } + if (cioc->fd < 0) { if (errno =3D=3D EINTR) { goto retry; diff --git a/io/net-listener.c b/io/net-listener.c index 5d8a226..bbdea1e 100644 --- a/io/net-listener.c +++ b/io/net-listener.c @@ -45,7 +45,7 @@ static gboolean qio_net_listener_channel_func(QIOChannel = *ioc, QIOChannelSocket *sioc; =20 sioc =3D qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc), - NULL); + -1, NULL); if (!sioc) { return TRUE; } @@ -194,7 +194,7 @@ static gboolean qio_net_listener_wait_client_func(QIOCh= annel *ioc, QIOChannelSocket *sioc; =20 sioc =3D qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc), - NULL); + -1, NULL); if (!sioc) { return TRUE; } diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c index 57ad830..0e6d683 100644 --- a/scsi/qemu-pr-helper.c +++ b/scsi/qemu-pr-helper.c @@ -800,7 +800,7 @@ static gboolean accept_client(QIOChannel *ioc, GIOCondi= tion cond, gpointer opaqu PRHelperClient *prh; =20 cioc =3D qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc), - NULL); + -1, NULL); if (!cioc) { return TRUE; } diff --git a/tests/qtest/tpm-emu.c b/tests/qtest/tpm-emu.c index 2e8eb7b..19e5dab 100644 --- a/tests/qtest/tpm-emu.c +++ b/tests/qtest/tpm-emu.c @@ -83,7 +83,7 @@ void *tpm_emu_ctrl_thread(void *data) g_cond_signal(&s->data_cond); =20 qio_channel_wait(QIO_CHANNEL(lioc), G_IO_IN); - ioc =3D QIO_CHANNEL(qio_channel_socket_accept(lioc, &error_abort)); + ioc =3D QIO_CHANNEL(qio_channel_socket_accept(lioc, -1, &error_abort)); g_assert(ioc); =20 { diff --git a/tests/test-char.c b/tests/test-char.c index 614bdac..1bb6ae0 100644 --- a/tests/test-char.c +++ b/tests/test-char.c @@ -884,7 +884,7 @@ char_socket_client_server_thread(gpointer data) QIOChannelSocket *cioc; =20 retry: - cioc =3D qio_channel_socket_accept(ioc, &error_abort); + cioc =3D qio_channel_socket_accept(ioc, -1, &error_abort); g_assert_nonnull(cioc); =20 if (char_socket_ping_pong(QIO_CHANNEL(cioc), NULL) !=3D 0) { diff --git a/tests/test-io-channel-socket.c b/tests/test-io-channel-socket.c index d43083a..0d410cf 100644 --- a/tests/test-io-channel-socket.c +++ b/tests/test-io-channel-socket.c @@ -75,7 +75,7 @@ static void test_io_channel_setup_sync(SocketAddress *lis= ten_addr, qio_channel_set_delay(*src, false); =20 qio_channel_wait(QIO_CHANNEL(lioc), G_IO_IN); - *dst =3D QIO_CHANNEL(qio_channel_socket_accept(lioc, &error_abort)); + *dst =3D QIO_CHANNEL(qio_channel_socket_accept(lioc, -1, &error_abort)= ); g_assert(*dst); =20 test_io_channel_set_socket_bufs(*src, *dst); @@ -143,7 +143,7 @@ static void test_io_channel_setup_async(SocketAddress *= listen_addr, g_assert(!data.err); =20 qio_channel_wait(QIO_CHANNEL(lioc), G_IO_IN); - *dst =3D QIO_CHANNEL(qio_channel_socket_accept(lioc, &error_abort)); + *dst =3D QIO_CHANNEL(qio_channel_socket_accept(lioc, -1, &error_abort)= ); g_assert(*dst); =20 qio_channel_set_delay(*src, false); --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596124962; cv=none; d=zohomail.com; s=zohoarc; b=Arpg7upbE4llzat7Q/KpHxpEvOpSuuF+kVjj1lmgvFxXaFAWCIxvYEp2EAAAImThGqSDZG7TZEg2BsMM1O8h8wfjp79vWkKWZZdp52l8UIkpWNTlkM9R1whpRPPbPS/DZ2LawFqZ68gqCx56D2v0J/XfheNy6MqT89cVvno9PrA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596124962; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=Nv/b2PUDoqsO8F4DqZ6z7ZSgREh1Dj6LffZizWf6DgQ=; b=QxJAoSd8MUeifWo27jrZvxhc5opVBIvpYVfg+ZVaBdwJp+GmXD4CGhT+H3Y4tzE+uWdEJA2TH5IhfcLiGGnW1AiKo7UgXga8PDhcwHM+y+d+3foeDPjRu8ORKKfbBaLaE5MccQdJ6PDAEv7HWRe5iJQxLJU52LnhwSszFiI/P6I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596124962712653.5425822208058; Thu, 30 Jul 2020 09:02:42 -0700 (PDT) Received: from localhost ([::1]:47136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1B0y-0006iN-UZ for importer@patchew.org; Thu, 30 Jul 2020 12:02:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AfQ-0001Vv-Uk for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:24 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:52020) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AfJ-0002Va-NE for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:24 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXPL6007495; Thu, 30 Jul 2020 15:40:14 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 32hu1jmfv3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:40:13 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXSM4130705; Thu, 30 Jul 2020 15:38:13 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 32hu5wwh1a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:13 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 06UFcCfo001915; Thu, 30 Jul 2020 15:38:12 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:12 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=Nv/b2PUDoqsO8F4DqZ6z7ZSgREh1Dj6LffZizWf6DgQ=; b=lpsd5iZB4zS7RfTSXqVLdGdu12hG/QHJ21uZjJif1qyYI7ULZ0ZRPwOmyB6no+Cp3XxQ HM+58KDyZ310qMlS7xdz+r11iDR47qaMcGYqvX39GsIea/V7BfrImKqMGPG+3zdSdm71 TSJJFkM823g5vejzOEzMkrQIMUUWTgGzC758EvTicU/XT9l32yDWQ5Xaeag569S8Hg3v JJRtmOsJ1ZDUzfCF2CPn2aZgbZl97NJSCl2LQtKlwAa/6UKKkysdt44xVDkDqSjpFbp/ FhLlkREJG+iOCocyyPrVetiAxt8tprwG9Y9DttZfxS7muDzDnf+k+NF7QxRFvfy4JNCc iw== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 23/32] char: save/restore chardev socket fds Date: Thu, 30 Jul 2020 08:14:27 -0700 Message-Id: <1596122076-341293-24-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=3 bulkscore=0 malwarescore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 clxscore=1015 malwarescore=0 spamscore=0 suspectscore=3 bulkscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.86; envelope-from=steven.sistare@oracle.com; helo=userp2130.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:37:58 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Mark Kanda Iterate through the character devices and save/restore the socket fds. Signed-off-by: Mark Kanda Signed-off-by: Steve Sistare --- chardev/char-socket.c | 35 +++++++++++++++++++++++++++++++++++ chardev/char.c | 14 ++++++++++++++ include/chardev/char.h | 5 +++++ include/sysemu/sysemu.h | 1 + migration/savevm.c | 8 ++++++++ 5 files changed, 63 insertions(+) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index ef62dbf..e08e7e1 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -36,6 +36,8 @@ #include "qapi/qapi-visit-sockets.h" =20 #include "chardev/char-io.h" +#include "sysemu/sysemu.h" +#include "qemu/cutils.h" =20 /***********************************************************/ /* TCP Net console */ @@ -400,6 +402,7 @@ static void tcp_chr_free_connection(Chardev *chr) SocketChardev *s =3D SOCKET_CHARDEV(chr); int i; =20 + unsetenv_fd(chr->label); if (s->read_msgfds_num) { for (i =3D 0; i < s->read_msgfds_num; i++) { close(s->read_msgfds[i]); @@ -1375,6 +1378,9 @@ static void qmp_chardev_open_socket(Chardev *chr, return; } } + + load_char_socket_fd(chr); + } =20 static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend, @@ -1517,3 +1523,32 @@ static void register_types(void) } =20 type_init(register_types); + +void save_char_socket_fd(Chardev *chr) +{ + SocketChardev *sockchar =3D SOCKET_CHARDEV(chr); + + if (sockchar->sioc) { + setenv_fd(chr->label, sockchar->sioc->fd); + } +} + +void load_char_socket_fd(Chardev *chr) +{ + SocketChardev *sockchar; + QIOChannelSocket *sioc; + + int fd =3D getenv_fd(chr->label); + + if (fd !=3D -1) { + unsetenv_fd(chr->label); + sockchar =3D SOCKET_CHARDEV(chr); + sioc =3D qio_channel_socket_accept(*sockchar->listener->sioc, fd, = NULL); + if (sioc) { + tcp_chr_accept(sockchar->listener, sioc, chr); + } else { + error_printf("error: could not restore socket for %s\n", + chr->label); + } + } +} diff --git a/chardev/char.c b/chardev/char.c index 77e7ec8..8fd54cc 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -34,6 +34,7 @@ #include "qapi/qapi-commands-char.h" #include "qapi/qmp/qerror.h" #include "sysemu/replay.h" +#include "sysemu/sysemu.h" #include "qemu/help_option.h" #include "qemu/module.h" #include "qemu/option.h" @@ -1174,3 +1175,16 @@ static void register_types(void) } =20 type_init(register_types); + +static int chardev_is_socket(Object *child, void *opaque) +{ + if (CHARDEV_IS_SOCKET(child)) { + save_char_socket_fd((Chardev *) child); + } + return 0; +} + +void save_chardev_fds(void) +{ + object_child_foreach(get_chardevs_root(), chardev_is_socket, NULL); +} diff --git a/include/chardev/char.h b/include/chardev/char.h index 00589a6..80a9cf8 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -250,6 +250,8 @@ int qemu_chr_wait_connected(Chardev *chr, Error **errp); object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_RINGBUF) #define CHARDEV_IS_PTY(chr) \ object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_PTY) +#define CHARDEV_IS_SOCKET(chr) \ + object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_SOCKET) =20 typedef struct ChardevClass { ObjectClass parent_class; @@ -290,4 +292,7 @@ GSource *qemu_chr_timeout_add_ms(Chardev *chr, guint ms, /* console.c */ void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *backend, Error **er= rp); =20 +void save_char_socket_fd(Chardev *); +void load_char_socket_fd(Chardev *); + #endif diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 4dfc4ca..fa1a5c3 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -27,6 +27,7 @@ void qemu_remove_machine_init_done_notifier(Notifier *not= ify); =20 void save_cpr_snapshot(const char *file, const char *mode, Error **errp); void load_cpr_snapshot(const char *file, Error **errp); +void save_chardev_fds(void); =20 extern int autostart; =20 diff --git a/migration/savevm.c b/migration/savevm.c index 2902006..81f38c4 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2700,6 +2700,12 @@ static QEMUFile *qf_file_open(const char *filename, = int flags, int mode, return qemu_fopen_channel_input(ioc); } =20 +static int preserve_fd(const char *name, const char *val, void *handle) +{ + qemu_clr_cloexec(atoi(val)); + return 0; +} + void save_cpr_snapshot(const char *file, const char *mode, Error **errp) { int ret =3D 0; @@ -2761,6 +2767,8 @@ void save_cpr_snapshot(const char *file, const char *= mode, Error **errp) if (qemu_preserve_ram(errp)) { return; } + save_chardev_fds(); + walkenv(FD_PREFIX, preserve_fd, 0); qemu_system_exec_request(); putenv((char *)"QEMU_START_FREEZE=3D"); } --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596124432; cv=none; d=zohomail.com; s=zohoarc; b=LnJXSuyLGENXYNg8paIxTTsqyslDshVoIWjHFV3ckiitL1dtkJzUjci/uubuE4xn+HbEtJcpltvt6TINGDPHOLVVDxlL0Qg5vEuG4biUw3qysPtOolG7ktQgVvi+u83RWhxittYIDp9HSeTgU4iRFxUs/xC5ga1tJ+9BEgOAwr8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596124432; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=gA4smmTDr4yV2TFqL9n5pgGRpocaWBZlXIn3Szu+0+M=; b=Z1C6cbjtW25+66cDsoK8aUc485q27Gszysz08aeHsbK4KBCz/vlub6abn7HzIxWckjOpkNPA8eomQuJ7xlMsuvcGe5SMReDfX+EJGh1gtLdNz7s5XfGiL7fskwmcUw0dCEHalAqLR6MWA87R+nU5Ib4c5yRzYEpsDnyFL7ObLJw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596124432051403.79199634245595; Thu, 30 Jul 2020 08:53:52 -0700 (PDT) Received: from localhost ([::1]:49846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1AsQ-0003dC-Nh for importer@patchew.org; Thu, 30 Jul 2020 11:53:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdS-0007bR-5f for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:25 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:37176) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdN-0002C2-CJ for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:20 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXXd3155787; Thu, 30 Jul 2020 15:38:15 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 32hu1jmee8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:38:15 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXShC130702; Thu, 30 Jul 2020 15:38:14 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 32hu5wwh23-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:14 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 06UFcDJV001920; Thu, 30 Jul 2020 15:38:13 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:12 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=gA4smmTDr4yV2TFqL9n5pgGRpocaWBZlXIn3Szu+0+M=; b=BVT1abTqjT8zlDGDu6rO+Dg2O4Nk18XH/O7Q2rr5r0KGQg849IeHfSQZ/DeAApQNwV+1 E/Q1bdCmAYFM2dgXFl+xJAF+eOlwk9rdA0+kQV1DYpzPvgQLvS8Lnmdlk5Ul4Yth6XpT MV370a/eE65P5ggWX/kavm9os1e2JXSSxaPnOvxWcUIHD9/Ns1KjmO0niJzVYIt3+P/H 8Nr6fThMIRzJ+VIkn3MTlupW9Bc8JeMlk9f7fQ06o+v14lHBtPFQhq0uw87GxbJZvY8g dDTAJaO+lFDZv+piwlaOpKQ8HHXZHsrtLXCsd0/XexF8jt+6D6mgfnlfkFy6P4BgiWXA 7g== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 24/32] ui: save/restore vnc socket fds Date: Thu, 30 Jul 2020 08:14:28 -0700 Message-Id: <1596122076-341293-25-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=1 bulkscore=0 malwarescore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 clxscore=1015 mlxscore=0 impostorscore=0 phishscore=0 adultscore=0 suspectscore=1 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=141.146.126.78; envelope-from=steven.sistare@oracle.com; helo=aserp2120.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:37:57 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Mark Kanda Iterate through the VNC displays and save/restore the socket fds. Signed-off-by: Mark Kanda Signed-off-by: Steve Sistare --- include/sysemu/sysemu.h | 2 + migration/savevm.c | 3 + ui/vnc.c | 153 +++++++++++++++++++++++++++++++++++++++-----= ---- 3 files changed, 130 insertions(+), 28 deletions(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index fa1a5c3..3e7bfee 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -28,6 +28,8 @@ void qemu_remove_machine_init_done_notifier(Notifier *not= ify); void save_cpr_snapshot(const char *file, const char *mode, Error **errp); void load_cpr_snapshot(const char *file, Error **errp); void save_chardev_fds(void); +void save_vnc_fds(void); +void load_vnc_fds(void); =20 extern int autostart; =20 diff --git a/migration/savevm.c b/migration/savevm.c index 81f38c4..35fafb7 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2768,6 +2768,7 @@ void save_cpr_snapshot(const char *file, const char *= mode, Error **errp) return; } save_chardev_fds(); + save_vnc_fds(); walkenv(FD_PREFIX, preserve_fd, 0); qemu_system_exec_request(); putenv((char *)"QEMU_START_FREEZE=3D"); @@ -3015,6 +3016,8 @@ void load_cpr_snapshot(const char *file, Error **errp) start_on_wake =3D 1; } } + + load_vnc_fds(); } =20 int load_snapshot(const char *name, Error **errp) diff --git a/ui/vnc.c b/ui/vnc.c index f006aa1..947ddf5 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -50,6 +50,7 @@ #include "qom/object_interfaces.h" #include "qemu/cutils.h" #include "io/dns-resolver.h" +#include "sysemu/sysemu.h" =20 #define VNC_REFRESH_INTERVAL_BASE GUI_REFRESH_INTERVAL_DEFAULT #define VNC_REFRESH_INTERVAL_INC 50 @@ -2214,28 +2215,34 @@ static void set_pixel_format(VncState *vs, int bits= _per_pixel, graphic_hw_update(vs->vd->dcl.con); } =20 -static void pixel_format_message (VncState *vs) { +/* + * reuse - true if we are using an existing (already initialized) + * connection to a vnc client + */ +static void pixel_format_message(VncState *vs, bool reuse) +{ char pad[3] =3D { 0, 0, 0 }; =20 vs->client_pf =3D qemu_default_pixelformat(32); =20 - vnc_write_u8(vs, vs->client_pf.bits_per_pixel); /* bits-per-pixel */ - vnc_write_u8(vs, vs->client_pf.depth); /* depth */ + if (!reuse) { + vnc_write_u8(vs, vs->client_pf.bits_per_pixel); /* bits-per-pixel = */ + vnc_write_u8(vs, vs->client_pf.depth); /* depth */ =20 #ifdef HOST_WORDS_BIGENDIAN - vnc_write_u8(vs, 1); /* big-endian-flag */ + vnc_write_u8(vs, 1); /* big-endian-flag */ #else - vnc_write_u8(vs, 0); /* big-endian-flag */ + vnc_write_u8(vs, 0); /* big-endian-flag */ #endif - vnc_write_u8(vs, 1); /* true-color-flag */ - vnc_write_u16(vs, vs->client_pf.rmax); /* red-max */ - vnc_write_u16(vs, vs->client_pf.gmax); /* green-max */ - vnc_write_u16(vs, vs->client_pf.bmax); /* blue-max */ - vnc_write_u8(vs, vs->client_pf.rshift); /* red-shift */ - vnc_write_u8(vs, vs->client_pf.gshift); /* green-shift */ - vnc_write_u8(vs, vs->client_pf.bshift); /* blue-shift */ - vnc_write(vs, pad, 3); /* padding */ - + vnc_write_u8(vs, 1); /* true-color-flag */ + vnc_write_u16(vs, vs->client_pf.rmax); /* red-max */ + vnc_write_u16(vs, vs->client_pf.gmax); /* green-max */ + vnc_write_u16(vs, vs->client_pf.bmax); /* blue-max */ + vnc_write_u8(vs, vs->client_pf.rshift); /* red-shift */ + vnc_write_u8(vs, vs->client_pf.gshift); /* green-shift */ + vnc_write_u8(vs, vs->client_pf.bshift); /* blue-shift */ + vnc_write(vs, pad, 3); /* padding */ + } vnc_hextile_set_pixel_conversion(vs, 0); vs->write_pixels =3D vnc_write_pixels_copy; } @@ -2252,7 +2259,7 @@ static void vnc_colordepth(VncState *vs) pixman_image_get_width(vs->vd->server), pixman_image_get_height(vs->vd->server), VNC_ENCODING_WMVi); - pixel_format_message(vs); + pixel_format_message(vs, false); vnc_unlock_output(vs); vnc_flush(vs); } else { @@ -2420,7 +2427,8 @@ static int protocol_client_msg(VncState *vs, uint8_t = *data, size_t len) return 0; } =20 -static int protocol_client_init(VncState *vs, uint8_t *data, size_t len) +static int protocol_client_init_base(VncState *vs, uint8_t *data, size_t l= en, + bool reuse) { char buf[1024]; VncShareMode mode; @@ -2495,10 +2503,11 @@ static int protocol_client_init(VncState *vs, uint8= _t *data, size_t len) pixman_image_get_height(vs->vd->server) >=3D 0); vs->client_width =3D pixman_image_get_width(vs->vd->server); vs->client_height =3D pixman_image_get_height(vs->vd->server); - vnc_write_u16(vs, vs->client_width); - vnc_write_u16(vs, vs->client_height); - - pixel_format_message(vs); + if (!reuse) { + vnc_write_u16(vs, vs->client_width); + vnc_write_u16(vs, vs->client_height); + } + pixel_format_message(vs, reuse); =20 if (qemu_name) { size =3D snprintf(buf, sizeof(buf), "QEMU (%s)", qemu_name); @@ -2509,9 +2518,11 @@ static int protocol_client_init(VncState *vs, uint8_= t *data, size_t len) size =3D snprintf(buf, sizeof(buf), "QEMU"); } =20 - vnc_write_u32(vs, size); - vnc_write(vs, buf, size); - vnc_flush(vs); + if (!reuse) { + vnc_write_u32(vs, size); + vnc_write(vs, buf, size); + vnc_flush(vs); + } =20 vnc_client_cache_auth(vs); vnc_qmp_event(vs, QAPI_EVENT_VNC_INITIALIZED); @@ -2521,6 +2532,11 @@ static int protocol_client_init(VncState *vs, uint8_= t *data, size_t len) return 0; } =20 +static int protocol_client_init(VncState *vs, uint8_t *data, size_t len) +{ + return protocol_client_init_base(vs, data, len, false); +} + void start_client_init(VncState *vs) { vnc_read_when(vs, protocol_client_init, 1); @@ -3012,8 +3028,12 @@ static void vnc_refresh(DisplayChangeListener *dcl) } } =20 +/* + * reuse - true if we are using an existing (already initialized) + * connection to a vnc client + */ static void vnc_connect(VncDisplay *vd, QIOChannelSocket *sioc, - bool skipauth, bool websocket) + bool skipauth, bool websocket, bool reuse) { VncState *vs =3D g_new0(VncState, 1); bool first_client =3D QTAILQ_EMPTY(&vd->clients); @@ -3109,10 +3129,15 @@ static void vnc_connect(VncDisplay *vd, QIOChannelS= ocket *sioc, =20 graphic_hw_update(vd->dcl.con); =20 - if (!vs->websocket) { + if ((!vs->websocket) && !reuse) { vnc_start_protocol(vs); } =20 + if (reuse) { + uint8_t data[1] =3D {0}; + (void) protocol_client_init_base(vs, data, sizeof(data), true); + } + if (vd->num_connecting > vd->connections_limit) { QTAILQ_FOREACH(vs, &vd->clients, next) { if (vs->share_mode =3D=3D VNC_SHARE_MODE_CONNECTING) { @@ -3143,7 +3168,7 @@ static void vnc_listen_io(QIONetListener *listener, qio_channel_set_name(QIO_CHANNEL(cioc), isWebsock ? "vnc-ws-server" : "vnc-server"); qio_channel_set_delay(QIO_CHANNEL(cioc), false); - vnc_connect(vd, cioc, false, isWebsock); + vnc_connect(vd, cioc, false, isWebsock, false); } =20 static const DisplayChangeListenerOps dcl_ops =3D { @@ -3733,7 +3758,7 @@ static int vnc_display_connect(VncDisplay *vd, if (qio_channel_socket_connect_sync(sioc, saddr[0], errp) < 0) { return -1; } - vnc_connect(vd, sioc, false, false); + vnc_connect(vd, sioc, false, false, false); object_unref(OBJECT(sioc)); return 0; } @@ -4057,7 +4082,7 @@ void vnc_display_add_client(const char *id, int csock= , bool skipauth) sioc =3D qio_channel_socket_new_fd(csock, NULL); if (sioc) { qio_channel_set_name(QIO_CHANNEL(sioc), "vnc-server"); - vnc_connect(vd, sioc, skipauth, false); + vnc_connect(vd, sioc, skipauth, false, false); object_unref(OBJECT(sioc)); } } @@ -4117,3 +4142,75 @@ static void vnc_register_config(void) qemu_add_opts(&qemu_vnc_opts); } opts_init(vnc_register_config); + +void save_vnc_fds(void) +{ + VncDisplay *vd; + VncState *vs; + int disp_num =3D 0; + char name[40]; + + QTAILQ_FOREACH(vd, &vnc_displays, next) { + QTAILQ_FOREACH(vs, &vd->clients, next) { + if (vs->sioc) { + snprintf(name, sizeof(name), "%s_%d", vs->sioc->parent.nam= e, + disp_num); + setenv_fd(name, vs->sioc->fd); + break; + } + } + disp_num++; + } +} + +static void set_vnc_fd(char *name, QIOChannelSocket *cioc, VncDisplay *vd, + bool isWebsock) +{ + VncState *vs; + QIOChannelSocket *sioc; + + int fd =3D getenv_fd(name); + if (fd !=3D -1) { + sioc =3D qio_channel_socket_accept(cioc, fd, NULL); + if (sioc) { + unsetenv_fd(name); + qio_channel_set_name(QIO_CHANNEL(sioc), + isWebsock ? "vnc-ws-server" : "vnc-server= "); + + qio_channel_set_delay(QIO_CHANNEL(sioc), false); + vnc_connect(vd, sioc, false, isWebsock, true); + object_unref(OBJECT(sioc)); + + /* force update on all clients */ + QTAILQ_FOREACH(vs, &vd->clients, next) { + vs->update =3D VNC_STATE_UPDATE_FORCE; + } + } else { + error_printf("Could not restore vnc channel %s; " + "client must reconnect.\n", name); + } + } +} + +void load_vnc_fds(void) +{ + VncDisplay *vd; + QIOChannelSocket *cioc =3D NULL; + int disp_num =3D 0; + char name[40]; + + QTAILQ_FOREACH(vd, &vnc_displays, next) { + if (vd->listener) { + cioc =3D *vd->listener->sioc; + snprintf(name, sizeof(name), "vnc-server_%d", disp_num); + set_vnc_fd(name, cioc, vd, false); + } + + if (vd->wslistener) { + cioc =3D *vd->wslistener->sioc; + snprintf(name, sizeof(name), "vnc-ws-server_%d", disp_num); + set_vnc_fd(name, cioc, vd, true); + } + disp_num++; + } +} --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596124553; cv=none; d=zohomail.com; s=zohoarc; b=bQlj6LezTQ2WSlVajPQfUsLS3Zk2vY+Yfqy/4up0taFMNw8G6vd3C/zf+/+1kKFghIhHzzRekTK5qpeiwAxaNXciMZxK1m/GjRq+J8jNlhUDt60cYtjBjAUE+GW78eq5vt4mruB+ULfbjcimNtu0SAmHso2us4OYFbg42rSm0P8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596124553; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=/bBMFyHn6buXcDgFeO/yrjY+ou4q0vlnEUE5DvXf+LI=; b=NrPESFJPNuixHWuiG13KhsaB6JF/Jspl/BaE8UA+5cL9HYwYArk9+T+f8seAOIXacWy3thIDYInSC1xsls/5YHk0ka4h8phfCZ6SWAU+3QCpuH0ZVBqttnILZa4JF9BHDZRmbHc7sI2ib44eFwOpaoGmppawkaY86gXQe6qmZgE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596124553945267.8345960882124; Thu, 30 Jul 2020 08:55:53 -0700 (PDT) Received: from localhost ([::1]:56196 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1AuO-0006Oq-Qn for importer@patchew.org; Thu, 30 Jul 2020 11:55:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdW-0007cN-9c for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:26 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50228) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdQ-0002CJ-MH for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:25 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXR5g007530; Thu, 30 Jul 2020 15:38:16 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 32hu1jmfg1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:38:16 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFWp1N188439; Thu, 30 Jul 2020 15:38:15 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 32hu5xja5u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:15 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 06UFcDTx014628; Thu, 30 Jul 2020 15:38:13 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:13 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=/bBMFyHn6buXcDgFeO/yrjY+ou4q0vlnEUE5DvXf+LI=; b=Y8jlFshG4yXOqZePVb8gyXnHbUjn+P4CQxQmtkKgEd5zeUs42PPhN7q4yEZi+gfHYqBl n3J3lP25+tvcyj+UE4YwVwUC4v/aMJ3OjLbbyzRmJar0A7qVU9JRQEWfqfzGi1Qta067 3tRqpdxQMVLb3FOlgp8RAkMFo/bVS8pwGDfwSZNIHkZuiBCkzDDqbKnRlf1kNNwlF393 gZwS7yrer37JihXNcO0QuHz7e9LrbXMY+rOjYcF0t6rLvlwzB+yd/iMQzUcf8clewgUA EBi1yPa6Dr+kcLx6oDhggBXmczUkbkOeVTxvZQcHNX+TeQ5YFexyZ+/2sX0RAasP/sRI ig== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 25/32] char: save/restore chardev pty fds Date: Thu, 30 Jul 2020 08:14:29 -0700 Message-Id: <1596122076-341293-26-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxscore=0 adultscore=0 spamscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 clxscore=1015 malwarescore=0 spamscore=0 suspectscore=1 bulkscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.86; envelope-from=steven.sistare@oracle.com; helo=userp2130.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:37:58 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Save and restore pty descriptors across cprsave and cprload. Signed-off-by: Steve Sistare --- chardev/char-pty.c | 38 +++++++++++++++++++++++++++----------- chardev/char.c | 2 ++ include/chardev/char.h | 1 + 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/chardev/char-pty.c b/chardev/char-pty.c index 1cc501a..0785429 100644 --- a/chardev/char-pty.c +++ b/chardev/char-pty.c @@ -30,6 +30,7 @@ #include "qemu/sockets.h" #include "qemu/error-report.h" #include "qemu/module.h" +#include "qemu/cutils.h" #include "qemu/qemu-print.h" =20 #include "chardev/char-io.h" @@ -183,6 +184,16 @@ static void pty_chr_state(Chardev *chr, int connected) } } =20 +void save_char_pty_fd(Chardev *chr) +{ + PtyChardev *s =3D PTY_CHARDEV(chr); + QIOChannelFile *fioc =3D QIO_CHANNEL_FILE(s->ioc); + + if (fioc) { + setenv_fd(chr->label, fioc->fd); + } +} + static void char_pty_finalize(Object *obj) { Chardev *chr =3D CHARDEV(obj); @@ -204,18 +215,23 @@ static void char_pty_open(Chardev *chr, char pty_name[PATH_MAX]; char *name; =20 - master_fd =3D qemu_openpty_raw(&slave_fd, pty_name); - if (master_fd < 0) { - error_setg_errno(errp, errno, "Failed to create PTY"); - return; - } - - close(slave_fd); - qemu_set_nonblock(master_fd); + master_fd =3D getenv_fd(chr->label); + if (master_fd >=3D 0) { + unsetenv_fd(chr->label); + chr->filename =3D g_strdup_printf("pty:unknown"); + } else { + master_fd =3D qemu_openpty_raw(&slave_fd, pty_name); + if (master_fd < 0) { + error_setg_errno(errp, errno, "Failed to create PTY"); + return; + } =20 - chr->filename =3D g_strdup_printf("pty:%s", pty_name); - qemu_printf("char device redirected to %s (label %s)\n", - pty_name, chr->label); + close(slave_fd); + qemu_set_nonblock(master_fd); + chr->filename =3D g_strdup_printf("pty:%s", pty_name); + qemu_printf("char device redirected to %s (label %s)\n", + pty_name, chr->label); + } =20 s =3D PTY_CHARDEV(chr); s->ioc =3D QIO_CHANNEL(qio_channel_file_new_fd(master_fd)); diff --git a/chardev/char.c b/chardev/char.c index 8fd54cc..da75a04 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -1180,6 +1180,8 @@ static int chardev_is_socket(Object *child, void *opa= que) { if (CHARDEV_IS_SOCKET(child)) { save_char_socket_fd((Chardev *) child); + } else if (CHARDEV_IS_PTY(child)) { + save_char_pty_fd((Chardev *) child); } return 0; } diff --git a/include/chardev/char.h b/include/chardev/char.h index 80a9cf8..c18bda8 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -294,5 +294,6 @@ void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *= backend, Error **errp); =20 void save_char_socket_fd(Chardev *); void load_char_socket_fd(Chardev *); +void save_char_pty_fd(Chardev *); =20 #endif --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596124863; cv=none; d=zohomail.com; s=zohoarc; b=Y52kPgqEw2S/xcqN/M+GBkJziiEWGhfg8N2QJ09szjxFoq/XnXSqxeg6vj/INGaiWmhP1vY4JVQ/S8UaRUq4lqfhq+zIwhirSefRGBhKWZ8lkeKdv3jgiIAaIZklr073tpZaoIsYwetUcx9V5yiOiivWmyMiEETNorz3hWfQkvk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596124863; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=nYgT/y57sVzpOSiaYIaK+jjHlfq5K79EuRuiPY25c60=; b=UqlZo1jjFGexmk7KU56BuyWxzcAxPSjIMYg88F9nW45fIF4FynIGhxwCjaF7lrttNLoKZ6g77Wp8l/jvDuaISy06umfmrYXTQXuXehRu/ZONlCxgVmhISk4/rPfEeGWAu5I85dwuF1DFvhyjCUFPts93MewCMcNfd65NbGbeowo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596124863862533.0132003021249; Thu, 30 Jul 2020 09:01:03 -0700 (PDT) Received: from localhost ([::1]:41796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1AzN-00043v-6f for importer@patchew.org; Thu, 30 Jul 2020 12:01:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54780) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AfR-0001X9-GG for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:25 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:52042) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AfL-0002Vv-0G for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:25 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXQsV007512; Thu, 30 Jul 2020 15:40:16 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 32hu1jmfv6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:40:15 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFWpSk188385; Thu, 30 Jul 2020 15:38:15 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 32hu5xja5v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:15 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 06UFcEXp020515; Thu, 30 Jul 2020 15:38:14 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:14 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=nYgT/y57sVzpOSiaYIaK+jjHlfq5K79EuRuiPY25c60=; b=b6tbzol30La8tD87BoxgppdoxH3E7J9KREUqyPa9GXweWn2XnDsog4HYdYhoDY9EajxA kPZ7iFiIMWJFk5Jj+NlegHwygsFqDLZjOnXlw4AeD+ouujPslSDCIuhuQOjTMauAZEWy e+eo7uSuX5xceyEvixl4uCc+dc8Hy0Yq1K0nlmL1aQBiHTNEBgw12WyTMhCUcXSLoUeo k284HeikC17b7cnEviS5olItJgyNsZ5iI+14AWwYSAae+7zKaL38uk5Hjh1zDbc7zpnB HyCB/AEbL8rqOqI/gFOGcJTrHmtFgVYjARWFUD4ToBP22RDHf81tmgYgP/QkgMYdfTRW 8Q== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 26/32] monitor: save/restore QMP negotiation status Date: Thu, 30 Jul 2020 08:14:30 -0700 Message-Id: <1596122076-341293-27-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxscore=0 adultscore=0 spamscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 clxscore=1015 malwarescore=0 spamscore=0 suspectscore=1 bulkscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.86; envelope-from=steven.sistare@oracle.com; helo=userp2130.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:37:58 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Mark Kanda Save and restore QMP compatibility negotiation status across cprsave and cprload. Signed-off-by: Mark Kanda Signed-off-by: Steve Sistare --- include/sysemu/sysemu.h | 1 + migration/savevm.c | 1 + monitor/qmp.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 3e7bfee..c5b2f24 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -30,6 +30,7 @@ void load_cpr_snapshot(const char *file, Error **errp); void save_chardev_fds(void); void save_vnc_fds(void); void load_vnc_fds(void); +void save_qmp_negotiation_status(void); =20 extern int autostart; =20 diff --git a/migration/savevm.c b/migration/savevm.c index 35fafb7..225eaa6 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2770,6 +2770,7 @@ void save_cpr_snapshot(const char *file, const char *= mode, Error **errp) save_chardev_fds(); save_vnc_fds(); walkenv(FD_PREFIX, preserve_fd, 0); + save_qmp_negotiation_status(); qemu_system_exec_request(); putenv((char *)"QEMU_START_FREEZE=3D"); } diff --git a/monitor/qmp.c b/monitor/qmp.c index d433cea..9944ce5 100644 --- a/monitor/qmp.c +++ b/monitor/qmp.c @@ -33,6 +33,8 @@ #include "qapi/qmp/qlist.h" #include "qapi/qmp/qstring.h" #include "trace.h" +#include "qemu/env.h" +#include "sysemu/sysemu.h" =20 struct QMPRequest { /* Owner of the request */ @@ -398,6 +400,21 @@ static void monitor_qmp_setup_handlers_bh(void *opaque) monitor_list_append(&mon->common); } =20 +static void setenv_qmp(const char *name, bool val) +{ + setenv_bool(name, val); +} + +static bool getenv_qmp(const char *name) +{ + bool ret =3D getenv_bool(name); + if (ret !=3D -1) { + unsetenv_bool(name); + return ret; + } + return false; +} + void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp) { MonitorQMP *mon =3D g_new0(MonitorQMP, 1); @@ -438,4 +455,29 @@ void monitor_init_qmp(Chardev *chr, bool pretty, Error= **errp) NULL, &mon->common, NULL, true); monitor_list_append(&mon->common); } + + /* + * If a chr->label qmp env var is true, this is a restored qmp + * connection with capabilities negotiated. + */ + if (getenv_qmp(chr->label) =3D=3D true) { + mon->commands =3D &qmp_commands; + } +} + +void save_qmp_negotiation_status(void) +{ + Monitor *mon; + MonitorQMP *qmp_mon; + + QTAILQ_FOREACH(mon, &mon_list, entry) { + if (!monitor_is_qmp(mon)) { + continue; + } + + qmp_mon =3D container_of(mon, MonitorQMP, common); + if (qmp_mon->commands =3D=3D &qmp_commands) { + setenv_qmp(mon->chr.chr->label, true); + } + } } --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596125082; cv=none; d=zohomail.com; s=zohoarc; b=FvOLQgCcbhrAgECcm46+YyqkYu0MM2ygrxjpr+npFhcoySzmSOd64n7tjG2+4qQATlGluL+7f3rZJCb49opq2zy6eYRlS/F3yU8K14tGpkTeiBRrSYERL7Ubx/em+3ruTe6RXbUFRl81xgO95dgwpNGUribt367J7QMfaz6STPc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596125082; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=7DOqpXdM4b46H9Bprd54+k7iPJnt7p1rT/stHg9VDPI=; b=X8VUUdg/gW/8wotE0uam0FFstaJUG1wrDHm9PpApm55Ja8bSxTmFpTktsgo5f8HwZonI9x0ISDKK8T/WiNwE44ZJnEDO29jtrvpIaSEajOroP0BzfKenVs9rl38wLhXab1H3Z3fRNnCpJszktyvuXE5viC3uGeCvApVgeLJgDXM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596125082283493.90403055341676; Thu, 30 Jul 2020 09:04:42 -0700 (PDT) Received: from localhost ([::1]:55592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1B2u-0002Ap-Ok for importer@patchew.org; Thu, 30 Jul 2020 12:04:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AfV-0001g1-6A for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:29 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48126) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AfP-0002W9-1T for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:28 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXP8L152158; Thu, 30 Jul 2020 15:40:16 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 32hu1jvedd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:40:16 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXSHV130739; Thu, 30 Jul 2020 15:38:16 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 32hu5wwh3p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:16 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 06UFcFlT001927; Thu, 30 Jul 2020 15:38:15 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:15 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=7DOqpXdM4b46H9Bprd54+k7iPJnt7p1rT/stHg9VDPI=; b=E14TlXm/Bn3ntVqhG5DOZ0bSJ5zXcJjpOBMNV6iqnotzOdMSJE3x/iI6qYJ1yJQGWyn7 ra9n+wYDQU+sSl4vokAvjuEVxfeJOCzjtzBjgufQSGNCKKak2iVn/jxvod/fOWYjC9gA nbMm2e9MpTTUq7UagRZ37ZmsipF8e6tntmIeT7SGATsHZ8mMVFNojMOVRds/qYXHOvvs 9+btehUn3NUcVWgo5e42xWlkTOxlryubPW+/OHDsASq2Dw7vTNyCrqsLoIXRFbOgIPUb Wp6kMfOWvr1X80UlfiA77aylwU58wWx0hO+GjpW/E8bSD2zXmWks1m1DSPcNgB1M2ztv Tg== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 27/32] vhost: reset vhost devices upon cprsave Date: Thu, 30 Jul 2020 08:14:31 -0700 Message-Id: <1596122076-341293-28-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=1 bulkscore=0 malwarescore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxlogscore=999 malwarescore=0 impostorscore=0 priorityscore=1501 spamscore=0 phishscore=0 suspectscore=1 bulkscore=0 mlxscore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.85; envelope-from=steven.sistare@oracle.com; helo=userp2120.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:38:02 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Mark Kanda A vhost device is implicitly preserved across re-exec because its fd is not closed, and the value of the fd is specified on the command line for the new qemu to find. However, new qemu issues an VHOST_RESET_OWNER ioctl, which fails because the device already has an owner. To fix, reset the owner prior to exec. Signed-off-by: Mark Kanda Signed-off-by: Steve Sistare --- hw/virtio/vhost.c | 12 ++++++++++++ include/sysemu/sysemu.h | 1 + migration/savevm.c | 1 + 3 files changed, 14 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 1a1384e..d065b53 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -29,6 +29,7 @@ #include "sysemu/dma.h" #include "sysemu/tcg.h" #include "trace.h" +#include "sysemu/sysemu.h" =20 /* enabled until disconnected backend stabilizes */ #define _VHOST_DEBUG 1 @@ -1773,3 +1774,14 @@ int vhost_net_set_backend(struct vhost_dev *hdev, =20 return -1; } + +void reset_vhost_devices(void) +{ + struct vhost_dev *dev; + + QLIST_FOREACH(dev, &vhost_devices, entry) { + if (dev->vhost_ops->vhost_reset_device(dev) < 0) { + VHOST_OPS_DEBUG("vhost_reset_device failed"); + } + } +} diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index c5b2f24..e19c15b 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -30,6 +30,7 @@ void load_cpr_snapshot(const char *file, Error **errp); void save_chardev_fds(void); void save_vnc_fds(void); void load_vnc_fds(void); +void reset_vhost_devices(void); void save_qmp_negotiation_status(void); =20 extern int autostart; diff --git a/migration/savevm.c b/migration/savevm.c index 225eaa6..732dfb5 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2770,6 +2770,7 @@ void save_cpr_snapshot(const char *file, const char *= mode, Error **errp) save_chardev_fds(); save_vnc_fds(); walkenv(FD_PREFIX, preserve_fd, 0); + reset_vhost_devices(); save_qmp_negotiation_status(); qemu_system_exec_request(); putenv((char *)"QEMU_START_FREEZE=3D"); --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596124553; cv=none; d=zohomail.com; s=zohoarc; b=MTnVWg9E6RhKAcJC53WWByM2C+ftgIYJBoSJ/VlsbRF6EbMWqmSvVcX2I8EMqOShm+uNML37yyzZos4YWUjnNBhwFNn96k1pVtCHJANjy5HdSQ0gcdMG21MkNcTlX6N6m/h+J0ugb+Y0OpnM3XFdZSMyVdXBb9CWjdzs8n/DW/8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596124553; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=FPPMSivcUUtl0hRkdAFGBRzCLwr8+PkkoZfhLsJyqGs=; b=jgU+6JUy83r/nyChuMBJaijYzDKlrzQvvdo+I65XQxN79ZFheZfYlWZef6ILMgovwLcU3hLnIPSu10feD0+uISO5z4Hrr+P6MXGSfuOGVWOmEAosb6/zRLQdNa93mWN5G2PQZyd2qUp+HkV1/aEtklZqRyin3jI+/Cy7+217aQw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596124553694723.2667289125295; Thu, 30 Jul 2020 08:55:53 -0700 (PDT) Received: from localhost ([::1]:56176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1AuO-0006OL-ED for importer@patchew.org; Thu, 30 Jul 2020 11:55:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54044) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdY-0007eQ-Jp for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:28 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:46366) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdV-0002CO-Tv for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:28 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXPlV152146; Thu, 30 Jul 2020 15:38:18 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 32hu1jve10-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:38:18 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFWZrB176081; Thu, 30 Jul 2020 15:38:17 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 32hu61a20m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:17 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 06UFcGWZ007542; Thu, 30 Jul 2020 15:38:16 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:15 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=FPPMSivcUUtl0hRkdAFGBRzCLwr8+PkkoZfhLsJyqGs=; b=QM4weokiqiLhDvpSqxMTqdt9/TGQT+Ou7MoBsLCGSgokxwBFmQhmIqisJbHEBmQ7B+oA wrn7ouDQNMEgIf1lNz7s98J3ycDk68G3XDQAp0dy2gb++M4uHrM5ls/WAIPYO6ucNbi4 +/TR+rPPjAIszj52BkxvW/cooNs5NIIcO7cTL9+YLpesp2so6ezMVha22wRXSewrrOjk e0sBy0YeViPbxKJvaYsZBppNsdd2dYHF1qRnN+zze1BibThoAlNRhG7i9QXpkUth4mDG eLyaZPtsRsjTJlQZHlLVdJ0V3/03rbqzRSaopYlKjFuZ7xPmClm2hlkkO6eVRIWZRw+u pw== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 28/32] char: restore terminal on restart Date: Thu, 30 Jul 2020 08:14:32 -0700 Message-Id: <1596122076-341293-29-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxlogscore=999 malwarescore=0 impostorscore=0 priorityscore=1501 spamscore=0 phishscore=0 suspectscore=1 bulkscore=0 mlxscore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.85; envelope-from=steven.sistare@oracle.com; helo=userp2120.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:38:02 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If stdin is is a char backend device, then restore original stdin terminal settings in before re-exec'ing. Otherwise, the new qemu sees the modified settings as initial settings, and does not restore the true initial settings when it exits. Signed-off-by: Steve Sistare --- chardev/char-stdio.c | 7 +++++++ include/chardev/char.h | 2 ++ migration/savevm.c | 2 ++ 3 files changed, 11 insertions(+) diff --git a/chardev/char-stdio.c b/chardev/char-stdio.c index 82eaebc..6481d08 100644 --- a/chardev/char-stdio.c +++ b/chardev/char-stdio.c @@ -119,6 +119,13 @@ static void qemu_chr_open_stdio(Chardev *chr, } #endif =20 +void qemu_term_exit(void) +{ +#ifndef _WIN32 + term_exit(); +#endif +} + static void qemu_chr_parse_stdio(QemuOpts *opts, ChardevBackend *backend, Error **errp) { diff --git a/include/chardev/char.h b/include/chardev/char.h index c18bda8..5fd3ecc 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -296,4 +296,6 @@ void save_char_socket_fd(Chardev *); void load_char_socket_fd(Chardev *); void save_char_pty_fd(Chardev *); =20 +void qemu_term_exit(void); + #endif diff --git a/migration/savevm.c b/migration/savevm.c index 732dfb5..881dc13 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -32,6 +32,7 @@ #include "migration.h" #include "migration/snapshot.h" #include "migration/vmstate.h" +#include "chardev/char.h" #include "migration/misc.h" #include "migration/register.h" #include "migration/global_state.h" @@ -2772,6 +2773,7 @@ void save_cpr_snapshot(const char *file, const char *= mode, Error **errp) walkenv(FD_PREFIX, preserve_fd, 0); reset_vhost_devices(); save_qmp_negotiation_status(); + qemu_term_exit(); qemu_system_exec_request(); putenv((char *)"QEMU_START_FREEZE=3D"); } --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596124432; cv=none; d=zohomail.com; s=zohoarc; b=VbGVdd5MFIMFN02NnqDvX93IZv8MWD+3yz2cPLEQv/gPcAd5t3Kds2lV4edHBfHOClrhHVLDYNN5KMWVSYiNWbAvmHPEIrsrFlmuEfdQoBAnCFabhfhF0UqRAdX62rm3Ig7A+5grCPLSKHh6dTr4xmlBoIQK6vYurgHG8n07Fdw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596124432; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=YY5D39VKx7KmG8DuA4MVFb9AvBcnww2s9GY477Dv1AY=; b=S/ghY+/uhVk3yIPPgEGoDzM2jMHModDURqasye4WMTUL24DJ/VtzfMz8saCUmVfeLgm3lh1cm4mpZmXV2t9jbEICPXg1vN4BKyItQD0Z/gtP6X0M3Py91YSY/u4MMqOk+ZicUCnJvVjnZUekds+WyV2NvaLoAR6+UVS/CtR5fm0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596124432631118.76155850711268; Thu, 30 Jul 2020 08:53:52 -0700 (PDT) Received: from localhost ([::1]:49932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1AsR-0003fA-8a for importer@patchew.org; Thu, 30 Jul 2020 11:53:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdY-0007eL-Ig for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:28 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50258) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdV-0002CS-VP for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:27 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXP6S007487; Thu, 30 Jul 2020 15:38:19 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 32hu1jmfg8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:38:19 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFWZkc176078; Thu, 30 Jul 2020 15:38:18 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 32hu61a21u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:18 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 06UFcGG1007551; Thu, 30 Jul 2020 15:38:16 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:16 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=YY5D39VKx7KmG8DuA4MVFb9AvBcnww2s9GY477Dv1AY=; b=F7bhjvHlazBQxGL8ecgUix4nSu7n3KX2vBNSjqrTaNCfBR3e1OkS+XYQK3UWFGe6odLA 9bVzh+9wd9EcRgiQjuHSijJFFYPriyV+HN/AiKi6muNl6v9cpTKGTNJl6NO0LqShbLn7 4owo3W8vaMqqnPBuBPTiKRd2tCbIzNvsYz+GdgFoxdHatGqS/+g0FnzztdN6QSr/6hua gPOrE5+v8YszM3CJnjMaHo41EG9FKZAdKX5PZhu+9AX1Uf45OvhrQv1qA1Mq0pRzaj6p 5lionbrrfOALx6xEpauTA34ORkGF3Wi0dWsug/2Jqrf9TmUPNkHZtn54U33K+Vvj1zl3 IA== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 29/32] pci: export pci_update_mappings Date: Thu, 30 Jul 2020 08:14:33 -0700 Message-Id: <1596122076-341293-30-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 clxscore=1015 malwarescore=0 spamscore=0 suspectscore=1 bulkscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.86; envelope-from=steven.sistare@oracle.com; helo=userp2130.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:37:58 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Allow pci_update_mappings to be called from other modules. No change in functionality. Signed-off-by: Steve Sistare --- hw/pci/pci.c | 3 +-- include/hw/pci/pci.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index de0fae1..7343e00 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -216,7 +216,6 @@ static const TypeInfo pcie_bus_info =3D { }; =20 static PCIBus *pci_find_bus_nr(PCIBus *bus, int bus_num); -static void pci_update_mappings(PCIDevice *d); static void pci_irq_handler(void *opaque, int irq_num, int level); static void pci_add_option_rom(PCIDevice *pdev, bool is_default_rom, Error= **); static void pci_del_option_rom(PCIDevice *pdev); @@ -1316,7 +1315,7 @@ static pcibus_t pci_bar_address(PCIDevice *d, return new_addr; } =20 -static void pci_update_mappings(PCIDevice *d) +void pci_update_mappings(PCIDevice *d) { PCIIORegion *r; int i; diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index c1bf7d5..bd07c86 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -865,5 +865,6 @@ extern const VMStateDescription vmstate_pci_device; } =20 MSIMessage pci_get_msi_message(PCIDevice *dev, int vector); +void pci_update_mappings(PCIDevice *d); =20 #endif --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596125008; cv=none; d=zohomail.com; s=zohoarc; b=GsEb32WncjKyQv4zQBNb8c9ut9Sr2uMBRxk4WWkprKBdGiAuy8uKInp1w5r3wGohwA83XaF0SEpecv+5YmUNAQ4To0dVvkMgWbuzPAVj5vk0P7oWE+cekk3ASFbg5imxSlj1sG9OV0mOXyzimDrFLhdCtQBcv4YybUgGffDVwOE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596125008; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=3rCNeo1Lw8KTjzWvOvYbs+6lVAyGwEr3YPghYoQiiNY=; b=dURWtTeKt5Ed9zjbtIuchFZw9RabGqPcBPsUveKQrO1opTceJc6MxC/YoPe+/uzBclrX9it7boBS4OrytmBq3zJtfAuL1upQUYB/FUVsU2VMS/vZjR8Ig22Yyngcj2fa5kZGvh/0IfnC0ez0rkkn01SvHkyOyreNHB4jsxY/vxk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596125008339892.0840900468169; Thu, 30 Jul 2020 09:03:28 -0700 (PDT) Received: from localhost ([::1]:50056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1B1i-0007zz-Dj for importer@patchew.org; Thu, 30 Jul 2020 12:03:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54808) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AfT-0001bK-6x for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:27 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48164) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AfP-0002WS-2O for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:26 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXjA3152650; Thu, 30 Jul 2020 15:40:19 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 32hu1jvedj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:40:18 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFWpKR188448; Thu, 30 Jul 2020 15:38:18 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 32hu5xja7j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:18 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 06UFcH4k020536; Thu, 30 Jul 2020 15:38:17 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:17 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=3rCNeo1Lw8KTjzWvOvYbs+6lVAyGwEr3YPghYoQiiNY=; b=UMFJfPomJfYPyHpdMbmwrvCZ5GOkfEkOFZgTvys1ghgwCWvuweuw/rBYHDLlRznCm6v1 9PlJBSimQ1n7aRQt33Oa/2hhu7gz4G9W05Xpz5oTNqDLA+FqBJ3wxl1uDUWiq+BwnZc9 ddz0BKPGldFIKJKdbOQpSsQx/YbXsBVmbAy5nwfsHQy596WaN3pZ062XstayWojS/tqb b6Li9HT6eeVA1AsKRIc5g+ErkBtlvTttW9wYQpoYDv4A+onLwnnyOVzkIkpSuruO6Aeg Cnq61Ri8U+0AHrup5HJ6dZ6Uq/ixt+ee93R0571VNPZcI5ASQfbUTul/+wFs/5YRPwfF Lg== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 30/32] vfio-pci: save and restore Date: Thu, 30 Jul 2020 08:14:34 -0700 Message-Id: <1596122076-341293-31-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=4 malwarescore=0 mlxscore=0 adultscore=0 spamscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 mlxlogscore=999 malwarescore=0 impostorscore=0 priorityscore=1501 spamscore=0 phishscore=0 suspectscore=4 bulkscore=0 mlxscore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.85; envelope-from=steven.sistare@oracle.com; helo=userp2120.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:38:02 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Enable vfio-pci devices to be saved and restored across an exec restart of qemu. At vfio creation time, save the value of vfio container, group, and device descriptors in the environment. In cprsave, save the msi message area as part of vfio-pci vmstate, and clear the close-on-exec flag for the vfio descriptors. The flag is not cleared earlier because the descriptors should not persist across misc fork and exec calls that may be performed during normal operation. On qemu restart, vfio_realize() finds the descriptor env vars, uses the descriptors, and notes that the device is being reused. Device and iommu state is already configured, so operations in vfio_realize that would modify the configuration are skipped for a reused device, including vfio ioctl's and writes to PCI configuration space. The result is that vfio_realize constructs qemu data structures that reflect the current state of the device. However, the reconstruction is not complete until cprload is called, and vfio_pci_post_load uses the msi data to rebuild interrupt structures and attach the interrupts to the new KVM instance. Lastly, vfio device reset is suppressed when the VM is started. Signed-off-by: Steve Sistare --- hw/pci/pci.c | 4 ++ hw/vfio/common.c | 99 ++++++++++++++++++++++++++++++++++-----= ---- hw/vfio/pci.c | 79 ++++++++++++++++++++++++++++++++-- hw/vfio/platform.c | 2 +- include/hw/pci/pci.h | 1 + include/hw/vfio/vfio-common.h | 4 +- migration/savevm.c | 2 +- 7 files changed, 163 insertions(+), 28 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 7343e00..c2e1509 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -291,6 +291,10 @@ static void pci_do_device_reset(PCIDevice *dev) { int r; =20 + if (dev->reused) { + return; + } + pci_device_deassert_intx(dev); assert(dev->irq_state =3D=3D 0); =20 diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 3335714..a51a093 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -37,6 +37,7 @@ #include "sysemu/reset.h" #include "trace.h" #include "qapi/error.h" +#include "qemu/cutils.h" =20 VFIOGroupList vfio_group_list =3D QLIST_HEAD_INITIALIZER(vfio_group_list); @@ -299,6 +300,10 @@ static int vfio_dma_unmap(VFIOContainer *container, .size =3D size, }; =20 + if (container->reused) { + return 0; + } + while (ioctl(container->fd, VFIO_IOMMU_UNMAP_DMA, &unmap)) { /* * The type1 backend has an off-by-one bug in the kernel (71a7d3d7= 8e3c @@ -336,6 +341,10 @@ static int vfio_dma_map(VFIOContainer *container, hwad= dr iova, .size =3D size, }; =20 + if (container->reused) { + return 0; + } + if (!readonly) { map.flags |=3D VFIO_DMA_MAP_FLAG_WRITE; } @@ -1179,25 +1188,27 @@ static int vfio_init_container(VFIOContainer *conta= iner, int group_fd, return iommu_type; } =20 - ret =3D ioctl(group_fd, VFIO_GROUP_SET_CONTAINER, &container->fd); - if (ret) { - error_setg_errno(errp, errno, "Failed to set group container"); - return -errno; - } + if (!container->reused) { + ret =3D ioctl(group_fd, VFIO_GROUP_SET_CONTAINER, &container->fd); + if (ret) { + error_setg_errno(errp, errno, "Failed to set group container"); + return -errno; + } =20 - while (ioctl(container->fd, VFIO_SET_IOMMU, iommu_type)) { - if (iommu_type =3D=3D VFIO_SPAPR_TCE_v2_IOMMU) { - /* - * On sPAPR, despite the IOMMU subdriver always advertises v1 = and - * v2, the running platform may not support v2 and there is no - * way to guess it until an IOMMU group gets added to the cont= ainer. - * So in case it fails with v2, try v1 as a fallback. - */ - iommu_type =3D VFIO_SPAPR_TCE_IOMMU; - continue; + while (ioctl(container->fd, VFIO_SET_IOMMU, iommu_type)) { + if (iommu_type =3D=3D VFIO_SPAPR_TCE_v2_IOMMU) { + /* + * On sPAPR, despite the IOMMU subdriver always advertises= v1 + * and v2, the running platform may not support v2 and the= re is + * no way to guess it until an IOMMU group gets added to t= he + * container. So in case it fails with v2, try v1 as a fal= lback. + */ + iommu_type =3D VFIO_SPAPR_TCE_IOMMU; + continue; + } + error_setg_errno(errp, errno, "Failed to set iommu for contain= er"); + return -errno; } - error_setg_errno(errp, errno, "Failed to set iommu for container"); - return -errno; } =20 container->iommu_type =3D iommu_type; @@ -1210,6 +1221,8 @@ static int vfio_connect_container(VFIOGroup *group, A= ddressSpace *as, VFIOContainer *container; int ret, fd; VFIOAddressSpace *space; + char name[40]; + bool reused; =20 space =3D vfio_get_address_space(as); =20 @@ -1254,7 +1267,13 @@ static int vfio_connect_container(VFIOGroup *group, = AddressSpace *as, } } =20 - fd =3D qemu_open("/dev/vfio/vfio", O_RDWR); + snprintf(name, sizeof(name), "vfio_container_%d", group->groupid); + fd =3D getenv_fd(name); + reused =3D (fd >=3D 0); + if (fd < 0) { + fd =3D qemu_open("/dev/vfio/vfio", O_RDWR); + } + if (fd < 0) { error_setg_errno(errp, errno, "failed to open /dev/vfio/vfio"); ret =3D -errno; @@ -1272,6 +1291,8 @@ static int vfio_connect_container(VFIOGroup *group, A= ddressSpace *as, container =3D g_malloc0(sizeof(*container)); container->space =3D space; container->fd =3D fd; + container->cid =3D group->groupid; + container->reused =3D reused; container->error =3D NULL; QLIST_INIT(&container->giommu_list); QLIST_INIT(&container->hostwin_list); @@ -1395,6 +1416,10 @@ static int vfio_connect_container(VFIOGroup *group, = AddressSpace *as, =20 container->initialized =3D true; =20 + if (!reused) { + setenv_fd(name, fd); + } + return 0; listener_release_exit: QLIST_REMOVE(group, container_next); @@ -1418,6 +1443,7 @@ put_space_exit: static void vfio_disconnect_container(VFIOGroup *group) { VFIOContainer *container =3D group->container; + char name[40]; =20 QLIST_REMOVE(group, container_next); group->container =3D NULL; @@ -1450,6 +1476,8 @@ static void vfio_disconnect_container(VFIOGroup *grou= p) } =20 trace_vfio_disconnect_container(container->fd); + snprintf(name, sizeof(name), "vfio_container_%d", container->cid); + unsetenv_fd(name); close(container->fd); g_free(container); =20 @@ -1462,6 +1490,7 @@ VFIOGroup *vfio_get_group(int groupid, AddressSpace *= as, Error **errp) VFIOGroup *group; char path[32]; struct vfio_group_status status =3D { .argsz =3D sizeof(status) }; + bool reused; =20 QLIST_FOREACH(group, &vfio_group_list, next) { if (group->groupid =3D=3D groupid) { @@ -1479,7 +1508,13 @@ VFIOGroup *vfio_get_group(int groupid, AddressSpace = *as, Error **errp) group =3D g_malloc0(sizeof(*group)); =20 snprintf(path, sizeof(path), "/dev/vfio/%d", groupid); - group->fd =3D qemu_open(path, O_RDWR); + + group->fd =3D getenv_fd(path); + reused =3D (group->fd >=3D 0); + if (group->fd < 0) { + group->fd =3D qemu_open(path, O_RDWR); + } + if (group->fd < 0) { error_setg_errno(errp, errno, "failed to open %s", path); goto free_group_exit; @@ -1513,6 +1548,10 @@ VFIOGroup *vfio_get_group(int groupid, AddressSpace = *as, Error **errp) =20 QLIST_INSERT_HEAD(&vfio_group_list, group, next); =20 + if (!reused) { + setenv_fd(path, group->fd); + } + return group; =20 close_fd_exit: @@ -1526,6 +1565,8 @@ free_group_exit: =20 void vfio_put_group(VFIOGroup *group) { + char path[32]; + if (!group || !QLIST_EMPTY(&group->device_list)) { return; } @@ -1537,6 +1578,8 @@ void vfio_put_group(VFIOGroup *group) vfio_disconnect_container(group); QLIST_REMOVE(group, next); trace_vfio_put_group(group->fd); + snprintf(path, sizeof(path), "/dev/vfio/%d", group->groupid); + unsetenv_fd(path); close(group->fd); g_free(group); =20 @@ -1546,12 +1589,18 @@ void vfio_put_group(VFIOGroup *group) } =20 int vfio_get_device(VFIOGroup *group, const char *name, - VFIODevice *vbasedev, Error **errp) + VFIODevice *vbasedev, bool *reusedp, Error **errp) { struct vfio_device_info dev_info =3D { .argsz =3D sizeof(dev_info) }; int ret, fd; + bool reused; + + fd =3D getenv_fd(name); + reused =3D (fd >=3D 0); + if (fd < 0) { + fd =3D ioctl(group->fd, VFIO_GROUP_GET_DEVICE_FD, name); + } =20 - fd =3D ioctl(group->fd, VFIO_GROUP_GET_DEVICE_FD, name); if (fd < 0) { error_setg_errno(errp, errno, "error getting device from group %d", group->groupid); @@ -1601,6 +1650,13 @@ int vfio_get_device(VFIOGroup *group, const char *na= me, dev_info.num_irqs); =20 vbasedev->reset_works =3D !!(dev_info.flags & VFIO_DEVICE_FLAGS_RESET); + + if (!reused) { + setenv_fd(name, fd); + } + if (reusedp) { + *reusedp =3D reused; + } return 0; } =20 @@ -1612,6 +1668,7 @@ void vfio_put_base_device(VFIODevice *vbasedev) QLIST_REMOVE(vbasedev, next); vbasedev->group =3D NULL; trace_vfio_put_base_device(vbasedev->fd); + unsetenv_fd(vbasedev->name); close(vbasedev->fd); } =20 diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 2e561c0..5743807 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -49,6 +49,7 @@ =20 static void vfio_disable_interrupts(VFIOPCIDevice *vdev); static void vfio_mmap_set_enabled(VFIOPCIDevice *vdev, bool enabled); +static const VMStateDescription vfio_pci_vmstate; =20 /* * Disabling BAR mmaping can be slow, but toggling it around INTx can @@ -1585,6 +1586,14 @@ static void vfio_mmap_set_enabled(VFIOPCIDevice *vde= v, bool enabled) } } =20 +static void vfio_config_sync(VFIOPCIDevice *vdev, uint32_t offset, size_t = len) +{ + if (pread(vdev->vbasedev.fd, vdev->pdev.config + offset, len, + vdev->config_offset + offset) !=3D len) { + error_report("vfio_config_sync pread failed"); + } +} + static void vfio_bar_prepare(VFIOPCIDevice *vdev, int nr) { VFIOBAR *bar =3D &vdev->bars[nr]; @@ -1626,6 +1635,7 @@ static void vfio_bar_register(VFIOPCIDevice *vdev, in= t nr) { VFIOBAR *bar =3D &vdev->bars[nr]; char *name; + PCIDevice *pdev =3D &vdev->pdev; =20 if (!bar->size) { return; @@ -1646,6 +1656,9 @@ static void vfio_bar_register(VFIOPCIDevice *vdev, in= t nr) } =20 pci_register_bar(&vdev->pdev, nr, bar->type, bar->mr); + if (pdev->reused) { + vfio_config_sync(vdev, pci_bar(pdev, nr), 8); + } } =20 static void vfio_bars_register(VFIOPCIDevice *vdev) @@ -2805,7 +2818,8 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) goto error; } =20 - ret =3D vfio_get_device(group, vdev->vbasedev.name, &vdev->vbasedev, e= rrp); + ret =3D vfio_get_device(group, vdev->vbasedev.name, &vdev->vbasedev, + &pdev->reused, errp); if (ret) { vfio_put_group(group); goto error; @@ -2972,9 +2986,11 @@ static void vfio_realize(PCIDevice *pdev, Error **er= rp) vfio_intx_routing_notifier); vdev->irqchip_change_notifier.notify =3D vfio_irqchip_change; kvm_irqchip_add_change_notifier(&vdev->irqchip_change_notifier); - ret =3D vfio_intx_enable(vdev, errp); - if (ret) { - goto out_deregister; + if (!pdev->reused) { + ret =3D vfio_intx_enable(vdev, errp); + if (ret) { + goto out_deregister; + } } } =20 @@ -3017,6 +3033,11 @@ static void vfio_realize(PCIDevice *pdev, Error **er= rp) vfio_register_req_notifier(vdev); vfio_setup_resetfn_quirk(vdev); =20 + vfio_config_sync(vdev, pdev->msix_cap + PCI_MSIX_FLAGS, 2); + if (pdev->reused) { + pci_update_mappings(pdev); + } + return; =20 out_deregister: @@ -3080,6 +3101,10 @@ static void vfio_pci_reset(DeviceState *dev) { VFIOPCIDevice *vdev =3D PCI_VFIO(dev); =20 + if (vdev->pdev.reused) { + return; + } + trace_vfio_pci_reset(vdev->vbasedev.name); =20 vfio_pci_pre_reset(vdev); @@ -3182,6 +3207,51 @@ static Property vfio_pci_dev_properties[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 +static int vfio_pci_post_load(void *opaque, int version_id) +{ + int vector; + MSIMessage msg; + Error *err =3D 0; + VFIOPCIDevice *vdev =3D opaque; + PCIDevice *pdev =3D &vdev->pdev; + + if (msix_enabled(pdev)) { + vfio_msix_enable(vdev); + pdev->msix_function_masked =3D false; + + for (vector =3D 0; vector < vdev->pdev.msix_entries_nr; vector++) { + if (!msix_is_masked(pdev, vector)) { + msg =3D msix_get_message(pdev, vector); + vfio_msix_vector_use(pdev, vector, msg); + } + } + + } else if (vfio_pci_read_config(pdev, PCI_INTERRUPT_PIN, 1)) { + vfio_intx_enable(vdev, &err); + if (err) { + error_report_err(err); + } + } + + vdev->vbasedev.group->container->reused =3D false; + vdev->pdev.reused =3D false; + + return 0; +} + +static const VMStateDescription vfio_pci_vmstate =3D { + .name =3D "vfio-pci", + .unmigratable =3D 1, + .mode_mask =3D VMS_RESTART, + .version_id =3D 0, + .minimum_version_id =3D 0, + .post_load =3D vfio_pci_post_load, + .fields =3D (VMStateField[]) { + VMSTATE_MSIX(pdev, VFIOPCIDevice), + VMSTATE_END_OF_LIST() + } +}; + static void vfio_pci_dev_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -3189,6 +3259,7 @@ static void vfio_pci_dev_class_init(ObjectClass *klas= s, void *data) =20 dc->reset =3D vfio_pci_reset; device_class_set_props(dc, vfio_pci_dev_properties); + dc->vmsd =3D &vfio_pci_vmstate; dc->desc =3D "VFIO-based PCI device assignment"; set_bit(DEVICE_CATEGORY_MISC, dc->categories); pdc->realize =3D vfio_realize; diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index ac2cefc..e6e1a5d 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -592,7 +592,7 @@ static int vfio_base_device_init(VFIODevice *vbasedev, = Error **errp) return -EBUSY; } } - ret =3D vfio_get_device(group, vbasedev->name, vbasedev, errp); + ret =3D vfio_get_device(group, vbasedev->name, vbasedev, 0, errp); if (ret) { vfio_put_group(group); return ret; diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index bd07c86..c926a24 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -358,6 +358,7 @@ struct PCIDevice { =20 /* ID of standby device in net_failover pair */ char *failover_pair_id; + bool reused; }; =20 void pci_register_bar(PCIDevice *pci_dev, int region_num, diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index c78f3ff..4e2a332 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -73,6 +73,8 @@ typedef struct VFIOContainer { unsigned iommu_type; Error *error; bool initialized; + bool reused; + int cid; unsigned long pgsizes; QLIST_HEAD(, VFIOGuestIOMMU) giommu_list; QLIST_HEAD(, VFIOHostDMAWindow) hostwin_list; @@ -177,7 +179,7 @@ void vfio_reset_handler(void *opaque); VFIOGroup *vfio_get_group(int groupid, AddressSpace *as, Error **errp); void vfio_put_group(VFIOGroup *group); int vfio_get_device(VFIOGroup *group, const char *name, - VFIODevice *vbasedev, Error **errp); + VFIODevice *vbasedev, bool *reused, Error **errp); =20 extern const MemoryRegionOps vfio_region_ops; typedef QLIST_HEAD(VFIOGroupList, VFIOGroup) VFIOGroupList; diff --git a/migration/savevm.c b/migration/savevm.c index 881dc13..2606cf0 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1568,7 +1568,7 @@ static int qemu_savevm_state(QEMUFile *f, VMStateMode= mode, Error **errp) return -EINVAL; } =20 - if (migrate_use_block()) { + if ((mode & (VMS_SNAPSHOT | VMS_MIGRATE)) && migrate_use_block()) { error_setg(errp, "Block migration and snapshots are incompatible"); return -EINVAL; } --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596124082; cv=none; d=zohomail.com; s=zohoarc; b=XlB8jcf+aHFLOF9NgI1QK2FucaYkSKMfGJFTFWXEgqwtdoeOQ7vE1la/cB1qMegAW65vXiBK3keJLJjXlG2wohY3fWdxQHRbytzd6Q3U+WX6Lfe8NueH12qOgTzoA8ajmzMUhZXCZgFuUfU5clA+qajzo2RMXCRy1WZLmsBCasc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596124082; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=UF79pvoFFJrsRYU2u2K28RtDkLoecSqXccCEeTdSY4A=; b=GXMmh4BRz84FLUXxX1ihyCjshKxFglnWYGEURd1Ji8kYk/lpkJZJz0IthzdvB4nBBUuIZQDq8JFl5wA7+T2IdJSruyXhq7uNKU73+8g7BQ8gmYkQVGrElnLdGTQ/dDEjXKrZmqQGo1CFjhkrgea21HuAH7RCnB8M0ri1TIz36X8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596124082502422.2850059492026; Thu, 30 Jul 2020 08:48:02 -0700 (PDT) Received: from localhost ([::1]:60026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1Amn-0004LA-7O for importer@patchew.org; Thu, 30 Jul 2020 11:48:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdZ-0007hN-Pt for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:30 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50262) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AdV-0002CX-Vt for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:38:29 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXSrl007533; Thu, 30 Jul 2020 15:38:19 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 32hu1jmfga-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:38:19 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFWpjI188534; Thu, 30 Jul 2020 15:38:18 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 32hu5xja81-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:18 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 06UFcIrw020542; Thu, 30 Jul 2020 15:38:18 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:18 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=UF79pvoFFJrsRYU2u2K28RtDkLoecSqXccCEeTdSY4A=; b=ecgJHuBNf/qK2wMV3XHPCVD5ikOXxVnRjA0Z5VMPbqQe+7mrlCR3wv4k1GSC7+nV1sKe jNznwLs0DIzWWfQ3fJM8sBsIwKgrSG6CRA33Bmkgkcc7lBpYygmnReQ65Lw4kdcDoEWZ tP4ICI+QlVXDI/Mt6q4+lvVXRYzj0rqF3RYNGDV/CPVZNEB2n4iGzlfuAx3XLbVX1a0L /vaxV2hx87nwKsAt6hjVJIOw5kO1aD7f9r8AGD0DGhRbJI8yuiNQmysppoGdZ5jjFi7M LQhIF039F4DdroVKmP4PJpmvaK1giD1081PuHih3gcGD6L14DQ9MC2QVPLL6sgeJb2n1 SQ== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 31/32] vfio-pci: trace pci config Date: Thu, 30 Jul 2020 08:14:35 -0700 Message-Id: <1596122076-341293-32-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxscore=0 adultscore=0 spamscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 clxscore=1015 malwarescore=0 spamscore=0 suspectscore=1 bulkscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.86; envelope-from=steven.sistare@oracle.com; helo=userp2130.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:37:58 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add new trace points trace_vfio_pci_config and trace_vfio_msix_table to dump PCI config space and MSI data. Signed-off-by: Steve Sistare --- hw/vfio/pci.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++ hw/vfio/trace-events | 2 ++ 2 files changed, 101 insertions(+) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 5743807..f72e277 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2715,6 +2715,90 @@ static void vfio_unregister_req_notifier(VFIOPCIDevi= ce *vdev) vdev->req_enabled =3D false; } =20 +/* To limit output, trace only this many bytes of config. */ +#define CONFIG_LEN 512 + +static void vfio_dump_config(const char *name, int fd, off_t offset) +{ + int i, j, n, config[CONFIG_LEN / 4]; + char buf[128]; + const char *fmt; + char *ptr =3D buf; + int *v =3D config; + int len =3D sizeof(buf) - 1; + +#ifdef CONFIG_TRACE_DTRACE + if (!QEMU_VFIO_PCI_CONFIG_ENABLED()) { + return; + } +#endif + + if (pread(fd, &config, sizeof(config), offset) < 0) { + perror("pread"); + return; + } + + trace_vfio_pci_config(name); + + for (i =3D 0; i < CONFIG_LEN; i +=3D 32, v +=3D 8) { + n =3D snprintf(buf, len, "+%3d:", i); + ptr +=3D n; + len -=3D n; + for (j =3D 0; j < 8; j++) { + fmt =3D v[j] ? " %08x" : " %8x"; + n =3D snprintf(ptr, len, fmt, v[j]); + ptr +=3D n; + len -=3D n; + } + *ptr =3D 0; /* terminate in case of truncation above */ + trace_vfio_pci_config(buf); + } +} + +static void vfio_dump_config_vdev(VFIOPCIDevice *vdev) +{ + vfio_dump_config(vdev->vbasedev.name, vdev->vbasedev.fd, + vdev->config_offset); +} + +static void vfio_dump_msix_vdev(VFIOPCIDevice *vdev) +{ + int i; + int *ptr =3D (int *) vdev->pdev.msix_table; + + for (i =3D 0; i < vdev->pdev.msix_entries_nr; i++, ptr +=3D 4) { + trace_vfio_msix_table(vdev->vbasedev.name, i, + ptr[0], ptr[1], ptr[2], ptr[3]); + } +} + +static void vfio_diff_config(VFIOPCIDevice *vdev) +{ + int i; + unsigned char config[CONFIG_LEN]; + int n =3D sizeof(config); + unsigned char *c1 =3D (unsigned char *)config; + unsigned char *c2 =3D (unsigned char *)vdev->pdev.config; + char buf[128]; + +#ifdef CONFIG_TRACE_DTRACE + if (!QEMU_VFIO_PCI_CONFIG_ENABLED()) { + return; + } +#endif + + if (pread(vdev->vbasedev.fd, &config, n, vdev->config_offset) !=3D n) { + error_report("vfio_diff_config pread failed"); + } + for (i =3D 0; i < CONFIG_LEN; i++) { + if (c1[i] !=3D c2[i]) { + snprintf(buf, sizeof(buf), + "config mismatch at %d: %x vs %x", i, c1[i], c2[i]); + trace_vfio_pci_config(buf); + } + } +} + static void vfio_realize(PCIDevice *pdev, Error **errp) { VFIOPCIDevice *vdev =3D PCI_VFIO(pdev); @@ -3037,6 +3121,9 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) if (pdev->reused) { pci_update_mappings(pdev); } + vfio_diff_config(vdev); + vfio_dump_config_vdev(vdev); + vfio_dump_msix_vdev(vdev); =20 return; =20 @@ -3207,6 +3294,15 @@ static Property vfio_pci_dev_properties[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 +static int vfio_pci_pre_save(void *opaque) +{ + VFIOPCIDevice *vdev =3D opaque; + + vfio_dump_config_vdev(vdev); + vfio_dump_msix_vdev(vdev); + return 0; +} + static int vfio_pci_post_load(void *opaque, int version_id) { int vector; @@ -3226,6 +3322,8 @@ static int vfio_pci_post_load(void *opaque, int versi= on_id) } } =20 + vfio_dump_msix_vdev(vdev); + } else if (vfio_pci_read_config(pdev, PCI_INTERRUPT_PIN, 1)) { vfio_intx_enable(vdev, &err); if (err) { @@ -3246,6 +3344,7 @@ static const VMStateDescription vfio_pci_vmstate =3D { .version_id =3D 0, .minimum_version_id =3D 0, .post_load =3D vfio_pci_post_load, + .pre_save =3D vfio_pci_pre_save, .fields =3D (VMStateField[]) { VMSTATE_MSIX(pdev, VFIOPCIDevice), VMSTATE_END_OF_LIST() diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index b1ef55a..10d899c 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -47,6 +47,8 @@ vfio_pci_emulated_vendor_id(const char *name, uint16_t va= l) "%s 0x%04x" vfio_pci_emulated_device_id(const char *name, uint16_t val) "%s 0x%04x" vfio_pci_emulated_sub_vendor_id(const char *name, uint16_t val) "%s 0x%04x" vfio_pci_emulated_sub_device_id(const char *name, uint16_t val) "%s 0x%04x" +vfio_msix_table(const char *name, int index, int x0, int x1, int x2, int x= 3) "%s MSI-X[%d] =3D { %x %x %x %x }" +vfio_pci_config(const char *buf) "%s" =20 # pci-quirks.c vfio_quirk_rom_blacklisted(const char *name, uint16_t vid, uint16_t did) "= %s %04x:%04x" --=20 1.8.3.1 From nobody Fri Apr 26 21:05:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1596123904; cv=none; d=zohomail.com; s=zohoarc; b=bHj89aEv7PYQ9TtRPGszLd3HpOT0zphPDL3I5juUPpdUGAbNwCOloZIL2WWRYg+GBnJE/GlIq4V9tGxLyQDKusvN5NLLnMjKNkSDggOsUGJu/AuI7x3BjDeYIxynLL31gCHrxcGRQojD7yfJb7xKKg0WQ093SlZdfjA84lCBIys= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596123904; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=2Avxi1QWe6cUG3l1LSMFbAq/69tVDOToYh40OrsqGe4=; b=InNMJLndyob/5yveNxAxsjih87GOFeIieGdK+snpwapA9E+xgiceZ4iRfM586uWgPZaAM8IosNsMQV8Jv7Sp607GVxZ/1ihcZptZrLiKBBKPsZjnrj0LpKb5RJPIw3oSs8RPY+ZtyhaGQ851pQiG1WeXf3RV5+6ZR0SUTt+piYs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596123904858191.8312960180716; Thu, 30 Jul 2020 08:45:04 -0700 (PDT) Received: from localhost ([::1]:48922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1Ajv-00081C-FL for importer@patchew.org; Thu, 30 Jul 2020 11:45:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AfT-0001cS-NT for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:27 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:38998) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1AfP-0002WW-9S for qemu-devel@nongnu.org; Thu, 30 Jul 2020 11:40:27 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFXPB2155707; Thu, 30 Jul 2020 15:40:21 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 32hu1jmeut-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Jul 2020 15:40:21 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06UFYjZg172022; Thu, 30 Jul 2020 15:38:20 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 32hu5x0wut-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Jul 2020 15:38:20 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 06UFcI64020550; Thu, 30 Jul 2020 15:38:18 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Jul 2020 08:38:18 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=2Avxi1QWe6cUG3l1LSMFbAq/69tVDOToYh40OrsqGe4=; b=JbtPvXPsB7YTbRvXEQcezDf1/hl6eo4YAYQOf/3R88VzkPO1trOzEzr3w/Zj4uim3Dev 4iYa84hS+7lLDnRO8rRso5jMOMW0sI0FcMOtLyCbh4rgZLI/P5kTSjB3IV9FH3Ghb5/k kZ28/1Yv9IZfgtkqA10m5cMOocUd8spHPIf90ZUNhGRrdZtB+LAZip+albt+gt36Ulpm SZmUCg7oxkgdZ88k7fQCYXsOjleMPYsKubhoJp3QJkSlmLnpGJ+pfSvNagW4mP+xxcpQ zGCTW+H7jdZcK49VlJX8jRIyOMT8JMgE/PLswNDW1Ir7scT08UJyBaPZccu1617VfMuV uw== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V1 32/32] vfio-pci: improved tracing Date: Thu, 30 Jul 2020 08:14:36 -0700 Message-Id: <1596122076-341293-33-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> References: <1596122076-341293-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 suspectscore=1 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9698 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 clxscore=1015 mlxscore=0 impostorscore=0 phishscore=0 adultscore=0 suspectscore=1 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007300111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=141.146.126.78; envelope-from=steven.sistare@oracle.com; helo=aserp2120.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/30 11:37:57 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -63 X-Spam_score: -6.4 X-Spam_bar: ------ X-Spam_report: (-6.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Print more info for existing trace points: trace_kvm_irqchip_add_msi_route. trace_pci_update_mappings_del trace_pci_update_mappings_add Add new trace points: trace_kvm_irqchip_assign_irqfd trace_msix_table_mmio_write trace_vfio_dma_unmap trace_vfio_dma_map trace_vfio_region trace_vfio_descriptors trace_ram_block_add Signed-off-by: Steve Sistare --- accel/kvm/kvm-all.c | 8 ++++++-- accel/kvm/trace-events | 3 ++- exec.c | 3 +++ hw/pci/msix.c | 1 + hw/pci/pci.c | 10 ++++++---- hw/pci/trace-events | 5 +++-- hw/vfio/common.c | 16 +++++++++++++++- hw/vfio/pci.c | 1 + hw/vfio/trace-events | 9 ++++++--- trace-events | 2 ++ 10 files changed, 45 insertions(+), 13 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 63ef6af..5511ea7 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -46,6 +46,7 @@ #include "sysemu/reset.h" =20 #include "hw/boards.h" +#include "trace-root.h" =20 /* This check must be after config-host.h is included */ #ifdef CONFIG_EVENTFD @@ -1670,7 +1671,7 @@ int kvm_irqchip_add_msi_route(KVMState *s, int vector= , PCIDevice *dev) } =20 trace_kvm_irqchip_add_msi_route(dev ? dev->name : (char *)"N/A", - vector, virq); + vector, virq, msg.address, msg.data); =20 kvm_add_routing_entry(s, &kroute); kvm_arch_add_msi_route_post(&kroute, vector, dev); @@ -1717,6 +1718,7 @@ static int kvm_irqchip_assign_irqfd(KVMState *s, Even= tNotifier *event, { int fd =3D event_notifier_get_fd(event); int rfd =3D resample ? event_notifier_get_fd(resample) : -1; + int ret; =20 struct kvm_irqfd irqfd =3D { .fd =3D fd, @@ -1758,7 +1760,9 @@ static int kvm_irqchip_assign_irqfd(KVMState *s, Even= tNotifier *event, return -ENOSYS; } =20 - return kvm_vm_ioctl(s, KVM_IRQFD, &irqfd); + ret =3D kvm_vm_ioctl(s, KVM_IRQFD, &irqfd); + trace_kvm_irqchip_assign_irqfd(fd, virq, rfd, ret); + return ret; } =20 int kvm_irqchip_add_adapter_route(KVMState *s, AdapterInfo *adapter) diff --git a/accel/kvm/trace-events b/accel/kvm/trace-events index a68eb66..67a01e6 100644 --- a/accel/kvm/trace-events +++ b/accel/kvm/trace-events @@ -9,7 +9,8 @@ kvm_device_ioctl(int fd, int type, void *arg) "dev fd %d, t= ype 0x%x, arg %p" kvm_failed_reg_get(uint64_t id, const char *msg) "Warning: Unable to retri= eve ONEREG %" PRIu64 " from KVM: %s" kvm_failed_reg_set(uint64_t id, const char *msg) "Warning: Unable to set O= NEREG %" PRIu64 " to KVM: %s" kvm_irqchip_commit_routes(void) "" -kvm_irqchip_add_msi_route(char *name, int vector, int virq) "dev %s vector= %d virq %d" +kvm_irqchip_add_msi_route(char *name, int vector, int virq, uint64_t addr,= uint32_t data) "%s, vector %d, virq %d, msg {addr 0x%"PRIx64", data 0x%x}" +kvm_irqchip_assign_irqfd(int fd, int virq, int rfd, int status) "(fd=3D%d,= virq=3D%d, rfd=3D%d) KVM_IRQFD returns %d" kvm_irqchip_update_msi_route(int virq) "Updating MSI route virq=3D%d" kvm_irqchip_release_virq(int virq) "virq %d" kvm_set_ioeventfd_mmio(int fd, uint64_t addr, uint32_t val, bool assign, u= int32_t size, bool datamatch) "fd: %d @0x%" PRIx64 " val=3D0x%x assign: %d = size: %d match: %d" diff --git a/exec.c b/exec.c index 5473c09..dd99ee0 100644 --- a/exec.c +++ b/exec.c @@ -2319,6 +2319,9 @@ static void ram_block_add(RAMBlock *new_block, Error = **errp, bool shared) } ram_block_notify_add(new_block->host, new_block->max_length); } + trace_ram_block_add(new_block->host, new_block->max_length, + memory_region_name(new_block->mr), + new_block->mr->readonly ? "ro" : "rw"); } =20 #ifdef CONFIG_POSIX diff --git a/hw/pci/msix.c b/hw/pci/msix.c index 67e34f3..65a2882 100644 --- a/hw/pci/msix.c +++ b/hw/pci/msix.c @@ -189,6 +189,7 @@ static void msix_table_mmio_write(void *opaque, hwaddr = addr, int vector =3D addr / PCI_MSIX_ENTRY_SIZE; bool was_masked; =20 + trace_msix_table_mmio_write(dev->name, addr, val, size); was_masked =3D msix_is_masked(dev, vector); pci_set_long(dev->msix_table + addr, val); msix_handle_mask_update(dev, vector, was_masked); diff --git a/hw/pci/pci.c b/hw/pci/pci.c index c2e1509..6142411 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1324,9 +1324,11 @@ void pci_update_mappings(PCIDevice *d) PCIIORegion *r; int i; pcibus_t new_addr; + const char *name; =20 for(i =3D 0; i < PCI_NUM_REGIONS; i++) { r =3D &d->io_regions[i]; + name =3D r->memory ? r->memory->name : ""; =20 /* this region isn't registered */ if (!r->size) @@ -1340,18 +1342,18 @@ void pci_update_mappings(PCIDevice *d) =20 /* now do the real mapping */ if (r->addr !=3D PCI_BAR_UNMAPPED) { - trace_pci_update_mappings_del(d, pci_dev_bus_num(d), + trace_pci_update_mappings_del(d->name, pci_dev_bus_num(d), PCI_SLOT(d->devfn), PCI_FUNC(d->devfn), - i, r->addr, r->size); + i, r->addr, r->size, name); memory_region_del_subregion(r->address_space, r->memory); } r->addr =3D new_addr; if (r->addr !=3D PCI_BAR_UNMAPPED) { - trace_pci_update_mappings_add(d, pci_dev_bus_num(d), + trace_pci_update_mappings_add(d->name, pci_dev_bus_num(d), PCI_SLOT(d->devfn), PCI_FUNC(d->devfn), - i, r->addr, r->size); + i, r->addr, r->size, name); memory_region_add_subregion_overlap(r->address_space, r->addr, r->memory, 1); } diff --git a/hw/pci/trace-events b/hw/pci/trace-events index def4b39..6dd7015 100644 --- a/hw/pci/trace-events +++ b/hw/pci/trace-events @@ -1,8 +1,8 @@ # See docs/devel/tracing.txt for syntax documentation. =20 # pci.c -pci_update_mappings_del(void *d, uint32_t bus, uint32_t slot, uint32_t fun= c, int bar, uint64_t addr, uint64_t size) "d=3D%p %02x:%02x.%x %d,0x%"PRIx6= 4"+0x%"PRIx64 -pci_update_mappings_add(void *d, uint32_t bus, uint32_t slot, uint32_t fun= c, int bar, uint64_t addr, uint64_t size) "d=3D%p %02x:%02x.%x %d,0x%"PRIx6= 4"+0x%"PRIx64 +pci_update_mappings_del(const char *dname, uint32_t bus, uint32_t slot, ui= nt32_t func, int bar, uint64_t addr, uint64_t size, const char *name) "%s %= 02x:%02x.%x [%d] 0x%"PRIx64", 0x%"PRIx64"B \"%s\"" +pci_update_mappings_add(const char *dname, uint32_t bus, uint32_t slot, ui= nt32_t func, int bar, uint64_t addr, uint64_t size, const char *name) "%s %= 02x:%02x.%x [%d] 0x%"PRIx64", 0x%"PRIx64"B \"%s\"" =20 # pci_host.c pci_cfg_read(const char *dev, unsigned devid, unsigned fnid, unsigned offs= , unsigned val) "%s %02u:%u @0x%x -> 0x%x" @@ -10,3 +10,4 @@ pci_cfg_write(const char *dev, unsigned devid, unsigned f= nid, unsigned offs, uns =20 # msix.c msix_write_config(char *name, bool enabled, bool masked) "dev %s enabled %= d masked %d" +msix_table_mmio_write(char *name, uint64_t addr, uint64_t val, unsigned si= ze) "(%s, @%"PRId64", 0x%"PRIx64", %dB)" diff --git a/hw/vfio/common.c b/hw/vfio/common.c index a51a093..23c8bf3 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -304,6 +304,8 @@ static int vfio_dma_unmap(VFIOContainer *container, return 0; } =20 + trace_vfio_dma_unmap(container->fd, iova, size); + while (ioctl(container->fd, VFIO_IOMMU_UNMAP_DMA, &unmap)) { /* * The type1 backend has an off-by-one bug in the kernel (71a7d3d7= 8e3c @@ -327,6 +329,11 @@ static int vfio_dma_unmap(VFIOContainer *container, return -errno; } =20 + if (unmap.size !=3D size) { + error_printf("warn: VFIO_UNMAP_DMA(0x%lx, 0x%lx) only unmaps 0x%ll= x", + iova, size, unmap.size); + } + return 0; } =20 @@ -345,6 +352,9 @@ static int vfio_dma_map(VFIOContainer *container, hwadd= r iova, return 0; } =20 + trace_vfio_dma_map(container->fd, iova, size, vaddr, + (readonly ? "r" : "rw")); + if (!readonly) { map.flags |=3D VFIO_DMA_MAP_FLAG_WRITE; } @@ -985,7 +995,8 @@ int vfio_region_mmap(VFIORegion *region) trace_vfio_region_mmap(memory_region_name(®ion->mmaps[i].mem), region->mmaps[i].offset, region->mmaps[i].offset + - region->mmaps[i].size - 1); + region->mmaps[i].size - 1, + region->mmaps[i].mmap); } =20 return 0; @@ -1696,6 +1707,9 @@ retry: goto retry; } =20 + trace_vfio_region(vbasedev->name, index, (*info)->offset, (*info)->siz= e, + (*info)->cap_offset, (*info)->flags); + return 0; } =20 diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index f72e277..d74e078 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -41,6 +41,7 @@ #include "trace.h" #include "qapi/error.h" #include "migration/blocker.h" +#include "trace-root.h" =20 #define TYPE_VFIO_PCI "vfio-pci" #define PCI_VFIO(obj) OBJECT_CHECK(VFIOPCIDevice, obj, TYPE_VFIO_PCI) diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 10d899c..83cd0a6 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -25,7 +25,7 @@ vfio_pci_size_rom(const char *name, int size) "%s ROM siz= e 0x%x" vfio_vga_write(uint64_t addr, uint64_t data, int size) " (0x%"PRIx64", 0x%= "PRIx64", %d)" vfio_vga_read(uint64_t addr, int size, uint64_t data) " (0x%"PRIx64", %d) = =3D 0x%"PRIx64 vfio_pci_read_config(const char *name, int addr, int len, int val) " (%s, = @0x%x, len=3D0x%x) 0x%x" -vfio_pci_write_config(const char *name, int addr, int val, int len) " (%s,= @0x%x, 0x%x, len=3D0x%x)" +vfio_pci_write_config(const char *name, int addr, int val, int len) "(%s, = @0x%x, 0x%x, 0x%xB)" vfio_msi_setup(const char *name, int pos) "%s PCI MSI CAP @0x%x" vfio_msix_early_setup(const char *name, int pos, int table_bar, int offset= , int entries) "%s PCI MSI-X CAP @0x%x, BAR %d, offset 0x%x, entries %d" vfio_check_pcie_flr(const char *name) "%s Supports FLR via PCIe cap" @@ -37,7 +37,7 @@ vfio_pci_hot_reset_dep_devices(int domain, int bus, int s= lot, int function, int vfio_pci_hot_reset_result(const char *name, const char *result) "%s hot re= set: %s" vfio_populate_device_config(const char *name, unsigned long size, unsigned= long offset, unsigned long flags) "Device %s config:\n size: 0x%lx, offse= t: 0x%lx, flags: 0x%lx" vfio_populate_device_get_irq_info_failure(const char *errstr) "VFIO_DEVICE= _GET_IRQ_INFO failure: %s" -vfio_realize(const char *name, int group_id) " (%s) group %d" +vfio_realize(const char *name, int group_id) "(%s) group %d" vfio_mdev(const char *name, bool is_mdev) " (%s) is_mdev %d" vfio_add_ext_cap_dropped(const char *name, uint16_t cap, uint16_t offset) = "%s 0x%x@0x%x" vfio_pci_reset(const char *name) " (%s)" @@ -109,7 +109,7 @@ vfio_get_device(const char * name, unsigned int flags, = unsigned int num_regions, vfio_put_base_device(int fd) "close vdev->fd=3D%d" vfio_region_setup(const char *dev, int index, const char *name, unsigned l= ong flags, unsigned long offset, unsigned long size) "Device %s, region %d = \"%s\", flags: 0x%lx, offset: 0x%lx, size: 0x%lx" vfio_region_mmap_fault(const char *name, int index, unsigned long offset, = unsigned long size, int fault) "Region %s mmaps[%d], [0x%lx - 0x%lx], fault= : %d" -vfio_region_mmap(const char *name, unsigned long offset, unsigned long end= ) "Region %s [0x%lx - 0x%lx]" +vfio_region_mmap(const char *name, unsigned long offset, unsigned long end= , void *addr) "%s [0x%lx - 0x%lx] maps to %p" vfio_region_exit(const char *name, int index) "Device %s, region %d" vfio_region_finalize(const char *name, int index) "Device %s, region %d" vfio_region_mmaps_set_enabled(const char *name, bool enabled) "Region %s m= maps enabled: %d" @@ -117,6 +117,9 @@ vfio_region_sparse_mmap_header(const char *name, int in= dex, int nr_areas) "Devic vfio_region_sparse_mmap_entry(int i, unsigned long start, unsigned long en= d) "sparse entry %d [0x%lx - 0x%lx]" vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t s= ubtype) "%s index %d, %08x/%0x8" vfio_dma_unmap_overflow_workaround(void) "" +vfio_dma_unmap(int fd, uint64_t iova, uint64_t size) "fd %d, iova 0x%"PRIx= 64", len 0x%"PRIx64 +vfio_dma_map(int fd, uint64_t iova, uint64_t size, void *addr, const char = *access) "fd %d, iova 0x%"PRIx64", len 0x%"PRIx64", va %p, %s" +vfio_region(const char *name, int index, uint64_t offset, uint64_t size, i= nt cap_offset, int flags) "%s [%d]: +0x%"PRIx64", 0x%"PRIx64"B, cap +0x%x, = flags 0x%x" =20 # platform.c vfio_platform_base_device_init(char *name, int groupid) "%s belongs to gro= up #%d" diff --git a/trace-events b/trace-events index 42107eb..98589a4 100644 --- a/trace-events +++ b/trace-events @@ -107,6 +107,8 @@ qmp_job_complete(void *job) "job %p" qmp_job_finalize(void *job) "job %p" qmp_job_dismiss(void *job) "job %p" =20 +# exec.c +ram_block_add(void *host, uint64_t maxlen, const char *name, const char *m= ode) "host=3D%p, maxlen=3D0x%"PRIx64", mr =3D {name=3D%s, %s}" =20 ### Guest events, keep at bottom =20 --=20 1.8.3.1