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

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

 



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

Attachment: signature.asc
Description: OpenPGP digital signature

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