Re: [PATCH 2/3] qemu: Check for generated MACs while detaching interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 02/24/2011 07:56 AM, Michal Privoznik wrote:
> When detaching interface without <mac> specified a one is generated
> which leads to not found device.
> ---
>  src/qemu/qemu_hotplug.c |   26 ++++++++++++++++++++------
>  1 files changed, 20 insertions(+), 6 deletions(-)
> 
> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index 0002af0..54c97db 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -1436,18 +1436,32 @@ int qemuDomainDetachNetDevice(struct qemud_driver *driver,
>                                virDomainDeviceDefPtr dev,
>                                virBitmapPtr qemuCaps)
>  {
> -    int i, ret = -1;
> +    int i = 0, ret = -1;
>      virDomainNetDefPtr detach = NULL;
>      qemuDomainObjPrivatePtr priv = vm->privateData;
>      int vlan;
>      char *hostnet_name = NULL;
>  
> -    for (i = 0 ; i < vm->def->nnets ; i++) {
> -        virDomainNetDefPtr net = vm->def->nets[i];
> +    if (!vm->def->nnets) {
> +        qemuReportError(VIR_ERR_OPERATION_FAILED,
> +                        _("domain has no interfaces."));
> +        goto cleanup;
> +    } else if ((vm->def->nnets > 2) && (dev->data.net->mac_generated)) {
> +        qemuReportError(VIR_ERR_OPERATION_FAILED,
> +                        _("You must specify mac address in xml file"));
> +        goto cleanup;
> +    }

If we refactor patch 1 to pass an additional flag to the parse routines
to avoid generating the mac in the first place, then this logic needs to
change a bit.  It turns into this pseudocode:

match = NULL;
for (i = 0; i < nnets; i++) {
    if (nets[i] matches dev) {
        if (match) error: ambiguous
        match = nets[i]
    }
}
if (!match) error: no match

This would also solve Hu Tao's point - if you have two interfaces, it is
then possible to provide xml that lists just the pci address and still
only matches one of the two interfaces, without requiring that the mac
address be provided in the xml.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]