From nobody Thu Dec 26 13:02:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1707418554; cv=none; d=zohomail.com; s=zohoarc; b=EjWRAqHSz1hSFVpvx4wnuzi9qxo73wTYJSkvvaYV4fHzDnmrrWSJpIU66ETMjvFO+v02Aisc9JaP7vW7NSRfVS9766QFZfBK9o3LhAI7ZATMugeJS9roRf68ibTP6/4u2gQ5lmWhiXf70R05n6zjJ+ESk/lz5QNoCn00mzk0NYA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707418554; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=01qgn5wow+x15Aw11bvu61/gEclzEp7mkjETYFlCgaI=; b=CzgypAh0S/7b9ynjjt4uzxq3t3qY4AwVTNjIsq8vnujCamvV2z7IiAbwk4CIK1FjboBkEyEu18kTPNLHUvzhNROZHK/GV+VstaN1ygxbMq0O4XLXxc2EQg8hjkU/aXVUwE/n1mnvaSY8fmDUCrR6kBOPW8s5phao+snaGgHOVg4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707418554375760.1887538146036; Thu, 8 Feb 2024 10:55:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rY9XU-0001Y3-BI; Thu, 08 Feb 2024 13:54:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9XP-0001R4-9T for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:20 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9XN-0005nC-3r for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:18 -0500 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 418IjqxG001625; Thu, 8 Feb 2024 18:54:12 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3w1e1vdgut-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:11 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 418IkLW5038437; Thu, 8 Feb 2024 18:54:10 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3w1bxawn0h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:10 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 418Iq35x013534; Thu, 8 Feb 2024 18:54:09 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3w1bxawmw9-2; Thu, 08 Feb 2024 18:54:09 +0000 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-2023-11-20; bh=01qgn5wow+x15Aw11bvu61/gEclzEp7mkjETYFlCgaI=; b=Wcz2uL44Qq149UHAZvq3MdJWnasJqmaV3JAWw2An1XYmS8all0wFr49oUtocI8fT5wiY gN5FGU62bpFr1/CyGxUjHFyp1STZeM7OKQKO5iWhpqL3FIyepugkRxHkHgh+DGI2YJr1 v1qKUolxUQj+BQukY10AaPgFna246yMPUbVOMg2aFy9/BmW79w+7zAQwJU6LjslHDKTR a/nx5APVoxH+oYrHt5v36NzX8qDQajZjMqwfpaF2qeNl0dXqwoHUmhBeBVN6a9zaXD1t yBmeUwJjzfD4Z4OuY3UXR8Ds2YE+DKKmmzw745JJlQVpJl+wJHImQ5YNoArneCTupC18 IA== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , "Michael S. Tsirkin" , Jason Wang , Alex Williamson , Cedric Le Goater , Gerd Hoffmann , Marc-Andre Lureau , David Hildenbrand , Steve Sistare Subject: [PATCH V3 01/13] notify: pass error to notifier with return Date: Thu, 8 Feb 2024 10:53:54 -0800 Message-Id: <1707418446-134863-2-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> References: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-08_08,2024-02-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402080099 X-Proofpoint-GUID: FA1TZ3xpyaALqaT1nauBvjm1TdDIdopY X-Proofpoint-ORIG-GUID: FA1TZ3xpyaALqaT1nauBvjm1TdDIdopY 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=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1707418556567100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Pass an error object as the third parameter to "notifier with return" notifiers, so clients no longer need to bundle an error object in the opaque data. The new parameter is used in a later patch. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu Reviewed-by: David Hildenbrand --- hw/virtio/vhost-user.c | 2 +- hw/virtio/virtio-balloon.c | 3 ++- include/qemu/notify.h | 7 +++++-- migration/postcopy-ram.c | 2 +- migration/ram.c | 2 +- util/notify.c | 5 +++-- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index f214df8..f502345 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -2084,7 +2084,7 @@ static int vhost_user_postcopy_end(struct vhost_dev *= dev, Error **errp) } =20 static int vhost_user_postcopy_notifier(NotifierWithReturn *notifier, - void *opaque) + void *opaque, Error **errp) { struct PostcopyNotifyData *pnd =3D opaque; struct vhost_user *u =3D container_of(notifier, struct vhost_user, diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 486fe3d..89f853f 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -633,7 +633,8 @@ static void virtio_balloon_free_page_done(VirtIOBalloon= *s) } =20 static int -virtio_balloon_free_page_hint_notify(NotifierWithReturn *n, void *data) +virtio_balloon_free_page_hint_notify(NotifierWithReturn *n, void *data, + Error **errp) { VirtIOBalloon *dev =3D container_of(n, VirtIOBalloon, free_page_hint_n= otify); VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); diff --git a/include/qemu/notify.h b/include/qemu/notify.h index bcfa70f..9a85631 100644 --- a/include/qemu/notify.h +++ b/include/qemu/notify.h @@ -45,12 +45,15 @@ bool notifier_list_empty(NotifierList *list); /* Same as Notifier but allows .notify() to return errors */ typedef struct NotifierWithReturn NotifierWithReturn; =20 +typedef int (*NotifierWithReturnFunc)(NotifierWithReturn *notifier, void *= data, + Error **errp); + struct NotifierWithReturn { /** * Return 0 on success (next notifier will be invoked), otherwise * notifier_with_return_list_notify() will stop and return the value. */ - int (*notify)(NotifierWithReturn *notifier, void *data); + NotifierWithReturnFunc notify; QLIST_ENTRY(NotifierWithReturn) node; }; =20 @@ -69,6 +72,6 @@ void notifier_with_return_list_add(NotifierWithReturnList= *list, void notifier_with_return_remove(NotifierWithReturn *notifier); =20 int notifier_with_return_list_notify(NotifierWithReturnList *list, - void *data); + void *data, Error **errp); =20 #endif diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 893ec8f..3ab2f6b 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -80,7 +80,7 @@ int postcopy_notify(enum PostcopyNotifyReason reason, Err= or **errp) pnd.errp =3D errp; =20 return notifier_with_return_list_notify(&postcopy_notifier_list, - &pnd); + &pnd, errp); } =20 /* diff --git a/migration/ram.c b/migration/ram.c index d5b7cd5..ed9241a 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -428,7 +428,7 @@ int precopy_notify(PrecopyNotifyReason reason, Error **= errp) pnd.reason =3D reason; pnd.errp =3D errp; =20 - return notifier_with_return_list_notify(&precopy_notifier_list, &pnd); + return notifier_with_return_list_notify(&precopy_notifier_list, &pnd, = errp); } =20 uint64_t ram_bytes_remaining(void) diff --git a/util/notify.c b/util/notify.c index 76bab21..c6e158f 100644 --- a/util/notify.c +++ b/util/notify.c @@ -61,13 +61,14 @@ void notifier_with_return_remove(NotifierWithReturn *no= tifier) QLIST_REMOVE(notifier, node); } =20 -int notifier_with_return_list_notify(NotifierWithReturnList *list, void *d= ata) +int notifier_with_return_list_notify(NotifierWithReturnList *list, void *d= ata, + Error **errp) { NotifierWithReturn *notifier, *next; int ret =3D 0; =20 QLIST_FOREACH_SAFE(notifier, &list->notifiers, node, next) { - ret =3D notifier->notify(notifier, data); + ret =3D notifier->notify(notifier, data, errp); if (ret !=3D 0) { break; } --=20 1.8.3.1 From nobody Thu Dec 26 13:02:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1707418496; cv=none; d=zohomail.com; s=zohoarc; b=F/MoXY+Uva26lLW2OI5HKuHGB28Nw0E9tiVtFhgz/YprTm0oPzqIAGq4IkISMbCNJjjxvyjuyf/k/l6rQ+o7MdBr+rWSlYutuKIutp6QA4GQIJQpfeSFeH5+SSW3d9dHs1tJiJMAcayLHohmw8/kS++XhE43MzrFkpf2qcURIiM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707418496; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FcJTiqsgF1X2wz8iNV5OhBrAgSn2FRO2IaN6FRWM09g=; b=MaSzBPp0QQ5W4x4Aa+VZJVuZay7VVd+EbxcIX4A5KZT2tw2vD1gApO1T9ARR4dsHa5PtX7m40rScagxtFUhYd/2TTZjO+8utRf/cLySBT5W+GFuTfU/ldZ3kiG+TIdV3EV/8vunu0vkNf3T+XW0w9Jdnj6zosOlOB7JQCzCEt4E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707418496182526.426073898234; Thu, 8 Feb 2024 10:54:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rY9XS-0001X6-Qr; Thu, 08 Feb 2024 13:54:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9XN-0001Qc-Bs for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:17 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9XK-0005nG-Js for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:16 -0500 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 418Ik2Ah031385; Thu, 8 Feb 2024 18:54:13 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3w1dcbne61-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:13 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 418ID0pt038393; Thu, 8 Feb 2024 18:54:11 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3w1bxawn1c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:11 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 418Iq361013534; Thu, 8 Feb 2024 18:54:11 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3w1bxawmw9-3; Thu, 08 Feb 2024 18:54:11 +0000 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-2023-11-20; bh=FcJTiqsgF1X2wz8iNV5OhBrAgSn2FRO2IaN6FRWM09g=; b=Mw93NN3LmFCl1vByrmnm9bjLTdAObxihe6RmE8NAeGXHihRGHzPDlBOrfCvwQ4EtH+ZQ AfqSzciqeFHfmgqaoEBzhRcS3C19feNFK9od/nFjgBVDHRT67cUETVZKJiPBBTn9Nf6T J3GjtXaPbzJmuggzQq9aQFC2aRxD8f6+EWq5Jvgeq90wdw32zqGr1gWO0g8jgvTB+B60 dKHuwyZS4z7MvYer4nshr5/5z5YFxNmPzfkMshACAWBFxsdk9KhIbNi/OV61rqMJEkXP frIa+bL9570Kcr28kxtAf0j1KqM8rn2k1UfpIxe2dPRzc/KbqET17p2JvpLOWFhPg8uo dg== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , "Michael S. Tsirkin" , Jason Wang , Alex Williamson , Cedric Le Goater , Gerd Hoffmann , Marc-Andre Lureau , David Hildenbrand , Steve Sistare Subject: [PATCH V3 02/13] migration: remove error from notifier data Date: Thu, 8 Feb 2024 10:53:55 -0800 Message-Id: <1707418446-134863-3-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> References: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-08_08,2024-02-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402080099 X-Proofpoint-GUID: 4hHglG1xEQTyfiqm79SLH31w-6TAAMd7 X-Proofpoint-ORIG-GUID: 4hHglG1xEQTyfiqm79SLH31w-6TAAMd7 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=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1707418498342100005 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Remove the error object from opaque data passed to notifiers. Use the new error parameter passed to the notifier instead. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu Reviewed-by: David Hildenbrand --- hw/virtio/vhost-user.c | 8 ++++---- include/migration/misc.h | 1 - migration/postcopy-ram.c | 1 - migration/postcopy-ram.h | 1 - migration/ram.c | 1 - 5 files changed, 4 insertions(+), 8 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index f502345..a1eea85 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -2096,20 +2096,20 @@ static int vhost_user_postcopy_notifier(NotifierWit= hReturn *notifier, if (!virtio_has_feature(dev->protocol_features, VHOST_USER_PROTOCOL_F_PAGEFAULT)) { /* TODO: Get the device name into this error somehow */ - error_setg(pnd->errp, + error_setg(errp, "vhost-user backend not capable of postcopy"); return -ENOENT; } break; =20 case POSTCOPY_NOTIFY_INBOUND_ADVISE: - return vhost_user_postcopy_advise(dev, pnd->errp); + return vhost_user_postcopy_advise(dev, errp); =20 case POSTCOPY_NOTIFY_INBOUND_LISTEN: - return vhost_user_postcopy_listen(dev, pnd->errp); + return vhost_user_postcopy_listen(dev, errp); =20 case POSTCOPY_NOTIFY_INBOUND_END: - return vhost_user_postcopy_end(dev, pnd->errp); + return vhost_user_postcopy_end(dev, errp); =20 default: /* We ignore notifications we don't know */ diff --git a/include/migration/misc.h b/include/migration/misc.h index 1bc8902..5e65c18 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -31,7 +31,6 @@ typedef enum PrecopyNotifyReason { =20 typedef struct PrecopyNotifyData { enum PrecopyNotifyReason reason; - Error **errp; } PrecopyNotifyData; =20 void precopy_infrastructure_init(void); diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 3ab2f6b..0273dc6 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -77,7 +77,6 @@ int postcopy_notify(enum PostcopyNotifyReason reason, Err= or **errp) { struct PostcopyNotifyData pnd; pnd.reason =3D reason; - pnd.errp =3D errp; =20 return notifier_with_return_list_notify(&postcopy_notifier_list, &pnd, errp); diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h index 442ab89..ecae941 100644 --- a/migration/postcopy-ram.h +++ b/migration/postcopy-ram.h @@ -128,7 +128,6 @@ enum PostcopyNotifyReason { =20 struct PostcopyNotifyData { enum PostcopyNotifyReason reason; - Error **errp; }; =20 void postcopy_add_notifier(NotifierWithReturn *nn); diff --git a/migration/ram.c b/migration/ram.c index ed9241a..fe90024 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -426,7 +426,6 @@ int precopy_notify(PrecopyNotifyReason reason, Error **= errp) { PrecopyNotifyData pnd; pnd.reason =3D reason; - pnd.errp =3D errp; =20 return notifier_with_return_list_notify(&precopy_notifier_list, &pnd, = errp); } --=20 1.8.3.1 From nobody Thu Dec 26 13:02:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1707418512; cv=none; d=zohomail.com; s=zohoarc; b=lG6a+vRMKWUHkHxi6FCEcbuYnHg9V+IOuCYZIroy/yJHLGsmxR5k7tAuIH7OplS+68EvtqoE9xnSSUOr0MK5xAoi8hYAgMpGrDtSJkWVvOR9Uwtfe3wBKaq5RwxNJ9GWxu+QeRGKqpxF68bgZ7Bz7pbwG/MUYY0GQ12Ab5nb7Gg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707418512; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=POdEXdybKvkA5L3DGpp+fBIHJi0QSPFZixwJzkY7dms=; b=gXv+l9gQG3je33zceMZa1c0IJHBhl0yT0hHhJGx/w/bGux3Pdbs25MFXoidf87gUO0Q03h7SFq1Q3z/uEJNzrDeqlD62+E2ddjI05wrw+PnDTaJrFZimA+Dy/9vp6+412eNCJ0cl95eYSEYRONQqDmi7UVuMuYxyrjJKdmypxn0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707418512146502.17029543231297; Thu, 8 Feb 2024 10:55:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rY9XW-0001YM-MH; Thu, 08 Feb 2024 13:54:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9XQ-0001U0-Fv for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:20 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9XN-0005nL-BS for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:20 -0500 Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 418Ijvk9015644; Thu, 8 Feb 2024 18:54:15 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3w1cdd5mpb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:14 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 418HcCWv038677; Thu, 8 Feb 2024 18:54:13 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3w1bxawn2a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:13 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 418Iq363013534; Thu, 8 Feb 2024 18:54:12 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3w1bxawmw9-4; Thu, 08 Feb 2024 18:54:12 +0000 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-2023-11-20; bh=POdEXdybKvkA5L3DGpp+fBIHJi0QSPFZixwJzkY7dms=; b=kWebYL8ChPtueUTIeMXgS1x4nWb9S4uxWkvW6KAXqJs0iw6D9nqK0fDcoLV4fI/mGPAn zlLzonarcHy6q4frZttcD0OF2tczHHJlazNG93ya0CdCRzwUbRDrVeuM3SCZZfeYQYIl /ZYD+klqHOdyYdI7OeOy3hhpWOEON2NLu22FR8nJTWJOkNnGQzvUXTMyh0AhwCiYnCpP O9FpuoWecbAeKBxxI+8ZyTesfkNfibwPGWHa3goxpYHb8zYp0J+Ocd+zKS5+slag2kuJ +IIyoV/oADqNfUB+9aT1EzG3d1SU1MuijbTXyURLkEkIUZt0OSD1MdDVXrA856FXn58Z 2g== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , "Michael S. Tsirkin" , Jason Wang , Alex Williamson , Cedric Le Goater , Gerd Hoffmann , Marc-Andre Lureau , David Hildenbrand , Steve Sistare Subject: [PATCH V3 03/13] migration: convert to NotifierWithReturn Date: Thu, 8 Feb 2024 10:53:56 -0800 Message-Id: <1707418446-134863-4-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> References: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-08_08,2024-02-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402080099 X-Proofpoint-GUID: J_ara4h-pEvXhu1Fo9r_ApjEGFK1-Nhp X-Proofpoint-ORIG-GUID: J_ara4h-pEvXhu1Fo9r_ApjEGFK1-Nhp 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=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1707418512479100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Change all migration notifiers to type NotifierWithReturn, so notifiers can return an error status in a future patch. For now, pass NULL for the notifier error parameter, and do not check the return value. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu Reviewed-by: David Hildenbrand --- hw/net/virtio-net.c | 4 +++- hw/vfio/migration.c | 4 +++- include/hw/vfio/vfio-common.h | 2 +- include/hw/virtio/virtio-net.h | 2 +- include/migration/misc.h | 6 +++--- include/qemu/notify.h | 1 + migration/migration.c | 16 ++++++++-------- net/vhost-vdpa.c | 6 ++++-- ui/spice-core.c | 8 +++++--- 9 files changed, 29 insertions(+), 20 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 5a79bc3..75f4e86 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3534,11 +3534,13 @@ static void virtio_net_handle_migration_primary(Vir= tIONet *n, MigrationState *s) } } =20 -static void virtio_net_migration_state_notifier(Notifier *notifier, void *= data) +static int virtio_net_migration_state_notifier(NotifierWithReturn *notifie= r, + void *data, Error **errp) { MigrationState *s =3D data; VirtIONet *n =3D container_of(notifier, VirtIONet, migration_state); virtio_net_handle_migration_primary(n, s); + return 0; } =20 static bool failover_hide_primary_device(DeviceListener *listener, diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 70e6b1a..6b6acc4 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -754,7 +754,8 @@ static void vfio_vmstate_change(void *opaque, bool runn= ing, RunState state) mig_state_to_str(new_state)); } =20 -static void vfio_migration_state_notifier(Notifier *notifier, void *data) +static int vfio_migration_state_notifier(NotifierWithReturn *notifier, + void *data, Error **errp) { MigrationState *s =3D data; VFIOMigration *migration =3D container_of(notifier, VFIOMigration, @@ -770,6 +771,7 @@ static void vfio_migration_state_notifier(Notifier *not= ifier, void *data) case MIGRATION_STATUS_FAILED: vfio_migration_set_state_or_reset(vbasedev, VFIO_DEVICE_STATE_RUNN= ING); } + return 0; } =20 static void vfio_migration_free(VFIODevice *vbasedev) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 9b7ef7d..4a6c262 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -62,7 +62,7 @@ typedef struct VFIORegion { typedef struct VFIOMigration { struct VFIODevice *vbasedev; VMChangeStateEntry *vm_state; - Notifier migration_state; + NotifierWithReturn migration_state; uint32_t device_state; int data_fd; void *data_buffer; diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 55977f0..eaee8f4 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -221,7 +221,7 @@ struct VirtIONet { DeviceListener primary_listener; QDict *primary_opts; bool primary_opts_from_json; - Notifier migration_state; + NotifierWithReturn migration_state; VirtioNetRssData rss_data; struct NetRxPkt *rx_pkt; struct EBPFRSSContext ebpf_rss; diff --git a/include/migration/misc.h b/include/migration/misc.h index 5e65c18..b62e351 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -60,9 +60,9 @@ void migration_object_init(void); void migration_shutdown(void); bool migration_is_idle(void); bool migration_is_active(MigrationState *); -void migration_add_notifier(Notifier *notify, - void (*func)(Notifier *notifier, void *data)); -void migration_remove_notifier(Notifier *notify); +void migration_add_notifier(NotifierWithReturn *notify, + NotifierWithReturnFunc func); +void migration_remove_notifier(NotifierWithReturn *notify); void migration_call_notifiers(MigrationState *s); bool migration_in_setup(MigrationState *); bool migration_has_finished(MigrationState *); diff --git a/include/qemu/notify.h b/include/qemu/notify.h index 9a85631..abf18db 100644 --- a/include/qemu/notify.h +++ b/include/qemu/notify.h @@ -45,6 +45,7 @@ bool notifier_list_empty(NotifierList *list); /* Same as Notifier but allows .notify() to return errors */ typedef struct NotifierWithReturn NotifierWithReturn; =20 +/* Return int to allow for different failure modes and recovery actions */ typedef int (*NotifierWithReturnFunc)(NotifierWithReturn *notifier, void *= data, Error **errp); =20 diff --git a/migration/migration.c b/migration/migration.c index d5f705c..ff9945b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -68,8 +68,8 @@ #include "sysemu/dirtylimit.h" #include "qemu/sockets.h" =20 -static NotifierList migration_state_notifiers =3D - NOTIFIER_LIST_INITIALIZER(migration_state_notifiers); +static NotifierWithReturnList migration_state_notifiers =3D + NOTIFIER_WITH_RETURN_LIST_INITIALIZER(migration_state_notifiers); =20 /* Messages sent on the return path from destination to source */ enum mig_rp_message_type { @@ -1453,24 +1453,24 @@ static void migrate_fd_cancel(MigrationState *s) } } =20 -void migration_add_notifier(Notifier *notify, - void (*func)(Notifier *notifier, void *data)) +void migration_add_notifier(NotifierWithReturn *notify, + NotifierWithReturnFunc func) { notify->notify =3D func; - notifier_list_add(&migration_state_notifiers, notify); + notifier_with_return_list_add(&migration_state_notifiers, notify); } =20 -void migration_remove_notifier(Notifier *notify) +void migration_remove_notifier(NotifierWithReturn *notify) { if (notify->notify) { - notifier_remove(notify); + notifier_with_return_remove(notify); notify->notify =3D NULL; } } =20 void migration_call_notifiers(MigrationState *s) { - notifier_list_notify(&migration_state_notifiers, s); + notifier_with_return_list_notify(&migration_state_notifiers, s, 0); } =20 bool migration_in_setup(MigrationState *s) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 3726ee5..1c00519 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -34,7 +34,7 @@ typedef struct VhostVDPAState { NetClientState nc; struct vhost_vdpa vhost_vdpa; - Notifier migration_state; + NotifierWithReturn migration_state; VHostNetState *vhost_net; =20 /* Control commands shadow buffers */ @@ -322,7 +322,8 @@ static void vhost_vdpa_net_log_global_enable(VhostVDPAS= tate *s, bool enable) } } =20 -static void vdpa_net_migration_state_notifier(Notifier *notifier, void *da= ta) +static int vdpa_net_migration_state_notifier(NotifierWithReturn *notifier, + void *data, Error **errp) { MigrationState *migration =3D data; VhostVDPAState *s =3D container_of(notifier, VhostVDPAState, @@ -333,6 +334,7 @@ static void vdpa_net_migration_state_notifier(Notifier = *notifier, void *data) } else if (migration_has_failed(migration)) { vhost_vdpa_net_log_global_enable(s, false); } + return 0; } =20 static void vhost_vdpa_net_data_start_first(VhostVDPAState *s) diff --git a/ui/spice-core.c b/ui/spice-core.c index 37b277f..b3cd229 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -42,7 +42,7 @@ /* core bits */ =20 static SpiceServer *spice_server; -static Notifier migration_state; +static NotifierWithReturn migration_state; static const char *auth =3D "spice"; static char *auth_passwd; static time_t auth_expires =3D TIME_MAX; @@ -568,12 +568,13 @@ static SpiceInfo *qmp_query_spice_real(Error **errp) return info; } =20 -static void migration_state_notifier(Notifier *notifier, void *data) +static int migration_state_notifier(NotifierWithReturn *notifier, + void *data, Error **errp) { MigrationState *s =3D data; =20 if (!spice_have_target_host) { - return; + return 0; } =20 if (migration_in_setup(s)) { @@ -586,6 +587,7 @@ static void migration_state_notifier(Notifier *notifier= , void *data) spice_server_migrate_end(spice_server, false); spice_have_target_host =3D false; } + return 0; } =20 int qemu_spice_migrate_info(const char *hostname, int port, int tls_port, --=20 1.8.3.1 From nobody Thu Dec 26 13:02:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1707418591; cv=none; d=zohomail.com; s=zohoarc; b=INqVQAjtOElCbbVt3Lsp9ce3+gZDmq6i7ihIlwvSfIW9O/JU5lHF2TZnAmHM3zELWR34/Q+7OT8FX7uvlirfrYPbk7MhJYJ64PTntbjjWmUaGMtpgAlNet+S0qC25FDb+JPvO1zxqVBSrkuVu1nMbVyiYiaw+pxb+W+9LXOePFI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707418591; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+52dW+iSmKyY+R2k17NQNKjn67GI/mL9UJVxxR+4Mlo=; b=fGXMm5ElUGMcK9poqgPPI6ouVpbAKeJ6bR5cUgc6ppTbjo2pinsNeUscxHfT6yyOx84HL3offRcPUckzSCzBxuNBaAGs74L8gASBYYBKn4FlmDYRikdkGxQEh0y7qrtlLXpRdrG7ZRzQ1RqSizJ5E1TTBEw6NlGBUNqCxUocAh0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707418591177816.6448894407737; Thu, 8 Feb 2024 10:56:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rY9XV-0001YG-Kk; Thu, 08 Feb 2024 13:54:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9XP-0001R5-Ar for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:20 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9XN-0005nO-4M for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:19 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 418IjxQB009895; Thu, 8 Feb 2024 18:54:15 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3w1c945qad-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:15 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 418IIpBO038401; Thu, 8 Feb 2024 18:54:14 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3w1bxawn3e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:14 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 418Iq365013534; Thu, 8 Feb 2024 18:54:14 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3w1bxawmw9-5; Thu, 08 Feb 2024 18:54:13 +0000 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-2023-11-20; bh=+52dW+iSmKyY+R2k17NQNKjn67GI/mL9UJVxxR+4Mlo=; b=ISVOYzJw44RoEvGrw7LuyUvlmxTWiphCMXvK+65MOogUcVhJp6AfqAdv1t6KGbNmQa6w YAAHUpIxzjY7joEADccWFt5RcVpULdLvsFZ+gErHt/qTbBGZGcsSpMJ8VcCNZ6PjxpQ3 xERdNWug6Laz/s3aRcbG03cysAo5+esi/6YonC4V3xpCZgL7hC9wBjoz6sOH6KUyIaTR 5r4xhf0NBgggXDsjmGO9CeE5FO5B03Kv4V6ppaX7b882GF50ZpAKsmrMzcB7W/fB0wX8 peCjDo+t88DGGXiHlkqgcC6bO3F1C8aDHTCzsuX+sPCSx+U76jVMcZ8z+zxodIM886NT /Q== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , "Michael S. Tsirkin" , Jason Wang , Alex Williamson , Cedric Le Goater , Gerd Hoffmann , Marc-Andre Lureau , David Hildenbrand , Steve Sistare Subject: [PATCH V3 04/13] migration: MigrationEvent for notifiers Date: Thu, 8 Feb 2024 10:53:57 -0800 Message-Id: <1707418446-134863-5-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> References: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-08_08,2024-02-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402080099 X-Proofpoint-ORIG-GUID: wHwZqpmocRIM_mCX6j0zE4XSuHy6mx_a X-Proofpoint-GUID: wHwZqpmocRIM_mCX6j0zE4XSuHy6mx_a 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=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1707418592738100015 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Passing MigrationState to notifiers is unsound because they could access unstable migration state internals or even modify the state. Instead, pass the minimal info needed in a new MigrationEvent struct, which could be extended in the future if needed. Suggested-by: Peter Xu Signed-off-by: Steve Sistare Reviewed-by: David Hildenbrand Reviewed-by: Peter Xu --- hw/net/virtio-net.c | 11 ++++++----- hw/vfio/migration.c | 10 +++------- hw/vfio/trace-events | 2 +- include/migration/misc.h | 14 +++++++++++++- migration/migration.c | 15 ++++++++++----- net/vhost-vdpa.c | 6 +++--- ui/spice-core.c | 9 ++++----- 7 files changed, 40 insertions(+), 27 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 75f4e86..e803f98 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3504,7 +3504,7 @@ out: return !err; } =20 -static void virtio_net_handle_migration_primary(VirtIONet *n, MigrationSta= te *s) +static void virtio_net_handle_migration_primary(VirtIONet *n, MigrationEve= nt *e) { bool should_be_hidden; Error *err =3D NULL; @@ -3516,7 +3516,7 @@ static void virtio_net_handle_migration_primary(VirtI= ONet *n, MigrationState *s) =20 should_be_hidden =3D qatomic_read(&n->failover_primary_hidden); =20 - if (migration_in_setup(s) && !should_be_hidden) { + if (e->type =3D=3D MIG_EVENT_PRECOPY_SETUP && !should_be_hidden) { if (failover_unplug_primary(n, dev)) { vmstate_unregister(VMSTATE_IF(dev), qdev_get_vmsd(dev), dev); qapi_event_send_unplug_primary(dev->id); @@ -3524,7 +3524,7 @@ static void virtio_net_handle_migration_primary(VirtI= ONet *n, MigrationState *s) } else { warn_report("couldn't unplug primary device"); } - } else if (migration_has_failed(s)) { + } else if (e->type =3D=3D MIG_EVENT_PRECOPY_FAILED) { /* We already unplugged the device let's plug it back */ if (!failover_replug_primary(n, dev, &err)) { if (err) { @@ -3537,9 +3537,10 @@ static void virtio_net_handle_migration_primary(Virt= IONet *n, MigrationState *s) static int virtio_net_migration_state_notifier(NotifierWithReturn *notifie= r, void *data, Error **errp) { - MigrationState *s =3D data; + MigrationEvent *e =3D data; + VirtIONet *n =3D container_of(notifier, VirtIONet, migration_state); - virtio_net_handle_migration_primary(n, s); + virtio_net_handle_migration_primary(n, e); return 0; } =20 diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 6b6acc4..869d841 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -757,18 +757,14 @@ static void vfio_vmstate_change(void *opaque, bool ru= nning, RunState state) static int vfio_migration_state_notifier(NotifierWithReturn *notifier, void *data, Error **errp) { - MigrationState *s =3D data; + MigrationEvent *e =3D data; VFIOMigration *migration =3D container_of(notifier, VFIOMigration, migration_state); VFIODevice *vbasedev =3D migration->vbasedev; =20 - trace_vfio_migration_state_notifier(vbasedev->name, - MigrationStatus_str(s->state)); + trace_vfio_migration_state_notifier(vbasedev->name, e->type); =20 - switch (s->state) { - case MIGRATION_STATUS_CANCELLING: - case MIGRATION_STATUS_CANCELLED: - case MIGRATION_STATUS_FAILED: + if (e->type =3D=3D MIG_EVENT_PRECOPY_FAILED) { vfio_migration_set_state_or_reset(vbasedev, VFIO_DEVICE_STATE_RUNN= ING); } return 0; diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 8fdde54..f0474b2 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -153,7 +153,7 @@ vfio_load_state(const char *name, uint64_t data) " (%s)= data 0x%"PRIx64 vfio_load_state_device_data(const char *name, uint64_t data_size, int ret)= " (%s) size 0x%"PRIx64" ret %d" vfio_migration_realize(const char *name) " (%s)" vfio_migration_set_state(const char *name, const char *state) " (%s) state= %s" -vfio_migration_state_notifier(const char *name, const char *state) " (%s) = state %s" +vfio_migration_state_notifier(const char *name, int state) " (%s) state %d" vfio_save_block(const char *name, int data_size) " (%s) data_size %d" vfio_save_cleanup(const char *name) " (%s)" vfio_save_complete_precopy(const char *name, int ret) " (%s) ret %d" diff --git a/include/migration/misc.h b/include/migration/misc.h index b62e351..ff8cc57 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -60,10 +60,22 @@ void migration_object_init(void); void migration_shutdown(void); bool migration_is_idle(void); bool migration_is_active(MigrationState *); + +typedef enum MigrationEventType { + MIG_EVENT_PRECOPY_SETUP, + MIG_EVENT_PRECOPY_DONE, + MIG_EVENT_PRECOPY_FAILED, + MIG_EVENT_MAX +} MigrationEventType; + +typedef struct MigrationEvent { + MigrationEventType type; +} MigrationEvent; + void migration_add_notifier(NotifierWithReturn *notify, NotifierWithReturnFunc func); void migration_remove_notifier(NotifierWithReturn *notify); -void migration_call_notifiers(MigrationState *s); +void migration_call_notifiers(MigrationState *s, MigrationEventType type); bool migration_in_setup(MigrationState *); bool migration_has_finished(MigrationState *); bool migration_has_failed(MigrationState *); diff --git a/migration/migration.c b/migration/migration.c index ff9945b..82098ad 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1361,7 +1361,9 @@ static void migrate_fd_cleanup(MigrationState *s) /* It is used on info migrate. We can't free it */ error_report_err(error_copy(s->error)); } - migration_call_notifiers(s); + migration_call_notifiers(s, s->state =3D=3D MIGRATION_STATUS_COMPLETED= ? + MIG_EVENT_PRECOPY_DONE : + MIG_EVENT_PRECOPY_FAILED); block_cleanup_parameters(); yank_unregister_instance(MIGRATION_YANK_INSTANCE); } @@ -1468,9 +1470,12 @@ void migration_remove_notifier(NotifierWithReturn *n= otify) } } =20 -void migration_call_notifiers(MigrationState *s) +void migration_call_notifiers(MigrationState *s, MigrationEventType type) { - notifier_with_return_list_notify(&migration_state_notifiers, s, 0); + MigrationEvent e; + + e.type =3D type; + notifier_with_return_list_notify(&migration_state_notifiers, &e, 0); } =20 bool migration_in_setup(MigrationState *s) @@ -2525,7 +2530,7 @@ static int postcopy_start(MigrationState *ms, Error *= *errp) * spice needs to trigger a transition now */ ms->postcopy_after_devices =3D true; - migration_call_notifiers(ms); + migration_call_notifiers(ms, MIG_EVENT_PRECOPY_DONE); =20 migration_downtime_end(ms); =20 @@ -3584,7 +3589,7 @@ void migrate_fd_connect(MigrationState *s, Error *err= or_in) rate_limit =3D migrate_max_bandwidth(); =20 /* Notify before starting migration thread */ - migration_call_notifiers(s); + migration_call_notifiers(s, MIG_EVENT_PRECOPY_SETUP); } =20 migration_rate_set(rate_limit); diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 1c00519..a29d18a 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -325,13 +325,13 @@ static void vhost_vdpa_net_log_global_enable(VhostVDP= AState *s, bool enable) static int vdpa_net_migration_state_notifier(NotifierWithReturn *notifier, void *data, Error **errp) { - MigrationState *migration =3D data; + MigrationEvent *e =3D data; VhostVDPAState *s =3D container_of(notifier, VhostVDPAState, migration_state); =20 - if (migration_in_setup(migration)) { + if (e->type =3D=3D MIG_EVENT_PRECOPY_SETUP) { vhost_vdpa_net_log_global_enable(s, true); - } else if (migration_has_failed(migration)) { + } else if (e->type =3D=3D MIG_EVENT_PRECOPY_FAILED) { vhost_vdpa_net_log_global_enable(s, false); } return 0; diff --git a/ui/spice-core.c b/ui/spice-core.c index b3cd229..0a59876 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -571,19 +571,18 @@ static SpiceInfo *qmp_query_spice_real(Error **errp) static int migration_state_notifier(NotifierWithReturn *notifier, void *data, Error **errp) { - MigrationState *s =3D data; + MigrationEvent *e =3D data; =20 if (!spice_have_target_host) { return 0; } =20 - if (migration_in_setup(s)) { + if (e->type =3D=3D MIG_EVENT_PRECOPY_SETUP) { spice_server_migrate_start(spice_server); - } else if (migration_has_finished(s) || - migration_in_postcopy_after_devices(s)) { + } else if (e->type =3D=3D MIG_EVENT_PRECOPY_DONE) { spice_server_migrate_end(spice_server, true); spice_have_target_host =3D false; - } else if (migration_has_failed(s)) { + } else if (e->type =3D=3D MIG_EVENT_PRECOPY_FAILED) { spice_server_migrate_end(spice_server, false); spice_have_target_host =3D false; } --=20 1.8.3.1 From nobody Thu Dec 26 13:02:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1707418496; cv=none; d=zohomail.com; s=zohoarc; b=J1ZdewW/vEgY39PVI0BrbFjrYhZM6enQQ55b9cZkkscUdMgp/hjoCSkK37n9q5pog3MA03H1tTTJjANQnx/0jJ+Rp08nawnDwaJQ4xxnIq4kT5gD1zHBSMIkd9jocbqOjLqgRkS2Fx1lOPbBp6UWYaHYIznLB4yOdLetQKYwfOo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707418496; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wuPyGOkKic+L90smhppp+iJseBpBIFQF2XB7aAHz2Ok=; b=kaqBJTDf9XCcZtujrDPDkT9EaEF1sXxiEoC4TpwOhy4Jrw43HhPEEBxl53HWIwlUYuLaMY8JMloDveg2ZmvoC5VwGYEzLlHb6lQ3gJSrs0zN0ewsE+pXJYbU9q+L1P5Ua3FsZdfiRctA7dLgNPogmCH+rUzxuUh5z3JiHzeOg0o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707418496111849.5670542525012; Thu, 8 Feb 2024 10:54:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rY9XU-0001Y8-Op; Thu, 08 Feb 2024 13:54:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9XQ-0001U1-LM for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:21 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9XO-0005nW-Uh for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:20 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 418IjxcG009889; Thu, 8 Feb 2024 18:54:16 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3w1c945qaf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:16 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 418IkLW8038437; Thu, 8 Feb 2024 18:54:16 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3w1bxawn53-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:16 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 418Iq367013534; Thu, 8 Feb 2024 18:54:15 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3w1bxawmw9-6; Thu, 08 Feb 2024 18:54:15 +0000 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-2023-11-20; bh=wuPyGOkKic+L90smhppp+iJseBpBIFQF2XB7aAHz2Ok=; b=cP/QQVxxduTgKmPDiwIPN/8su8Xcv5a7AmN7D8KtuBQdWJRJvwX9KZPr4EpxhI2Ypq+C 7rK+GM0vVjAOFvy7YTVU0XjdZ/fuTrcKxWfxwrOcV492Jno6CErYqbFSwkST9hNg6IDI 2neETSy4M1XJkFG+dGu9Lr1cDpXwvIl47KbjHD95GVYVK4IrJTG5ztuiXkNXfnjc2hr8 E+GGjipz8DCJ59l5KPFeVkW8wE+cDrqJncs4mtG3rDQs0kJeEHcYsVT3UR53D1e1TyON ZpnjVDmwtoFeVf9X1olRo2bzp3yZW30ebLwIY8xqSSRu/6gtEMkli49SEuoeHQQ/BSe0 AA== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , "Michael S. Tsirkin" , Jason Wang , Alex Williamson , Cedric Le Goater , Gerd Hoffmann , Marc-Andre Lureau , David Hildenbrand , Steve Sistare Subject: [PATCH V3 05/13] migration: remove postcopy_after_devices Date: Thu, 8 Feb 2024 10:53:58 -0800 Message-Id: <1707418446-134863-6-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> References: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-08_08,2024-02-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402080099 X-Proofpoint-ORIG-GUID: t1j5jBi89qi06TgTgdhmHjoJKme73tU8 X-Proofpoint-GUID: t1j5jBi89qi06TgTgdhmHjoJKme73tU8 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=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1707418498343100006 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" postcopy_after_devices and migration_in_postcopy_after_devices are no longer used, so delete them. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu --- include/migration/misc.h | 1 - migration/migration.c | 7 ------- migration/migration.h | 2 -- 3 files changed, 10 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index ff8cc57..7a51b45 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -80,7 +80,6 @@ bool migration_in_setup(MigrationState *); bool migration_has_finished(MigrationState *); bool migration_has_failed(MigrationState *); /* ...and after the device transmission */ -bool migration_in_postcopy_after_devices(MigrationState *); /* True if incoming migration entered POSTCOPY_INCOMING_DISCARD */ bool migration_in_incoming_postcopy(void); /* True if incoming migration entered POSTCOPY_INCOMING_ADVISE */ diff --git a/migration/migration.c b/migration/migration.c index 82098ad..9a72680 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1519,11 +1519,6 @@ bool migration_postcopy_is_alive(int state) } } =20 -bool migration_in_postcopy_after_devices(MigrationState *s) -{ - return migration_in_postcopy() && s->postcopy_after_devices; -} - bool migration_in_incoming_postcopy(void) { PostcopyState ps =3D postcopy_state_get(); @@ -1605,7 +1600,6 @@ int migrate_init(MigrationState *s, Error **errp) s->expected_downtime =3D 0; s->setup_time =3D 0; s->start_postcopy =3D false; - s->postcopy_after_devices =3D false; s->migration_thread_running =3D false; error_free(s->error); s->error =3D NULL; @@ -2529,7 +2523,6 @@ static int postcopy_start(MigrationState *ms, Error *= *errp) * at the transition to postcopy and after the device state; in partic= ular * spice needs to trigger a transition now */ - ms->postcopy_after_devices =3D true; migration_call_notifiers(ms, MIG_EVENT_PRECOPY_DONE); =20 migration_downtime_end(ms); diff --git a/migration/migration.h b/migration/migration.h index f2c8b8f..aef8afb 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -348,8 +348,6 @@ struct MigrationState { =20 /* Flag set once the migration has been asked to enter postcopy */ bool start_postcopy; - /* Flag set after postcopy has sent the device state */ - bool postcopy_after_devices; =20 /* Flag set once the migration thread is running (and needs joining) */ bool migration_thread_running; --=20 1.8.3.1 From nobody Thu Dec 26 13:02:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1707418577; cv=none; d=zohomail.com; s=zohoarc; b=DDiF5DQhT1vMNU1/vKmRYm8JYuOsQFDTTYSsq67I3NQLy+qDEdBusySkbm3KGRgVbHzACzUwDQNmC2RtKTIyjow876W7Xbshw+XF+e545OKVexsCE2ZUJyQMI10ioVNXgfRVF3MjX8EXmh1eM1DP1eJXeowZ5brs/0e78Jc7MR4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707418577; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JZTMr7g7u817e6FyiJR+uYUJqLyCvoUAZig4Q77BMbs=; b=WRqSVaHCLLpnfbNvmF71H89G7qgVPitfU1KeJo/+PyGCNq9CSSDBhJLmnSlpNkXqsonew27oRJDEMZesywcRoE0HU4jHko2o2ge1xNUEVW8z5FkdH+uFmvY2FctYXnMsfRoRxSHL9V++9jiD9Ol8h1J3VYW1QFnwucz36L+A3Ws= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707418577861153.26610171573475; Thu, 8 Feb 2024 10:56:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rY9Xh-0001jG-Pl; Thu, 08 Feb 2024 13:54:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9Xg-0001hz-Gq for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:36 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9XQ-0005o5-HM for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:36 -0500 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 418Ik7KV003413; Thu, 8 Feb 2024 18:54:19 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3w1c32wnqp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:19 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 418I0NgJ038389; Thu, 8 Feb 2024 18:54:17 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3w1bxawn6e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:17 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 418Iq369013534; Thu, 8 Feb 2024 18:54:17 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3w1bxawmw9-7; Thu, 08 Feb 2024 18:54:16 +0000 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-2023-11-20; bh=JZTMr7g7u817e6FyiJR+uYUJqLyCvoUAZig4Q77BMbs=; b=NbNU0z90RE/RfXlHrBYna1rye3zUAH3d7KUNzTXwLgOoaWfsyxXOdBM6KeQC7+mCVuRR SuDqoWYu+NpXSY1R+yxqodWifldSsX9pIqr0ArJHleJbMbDSFFJ11GRM9b+zztSIb9Lu 0wqLxXelAOWt65N3RBtLCZX23hIwzypZYhz5XsihneDCH28XlS71oJrYRZRfO4xKRUDW H/23cKduGuySzBm7qF2g8iQYMZ6MoH1LmMLe9N2PI0RSm2f8bXNc3hIUNaaKbdD5s+mu Sk+r2yzHHNoXCxsd2HaRTL1DBX21cakJdpvKzW+SxDfbtb31VojZ+JMTh7fQ9bm8i2RR eg== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , "Michael S. Tsirkin" , Jason Wang , Alex Williamson , Cedric Le Goater , Gerd Hoffmann , Marc-Andre Lureau , David Hildenbrand , Steve Sistare Subject: [PATCH V3 06/13] migration: MigrationNotifyFunc Date: Thu, 8 Feb 2024 10:53:59 -0800 Message-Id: <1707418446-134863-7-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> References: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-08_08,2024-02-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402080099 X-Proofpoint-GUID: zYXlKzeVH2SmsDgI5rEHKK01AO4rCMp2 X-Proofpoint-ORIG-GUID: zYXlKzeVH2SmsDgI5rEHKK01AO4rCMp2 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=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1707418578638100005 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Define MigrationNotifyFunc to improve type safety and simplify migration notifiers. Signed-off-by: Steve Sistare Reviewed-by: David Hildenbrand Reviewed-by: Peter Xu --- hw/net/virtio-net.c | 4 +--- hw/vfio/migration.c | 3 +-- include/migration/misc.h | 7 ++++++- migration/migration.c | 4 ++-- net/vhost-vdpa.c | 6 ++---- ui/spice-core.c | 4 +--- 6 files changed, 13 insertions(+), 15 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index e803f98..a3c711b 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3535,10 +3535,8 @@ static void virtio_net_handle_migration_primary(Virt= IONet *n, MigrationEvent *e) } =20 static int virtio_net_migration_state_notifier(NotifierWithReturn *notifie= r, - void *data, Error **errp) + MigrationEvent *e, Error **= errp) { - MigrationEvent *e =3D data; - VirtIONet *n =3D container_of(notifier, VirtIONet, migration_state); virtio_net_handle_migration_primary(n, e); return 0; diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 869d841..50140ed 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -755,9 +755,8 @@ static void vfio_vmstate_change(void *opaque, bool runn= ing, RunState state) } =20 static int vfio_migration_state_notifier(NotifierWithReturn *notifier, - void *data, Error **errp) + MigrationEvent *e, Error **errp) { - MigrationEvent *e =3D data; VFIOMigration *migration =3D container_of(notifier, VFIOMigration, migration_state); VFIODevice *vbasedev =3D migration->vbasedev; diff --git a/include/migration/misc.h b/include/migration/misc.h index 7a51b45..d75c8b0 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -72,8 +72,13 @@ typedef struct MigrationEvent { MigrationEventType type; } MigrationEvent; =20 + +/* Return int to allow for different failure modes and recovery actions */ +typedef int (*MigrationNotifyFunc)(NotifierWithReturn *notify, + MigrationEvent *e, Error **errp); + void migration_add_notifier(NotifierWithReturn *notify, - NotifierWithReturnFunc func); + MigrationNotifyFunc func); void migration_remove_notifier(NotifierWithReturn *notify); void migration_call_notifiers(MigrationState *s, MigrationEventType type); bool migration_in_setup(MigrationState *); diff --git a/migration/migration.c b/migration/migration.c index 9a72680..5f04c46 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1456,9 +1456,9 @@ static void migrate_fd_cancel(MigrationState *s) } =20 void migration_add_notifier(NotifierWithReturn *notify, - NotifierWithReturnFunc func) + MigrationNotifyFunc func) { - notify->notify =3D func; + notify->notify =3D (NotifierWithReturnFunc)func; notifier_with_return_list_add(&migration_state_notifiers, notify); } =20 diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index a29d18a..e6bdb45 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -323,11 +323,9 @@ static void vhost_vdpa_net_log_global_enable(VhostVDPA= State *s, bool enable) } =20 static int vdpa_net_migration_state_notifier(NotifierWithReturn *notifier, - void *data, Error **errp) + MigrationEvent *e, Error **er= rp) { - MigrationEvent *e =3D data; - VhostVDPAState *s =3D container_of(notifier, VhostVDPAState, - migration_state); + VhostVDPAState *s =3D container_of(notifier, VhostVDPAState, migration= _state); =20 if (e->type =3D=3D MIG_EVENT_PRECOPY_SETUP) { vhost_vdpa_net_log_global_enable(s, true); diff --git a/ui/spice-core.c b/ui/spice-core.c index 0a59876..15be640 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -569,10 +569,8 @@ static SpiceInfo *qmp_query_spice_real(Error **errp) } =20 static int migration_state_notifier(NotifierWithReturn *notifier, - void *data, Error **errp) + MigrationEvent *e, Error **errp) { - MigrationEvent *e =3D data; - if (!spice_have_target_host) { return 0; } --=20 1.8.3.1 From nobody Thu Dec 26 13:02:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1707418563; cv=none; d=zohomail.com; s=zohoarc; b=R3p+/qliaJq3VxH1tcUK6QWjngXBztxDXJBSNTKvdY+UffFuMr+4knZ+KhJFhckxM2xmgaG8Rb4I1Zo+x1ECbTR5+aQlKPigRrItXX4kdu92ptds0JE8WhLgnXtnyFmPMC/V2bGTnGC9ufpPJH0ACdRHvzZQEUSzrmm7x9v+Tzk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707418563; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WCcP6TWmLDaYsdFn0Xjp5tMFbrHpoq809H/HBgSJSqQ=; b=UEipNrCv8X9y1uah5x5vXVdfKTNYdFvw3Hzlv1U9pddD+w2NbqQD8gJulp61/hgDHh/cQc4T4J9G4/yI8lHoAdgR5tbYicQRa5OYf39SDzPyXfEDXAseM/zYbqD397cqr+KJNPZm7MZESbWI6Ak4KoA8dohRkrhWRHkpap3Xkw0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707418563710443.9586457570573; Thu, 8 Feb 2024 10:56:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rY9Xb-0001av-V2; Thu, 08 Feb 2024 13:54:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9XU-0001Y9-TK for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:25 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9XS-0005oR-HX for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:24 -0500 Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 418Iju5a015620; Thu, 8 Feb 2024 18:54:21 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3w1cdd5mph-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:21 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 418HcbYb038354; Thu, 8 Feb 2024 18:54:19 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3w1bxawn91-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:19 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 418Iq36B013534; Thu, 8 Feb 2024 18:54:19 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3w1bxawmw9-8; Thu, 08 Feb 2024 18:54:19 +0000 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-2023-11-20; bh=WCcP6TWmLDaYsdFn0Xjp5tMFbrHpoq809H/HBgSJSqQ=; b=Ip8SwOhkAIPOYWcSvr9lPXhB0iiKaLZUwqyO4f41U0uz2gO0FQF2tnfbThtvHRs039e3 B/uGfOCrbwn3sT1e7XAwEfXr8tfKrd2eB3GEfYQ9nu941FDXZvn1UYiNGs9c1dozqobb mqM5QEuHMHNe7SVfSDbKA22yZAX4QaDcgy2v8MPzipAeuSqknPBwKyYSCb/Ty1w7y5q0 j4/XizSo7BW95wzhRo9iO4FxIYrdwujVfwpcAB7QwMQXumE5q0Fxhij/cgzGl8KcB0YA Mtx75VWa+ngJg0ZyFD7foO0udCgQ/YMLVQ3HtV0pO9v4J4NkS/QRsIseAUlcW/elap0l ow== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , "Michael S. Tsirkin" , Jason Wang , Alex Williamson , Cedric Le Goater , Gerd Hoffmann , Marc-Andre Lureau , David Hildenbrand , Steve Sistare Subject: [PATCH V3 07/13] migration: per-mode notifiers Date: Thu, 8 Feb 2024 10:54:00 -0800 Message-Id: <1707418446-134863-8-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> References: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-08_08,2024-02-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402080099 X-Proofpoint-GUID: T9FMOo7z8P-XDqvW5RLZIyhUavWS4CbR X-Proofpoint-ORIG-GUID: T9FMOo7z8P-XDqvW5RLZIyhUavWS4CbR 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=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1707418564575100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Keep a separate list of migration notifiers for each migration mode. Suggested-by: Peter Xu Signed-off-by: Steve Sistare Reviewed-by: David Hildenbrand Reviewed-by: Peter Xu --- include/migration/misc.h | 2 ++ migration/migration.c | 22 +++++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index d75c8b0..0ea1902 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -79,6 +79,8 @@ typedef int (*MigrationNotifyFunc)(NotifierWithReturn *no= tify, =20 void migration_add_notifier(NotifierWithReturn *notify, MigrationNotifyFunc func); +void migration_add_notifier_mode(NotifierWithReturn *notify, + MigrationNotifyFunc func, MigMode mode); void migration_remove_notifier(NotifierWithReturn *notify); void migration_call_notifiers(MigrationState *s, MigrationEventType type); bool migration_in_setup(MigrationState *); diff --git a/migration/migration.c b/migration/migration.c index 5f04c46..1601a03 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -68,8 +68,13 @@ #include "sysemu/dirtylimit.h" #include "qemu/sockets.h" =20 -static NotifierWithReturnList migration_state_notifiers =3D - NOTIFIER_WITH_RETURN_LIST_INITIALIZER(migration_state_notifiers); +#define NOTIFIER_ELEM_INIT(array, elem) \ + [elem] =3D NOTIFIER_WITH_RETURN_LIST_INITIALIZER((array)[elem]) + +static NotifierWithReturnList migration_state_notifiers[] =3D { + NOTIFIER_ELEM_INIT(migration_state_notifiers, MIG_MODE_NORMAL), + NOTIFIER_ELEM_INIT(migration_state_notifiers, MIG_MODE_CPR_REBOOT), +}; =20 /* Messages sent on the return path from destination to source */ enum mig_rp_message_type { @@ -1455,11 +1460,17 @@ static void migrate_fd_cancel(MigrationState *s) } } =20 +void migration_add_notifier_mode(NotifierWithReturn *notify, + MigrationNotifyFunc func, MigMode mode) +{ + notify->notify =3D (NotifierWithReturnFunc)func; + notifier_with_return_list_add(&migration_state_notifiers[mode], notify= ); +} + void migration_add_notifier(NotifierWithReturn *notify, MigrationNotifyFunc func) { - notify->notify =3D (NotifierWithReturnFunc)func; - notifier_with_return_list_add(&migration_state_notifiers, notify); + migration_add_notifier_mode(notify, func, MIG_MODE_NORMAL); } =20 void migration_remove_notifier(NotifierWithReturn *notify) @@ -1472,10 +1483,11 @@ void migration_remove_notifier(NotifierWithReturn *= notify) =20 void migration_call_notifiers(MigrationState *s, MigrationEventType type) { + MigMode mode =3D s->parameters.mode; MigrationEvent e; =20 e.type =3D type; - notifier_with_return_list_notify(&migration_state_notifiers, &e, 0); + notifier_with_return_list_notify(&migration_state_notifiers[mode], &e,= 0); } =20 bool migration_in_setup(MigrationState *s) --=20 1.8.3.1 From nobody Thu Dec 26 13:02:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1707418552; cv=none; d=zohomail.com; s=zohoarc; b=f8EzPQq0Aa4xyRrGtHjjeMx8mgwE1LNZS1p+NniG58kYC67ntRjFVNn46OSuVyTC8fQI5tcWcwU45WHa3tMIHJ3MP0dYfpP8PM7O3FC5AxgTHBbwCijtyLq8NGenkyUYGZSoD6q2dQ7FpLwLKuEokVRjZEBkU7p2+Pb3XBe9BrQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707418552; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iSIfqSBMc39ZjucLn8EacCTbQQWpPMUX085KAVl1IGM=; b=jZta6h6HQiDmgfxSj2QSokE/mzDBsUDrfvTf/FPNmZ5ETLhRBErD8TNOe1yR+npCj2ueb6vgm49gOJlrKu4WPkTnzyhtd4rqS3jaE1TaceAwLHm5R1je9aFS14OT5RCsicPu+rsz9j1IntE3LQhYA4WZuLgZCfH9fUb6Gsm+2ww= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707418552301537.6602702170956; Thu, 8 Feb 2024 10:55:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rY9Xb-0001ai-Ch; Thu, 08 Feb 2024 13:54:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9XW-0001YL-4v for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:26 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9XU-0005ob-Li for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:25 -0500 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 418IkIrU009749; Thu, 8 Feb 2024 18:54:22 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3w1d3unk2q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:22 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 418IKM3j038388; Thu, 8 Feb 2024 18:54:22 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3w1bxawnay-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:21 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 418Iq36D013534; Thu, 8 Feb 2024 18:54:20 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3w1bxawmw9-9; Thu, 08 Feb 2024 18:54:20 +0000 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-2023-11-20; bh=iSIfqSBMc39ZjucLn8EacCTbQQWpPMUX085KAVl1IGM=; b=IL1JbLelLUeso9PLL7MacPOediwnKpy/VtqBaLLnM+WuPuyTdaLYDZM1Jzk3kbAlzdmE HopwsK1kBbRKmuWRDryulHko4cy5FRqUZKrANIG3LXZBHbp/eldoafeoP2xJv1G6sYbQ s8zxljC2qOrPDa4xYw9cAJ8sMQAfbiFUbCRZMu4B14keYo+77T4sQa1uafLNP3WE2Xbg hgDPt3lV36OTDlijckMjjoCg4kp/Q1+iZ2ymjT1Sua5qlw3IdtD/2x8Oy7V2SY/CNodW o15bANMM3ZGsv3x0R/PUYQAycwDrYgqT/9dY2iuSRwVSOQe1Y2LZDiywQtgTxiKCoF/e 5Q== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , "Michael S. Tsirkin" , Jason Wang , Alex Williamson , Cedric Le Goater , Gerd Hoffmann , Marc-Andre Lureau , David Hildenbrand , Steve Sistare Subject: [PATCH V3 08/13] migration: refactor migrate_fd_connect failures Date: Thu, 8 Feb 2024 10:54:01 -0800 Message-Id: <1707418446-134863-9-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> References: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-08_08,2024-02-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402080099 X-Proofpoint-ORIG-GUID: rhJ4gMNuKswg2sT0ZgQ9UURrhVakP2Lm X-Proofpoint-GUID: rhJ4gMNuKswg2sT0ZgQ9UURrhVakP2Lm 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=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1707418552624100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Move common code for the error path in migrate_fd_connect to a shared fail label. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu Reviewed-by: David Hildenbrand --- migration/migration.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 1601a03..01d8867 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3608,11 +3608,7 @@ void migrate_fd_connect(MigrationState *s, Error *er= ror_in) if (migrate_postcopy_ram() || migrate_return_path()) { if (open_return_path_on_source(s)) { error_setg(&local_err, "Unable to open return-path for postcop= y"); - migrate_set_state(&s->state, s->state, MIGRATION_STATUS_FAILED= ); - migrate_set_error(s, local_err); - error_report_err(local_err); - migrate_fd_cleanup(s); - return; + goto fail; } } =20 @@ -3634,12 +3630,7 @@ void migrate_fd_connect(MigrationState *s, Error *er= ror_in) } =20 if (multifd_save_setup(&local_err) !=3D 0) { - migrate_set_error(s, local_err); - error_report_err(local_err); - migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, - MIGRATION_STATUS_FAILED); - migrate_fd_cleanup(s); - return; + goto fail; } =20 if (migrate_background_snapshot()) { @@ -3650,6 +3641,13 @@ void migrate_fd_connect(MigrationState *s, Error *er= ror_in) migration_thread, s, QEMU_THREAD_JOINABLE); } s->migration_thread_running =3D true; + return; + +fail: + migrate_set_error(s, local_err); + migrate_set_state(&s->state, s->state, MIGRATION_STATUS_FAILED); + error_report_err(local_err); + migrate_fd_cleanup(s); } =20 static void migration_class_init(ObjectClass *klass, void *data) --=20 1.8.3.1 From nobody Thu Dec 26 13:02:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1707418588; cv=none; d=zohomail.com; s=zohoarc; b=mCaNtk2mL3yno1p3ccjIImBFgjYwr/CXvHnx3CCmGkSRJNoBNVQ26J6+7noFv9YG+StkPgEb+QJNwoa/n/OkheAfpWgpRK1ppR3iZPTxMglh3ahiSRYmmDW3Kfo8Jv9vErFulGO8KU70Mu5Gubd06WK5Pfj3ahefsQPFS6AyG84= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707418588; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zPAMmVxL+ok2jMGzEmCWKDz75wO7j7NGVcD7kUCLI9A=; b=XM3huybAvNcLLFg1iMWrlVYx/dgSpBzaHFwxeP24RgZGZVZ8XaYsrm1LKIJ2ZVaIPQFjI4Ttab3LMw1JlqVqSHvKM75IIoaXw9ApTK86BHCiViSFLK/UTIAlLjeVEXvALP/amEWW+B+d9LpQ05l6SRTlsxnjfojs3sBvPJ3z0Zc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17074185886781000.5054358790015; Thu, 8 Feb 2024 10:56:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rY9Xc-0001bB-Qn; Thu, 08 Feb 2024 13:54:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9XW-0001Yj-SG for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:26 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9XU-0005oh-Lw for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:26 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 418Ik6d0020088; Thu, 8 Feb 2024 18:54:23 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3w1bwewdeq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:23 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 418HWkMx038686; Thu, 8 Feb 2024 18:54:22 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3w1bxawncg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:22 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 418Iq36F013534; Thu, 8 Feb 2024 18:54:22 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3w1bxawmw9-10; Thu, 08 Feb 2024 18:54:21 +0000 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-2023-11-20; bh=zPAMmVxL+ok2jMGzEmCWKDz75wO7j7NGVcD7kUCLI9A=; b=G7kwu6Mp4/SCK+W3t0ozWFce+bulZjFHj3NKb+WYWZ8MEFfEwqtD9grd+uqVobovSkXl wf7G1yrlrTd/2/U/5Wby0figemuhj9ehh5sg9zyDWgxqfC/ZPt66QDXwC8TV7AZAw9Bl iJ9y4nA6vbA9yuh3MdNJCbJOnZ7Po8pVWaETN/TXLpfdrlfJWGASL+5hb8UCP09XitJn S889quMLW3SwzWs3fFZCcw9jNwatjy+QeKdJq/zlx5loscBBNOE3tKJ3UNGYV2P0K2LN ToF+jzaVp5y3ss27HeqFrSfZEjC0sDhY1ad2PddaSKU613+ofmjt3QY2mNANsElFIIHY LQ== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , "Michael S. Tsirkin" , Jason Wang , Alex Williamson , Cedric Le Goater , Gerd Hoffmann , Marc-Andre Lureau , David Hildenbrand , Steve Sistare Subject: [PATCH V3 09/13] migration: notifier error checking Date: Thu, 8 Feb 2024 10:54:02 -0800 Message-Id: <1707418446-134863-10-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> References: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-08_08,2024-02-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402080099 X-Proofpoint-ORIG-GUID: L_HM-5lXPE70miD4wBHITZEjCcxr9mrH X-Proofpoint-GUID: L_HM-5lXPE70miD4wBHITZEjCcxr9mrH 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=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1707418590706100010 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Check the status returned by migration notifiers and report errors. If notifiers fail, call the notifiers again so they can clean up. None of the notifiers return an error status at this time. Signed-off-by: Steve Sistare --- include/migration/misc.h | 3 ++- migration/migration.c | 40 +++++++++++++++++++++++++++++----------- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index 0ea1902..6dc234b 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -82,7 +82,8 @@ void migration_add_notifier(NotifierWithReturn *notify, void migration_add_notifier_mode(NotifierWithReturn *notify, MigrationNotifyFunc func, MigMode mode); void migration_remove_notifier(NotifierWithReturn *notify); -void migration_call_notifiers(MigrationState *s, MigrationEventType type); +int migration_call_notifiers(MigrationState *s, MigrationEventType type, + Error **errp); bool migration_in_setup(MigrationState *); bool migration_has_finished(MigrationState *); bool migration_has_failed(MigrationState *); diff --git a/migration/migration.c b/migration/migration.c index 01d8867..d1fce9e 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1318,6 +1318,8 @@ void migrate_set_state(int *state, int old_state, int= new_state) =20 static void migrate_fd_cleanup(MigrationState *s) { + Error *local_err =3D NULL; + g_free(s->hostname); s->hostname =3D NULL; json_writer_free(s->vmdesc); @@ -1362,13 +1364,23 @@ static void migrate_fd_cleanup(MigrationState *s) MIGRATION_STATUS_CANCELLED); } =20 + if (!migration_has_failed(s) && + migration_call_notifiers(s, MIG_EVENT_PRECOPY_DONE, &local_err)) { + + migrate_set_state(&s->state, s->state, MIGRATION_STATUS_FAILED); + migrate_set_error(s, local_err); + error_free(local_err); + } + if (s->error) { /* It is used on info migrate. We can't free it */ error_report_err(error_copy(s->error)); } - migration_call_notifiers(s, s->state =3D=3D MIGRATION_STATUS_COMPLETED= ? - MIG_EVENT_PRECOPY_DONE : - MIG_EVENT_PRECOPY_FAILED); + + if (migration_has_failed(s)) { + migration_call_notifiers(s, MIG_EVENT_PRECOPY_FAILED, NULL); + } + block_cleanup_parameters(); yank_unregister_instance(MIGRATION_YANK_INSTANCE); } @@ -1481,13 +1493,15 @@ void migration_remove_notifier(NotifierWithReturn *= notify) } } =20 -void migration_call_notifiers(MigrationState *s, MigrationEventType type) +int migration_call_notifiers(MigrationState *s, MigrationEventType type, + Error **errp) { MigMode mode =3D s->parameters.mode; MigrationEvent e; =20 e.type =3D type; - notifier_with_return_list_notify(&migration_state_notifiers[mode], &e,= 0); + return notifier_with_return_list_notify(&migration_state_notifiers[mod= e], + &e, errp); } =20 bool migration_in_setup(MigrationState *s) @@ -2535,7 +2549,9 @@ static int postcopy_start(MigrationState *ms, Error *= *errp) * at the transition to postcopy and after the device state; in partic= ular * spice needs to trigger a transition now */ - migration_call_notifiers(ms, MIG_EVENT_PRECOPY_DONE); + if (migration_call_notifiers(ms, MIG_EVENT_PRECOPY_DONE, errp)) { + goto fail; + } =20 migration_downtime_end(ms); =20 @@ -2555,11 +2571,10 @@ static int postcopy_start(MigrationState *ms, Error= **errp) =20 ret =3D qemu_file_get_error(ms->to_dst_file); if (ret) { - error_setg(errp, "postcopy_start: Migration stream errored"); - migrate_set_state(&ms->state, MIGRATION_STATUS_POSTCOPY_ACTIVE, - MIGRATION_STATUS_FAILED); + error_setg_errno(errp, -ret, "postcopy_start: Migration stream err= or"); + bql_lock(); + goto fail; } - trace_postcopy_preempt_enabled(migrate_postcopy_preempt()); =20 return ret; @@ -2580,6 +2595,7 @@ fail: error_report_err(local_err); } } + migration_call_notifiers(ms, MIG_EVENT_PRECOPY_FAILED, NULL); bql_unlock(); return -1; } @@ -3594,7 +3610,9 @@ void migrate_fd_connect(MigrationState *s, Error *err= or_in) rate_limit =3D migrate_max_bandwidth(); =20 /* Notify before starting migration thread */ - migration_call_notifiers(s, MIG_EVENT_PRECOPY_SETUP); + if (migration_call_notifiers(s, MIG_EVENT_PRECOPY_SETUP, &local_er= r)) { + goto fail; + } } =20 migration_rate_set(rate_limit); --=20 1.8.3.1 From nobody Thu Dec 26 13:02:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1707418568; cv=none; d=zohomail.com; s=zohoarc; b=ftayImGJcOoC7mL1JHgkDvTKC7frDPiwtu9tUkmZe+QHyEFcfb4b6fbjZhsdmKztJBfIQ/cnsnBcS1JV0k/L/F8kNcbkJKISzIs269tg1+spSFmdNyP+VvtFBOr+WXwjLMJEYOUsmqY9eAGUJ7zCNgMKWXra7WcpOtvTr0Pt09A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707418568; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AKrGyHd5sYvDWxNgBylMHS2Y8gYn4BTh9nzo3WKhqw8=; b=fqO4mhZGXdhQvJAAW2WQUjX1+NDCFZIvFqCwubMScTSDEb6+0W8ptWM3fkaHWvX9RG9H2W+NM63+P0200ZEET1e0KCBmohWz/mZ7bFA9heskBiRKZ/7uz2kUFz2W0FhgY3Ey2fJUE6UvV457MlboVOCzGKvbeLDLPWlz3RFbSrE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170741856809769.63810845857654; Thu, 8 Feb 2024 10:56:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rY9Xe-0001bu-Dw; Thu, 08 Feb 2024 13:54:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9XY-0001Zz-Ou for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:30 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9XW-0005os-Jx for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:27 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 418IkQVu020283; Thu, 8 Feb 2024 18:54:25 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3w1bwewdes-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:24 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 418HcD5q038384; Thu, 8 Feb 2024 18:54:24 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3w1bxawneh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:24 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 418Iq36H013534; Thu, 8 Feb 2024 18:54:23 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3w1bxawmw9-11; Thu, 08 Feb 2024 18:54:23 +0000 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-2023-11-20; bh=AKrGyHd5sYvDWxNgBylMHS2Y8gYn4BTh9nzo3WKhqw8=; b=eKWrlmOTruS35o/V5auHxz5kB/HkUjGnxT3+IQtWgsnzpcvK7algYuK0PFHDeGGYxX6f ckP9MyYXemmIzTLgNDKY00GkKNUasRZOtLXMKGjwTW2ra2P6cAxsOGRJk/sq41/puzKl qs9VHQLdws0vmeCXtCv/+X7djLZY4lRV3jF1y4UJC0GM2jWiyKvgsY2F8yYU+8AZ9I+m /OyTAa9LfxLuQTZYLHuCCmFSnEOdJ5w6H288CtTb483wLyLlUmZXs/ugL8QcosgnbfrW 9bbaz2BAIbaszIJo+d78zI+bE9gQRjpAiC+7cAZO1jh9ewc9F6l4uVOLYWmpspQ9mOSo uw== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , "Michael S. Tsirkin" , Jason Wang , Alex Williamson , Cedric Le Goater , Gerd Hoffmann , Marc-Andre Lureau , David Hildenbrand , Steve Sistare Subject: [PATCH V3 10/13] migration: stop vm for cpr Date: Thu, 8 Feb 2024 10:54:03 -0800 Message-Id: <1707418446-134863-11-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> References: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-08_08,2024-02-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402080099 X-Proofpoint-ORIG-GUID: swgr-NiT0Q330me73bx0eP6ODAqfvc9m X-Proofpoint-GUID: swgr-NiT0Q330me73bx0eP6ODAqfvc9m 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=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1707418568606100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When migration for cpr is initiated, stop the vm and set state RUN_STATE_FINISH_MIGRATE before ram is saved. This eliminates the possibility of ram and device state being out of sync, and guarantees that a guest in the suspended state remains suspended, because qmp_cont rejects a cont command in the RUN_STATE_FINISH_MIGRATE state. Signed-off-by: Steve Sistare --- include/migration/misc.h | 1 + migration/migration.c | 32 +++++++++++++++++++++++++------- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index 6dc234b..54c99a3 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -60,6 +60,7 @@ void migration_object_init(void); void migration_shutdown(void); bool migration_is_idle(void); bool migration_is_active(MigrationState *); +bool migrate_mode_is_cpr(MigrationState *); =20 typedef enum MigrationEventType { MIG_EVENT_PRECOPY_SETUP, diff --git a/migration/migration.c b/migration/migration.c index d1fce9e..fc5c587 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1603,6 +1603,11 @@ bool migration_is_active(MigrationState *s) s->state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE); } =20 +bool migrate_mode_is_cpr(MigrationState *s) +{ + return s->parameters.mode =3D=3D MIG_MODE_CPR_REBOOT; +} + int migrate_init(MigrationState *s, Error **errp) { int ret; @@ -2651,13 +2656,14 @@ static int migration_completion_precopy(MigrationSt= ate *s, bql_lock(); migration_downtime_start(s); =20 - s->vm_old_state =3D runstate_get(); - global_state_store(); - - ret =3D migration_stop_vm(RUN_STATE_FINISH_MIGRATE); - trace_migration_completion_vm_stop(ret); - if (ret < 0) { - goto out_unlock; + if (!migrate_mode_is_cpr(s)) { + s->vm_old_state =3D runstate_get(); + global_state_store(); + ret =3D migration_stop_vm(RUN_STATE_FINISH_MIGRATE); + trace_migration_completion_vm_stop(ret); + if (ret < 0) { + goto out_unlock; + } } =20 ret =3D migration_maybe_pause(s, current_active_state, @@ -3576,6 +3582,7 @@ void migrate_fd_connect(MigrationState *s, Error *err= or_in) Error *local_err =3D NULL; uint64_t rate_limit; bool resume =3D s->state =3D=3D MIGRATION_STATUS_POSTCOPY_PAUSED; + int ret; =20 /* * If there's a previous error, free it and prepare for another one. @@ -3651,6 +3658,17 @@ void migrate_fd_connect(MigrationState *s, Error *er= ror_in) goto fail; } =20 + if (migrate_mode_is_cpr(s)) { + s->vm_old_state =3D runstate_get(); + global_state_store(); + ret =3D migration_stop_vm(RUN_STATE_FINISH_MIGRATE); + trace_migration_completion_vm_stop(ret); + if (ret < 0) { + error_setg(&local_err, "migration_stop_vm failed, error %d", -= ret); + goto fail; + } + } + if (migrate_background_snapshot()) { qemu_thread_create(&s->thread, "bg_snapshot", bg_migration_thread, s, QEMU_THREAD_JOINABLE); --=20 1.8.3.1 From nobody Thu Dec 26 13:02:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1707418589; cv=none; d=zohomail.com; s=zohoarc; b=Qtq2TtvIjPv5NtyLuIMaDtmfoqThnzdjWNFPJfL16cQi3x+cgDSbQEDdXM93xrL7GpW2saNt/+3xd/58219QvbAQxeuk+VZRXaW7mD9d6ZmmMThFjM7wY+NW1Tadl1+co7YrHeJh4WitkTPPNAF4pacSwW1IYcJCNgaRRk3zbC0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707418589; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=rH7BH7+m4emVEj2RIKS77Ga1/IdPcieuJjzqzULPCFo=; b=ilETLwxFdLkpQE4bbs9w2R9qbRlxiAPLZN1Xvx7Y+FwygfdUbdi+bwZMfNQbiB0FopXJLmfdRTjhq74OQ+KA1IJeRG/33/b0d7yRp6NuR9ga8k77BC7r+olXHS28hupWqsEwAjZqU9QU1BWCVGlxwM7HWMP9FilIcEwcrsvZ+3o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707418589495180.45389145752506; Thu, 8 Feb 2024 10:56:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rY9Xe-0001bq-B3; Thu, 08 Feb 2024 13:54:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9Xa-0001a3-8x for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:30 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9XY-0005pC-GX for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:29 -0500 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 418IjwHE009585; Thu, 8 Feb 2024 18:54:27 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3w1d3unk2v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:26 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 418HUj5R038399; Thu, 8 Feb 2024 18:54:26 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3w1bxawnha-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:25 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 418Iq36J013534; Thu, 8 Feb 2024 18:54:25 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3w1bxawmw9-12; Thu, 08 Feb 2024 18:54:25 +0000 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-2023-11-20; bh=rH7BH7+m4emVEj2RIKS77Ga1/IdPcieuJjzqzULPCFo=; b=nS7I2Oktgb98yXIMPtrQ5f+RjvXFO0111ebOvFhhNxvXuxkyIKU0XwIDONg16kWKWskM qrrP9EE9dRwD4u9i2XF8+dNKjPLeflWYXnWYO8N+0s+/9R5a/LcO3TvuIc07eHbSobmT qTYAYPKpJ+UUFeJ2Q/Mb03PVQPF798IJiAyIxKBgkoIjQRXtoxN1ZPQXLRbDU6G4w5S8 UYjOyUph6JXiBDu2hZrbofwv9kjIhhRwDzYycbX61zgbXLaGR4DhwmFzCDgqjrQilrCm MADvwO5HyONtz3B08srkbmi4a8gOKpsmMWMim39dKR+RdfdAYVRiqEDC/05bdoV0uv8n QQ== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , "Michael S. Tsirkin" , Jason Wang , Alex Williamson , Cedric Le Goater , Gerd Hoffmann , Marc-Andre Lureau , David Hildenbrand , Steve Sistare Subject: [PATCH V3 11/13] vfio: register container for cpr Date: Thu, 8 Feb 2024 10:54:04 -0800 Message-Id: <1707418446-134863-12-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> References: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-08_08,2024-02-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402080099 X-Proofpoint-ORIG-GUID: Ql8SJR7j1vEuUaoZze8ZTxbBaHRdNXz9 X-Proofpoint-GUID: Ql8SJR7j1vEuUaoZze8ZTxbBaHRdNXz9 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=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1707418590706100009 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Define entry points to perform per-container cpr-specific initialization and teardown. Signed-off-by: Steve Sistare --- hw/vfio/container.c | 11 ++++++++++- hw/vfio/cpr.c | 19 +++++++++++++++++++ hw/vfio/iommufd.c | 6 ++++++ hw/vfio/meson.build | 1 + include/hw/vfio/vfio-common.h | 3 +++ 5 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 hw/vfio/cpr.c diff --git a/hw/vfio/container.c b/hw/vfio/container.c index bd25b9f..096d77e 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -621,10 +621,15 @@ static int vfio_connect_container(VFIOGroup *group, A= ddressSpace *as, goto free_container_exit; } =20 + ret =3D vfio_cpr_register_container(bcontainer, errp); + if (ret) { + goto free_container_exit; + } + ret =3D vfio_ram_block_discard_disable(container, true); if (ret) { error_setg_errno(errp, -ret, "Cannot set discarding of RAM broken"= ); - goto free_container_exit; + goto unregister_container_exit; } =20 assert(bcontainer->ops->setup); @@ -667,6 +672,9 @@ listener_release_exit: enable_discards_exit: vfio_ram_block_discard_disable(container, false); =20 +unregister_container_exit: + vfio_cpr_unregister_container(bcontainer); + free_container_exit: g_free(container); =20 @@ -710,6 +718,7 @@ static void vfio_disconnect_container(VFIOGroup *group) vfio_container_destroy(bcontainer); =20 trace_vfio_disconnect_container(container->fd); + vfio_cpr_unregister_container(bcontainer); close(container->fd); g_free(container); =20 diff --git a/hw/vfio/cpr.c b/hw/vfio/cpr.c new file mode 100644 index 0000000..3bede54 --- /dev/null +++ b/hw/vfio/cpr.c @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2021-2024 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "hw/vfio/vfio-common.h" +#include "qapi/error.h" + +int vfio_cpr_register_container(VFIOContainerBase *bcontainer, Error **err= p) +{ + return 0; +} + +void vfio_cpr_unregister_container(VFIOContainerBase *bcontainer) +{ +} diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 9bfddc1..e1be224 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -411,6 +411,11 @@ found_container: goto err_listener_register; } =20 + ret =3D vfio_cpr_register_container(bcontainer, errp); + if (ret) { + goto err_listener_register; + } + /* * TODO: examine RAM_BLOCK_DISCARD stuff, should we do group level * for discarding incompatibility check as well? @@ -461,6 +466,7 @@ static void iommufd_cdev_detach(VFIODevice *vbasedev) iommufd_cdev_ram_block_discard_disable(false); } =20 + vfio_cpr_unregister_container(bcontainer); iommufd_cdev_detach_container(vbasedev, container); iommufd_cdev_container_destroy(container); vfio_put_address_space(space); diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build index bb98493..bba776f 100644 --- a/hw/vfio/meson.build +++ b/hw/vfio/meson.build @@ -5,6 +5,7 @@ vfio_ss.add(files( 'container-base.c', 'container.c', 'migration.c', + 'cpr.c', )) vfio_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr.c')) vfio_ss.add(when: 'CONFIG_IOMMUFD', if_true: files( diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 4a6c262..b9da6c0 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -205,6 +205,9 @@ void vfio_detach_device(VFIODevice *vbasedev); int vfio_kvm_device_add_fd(int fd, Error **errp); int vfio_kvm_device_del_fd(int fd, Error **errp); =20 +int vfio_cpr_register_container(VFIOContainerBase *bcontainer, Error **err= p); +void vfio_cpr_unregister_container(VFIOContainerBase *bcontainer); + extern const MemoryRegionOps vfio_region_ops; typedef QLIST_HEAD(VFIOGroupList, VFIOGroup) VFIOGroupList; typedef QLIST_HEAD(VFIODeviceList, VFIODevice) VFIODeviceList; --=20 1.8.3.1 From nobody Thu Dec 26 13:02:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1707418578; cv=none; d=zohomail.com; s=zohoarc; b=KITTlhCCvu08WwjIZzrtXL5wCLogS5eeHPE6mEGoimxcL/1VCWDQYORr9hXjum77orkB1HCHaY8wSphO6UIvconDsaYd7ImxGLtiQP8/ii50Mg0zuMab39vmt6ivFxvxabsnDMNF3p/aab023jZX0/OD2bQXVkfJwVRIDrLlg9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707418578; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gsBCfpYo6nRhd1lyMEyOJxnbTlx2IARryMCqC21aU7A=; b=OypT87FOPGK8aW61bEoIjln6DUmBfKnv0aZJo0uT7baAYNFUSocrY/nWvSTWMqK3/4cW4bYoRVIyDrqKZ4n+x9cfCfQQWHagXf6EWni9pIrs4W98kxJ/UHTEdmbMGnIvp2xmQY0Trz0ts/sCGYFPDceI2XTvzIu1czaBcalE8MQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707418578293137.7902258495193; Thu, 8 Feb 2024 10:56:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rY9Xc-0001b8-JJ; Thu, 08 Feb 2024 13:54:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9Xb-0001aj-Gi for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:31 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9Xa-0005pS-0s for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:31 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 418Ijxwk009881; Thu, 8 Feb 2024 18:54:28 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3w1c945qax-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:28 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 418IfoeF038357; Thu, 8 Feb 2024 18:54:27 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3w1bxawnke-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:27 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 418Iq36L013534; Thu, 8 Feb 2024 18:54:27 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3w1bxawmw9-13; Thu, 08 Feb 2024 18:54:27 +0000 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-2023-11-20; bh=gsBCfpYo6nRhd1lyMEyOJxnbTlx2IARryMCqC21aU7A=; b=L7tQhorEBYhiOU4EewcJixD4HApcBzArDmO9jqrtWsxue6QNklFBYCS6tAQeFLQFuYZK a9hf2gcgD9tyjX1eMot5o4mXnSu9sBv97pg8IYP3eYCeVBwujfwAJcE9gSua+QjD2ZfL 6y+uNnG9fPA1HMJFg0K+TRILSPPfEUofR+khdc22IA1kvjQkK8WLKkuKS+DURqml/Rzf XjvKP62RO6Ur6WmqtC4LhlMBguA5PnAsoK0uWmLBmN7ipZToXeOF7+IAqIZ6587G0pdn /X/+WzXEAkUt7ajPMeXETuC+U0dv9wFPt9llqU+XbYe4gVTXT0VQv4CVzGaYLIS7mnGf +w== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , "Michael S. Tsirkin" , Jason Wang , Alex Williamson , Cedric Le Goater , Gerd Hoffmann , Marc-Andre Lureau , David Hildenbrand , Steve Sistare Subject: [PATCH V3 12/13] vfio: allow cpr-reboot migration if suspended Date: Thu, 8 Feb 2024 10:54:05 -0800 Message-Id: <1707418446-134863-13-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> References: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-08_08,2024-02-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402080099 X-Proofpoint-ORIG-GUID: XBX4lnxbA_a-yYBgDpne9D8xZX0P2RPB X-Proofpoint-GUID: XBX4lnxbA_a-yYBgDpne9D8xZX0P2RPB 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=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1707418578639100006 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Allow cpr-reboot for vfio if the guest is in the suspended runstate. The guest drivers' suspend methods flush outstanding requests and re-initialize the devices, and thus there is no device state to save and restore. The user is responsible for suspending the guest before initiating cpr, such as by issuing guest-suspend-ram to the qemu guest agent. Relax the vfio blocker so it does not apply to cpr, and add a notifier that verifies the guest is suspended. Signed-off-by: Steve Sistare --- hw/vfio/common.c | 2 +- hw/vfio/cpr.c | 20 ++++++++++++++++++++ hw/vfio/migration.c | 2 +- include/hw/vfio/vfio-container-base.h | 1 + 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 059bfdc..ff88c3f 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -128,7 +128,7 @@ int vfio_block_multiple_devices_migration(VFIODevice *v= basedev, Error **errp) error_setg(&multiple_devices_migration_blocker, "Multiple VFIO devices migration is supported only if all o= f " "them support P2P migration"); - ret =3D migrate_add_blocker(&multiple_devices_migration_blocker, errp); + ret =3D migrate_add_blocker_normal(&multiple_devices_migration_blocker= , errp); =20 return ret; } diff --git a/hw/vfio/cpr.c b/hw/vfio/cpr.c index 3bede54..392c2dd 100644 --- a/hw/vfio/cpr.c +++ b/hw/vfio/cpr.c @@ -7,13 +7,33 @@ =20 #include "qemu/osdep.h" #include "hw/vfio/vfio-common.h" +#include "migration/misc.h" #include "qapi/error.h" +#include "sysemu/runstate.h" + +static int vfio_cpr_reboot_notifier(NotifierWithReturn *notifier, + MigrationEvent *e, Error **errp) +{ + if (e->type =3D=3D MIG_EVENT_PRECOPY_SETUP && + !runstate_check(RUN_STATE_SUSPENDED) && !vm_get_suspended()) { + + error_setg(errp, + "VFIO device only supports cpr-reboot for runstate suspended"); + + return -1; + } + return 0; +} =20 int vfio_cpr_register_container(VFIOContainerBase *bcontainer, Error **err= p) { + migration_add_notifier_mode(&bcontainer->cpr_reboot_notifier, + vfio_cpr_reboot_notifier, + MIG_MODE_CPR_REBOOT); return 0; } =20 void vfio_cpr_unregister_container(VFIOContainerBase *bcontainer) { + migration_remove_notifier(&bcontainer->cpr_reboot_notifier); } diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 50140ed..2050ac8 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -889,7 +889,7 @@ static int vfio_block_migration(VFIODevice *vbasedev, E= rror *err, Error **errp) vbasedev->migration_blocker =3D error_copy(err); error_free(err); =20 - return migrate_add_blocker(&vbasedev->migration_blocker, errp); + return migrate_add_blocker_normal(&vbasedev->migration_blocker, errp); } =20 /* ---------------------------------------------------------------------- = */ diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-c= ontainer-base.h index b2813b0..3582d5f 100644 --- a/include/hw/vfio/vfio-container-base.h +++ b/include/hw/vfio/vfio-container-base.h @@ -49,6 +49,7 @@ typedef struct VFIOContainerBase { QLIST_ENTRY(VFIOContainerBase) next; QLIST_HEAD(, VFIODevice) device_list; GList *iova_ranges; + NotifierWithReturn cpr_reboot_notifier; } VFIOContainerBase; =20 typedef struct VFIOGuestIOMMU { --=20 1.8.3.1 From nobody Thu Dec 26 13:02:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1707418586; cv=none; d=zohomail.com; s=zohoarc; b=U9BrcoHiovrjoPujiIWPPEnjWgKZ+c4ygG+WSMHG4dTjXmbmpH/qGazOH4PcPVeY08j+5X9c9xMtoJy5S3zl4PLwmAuO++ulkJaYX88ypHRN+aOkpyPksHoOWEqMHVtH9b0WMfofxFICWWvDcd/npKf/4NZyorePpjxgrgV5afs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707418586; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ta4RajXp4A5/tKccMGjZ7rIh6kE+PS4323ZhW1w6QlQ=; b=fWuOYIW+FxDARqztkIOAltYZ0q4ycNOh8DuABxSBTts3J+YL0BMsAGiiig4hDaHHIqoJJcNu0JdWn361VRLeAr8oXgn3NsVfr1oA2oDzUqSH8F7KdtQc8xQq4h7xQ++HleAI7M15VoCcUaGc8hhWJcY2wlyNOqHEo//Ztc6c/vk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707418586956305.44438355307966; Thu, 8 Feb 2024 10:56:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rY9Xe-0001bm-4O; Thu, 08 Feb 2024 13:54:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9Xc-0001b9-MN for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:32 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY9Xa-0005pe-QS for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:54:32 -0500 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 418Ijvi3002703; Thu, 8 Feb 2024 18:54:30 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3w1dhdnqyk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:29 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 418Iikfi038387; Thu, 8 Feb 2024 18:54:29 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3w1bxawnmv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Feb 2024 18:54:29 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 418Iq36N013534; Thu, 8 Feb 2024 18:54:28 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3w1bxawmw9-14; Thu, 08 Feb 2024 18:54:28 +0000 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-2023-11-20; bh=ta4RajXp4A5/tKccMGjZ7rIh6kE+PS4323ZhW1w6QlQ=; b=CeoSY2hzZTjGdO2BAy68dCkXoEWvbYS3vcYl/4M/d8JW3lWsoVpRzB2yWHnYiQtOs9zT OWWHA3evuLyjKCniX4qWjCt1qRVh90raxOpkIfXlhB/JBJAJqnz7sCCrmIIm4k8Kdc9e mIfyewp+nBgwGFC+IB2lqxeIFOXqz1U+nSDHP3yNGSNzJSLU7cOzv2sjXdla743Y+4/U F4F6mHv1aWOp8zt02CB99TAalSHa4ZLjeOt2gELTB/RB6pcNW0P7hV+QwgVhFQ9RB6kb x+u2P/pQVDBi1WZjdZBq/CMtWBaHHNe4gaS1H1BUVnfHnmu1ujP/WzbkCwjVgJITbZ8o 4Q== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , "Michael S. Tsirkin" , Jason Wang , Alex Williamson , Cedric Le Goater , Gerd Hoffmann , Marc-Andre Lureau , David Hildenbrand , Steve Sistare Subject: [PATCH V3 13/13] migration: update cpr-reboot description Date: Thu, 8 Feb 2024 10:54:06 -0800 Message-Id: <1707418446-134863-14-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> References: <1707418446-134863-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-08_08,2024-02-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402080099 X-Proofpoint-GUID: r3XyUTUAsIrAl3DENq1TPxr9BtdmWjcN X-Proofpoint-ORIG-GUID: r3XyUTUAsIrAl3DENq1TPxr9BtdmWjcN 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=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1707418588691100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Clarify qapi for cpr-reboot migration mode, and add vfio support. Signed-off-by: Steve Sistare --- qapi/migration.json | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/qapi/migration.json b/qapi/migration.json index 8197083..c83e0c0 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -636,19 +636,29 @@ # # @normal: the original form of migration. (since 8.2) # -# @cpr-reboot: The migrate command saves state to a file, allowing one to -# quit qemu, reboot to an updated kernel, and restart an upda= ted -# version of qemu. The caller must specify a migration URI -# that writes to and reads from a file. Unlike normal mode, -# the use of certain local storage options does not block the -# migration, but the caller must not modify guest block devic= es -# between the quit and restart. To avoid saving guest RAM to= the -# file, the memory backend must be shared, and the @x-ignore-= shared -# migration capability must be set. Guest RAM must be non-vo= latile -# across reboot, such as by backing it with a dax device, but= this -# is not enforced. The restarted qemu arguments must match t= hose -# used to initially start qemu, plus the -incoming option. -# (since 8.2) +# @cpr-reboot: The migrate command stops the VM, saves state to the URI, +# and qemu exits. After qemu exits, the user resumes by running +# qemu -incoming. +# +# This mode allows the user to quit qemu, and restart an updated versi= on +# of qemu. The user may even update and reboot the OS before restarti= ng, +# as long as the URI persists across a reboot. +# +# Unlike normal mode, the use of certain local storage options does not +# block the migration, but the user must not modify guest block devices +# between the quit and restart. +# +# This mode supports vfio devices provided the user first puts the gue= st +# in the suspended runstate, such as by issuing guest-suspend-ram to t= he +# qemu guest agent. +# +# Best performance is achieved when the memory backend is shared and t= he +# @x-ignore-shared migration capability is set, but this is not requir= ed. +# Further, if the user reboots before restarting such a configuration,= the +# shared backend must be be non-volatile across reboot, such as by bac= king +# it with a dax device. +# +# (since 8.2) ## { 'enum': 'MigMode', 'data': [ 'normal', 'cpr-reboot' ] } --=20 1.8.3.1