From nobody Sat May 18 04:46:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672936236; cv=none; d=zohomail.com; s=zohoarc; b=X1b4L6EyN4e0HrfgDypG5EW5IRq5Mw3M2+ixwLKeIUWaGHDXZq7EO1y7zfn1KIKXHNkCbZY1YuCmMMkhDq59OvYcla/s3pgv7HwHyvptxR3erjrok3cXBKD/RmnfAdIuhdFaolTT6wPPZo9V9F1110nCRblxlCTqeQ4TUshy4ps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672936236; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7GRm8+ho/SZ51cyNMDlzkXhuQ9QV1sZhOsJST8/zitM=; b=Yq+GFLFguoqCzQPdp4yugGuLu0bqlivPhaPO31dqwlTR6aJmoMfcZUbM3c5PKIfH4vEDcUEcutEbJJJHt2mGgBWfZ8WgCXa201xSyfHTaxzZ2xr6ZJxZ6AlBsQWvs0jlmlQf/TKa73iJI8D0dPS5NmyC1AnocT36hdbTc3r+DO8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1672936236580877.9648041316844; Thu, 5 Jan 2023 08:30:36 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-298-NnxLgWSVNUeD8m8INi5JoQ-1; Thu, 05 Jan 2023 11:30:32 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 37693858F0E; Thu, 5 Jan 2023 16:30:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2015539D6D; Thu, 5 Jan 2023 16:30:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DB3B01946589; Thu, 5 Jan 2023 16:30:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AC6E01946586 for ; Thu, 5 Jan 2023 16:30:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 813B72166B31; Thu, 5 Jan 2023 16:30:28 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 958482166B30 for ; Thu, 5 Jan 2023 16:30:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672936235; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=7GRm8+ho/SZ51cyNMDlzkXhuQ9QV1sZhOsJST8/zitM=; b=PAmOlR4AhDJ8Cg59tAkghTMtPTrthtbt8ZT5cGGXgcPICeBfTN0RqAF2ZuSdLp08CLoTQB hR/fWNv3qn8JQSFQP1pQu+EspMXxVH4rOIPOvIs43EQ9ALHJzjuPLWqkfR0IqgHBx1KrPZ DD4lp+YhOhQxK7QOpP7W4OIuFb0I2Fo= X-MC-Unique: NnxLgWSVNUeD8m8INi5JoQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/36] datatypes: Simplify error path of 'virGetDomain' Date: Thu, 5 Jan 2023 17:29:50 +0100 Message-Id: <093af0a98e645bc3f17b91f38bce57248d4fcd1c.1672935969.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672936237429100001 Content-Type: text/plain; charset="utf-8" 'virObjectNew' can't return NULL. If we pre-check the arguments we don't need a cleanup label. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: Pavel Hrdina --- src/datatypes.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/datatypes.c b/src/datatypes.c index da8a9970f1..c83a74edd5 100644 --- a/src/datatypes.c +++ b/src/datatypes.c @@ -292,13 +292,11 @@ virGetDomain(virConnectPtr conn, if (virDataTypesInitialize() < 0) return NULL; - virCheckConnectGoto(conn, error); - virCheckNonNullArgGoto(name, error); - virCheckNonNullArgGoto(uuid, error); - - if (!(ret =3D virObjectNew(virDomainClass))) - goto error; + virCheckConnectReturn(conn, NULL); + virCheckNonNullArgReturn(name, NULL); + virCheckNonNullArgReturn(uuid, NULL); + ret =3D virObjectNew(virDomainClass); ret->name =3D g_strdup(name); ret->conn =3D virObjectRef(conn); @@ -306,10 +304,6 @@ virGetDomain(virConnectPtr conn, memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN); return ret; - - error: - virObjectUnref(ret); - return NULL; } /** --=20 2.38.1 From nobody Sat May 18 04:46:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672936281; cv=none; d=zohomail.com; s=zohoarc; b=Acwr469dt5yGTMFSNqVkiKzffGYbsrlzAOv56Aib9aF7BYY23KQhVLMDi/OIJa+P/GTmDewxhIZRlXKcCSGEBAJUmAjGydWLr+t7heaASVlU4hxA/FL4ZJaBKejt6XF+cZfMvqQ8bZpBtBr7PhoCWZPz762Omq22YmhBHDIwRE8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672936281; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wvUVAQe7u7VWLwaiVWsS6hCUpXuwW2HRAF6AQvEV+ls=; b=bFfCow3L8kWz6Sv5p6BgtU8xc/tijCblqwt5wUJpNGL/qbp0kJQ4/AB4im1Y+HMy0EUxGXWBOwohyvNERoBe4f6rcNS4HIZhPIDUJH5rAsYtcR+bOkiSrHk05MA9Iy4tznj1EPSTkRQ5tmXZmJT0NZYbcA5H3dMMzIaq+uKYLQw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1672936281398531.2070860347312; Thu, 5 Jan 2023 08:31:21 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-175-w24F8TQZO7qnJnfegtYmMg-1; Thu, 05 Jan 2023 11:30:36 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6CCCE811E6E; Thu, 5 Jan 2023 16:30:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55BF514171B6; Thu, 5 Jan 2023 16:30:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1B5D91946589; Thu, 5 Jan 2023 16:30:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B59551946586 for ; Thu, 5 Jan 2023 16:30:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A5DC32166B32; Thu, 5 Jan 2023 16:30:29 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CFA42166B35 for ; Thu, 5 Jan 2023 16:30:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672936280; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=wvUVAQe7u7VWLwaiVWsS6hCUpXuwW2HRAF6AQvEV+ls=; b=XoEq4H2depo4qFokbgqwoQurN70wyhaK/uxpTWXiZ2Xk4Ss0NBZSsppQcgjIauX/3gCGNI S76mmxXIvLv1DQQ+4pF1a19qb3T0/vgoED7JET9gnZOX2YAPHpO9U8pcDcG7g1BjnU9lIP LWDy/DAfeYgT1Y0snYZyPRiTbJZEc6M= X-MC-Unique: w24F8TQZO7qnJnfegtYmMg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/36] datatypes: Clean up whitespace in definition of struct _virConnect Date: Thu, 5 Jan 2023 17:29:51 +0100 Message-Id: <9c9ea06ce2bacaf91dea04db1078e7d34115a400.1672935969.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672936281871100001 Content-Type: text/plain; charset="utf-8" Remove extraneous spaces and put comment on a single line. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: Pavel Hrdina --- src/datatypes.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/datatypes.h b/src/datatypes.h index 0f9730d9e8..f8b1a83407 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -528,11 +528,10 @@ struct _virConnect { virSecretDriver *secretDriver; virNWFilterDriver *nwfilterDriver; - /* Private data pointer which can be used by domain driver as - * it pleases. + /* Private data pointer which can be used by domain driver as it pleas= es. * NB: 'private' is a reserved word in C++. */ - void * privateData; + void *privateData; /* * Object lock must be acquired before accessing/changing any of --=20 2.38.1 From nobody Sat May 18 04:46:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672936238; cv=none; d=zohomail.com; s=zohoarc; b=Y0F4NWOqXwRDOyihwS+9Ucvk4w9Aa9GAGMAt7lJ/C0Q56laqchmhDt8oUUtp+7OcvqMQOuC6cyP61tBfbOVbnk7JgfzVJGx6+9GHhlPPmGcuBsB/9k/UDwsdTF1zPzUkYJQiVFTfUYCUJ7yEDYxF1Fh4zkUpkAti0jLYqbbMuuY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672936238; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=N1kKlgw54Q8n9BW424jOaMUMn/WIL2OhbNr2ePYwZQI=; b=WJbP4mlg24SoxV50XjyEzFX0/rYb0ZNDfKCjOAN5BNkVXaHmf/QI+UX7Zu86FrvyPq/7K9sYM6fIBygAiSo+qSzCepUZ0MRtupyeV1GTWrA9y2qQn7w4Fs+48VyfoxpmSJnn9aQVGNbePSV9oM3Lum4PTEcka6bTpiEr9I0DEds= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1672936238414321.5076221194887; Thu, 5 Jan 2023 08:30:38 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-552-Mo-VXd-jOqOa4OPGJKmlNg-1; Thu, 05 Jan 2023 11:30:34 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8050A18E0043; Thu, 5 Jan 2023 16:30:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BE7540C1141; Thu, 5 Jan 2023 16:30:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 51B3019465A0; Thu, 5 Jan 2023 16:30:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CF1D91946586 for ; Thu, 5 Jan 2023 16:30:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C18FB2166B31; Thu, 5 Jan 2023 16:30:30 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E7E22166B30 for ; Thu, 5 Jan 2023 16:30:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672936237; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=N1kKlgw54Q8n9BW424jOaMUMn/WIL2OhbNr2ePYwZQI=; b=VubBrDStE+TcMdR1+76O60f5iQ3JHr+K/gDngaNDMqSXtSLwy+lv5mJv/A6nwqgRf/wufh e2kuNC5dhVq73orBRHzkyAO1p2JKGBhk//K3RGnGmpyJIXAAv4P1kVdoXIH8f0Usd5yGim pEb4oJ5X9CNrb+GBoXFsoAKPbGSOu0A= X-MC-Unique: Mo-VXd-jOqOa4OPGJKmlNg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/36] conf: virdomainobjlist: Convert header to contemporary style Date: Thu, 5 Jan 2023 17:29:52 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672936239456100009 Content-Type: text/plain; charset="utf-8" Use the new style which doesn't require re-aligning the argument list once you change the return type. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: Pavel Hrdina --- src/conf/virdomainobjlist.h | 156 ++++++++++++++++++++---------------- 1 file changed, 86 insertions(+), 70 deletions(-) diff --git a/src/conf/virdomainobjlist.h b/src/conf/virdomainobjlist.h index 4169eb4f78..cfa165d56f 100644 --- a/src/conf/virdomainobjlist.h +++ b/src/conf/virdomainobjlist.h @@ -26,72 +26,85 @@ typedef struct _virDomainObjList virDomainObjList; -virDomainObjList *virDomainObjListNew(void); - -virDomainObj *virDomainObjListFindByID(virDomainObjList *doms, - int id); -virDomainObj *virDomainObjListFindByUUID(virDomainObjList *doms, - const unsigned char *uuid); -virDomainObj *virDomainObjListFindByName(virDomainObjList *doms, - const char *name); +virDomainObjList * +virDomainObjListNew(void); + +virDomainObj * +virDomainObjListFindByID(virDomainObjList *doms, + int id); +virDomainObj * +virDomainObjListFindByUUID(virDomainObjList *doms, + const unsigned char *uuid); +virDomainObj * +virDomainObjListFindByName(virDomainObjList *doms, + const char *name); enum { VIR_DOMAIN_OBJ_LIST_ADD_LIVE =3D (1 << 0), VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE =3D (1 << 1), }; -virDomainObj *virDomainObjListAdd(virDomainObjList *doms, - virDomainDef **def, - virDomainXMLOption *xmlopt, - unsigned int flags, - virDomainDef **oldDef); +virDomainObj * +virDomainObjListAdd(virDomainObjList *doms, + virDomainDef **def, + virDomainXMLOption *xmlopt, + unsigned int flags, + virDomainDef **oldDef); typedef int (*virDomainObjListRenameCallback)(virDomainObj *dom, const char *new_name, unsigned int flags, void *opaque); -int virDomainObjListRename(virDomainObjList *doms, - virDomainObj *dom, - const char *new_name, - unsigned int flags, - virDomainObjListRenameCallback callback, - void *opaque); - -void virDomainObjListRemove(virDomainObjList *doms, - virDomainObj *dom); -void virDomainObjListRemoveLocked(virDomainObjList *doms, - virDomainObj *dom); - -int virDomainObjListLoadAllConfigs(virDomainObjList *doms, - const char *configDir, - const char *autostartDir, - bool liveStatus, - virDomainXMLOption *xmlopt, - virDomainLoadConfigNotify notify, - void *opaque); - -int virDomainObjListNumOfDomains(virDomainObjList *doms, - bool active, - virDomainObjListACLFilter filter, - virConnectPtr conn); - -int virDomainObjListGetActiveIDs(virDomainObjList *doms, - int *ids, - int maxids, +int +virDomainObjListRename(virDomainObjList *doms, + virDomainObj *dom, + const char *new_name, + unsigned int flags, + virDomainObjListRenameCallback callback, + void *opaque); + +void +virDomainObjListRemove(virDomainObjList *doms, + virDomainObj *dom); +void +virDomainObjListRemoveLocked(virDomainObjList *doms, + virDomainObj *dom); + +int +virDomainObjListLoadAllConfigs(virDomainObjList *doms, + const char *configDir, + const char *autostartDir, + bool liveStatus, + virDomainXMLOption *xmlopt, + virDomainLoadConfigNotify notify, + void *opaque); + +int +virDomainObjListNumOfDomains(virDomainObjList *doms, + bool active, + virDomainObjListACLFilter filter, + virConnectPtr conn); + +int +virDomainObjListGetActiveIDs(virDomainObjList *doms, + int *ids, + int maxids, + virDomainObjListACLFilter filter, + virConnectPtr conn); +int +virDomainObjListGetInactiveNames(virDomainObjList *doms, + char **const names, + int maxnames, virDomainObjListACLFilter filter, virConnectPtr conn); -int virDomainObjListGetInactiveNames(virDomainObjList *doms, - char **const names, - int maxnames, - virDomainObjListACLFilter filter, - virConnectPtr conn); typedef int (*virDomainObjListIterator)(virDomainObj *dom, void *opaque); -int virDomainObjListForEach(virDomainObjList *doms, - bool modify, - virDomainObjListIterator callback, - void *opaque); +int +virDomainObjListForEach(virDomainObjList *doms, + bool modify, + virDomainObjListIterator callback, + void *opaque); #define VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE \ (VIR_CONNECT_LIST_DOMAINS_ACTIVE | \ @@ -132,23 +145,26 @@ int virDomainObjListForEach(virDomainObjList *doms, VIR_CONNECT_LIST_DOMAINS_FILTERS_SNAPSHOT | \ VIR_CONNECT_LIST_DOMAINS_FILTERS_CHECKPOINT) -int virDomainObjListCollect(virDomainObjList *doms, - virConnectPtr conn, - virDomainObj ***vms, - size_t *nvms, - virDomainObjListACLFilter filter, - unsigned int flags); -int virDomainObjListExport(virDomainObjList *doms, - virConnectPtr conn, - virDomainPtr **domains, - virDomainObjListACLFilter filter, - unsigned int flags); -int virDomainObjListConvert(virDomainObjList *domlist, - virConnectPtr conn, - virDomainPtr *doms, - size_t ndoms, - virDomainObj ***vms, - size_t *nvms, - virDomainObjListACLFilter filter, - unsigned int flags, - bool skip_missing); +int +virDomainObjListCollect(virDomainObjList *doms, + virConnectPtr conn, + virDomainObj ***vms, + size_t *nvms, + virDomainObjListACLFilter filter, + unsigned int flags); +int +virDomainObjListExport(virDomainObjList *doms, + virConnectPtr conn, + virDomainPtr **domains, + virDomainObjListACLFilter filter, + unsigned int flags); +int +virDomainObjListConvert(virDomainObjList *domlist, + virConnectPtr conn, + virDomainPtr *doms, + size_t ndoms, + virDomainObj ***vms, + size_t *nvms, + virDomainObjListACLFilter filter, + unsigned int flags, + bool skip_missing); --=20 2.38.1 From nobody Sat May 18 04:46:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672936253; cv=none; d=zohomail.com; s=zohoarc; b=i7mTE6l2IyqeWx/7IoO574vE1vF5BdHFa3LVuVnfP0nkzAIj1xz504eZ+m/z+IbkS9IR6vwrKr7byVlFCN96U0RcHXjuG9PocMeB4KKrWLbyzqFommrhxUQAw37fmJo944szY9SiC3/4uZgJnRrHoYe6P/18zVMUcaiddKZ3UNc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672936253; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uKLe9krqt+NTshl4QVi6cPIiOwphCiTBHUsrUw/13cg=; b=k5F7j/6NnrGw6a7QTDuQcJtsOKHzp30X1Huy/sBZ/36gDLst6LzCui3tYxEe5lNYIgXjF2oLsdTi6j7C6Iz7a9+TBa3Va0mCPcVZjIGaiGm7UPg/zA0GC/o48bJ+keqg6oW17pcKX9oh0K1iSYW6IoVo25NWwV38iONnmsRFOtM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1672936253785776.3962934815871; Thu, 5 Jan 2023 08:30:53 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-38-M63YMqOxP7GkQBzbrEyOpQ-1; Thu, 05 Jan 2023 11:30:35 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 71BD129AA3BE; Thu, 5 Jan 2023 16:30:33 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B09B4085722; Thu, 5 Jan 2023 16:30:33 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4178D19465A0; Thu, 5 Jan 2023 16:30:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2A93A1946589 for ; Thu, 5 Jan 2023 16:30:32 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0C8092166B31; Thu, 5 Jan 2023 16:30:32 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4655C2166B30 for ; Thu, 5 Jan 2023 16:30:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672936252; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=uKLe9krqt+NTshl4QVi6cPIiOwphCiTBHUsrUw/13cg=; b=Cuo8lcb/lCVARNbt8a2TbGBxj2jYq9xeuhH8VIaXjezlW0ES1saYzOIbHVBFrHPq2toaUK bg0lSdhyXcHfEp0Eml91ObrxIl4xz4cnswnbDXKhc9YhLV21mBP6FpLmcYcmk02PkSR8CR MgCGKUwPSaM3+nBpdVv0QbTxhJMWTnI= X-MC-Unique: M63YMqOxP7GkQBzbrEyOpQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/36] conf: virdomainobjlist: Introduce 'virDomainObjListCollectAll' Date: Thu, 5 Jan 2023 17:29:53 +0100 Message-Id: <2be6280256a10edc4071ad6431e87b537e332090.1672935969.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672936255538100003 Content-Type: text/plain; charset="utf-8" Introduce a helper which will return a list of all domain objects inside of the list without filtering and thus without the need to lock individual members. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: Pavel Hrdina --- src/conf/virdomainobjlist.c | 32 ++++++++++++++++++++------------ src/conf/virdomainobjlist.h | 4 ++++ src/libvirt_private.syms | 1 + 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index 2569454ff8..4968dfcf3e 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -913,6 +913,24 @@ virDomainObjListCollectIterator(void *payload, } +void +virDomainObjListCollectAll(virDomainObjList *domlist, + virDomainObj ***vms, + size_t *nvms) +{ + struct virDomainListData data =3D { NULL, 0 }; + + virObjectRWLockRead(domlist); + data.vms =3D g_new0(virDomainObj *, virHashSize(domlist->objs)); + + virHashForEach(domlist->objs, virDomainObjListCollectIterator, &data); + virObjectRWUnlock(domlist); + + *nvms =3D data.nvms; + *vms =3D data.vms; +} + + static void virDomainObjListFilter(virDomainObj ***list, size_t *nvms, @@ -954,18 +972,8 @@ virDomainObjListCollect(virDomainObjList *domlist, virDomainObjListACLFilter filter, unsigned int flags) { - struct virDomainListData data =3D { NULL, 0 }; - - virObjectRWLockRead(domlist); - data.vms =3D g_new0(virDomainObj *, virHashSize(domlist->objs)); - - virHashForEach(domlist->objs, virDomainObjListCollectIterator, &data); - virObjectRWUnlock(domlist); - - virDomainObjListFilter(&data.vms, &data.nvms, conn, filter, flags); - - *nvms =3D data.nvms; - *vms =3D data.vms; + virDomainObjListCollectAll(domlist, vms, nvms); + virDomainObjListFilter(vms, nvms, conn, filter, flags); return 0; } diff --git a/src/conf/virdomainobjlist.h b/src/conf/virdomainobjlist.h index cfa165d56f..8c53680374 100644 --- a/src/conf/virdomainobjlist.h +++ b/src/conf/virdomainobjlist.h @@ -145,6 +145,10 @@ virDomainObjListForEach(virDomainObjList *doms, VIR_CONNECT_LIST_DOMAINS_FILTERS_SNAPSHOT | \ VIR_CONNECT_LIST_DOMAINS_FILTERS_CHECKPOINT) +void +virDomainObjListCollectAll(virDomainObjList *domlist, + virDomainObj ***vms, + size_t *nvms); int virDomainObjListCollect(virDomainObjList *doms, virConnectPtr conn, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ae746a2d51..54a3859604 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1209,6 +1209,7 @@ virDomainMomentObjNew; # conf/virdomainobjlist.h virDomainObjListAdd; virDomainObjListCollect; +virDomainObjListCollectAll; virDomainObjListConvert; virDomainObjListExport; virDomainObjListFindByID; --=20 2.38.1 From nobody Sat May 18 04:46:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672936245; cv=none; d=zohomail.com; s=zohoarc; b=Cfa9TLvPJFlWn5t0ByHOgnc2uMMgb7rVRa+mdWqCtnx41qphdlDymxdDWDUD/jO1QsBpkGlq57Jl7ajkCVoJbdnu0HOU5Z4C1jXmZy98QWNH9Ly6T7IFccZO7K/iFLq5fxL58veI5u9cXWfCo5OOyppXqXTbi5Te8+70t+0Wq+E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672936245; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=C8R8+qxsbFmLkJRN08eaD3IZ7s+rv7DSOE4Ewsaa7Ks=; b=CCINllhOfcAKMEZn9FOD1u5Cazmkl/aa6jBRKvuN69kR0Cr21FhRZkgrHn3ol507RpLzmi31xAE0N/lvyOJIQJ7GwmspCn18RTfTO0vBr4dZmigERHQbaHGsFMDFXoA9Lk/TdmX8J2bsmMAWTYyL/+X4vg2dZ7TwrIrwk1+OThI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1672936245966999.9793815339315; Thu, 5 Jan 2023 08:30:45 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-463-XaeAO62RNBOZtCK18ZqU5A-1; Thu, 05 Jan 2023 11:30:38 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DC31A86C164; Thu, 5 Jan 2023 16:30:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C87061121315; Thu, 5 Jan 2023 16:30:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9232B1946A71; Thu, 5 Jan 2023 16:30:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5CB2D1946A72 for ; Thu, 5 Jan 2023 16:30:33 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4DDD02166B30; Thu, 5 Jan 2023 16:30:33 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id A456D2166B32 for ; Thu, 5 Jan 2023 16:30:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672936244; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=C8R8+qxsbFmLkJRN08eaD3IZ7s+rv7DSOE4Ewsaa7Ks=; b=P4yjdb/4ey8mAPS45UwNviiV2SkbUn7zvNV9kEMCnYt2VLM6yGRZ2npELaTf4AuG4D8qLX Vd/ksqGzN+jU/IH3q9PuBGd1kUdS6Hs+7T2FrKcCEWgHrME/0/qR6EwMFfndjeN1Okflb0 eVfS0ajzqdtraa6z5IWtFErz9Hfiat8= X-MC-Unique: XaeAO62RNBOZtCK18ZqU5A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/36] conf: virdomainobjlist: Remove return value from virDomainObjListCollect Date: Thu, 5 Jan 2023 17:29:54 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672936247479100003 Content-Type: text/plain; charset="utf-8" The function can't fail so there's no point in returning anything. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: Pavel Hrdina --- src/conf/virdomainobjlist.c | 7 ++----- src/conf/virdomainobjlist.h | 2 +- src/qemu/qemu_driver.c | 7 +++---- src/test/test_driver.c | 4 +--- src/vz/vz_driver.c | 7 +++---- 5 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index 4968dfcf3e..13675acda5 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -964,7 +964,7 @@ virDomainObjListFilter(virDomainObj ***list, } -int +void virDomainObjListCollect(virDomainObjList *domlist, virConnectPtr conn, virDomainObj ***vms, @@ -974,8 +974,6 @@ virDomainObjListCollect(virDomainObjList *domlist, { virDomainObjListCollectAll(domlist, vms, nvms); virDomainObjListFilter(vms, nvms, conn, filter, flags); - - return 0; } @@ -1046,8 +1044,7 @@ virDomainObjListExport(virDomainObjList *domlist, size_t i; int ret =3D -1; - if (virDomainObjListCollect(domlist, conn, &vms, &nvms, filter, flags)= < 0) - return -1; + virDomainObjListCollect(domlist, conn, &vms, &nvms, filter, flags); if (domains) { doms =3D g_new0(virDomainPtr, nvms + 1); diff --git a/src/conf/virdomainobjlist.h b/src/conf/virdomainobjlist.h index 8c53680374..058f2c4ca6 100644 --- a/src/conf/virdomainobjlist.h +++ b/src/conf/virdomainobjlist.h @@ -149,7 +149,7 @@ void virDomainObjListCollectAll(virDomainObjList *domlist, virDomainObj ***vms, size_t *nvms); -int +void virDomainObjListCollect(virDomainObjList *doms, virConnectPtr conn, virDomainObj ***vms, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d509582719..1b3da86c81 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18665,10 +18665,9 @@ qemuConnectGetAllDomainStats(virConnectPtr conn, lflags, true) < 0) return -1; } else { - if (virDomainObjListCollect(driver->domains, conn, &vms, &nvms, - virConnectGetAllDomainStatsCheckACL, - lflags) < 0) - return -1; + virDomainObjListCollect(driver->domains, conn, &vms, &nvms, + virConnectGetAllDomainStatsCheckACL, + lflags); } tmpstats =3D g_new0(virDomainStatsRecordPtr, nvms + 1); diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 6c21c6bcb4..bd6f063a00 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9923,9 +9923,7 @@ testConnectGetAllDomainStats(virConnectPtr conn, &nvms, NULL, lflags, true) < 0) return -1; } else { - if (virDomainObjListCollect(driver->domains, conn, &vms, &nvms, - NULL, lflags) < 0) - return -1; + virDomainObjListCollect(driver->domains, conn, &vms, &nvms, NULL, = lflags); } tmpstats =3D g_new0(virDomainStatsRecordPtr, nvms + 1); diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index d5147a6c0d..327704b375 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -3771,10 +3771,9 @@ vzConnectGetAllDomainStats(virConnectPtr conn, lflags, true) < 0) return -1; } else { - if (virDomainObjListCollect(driver->domains, conn, &doms, &ndoms, - virConnectGetAllDomainStatsCheckACL, - lflags) < 0) - return -1; + virDomainObjListCollect(driver->domains, conn, &doms, &ndoms, + virConnectGetAllDomainStatsCheckACL, + lflags); } tmpstats =3D g_new0(virDomainStatsRecordPtr, ndoms + 1); --=20 2.38.1 From nobody Sat May 18 04:46:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672936243; cv=none; d=zohomail.com; s=zohoarc; b=bstXwZt6213ezJyqUn8u6PZLLmA5xuB78nVFITbuIf6sCgiq2Atfh0nfEQRa3rk8DKyXoDBE9Dm+Gw9kZlJySu4naIIxnPu16qCP1Vhxjt4aIHggWmbIZyosoAcLNYQLhOpPcK+m9/Dyt94PSd3nYGCcEkn3LZ6m23ndsColHf0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672936243; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KmRR5jhR0gULznHWFHlEts4QAor8cOGF+Za3p3NGvFI=; b=cpzZUthZH+bkq34xSyqhLcwa/aM1BfpSTbS1P/kSab1hFZtKJ7I4G6191KxhQ3BtjUG2v+AwoXh4lzqSaoG8/tH5Dhbgwe0QFzM4UrC+IhGcXccbcpBmPdZqAhlQBBeMLDBgUErMFDmDrQLLEXvVmiM37sa/UATbpfr/Snp8G/o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1672936243923639.3876591732557; Thu, 5 Jan 2023 08:30:43 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-107-3HUprwRkM6imdyXwAIaYhw-1; Thu, 05 Jan 2023 11:30:38 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C39108030CB; Thu, 5 Jan 2023 16:30:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB46553A0; Thu, 5 Jan 2023 16:30:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9A37D1946A70; Thu, 5 Jan 2023 16:30:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9FFE01946A7A for ; Thu, 5 Jan 2023 16:30:34 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 90F6D2166B30; Thu, 5 Jan 2023 16:30:34 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id C19592166B33 for ; Thu, 5 Jan 2023 16:30:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672936242; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=KmRR5jhR0gULznHWFHlEts4QAor8cOGF+Za3p3NGvFI=; b=SSwP+4DUFXQjRBwAa00LZ44mLEELY3exqks0/3OOwoNpLoZ2N2mHCbPQwveWkqkQwcSvbk jr4W69VMfKTO3a20MAXk2Q5898NPjGr8NHgIZ8zo2ufUcEW9d6w8x9knO7sL4ncVdocQtm 8aerHyA30IjwtClleFXC3Gu8nnNpdVU= X-MC-Unique: 3HUprwRkM6imdyXwAIaYhw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/36] conf: domain: Add helper infrastructure for new connection close callbacks Date: Thu, 5 Jan 2023 17:29:55 +0100 Message-Id: <5f42c7d359466ee78da093547d82b1594a4d6253.1672935969.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672936245480100001 Content-Type: text/plain; charset="utf-8" The new connect close callbacks for domains will be represented by a virObject associated with the domain object itself. To simplify handling the pointer to the close callback data will be done by an immutable pointer allocated directly when allocating the corresponding virDomainObj struct. This patch adds the 'closecallbacks' field to virDomainObj and a corresponding callback to allocate it into virDomainXMLOption. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/conf/domain_conf.c | 13 +++++++++++++ src/conf/domain_conf.h | 25 +++++++++++++++++++++++++ src/libvirt_private.syms | 1 + 3 files changed, 39 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6c088ff295..66189277fd 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1722,6 +1722,14 @@ virDomainXMLOptionGetSaveCookie(virDomainXMLOption *= xmlopt) } +void +virDomainXMLOptionSetCloseCallbackAlloc(virDomainXMLOption *xmlopt, + virDomainCloseCallbackDataAlloc cb) +{ + xmlopt->closecallbackAlloc =3D cb; +} + + void virDomainXMLOptionSetMomentPostParse(virDomainXMLOption *xmlopt, virDomainMomentPostParseCallback cb) @@ -3906,6 +3914,7 @@ static void virDomainObjDispose(void *obj) virDomainSnapshotObjListFree(dom->snapshots); virDomainCheckpointObjListFree(dom->checkpoints); virDomainJobObjFree(dom->job); + virObjectUnref(dom->closecallbacks); } virDomainObj * @@ -3932,6 +3941,10 @@ virDomainObjNew(virDomainXMLOption *xmlopt) domain->privateDataFreeFunc =3D xmlopt->privateData.free; } + if (xmlopt->closecallbackAlloc) { + domain->closecallbacks =3D (xmlopt->closecallbackAlloc)(); + } + if (!(domain->snapshots =3D virDomainSnapshotObjListNew())) goto error; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 1404c55053..33c4ff69dd 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3126,6 +3126,23 @@ struct _virDomainObj { void *privateData; void (*privateDataFreeFunc)(void *); + /* Connection close callbacks helper data + * + * Immutable pointer sharing lifetime of the virDomainObj. May be NULL= , if + * the hypervisor driver doesn't use close callbacks. + * + * The closecallbacks helper data may be accessed without holding the + * virDomainObj lock to check whether a connection being closed has a + * registered close callback. + * + * Otherwise virDomainObj must be held and acquired before the lock on= the + * closecallbacks data. + * + * The above rules ensure minimal lock contention when closing the + * connection while also allowing correct handling. + */ + virObject *closecallbacks; + int taint; size_t ndeprecations; char **deprecations; @@ -3304,6 +3321,11 @@ struct _virDomainJobObjConfig { unsigned int maxQueuedJobs; }; + +typedef virObject *(*virDomainCloseCallbackDataAlloc)(void); +void virDomainXMLOptionSetCloseCallbackAlloc(virDomainXMLOption *xmlopt, + virDomainCloseCallbackDataAll= oc cb); + virDomainXMLOption *virDomainXMLOptionNew(virDomainDefParserConfig *config, virDomainXMLPrivateDataCallbacks= *priv, virXMLNamespace *xmlns, @@ -3352,6 +3374,9 @@ struct _virDomainXMLOption { /* virDomainJobObj callbacks, private data callbacks and defaults */ virDomainJobObjConfig jobObjConfig; + + /* closecallback allocation callback */ + virDomainCloseCallbackDataAlloc closecallbackAlloc; }; G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainXMLOption, virObjectUnref); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 54a3859604..8f50f9fa1e 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -699,6 +699,7 @@ virDomainXenPassthroughModeTypeToString; virDomainXMLOptionGetNamespace; virDomainXMLOptionGetSaveCookie; virDomainXMLOptionNew; +virDomainXMLOptionSetCloseCallbackAlloc; virDomainXMLOptionSetMomentPostParse; --=20 2.38.1 From nobody Sat May 18 04:46:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672936266; cv=none; d=zohomail.com; s=zohoarc; b=b4dy839Yy2bVuzD59UnpjBTfNsRnUcYAWOyZeMOdhS+G8A2KF0ZnuT4lpq4A+Spk98sFrfIGPhbDILAeA1dse/uzP0SGeUgplxNWkCHmn129Tng3URinj5kvUxY1UXTq0X3R0wAp5mUpONhWI8uy9Eoijai2wiVrZTU/v3gpFEw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672936266; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fQX8DhhWnMO8vn2VmwhABdewRWK+dtkwrXPj/e+2+FM=; b=WBXFhX5uv7GOeOAeAkgweAW8LlatQC+hMdhIDMFBxIHeH4NkPqXMzEJ0FxkchZm3lNNaxKvxtV8sV/eGT2F2KUSmH/sf5Oj0J/Lywz8vdO1tL3+MlKsf/WlsnUP4J5mem68GLVow0kZPq+O8DZ17C/409ujunkzQoytUh8MQlp0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1672936266359491.82953876713395; Thu, 5 Jan 2023 08:31:06 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-594-jbTzu4GQPNScE_GwpL4Lhw-1; Thu, 05 Jan 2023 11:30:48 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7340585C6E4; Thu, 5 Jan 2023 16:30:41 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B946492B06; Thu, 5 Jan 2023 16:30:41 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 51E6E1946589; Thu, 5 Jan 2023 16:30:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CBE181946A7D for ; Thu, 5 Jan 2023 16:30:35 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B174C2166B33; Thu, 5 Jan 2023 16:30:35 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 130882166B32 for ; Thu, 5 Jan 2023 16:30:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672936264; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fQX8DhhWnMO8vn2VmwhABdewRWK+dtkwrXPj/e+2+FM=; b=Dg+fecd7MrpieYobfgAtUsk+M9QQOdExJMBNjQEf+MlFFMol6VwO2ydd+XyGjtAwUdvV2w KKIVBt2YYAFe7OCWyvVNIMRTUDNszsAwqwU32AMdZOnwbF0wQVtvYKVJM3KhZWD1WPqixv qKLFNDG7RACxGShxXdoQZZ04Rvl8a5Y= X-MC-Unique: jbTzu4GQPNScE_GwpL4Lhw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/36] virclosecallbacks: Add new close callbacks APIs Date: Thu, 5 Jan 2023 17:29:56 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672936267795100008 Content-Type: text/plain; charset="utf-8" The new APIs store the list of callbacks for a VM inside the virDomainObj and also allow registering multiple callbacks for a single domain and also for multiple connections. For now this code is dormant until each driver using the old APIs is not refactored to use the new APIs. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/hypervisor/virclosecallbacks.c | 336 +++++++++++++++++++++++++++++ src/hypervisor/virclosecallbacks.h | 24 +++ src/libvirt_private.syms | 5 + 3 files changed, 365 insertions(+) diff --git a/src/hypervisor/virclosecallbacks.c b/src/hypervisor/vircloseca= llbacks.c index a08464438a..21b97cce12 100644 --- a/src/hypervisor/virclosecallbacks.c +++ b/src/hypervisor/virclosecallbacks.c @@ -310,3 +310,339 @@ virCloseCallbacksRun(virCloseCallbacks *closeCallback= s, VIR_FREE(list->entries); VIR_FREE(list); } + + +struct _virCloseCallbacksDomainData { + virConnectPtr conn; + virCloseCallback cb; +}; +typedef struct _virCloseCallbacksDomainData virCloseCallbacksDomainData; + + +static void +virCloseCallbacksDomainDataFree(virCloseCallbacksDomainData* data) +{ + g_free(data); +} +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCloseCallbacksDomainData, virCloseCallbac= ksDomainDataFree); + + +virClass *virCloseCallbacksDomainListClass; + +struct _virCloseCallbacksDomainList { + virObjectLockable parent; + + GList *callbacks; +}; +typedef struct _virCloseCallbacksDomainList virCloseCallbacksDomainList; + + +static void +virCloseCallbacksDomainListDispose(void *obj G_GNUC_UNUSED) +{ + virCloseCallbacksDomainList *cc =3D obj; + + g_list_free_full(cc->callbacks, (GDestroyNotify) virCloseCallbacksDoma= inDataFree); +} + + +static int +virCloseCallbacksDomainListOnceInit(void) +{ + if (!(VIR_CLASS_NEW(virCloseCallbacksDomainList, virClassForObjectLock= able()))) + return -1; + + return 0; +} + +VIR_ONCE_GLOBAL_INIT(virCloseCallbacksDomainList); + + +/** + * virCloseCallbacksDomainAlloc: + * + * Allocates and returns a data structure for holding close callback data = in + * a virDomainObj. + */ +virObject * +virCloseCallbacksDomainAlloc(void) +{ + if (virCloseCallbacksDomainListInitialize() < 0) + abort(); + + return virObjectNew(virCloseCallbacksDomainListClass); +} + + +/** + * virCloseCallbacksDomainAdd: + * @vm: domain object + * @conn: pointer to the connection which should trigger the close callback + * @cb: pointer to the callback function + * + * Registers @cb as a connection close callback for the @conn connection w= ith + * the @vm domain. Duplicate registrations are ignored. + * + * Caller must hold lock on @vm. + */ +void +virCloseCallbacksDomainAdd(virDomainObj *vm, + virConnectPtr conn, + virCloseCallback cb) +{ + virCloseCallbacksDomainList *cc =3D (virCloseCallbacksDomainList *) vm= ->closecallbacks; + + if (!conn || !cb) + return; + + VIR_WITH_OBJECT_LOCK_GUARD(cc) { + virCloseCallbacksDomainData *data; + GList *n; + + for (n =3D cc->callbacks; n; n =3D n->next) { + data =3D n->data; + + if (data->cb =3D=3D cb && data->conn =3D=3D conn) + return; + } + + data =3D g_new0(virCloseCallbacksDomainData, 1); + data->conn =3D conn; + data->cb =3D cb; + + cc->callbacks =3D g_list_prepend(cc->callbacks, data); + } +} + + +/** + * virCloseCallbacksDomainMatch: + * @data: pointer to a close callback data structure + * @conn: connection pointer matched against @data + * @cb: callback pointer matched against @data + * + * Returns true if the @data callback structure matches the requested @conn + * and/or @cb parameters. If either of @conn/@cb is NULL it is interpreted= as + * a wildcard. + */ +static bool +virCloseCallbacksDomainMatch(virCloseCallbacksDomainData *data, + virConnectPtr conn, + virCloseCallback cb) +{ + if (conn && cb) + return data->conn =3D=3D conn && data->cb =3D=3D cb; + + if (conn) + return data->conn =3D=3D conn; + + if (cb) + return data->cb =3D=3D cb; + + return true; +} + + +/** + * virCloseCallbacksDomainIsRegistered: + * @vm: domain object + * @conn: connection pointer + * @cb: callback pointer + * + * Returns true if @vm has one or more matching (see virCloseCallbacksDoma= inMatch) + * callback(s) registered. Caller must hold lock on @vm. + */ +bool +virCloseCallbacksDomainIsRegistered(virDomainObj *vm, + virConnectPtr conn, + virCloseCallback cb) +{ + virCloseCallbacksDomainList *cc =3D (virCloseCallbacksDomainList *) vm= ->closecallbacks; + + VIR_WITH_OBJECT_LOCK_GUARD(cc) { + GList *n; + + for (n =3D cc->callbacks; n; n =3D n->next) { + virCloseCallbacksDomainData *data =3D n->data; + + if (virCloseCallbacksDomainMatch(data, conn, cb)) + return true; + } + } + + return false; +} + + +/** + * virCloseCallbacksDomainRemove: + * @vm: domain object + * @conn: connection pointer + * @cb: callback pointer + * + * Removes all the registered matching (see virCloseCallbacksDomainMatch) + * callbacks for @vm. Caller must hold lock on @vm. + */ +void +virCloseCallbacksDomainRemove(virDomainObj *vm, + virConnectPtr conn, + virCloseCallback cb) +{ + virCloseCallbacksDomainList *cc =3D (virCloseCallbacksDomainList *) vm= ->closecallbacks; + + VIR_WITH_OBJECT_LOCK_GUARD(cc) { + GList *n =3D cc->callbacks; + + while (n) { + GList *cur =3D n; + + n =3D n->next; + + if (virCloseCallbacksDomainMatch(cur->data, conn, cb)) { + cc->callbacks =3D g_list_remove_link(cc->callbacks, cur); + g_list_free_full(cur, (GDestroyNotify) virCloseCallbacksDo= mainDataFree); + } + } + } +} + + +/** + * virCloseCallbacksDomainFetchForConn: + * @vm: domain object + * @conn: pointer to connection being closed + * + * Fetches connection close callbacks for @conn from @vm. The fetched close + * callbacks are removed from the list of callbacks of @vm. This function + * must be called with lock on @vm held. Caller is responsible for freeing= the + * returned list. + */ +static GList * +virCloseCallbacksDomainFetchForConn(virDomainObj *vm, + virConnectPtr conn) +{ + virCloseCallbacksDomainList *cc =3D (virCloseCallbacksDomainList *) vm= ->closecallbacks; + GList *conncallbacks =3D NULL; + + VIR_WITH_OBJECT_LOCK_GUARD(cc) { + GList *n; + + for (n =3D cc->callbacks; n;) { + virCloseCallbacksDomainData *data =3D n->data; + GList *cur =3D n; + + n =3D n->next; + + if (data->conn =3D=3D conn) { + cc->callbacks =3D g_list_remove_link(cc->callbacks, cur); + conncallbacks =3D g_list_concat(cur, conncallbacks); + } + } + } + + return conncallbacks; +} + + +/** + * virCloseCallbacksDomainRun + * @vm: domain object + * @conn: pointer to connection being closed + * + * Fetches and sequentially calls all connection close callbacks for @conn= from + * @vm. This function must be called with lock on @vm held. + */ +static void +virCloseCallbacksDomainRun(virDomainObj *vm, + virConnectPtr conn) +{ + g_autolist(virCloseCallbacksDomainData) callbacks =3D NULL; + GList *n; + + callbacks =3D virCloseCallbacksDomainFetchForConn(vm, conn); + + for (n =3D callbacks; n; n =3D n->next) { + virCloseCallbacksDomainData *data =3D n->data; + + VIR_DEBUG("vm=3D'%s' cb=3D'%p'", vm->def->name, data->cb); + + (data->cb)(vm, conn); + } +} + + +/** + * virCloseCallbacksDomainHasCallbackForConn: + * @vm: domain object + * @conn: connection being closed + * + * Returns true if @vm has a callback registered for the @conn connection.= This + * function doesn't require a lock being held on @vm. + */ +static bool +virCloseCallbacksDomainHasCallbackForConn(virDomainObj *vm, + virConnectPtr conn) +{ + /* we can access vm->closecallbacks as it's a immutable pointer */ + virCloseCallbacksDomainList *cc =3D (virCloseCallbacksDomainList *) vm= ->closecallbacks; + + if (!cc) + return false; + + VIR_WITH_OBJECT_LOCK_GUARD(cc) { + GList *n; + + for (n =3D cc->callbacks; n; n =3D n->next) { + virCloseCallbacksDomainData *data =3D n->data; + + if (data->conn =3D=3D conn) + return true; + } + } + + return false; +} + + +/** + * virCloseCallbacksDomainRunForConn: + * @domains: domain list object + * @conn: connection being closed + * + * Finds all domains in @domains which registered one or more connection c= lose + * callbacks for @conn and calls the callbacks. This function is designed = to + * be called from virDrvConnectClose function of individual drivers. + * + * To minimize lock contention the function first fetches a list of all do= main + * objects, then checks whether a connect close callback is actually regis= tered + * for the domain object and just then acquires the lock on the VM object. + */ +void +virCloseCallbacksDomainRunForConn(virDomainObjList *domains, + virConnectPtr conn) +{ + virDomainObj **vms =3D NULL; + size_t nvms; + size_t i; + + VIR_DEBUG("conn=3D%p", conn); + + virDomainObjListCollectAll(domains, &vms, &nvms); + + for (i =3D 0; i < nvms; i++) { + virDomainObj *vm =3D vms[i]; + + if (!virCloseCallbacksDomainHasCallbackForConn(vm, conn)) + continue; + + VIR_WITH_OBJECT_LOCK_GUARD(vm) { + /* VIR_WITH_OBJECT_LOCK_GUARD is a for loop, so this break app= lies to that */ + if (vm->removing) + break; + + virCloseCallbacksDomainRun(vm, conn); + } + } + + virObjectListFreeCount(vms, nvms); +} diff --git a/src/hypervisor/virclosecallbacks.h b/src/hypervisor/vircloseca= llbacks.h index 7afb0e5640..b471f6b160 100644 --- a/src/hypervisor/virclosecallbacks.h +++ b/src/hypervisor/virclosecallbacks.h @@ -49,3 +49,27 @@ void virCloseCallbacksRun(virCloseCallbacks *closeCallbacks, virConnectPtr conn, virDomainObjList *domains); + +/* ---- */ + +virObject * +virCloseCallbacksDomainAlloc(void); + +void +virCloseCallbacksDomainAdd(virDomainObj *vm, + virConnectPtr conn, + virCloseCallback cb); + +void +virCloseCallbacksDomainRemove(virDomainObj *vm, + virConnectPtr conn, + virCloseCallback cb); + +bool +virCloseCallbacksDomainIsRegistered(virDomainObj *vm, + virConnectPtr conn, + virCloseCallback cb); + +void +virCloseCallbacksDomainRunForConn(virDomainObjList *domains, + virConnectPtr conn); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8f50f9fa1e..b1fa23729a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1607,6 +1607,11 @@ virDomainDriverSetupPersistentDefBlkioParams; # hypervisor/virclosecallbacks.h +virCloseCallbacksDomainAdd; +virCloseCallbacksDomainAlloc; +virCloseCallbacksDomainIsRegistered; +virCloseCallbacksDomainRemove; +virCloseCallbacksDomainRunForConn; virCloseCallbacksGet; virCloseCallbacksNew; virCloseCallbacksRun; --=20 2.38.1 From nobody Sat May 18 04:46:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672936246; cv=none; d=zohomail.com; s=zohoarc; b=V80Cirk6aPMTPwn/vvPaUr0WXLHwjduNh+ZYG2M3EcWmIcR0mIrj9loxg9UbpfhGHhDMpzdi83FoOTxuKLv1hg5Q8+liDzKR3ph86IFzSO3TmsX2HKrSzyGZnNdlp2l2spkjg+iV0WtiiT4IGYbJJUO+WMU5r7TNk6lBuvr8ONQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672936246; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9XF8tg2sIdsflclRXiVs5+0pBIDiaLQPWbflluIIERM=; b=MvkLv4f6uj5kU92pjpgV9qAWFNmj13gf9knABL9aQx7TfnD3QveO1VpSdVkJ7FB3Zi9vXbNp8B16cqnX+n9QnRkrGjiKsk1V7SqroRibSeBW+OVzKkyu7uADUWW7uzEtsCkycHL/uoUgYmuTLfP3Xezq9XYaWDH9m2K7kiACkA8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1672936246648655.6711389612565; Thu, 5 Jan 2023 08:30:46 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-401-GZ_vNnR1NnuHJygpVicgOA-1; Thu, 05 Jan 2023 11:30:42 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1EFC385C6EF; Thu, 5 Jan 2023 16:30:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A4FDC15BA0; Thu, 5 Jan 2023 16:30:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D2A351946589; Thu, 5 Jan 2023 16:30:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 291271946589 for ; Thu, 5 Jan 2023 16:30:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0AB782166B30; Thu, 5 Jan 2023 16:30:37 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A0182166B35 for ; Thu, 5 Jan 2023 16:30:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672936245; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=9XF8tg2sIdsflclRXiVs5+0pBIDiaLQPWbflluIIERM=; b=UdCD1V1XGc7tW6BcvZrc3sWgg4NA6BvXXjgNWrjKS9Gd+d09XwELOz/BDRtA6cq992827f ftv2RIB91xyqxf6KF5zLI10iC/lXxMUhZEiKFSNw3MLtfE6nRvwy3xaV7x6E+xXFB+NESa ZayhL82VvCWRpY2mLXp1mfV+d4wfb+k= X-MC-Unique: GZ_vNnR1NnuHJygpVicgOA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/36] lxc: Use new connection close callbacks API Date: Thu, 5 Jan 2023 17:29:57 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672936247528100005 Content-Type: text/plain; charset="utf-8" The rewrite is straightforward as LXC registers only the 'lxcProcessAutoDestroy' callback which by design doesn't need any special handling (there's just one caller which can start the VM thus implicitly there's only one possible registration for that function). Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/lxc/lxc_conf.c | 15 +++++++++++---- src/lxc/lxc_conf.h | 3 --- src/lxc/lxc_driver.c | 8 ++------ src/lxc/lxc_process.c | 8 +++----- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index fefe63bf20..146e43c5d5 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -184,12 +184,19 @@ virCaps *virLXCDriverGetCapabilities(virLXCDriver *dr= iver, virDomainXMLOption * lxcDomainXMLConfInit(virLXCDriver *driver, const char *defsecmodel) { + virDomainXMLOption *ret =3D NULL; + virLXCDriverDomainDefParserConfig.priv =3D driver; virLXCDriverDomainDefParserConfig.defSecModel =3D defsecmodel; - return virDomainXMLOptionNew(&virLXCDriverDomainDefParserConfig, - &virLXCDriverPrivateDataCallbacks, - &virLXCDriverDomainXMLNamespace, - NULL, NULL, NULL); + + ret =3D virDomainXMLOptionNew(&virLXCDriverDomainDefParserConfig, + &virLXCDriverPrivateDataCallbacks, + &virLXCDriverDomainXMLNamespace, + NULL, NULL, NULL); + + virDomainXMLOptionSetCloseCallbackAlloc(ret, virCloseCallbacksDomainAl= loc); + + return ret; } diff --git a/src/lxc/lxc_conf.h b/src/lxc/lxc_conf.h index 6b9004aa3c..c0967ac63b 100644 --- a/src/lxc/lxc_conf.h +++ b/src/lxc/lxc_conf.h @@ -93,9 +93,6 @@ struct _virLXCDriver { /* Immutable pointer. self-locking APIs */ virSecurityManager *securityManager; - - /* Immutable pointer, self-locking APIs */ - virCloseCallbacks *closeCallbacks; }; G_DEFINE_AUTOPTR_CLEANUP_FUNC(virLXCDriverConfig, virObjectUnref); diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 5a16e7375e..f49964285b 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -161,7 +161,8 @@ static int lxcConnectClose(virConnectPtr conn) { virLXCDriver *driver =3D conn->privateData; - virCloseCallbacksRun(driver->closeCallbacks, conn, driver->domains); + virCloseCallbacksDomainRunForConn(driver->domains, conn); + conn->privateData =3D NULL; return 0; } @@ -1496,9 +1497,6 @@ static int lxcStateInitialize(bool privileged, if (!(lxc_driver->xmlopt =3D lxcDomainXMLConfInit(lxc_driver, defsecmo= del))) goto cleanup; - if (!(lxc_driver->closeCallbacks =3D virCloseCallbacksNew())) - goto cleanup; - if (g_mkdir_with_parents(cfg->stateDir, 0777) < 0) { virReportSystemError(errno, _("Failed to mkdir %s"), @@ -1586,8 +1584,6 @@ static int lxcStateCleanup(void) virObjectUnref(lxc_driver->domains); virObjectUnref(lxc_driver->domainEventState); - virObjectUnref(lxc_driver->closeCallbacks); - virSysinfoDefFree(lxc_driver->hostsysinfo); virObjectUnref(lxc_driver->hostdevMgr); diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 2a753ae1da..14fe60b074 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -188,7 +188,7 @@ static void virLXCProcessCleanup(virLXCDriver *driver, /* Stop autodestroy in case guest is restarted */ if (flags & VIR_LXC_PROCESS_CLEANUP_AUTODESTROY) { - virCloseCallbacksUnset(driver->closeCallbacks, vm, lxcProcessAutoD= estroy); + virCloseCallbacksDomainRemove(vm, NULL, lxcProcessAutoDestroy); } if (priv->monitor) { @@ -1504,10 +1504,8 @@ int virLXCProcessStart(virLXCDriver * driver, goto cleanup; } - if (autoDestroyConn && - virCloseCallbacksSet(driver->closeCallbacks, vm, - autoDestroyConn, lxcProcessAutoDestroy) < 0) - goto cleanup; + if (autoDestroyConn) + virCloseCallbacksDomainAdd(vm, autoDestroyConn, lxcProcessAutoDest= roy); /* We don't need the temporary NIC names anymore, clear them */ virLXCProcessCleanInterfaces(vm->def); --=20 2.38.1 From nobody Sat May 18 04:46:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672936247; cv=none; d=zohomail.com; s=zohoarc; b=QVqB89NSxBv5/O/aNimgSdgDx4ftDyVjBJB+ZyZhEUI+7pfY+xZIE2TyhXU8cASqPxW5r8RKBR9CfBhzSQEwDobmIiAiGD4aStGAIbImwMX0shZFuhGUKH/52U31zjaedVSrj8Azm332yL8RKroZgAio+B1px3iT98xq6IZ0lI8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672936247; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9095KkUQmX2uygc6hNGt+TTO4Or4c7KBuwH5G2XJThw=; b=DCMTNPeb+9SmZRQb8gsKIGO/e8HW8ECBtNUzYufuKiR1KPDTl0dSFpoqy3Q5yXBYvWJrb6l4gr8NkedgxT6gYn/P0xyCoNRG16CtodxTq6NLysL752B3/PT8ZMnpexTpf8B3JipaLK1C+5vwAejwo0mSYiOo/N9PFm9LzHYBbWE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 167293624700370.050251287337; Thu, 5 Jan 2023 08:30:47 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-246-1AE2MdruPcKdNlj11cH9vw-1; Thu, 05 Jan 2023 11:30:42 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 425D6381458F; Thu, 5 Jan 2023 16:30:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B6024015308; Thu, 5 Jan 2023 16:30:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 149C11946589; Thu, 5 Jan 2023 16:30:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 329CF1946586 for ; Thu, 5 Jan 2023 16:30:38 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2722C2166B32; Thu, 5 Jan 2023 16:30:38 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E04C2166B30 for ; Thu, 5 Jan 2023 16:30:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672936245; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=9095KkUQmX2uygc6hNGt+TTO4Or4c7KBuwH5G2XJThw=; b=C/WcRMV0V4ClGeSeUOinauEsAG+55O5VpAU7uqygVTVtISQ0tVpspdnAbW2j3YeFpig/YI xL/DZ3utNie6HqAAZmzHjXZ2LbVtz1yIJWA7nnerL/PpZVVSzsF39ypZYxQ89OwjnGSwEE 5HWFWvmi055J2Jz73gn8cOaulMjPmKw= X-MC-Unique: 1AE2MdruPcKdNlj11cH9vw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/36] bhyve: Use new connection close callbacks API Date: Thu, 5 Jan 2023 17:29:58 +0100 Message-Id: <38196e735068ecb16bd83a1e2518b98863d6c7ae.1672935969.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672936247518100004 Content-Type: text/plain; charset="utf-8" The rewrite is straightforward as bhyve registers only the 'bhyveProcessAutoDestroy' callback which by design doesn't need any special handling (there's just one caller which can start the VM thus implicitly there's only one possible registration for that function). Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/bhyve/bhyve_domain.c | 15 +++++++++++---- src/bhyve/bhyve_driver.c | 6 +----- src/bhyve/bhyve_process.c | 9 +++------ src/bhyve/bhyve_utils.h | 2 -- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c index b7b2db57b8..a1d1ebc706 100644 --- a/src/bhyve/bhyve_domain.c +++ b/src/bhyve/bhyve_domain.c @@ -217,11 +217,18 @@ bhyveDomainDefAssignAddresses(virDomainDef *def, virDomainXMLOption * virBhyveDriverCreateXMLConf(struct _bhyveConn *driver) { + virDomainXMLOption *ret =3D NULL; + virBhyveDriverDomainDefParserConfig.priv =3D driver; - return virDomainXMLOptionNew(&virBhyveDriverDomainDefParserConfig, - &virBhyveDriverPrivateDataCallbacks, - &virBhyveDriverDomainXMLNamespace, - NULL, NULL, NULL); + + ret =3D virDomainXMLOptionNew(&virBhyveDriverDomainDefParserConfig, + &virBhyveDriverPrivateDataCallbacks, + &virBhyveDriverDomainXMLNamespace, + NULL, NULL, NULL); + + virDomainXMLOptionSetCloseCallbackAlloc(ret, virCloseCallbacksDomainAl= loc); + + return ret; } diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index e0bf2a19a6..d100adeb8f 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -207,7 +207,7 @@ bhyveConnectClose(virConnectPtr conn) { struct _bhyveConn *privconn =3D conn->privateData; - virCloseCallbacksRun(privconn->closeCallbacks, conn, privconn->domains= ); + virCloseCallbacksDomainRunForConn(privconn->domains, conn); conn->privateData =3D NULL; return 0; @@ -1161,7 +1161,6 @@ bhyveStateCleanup(void) virObjectUnref(bhyve_driver->caps); virObjectUnref(bhyve_driver->xmlopt); virSysinfoDefFree(bhyve_driver->hostsysinfo); - virObjectUnref(bhyve_driver->closeCallbacks); virObjectUnref(bhyve_driver->domainEventState); virObjectUnref(bhyve_driver->config); virPortAllocatorRangeFree(bhyve_driver->remotePorts); @@ -1203,9 +1202,6 @@ bhyveStateInitialize(bool privileged, return VIR_DRV_STATE_INIT_ERROR; } - if (!(bhyve_driver->closeCallbacks =3D virCloseCallbacksNew())) - goto cleanup; - if (!(bhyve_driver->caps =3D virBhyveCapsBuild())) goto cleanup; diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c index d46786d393..eee0c4bf1d 100644 --- a/src/bhyve/bhyve_process.c +++ b/src/bhyve/bhyve_process.c @@ -268,10 +268,8 @@ virBhyveProcessStart(virConnectPtr conn, if (bhyveProcessStartHook(vm, VIR_HOOK_BHYVE_OP_PREPARE) < 0) return -1; - if (flags & VIR_BHYVE_PROCESS_START_AUTODESTROY && - virCloseCallbacksSet(driver->closeCallbacks, vm, - conn, bhyveProcessAutoDestroy) < 0) - return -1; + if (flags & VIR_BHYVE_PROCESS_START_AUTODESTROY) + virCloseCallbacksDomainAdd(vm, conn, bhyveProcessAutoDestroy); if (bhyveProcessPrepareDomain(driver, vm, flags) < 0) return -1; @@ -325,8 +323,7 @@ virBhyveProcessStop(struct _bhyveConn *driver, ret =3D 0; - virCloseCallbacksUnset(driver->closeCallbacks, vm, - bhyveProcessAutoDestroy); + virCloseCallbacksDomainRemove(vm, NULL, bhyveProcessAutoDestroy); virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, reason); vm->pid =3D 0; diff --git a/src/bhyve/bhyve_utils.h b/src/bhyve/bhyve_utils.h index 5d6e198b09..0680ae4cd1 100644 --- a/src/bhyve/bhyve_utils.h +++ b/src/bhyve/bhyve_utils.h @@ -59,8 +59,6 @@ struct _bhyveConn { virObjectEventState *domainEventState; - virCloseCallbacks *closeCallbacks; - virPortAllocatorRange *remotePorts; unsigned bhyvecaps; --=20 2.38.1 From nobody Sat May 18 04:46:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672936251; cv=none; d=zohomail.com; s=zohoarc; b=LFvsWvb31OOn9iItfpoUcEI1CfPOdU2Z05fonhVShQO2BqyJPmlkY9hFYV3/iz2kuVJutNJUxx0hNA6LlcLGPD1pOd0RoP5ETUX5c1VxLQAlYxXG5JUBCrFs5GGLgmHdWrIPYjNr5opjYrpYdyFl5L/1IjeFO2pydPllH1k6eA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672936251; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sQGwlf9ZRLteVig0TW33q9pXL9QesQaEXkTt+OHnUwg=; b=GV+QEQSj5en61D4eXxFT/G3c92zCCs2f+jp28dJqhE4x+yAxeP17fK2cA+is+vnoMr80Ag5Z9TmvPEsZMnwRUHePd95R90pxumpWEFlAxNnRiCD4r+G1Y2N5AlrW36EV6f1MXXQ84dMXjNG/KBAFvLbpQNJfXNXHpz/pEfqDMJY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1672936251936273.82149997542604; Thu, 5 Jan 2023 08:30:51 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-518-zbOR80JhOO2AogNA-kib8Q-1; Thu, 05 Jan 2023 11:30:47 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F3D7C802D1A; Thu, 5 Jan 2023 16:30:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFC7E40C1141; Thu, 5 Jan 2023 16:30:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D66911946589; Thu, 5 Jan 2023 16:30:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 485CB1946A71 for ; Thu, 5 Jan 2023 16:30:39 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3927D2166B31; Thu, 5 Jan 2023 16:30:39 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 801C52166B30 for ; Thu, 5 Jan 2023 16:30:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672936250; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=sQGwlf9ZRLteVig0TW33q9pXL9QesQaEXkTt+OHnUwg=; b=G+2c4jVLIqu/WG3+L+RyPseWAJMbFQVCrZOjlX2DiGeqySbFw4XDXGvhWkqMFpX8b5ZLKi 4C3p+O8DKwaH73xj4A9+lB/AYDAYzv+fe3hTMh1opxjPW2HsqjlEF+dKnBdDVfyRBkLZEn eCVX+E3IDiURHKgsGZFwZ5PVBcT/cdA= X-MC-Unique: zbOR80JhOO2AogNA-kib8Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/36] qemu: Use new connection close callbacks API Date: Thu, 5 Jan 2023 17:29:59 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672936253533100001 Content-Type: text/plain; charset="utf-8" The qemu driver uses connection close callbacks in more places requiring more changes than other drivers, but luckily the changes are very straightforward. The migration code was written in a way ensuring that there's just one callback present so this can be preserved directly. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/qemu/qemu_conf.c | 17 +++++++++----- src/qemu/qemu_conf.h | 3 --- src/qemu/qemu_driver.c | 8 +------ src/qemu/qemu_migration.c | 47 +++++++++++++-------------------------- src/qemu/qemu_process.c | 35 ++++------------------------- src/qemu/qemu_process.h | 11 ++------- 6 files changed, 34 insertions(+), 87 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index ae5bbcd138..0f10c5bf93 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1311,17 +1311,22 @@ virQEMUDriverCreateXMLConf(virQEMUDriver *driver, const char *defsecmodel) { g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + virDomainXMLOption *ret =3D NULL; virQEMUDriverDomainDefParserConfig.priv =3D driver; virQEMUDriverDomainDefParserConfig.defSecModel =3D defsecmodel; virQEMUDriverDomainJobConfig.maxQueuedJobs =3D cfg->maxQueuedJobs; - return virDomainXMLOptionNew(&virQEMUDriverDomainDefParserConfig, - &virQEMUDriverPrivateDataCallbacks, - &virQEMUDriverDomainXMLNamespace, - &virQEMUDriverDomainABIStability, - &virQEMUDriverDomainSaveCookie, - &virQEMUDriverDomainJobConfig); + ret =3D virDomainXMLOptionNew(&virQEMUDriverDomainDefParserConfig, + &virQEMUDriverPrivateDataCallbacks, + &virQEMUDriverDomainXMLNamespace, + &virQEMUDriverDomainABIStability, + &virQEMUDriverDomainSaveCookie, + &virQEMUDriverDomainJobConfig); + + virDomainXMLOptionSetCloseCallbackAlloc(ret, virCloseCallbacksDomainAl= loc); + + return ret; } diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 8cf2dd2ec5..b7ed00ca41 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -314,9 +314,6 @@ struct _virQEMUDriver { /* Immutable pointer. lockless access */ virLockManagerPlugin *lockManager; - /* Immutable pointer, self-clocking APIs */ - virCloseCallbacks *closeCallbacks; - /* Immutable pointer, self-locking APIs */ virHashAtomic *migrationErrors; }; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1b3da86c81..bd8c907567 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -846,9 +846,6 @@ qemuStateInitialize(bool privileged, 0, S_IXGRP | S_IXOTH) < 0) goto error; - if (!(qemu_driver->closeCallbacks =3D virCloseCallbacksNew())) - goto error; - /* Get all the running persistent or transient configs first */ if (virDomainObjListLoadAllConfigs(qemu_driver->domains, cfg->stateDir, @@ -1053,7 +1050,6 @@ qemuStateCleanup(void) return -1; virObjectUnref(qemu_driver->migrationErrors); - virObjectUnref(qemu_driver->closeCallbacks); virLockManagerPluginUnref(qemu_driver->lockManager); virSysinfoDefFree(qemu_driver->hostsysinfo); virPortAllocatorRangeFree(qemu_driver->migrationPorts); @@ -1146,9 +1142,7 @@ static int qemuConnectClose(virConnectPtr conn) { virQEMUDriver *driver =3D conn->privateData; - /* Get rid of callbacks registered for this conn */ - virCloseCallbacksRun(driver->closeCallbacks, conn, driver->domains); - + virCloseCallbacksDomainRunForConn(driver->domains, conn); conn->privateData =3D NULL; return 0; diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index f4441d61ae..61a2bc39c4 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1371,7 +1371,7 @@ qemuDomainGetMigrationBlockers(virDomainObj *vm, * false otherwise. */ bool -qemuMigrationSrcIsAllowed(virQEMUDriver *driver, +qemuMigrationSrcIsAllowed(virQEMUDriver *driver G_GNUC_UNUSED, virDomainObj *vm, bool remote, int asyncJob, @@ -1437,7 +1437,7 @@ qemuMigrationSrcIsAllowed(virQEMUDriver *driver, return false; } - if (qemuProcessAutoDestroyActive(driver, vm)) { + if (virCloseCallbacksDomainIsRegistered(vm, NULL, qemuProcessA= utoDestroy)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("domain is marked for auto destroy"= )); return false; @@ -2735,7 +2735,7 @@ qemuMigrationSrcBeginResume(virDomainObj *vm, static char * qemuMigrationSrcBeginResumePhase(virConnectPtr conn, - virQEMUDriver *driver, + virQEMUDriver *driver G_GNUC_UNUSED, virDomainObj *vm, const char *xmlin, char **cookieout, @@ -2753,15 +2753,12 @@ qemuMigrationSrcBeginResumePhase(virConnectPtr conn, if (qemuMigrationJobStartPhase(vm, QEMU_MIGRATION_PHASE_BEGIN_RESUME) = < 0) return NULL; - virCloseCallbacksUnset(driver->closeCallbacks, vm, - qemuMigrationAnyConnectionClosed); + virCloseCallbacksDomainRemove(vm, NULL, qemuMigrationAnyConnectionClos= ed); qemuDomainCleanupRemove(vm, qemuProcessCleanupMigrationJob); xml =3D qemuMigrationSrcBeginResume(vm, xmlin, cookieout, cookieoutlen= , flags); - if (virCloseCallbacksSet(driver->closeCallbacks, vm, conn, - qemuMigrationAnyConnectionClosed) < 0) - g_clear_pointer(&xml, g_free); + virCloseCallbacksDomainAdd(vm, conn, qemuMigrationAnyConnectionClosed); if (!xml) ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); @@ -2837,9 +2834,7 @@ qemuMigrationSrcBegin(virConnectPtr conn, * This prevents any other APIs being invoked while migration is t= aking * place. */ - if (virCloseCallbacksSet(driver->closeCallbacks, vm, conn, - qemuMigrationAnyConnectionClosed) < 0) - goto endjob; + virCloseCallbacksDomainAdd(vm, conn, qemuMigrationAnyConnectionClo= sed); } ret =3D g_steal_pointer(&xml); @@ -3490,8 +3485,7 @@ qemuMigrationDstPrepareResume(virQEMUDriver *driver, QEMU_MIGRATION_COOKIE_CAPS) < 0) VIR_WARN("Unable to encode migration cookie"); - virCloseCallbacksSet(driver->closeCallbacks, vm, conn, - qemuMigrationAnyConnectionClosed); + virCloseCallbacksDomainAdd(vm, conn, qemuMigrationAnyConnectionClosed); if (autoPort) priv->migrationPort =3D port; @@ -4031,8 +4025,7 @@ qemuMigrationSrcConfirm(virQEMUDriver *driver, if (qemuMigrationJobStartPhase(vm, phase) < 0) goto cleanup; - virCloseCallbacksUnset(driver->closeCallbacks, vm, - qemuMigrationAnyConnectionClosed); + virCloseCallbacksDomainRemove(vm, NULL, qemuMigrationAnyConnectionClos= ed); qemuDomainCleanupRemove(vm, qemuProcessCleanupMigrationJob); ret =3D qemuMigrationSrcConfirmPhase(driver, vm, @@ -5285,8 +5278,7 @@ qemuMigrationSrcPerformResume(virQEMUDriver *driver, if (qemuMigrationJobStartPhase(vm, QEMU_MIGRATION_PHASE_PERFORM_RESUME= ) < 0) return -1; - virCloseCallbacksUnset(driver->closeCallbacks, vm, - qemuMigrationAnyConnectionClosed); + virCloseCallbacksDomainRemove(vm, NULL, qemuMigrationAnyConnectionClos= ed); qemuDomainCleanupRemove(vm, qemuProcessCleanupMigrationJob); ret =3D qemuMigrationSrcPerformNative(driver, vm, NULL, uri, @@ -5294,9 +5286,7 @@ qemuMigrationSrcPerformResume(virQEMUDriver *driver, cookieout, cookieoutlen, flags, 0, NULL, NULL, 0, NULL, migParams,= NULL); - if (virCloseCallbacksSet(driver->closeCallbacks, vm, conn, - qemuMigrationAnyConnectionClosed) < 0) - ret =3D -1; + virCloseCallbacksDomainAdd(vm, conn, qemuMigrationAnyConnectionClosed); if (ret < 0) ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); @@ -6034,8 +6024,7 @@ qemuMigrationSrcPerformJob(virQEMUDriver *driver, if (qemuMigrationJobStartPhase(vm, QEMU_MIGRATION_PHASE_BEGIN_RESU= ME) < 0) goto cleanup; - virCloseCallbacksUnset(driver->closeCallbacks, vm, - qemuMigrationAnyConnectionClosed); + virCloseCallbacksDomainRemove(vm, NULL, qemuMigrationAnyConnection= Closed); qemuDomainCleanupRemove(vm, qemuProcessCleanupMigrationJob); } else { if (qemuMigrationJobStart(vm, VIR_ASYNC_JOB_MIGRATION_OUT, @@ -6167,8 +6156,7 @@ qemuMigrationSrcPerformPhase(virQEMUDriver *driver, if (qemuMigrationJobStartPhase(vm, QEMU_MIGRATION_PHASE_PERFORM3) < 0) goto cleanup; - virCloseCallbacksUnset(driver->closeCallbacks, vm, - qemuMigrationAnyConnectionClosed); + virCloseCallbacksDomainRemove(vm, NULL, qemuMigrationAnyConnectionClos= ed); if (qemuMigrationSrcPerformNative(driver, vm, persist_xml, uri, cookie= in, cookieinlen, cookieout, cookieoutlen, @@ -6176,9 +6164,7 @@ qemuMigrationSrcPerformPhase(virQEMUDriver *driver, nmigrate_disks, migrate_disks, migPa= rams, nbdURI) < 0) goto cleanup; - if (virCloseCallbacksSet(driver->closeCallbacks, vm, conn, - qemuMigrationAnyConnectionClosed) < 0) - goto cleanup; + virCloseCallbacksDomainAdd(vm, conn, qemuMigrationAnyConnectionClosed); ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PERFORM= 3_DONE)); ret =3D 0; @@ -6434,7 +6420,7 @@ qemuMigrationDstComplete(virQEMUDriver *driver, * nothing to remove when we are resuming post-copy migration. */ if (job->phase < QEMU_MIGRATION_PHASE_POSTCOPY_FAILED) - qemuProcessAutoDestroyRemove(driver, vm); + virCloseCallbacksDomainRemove(vm, NULL, qemuProcessAutoDestroy); /* Remove completed stats for post-copy, everything but timing fields * is obsolete anyway. @@ -6727,7 +6713,7 @@ qemuMigrationDstFinishActive(virQEMUDriver *driver, if (virDomainObjIsFailedPostcopy(vm)) { ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); - qemuProcessAutoDestroyRemove(driver, vm); + virCloseCallbacksDomainRemove(vm, NULL, qemuProcessAutoDestroy); *finishJob =3D false; } else { qemuMigrationParamsReset(vm, VIR_ASYNC_JOB_MIGRATION_IN, @@ -6787,8 +6773,7 @@ qemuMigrationDstFinish(virQEMUDriver *driver, goto cleanup; if (flags & VIR_MIGRATE_POSTCOPY_RESUME) { - virCloseCallbacksUnset(driver->closeCallbacks, vm, - qemuMigrationAnyConnectionClosed); + virCloseCallbacksDomainRemove(vm, NULL, qemuMigrationAnyConnection= Closed); qemuDomainCleanupRemove(vm, qemuProcessCleanupMigrationJob); } else { qemuDomainCleanupRemove(vm, qemuMigrationDstPrepareCleanup); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b6adcf2f2a..fc4e58f95b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7901,9 +7901,8 @@ qemuProcessLaunch(virConnectPtr conn, qemuProcessRefreshBalloonState(vm, asyncJob) < 0) goto cleanup; - if (flags & VIR_QEMU_PROCESS_START_AUTODESTROY && - qemuProcessAutoDestroyAdd(driver, vm, conn) < 0) - goto cleanup; + if (flags & VIR_QEMU_PROCESS_START_AUTODESTROY) + virCloseCallbacksDomainAdd(vm, conn, qemuProcessAutoDestroy); if (!incoming && !snapshot) { VIR_DEBUG("Setting up transient disk"); @@ -8381,7 +8380,7 @@ void qemuProcessStop(virQEMUDriver *driver, virFileDeleteTree(priv->channelTargetDir); /* Stop autodestroy in case guest is restarted */ - qemuProcessAutoDestroyRemove(driver, vm); + virCloseCallbacksDomainRemove(vm, NULL, qemuProcessAutoDestroy); /* now that we know it's stopped call the hook if present */ if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) { @@ -8601,7 +8600,7 @@ void qemuProcessStop(virQEMUDriver *driver, } -static void +void qemuProcessAutoDestroy(virDomainObj *dom, virConnectPtr conn) { @@ -8641,32 +8640,6 @@ qemuProcessAutoDestroy(virDomainObj *dom, virObjectEventStateQueue(driver->domainEventState, event); } -int qemuProcessAutoDestroyAdd(virQEMUDriver *driver, - virDomainObj *vm, - virConnectPtr conn) -{ - VIR_DEBUG("vm=3D%s, conn=3D%p", vm->def->name, conn); - return virCloseCallbacksSet(driver->closeCallbacks, vm, conn, - qemuProcessAutoDestroy); -} - -int qemuProcessAutoDestroyRemove(virQEMUDriver *driver, - virDomainObj *vm) -{ - VIR_DEBUG("vm=3D%s", vm->def->name); - return virCloseCallbacksUnset(driver->closeCallbacks, vm, - qemuProcessAutoDestroy); -} - -bool qemuProcessAutoDestroyActive(virQEMUDriver *driver, - virDomainObj *vm) -{ - virCloseCallback cb; - VIR_DEBUG("vm=3D%s", vm->def->name); - cb =3D virCloseCallbacksGet(driver->closeCallbacks, vm, NULL); - return cb =3D=3D qemuProcessAutoDestroy; -} - int qemuProcessRefreshDisks(virDomainObj *vm, diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 9a24745f15..b171f0464c 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -168,15 +168,8 @@ int qemuProcessKill(virDomainObj *vm, unsigned int fla= gs); void qemuProcessShutdownOrReboot(virDomainObj *vm); -int qemuProcessAutoDestroyInit(virQEMUDriver *driver); -void qemuProcessAutoDestroyShutdown(virQEMUDriver *driver); -int qemuProcessAutoDestroyAdd(virQEMUDriver *driver, - virDomainObj *vm, - virConnectPtr conn); -int qemuProcessAutoDestroyRemove(virQEMUDriver *driver, - virDomainObj *vm); -bool qemuProcessAutoDestroyActive(virQEMUDriver *driver, - virDomainObj *vm); +void qemuProcessAutoDestroy(virDomainObj *dom, + virConnectPtr conn); int qemuProcessSetSchedParams(int id, pid_t pid, size_t nsp, virDomainThreadSchedParam *sp); --=20 2.38.1 From nobody Sat May 18 04:46:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672936340; cv=none; d=zohomail.com; s=zohoarc; b=W7J9Ap/r2/EG+NERz3wsKrpVIrhG2wnc5JlcoDibhrcPRidfBnm756uwpNNXaIR9myhr/fYgRvoFIpJX06WGWCM87vGWjjl77jCiaNwtexJ+MT5F9hs1GgrbakUIh1OW6Zj1kGq8g9Fs+5HB9yMct9umTxe6cfOHjpA37WOxp6s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672936340; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ncUwZi36O340Q0I4FuMhprDO4i9K5SFGIYILNVBWxrc=; b=FuOOYv3vZzcJRUDvu+ua1O68Qdv6EJdV5IZ/kInZ0Yi1fuMTtDNT9ZOll59au3IG9p0jcTxjtYIlDeq4P3ujKfQTeAe+ZPh1JsM8gQIQcPQ77aS/A5i7WffEVjdDdYmqYlWyrxfz3j4bByWjfalDrC2VQuD6MAqU53YEzbwtdU8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1672936340974976.936678147267; Thu, 5 Jan 2023 08:32:20 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-400-jB3nz7ecP-KUBt0Pj45IZw-1; Thu, 05 Jan 2023 11:30:52 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CBD64877CA4; Thu, 5 Jan 2023 16:30:41 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6143492B12; Thu, 5 Jan 2023 16:30:41 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 902191946A79; Thu, 5 Jan 2023 16:30:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5A9291946586 for ; Thu, 5 Jan 2023 16:30:40 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4C7CC2166B31; Thu, 5 Jan 2023 16:30:40 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E9102166B30 for ; Thu, 5 Jan 2023 16:30:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672936339; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ncUwZi36O340Q0I4FuMhprDO4i9K5SFGIYILNVBWxrc=; b=Z04c/VO0Xyae/JVKeCcAWj77dxYsgCBAJhWSAKU6Tm/4rMN0lE5FN+3xMOa3MTfaIzq7H/ YiuoJ8y1sG7h+gwnPYv90yHSnaorLP8B0j44k4wXjxNALlI+i/sfdosIteM4QKNTe1eSp/ 0PyFaGIDFq+ETweP97gdhG6XnGvFumY= X-MC-Unique: jB3nz7ecP-KUBt0Pj45IZw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/36] qemuMigrationSrcIsAllowed: Remove unused 'driver' argument Date: Thu, 5 Jan 2023 17:30:00 +0100 Message-Id: <1976d6bf147c09ccead42242e963e334d9f7b525.1672935969.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672936342920100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/qemu/qemu_driver.c | 4 ++-- src/qemu/qemu_migration.c | 8 +++----- src/qemu/qemu_migration.h | 3 +-- src/qemu/qemu_snapshot.c | 4 ++-- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index bd8c907567..37bdc81378 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2624,7 +2624,7 @@ qemuDomainSaveInternal(virQEMUDriver *driver, VIR_DOMAIN_JOB_OPERATION_SAVE, flags) < = 0) goto cleanup; - if (!qemuMigrationSrcIsAllowed(driver, vm, false, VIR_ASYNC_JOB_SAVE, = 0)) + if (!qemuMigrationSrcIsAllowed(vm, false, VIR_ASYNC_JOB_SAVE, 0)) goto endjob; if (!virDomainObjIsActive(vm)) { @@ -3129,7 +3129,7 @@ doCoreDump(virQEMUDriver *driver, goto cleanup; } - if (!qemuMigrationSrcIsAllowed(driver, vm, false, VIR_ASYNC_JOB_DU= MP, 0)) + if (!qemuMigrationSrcIsAllowed(vm, false, VIR_ASYNC_JOB_DUMP, 0)) goto cleanup; if (qemuMigrationSrcToFile(driver, vm, fd, compressor, diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 61a2bc39c4..a561e1bc63 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1358,7 +1358,6 @@ qemuDomainGetMigrationBlockers(virDomainObj *vm, /** * qemuMigrationSrcIsAllowed: - * @driver: qemu driver struct * @vm: domain object * @remote: migration is remote * @flags: migration flags (see struct virDomainMigrateFlags) @@ -1371,8 +1370,7 @@ qemuDomainGetMigrationBlockers(virDomainObj *vm, * false otherwise. */ bool -qemuMigrationSrcIsAllowed(virQEMUDriver *driver G_GNUC_UNUSED, - virDomainObj *vm, +qemuMigrationSrcIsAllowed(virDomainObj *vm, bool remote, int asyncJob, unsigned int flags) @@ -2546,7 +2544,7 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, qemuMigrationJobStartPhase(vm, QEMU_MIGRATION_PHASE_BEGIN3) < 0) return NULL; - if (!qemuMigrationSrcIsAllowed(driver, vm, true, vm->job->asyncJob, fl= ags)) + if (!qemuMigrationSrcIsAllowed(vm, true, vm->job->asyncJob, flags)) return NULL; if (!(flags & (VIR_MIGRATE_UNSAFE | VIR_MIGRATE_OFFLINE)) && @@ -6034,7 +6032,7 @@ qemuMigrationSrcPerformJob(virQEMUDriver *driver, if (!(flags & VIR_MIGRATE_OFFLINE) && virDomainObjCheckActive(vm) = < 0) goto endjob; - if (!qemuMigrationSrcIsAllowed(driver, vm, true, VIR_ASYNC_JOB_MIG= RATION_OUT, flags)) + if (!qemuMigrationSrcIsAllowed(vm, true, VIR_ASYNC_JOB_MIGRATION_O= UT, flags)) goto endjob; if (!(flags & (VIR_MIGRATE_UNSAFE | VIR_MIGRATE_OFFLINE)) && diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index 38a961f4e9..d21b6f67e8 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -226,8 +226,7 @@ qemuMigrationProcessUnattended(virQEMUDriver *driver, qemuMonitorMigrationStatus status); bool -qemuMigrationSrcIsAllowed(virQEMUDriver *driver, - virDomainObj *vm, +qemuMigrationSrcIsAllowed(virDomainObj *vm, bool remote, int asyncJob, unsigned int flags); diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index d7983c134f..8b5bcd9770 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -291,7 +291,7 @@ qemuSnapshotCreateActiveInternal(virQEMUDriver *driver, virDomainSnapshotDef *snapdef =3D virDomainSnapshotObjGetDef(snap); int ret =3D -1; - if (!qemuMigrationSrcIsAllowed(driver, vm, false, VIR_ASYNC_JOB_SNAPSH= OT, 0)) + if (!qemuMigrationSrcIsAllowed(vm, false, VIR_ASYNC_JOB_SNAPSHOT, 0)) goto cleanup; if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_RUNNING) { @@ -1331,7 +1331,7 @@ qemuSnapshotCreateActiveExternal(virQEMUDriver *drive= r, /* do the memory snapshot if necessary */ if (memory) { /* check if migration is possible */ - if (!qemuMigrationSrcIsAllowed(driver, vm, false, VIR_ASYNC_JOB_SN= APSHOT, 0)) + if (!qemuMigrationSrcIsAllowed(vm, false, VIR_ASYNC_JOB_SNAPSHOT, = 0)) goto cleanup; qemuDomainJobSetStatsType(vm->job->current, --=20 2.38.1 From nobody Sat May 18 04:46:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672936325; cv=none; d=zohomail.com; s=zohoarc; b=n1rD2F/6ZJwpHFriK6/Hg3mIwTceOXlOnBGqgl4ZQ5nZjgXt2s7LCIA51iV/ulRvpkeU9gHnOcihLPpzABsKZoooS4zASaTMCKTZ1gqku44liWFegPfzXCdDZjhCmZc7sanz7WWli2yuTe02Mnslfz8xYHwo4hwC7147JyNQ7C4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672936325; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YESk9sA7cjDz9IQlVMxOFU2JmnpLkxsx2JNOlzUOZK8=; b=Yxjx00B+pu3GbAEY7jVWgnyPxKwJ9Fyyvop3RcmCtKH0tus/xYgtVK/2WCt8Bcf1qHKyagWgL1eGz/xThr0gG2IzjaFssX+S8sVoSFVbVrrNytRoZG2Cv8z629rzula9SfvTOj/UprnvWxLQvyjjD4ttdDv8yVjPhp9TsRTMa+Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1672936325580258.58299587113345; Thu, 5 Jan 2023 08:32:05 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-284-7OgY0oZWP5uMQJ39aaSsbQ-1; Thu, 05 Jan 2023 11:30:59 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 44FB218E0044; Thu, 5 Jan 2023 16:30:43 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 328D7492D8B; Thu, 5 Jan 2023 16:30:43 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 28743194658C; Thu, 5 Jan 2023 16:30:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6726D19465A0 for ; Thu, 5 Jan 2023 16:30:41 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4CC882166B31; Thu, 5 Jan 2023 16:30:41 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id B1E852166B30 for ; Thu, 5 Jan 2023 16:30:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672936324; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=YESk9sA7cjDz9IQlVMxOFU2JmnpLkxsx2JNOlzUOZK8=; b=Nx0Qk0xhsIBtFZYsfku3bqRPJNodQg9eF9RoQFKI5S+ZeomES/LOVMiWOx3m3+1+L4r+o9 Va23+DHwDY5rykkh+Hvq3FS1px6tNt02uYUaT0168nTd1oTrNTpNgW28toOks9cTWRPYOq 83WO9ZcmXbids3yCfprpNJtdf61ix/0= X-MC-Unique: 7OgY0oZWP5uMQJ39aaSsbQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/36] qemuMigrationSrcBeginResumePhase: Remove unused 'driver' argument Date: Thu, 5 Jan 2023 17:30:01 +0100 Message-Id: <3eee6a8541cbb0859e96c57637d51930129f17e3.1672935969.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672936326856100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/qemu/qemu_migration.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index a561e1bc63..54626bd851 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2733,7 +2733,6 @@ qemuMigrationSrcBeginResume(virDomainObj *vm, static char * qemuMigrationSrcBeginResumePhase(virConnectPtr conn, - virQEMUDriver *driver G_GNUC_UNUSED, virDomainObj *vm, const char *xmlin, char **cookieout, @@ -2792,7 +2791,7 @@ qemuMigrationSrcBegin(virConnectPtr conn, } if (flags & VIR_MIGRATE_POSTCOPY_RESUME) { - ret =3D qemuMigrationSrcBeginResumePhase(conn, driver, vm, xmlin, + ret =3D qemuMigrationSrcBeginResumePhase(conn, vm, xmlin, cookieout, cookieoutlen, fl= ags); goto cleanup; } --=20 2.38.1 From nobody Sat May 18 04:46:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672936261; cv=none; d=zohomail.com; s=zohoarc; b=QVNyur2dN25G0drfolwtbcqzHhFtin+OI4mam3Z63PCs1NsDXCC5Eqsdc3YBB2014NeuV1j1oIljZ+jMFhckNR3G4pklIBksHqZ2AH2D4zDLT3fO+qGpN2OjU4E8VqcIql9HfoXMqJRAdRaTcFwHH/qssDbZ3iEbmJbxaS9FPdU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672936261; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=STFU0vDTcL1hVFRw5jUbkN3znSV4Bkad5q+L6qqzB9w=; b=af1PNkj8sFnOySuMnFV4GHYvqLpAmqs01LNWh0uy4vH40c9xXZaH8qib3Ekiubpyr90TndBW0lsz7hNrN9D/wZU4aOgUgFJKl6MjfV45wCO0xF0pzjB75en0HFERm+YkQ/X693038MNSrb+xU12xfXFuyVWQ8i9lBNLuNc5cIws= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1672936261730213.35449875191523; Thu, 5 Jan 2023 08:31:01 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-668-TD4gWdHnMdmdpjOg74ckoA-1; Thu, 05 Jan 2023 11:30:52 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BADA5100F911; Thu, 5 Jan 2023 16:30:43 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A38EB112131B; Thu, 5 Jan 2023 16:30:43 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 670971946A7A; Thu, 5 Jan 2023 16:30:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 78EE31946586 for ; Thu, 5 Jan 2023 16:30:42 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6E4322166B31; Thu, 5 Jan 2023 16:30:42 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA2FE2166B30 for ; Thu, 5 Jan 2023 16:30:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672936260; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=STFU0vDTcL1hVFRw5jUbkN3znSV4Bkad5q+L6qqzB9w=; b=HExdywubD/IYq4G1mxL01gwJkv4PGvGKBky8xJNtqPV/KbFOs1ZBDz4ZEXkkzljqGEPfBK J2VTByT/nDbftxnNElZfbAVkn9CJmhFt7MsDqVvRXguGMNWV3P1GyJD3Gl9aLPIa/aQUA+ 7rTZI+mdPM9agToOp1Am0ZrJ2rdaEmY= X-MC-Unique: TD4gWdHnMdmdpjOg74ckoA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/36] virclosecallbacks: Remove old close callbacks code Date: Thu, 5 Jan 2023 17:30:02 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672936263799100002 Content-Type: text/plain; charset="utf-8" Now that all code was refactored to use the new version we can remove the old code. For now the new close callbacks code has no error messages so syntax-check forced me to remove the POTFILES entry for virclosecallbacks.c Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- po/POTFILES | 1 - src/hypervisor/virclosecallbacks.c | 282 ----------------------------- src/hypervisor/virclosecallbacks.h | 27 --- src/libvirt_private.syms | 5 - 4 files changed, 315 deletions(-) diff --git a/po/POTFILES b/po/POTFILES index 169e2a41dc..b2297be84e 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -91,7 +91,6 @@ src/hyperv/hyperv_util.c src/hyperv/hyperv_wmi.c src/hypervisor/domain_cgroup.c src/hypervisor/domain_driver.c -src/hypervisor/virclosecallbacks.c src/hypervisor/virhostdev.c src/interface/interface_backend_netcf.c src/interface/interface_backend_udev.c diff --git a/src/hypervisor/virclosecallbacks.c b/src/hypervisor/vircloseca= llbacks.c index 21b97cce12..4fad4c8288 100644 --- a/src/hypervisor/virclosecallbacks.c +++ b/src/hypervisor/virclosecallbacks.c @@ -29,288 +29,6 @@ VIR_LOG_INIT("util.closecallbacks"); -typedef struct _virDriverCloseDef virDriverCloseDef; -struct _virDriverCloseDef { - virConnectPtr conn; - virCloseCallback cb; -}; - -struct _virCloseCallbacks { - virObjectLockable parent; - - /* UUID string to qemuDriverCloseDef mapping */ - GHashTable *list; -}; - - -static virClass *virCloseCallbacksClass; -static void virCloseCallbacksDispose(void *obj); - -static int virCloseCallbacksOnceInit(void) -{ - if (!VIR_CLASS_NEW(virCloseCallbacks, virClassForObjectLockable())) - return -1; - - return 0; -} - -VIR_ONCE_GLOBAL_INIT(virCloseCallbacks); - - -virCloseCallbacks * -virCloseCallbacksNew(void) -{ - virCloseCallbacks *closeCallbacks; - - if (virCloseCallbacksInitialize() < 0) - return NULL; - - if (!(closeCallbacks =3D virObjectLockableNew(virCloseCallbacksClass))) - return NULL; - - closeCallbacks->list =3D virHashNew(g_free); - - return closeCallbacks; -} - -static void -virCloseCallbacksDispose(void *obj) -{ - virCloseCallbacks *closeCallbacks =3D obj; - - g_clear_pointer(&closeCallbacks->list, g_hash_table_unref); -} - -int -virCloseCallbacksSet(virCloseCallbacks *closeCallbacks, - virDomainObj *vm, - virConnectPtr conn, - virCloseCallback cb) -{ - char uuidstr[VIR_UUID_STRING_BUFLEN]; - virDriverCloseDef *closeDef; - int ret =3D -1; - - virUUIDFormat(vm->def->uuid, uuidstr); - VIR_DEBUG("vm=3D%s, uuid=3D%s, conn=3D%p, cb=3D%p", - vm->def->name, uuidstr, conn, cb); - - virObjectLock(closeCallbacks); - - closeDef =3D virHashLookup(closeCallbacks->list, uuidstr); - if (closeDef) { - if (closeDef->conn !=3D conn) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Close callback for domain %s already registe= red" - " with another connection %p"), - vm->def->name, closeDef->conn); - goto cleanup; - } - if (closeDef->cb && closeDef->cb !=3D cb) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Another close callback is already defined fo= r" - " domain %s"), vm->def->name); - goto cleanup; - } - - closeDef->cb =3D cb; - } else { - closeDef =3D g_new0(virDriverCloseDef, 1); - closeDef->conn =3D conn; - closeDef->cb =3D cb; - if (virHashAddEntry(closeCallbacks->list, uuidstr, closeDef) < 0) { - VIR_FREE(closeDef); - goto cleanup; - } - virObjectRef(vm); - } - - virObjectRef(closeCallbacks); - ret =3D 0; - cleanup: - virObjectUnlock(closeCallbacks); - return ret; -} - -int -virCloseCallbacksUnset(virCloseCallbacks *closeCallbacks, - virDomainObj *vm, - virCloseCallback cb) -{ - char uuidstr[VIR_UUID_STRING_BUFLEN]; - virDriverCloseDef *closeDef; - int ret =3D -1; - - virUUIDFormat(vm->def->uuid, uuidstr); - VIR_DEBUG("vm=3D%s, uuid=3D%s, cb=3D%p", - vm->def->name, uuidstr, cb); - - virObjectLock(closeCallbacks); - - closeDef =3D virHashLookup(closeCallbacks->list, uuidstr); - if (!closeDef) - goto cleanup; - - if (closeDef->cb && closeDef->cb !=3D cb) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Trying to remove mismatching close callback for" - " domain %s"), vm->def->name); - goto cleanup; - } - - if (virHashRemoveEntry(closeCallbacks->list, uuidstr) < 0) - goto cleanup; - - virObjectUnref(vm); - ret =3D 0; - cleanup: - virObjectUnlock(closeCallbacks); - if (!ret) - virObjectUnref(closeCallbacks); - return ret; -} - -virCloseCallback -virCloseCallbacksGet(virCloseCallbacks *closeCallbacks, - virDomainObj *vm, - virConnectPtr conn) -{ - char uuidstr[VIR_UUID_STRING_BUFLEN]; - virDriverCloseDef *closeDef; - virCloseCallback cb =3D NULL; - - virUUIDFormat(vm->def->uuid, uuidstr); - VIR_DEBUG("vm=3D%s, uuid=3D%s, conn=3D%p", - vm->def->name, uuidstr, conn); - - virObjectLock(closeCallbacks); - - closeDef =3D virHashLookup(closeCallbacks->list, uuidstr); - if (closeDef && (!conn || closeDef->conn =3D=3D conn)) - cb =3D closeDef->cb; - - virObjectUnlock(closeCallbacks); - - VIR_DEBUG("cb=3D%p", cb); - return cb; -} - -typedef struct _virCloseCallbacksListEntry virCloseCallbacksListEntry; -struct _virCloseCallbacksListEntry { - unsigned char uuid[VIR_UUID_BUFLEN]; - virCloseCallback callback; -}; - -typedef struct _virCloseCallbacksList virCloseCallbacksList; -struct _virCloseCallbacksList { - size_t nentries; - virCloseCallbacksListEntry *entries; -}; - -struct virCloseCallbacksData { - virConnectPtr conn; - virCloseCallbacksList *list; -}; - -static int -virCloseCallbacksGetOne(void *payload, - const char *key, - void *opaque) -{ - struct virCloseCallbacksData *data =3D opaque; - virDriverCloseDef *closeDef =3D payload; - const char *uuidstr =3D key; - unsigned char uuid[VIR_UUID_BUFLEN]; - - if (virUUIDParse(uuidstr, uuid) < 0) - return 0; - - VIR_DEBUG("conn=3D%p, thisconn=3D%p, uuid=3D%s, cb=3D%p", - closeDef->conn, data->conn, uuidstr, closeDef->cb); - - if (data->conn !=3D closeDef->conn || !closeDef->cb) - return 0; - - VIR_EXPAND_N(data->list->entries, data->list->nentries, 1); - - memcpy(data->list->entries[data->list->nentries - 1].uuid, - uuid, VIR_UUID_BUFLEN); - data->list->entries[data->list->nentries - 1].callback =3D closeDef->c= b; - return 0; -} - -static virCloseCallbacksList * -virCloseCallbacksGetForConn(virCloseCallbacks *closeCallbacks, - virConnectPtr conn) -{ - virCloseCallbacksList *list =3D NULL; - struct virCloseCallbacksData data; - - list =3D g_new0(virCloseCallbacksList, 1); - - data.conn =3D conn; - data.list =3D list; - - virHashForEach(closeCallbacks->list, virCloseCallbacksGetOne, &data); - - return list; -} - - -void -virCloseCallbacksRun(virCloseCallbacks *closeCallbacks, - virConnectPtr conn, - virDomainObjList *domains) -{ - virCloseCallbacksList *list; - size_t i; - - VIR_DEBUG("conn=3D%p", conn); - - /* We must not hold the lock while running the callbacks, - * so first we obtain the list of callbacks, then remove - * them all from the hash. At that point we can release - * the lock and run the callbacks safely. */ - - virObjectLock(closeCallbacks); - list =3D virCloseCallbacksGetForConn(closeCallbacks, conn); - if (!list) { - virObjectUnlock(closeCallbacks); - return; - } - - for (i =3D 0; i < list->nentries; i++) { - char uuidstr[VIR_UUID_STRING_BUFLEN]; - virUUIDFormat(list->entries[i].uuid, uuidstr); - virHashRemoveEntry(closeCallbacks->list, uuidstr); - } - virObjectUnlock(closeCallbacks); - - for (i =3D 0; i < list->nentries; i++) { - virDomainObj *vm; - - /* Grab a ref and lock to the vm */ - if (!(vm =3D virDomainObjListFindByUUID(domains, - list->entries[i].uuid))) { - char uuidstr[VIR_UUID_STRING_BUFLEN]; - virUUIDFormat(list->entries[i].uuid, uuidstr); - VIR_DEBUG("No domain object with UUID %s", uuidstr); - continue; - } - - /* Remove the ref taken out during virCloseCallbacksSet since - * we're about to call the callback function and we have another - * ref anyway (so it cannot be deleted). - * - * Call the callback function and end the API usage. */ - virObjectUnref(vm); - list->entries[i].callback(vm, conn); - virDomainObjEndAPI(&vm); - } - VIR_FREE(list->entries); - VIR_FREE(list); -} - struct _virCloseCallbacksDomainData { virConnectPtr conn; diff --git a/src/hypervisor/virclosecallbacks.h b/src/hypervisor/vircloseca= llbacks.h index b471f6b160..893292763f 100644 --- a/src/hypervisor/virclosecallbacks.h +++ b/src/hypervisor/virclosecallbacks.h @@ -22,36 +22,9 @@ #include "conf/virdomainobjlist.h" -typedef struct _virCloseCallbacks virCloseCallbacks; - typedef void (*virCloseCallback)(virDomainObj *vm, virConnectPtr conn); -virCloseCallbacks * -virCloseCallbacksNew(void); - -int -virCloseCallbacksSet(virCloseCallbacks *closeCallbacks, - virDomainObj *vm, - virConnectPtr conn, - virCloseCallback cb); -int -virCloseCallbacksUnset(virCloseCallbacks *closeCallbacks, - virDomainObj *vm, - virCloseCallback cb); - -virCloseCallback -virCloseCallbacksGet(virCloseCallbacks *closeCallbacks, - virDomainObj *vm, - virConnectPtr conn); - -void -virCloseCallbacksRun(virCloseCallbacks *closeCallbacks, - virConnectPtr conn, - virDomainObjList *domains); - -/* ---- */ - virObject * virCloseCallbacksDomainAlloc(void); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b1fa23729a..b81c2cc7da 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1612,11 +1612,6 @@ virCloseCallbacksDomainAlloc; virCloseCallbacksDomainIsRegistered; virCloseCallbacksDomainRemove; virCloseCallbacksDomainRunForConn; -virCloseCallbacksGet; -virCloseCallbacksNew; -virCloseCallbacksRun; -virCloseCallbacksSet; -virCloseCallbacksUnset; # hypervisor/virhostdev.h --=20 2.38.1 From nobody Sat May 18 04:46:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672936329; cv=none; d=zohomail.com; s=zohoarc; b=EfqC7Mqov/NDQyhsL6Y/65RbATa2obSflW8EUFncbGRQhSnkw1k9THbdY+GCy4XeLVHBAZKoA8uuRaOJhSuMbbO1UVsZrTcaM0u1c7RWGbXbGhA6u7EAoL5mtdqim0tHTLkfxPlH1H5NOjv5qpMlv3ybEzg6v/HKu1k6Zru2Ih4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672936329; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=b/IPUFUbrBoXc56jUENPXF01sI7MHXl8tGuH4pyzQv4=; b=axaN/hmY64+3J0G0vGT7W++Gv/LLYnsryogwrZzk5Wi3S6MaweSU19rUsmLMqpy+sd1NKrteJMDPpxi5nnADyJJjmLOIobyr7etZchrb7Brr7x1cqcji6QU47iR173fHT+TY4JP/I6036spx7ELY7EvqarlEQV7Zhy7nn5vq1uM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1672936329771879.2719813028361; Thu, 5 Jan 2023 08:32:09 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-372-B6TQAynEPRGIxy2KH8cnxQ-1; Thu, 05 Jan 2023 11:30:54 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 07755381495F; Thu, 5 Jan 2023 16:30:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4ECA140EBF6; Thu, 5 Jan 2023 16:30:44 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DB542194658C; Thu, 5 Jan 2023 16:30:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A08D4194704B for ; Thu, 5 Jan 2023 16:30:43 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7A40D2166B33; Thu, 5 Jan 2023 16:30:43 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id E79932166B30 for ; Thu, 5 Jan 2023 16:30:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672936328; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=b/IPUFUbrBoXc56jUENPXF01sI7MHXl8tGuH4pyzQv4=; b=EjKFdFRtXxu8rrNg3XOW8jRgokHxAq/1c8BRaN3p/nlvlL7TG8Zm/b/+ljXw8hSbg4yoNW yoS5nAt1p4j8iU8VfZGd3ecU5C3Vz+hquaOiuLZH5hN/mlplEdZZZClpFwFscWbNAFQgrI U1+ZOjbS4JbKWQBsgNpVnHu3SV8kwfk= X-MC-Unique: B6TQAynEPRGIxy2KH8cnxQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/36] gendispatch: Add 'G_GNUC_WARN_UNUSED_RESULT' to output of 'aclheader' Date: Thu, 5 Jan 2023 17:30:03 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672936330878100001 Content-Type: text/plain; charset="utf-8" Require check of return value of the ACL checking functions. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/rpc/gendispatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index 5f2b163ea0..54d55d91e7 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -2182,7 +2182,7 @@ elsif ($mode eq "client") { } if ($mode eq "aclheader") { - print "extern $ret $apiname(" . join(", ", @argdecls) . ")= ;\n"; + print "extern $ret $apiname(" . join(", ", @argdecls) . ")= G_GNUC_WARN_UNUSED_RESULT;\n"; } else { my @argvars; push @argvars, "mgr"; --=20 2.38.1 From nobody Sat May 18 04:46:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672936263; cv=none; d=zohomail.com; s=zohoarc; b=PLiwaW9vB+Ja7ESsU5NvjHWnKBP5YKqQbaRX92qSP5xxUMYxYiMt1zeYkRX9cLABmOgzj9GN8WNzxGWxIOt88SupTPxXRex5YrPr5vqECHuLsBgABGefsGphZZdW+VFElIvHFOnixxYp3vVWMfrsTZIN5L0dQL5WwBf1xJ//Rsw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672936263; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TCco2ELTbne03/DoUjoo79MYRPe0+S6n8fV3MRSQMU0=; b=XJlcfvYp2NmDwydG+Gl2OK0E6EcIn81lC2JWwD9/PBgAuJmlQHhQJtARf/1zc2Is6dcErTrsPXw32bPPxoAPTxUotxLLSQZZcjXUPjzjeU73dxZTBnZrMWb4F1uCH18Lz++gO4rt49UXcyO8U4WHl4zqs66l1t7ce4KbG+/93Yg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1672936263910733.0232243614339; Thu, 5 Jan 2023 08:31:03 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-407-AI7RIr7fMHSrNZmzzSFWiw-1; Thu, 05 Jan 2023 11:30:56 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EC091803493; Thu, 5 Jan 2023 16:30:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D563840C2004; Thu, 5 Jan 2023 16:30:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CB7AA1946589; Thu, 5 Jan 2023 16:30:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9EEC41946586 for ; Thu, 5 Jan 2023 16:30:44 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 940892166B30; Thu, 5 Jan 2023 16:30:44 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id DED702166B31 for ; Thu, 5 Jan 2023 16:30:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672936262; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=TCco2ELTbne03/DoUjoo79MYRPe0+S6n8fV3MRSQMU0=; b=Va/WaRFjP4BVuTCE/Gv57hXS7ifomA1f15dgBjF/mD+zmX9Moh6dsYHp2ubgkhYxZ8ExDm CedVxRG0HpzlmC04E23UdYBxBSz+2y70J9Dnspe768oKVlFyWv+f2tLY+16kh80e6YQMdH M70u2OnYn0zRrA/me7TTQPMaiymcu30= X-MC-Unique: AI7RIr7fMHSrNZmzzSFWiw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 15/36] remote_driver: Return 'virLockGuard' from 'remoteDriverLock' Date: Thu, 5 Jan 2023 17:30:04 +0100 Message-Id: <202c4601174b9c1bbad062f326c26d32e5482d67.1672935969.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672936265746100005 Content-Type: text/plain; charset="utf-8" The function currently didn't have a return value. Returning the 'virLockGuard' struct allows the callers to use automatic unlocking of the mutex. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/remote/remote_driver.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index b0dba9057b..8310326ad0 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -105,9 +105,17 @@ enum { }; -static void remoteDriverLock(struct private_data *driver) +/** + * remoteDriverLock: + * @driver: private data of the remote driver + * + * Locks the internal mutex of the private driver. Callers may optionally = use + * the returned virLockGuard struct to automatically unlock the driver. + */ +static virLockGuard +remoteDriverLock(struct private_data *driver) { - virMutexLock(&driver->lock); + return virLockGuardLock(&driver->lock); } static void remoteDriverUnlock(struct private_data *driver) --=20 2.38.1 From nobody Sat May 18 04:46:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672936266; cv=none; d=zohomail.com; s=zohoarc; b=Zk9ZltzCjbCqbAtIsgorHL2Gw6vJKePN4mLPysidK2oaS5cNagDrWD/lP+QMcOCcbH50bnLJQ/W4sqdbORt+SqAXHlSRomkc5jsw3rxiM4FcAF+VpZpLlzLuGfhRmhpfBXIzTfL0rUMPMfkPWogRO2ea3livk4WbjnLK3V9KeEc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672936266; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fogr0EzZZlySn3IU4ZI8nm1hxFyjWKqi5uiI9l6Wvtg=; b=F20qa5TDIMASopqzKff5nVoEDO0G07n/4J0xmUSOSG+0dReOcYPaXCMR5oQJkX5u6rHNs5saauUp/v0Y26rESpnLkBirIzhN0ejvLIiN6ecxQc5K6mNnRFnxiripCD0Gaxa2+T+AuYW68Uk+SVrn8f9Jb9Pclz3VV6VKcG2Nugw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1672936266903465.8449285882134; Thu, 5 Jan 2023 08:31:06 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-562-9Esd_QiENkerb3ttrHsN8A-1; Thu, 05 Jan 2023 11:30:59 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4B22D857A89; Thu, 5 Jan 2023 16:30:47 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3460B492D8B; Thu, 5 Jan 2023 16:30:47 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 22FB1194658C; Thu, 5 Jan 2023 16:30:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CC01A194658C for ; Thu, 5 Jan 2023 16:30:45 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C22BB2166B30; Thu, 5 Jan 2023 16:30:45 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 31EC12166B32 for ; Thu, 5 Jan 2023 16:30:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672936265; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fogr0EzZZlySn3IU4ZI8nm1hxFyjWKqi5uiI9l6Wvtg=; b=RL2Po8c3dgo7shTmeSflZcivP7nia7vPavc1qUMDQtjYa7b4y2X68jo2bfXTepbycCSTgS psemgjfpIs848vclHx0NLP6eWM35rWRBu0a8Uiix42Ehs0fUw8s11O8Atejkevt3ofRhEG YOrMD/fK9AzbS5qiwjjlBe4P/tCP/8g= X-MC-Unique: 9Esd_QiENkerb3ttrHsN8A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 16/36] remote_driver: Refactor few functions as example of auto-locking Date: Thu, 5 Jan 2023 17:30:05 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672936267765100007 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/remote/remote_driver.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 8310326ad0..7946e9d9bd 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -7978,12 +7978,10 @@ remoteStorageVolGetInfoFlags(virStorageVolPtr vol, virStorageVolInfoPtr result, unsigned int flags) { - int rv =3D -1; struct private_data *priv =3D vol->conn->privateData; remote_storage_vol_get_info_flags_args args; remote_storage_vol_get_info_flags_ret ret; - - remoteDriverLock(priv); + VIR_LOCK_GUARD lock =3D remoteDriverLock(priv); make_nonnull_storage_vol(&args.vol, vol); args.flags =3D flags; @@ -7994,18 +7992,14 @@ remoteStorageVolGetInfoFlags(virStorageVolPtr vol, (xdrproc_t)xdr_remote_storage_vol_get_info_flags_args, (char *)&args, (xdrproc_t)xdr_remote_storage_vol_get_info_flags_ret, - (char *)&ret) =3D=3D -1) { - goto done; - } + (char *)&ret) =3D=3D -1) + return -1; result->type =3D ret.type; result->capacity =3D ret.capacity; result->allocation =3D ret.allocation; - rv =3D 0; - done: - remoteDriverUnlock(priv); - return rv; + return 0; } @@ -8143,17 +8137,15 @@ remoteDomainAuthorizedSSHKeysSet(virDomainPtr domai= n, unsigned int nkeys, unsigned int flags) { - int rv =3D -1; struct private_data *priv =3D domain->conn->privateData; remote_domain_authorized_ssh_keys_set_args args; - - remoteDriverLock(priv); + VIR_LOCK_GUARD lock =3D remoteDriverLock(priv); if (nkeys > REMOTE_DOMAIN_AUTHORIZED_SSH_KEYS_MAX) { virReportError(VIR_ERR_RPC, "%s", _("remoteDomainAuthorizedSSHKeysSet: " "returned number of keys exceeds limit")); - goto cleanup; + return -1; } make_nonnull_domain(&args.dom, domain); @@ -8164,15 +8156,10 @@ remoteDomainAuthorizedSSHKeysSet(virDomainPtr domai= n, if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_AUTHORIZED_SSH_KEYS= _SET, (xdrproc_t) xdr_remote_domain_authorized_ssh_keys_set_args, (= char *)&args, - (xdrproc_t) xdr_void, (char *) NULL) =3D=3D -1) { - goto cleanup; - } - - rv =3D 0; + (xdrproc_t) xdr_void, (char *) NULL) =3D=3D -1) + return -1; - cleanup: - remoteDriverUnlock(priv); - return rv; + return 0; } --=20 2.38.1 From nobody Sat May 18 04:46:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672936262; cv=none; d=zohomail.com; s=zohoarc; b=eOkxi7o1ylzo9m+ilal+vfwcgtjcB4gglO1WHQo3YPzhxO4JBBZBVVOtwxNKzQpd7x+68wPt6kOmzXFeoASYz6/UPyMGHVSI3/CGEkkbfikzdzC4Sbkg2Hz4+icGbLgHYtfV1AsjuFycZjzxC3kDCPa9BplBLsJwjNR3CCqfLzQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672936262; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2zf7kv9Uwl/mwABrokZLXuqXSmuXHaehzmAOjzLSPFw=; b=mrrmpNOLhnwWHH5D7zPPOQXTFk4wfQmXamDZLYzBBbM0Fn2TBhHXNfbG4OgDnCrxNjfTJXYUOMc0/Gh6iTmBQODiD2jl9xM6OEJBsKX1Kq5h+BDyjK0sKXCPcZLFoSwEfRSDwYbJi6jSMNUkTqREi1xK4mDBwYAtE6fkEtuoPdw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1672936262163984.989646065622; Thu, 5 Jan 2023 08:31:02 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-463-6OrOOTVzPQWqOENvitPMKg-1; Thu, 05 Jan 2023 11:30:58 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2D64B85C6F0; Thu, 5 Jan 2023 16:30:48 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18F9F400E107; Thu, 5 Jan 2023 16:30:48 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0FEDB1946589; Thu, 5 Jan 2023 16:30:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B9AF5194658D for ; Thu, 5 Jan 2023 16:30:46 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AF28C2166B31; Thu, 5 Jan 2023 16:30:46 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F78E2166B30 for ; Thu, 5 Jan 2023 16:30:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672936261; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=2zf7kv9Uwl/mwABrokZLXuqXSmuXHaehzmAOjzLSPFw=; b=e4fUjZ4fqRMIVk+zlav/E/cGUlNfXML3Z2xoxDZrV4LUppVOiUPZxqaH+Ugbh4xwRCxD2S 7omZG5K6ayCpnq2vjZWxCcy3Jz9aXJ7tmtczYn/qcpl3d6ma+a5lxd52bckpYyw7YQv5SX tmpQGjOepXUvFsp47hpcfOWB7ZiT+vg= X-MC-Unique: 6OrOOTVzPQWqOENvitPMKg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 17/36] virStorageSourceIsSameLocation: Use switch statement for individual storage types Date: Thu, 5 Jan 2023 17:30:06 +0100 Message-Id: <1f06588f9d2e86df2ba9544e02679d2919e6f037.1672935969.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672936263746100001 Content-Type: text/plain; charset="utf-8" Convert to a switch instead of a bunch of 'if (type =3D=3D ...). Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/conf/storage_source_conf.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/conf/storage_source_conf.c b/src/conf/storage_source_conf.c index 2b4cf5e241..84df8d28fa 100644 --- a/src/conf/storage_source_conf.c +++ b/src/conf/storage_source_conf.c @@ -929,7 +929,8 @@ virStorageSourceIsSameLocation(virStorageSource *a, STRNEQ_NULLABLE(a->snapshot, b->snapshot)) return false; - if (a->type =3D=3D VIR_STORAGE_TYPE_NETWORK) { + switch ((virStorageType) virStorageSourceGetActualType(a)) { + case VIR_STORAGE_TYPE_NETWORK: if (a->protocol !=3D b->protocol || a->nhosts !=3D b->nhosts) return false; @@ -941,11 +942,23 @@ virStorageSourceIsSameLocation(virStorageSource *a, STRNEQ_NULLABLE(a->hosts[i].socket, b->hosts[i].socket)) return false; } - } + break; - if (a->type =3D=3D VIR_STORAGE_TYPE_NVME && - !virStorageSourceNVMeDefIsEqual(a->nvme, b->nvme)) - return false; + case VIR_STORAGE_TYPE_NVME: + if (!virStorageSourceNVMeDefIsEqual(a->nvme, b->nvme)) + return false; + break; + + case VIR_STORAGE_TYPE_VHOST_USER: + case VIR_STORAGE_TYPE_NONE: + case VIR_STORAGE_TYPE_FILE: + case VIR_STORAGE_TYPE_BLOCK: + case VIR_STORAGE_TYPE_DIR: + case VIR_STORAGE_TYPE_LAST: + case VIR_STORAGE_TYPE_VOLUME: + /* nothing to do */ + break; + } return true; } --=20 2.38.1 From nobody Sat May 18 04:46:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672936283; cv=none; d=zohomail.com; s=zohoarc; b=H7ejiHkoC+WKJJbZLL7II8SUkoZMm4asTCdOPlKquFAWouvMc/dNNT6/wJxv5ZYVMh2HBQPBmCETU8Hqpuk423Qo8gJj5oWlPBfiN7SrpMIpV0BfoYpZdKvTYytIqi++NM/doBfXIIjJfMZ9vWKmCozqsUhHSC3MlkpNl24v8b8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672936283; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aBVPZSgA/pX8rEhGudzf5+26iZcWv7/gUYp8ompAHBk=; b=WJ7MedSS7DVh1x0xbCfQ8j81/hfYZ7Vgr051Q/Db9Dm2TG4oL/X6nHeBiPhEYMAVWfpH86UZchKmQOut90JeSH7P13Kf1rVnOUi/W6dwX1VKXL/2cMZZYQ4U2j4q9ziFOBBdIfJGK7XQvpB10BfyocpirVvtwBvK6r/4fj9/bnM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1672936283438711.1072932664678; Thu, 5 Jan 2023 08:31:23 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-118-3wBQ8_BDN7OCs5ZB5vlQ5w-1; Thu, 05 Jan 2023 11:30:58 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6B2033C0F673; Thu, 5 Jan 2023 16:30:49 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 51A921121314; Thu, 5 Jan 2023 16:30:49 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 46FA01946589; Thu, 5 Jan 2023 16:30:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9C1141946586 for ; Thu, 5 Jan 2023 16:30:47 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 917302166B33; Thu, 5 Jan 2023 16:30:47 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13C992166B30 for ; Thu, 5 Jan 2023 16:30:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672936282; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=aBVPZSgA/pX8rEhGudzf5+26iZcWv7/gUYp8ompAHBk=; b=bOGZKWJ9of8Y7XRxXGC7vp50c0YilvD7YYApafKDZI767cyl9rBrQiqLeyy9yobLTY8mVx xWNsVEaUYGWF3NwakoMdQkBAV5UI2edIekc/+pvUKCDfx52NDU796MrlEaGpyd8faCDqN0 ycW8ejh/yju2skK9fFvpAL8griA51kY= X-MC-Unique: 3wBQ8_BDN7OCs5ZB5vlQ5w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 18/36] qemuxml2argvtest: Add seclabels in to disk-backing-chains-(no)index Date: Thu, 5 Jan 2023 17:30:07 +0100 Message-Id: <018eb6e6c9e980a22be392d1b2ae51aab21d82c3.1672935969.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672936283922100006 Content-Type: text/plain; charset="utf-8" Commit da9f3cd84b250088 added the seclabel example into the 'disk-backing-chains' case. Since the only thing that 'disk-backing-chains' tests which 'disk-backing-chains-(no)index' don't test is the seclabel we'll be able to remove the test case if we add the seclabel example. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- tests/qemuxml2argvdata/disk-backing-chains-index.xml | 6 +++++- tests/qemuxml2argvdata/disk-backing-chains-noindex.xml | 6 +++++- .../qemuxml2xmloutdata/disk-backing-chains-index-active.xml | 6 +++++- .../disk-backing-chains-index-inactive.xml | 6 +++++- tests/qemuxml2xmloutdata/disk-backing-chains-noindex.xml | 6 +++++- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/tests/qemuxml2argvdata/disk-backing-chains-index.xml b/tests/q= emuxml2argvdata/disk-backing-chains-index.xml index 9054963f1f..90da6a97e9 100644 --- a/tests/qemuxml2argvdata/disk-backing-chains-index.xml +++ b/tests/qemuxml2argvdata/disk-backing-chains-index.xml @@ -38,7 +38,11 @@ - + + + + + diff --git a/tests/qemuxml2argvdata/disk-backing-chains-noindex.xml b/tests= /qemuxml2argvdata/disk-backing-chains-noindex.xml index ca7dc2d2b3..dc928f7075 100644 --- a/tests/qemuxml2argvdata/disk-backing-chains-noindex.xml +++ b/tests/qemuxml2argvdata/disk-backing-chains-noindex.xml @@ -38,7 +38,11 @@ - + + + + + diff --git a/tests/qemuxml2xmloutdata/disk-backing-chains-index-active.xml = b/tests/qemuxml2xmloutdata/disk-backing-chains-index-active.xml index ca7684d3b6..4f30bc7111 100644 --- a/tests/qemuxml2xmloutdata/disk-backing-chains-index-active.xml +++ b/tests/qemuxml2xmloutdata/disk-backing-chains-index-active.xml @@ -39,7 +39,11 @@ - + + + + + diff --git a/tests/qemuxml2xmloutdata/disk-backing-chains-index-inactive.xm= l b/tests/qemuxml2xmloutdata/disk-backing-chains-index-inactive.xml index 74e7a74b48..c992679b36 100644 --- a/tests/qemuxml2xmloutdata/disk-backing-chains-index-inactive.xml +++ b/tests/qemuxml2xmloutdata/disk-backing-chains-index-inactive.xml @@ -39,7 +39,11 @@ - + + + + + diff --git a/tests/qemuxml2xmloutdata/disk-backing-chains-noindex.xml b/tes= ts/qemuxml2xmloutdata/disk-backing-chains-noindex.xml index 74e7a74b48..c992679b36 100644 --- a/tests/qemuxml2xmloutdata/disk-backing-chains-noindex.xml +++ b/tests/qemuxml2xmloutdata/disk-backing-chains-noindex.xml @@ -39,7 +39,11 @@ - + + + + + --=20 2.38.1 From nobody Sat May 18 04:46:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672936574; cv=none; d=zohomail.com; s=zohoarc; b=YeTAKgVOcgw/rM97qUbL2W6d/+Ac3/+C6xYL/eNsUuIa+S24csltFIXqAxmsLG35eIH7LmFaiFrXzRM0DzYo3lZHg5cgIgNUM2yztdAdvsGLgoAaZr1/3/57bxzL2TanP2mUYJDA+zYKTM01U3kLxlePA1KDsD6hL+elVFztCII= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672936574; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=52DmdBMCm9Y/cQXr7SKxffbn047qQzZ0kvV436JsdNY=; b=TxXvTnp4ckUGWmT/TFpmYoBjpjtRbamAENpZuUtEQob1RO3gfF0hxb2Gxq3fVXF36Zt3au57d5x4253tUj8OZgfZsywENrxtuTR5+CjbKbn9kfVETp2TnKJiPI4lCCNCtZxumcjbYeToRw6QSIr0lvc389a8XvrgTgb+Fjp2Z6s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1672936574879948.2415029791226; Thu, 5 Jan 2023 08:36:14 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-177-VJuakRdjPzqTZfQZiGzMqQ-1; Thu, 05 Jan 2023 11:31:11 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E5889281DE9E; Thu, 5 Jan 2023 16:30:49 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF19C492D8B; Thu, 5 Jan 2023 16:30:49 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 89B211947053; Thu, 5 Jan 2023 16:30:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0BCFA1946586 for ; Thu, 5 Jan 2023 16:30:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E4AD52166B31; Thu, 5 Jan 2023 16:30:48 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B6022166B30 for ; Thu, 5 Jan 2023 16:30:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672936573; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=52DmdBMCm9Y/cQXr7SKxffbn047qQzZ0kvV436JsdNY=; b=Hy7TWe8jOiTBzzegnBpaMubxdDnSMdOLZWaNYGZ1QUj3a+dKSYLSPnfukyzt6T1bfuJ0P6 Wmmv3upH0HoZj3IpRyHgkmSwqS0mzbaXEBISWxflYUmm+pS0PQ0tydWur8lIRQ9pfwiFKY x/mnnKwo8dM6uixkN7hfpK844F/pYFc= X-MC-Unique: VJuakRdjPzqTZfQZiGzMqQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 19/36] qemuxml2xmltest: Remove 'disk-backing-chain' case and output files Date: Thu, 5 Jan 2023 17:30:08 +0100 Message-Id: <60b4ed37f4e0d9d5cc6d41942ddb50da5d910f99.1672935969.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672936576470100001 Content-Type: text/plain; charset="utf-8" The test is superseded by 'disk-backing-chains-(no)index' cases. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- .../qemuxml2argvdata/disk-backing-chains.xml | 98 ---------------- .../disk-backing-chains-active.xml | 110 ------------------ .../disk-backing-chains-inactive.xml | 110 ------------------ tests/qemuxml2xmltest.c | 1 - 4 files changed, 319 deletions(-) delete mode 100644 tests/qemuxml2argvdata/disk-backing-chains.xml delete mode 100644 tests/qemuxml2xmloutdata/disk-backing-chains-active.xml delete mode 100644 tests/qemuxml2xmloutdata/disk-backing-chains-inactive.x= ml diff --git a/tests/qemuxml2argvdata/disk-backing-chains.xml b/tests/qemuxml= 2argvdata/disk-backing-chains.xml deleted file mode 100644 index 7fe84da3f0..0000000000 --- a/tests/qemuxml2argvdata/disk-backing-chains.xml +++ /dev/null @@ -1,98 +0,0 @@ - - QEMUGuest1 - c7a5fdbd-edaf-9455-926a-d65c16db1809 - 219136 - 219136 - 1 - - hvm - - - - destroy - restart - destroy - - /usr/bin/qemu-system-i386 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/qemuxml2xmloutdata/disk-backing-chains-active.xml b/test= s/qemuxml2xmloutdata/disk-backing-chains-active.xml deleted file mode 100644 index 5901aef3d3..0000000000 --- a/tests/qemuxml2xmloutdata/disk-backing-chains-active.xml +++ /dev/null @@ -1,110 +0,0 @@ - - QEMUGuest1 - c7a5fdbd-edaf-9455-926a-d65c16db1809 - 219136 - 219136 - 1 - - hvm - - - - destroy - restart - destroy - - /usr/bin/qemu-system-i386 - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - - - - -
- - -
- - - - -