From nobody Mon Feb 9 04:45:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1632409746; cv=none; d=zohomail.com; s=zohoarc; b=VwsGQoJzNsZArt93p5e4RDRpfSKoAOqcR99aXtWzpsxfT0PXrzMIUwnA3gvdeba/2Cnw1LRaL85CiMu/3CObMTQ/6IQ/eTU1Sso94mjqUaWTygnd+KX/TI5GRJy/KKoFfCm44k+nuU9Ll1BrZPjsFmgioMl8xTVk/KBZ1A2p2rI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632409746; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hh+m1gp3vvt5WEKRpxvj4/dgkGdLf6F6oyu0tEHLUoA=; b=PSzJU+Xrvcr8sR4wv74VQU7dDXkXHMYmJ+OFKwn3ETfIgTAY6+CCQD3Y7UaHkkQu5B9+WU3rXYsz9kZM2tkYD+P8xPIskIo7rCXc2spg9N8UpvhD7Z0s6dtDIzffhGthUAEma6xo8nt6qAH3A2XJg++N884AJY++6D5q6FFEr2g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1632409746579790.1129544839323; Thu, 23 Sep 2021 08:09:06 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-209-AX0uwJQhPLSv6p23uz8GOA-1; Thu, 23 Sep 2021 11:08:45 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9934E835DED; Thu, 23 Sep 2021 15:08:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B8CF5D6CF; Thu, 23 Sep 2021 15:08:39 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1EA5B180BAD2; Thu, 23 Sep 2021 15:08:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18NF8M6C030569 for ; Thu, 23 Sep 2021 11:08:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 40E0C171FF; Thu, 23 Sep 2021 15:08:22 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.43.2.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B9DB5FC25 for ; Thu, 23 Sep 2021 15:08:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632409745; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=hh+m1gp3vvt5WEKRpxvj4/dgkGdLf6F6oyu0tEHLUoA=; b=CqWN6HOWI8VFheUsZCLrKhHr/FpMy3kCWTutZl9vF1OvMghkYis0FqISW1yO8Ev42lIVto jWsZ+6DLbnI7LGYHKZfvndbkC/DAUKuZ1CHqfwoOn/9KSDZC7CRjygZh1pjcuyT3VC9rrH 93uwARjacDqqtJK1KnHL3f0UoAmBXsE= X-MC-Unique: AX0uwJQhPLSv6p23uz8GOA-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 2/5] virsh: domain: refactoring of small functions Date: Thu, 23 Sep 2021 17:08:01 +0200 Message-Id: <490cfcfa238430be8521fbe4ca37a2cb62c54b77.1632409613.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1632409747528100001 Content-Type: text/plain; charset="utf-8" This patch includes: * fix of a mistake in cmdMigrateSetMaxDowntime() - function returned false when it should have returned true * use of an early return in case of an error * removal of unnecessary variables and extra labels * returning value directly Signed-off-by: Kristina Hanicova --- tools/virsh-domain.c | 250 +++++++++++++++++-------------------------- 1 file changed, 98 insertions(+), 152 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index f876f30cc5..3232463485 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -245,18 +245,18 @@ static virDomainPtr virshDomainDefine(virConnectPtr conn, const char *xml, unsigned int flags) { virDomainPtr dom; - if (flags) { - dom =3D virDomainDefineXMLFlags(conn, xml, flags); - /* If validate is the only flag, just drop it and - * try again. - */ - if (!dom) { - if ((virGetLastErrorCode() =3D=3D VIR_ERR_NO_SUPPORT) && - (flags =3D=3D VIR_DOMAIN_DEFINE_VALIDATE)) - dom =3D virDomainDefineXML(conn, xml); - } - } else { - dom =3D virDomainDefineXML(conn, xml); + + if (!flags) + return virDomainDefineXML(conn, xml); + + dom =3D virDomainDefineXMLFlags(conn, xml, flags); + /* If validate is the only flag, just drop it and + * try again. + */ + if (!dom) { + if ((virGetLastErrorCode() =3D=3D VIR_ERR_NO_SUPPORT) && + (flags =3D=3D VIR_DOMAIN_DEFINE_VALIDATE)) + dom =3D virDomainDefineXML(conn, xml); } return dom; } @@ -659,12 +659,10 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) return false; } =20 - if (mode) { - if (STRNEQ(mode, "readonly") && STRNEQ(mode, "shareable")) { - vshError(ctl, _("No support for %s in command 'attach-disk'"), - mode); - return false; - } + if (mode && STRNEQ(mode, "readonly") && STRNEQ(mode, "shareable")) { + vshError(ctl, _("No support for %s in command 'attach-disk'"), + mode); + return false; } =20 if (wwn && !virValidateWWN(wwn)) @@ -2705,7 +2703,6 @@ virshBlockJobAbort(virDomainPtr dom, static bool cmdBlockjob(vshControl *ctl, const vshCmd *cmd) { - bool ret =3D false; bool raw =3D vshCommandOptBool(cmd, "raw"); bool bytes =3D vshCommandOptBool(cmd, "bytes"); bool abortMode =3D vshCommandOptBool(cmd, "abort"); @@ -2738,13 +2735,10 @@ cmdBlockjob(vshControl *ctl, const vshCmd *cmd) return false; =20 if (bandwidth) - ret =3D virshBlockJobSetSpeed(ctl, cmd, dom, path, bytes); - else if (abortMode || pivot || async) - ret =3D virshBlockJobAbort(dom, path, pivot, async); - else - ret =3D virshBlockJobInfo(ctl, dom, path, raw, bytes); - - return ret; + return virshBlockJobSetSpeed(ctl, cmd, dom, path, bytes); + if (abortMode || pivot || async) + return virshBlockJobAbort(dom, path, pivot, async); + return virshBlockJobInfo(ctl, dom, path, raw, bytes); } =20 /* @@ -2930,7 +2924,6 @@ cmdBlockresize(vshControl *ctl, const vshCmd *cmd) const char *path =3D NULL; unsigned long long size =3D 0; unsigned int flags =3D 0; - bool ret =3D false; =20 if (vshCommandOptStringReq(ctl, cmd, "path", (const char **) &path) < = 0) return false; @@ -2949,12 +2942,11 @@ cmdBlockresize(vshControl *ctl, const vshCmd *cmd) =20 if (virDomainBlockResize(dom, path, size, flags) < 0) { vshError(ctl, _("Failed to resize block device '%s'"), path); - } else { - vshPrintExtra(ctl, _("Block device '%s' is resized"), path); - ret =3D true; + return false; } =20 - return ret; + vshPrintExtra(ctl, _("Block device '%s' is resized"), path); + return true; } =20 #ifndef WIN32 @@ -3428,19 +3420,17 @@ cmdSuspend(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; const char *name; - bool ret =3D true; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 - if (virDomainSuspend(dom) =3D=3D 0) { - vshPrintExtra(ctl, _("Domain '%s' suspended\n"), name); - } else { + if (virDomainSuspend(dom) !=3D 0) { vshError(ctl, _("Failed to suspend domain '%s'"), name); - ret =3D false; + return false; } =20 - return ret; + vshPrintExtra(ctl, _("Domain '%s' suspended\n"), name); + return true; } =20 /* @@ -5066,7 +5056,6 @@ cmdSchedInfoUpdateOne(vshControl *ctl, const char *field, const char *value) { virTypedParameterPtr param; - int ret =3D -1; size_t i; =20 for (i =3D 0; i < nsrc_params; i++) { @@ -5081,14 +5070,11 @@ cmdSchedInfoUpdateOne(vshControl *ctl, vshSaveLibvirtError(); return -1; } - ret =3D 0; - break; + return 0; } =20 - if (ret < 0) - vshError(ctl, _("invalid scheduler option: %s"), field); - - return ret; + vshError(ctl, _("invalid scheduler option: %s"), field); + return -1; } =20 static int @@ -5539,7 +5525,6 @@ virshGenFileName(vshControl *ctl, virDomainPtr dom, c= onst char *mime) g_autoptr(GDateTime) now =3D g_date_time_new_now_local(); g_autofree char *nowstr =3D NULL; const char *ext =3D NULL; - char *ret =3D NULL; =20 if (!dom) { vshError(ctl, "%s", _("Invalid domain supplied")); @@ -5554,10 +5539,8 @@ virshGenFileName(vshControl *ctl, virDomainPtr dom, = const char *mime) =20 nowstr =3D g_date_time_format(now, "%Y-%m-%d-%H:%M:%S"); =20 - ret =3D g_strdup_printf("%s-%s%s", virDomainGetName(dom), - nowstr, NULLSTR_EMPTY(ext)); - - return ret; + return g_strdup_printf("%s-%s%s", virDomainGetName(dom), + nowstr, NULLSTR_EMPTY(ext)); } =20 static bool @@ -5696,7 +5679,6 @@ static bool cmdSetLifecycleAction(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - bool ret =3D true; bool config =3D vshCommandOptBool(cmd, "config"); bool live =3D vshCommandOptBool(cmd, "live"); bool current =3D vshCommandOptBool(cmd, "current"); @@ -5737,10 +5719,9 @@ cmdSetLifecycleAction(vshControl *ctl, const vshCmd = *cmd) =20 if (virDomainSetLifecycleAction(dom, type, action, flags) < 0) { vshError(ctl, "%s", _("Unable to change lifecycle action.")); - ret =3D false; + return false; } - - return ret; + return true; } =20 /* @@ -5825,20 +5806,18 @@ static bool cmdResume(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - bool ret =3D true; const char *name; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 - if (virDomainResume(dom) =3D=3D 0) { - vshPrintExtra(ctl, _("Domain '%s' resumed\n"), name); - } else { + if (virDomainResume(dom) !=3D 0) { vshError(ctl, _("Failed to resume domain '%s'"), name); - ret =3D false; + return false; } =20 - return ret; + vshPrintExtra(ctl, _("Domain '%s' resumed\n"), name); + return true; } =20 /* @@ -5912,13 +5891,13 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd) rv =3D virDomainShutdownFlags(dom, flags); else rv =3D virDomainShutdown(dom); - if (rv =3D=3D 0) { - vshPrintExtra(ctl, _("Domain '%s' is being shutdown\n"), name); - } else { + + if (rv !=3D 0) { vshError(ctl, _("Failed to shutdown domain '%s'"), name); return false; } =20 + vshPrintExtra(ctl, _("Domain '%s' is being shutdown\n"), name); return true; } =20 @@ -5988,13 +5967,12 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd) if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 - if (virDomainReboot(dom, flags) =3D=3D 0) { - vshPrintExtra(ctl, _("Domain '%s' is being rebooted\n"), name); - } else { + if (virDomainReboot(dom, flags) !=3D 0) { vshError(ctl, _("Failed to reboot domain '%s'"), name); return false; } =20 + vshPrintExtra(ctl, _("Domain '%s' is being rebooted\n"), name); return true; } =20 @@ -6020,20 +5998,18 @@ static bool cmdReset(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - bool ret =3D true; const char *name; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 - if (virDomainReset(dom, 0) =3D=3D 0) { - vshPrintExtra(ctl, _("Domain '%s' was reset\n"), name); - } else { + if (virDomainReset(dom, 0) !=3D 0) { vshError(ctl, _("Failed to reset domain '%s'"), name); - ret =3D false; + return false; } =20 - return ret; + vshPrintExtra(ctl, _("Domain '%s' was reset\n"), name); + return true; } =20 /* @@ -6479,15 +6455,14 @@ static bool cmdDomjobabort(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - bool ret =3D true; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (virDomainAbortJob(dom) < 0) - ret =3D false; + return false; =20 - return ret; + return true; } =20 /* @@ -7042,8 +7017,7 @@ virshParseCPUList(vshControl *ctl, int *cpumaplen, } } =20 - if (virBitmapToData(map, &cpumap, cpumaplen) < 0) - goto cleanup; + virBitmapToData(map, &cpumap, cpumaplen); =20 cleanup: virBitmapFree(map); @@ -8212,7 +8186,6 @@ cmdDefine(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; const char *from =3D NULL; - bool ret =3D true; char *buffer; unsigned int flags =3D 0; virshControl *priv =3D ctl->privData; @@ -8232,14 +8205,14 @@ cmdDefine(vshControl *ctl, const vshCmd *cmd) dom =3D virDomainDefineXML(priv->conn, buffer); VIR_FREE(buffer); =20 - if (dom !=3D NULL) { - vshPrintExtra(ctl, _("Domain '%s' defined from %s\n"), - virDomainGetName(dom), from); - } else { + if (!dom) { vshError(ctl, _("Failed to define domain from %s"), from); - ret =3D false; + return false; } - return ret; + + vshPrintExtra(ctl, _("Domain '%s' defined from %s\n"), + virDomainGetName(dom), from); + return true; } =20 /* @@ -8268,7 +8241,6 @@ static bool cmdDestroy(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - bool ret =3D true; const char *name; unsigned int flags =3D 0; int result; @@ -8284,14 +8256,13 @@ cmdDestroy(vshControl *ctl, const vshCmd *cmd) else result =3D virDomainDestroy(dom); =20 - if (result =3D=3D 0) { - vshPrintExtra(ctl, _("Domain '%s' destroyed\n"), name); - } else { + if (result < 0) { vshError(ctl, _("Failed to destroy domain '%s'"), name); - ret =3D false; + return false; } =20 - return ret; + vshPrintExtra(ctl, _("Domain '%s' destroyed\n"), name); + return true; } =20 /* @@ -9990,7 +9961,6 @@ static bool cmdDumpXML(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - bool ret =3D true; g_autofree char *dump =3D NULL; unsigned int flags =3D 0; bool inactive =3D vshCommandOptBool(cmd, "inactive"); @@ -10010,14 +9980,11 @@ cmdDumpXML(vshControl *ctl, const vshCmd *cmd) if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 - dump =3D virDomainGetXMLDesc(dom, flags); - if (dump !=3D NULL) { - vshPrint(ctl, "%s", dump); - } else { - ret =3D false; - } + if (!(dump =3D virDomainGetXMLDesc(dom, flags))) + return false; =20 - return ret; + vshPrint(ctl, "%s", dump); + return true; } =20 /* @@ -10051,7 +10018,6 @@ static const vshCmdOptDef opts_domxmlfromnative[] = =3D { static bool cmdDomXMLFromNative(vshControl *ctl, const vshCmd *cmd) { - bool ret =3D true; const char *format =3D NULL; const char *configFile =3D NULL; g_autofree char *configData =3D NULL; @@ -10067,13 +10033,11 @@ cmdDomXMLFromNative(vshControl *ctl, const vshCmd= *cmd) return false; =20 xmlData =3D virConnectDomainXMLFromNative(priv->conn, format, configDa= ta, flags); - if (xmlData !=3D NULL) { - vshPrint(ctl, "%s", xmlData); - } else { - ret =3D false; - } + if (!xmlData) + return false; =20 - return ret; + vshPrint(ctl, "%s", xmlData); + return true; } =20 /* @@ -11006,25 +10970,19 @@ cmdMigrateSetMaxDowntime(vshControl *ctl, const v= shCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; unsigned long long downtime =3D 0; - bool ret =3D false; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptULongLong(ctl, cmd, "downtime", &downtime) < 0) - goto done; + return false; + if (downtime < 1) { vshError(ctl, "%s", _("migrate: Invalid downtime")); - goto done; + return false; } =20 - if (virDomainMigrateSetMaxDowntime(dom, downtime, 0)) - goto done; - - ret =3D true; - - done: - return ret; + return virDomainMigrateSetMaxDowntime(dom, downtime, 0) =3D=3D 0; } =20 =20 @@ -11100,12 +11058,12 @@ cmdMigrateCompCache(vshControl *ctl, const vshCmd= *cmd) return false; =20 rc =3D vshCommandOptULongLong(ctl, cmd, "size", &size); - if (rc < 0) { + if (rc < 0) + return false; + + if (rc !=3D 0 && + (virDomainMigrateSetCompressionCache(dom, size, 0) < 0)) return false; - } else if (rc !=3D 0) { - if (virDomainMigrateSetCompressionCache(dom, size, 0) < 0) - return false; - } =20 if (virDomainMigrateGetCompressionCache(dom, &size, 0) < 0) return false; @@ -11486,11 +11444,9 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) =20 /* We got what we came for so return successfully */ ret =3D true; - if (!all) { + if (!all) break; - } else { - vshPrint(ctl, "\n"); - } + vshPrint(ctl, "\n"); } =20 if (!ret) { @@ -11947,12 +11903,12 @@ virshDomainDetachInterface(char *doc, xmlNodePtr cur =3D NULL, matchNode =3D NULL; g_autofree char *detach_xml =3D NULL; char buf[64]; - int diff_mac, ret =3D -1; + int diff_mac =3D -1; size_t i; =20 if (!(xml =3D virXMLParseStringCtxt(doc, _("(domain_definition)"), &ct= xt))) { vshError(ctl, "%s", _("Failed to get interface information")); - goto cleanup; + return false; } =20 g_snprintf(buf, sizeof(buf), "/domain/devices/interface[@type=3D'%s']"= , type); @@ -11960,13 +11916,13 @@ virshDomainDetachInterface(char *doc, if (obj =3D=3D NULL || obj->type !=3D XPATH_NODESET || obj->nodesetval =3D=3D NULL || obj->nodesetval->nodeNr =3D=3D 0) { vshError(ctl, _("No interface found whose type is %s"), type); - goto cleanup; + return false; } =20 if (!mac && obj->nodesetval->nodeNr > 1) { vshError(ctl, _("Domain has %d interfaces. Please specify which on= e " "to detach using --mac"), obj->nodesetval->nodeNr); - goto cleanup; + return false; } =20 if (!mac) { @@ -11989,7 +11945,7 @@ virshDomainDetachInterface(char *doc, "MAC address %s. You must use deta= ch-device and " "specify the device pci address to= remove it."), mac); - goto cleanup; + return false; } matchNode =3D obj->nodesetval->nodeTab[i]; } @@ -11999,22 +11955,18 @@ virshDomainDetachInterface(char *doc, } if (!matchNode) { vshError(ctl, _("No interface with MAC address %s was found"), mac= ); - goto cleanup; + return false; } =20 hit: if (!(detach_xml =3D virXMLNodeToString(xml, matchNode))) { vshSaveLibvirtError(); - goto cleanup; + return false; } =20 if (flags !=3D 0 || current) - ret =3D virDomainDetachDeviceFlags(dom, detach_xml, flags); - else - ret =3D virDomainDetachDevice(dom, detach_xml); - - cleanup: - return ret =3D=3D 0; + return virDomainDetachDeviceFlags(dom, detach_xml, flags) =3D=3D 0; + return virDomainDetachDevice(dom, detach_xml) =3D=3D 0; } =20 =20 @@ -13666,10 +13618,10 @@ static bool cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - int ret =3D -1; const vshCmdOpt *opt =3D NULL; g_autofree const char **mountpoints =3D NULL; size_t nmountpoints =3D 0; + int count =3D 0; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -13679,16 +13631,13 @@ cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd) mountpoints[nmountpoints-1] =3D opt->data; } =20 - ret =3D virDomainFSFreeze(dom, mountpoints, nmountpoints, 0); - if (ret < 0) { + if ((count =3D virDomainFSFreeze(dom, mountpoints, nmountpoints, 0)) <= 0) { vshError(ctl, _("Unable to freeze filesystems")); - goto cleanup; + return false; } =20 - vshPrintExtra(ctl, _("Froze %d filesystem(s)\n"), ret); - - cleanup: - return ret >=3D 0; + vshPrintExtra(ctl, _("Froze %d filesystem(s)\n"), count); + return true; } =20 static const vshCmdInfo info_domfsthaw[] =3D { @@ -13714,10 +13663,10 @@ static bool cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - int ret =3D -1; const vshCmdOpt *opt =3D NULL; g_autofree const char **mountpoints =3D NULL; size_t nmountpoints =3D 0; + int count =3D 0; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -13727,16 +13676,13 @@ cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd) mountpoints[nmountpoints-1] =3D opt->data; } =20 - ret =3D virDomainFSThaw(dom, mountpoints, nmountpoints, 0); - if (ret < 0) { + if ((count =3D virDomainFSThaw(dom, mountpoints, nmountpoints, 0)) < 0= ) { vshError(ctl, _("Unable to thaw filesystems")); - goto cleanup; + return false; } =20 - vshPrintExtra(ctl, _("Thawed %d filesystem(s)\n"), ret); - - cleanup: - return ret >=3D 0; + vshPrintExtra(ctl, _("Thawed %d filesystem(s)\n"), count); + return true; } =20 static const vshCmdInfo info_domfsinfo[] =3D { --=20 2.31.1