Re: [PATCH 3/4] test_driver: implement virDomainFSThaw

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

 



On Tue, Jul 09, 2019 at 09:23:23PM +0200, Ilias Stamatis wrote:
> Signed-off-by: Ilias Stamatis <stamatis.iliass@xxxxxxxxx>
> ---
>  src/test/test_driver.c | 66 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 66 insertions(+)
>
> diff --git a/src/test/test_driver.c b/src/test/test_driver.c
> index 8c25c679a5..097720bb0a 100644
> --- a/src/test/test_driver.c
> +++ b/src/test/test_driver.c
> @@ -3496,6 +3496,71 @@ testDomainFSFreeze(virDomainPtr dom,
>  }
>
>
> +static int
> +testDomainFSThaw(virDomainPtr dom,
> +                   const char **mountpoints,
> +                   unsigned int nmountpoints,
> +                   unsigned int flags)
> +{
> +    virDomainObjPtr vm;
> +    testDomainObjPrivatePtr priv;
> +    size_t i;
> +    int slash = 0, slash_boot = 0;

One declaration per line...

> +    int ret = -1;
> +
> +    virCheckFlags(0, -1);
> +
> +    if (!(vm = testDomObjFromDomain(dom)))
> +        goto cleanup;
> +
> +    if (virDomainObjCheckActive(vm) < 0)
> +        goto cleanup;
> +
> +    priv = vm->privateData;
> +
> +    if (nmountpoints == 0) {
> +        ret = priv->frozen[0] + priv->frozen[1];
> +        priv->frozen[0] = priv->frozen[1] = false;
> +    } else {
> +        for (i = 0; i < nmountpoints; i++) {
> +            if (STREQ(mountpoints[i], "/")) {
> +                if (priv->frozen[0]) {
> +                    slash = 1;
> +                } else {
> +                    virReportError(VIR_ERR_OPERATION_INVALID, "%s",
> +                                   _("mount point is not frozen: /"));
> +                    goto cleanup;
> +                }

I don't think ^this is an error per se, instead we can silently ignore the
mountpoint if it's already been thawed prior to calling this API.

> +            } else if (STREQ(mountpoints[i], "/boot")) {
> +                if (priv->frozen[1]) {
> +                    slash_boot = 1;
> +                } else {
> +                    virReportError(VIR_ERR_OPERATION_INVALID, "%s",
> +                                   _("mount point is not frozen: /boot"));
> +                    goto cleanup;
> +                }

Same here...

> +            } else {
> +                virReportError(VIR_ERR_OPERATION_INVALID,
> +                               _("mount point not found: %s"),
> +                               mountpoints[i]);
> +                goto cleanup;
> +            }
> +        }
> +
> +        if (slash)
> +            priv->frozen[0] = false;
> +        if (slash_boot)
> +            priv->frozen[1] = false;
> +
> +        ret = slash + slash_boot;
> +    }

Consider the alternative implementation I hinted in comments to 2/4

Erik

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