From nobody Sun Feb 8 18:48:57 2026 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 15317757088591001.9010500842091; Mon, 16 Jul 2018 14:15:08 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1D51DC04AC4C; Mon, 16 Jul 2018 21:15:05 +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 BE727CABF6; Mon, 16 Jul 2018 21:15:04 +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 4095918037EF; Mon, 16 Jul 2018 21:15:04 +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 w6GLEUfr003183 for ; Mon, 16 Jul 2018 17:14:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4E10F600CD; Mon, 16 Jul 2018 21:14:30 +0000 (UTC) Received: from unknown4CEB42C824F4.redhat.com (ovpn-116-112.phx2.redhat.com [10.3.116.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C705600C9 for ; Mon, 16 Jul 2018 21:14:29 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 16 Jul 2018 17:14:23 -0400 Message-Id: <20180716211424.15582-3-jferlan@redhat.com> In-Reply-To: <20180716211424.15582-1-jferlan@redhat.com> References: <20180716211424.15582-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 2/3] qemu: Check for existing address when cold attach device 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.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 16 Jul 2018 21:15:07 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Now that virDomainDefCompatibleDevice accepts an action, let's use that to generically determine whether a to be cold plugged device with a defined
would conflict with any existing address for the domain config. This replaces the RNG check in qemuDomainAttachDeviceConfig. This type of check would need to be made before a device is inserted into its domain device list (disk, rng, hostdev, etc.). This type of check cannot be done during the post parse processing because the check would conflict with itself as the device would be placed onto the its device list prior to post parse. By comparison this is similar to the validation phase checks in virDomainDefCheckDuplicateDriveAddresses that occur during define/startup processing, but are not run during config attach of a live guest. Signed-off-by: John Ferlan --- src/conf/domain_conf.c | 22 ++++++++++++++++++++++ src/qemu/qemu_driver.c | 7 ------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 82df8012af..fd5bc10c82 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -28270,11 +28270,25 @@ virDomainDefCompatibleDevice(virDomainDefPtr def, virDomainDeviceAction action, bool live) { + int target_bus =3D -1; virDomainCompatibleDeviceData data =3D { .newInfo =3D virDomainDeviceGetInfo(dev), .oldInfo =3D NULL, }; =20 + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_DISK) { + target_bus =3D dev->data.disk->bus; + } else if (dev->type =3D=3D VIR_DOMAIN_DEVICE_HOSTDEV && + dev->data.hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBS= YS) { + virDomainHostdevSubsysPtr subsys =3D &dev->data.hostdev->source.su= bsys; + + /* If using 'scsi' or 'scsi_host', then the device can be placed + * on the same bus as a , so account for that */ + if (subsys->type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI || + subsys->type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST) + target_bus =3D VIR_DOMAIN_DISK_BUS_SCSI; + } + if (oldDev) data.oldInfo =3D virDomainDeviceGetInfo(oldDev); =20 @@ -28288,6 +28302,14 @@ virDomainDefCompatibleDevice(virDomainDefPtr def, return -1; } =20 + if (action =3D=3D VIR_DOMAIN_DEVICE_ACTION_ATTACH && !live && data.new= Info && + data.newInfo->type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && + virDomainDefHasDeviceAddress(def, target_bus, data.newInfo)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("a device with the same address already exists")); + return -1; + } + if (!virDomainDefHasUSB(def) && def->os.type !=3D VIR_DOMAIN_OSTYPE_EXE && virDomainDeviceIsUSB(dev)) { diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 5f91d463ae..7d519c0714 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8081,13 +8081,6 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, break; =20 case VIR_DOMAIN_DEVICE_RNG: - if (dev->data.rng->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_N= ONE && - virDomainDefHasDeviceAddress(vmdef, -1, &dev->data.rng->info))= { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("a device with the same address already exist= s ")); - return -1; - } - if (VIR_APPEND_ELEMENT(vmdef->rngs, vmdef->nrngs, dev->data.rng) <= 0) return -1; dev->data.rng =3D NULL; --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list