[libvirt] [PATCH 15/15] virsh: Adapt to virDomain{Resume, Suspend}Flags

Eric Blake eblake at redhat.com
Mon Feb 3 18:15:47 UTC 2014


On 02/03/2014 09:17 AM, Michal Privoznik wrote:
> Things get complicated once we want to fall back to using the older
> versions of APIs when talking to older libvirtd.
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  tools/virsh-domain.c | 52 +++++++++++++++++++++++++++++++++++++++-------------
>  1 file changed, 39 insertions(+), 13 deletions(-)
> 
>  
> -    if (virDomainSuspend(dom) == 0) {
> -        vshPrint(ctl, _("Domain %s suspended\n"), name);
> -    } else {
> -        vshError(ctl, _("Failed to suspend domain %s"), name);
> -        ret = false;
> +    if (virDomainSuspendFlags(dom, flags) < 0) {
> +        /* Fallback to older API iff no flag was requested */
> +        if (flags || last_error->code != VIR_ERR_NO_SUPPORT) {

Your logic:

try new API
if (fail) {
    if (flags requested or failure is unrelated to unknown function)
        goto done
    try fallback of old api
}

Elsewhere, we have coded things to be more efficient, with only one API
attempt that always favors the oldest API known to serve the user's request:

if (user requested flags)
    call new API
else
    call old API

But that only works if there is an addition of a flag to make it worth
calling the new API.  Which goes back to the question in patch 1 on what
we plan on adding to make use of a flag.

So your conversion looks okay to me for being easier to modify if we add
a flag in the future.

-- 
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: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140203/b513555c/attachment-0001.sig>


More information about the libvir-list mailing list