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