From nobody Tue Apr 30 21:46:05 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=1641315590; cv=none; d=zohomail.com; s=zohoarc; b=YxCuEBxmtum5bR4oMPVG2gdNLfzEMxeN7RSBnsVd1Rlh70iIhZmTVI7zgxd2miC53f0w79kdHWLcwoF4SEp9rY4aMin2aG70f7LhHonpiv1+VfD+skkNovU5MnAG9Ja/utw/lqbnGyvxvm49nFbPSUTccRGVHKmyjCxf+NaMnfU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641315590; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=wUx6Fbcc14ffZDlndQX8eiw2OW/OsV556bKacGE1JKQ=; b=h3EWrGLWcg/5XWWZZcCNTNXewAywAqWhXhzpAVQakXh1FnvY9CZCY2nUgSN9smmF/Tdvuql5aSlQroB0ljfuvsdrdnZ3DHBQe3Sgxc/80di1EUvFQaqb6p14qdTdDv/9Tubxa9dXgSX+wubSXPHJEdcv7pNYoPCPPm50X8ZAoXQ= 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 1641315590018852.6162153166046; Tue, 4 Jan 2022 08:59:50 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-81-fwylqRFGP4yo8IGEKSf7fQ-1; Tue, 04 Jan 2022 11:59:47 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 159DD1054FBC; Tue, 4 Jan 2022 16:59:41 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 95F368CB31; Tue, 4 Jan 2022 16:59:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 06EC14BB7C; Tue, 4 Jan 2022 16:59:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 204Gxc8J005239 for ; Tue, 4 Jan 2022 11:59:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id AE6EF7ED95; Tue, 4 Jan 2022 16:59:38 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3816A7ED94 for ; Tue, 4 Jan 2022 16:59:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641315588; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=wUx6Fbcc14ffZDlndQX8eiw2OW/OsV556bKacGE1JKQ=; b=OlcG5+DTBy4CjtggddMBWLXsQ7B47EMzAfzU/r3huIWBXk1RYSYGzX2hwCgbHFfs2LdP5h unS1wOkfD3LY6V/554a36wp5t1oXZvxgJA2yHeZGEn0GK3wJ5lis7uYaOQDhVGMqlwTxhi /gmCHr4Efl+n/muRfW9GXj83f31PxKQ= X-MC-Unique: fwylqRFGP4yo8IGEKSf7fQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] Account for fact that virDomainDeviceDefCopy() does an inactive copy Date: Tue, 4 Jan 2022 17:59:19 +0100 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1641315591677100001 Content-Type: text/plain; charset="utf-8" In a few places (e.g. device attach/detach/update) we are given a device XML, parse it but then need a copy of parsed data so that the original can be passed to function handling the request over inactive XML and the copy is then passed to function handling the operation over live XML. Note, both functions consume passed device on success, hence the need for copy. The problem is in combination of how the copy is obtained and where is passed. The copy is done by calling virDomainDeviceDefCopy() which does only inactive copy, i.e. no live information is copied over (e.g. no aliases). Then, this copy (inactive XML effectively) is passed to function handling live part of the operation (e.g. qemuDomainUpdateDeviceLive()) and the definition containing all the juicy, live bits is passed to function handling inactive part of the operation (e.g. qemuDomainUpdateDeviceConfig()). This is rather suboptimal, and XML copies should be passed to their respective functions. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2036895 Signed-off-by: Michal Privoznik Reviewed-by: Laine Stump --- src/lxc/lxc_driver.c | 10 +++++----- src/qemu/qemu_driver.c | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index fe583ccb76..7bc39120ee 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -4308,17 +4308,17 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr = dom, false) < 0) goto endjob; =20 - if ((ret =3D lxcDomainAttachDeviceConfig(vmdef, dev)) < 0) + if ((ret =3D lxcDomainAttachDeviceConfig(vmdef, dev_copy)) < 0) goto endjob; } =20 if (flags & VIR_DOMAIN_AFFECT_LIVE) { - if (virDomainDefCompatibleDevice(vm->def, dev_copy, NULL, + if (virDomainDefCompatibleDevice(vm->def, dev, NULL, VIR_DOMAIN_DEVICE_ACTION_ATTACH, true) < 0) goto endjob; =20 - if ((ret =3D lxcDomainAttachDeviceLive(driver, vm, dev_copy)) < 0) + if ((ret =3D lxcDomainAttachDeviceLive(driver, vm, dev)) < 0) goto endjob; /* * update domain status forcibly because the domain status may be @@ -4475,12 +4475,12 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr = dom, if (!vmdef) goto endjob; =20 - if ((ret =3D lxcDomainDetachDeviceConfig(vmdef, dev)) < 0) + if ((ret =3D lxcDomainDetachDeviceConfig(vmdef, dev_copy)) < 0) goto endjob; } =20 if (flags & VIR_DOMAIN_AFFECT_LIVE) { - if ((ret =3D lxcDomainDetachDeviceLive(driver, vm, dev_copy)) < 0) + if ((ret =3D lxcDomainDetachDeviceLive(driver, vm, dev)) < 0) goto endjob; /* * update domain status forcibly because the domain status may be diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b8537a4260..b1255da9f2 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8020,7 +8020,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr d= om, =20 /* virDomainDefCompatibleDevice call is delayed until we know the * device we're going to update. */ - if ((ret =3D qemuDomainUpdateDeviceConfig(vmdef, dev, priv->qemuCa= ps, + if ((ret =3D qemuDomainUpdateDeviceConfig(vmdef, dev_copy, priv->q= emuCaps, parse_flags, driver->xmlopt)) < 0) goto endjob; @@ -8029,7 +8029,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr d= om, 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_copy, dom, force))= < 0) + if ((ret =3D qemuDomainUpdateDeviceLive(vm, dev, dom, force)) < 0) goto endjob; =20 qemuDomainSaveStatus(vm); @@ -8100,7 +8100,7 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriver *dr= iver, if (!vmdef) goto cleanup; =20 - if (qemuDomainDetachDeviceConfig(vmdef, dev, priv->qemuCaps, + if (qemuDomainDetachDeviceConfig(vmdef, dev_copy, priv->qemuCaps, parse_flags, driver->xmlopt) < 0) goto cleanup; @@ -8109,7 +8109,7 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriver *dr= iver, if (flags & VIR_DOMAIN_AFFECT_LIVE) { int rc; =20 - if ((rc =3D qemuDomainDetachDeviceLive(vm, dev_copy, driver, false= )) < 0) + if ((rc =3D qemuDomainDetachDeviceLive(vm, dev, driver, false)) < = 0) goto cleanup; =20 if (rc =3D=3D 0 && qemuDomainUpdateDeviceList(driver, vm, QEMU_ASY= NC_JOB_NONE) < 0) --=20 2.34.1