From nobody Tue May 7 01:22:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519309334695240.17765023837478; Thu, 22 Feb 2018 06:22:14 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7CDE0757C2; Thu, 22 Feb 2018 14:22:13 +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 50F365D9CC; Thu, 22 Feb 2018 14:22:13 +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 1BE464A472; Thu, 22 Feb 2018 14:22:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1MELxad002117 for ; Thu, 22 Feb 2018 09:21:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id 774F110073BC; Thu, 22 Feb 2018 14:21:59 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 55BF310073B0 for ; Thu, 22 Feb 2018 14:21:57 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 7EF4D1000CA; Thu, 22 Feb 2018 15:21:56 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Thu, 22 Feb 2018 15:21:53 +0100 Message-Id: <69c4b39b17132cdc8a3a9916d87d740bf4d54274.1519309259.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/3] lxc: Drop useless check in live device update 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 22 Feb 2018 14:22:13 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Checking the new device definition makes little sense when lxc driver does not support live device update at all. Signed-off-by: Jiri Denemark --- src/lxc/lxc_driver.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 3d5b2254f2..4c6f09a435 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -4939,9 +4939,6 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr do= m, } =20 if (flags & VIR_DOMAIN_AFFECT_LIVE) { - if (virDomainDefCompatibleDevice(vm->def, dev_copy) < 0) - goto endjob; - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("Unable to modify live devices")); =20 --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 01:22:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519309325061529.5105729769456; Thu, 22 Feb 2018 06:22:05 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 407B6C0587E6; Thu, 22 Feb 2018 14:22:03 +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 18FC15D75F; Thu, 22 Feb 2018 14:22:03 +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 D64BF4A46E; Thu, 22 Feb 2018 14:22:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1MELxcL002118 for ; Thu, 22 Feb 2018 09:21:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id A2C44AB592; Thu, 22 Feb 2018 14:21:59 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 65972AF037 for ; Thu, 22 Feb 2018 14:21:57 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 81A9C101761; Thu, 22 Feb 2018 15:21:56 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Thu, 22 Feb 2018 15:21:54 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/3] Pass oldDev to virDomainDefCompatibleDevice on device update 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 22 Feb 2018 14:22:03 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When calling virDomainDefCompatibleDevice to check a new device during device update, we need to pass the original device which is going to be updated in addition to the new device. Otherwise, the function can report false conflicts. The new argument is currently ignored by virDomainDefCompatibleDevice, but this will change in the following patch. https://bugzilla.redhat.com/show_bug.cgi?id=3D1546971 Signed-off-by: Jiri Denemark --- src/conf/domain_conf.c | 3 ++- src/conf/domain_conf.h | 3 ++- src/lxc/lxc_driver.c | 15 +++++++++------ src/qemu/qemu_driver.c | 51 ++++++++++++++++++++++++++++++++++++++++------= ---- 4 files changed, 54 insertions(+), 18 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f2ddde7a36..c71c28e8d2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -27400,7 +27400,8 @@ virDomainDeviceInfoCheckBootIndex(virDomainDefPtr d= ef ATTRIBUTE_UNUSED, =20 int virDomainDefCompatibleDevice(virDomainDefPtr def, - virDomainDeviceDefPtr dev) + virDomainDeviceDefPtr dev, + virDomainDeviceDefPtr oldDev ATTRIBUTE_UNUSED) { virDomainDeviceInfoPtr info =3D virDomainDeviceGetInfo(dev); =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 2350926e5b..368f16f3fb 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3014,7 +3014,8 @@ typedef enum { } virDomainDeviceAction; =20 int virDomainDefCompatibleDevice(virDomainDefPtr def, - virDomainDeviceDefPtr dev); + virDomainDeviceDefPtr dev, + virDomainDeviceDefPtr oldDev); =20 void virDomainRNGDefFree(virDomainRNGDefPtr def); =20 diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 4c6f09a435..fa6fc4643e 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -3578,6 +3578,7 @@ lxcDomainUpdateDeviceConfig(virDomainDefPtr vmdef, { int ret =3D -1; virDomainNetDefPtr net; + virDomainDeviceDef oldDev =3D { .type =3D dev->type }; int idx; =20 switch (dev->type) { @@ -3586,8 +3587,11 @@ lxcDomainUpdateDeviceConfig(virDomainDefPtr vmdef, if ((idx =3D virDomainNetFindIdx(vmdef, net)) < 0) goto cleanup; =20 - virDomainNetDefFree(vmdef->nets[idx]); + oldDev.data.net =3D vmdef->nets[idx]; + if (virDomainDefCompatibleDevice(vmdef, dev, &oldDev) < 0) + return -1; =20 + virDomainNetDefFree(vmdef->nets[idx]); vmdef->nets[idx] =3D net; dev->data.net =3D NULL; ret =3D 0; @@ -4820,7 +4824,7 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr do= m, if (!vmdef) goto endjob; =20 - if (virDomainDefCompatibleDevice(vmdef, dev) < 0) + if (virDomainDefCompatibleDevice(vmdef, dev, NULL) < 0) goto endjob; =20 if ((ret =3D lxcDomainAttachDeviceConfig(vmdef, dev)) < 0) @@ -4828,7 +4832,7 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr do= m, } =20 if (flags & VIR_DOMAIN_AFFECT_LIVE) { - if (virDomainDefCompatibleDevice(vm->def, dev_copy) < 0) + if (virDomainDefCompatibleDevice(vm->def, dev_copy, NULL) < 0) goto endjob; =20 if ((ret =3D lxcDomainAttachDeviceLive(dom->conn, driver, vm, dev_= copy)) < 0) @@ -4931,9 +4935,8 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr do= m, if (!vmdef) goto endjob; =20 - if (virDomainDefCompatibleDevice(vmdef, dev) < 0) - goto endjob; - + /* virDomainDefCompatibleDevice call is delayed until we know the + * device we're going to update. */ if ((ret =3D lxcDomainUpdateDeviceConfig(vmdef, dev)) < 0) goto endjob; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 14c39b2610..313d730c79 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7844,6 +7844,7 @@ qemuDomainChangeDiskLive(virDomainObjPtr vm, { virDomainDiskDefPtr disk =3D dev->data.disk; virDomainDiskDefPtr orig_disk =3D NULL; + virDomainDeviceDef oldDev =3D { .type =3D dev->type }; int ret =3D -1; =20 if (virDomainDiskTranslateSourcePool(disk) < 0) @@ -7861,6 +7862,10 @@ qemuDomainChangeDiskLive(virDomainObjPtr vm, goto cleanup; } =20 + oldDev.data.disk =3D orig_disk; + if (virDomainDefCompatibleDevice(vm->def, dev, &oldDev) < 0) + goto cleanup; + if (!qemuDomainDiskChangeSupported(disk, orig_disk)) goto cleanup; =20 @@ -7903,19 +7908,36 @@ qemuDomainUpdateDeviceLive(virDomainObjPtr vm, bool force) { virQEMUDriverPtr driver =3D dom->conn->privateData; + virDomainDeviceDef oldDev =3D { .type =3D dev->type }; int ret =3D -1; + int idx; =20 switch ((virDomainDeviceType) dev->type) { case VIR_DOMAIN_DEVICE_DISK: qemuDomainObjCheckDiskTaint(driver, vm, dev->data.disk, NULL); ret =3D qemuDomainChangeDiskLive(vm, dev, driver, force); break; + case VIR_DOMAIN_DEVICE_GRAPHICS: + if ((idx =3D qemuDomainFindGraphicsIndex(vm->def, dev->data.graphi= cs) >=3D 0)) { + oldDev.data.graphics =3D vm->def->graphics[idx]; + if (virDomainDefCompatibleDevice(vm->def, dev, &oldDev) < 0) + return -1; + } + ret =3D qemuDomainChangeGraphics(driver, vm, dev->data.graphics); break; + case VIR_DOMAIN_DEVICE_NET: + if ((idx =3D virDomainNetFindIdx(vm->def, dev->data.net)) >=3D 0) { + oldDev.data.net =3D vm->def->nets[idx]; + if (virDomainDefCompatibleDevice(vm->def, dev, &oldDev) < 0) + return -1; + } + ret =3D qemuDomainChangeNet(driver, vm, dev); break; + case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_SOUND: @@ -8329,6 +8351,7 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef, virDomainDiskDefPtr newDisk; virDomainGraphicsDefPtr newGraphics; virDomainNetDefPtr net; + virDomainDeviceDef oldDev =3D { .type =3D dev->type }; int pos; =20 switch ((virDomainDeviceType) dev->type) { @@ -8340,6 +8363,10 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef, return -1; } =20 + oldDev.data.disk =3D vmdef->disks[pos]; + if (virDomainDefCompatibleDevice(vmdef, dev, &oldDev) < 0) + return -1; + virDomainDiskDefFree(vmdef->disks[pos]); vmdef->disks[pos] =3D newDisk; dev->data.disk =3D NULL; @@ -8355,8 +8382,11 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef, return -1; } =20 - virDomainGraphicsDefFree(vmdef->graphics[pos]); + oldDev.data.graphics =3D vmdef->graphics[pos]; + if (virDomainDefCompatibleDevice(vmdef, dev, &oldDev) < 0) + return -1; =20 + virDomainGraphicsDefFree(vmdef->graphics[pos]); vmdef->graphics[pos] =3D newGraphics; dev->data.graphics =3D NULL; break; @@ -8366,8 +8396,11 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef, if ((pos =3D virDomainNetFindIdx(vmdef, net)) < 0) return -1; =20 - virDomainNetDefFree(vmdef->nets[pos]); + oldDev.data.net =3D vmdef->nets[pos]; + if (virDomainDefCompatibleDevice(vmdef, dev, &oldDev) < 0) + return -1; =20 + virDomainNetDefFree(vmdef->nets[pos]); vmdef->nets[pos] =3D net; dev->data.net =3D NULL; break; @@ -8454,7 +8487,7 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr v= m, if (!vmdef) goto cleanup; =20 - if (virDomainDefCompatibleDevice(vmdef, dev) < 0) + if (virDomainDefCompatibleDevice(vmdef, dev, NULL) < 0) goto cleanup; if ((ret =3D qemuDomainAttachDeviceConfig(vmdef, dev, caps, parse_flags, @@ -8463,7 +8496,7 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr v= m, } =20 if (flags & VIR_DOMAIN_AFFECT_LIVE) { - if (virDomainDefCompatibleDevice(vm->def, dev_copy) < 0) + if (virDomainDefCompatibleDevice(vm->def, dev_copy, NULL) < 0) goto cleanup; =20 if ((ret =3D qemuDomainAttachDeviceLive(vm, dev_copy, driver)) < 0) @@ -8603,9 +8636,8 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr d= om, if (!vmdef) goto endjob; =20 - if (virDomainDefCompatibleDevice(vmdef, dev) < 0) - goto endjob; - + /* virDomainDefCompatibleDevice call is delayed until we know the + * device we're going to update. */ if ((ret =3D qemuDomainUpdateDeviceConfig(vmdef, dev, caps, parse_flags, driver->xmlopt)) < 0) @@ -8613,9 +8645,8 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr d= om, } =20 if (flags & VIR_DOMAIN_AFFECT_LIVE) { - if (virDomainDefCompatibleDevice(vm->def, dev_copy) < 0) - goto endjob; - + /* virDomainDefCompatibleDevice call is delayed until we know the + * device we're going to update. */ if ((ret =3D qemuDomainUpdateDeviceLive(vm, dev_copy, dom, force))= < 0) goto endjob; /* --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 01:22:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519309322821887.8733583679975; Thu, 22 Feb 2018 06:22:02 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 37D0328211; Thu, 22 Feb 2018 14:22:01 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D273C608FA; Thu, 22 Feb 2018 14:22:00 +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 67C0618033EA; Thu, 22 Feb 2018 14:21:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1MELvU9002098 for ; Thu, 22 Feb 2018 09:21:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9EC80217B409; Thu, 22 Feb 2018 14:21:57 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7CB2E217B400 for ; Thu, 22 Feb 2018 14:21:57 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 8505D101762; Thu, 22 Feb 2018 15:21:56 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Thu, 22 Feb 2018 15:21:55 +0100 Message-Id: <692e18987d7b29bd3317671f50917614524648cc.1519309259.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/3] qemu: Fix updating device with boot order 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 22 Feb 2018 14:22:01 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Commit v3.7.0-14-gc57f3fd2f8 prevented adding a element to an inactive domain with global element. However, as a result of that change updating any device with boot order would fail with 'boot order X is already used by another device', where "another device" is in fact the device which is being updated. To fix this we have to ignore the device which we're about to update when checking for boot order conflicts. https://bugzilla.redhat.com/show_bug.cgi?id=3D1546971 Signed-off-by: Jiri Denemark --- src/conf/domain_conf.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c71c28e8d2..d96b012b98 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -27381,18 +27381,30 @@ virDomainDeviceIsUSB(virDomainDeviceDefPtr dev) return false; } =20 + +typedef struct _virDomainCompatibleDeviceData virDomainCompatibleDeviceDat= a; +typedef virDomainCompatibleDeviceData *virDomainCompatibleDeviceDataPtr; +struct _virDomainCompatibleDeviceData { + virDomainDeviceInfoPtr newInfo; + virDomainDeviceInfoPtr oldInfo; +}; + static int virDomainDeviceInfoCheckBootIndex(virDomainDefPtr def ATTRIBUTE_UNUSED, virDomainDeviceDefPtr device ATTRIBUTE_U= NUSED, virDomainDeviceInfoPtr info, void *opaque) { - virDomainDeviceInfoPtr newinfo =3D opaque; + virDomainCompatibleDeviceDataPtr data =3D opaque; =20 - if (info->bootIndex =3D=3D newinfo->bootIndex) { + /* Ignore the device we're about to update */ + if (data->oldInfo =3D=3D info) + return 0; + + if (info->bootIndex =3D=3D data->newInfo->bootIndex) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("boot order %u is already used by another device"= ), - newinfo->bootIndex); + data->newInfo->bootIndex); return -1; } return 0; @@ -27401,9 +27413,12 @@ virDomainDeviceInfoCheckBootIndex(virDomainDefPtr = def ATTRIBUTE_UNUSED, int virDomainDefCompatibleDevice(virDomainDefPtr def, virDomainDeviceDefPtr dev, - virDomainDeviceDefPtr oldDev ATTRIBUTE_UNUSED) + virDomainDeviceDefPtr oldDev) { - virDomainDeviceInfoPtr info =3D virDomainDeviceGetInfo(dev); + virDomainCompatibleDeviceData data =3D { + .newInfo =3D virDomainDeviceGetInfo(dev), + .oldInfo =3D virDomainDeviceGetInfo(oldDev), + }; =20 if (!virDomainDefHasUSB(def) && def->os.type !=3D VIR_DOMAIN_OSTYPE_EXE && @@ -27414,7 +27429,7 @@ virDomainDefCompatibleDevice(virDomainDefPtr def, return -1; } =20 - if (info && info->bootIndex > 0) { + if (data.newInfo && data.newInfo->bootIndex > 0) { if (def->os.nBootDevs > 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("per-device boot elements cannot be used" @@ -27423,7 +27438,7 @@ virDomainDefCompatibleDevice(virDomainDefPtr def, } if (virDomainDeviceInfoIterate(def, virDomainDeviceInfoCheckBootIndex, - info) < 0) + &data) < 0) return -1; } =20 --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list