From nobody Sat Apr 27 04:43:10 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=1669210504; cv=none; d=zohomail.com; s=zohoarc; b=OjFkeY49esehJNwCijmOrJeWnD73IW3BVA14e7x8WqtGmEX6s19C1jmMYtLyHf9yLdqPc+jsBl23Wsog7k5psHrxnpQBKTAk4NKhwxrzQx2Gk8PV6gPta0Fym8h8xcQcvY/Nzj04fF1ilckImyD7ycnaUl6DYZgP6krbKh1I4t4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669210504; 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=pJ2dQPx3Db4J8DVv2dLHwGinxe3n8T40Kp6nAAFbh+o=; b=cudPqrQglDUUBNVn5lJpfScrROp9spphIAIzHelYKOhps1A4Szs7cLpjYXJ8XFceGF/NVQzAuysibE+HjRi56XiooBTEdQniLJDPxfb4WeA9olimuuyi5wJcpIgT0wV3daY6nB+VRh8AysYWhCCzvXZPdC7zfqxPeqK2Wmb8Mwk= 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 1669210504716506.41684552907805; Wed, 23 Nov 2022 05:35:04 -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-619-rzg9DNevO4OGAuB99Jozdw-1; Wed, 23 Nov 2022 08:34:33 -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 56DB58027EC; Wed, 23 Nov 2022 13:34:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4000C492B07; Wed, 23 Nov 2022 13:34: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 36B2D1946589; Wed, 23 Nov 2022 13:34: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 B76311946587 for ; Wed, 23 Nov 2022 12:36:44 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9C4F02166B31; Wed, 23 Nov 2022 12:36: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 10ED82166B26 for ; Wed, 23 Nov 2022 12:36:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669210503; 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=pJ2dQPx3Db4J8DVv2dLHwGinxe3n8T40Kp6nAAFbh+o=; b=bqnbXQFPUTVrWAJqcAPHfUiB6FsI8T/S4Szh4MuGR9LvfEEICYcOuIPsJZd/BzCmhHYOFU zzzofRHAr6NTKHP7vl8HRCPHFnlcbvtWJrOgSE5Tq5bB/I6T2VJLkjq3uFmfDPw5Ut7uw3 +nUxbm97t/kfSUVhysLS/epGTM8VWro= X-MC-Unique: rzg9DNevO4OGAuB99Jozdw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/7] qemu: driver: Fix formatting of function headers around qemuDomainAttachDevice Date: Wed, 23 Nov 2022 13:36:35 +0100 Message-Id: <63b7287c56c843192d45be9021d773f7f0fd3dc1.1669206840.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: 1669210504978100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ff5a743716..70368ffb10 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7757,16 +7757,19 @@ qemuDomainAttachDeviceFlags(virDomainPtr dom, return ret; } -static int qemuDomainAttachDevice(virDomainPtr dom, const char *xml) + +static int +qemuDomainAttachDevice(virDomainPtr dom, + const char *xml) { - return qemuDomainAttachDeviceFlags(dom, xml, - VIR_DOMAIN_AFFECT_LIVE); + return qemuDomainAttachDeviceFlags(dom, xml, VIR_DOMAIN_AFFECT_LIVE); } -static int qemuDomainUpdateDeviceFlags(virDomainPtr dom, - const char *xml, - unsigned int flags) +static int +qemuDomainUpdateDeviceFlags(virDomainPtr dom, + const char *xml, + unsigned int flags) { virQEMUDriver *driver =3D dom->conn->privateData; virDomainObj *vm =3D NULL; --=20 2.37.3 From nobody Sat Apr 27 04:43:10 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=1669207563; cv=none; d=zohomail.com; s=zohoarc; b=n8yo0qGeCDdP7aiHPB6AgZG3pDGEIcPHgm0nS0Am7lnEuVG3LY25ydmBDaKbzU80lvgtRIvJvbh4bbMA7SZ/oilD9gWS6eObCkZfVe1c/m5H7bvvZTSswL0gqHxrb01PhJ4AFXrrzkTR7PZOHFa7u/vBjR927L2OdEJMhXlWdNM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669207563; 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=4+gM1Uf7C4aK+NIeTBL8cWZMEeC4ziNhlNvdrZdUktY=; b=lp5oj4PcVFIbFKZMXOE6Iua6YUG5ILluT55HGQeryeEszkWVV4jCi8vt0trnhlINgpi84VHTfkHgzSLQxkltWmxTC2ElHD48X8xIlpAZ4EREZCmFWQ7rb6oRW2XjpU3ntuiAJMxcAcLny07b2up3J+R274KAZQQeDrAQ3kwx8eI= 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 1669207563831841.3700717329481; Wed, 23 Nov 2022 04:46:03 -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-6-sl6p0Kc-PlaqXp6AAS5DeQ-1; Wed, 23 Nov 2022 07:45:21 -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 BDC291C08973; Wed, 23 Nov 2022 12:45:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB5A44EA5C; Wed, 23 Nov 2022 12:45:19 +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 76AB51946589; Wed, 23 Nov 2022 12:45:19 +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 A57F01946587 for ; Wed, 23 Nov 2022 12:36:45 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 99F352166B31; Wed, 23 Nov 2022 12:36: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 0A9362166B26 for ; Wed, 23 Nov 2022 12:36:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669207562; 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=4+gM1Uf7C4aK+NIeTBL8cWZMEeC4ziNhlNvdrZdUktY=; b=C6MiATcdjkz8AymAQH3s7+rC1FBn0pUAr+WQzl49pXb6uMulI5FGQl9F5kX/nMSsVPWd/2 TIVhaWYcnEpRFDM7Unx/ghwNuCZJu7OpTGjLlN0OuW5PO/GdEqJEzrRQJYK2gUkSJBBlVx P722i6ME3QMaTJqXgIvWQs4UXf/ywds= X-MC-Unique: sl6p0Kc-PlaqXp6AAS5DeQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/7] qemuDomainUpdateDeviceFlags: Parse XML twice rather than use virDomainDeviceDefCopy Date: Wed, 23 Nov 2022 13:36:36 +0100 Message-Id: <31074448154a75cebce9436971f6b501db217b73.1669206840.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: 1669207565298100001 Content-Type: text/plain; charset="utf-8" 'virDomainDeviceDefCopy' formats the definition and parses it back. Since we already are parsing the XML here, we're better off parsing it twice and save the formatting step. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 70368ffb10..ef0a2e06fd 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7775,8 +7775,8 @@ qemuDomainUpdateDeviceFlags(virDomainPtr dom, virDomainObj *vm =3D NULL; qemuDomainObjPrivate *priv; g_autoptr(virDomainDef) vmdef =3D NULL; - g_autoptr(virDomainDeviceDef) dev =3D NULL; - virDomainDeviceDef *dev_copy =3D NULL; + g_autoptr(virDomainDeviceDef) dev_config =3D NULL; + g_autoptr(virDomainDeviceDef) dev_live =3D NULL; bool force =3D (flags & VIR_DOMAIN_DEVICE_MODIFY_FORCE) !=3D 0; int ret =3D -1; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; @@ -7806,21 +7806,15 @@ qemuDomainUpdateDeviceFlags(virDomainPtr dom, !(flags & VIR_DOMAIN_AFFECT_LIVE)) parse_flags |=3D VIR_DOMAIN_DEF_PARSE_INACTIVE; - dev =3D dev_copy =3D virDomainDeviceDefParse(xml, vm->def, - driver->xmlopt, priv->qemuCap= s, - parse_flags); - if (dev =3D=3D NULL) - goto endjob; + if (flags & VIR_DOMAIN_AFFECT_CONFIG) { + if (!(dev_config =3D virDomainDeviceDefParse(xml, vm->def, driver-= >xmlopt, + priv->qemuCaps, parse_f= lags))) + goto endjob; + } - if (flags & VIR_DOMAIN_AFFECT_CONFIG && - flags & VIR_DOMAIN_AFFECT_LIVE) { - /* If we are affecting both CONFIG and LIVE - * create a deep copy of device as adding - * to CONFIG takes one instance. - */ - dev_copy =3D virDomainDeviceDefCopy(dev, vm->def, - driver->xmlopt, priv->qemuCaps); - if (!dev_copy) + if (flags & VIR_DOMAIN_AFFECT_LIVE) { + if (!(dev_live =3D virDomainDeviceDefParse(xml, vm->def, driver->x= mlopt, + priv->qemuCaps, parse_fla= gs))) goto endjob; } @@ -7833,7 +7827,7 @@ qemuDomainUpdateDeviceFlags(virDomainPtr dom, /* virDomainDefCompatibleDevice call is delayed until we know the * device we're going to update. */ - if ((ret =3D qemuDomainUpdateDeviceConfig(vmdef, dev_copy, priv->q= emuCaps, + if ((ret =3D qemuDomainUpdateDeviceConfig(vmdef, dev_config, priv-= >qemuCaps, parse_flags, driver->xmlopt)) < 0) goto endjob; @@ -7842,7 +7836,7 @@ qemuDomainUpdateDeviceFlags(virDomainPtr dom, if (flags & VIR_DOMAIN_AFFECT_LIVE) { /* virDomainDefCompatibleDevice call is delayed until we know the * device we're going to update. */ - if ((ret =3D qemuDomainUpdateDeviceLive(vm, dev, dom, force)) < 0) + if ((ret =3D qemuDomainUpdateDeviceLive(vm, dev_live, dom, force))= < 0) goto endjob; qemuDomainSaveStatus(vm); @@ -7859,8 +7853,6 @@ qemuDomainUpdateDeviceFlags(virDomainPtr dom, virDomainObjEndJob(vm); cleanup: - if (dev !=3D dev_copy) - virDomainDeviceDefFree(dev_copy); virDomainObjEndAPI(&vm); return ret; } --=20 2.37.3 From nobody Sat Apr 27 04:43:10 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=1669210483; cv=none; d=zohomail.com; s=zohoarc; b=nZqeZ9Qpn7yTt5Dmn+/NO3KvYpm65xMEZJZgq0QMPG4IdwOHoN+6ALYnNpzho8FbZswQjx9jK9PBtbwGnKTXLPAdM29IyInZEr44JlRFFHWC348KfeQD3KHBZmx5GAeEGnnlhpqahXUAKkhjMkCiONqhSKG0fK/DCiaNijbu/dg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669210483; 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=Z2ikUt0s4ssZz/cauo5hsKQVqNtIjo108qxGZe2f7LY=; b=DaSrVoanf7jLlYtSkAUIWFa3xaH4NTLwgQopKmy5U717E5+0VksVflzOKOOXJ0lkyAo7SxrQoGCeKK7Y6DxbAlbq4KF0Oyk3VfHynfXetvu5KtnU/gxbfkKVDutobZd4WPOf/PbMt8ZzcNyspNvwNjM7BBu+/Xa/EDV9vTpmb7c= 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 1669210483156648.3773927159099; Wed, 23 Nov 2022 05:34: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-532-ncvWbccOPNag3x4waoHKVw-1; Wed, 23 Nov 2022 08:34:33 -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 E721787A9E3; Wed, 23 Nov 2022 13:34:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE44540C2086; Wed, 23 Nov 2022 13:34: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 8534E1946A40; Wed, 23 Nov 2022 13:34: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 A0BDC1946587 for ; Wed, 23 Nov 2022 12:36:46 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 92A712166B31; Wed, 23 Nov 2022 12:36: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 03ECA2166B26 for ; Wed, 23 Nov 2022 12:36:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669210482; 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=Z2ikUt0s4ssZz/cauo5hsKQVqNtIjo108qxGZe2f7LY=; b=eN+nSJARpDqVP2nknDJ7W3wEEQ3xHkDl3IHpEoYM4M1VWX8qXDGEsM6GUXSwUX9iY75+G7 RjJtsr4kUP0xiXnxBUAWUGGFmJ3uGM/9TDZ2SjP9N7w45pcLeemtSszUAXbktX/Vs1xezr s4CyW7JkRPkFDoexYNBSzocBvsyA6ZE= X-MC-Unique: ncvWbccOPNag3x4waoHKVw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/7] qemuDomainDetachDeviceLiveAndConfig: Parse XML twice rather than use virDomainDeviceDefCopy Date: Wed, 23 Nov 2022 13:36:37 +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.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: 1669210484850100001 Content-Type: text/plain; charset="utf-8" 'virDomainDeviceDefCopy' formats the definition and parses it back. Since we already are parsing the XML here, we're better off parsing it twice and save the formatting step. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ef0a2e06fd..bb345ef017 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7865,8 +7865,8 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriver *dr= iver, { qemuDomainObjPrivate *priv =3D vm->privateData; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; - g_autoptr(virDomainDeviceDef) dev =3D NULL; - virDomainDeviceDef *dev_copy =3D NULL; + g_autoptr(virDomainDeviceDef) dev_config =3D NULL; + g_autoptr(virDomainDeviceDef) dev_live =3D NULL; unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE; g_autoptr(virDomainDef) vmdef =3D NULL; int ret =3D -1; @@ -7880,21 +7880,15 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriver *= driver, !(flags & VIR_DOMAIN_AFFECT_LIVE)) parse_flags |=3D VIR_DOMAIN_DEF_PARSE_INACTIVE; - dev =3D dev_copy =3D virDomainDeviceDefParse(xml, vm->def, - driver->xmlopt, priv->qemuCap= s, - parse_flags); - if (dev =3D=3D NULL) - goto cleanup; + if (flags & VIR_DOMAIN_AFFECT_CONFIG) { + if (!(dev_config =3D virDomainDeviceDefParse(xml, vm->def, driver-= >xmlopt, + priv->qemuCaps, parse_f= lags))) + goto cleanup; + } - if (flags & VIR_DOMAIN_AFFECT_CONFIG && - flags & VIR_DOMAIN_AFFECT_LIVE) { - /* If we are affecting both CONFIG and LIVE - * create a deep copy of device as adding - * to CONFIG takes one instance. - */ - dev_copy =3D virDomainDeviceDefCopy(dev, vm->def, - driver->xmlopt, priv->qemuCaps); - if (!dev_copy) + if (flags & VIR_DOMAIN_AFFECT_LIVE) { + if (!(dev_live =3D virDomainDeviceDefParse(xml, vm->def, driver->x= mlopt, + priv->qemuCaps, parse_fla= gs))) goto cleanup; } @@ -7904,7 +7898,7 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriver *dr= iver, if (!vmdef) goto cleanup; - if (qemuDomainDetachDeviceConfig(vmdef, dev_copy, priv->qemuCaps, + if (qemuDomainDetachDeviceConfig(vmdef, dev_config, priv->qemuCaps, parse_flags, driver->xmlopt) < 0) goto cleanup; @@ -7913,7 +7907,7 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriver *dr= iver, if (flags & VIR_DOMAIN_AFFECT_LIVE) { int rc; - if ((rc =3D qemuDomainDetachDeviceLive(vm, dev, driver, false)) < = 0) + if ((rc =3D qemuDomainDetachDeviceLive(vm, dev_live, driver, false= )) < 0) goto cleanup; if (rc =3D=3D 0 && qemuDomainUpdateDeviceList(vm, VIR_ASYNC_JOB_NO= NE) < 0) @@ -7933,8 +7927,6 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriver *dr= iver, ret =3D 0; cleanup: - if (dev !=3D dev_copy) - virDomainDeviceDefFree(dev_copy); return ret; } --=20 2.37.3 From nobody Sat Apr 27 04:43:10 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=1669209268; cv=none; d=zohomail.com; s=zohoarc; b=Tfw8vgoOtabi5tfNq0VKJej+0PNrVTPGT2OTXdt3RcrZHiTtu7Ng1440Fnh0ejt+TVq49VP0fCRqWU9PjuSkRiDch9XmLPES03I2ByClYXys4owSBrATzXzcb2ihIGMrUkZlctIt2b1MliVRYDHXdbTA+NBUhrdqUu1xGF2M+DE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669209268; 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=0VszxtmluWfNeXg7hRej9JDGu+LRemeI8xTsB8bFe5o=; b=UyJL8H0nnCU8JkMMa6LiE0Q4GZ/L98snzTIteBrLJefmNFS35oae/VMWb0gUAppJeN9out0QfxGzLK5zNM4B39kypWWhgg0erpob9jXtIQ1zzooHP3qgjHyyieg0kYdWlXspPe878ry2JuI+RAZGCIk/pPlxTXkF6FFbid6R/0Q= 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 1669209268557498.67488740575095; Wed, 23 Nov 2022 05:14:28 -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-587-MluYd4abND-6uYtqcMRe0Q-1; Wed, 23 Nov 2022 08:14:16 -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 E316F85A5B6; Wed, 23 Nov 2022 13:14:13 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id ACEC74B400F; Wed, 23 Nov 2022 13:14:13 +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 86B6D1946589; Wed, 23 Nov 2022 13:14:12 +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 D59111946587 for ; Wed, 23 Nov 2022 12:36:47 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B976A2166B34; Wed, 23 Nov 2022 12:36: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 339A42166B26 for ; Wed, 23 Nov 2022 12:36:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669209267; 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=0VszxtmluWfNeXg7hRej9JDGu+LRemeI8xTsB8bFe5o=; b=COKnAYKSE8Tx+1whqpakbpD8V74uXRfQaiN1bljF7J+APwuY7rrZATR1Jq1FDP1mg0cjIp MY03CTaZZqjMtdiEAwc1/CbEx1vW9ug8/Kyq51A65IeI/QBQ23mTeFEnlVef7UcFNEJlTh bBlukE0NUsS0ZGtJ1UlG7Eifnjbsy4U= X-MC-Unique: MluYd4abND-6uYtqcMRe0Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/7] qemuDomainDetachDeviceLiveAndConfig: Refactor cleanup Date: Wed, 23 Nov 2022 13:36:38 +0100 Message-Id: <0eb82be11b845ab7bab0cff87cecc5eb9e539b7c.1669206840.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: 1669209269333100001 Content-Type: text/plain; charset="utf-8" Remove the 'cleanup' label and 'ret' variable as we can now directly return form all cases. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index bb345ef017..22e4a42c64 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7869,7 +7869,6 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriver *dr= iver, g_autoptr(virDomainDeviceDef) dev_live =3D NULL; unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE; g_autoptr(virDomainDef) vmdef =3D NULL; - int ret =3D -1; virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1); @@ -7883,35 +7882,35 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriver *= driver, if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (!(dev_config =3D virDomainDeviceDefParse(xml, vm->def, driver-= >xmlopt, priv->qemuCaps, parse_f= lags))) - goto cleanup; + return -1; } if (flags & VIR_DOMAIN_AFFECT_LIVE) { if (!(dev_live =3D virDomainDeviceDefParse(xml, vm->def, driver->x= mlopt, priv->qemuCaps, parse_fla= gs))) - goto cleanup; + return -1; } if (flags & VIR_DOMAIN_AFFECT_CONFIG) { /* Make a copy for updated domain. */ vmdef =3D virDomainObjCopyPersistentDef(vm, driver->xmlopt, priv->= qemuCaps); if (!vmdef) - goto cleanup; + return -1; if (qemuDomainDetachDeviceConfig(vmdef, dev_config, priv->qemuCaps, parse_flags, driver->xmlopt) < 0) - goto cleanup; + return -1; } if (flags & VIR_DOMAIN_AFFECT_LIVE) { int rc; if ((rc =3D qemuDomainDetachDeviceLive(vm, dev_live, driver, false= )) < 0) - goto cleanup; + return -1; if (rc =3D=3D 0 && qemuDomainUpdateDeviceList(vm, VIR_ASYNC_JOB_NO= NE) < 0) - goto cleanup; + return -1; qemuDomainSaveStatus(vm); } @@ -7919,15 +7918,12 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriver *= driver, /* Finally, if no error until here, we can save config. */ if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (virDomainDefSave(vmdef, driver->xmlopt, cfg->configDir) < 0) - goto cleanup; + return -1; virDomainObjAssignDef(vm, &vmdef, false, NULL); } - ret =3D 0; - - cleanup: - return ret; + return 0; } --=20 2.37.3 From nobody Sat Apr 27 04:43:10 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=1669207529; cv=none; d=zohomail.com; s=zohoarc; b=C68tUI7oEIZU2ivMBzVBjzWpNUyVBENWOtFHGgK7OgyA6WPu6Q6OBNXSqgzymfPsL3u+OXG5pebc/X22nU2XGRKFVYO1sbFkA+MpiK/4pC+2EcILS57JbM5CCkQlTCvt4/H5bKe7lQe53J8YYvgiqDhJ0ipahRYv7sqlVDt7spE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669207529; 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=FNF83sEtB3aKdxXjkA31VpdL28WzCzvZVEOseem5DzE=; b=Si54As3NRawoW18GCX3TO/QUCwfVBNnvhBx4+R9KqmG13TO40bM9p+CqkT1pLeHb14fWshVIN73gq5Ts0WRa2cdhFZaBUu+7U/iRCigg5n5w/vBxv2QZhx0jJbfLSAU5IyGS7LTHslzZKuSrfz+TtuM5uvyQ0PW1IKqPptZ19lM= 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 1669207529300367.79063774783356; Wed, 23 Nov 2022 04:45:29 -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-557-AXDp1MgdN0WIaiGnYL3kUA-1; Wed, 23 Nov 2022 07:45:22 -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 D3A7A8027F5; Wed, 23 Nov 2022 12:45:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C16AC40C83BB; Wed, 23 Nov 2022 12:45:19 +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 8D9CC194658F; Wed, 23 Nov 2022 12:45:19 +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 BB1C21946587 for ; Wed, 23 Nov 2022 12:36:48 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AF72A2166B34; Wed, 23 Nov 2022 12:36: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 24F0F2166B26 for ; Wed, 23 Nov 2022 12:36:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669207528; 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=FNF83sEtB3aKdxXjkA31VpdL28WzCzvZVEOseem5DzE=; b=aVOrumcS1IRdnOoThc/Uh8U+rIU1F5NGTIjqT3ZI4ETKMXTnBxDkh3mZhXEz/99KD9yigq 671EJkfL1fv42g4MwrG79Z7UZEUkgy8FjXbwPWf4Qgg4YsBR64UVOapyOH5FDL0nQnejpd 1uSgZ/PDfUOeC5GSkdOJj4qeI1zi7dM= X-MC-Unique: AXDp1MgdN0WIaiGnYL3kUA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/7] lxcDomainAttachDeviceFlags: Parse XML twice rather than use virDomainDeviceDefCopy Date: Wed, 23 Nov 2022 13:36:39 +0100 Message-Id: <8e944f4417d1ed8a8667986905327742e4a75a27.1669206840.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: 1669207531045100001 Content-Type: text/plain; charset="utf-8" 'virDomainDeviceDefCopy' formats the definition and parses it back. Since we already are parsing the XML here, we're better off parsing it twice and save the formatting step. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/lxc/lxc_driver.c | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index d66c26221c..2801ed3d6d 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -4255,8 +4255,8 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr do= m, virLXCDriver *driver =3D dom->conn->privateData; virDomainObj *vm =3D NULL; g_autoptr(virDomainDef) vmdef =3D NULL; - virDomainDeviceDef *dev =3D NULL; - virDomainDeviceDef *dev_copy =3D NULL; + g_autoptr(virDomainDeviceDef) dev_config =3D NULL; + g_autoptr(virDomainDeviceDef) dev_live =3D NULL; int ret =3D -1; g_autoptr(virLXCDriverConfig) cfg =3D virLXCDriverGetConfig(driver); @@ -4275,21 +4275,17 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr = dom, if (virDomainObjUpdateModificationImpact(vm, &flags) < 0) goto endjob; - dev =3D dev_copy =3D virDomainDeviceDefParse(xml, vm->def, - driver->xmlopt, NULL, - VIR_DOMAIN_DEF_PARSE_INACTIVE= ); - if (dev =3D=3D NULL) - goto endjob; + if (flags & VIR_DOMAIN_AFFECT_CONFIG) { + if (!(dev_config =3D virDomainDeviceDefParse(xml, vm->def, driver-= >xmlopt, + NULL, + VIR_DOMAIN_DEF_PARSE_IN= ACTIVE))) + goto endjob; + } - if (flags & VIR_DOMAIN_AFFECT_CONFIG && - flags & VIR_DOMAIN_AFFECT_LIVE) { - /* If we are affecting both CONFIG and LIVE - * create a deep copy of device as adding - * to CONFIG takes one instance. - */ - dev_copy =3D virDomainDeviceDefCopy(dev, vm->def, - driver->xmlopt, NULL); - if (!dev_copy) + if (flags & VIR_DOMAIN_AFFECT_LIVE) { + if (!(dev_live =3D virDomainDeviceDefParse(xml, vm->def, driver->x= mlopt, + NULL, + VIR_DOMAIN_DEF_PARSE_INAC= TIVE))) goto endjob; } @@ -4299,22 +4295,22 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr = dom, if (!vmdef) goto endjob; - if (virDomainDefCompatibleDevice(vmdef, dev, NULL, + if (virDomainDefCompatibleDevice(vmdef, dev_config, NULL, VIR_DOMAIN_DEVICE_ACTION_ATTACH, false) < 0) goto endjob; - if ((ret =3D lxcDomainAttachDeviceConfig(vmdef, dev_copy)) < 0) + if ((ret =3D lxcDomainAttachDeviceConfig(vmdef, dev_config)) < 0) goto endjob; } if (flags & VIR_DOMAIN_AFFECT_LIVE) { - if (virDomainDefCompatibleDevice(vm->def, dev, NULL, + if (virDomainDefCompatibleDevice(vm->def, dev_live, NULL, VIR_DOMAIN_DEVICE_ACTION_ATTACH, true) < 0) goto endjob; - if ((ret =3D lxcDomainAttachDeviceLive(driver, vm, dev)) < 0) + if ((ret =3D lxcDomainAttachDeviceLive(driver, vm, dev_live)) < 0) goto endjob; /* * update domain status forcibly because the domain status may be @@ -4338,9 +4334,6 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr do= m, virDomainObjEndJob(vm); cleanup: - if (dev !=3D dev_copy) - virDomainDeviceDefFree(dev_copy); - virDomainDeviceDefFree(dev); virDomainObjEndAPI(&vm); return ret; } --=20 2.37.3 From nobody Sat Apr 27 04:43:10 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=1669209704; cv=none; d=zohomail.com; s=zohoarc; b=RwczC12HCkcw+ogglTLQbt12Cmv3Ld/XveV7eRbCL2Je4U4BUIVuA2TjHTpBeAyUDZOupdX71xw1gqCeKUL3YW2UM2wsla25Wykazlg5dhH+gtW/buzDWYmsYloYh+q0E0FZ22LKqP6EBlLmiHuDhySs+nWRRLk6j210qY6AxsU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669209704; 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=pZl1lXVQV1S+RiabkN0C6l5uEKa/sW9GKNbQDobWXHk=; b=Ler0h6Eku+KDOcoAcwmgd1g2Q0dL1EeQjW3l+G0bHcMFaHazywOO+gNB4vpdBhO+Khv2VpYCvon+URQ1lqtqpCn9qKHssDOVuXtRVReNc7TRDsMPvf455xHsP5T47WKMHX8Ya8Jqb7ye4Thh/cFqoz+2Hkw12n5k4anPfRuwVO0= 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 1669209704425568.3582774752537; Wed, 23 Nov 2022 05:21:44 -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-622-BR7fvzP1OfSEz40zqV6_Xg-1; Wed, 23 Nov 2022 08:21:37 -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 04BBC801585; Wed, 23 Nov 2022 13:21:36 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5D3640C6EC5; Wed, 23 Nov 2022 13:21: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 9ED621946589; Wed, 23 Nov 2022 13:21: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 BEAC61946587 for ; Wed, 23 Nov 2022 12:36:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B068F2166B31; Wed, 23 Nov 2022 12:36:49 +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 152922166B26 for ; Wed, 23 Nov 2022 12:36:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669209703; 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=pZl1lXVQV1S+RiabkN0C6l5uEKa/sW9GKNbQDobWXHk=; b=U88lipwaCSJpJlYlq0pUrrwYX1wV03WSY8Q4yaRq0YMuqn6X/KMiG25188s9tUq+4m9zMh b4pSWMCBiz2k0gEKv83P7usyp+WhdbumkqXeFCvSRCRgPn+5GBhO8nAcqpe7YUl6Uxjhtz GJ1y8d8BaMc4Ul8oNNjb5l9JS/XV7UM= X-MC-Unique: BR7fvzP1OfSEz40zqV6_Xg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 6/7] lxcDomainDetachDeviceFlags: Parse XML twice rather than use virDomainDeviceDefCopy Date: Wed, 23 Nov 2022 13:36:40 +0100 Message-Id: <77c9db389c20028ae6257708ef9df162fce4901e.1669206840.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: 1669209706640100001 Content-Type: text/plain; charset="utf-8" 'virDomainDeviceDefCopy' formats the definition and parses it back. Since we already are parsing the XML here, we're better off parsing it twice and save the formatting step. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/lxc/lxc_driver.c | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 2801ed3d6d..5a16e7375e 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -4416,8 +4416,10 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr d= om, g_autoptr(virCaps) caps =3D NULL; virDomainObj *vm =3D NULL; g_autoptr(virDomainDef) vmdef =3D NULL; - virDomainDeviceDef *dev =3D NULL; - virDomainDeviceDef *dev_copy =3D NULL; + g_autoptr(virDomainDeviceDef) dev_config =3D NULL; + g_autoptr(virDomainDeviceDef) dev_live =3D NULL; + unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE | + VIR_DOMAIN_DEF_PARSE_INACTIVE; int ret =3D -1; g_autoptr(virLXCDriverConfig) cfg =3D virLXCDriverGetConfig(driver); @@ -4439,22 +4441,15 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr = dom, if (!(caps =3D virLXCDriverGetCapabilities(driver, false))) goto endjob; - dev =3D dev_copy =3D virDomainDeviceDefParse(xml, vm->def, - driver->xmlopt, NULL, - VIR_DOMAIN_DEF_PARSE_INACTIVE= | - VIR_DOMAIN_DEF_PARSE_SKIP_VAL= IDATE); - if (dev =3D=3D NULL) - goto endjob; + if (flags & VIR_DOMAIN_AFFECT_CONFIG) { + if (!(dev_config =3D virDomainDeviceDefParse(xml, vm->def, driver-= >xmlopt, + NULL, parse_flags))) + goto endjob; + } - if (flags & VIR_DOMAIN_AFFECT_CONFIG && - flags & VIR_DOMAIN_AFFECT_LIVE) { - /* If we are affecting both CONFIG and LIVE - * create a deep copy of device as adding - * to CONFIG takes one instance. - */ - dev_copy =3D virDomainDeviceDefCopy(dev, vm->def, - driver->xmlopt, NULL); - if (!dev_copy) + if (flags & VIR_DOMAIN_AFFECT_LIVE) { + if (!(dev_live =3D virDomainDeviceDefParse(xml, vm->def, driver->x= mlopt, + NULL, parse_flags))) goto endjob; } @@ -4464,12 +4459,12 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr = dom, if (!vmdef) goto endjob; - if ((ret =3D lxcDomainDetachDeviceConfig(vmdef, dev_copy)) < 0) + if ((ret =3D lxcDomainDetachDeviceConfig(vmdef, dev_config)) < 0) goto endjob; } if (flags & VIR_DOMAIN_AFFECT_LIVE) { - if ((ret =3D lxcDomainDetachDeviceLive(driver, vm, dev)) < 0) + if ((ret =3D lxcDomainDetachDeviceLive(driver, vm, dev_live)) < 0) goto endjob; /* * update domain status forcibly because the domain status may be @@ -4493,9 +4488,6 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr do= m, virDomainObjEndJob(vm); cleanup: - if (dev !=3D dev_copy) - virDomainDeviceDefFree(dev_copy); - virDomainDeviceDefFree(dev); virDomainObjEndAPI(&vm); return ret; } --=20 2.37.3 From nobody Sat Apr 27 04:43:10 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=1669208121; cv=none; d=zohomail.com; s=zohoarc; b=O8hm6QxS5c7hTjUQw4efQlZyqZ9S5WA+ZDr8H6g07YMyvb+o5mtJqnrerCPt/C0Areg10HbFcTJ/xIqWbmJrvshaCE3vXKbvNZqVMdTQWUqVhCcnMmGGx37Uy1ZVPsPKlfRqG3ZXS6YpS+aPXkdy7PZjIa0qB7jGH9xYp/XRycE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669208121; 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=VZKKvmf7iHSFowLIjdtBRPitQeOpytJDYNKhvPCKDmM=; b=Cl6h7oyS+ErAYS+Yb1I0cBBEDRPQzOMGFvxrGrqZLWlICCP8sJjvdWaMD4nQBUFADI0Jjv45tYBBslwdZbxRr1aWE4rjiHvYxRPjsFNT5f3oTIV50czf2rYyxEo4ovWWHC6vK/mM6l9WL8bVRNtafNbYQPZ0NCumVuCyfATzuZo= 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 16692081214481021.5874519267995; Wed, 23 Nov 2022 04:55:21 -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-455-SPn0vDsaNeKJTyp9y47bsw-1; Wed, 23 Nov 2022 07:55:18 -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 29FEA3833286; Wed, 23 Nov 2022 12:55:16 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE3464EA4E; Wed, 23 Nov 2022 12:55:15 +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 667ED1946589; Wed, 23 Nov 2022 12:55:15 +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 F11C41946587 for ; Wed, 23 Nov 2022 12:36:50 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D59D72166B31; Wed, 23 Nov 2022 12:36:50 +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 2D01E2166B26 for ; Wed, 23 Nov 2022 12:36:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669208120; 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=VZKKvmf7iHSFowLIjdtBRPitQeOpytJDYNKhvPCKDmM=; b=TbOjV6AgM7W7jvlNMZ5JHWkMKtRzJkxZbvGnBW/Wphp44wPob48P8zuZQD5/60bKryGToF sZeAMp+wpGiyStWgLTmU8Rs5LeYMtQOZWKYPZ/pC/RgKu+59e6ZsSENtKwdTAYT8mlhsKy jJYHpXFES/blHnEfI1ZdKTlvD1XtYM0= X-MC-Unique: SPn0vDsaNeKJTyp9y47bsw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 7/7] conf: domain: Remove virDomainDeviceDefCopy Date: Wed, 23 Nov 2022 13:36:41 +0100 Message-Id: <67981e185cf799f26183b761c8ec67ffbb8e578c.1669206840.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: 1669208123694100001 Content-Type: text/plain; charset="utf-8" The function is now unused. Remove it to dissuade anybody from trying to use it in the future. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 121 --------------------------------------- src/conf/domain_conf.h | 4 -- src/libvirt_private.syms | 1 - 3 files changed, 126 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3790121cf7..ce16cc414a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -28347,127 +28347,6 @@ virDomainNetFindByName(virDomainDef *def, } -/** - * virDomainDeviceDefCopy: - * @caps: Capabilities - * @def: Domain definition to which @src belongs - * @src: source to be copied - * - * virDomainDeviceDefCopy does a deep copy of only the parts of a - * DeviceDef that are valid when just the flag VIR_DOMAIN_DEF_PARSE_INACTI= VE is - * set. This means that any part of the device xml that is conditionally - * parsed/formatted based on some other flag being set (or on the INACTIVE - * flag being reset) *will not* be copied to the destination. Caveat empto= r. - * - * Returns a pointer to copied @src or NULL in case of error. - */ -virDomainDeviceDef * -virDomainDeviceDefCopy(virDomainDeviceDef *src, - const virDomainDef *def, - virDomainXMLOption *xmlopt, - void *parseOpaque) -{ - g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - int flags =3D VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_FORMAT_S= ECURE; - int rc =3D -1; - g_autofree char *xmlStr =3D NULL; - - switch ((virDomainDeviceType) src->type) { - case VIR_DOMAIN_DEVICE_DISK: - rc =3D virDomainDiskDefFormat(&buf, src->data.disk, flags, xmlopt); - break; - case VIR_DOMAIN_DEVICE_LEASE: - virDomainLeaseDefFormat(&buf, src->data.lease); - rc =3D 0; - break; - case VIR_DOMAIN_DEVICE_FS: - rc =3D virDomainFSDefFormat(&buf, src->data.fs, flags); - break; - case VIR_DOMAIN_DEVICE_NET: - rc =3D virDomainNetDefFormat(&buf, src->data.net, xmlopt, flags); - break; - case VIR_DOMAIN_DEVICE_INPUT: - rc =3D virDomainInputDefFormat(&buf, src->data.input, flags); - break; - case VIR_DOMAIN_DEVICE_SOUND: - rc =3D virDomainSoundDefFormat(&buf, src->data.sound, flags); - break; - case VIR_DOMAIN_DEVICE_VIDEO: - rc =3D virDomainVideoDefFormat(&buf, src->data.video, flags); - break; - case VIR_DOMAIN_DEVICE_HOSTDEV: - rc =3D virDomainHostdevDefFormat(&buf, src->data.hostdev, flags, x= mlopt); - break; - case VIR_DOMAIN_DEVICE_WATCHDOG: - rc =3D virDomainWatchdogDefFormat(&buf, src->data.watchdog, flags); - break; - case VIR_DOMAIN_DEVICE_CONTROLLER: - rc =3D virDomainControllerDefFormat(&buf, src->data.controller, fl= ags); - break; - case VIR_DOMAIN_DEVICE_GRAPHICS: - rc =3D virDomainGraphicsDefFormat(&buf, src->data.graphics, flags); - break; - case VIR_DOMAIN_DEVICE_HUB: - rc =3D virDomainHubDefFormat(&buf, src->data.hub, flags); - break; - case VIR_DOMAIN_DEVICE_REDIRDEV: - rc =3D virDomainRedirdevDefFormat(&buf, src->data.redirdev, flags); - break; - case VIR_DOMAIN_DEVICE_RNG: - rc =3D virDomainRNGDefFormat(&buf, src->data.rng, flags); - break; - case VIR_DOMAIN_DEVICE_CHR: - rc =3D virDomainChrDefFormat(&buf, src->data.chr, flags); - break; - case VIR_DOMAIN_DEVICE_TPM: - virDomainTPMDefFormat(&buf, src->data.tpm, flags, xmlopt); - rc =3D 0; - break; - case VIR_DOMAIN_DEVICE_PANIC: - virDomainPanicDefFormat(&buf, src->data.panic); - rc =3D 0; - break; - case VIR_DOMAIN_DEVICE_MEMORY: - rc =3D virDomainMemoryDefFormat(&buf, src->data.memory, flags); - break; - case VIR_DOMAIN_DEVICE_SHMEM: - virDomainShmemDefFormat(&buf, src->data.shmem, flags); - rc =3D 0; - break; - case VIR_DOMAIN_DEVICE_IOMMU: - virDomainIOMMUDefFormat(&buf, src->data.iommu); - rc =3D 0; - break; - case VIR_DOMAIN_DEVICE_VSOCK: - virDomainVsockDefFormat(&buf, src->data.vsock); - rc =3D 0; - break; - case VIR_DOMAIN_DEVICE_AUDIO: - rc =3D virDomainAudioDefFormat(&buf, src->data.audio); - break; - - case VIR_DOMAIN_DEVICE_NONE: - case VIR_DOMAIN_DEVICE_SMARTCARD: - case VIR_DOMAIN_DEVICE_MEMBALLOON: - case VIR_DOMAIN_DEVICE_NVRAM: - case VIR_DOMAIN_DEVICE_LAST: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Copying definition of '%d' type " - "is not implemented yet."), - src->type); - return NULL; - } - - if (rc < 0) - return NULL; - - xmlStr =3D virBufferContentAndReset(&buf); - return virDomainDeviceDefParse(xmlStr, def, xmlopt, parseOpaque, - VIR_DOMAIN_DEF_PARSE_INACTIVE | - VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE); -} - - virSecurityLabelDef * virDomainDefGetSecurityLabelDef(const virDomainDef *def, const char *model) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a9f7e8d977..c19dfc5470 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3471,10 +3471,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainShmemDef, vir= DomainShmemDefFree); void virDomainDeviceDefFree(virDomainDeviceDef *def); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainDeviceDef, virDomainDeviceDefFree); -virDomainDeviceDef *virDomainDeviceDefCopy(virDomainDeviceDef *src, - const virDomainDef *def, - virDomainXMLOption *xmlopt, - void *parseOpaque); virDomainDeviceInfo *virDomainDeviceGetInfo(const virDomainDeviceDef *devi= ce); void virDomainDeviceSetData(virDomainDeviceDef *device, void *devicedata); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ebd7bc61a8..fd79a9d440 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -353,7 +353,6 @@ virDomainDefSetVcpusMax; virDomainDefVcpuOrderClear; virDomainDeleteConfig; virDomainDeviceAliasIsUserAlias; -virDomainDeviceDefCopy; virDomainDeviceDefFree; virDomainDeviceDefParse; virDomainDeviceFindSCSIController; --=20 2.37.3