[libvirt] [PATCH] qemu: Check for existing hostdev address for cold attach device

Ján Tomko jtomko at redhat.com
Mon Jun 11 14:42:56 UTC 2018


On Wed, Jun 06, 2018 at 10:44:10AM -0400, John Ferlan wrote:
>https://bugzilla.redhat.com/show_bug.cgi?id=1559867
>
>Add a check if the incoming <hostdev ...> with specified <address>
>already exists and if so fail the attach.
>

Looking at the reproducer steps, the bug talks about libvirt
auto-generating a duplicate address, not user-specified input.

>Signed-off-by: John Ferlan <jferlan at redhat.com>
>---
> src/qemu/qemu_driver.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
>diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
>index 38ea865ce3..7b4cdbcdcf 100644
>--- a/src/qemu/qemu_driver.c
>+++ b/src/qemu/qemu_driver.c
>@@ -8014,6 +8014,12 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
>                            _("device is already in the domain configuration"));
>             return -1;
>         }
>+        if (dev->data.hostdev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
>+            virDomainDefHasDeviceAddress(vmdef, dev->data.hostdev->info)) {
>+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
>+                           _("a device with the same address already exists "));
>+            return -1;
>+        }

This does not fix the problem of autogenerating the address in any way
(which seems to work when I call attach --config while the domain is not
running).

Also, if we needded additional checks for guest addresses on attach,
we should either do it for all devices (and drop the calling of
per-domain postParse after adding a single device), or take care of the
conflicts in postParse.

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180611/3c841ac2/attachment-0001.sig>


More information about the libvir-list mailing list