Re: [PATCH 1/2] test_driver: implement virDomainManagedSaveGetXMLDesc

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

 



On Wed, Aug 07, 2019 at 06:56:35PM +0200, Ilias Stamatis wrote:
> The managedSave APIs according to the documentation are supposed to
> operate on a disk file. However, this might not be appropriate in the
> case of the test driver since:
>
> * It's better if the test driver keeps all its state in memory only and
> doesn't affect the host in any way.
>
> * The test driver, apart from "emulating" the domains, it additionally
> "emulates" a fake physical host. Every time we start a new test
> connection that sort of means that a new physical host is created as
> well. And this fake host isn't necessarily the same.
>
> What we can do instead is operating on the already existing domain
> definitions. So along as a connection remains open, a domain can
> preserve the managed state between different shutdown / create calls.
> When the test connection closes this means that the fake host is
> destroyed as well, hence no other state is preserved after that.

True, however...

>
> This way we also make sure that we don't touch the real host's
> filesystem.
>
> Signed-off-by: Ilias Stamatis <stamatis.iliass@xxxxxxxxx>
> ---
>  src/test/test_driver.c | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
>
> diff --git a/src/test/test_driver.c b/src/test/test_driver.c
> index 6f18baa265..8715d6c0d6 100755
> --- a/src/test/test_driver.c
> +++ b/src/test/test_driver.c
> @@ -7606,6 +7606,33 @@ testDomainManagedSave(virDomainPtr dom, unsigned int flags)
>  }
>
>
> +static char *
> +testDomainManagedSaveGetXMLDesc(virDomainPtr dom,
> +                                unsigned int flags)
> +{
> +    virDomainObjPtr vm;
> +    testDriverPtr privconn = dom->conn->privateData;
> +    char *ret = NULL;
> +
> +    virCheckFlags(VIR_DOMAIN_SAVE_IMAGE_XML_SECURE, NULL);
> +
> +    if (!(vm = testDomObjFromDomain(dom)))
> +        return NULL;
> +
> +    if (vm->hasManagedSave == false) {
> +        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
> +                       _("domain does not have managed save image"));
> +        goto cleanup;
> +    }
> +
> +    ret = virDomainDefFormat(vm->def, privconn->caps, VIR_DOMAIN_DEF_FORMAT_SECURE);

...^this won't fly, because this function is supposed to return the XML valid
at the time the managedsave was performed. If you e.g. attach a disk to the
inactive XML in the meantime, your changes will mean that managedsave-dumpxml
will return the current config along with the new attached disk, which is
incorrect, so you indeed need to make use of the private data.
Because of ^this I think there's no need to review patch 2 at the moment.

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