Re: [PATCH v2 6/6] test_driver: implement virDomainUpdateDeviceFlags

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

 



On Wed, Aug 14, 2019 at 07:47:10PM +0300, Ilias Stamatis wrote:
> Signed-off-by: Ilias Stamatis <stamatis.iliass@xxxxxxxxx>
> ---
>  src/test/test_driver.c | 72 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 72 insertions(+)
>
> diff --git a/src/test/test_driver.c b/src/test/test_driver.c
> index e271bc58f8..9bf3728654 100755
> --- a/src/test/test_driver.c
> +++ b/src/test/test_driver.c
> @@ -4999,6 +4999,65 @@ testDomainDetachDeviceLiveAndConfig(virDomainDefPtr vmdef,
>  }
>
>
> +static int
> +testDomainUpdateDeviceLiveAndConfig(virDomainDefPtr vmdef,
> +                                    virDomainDeviceDefPtr dev)
> +{
> +    virDomainDiskDefPtr newDisk;
> +    virDomainDeviceDef oldDev = { .type = dev->type };
> +    virDomainNetDefPtr net;
> +    int idx;
> +    int ret = -1;
> +
> +    switch (dev->type) {
> +        case VIR_DOMAIN_DEVICE_DISK:
> +            newDisk = dev->data.disk;
> +            if ((idx = virDomainDiskIndexByName(vmdef, newDisk->dst, false)) < 0) {
> +                virReportError(VIR_ERR_INVALID_ARG,
> +                               _("target %s doesn't exist."), newDisk->dst);
> +                return -1;
> +            }
> +
> +            oldDev.data.disk = vmdef->disks[idx];
> +            if (virDomainDefCompatibleDevice(vmdef, dev, &oldDev,
> +                                             VIR_DOMAIN_DEVICE_ACTION_UPDATE,
> +                                             false) < 0)
> +                return -1;
> +
> +            virDomainDiskDefFree(vmdef->disks[idx]);
> +            vmdef->disks[idx] = newDisk;
> +            dev->data.disk = NULL;
> +            break;
> +
> +        case VIR_DOMAIN_DEVICE_NET:
> +            net = dev->data.net;
> +            if ((idx = virDomainNetFindIdx(vmdef, net)) < 0)
> +                goto cleanup;
> +
> +            oldDev.data.net = vmdef->nets[idx];
> +            if (virDomainDefCompatibleDevice(vmdef, dev, &oldDev,
> +                                             VIR_DOMAIN_DEVICE_ACTION_UPDATE,
> +                                             false) < 0)
> +                return -1;
> +
> +            virDomainNetDefFree(vmdef->nets[idx]);
> +            vmdef->nets[idx] = net;
> +            dev->data.net = NULL;
> +            ret = 0;
> +            break;
> +
> +        default:
> +            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                           _("neither persistent nor live update of device is supported"));
> +            goto cleanup;

return -1;

> +    }
> +
> +    ret = 0;
> + cleanup:

drop the cleanup label

Reviewed-by: Erik Skultety <eskultet@xxxxxxxxxx>

--
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]

  Powered by Linux