From nobody Mon Feb 9 07:55:58 2026 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 --- 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