[libvirt] [PATCH v2 1/9] test: Allow specifying object runstate in driver XML

Eric Blake eblake at redhat.com
Fri Aug 30 16:43:59 UTC 2013


On 08/30/2013 10:03 AM, Cole Robinson wrote:
> When passing in custom driver XML, allow a block like
> 
> <domain xmlns:test='http://libvirt.org/schemas/domain/test/1.0'>
>   ...
>   <test:runstate>5</test:runstate>

Since the enum virDomainState is part of our public API, I'm not worried
about the numbers ever being tied to the wrong state.  But wouldn't it
be nicer for the XML to use a string conversion of a name, rather than
just a raw number?  On the other hand, this is just for testing
purposes, so I can live with it.

> </domain>
> 
> This is only read at initial driver start time, and sets the initial
> run state of the object. This is handy for UI testing.
> 
> It's only wired up for domains, since that's the only conf/
> infrastructure that supports namespaces at the moment.
> ---
>  src/test/test_driver.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 84 insertions(+), 7 deletions(-)
> 

> +
> +    tmp = virXPathUInt("string(./test:runstate)", ctxt, &tmpuint);
> +    if (tmp == 0) {
> +        if (tmpuint >= VIR_DOMAIN_LAST) {
> +            virReportError(VIR_ERR_XML_ERROR,
> +                           _("runstate '%d' out of range'"), tmpuint);
> +            goto error;
> +        }
> +        nsdata->runstate = tmpuint;

Should we also reject VIR_DOMAIN_NOSTATE?

> +    };
> +
> +    /* All our XML extensions are write only, so we only need to parse */

Maybe s/write only/input only/

ACK, but not until after the release.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130830/9e6e158c/attachment-0001.sig>


More information about the libvir-list mailing list