[libvirt PATCH 3/4] tools: use VIR_UNLESS more

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

 



Demonstrate the elegance of the macro.

Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 tools/virsh-backup.c               |   8 +-
 tools/virsh-checkpoint.c           |  28 +-
 tools/virsh-completer-checkpoint.c |   2 +-
 tools/virsh-completer-domain.c     |  30 +-
 tools/virsh-completer-host.c       |  12 +-
 tools/virsh-completer-network.c    |   4 +-
 tools/virsh-completer-snapshot.c   |   2 +-
 tools/virsh-completer-volume.c     |   4 +-
 tools/virsh-console.c              |  20 +-
 tools/virsh-domain-event.c         |   6 +-
 tools/virsh-domain-monitor.c       |  68 ++---
 tools/virsh-domain.c               | 432 ++++++++++++++---------------
 tools/virsh-edit.c                 |  10 +-
 tools/virsh-host.c                 |  42 +--
 tools/virsh-interface.c            |  88 +++---
 tools/virsh-network.c              |  70 ++---
 tools/virsh-nodedev.c              |  48 ++--
 tools/virsh-nwfilter.c             |  32 +--
 tools/virsh-pool.c                 |  62 ++---
 tools/virsh-secret.c               |  30 +-
 tools/virsh-snapshot.c             | 102 +++----
 tools/virsh-util.c                 |  32 +--
 tools/virsh-volume.c               |  70 ++---
 tools/virsh.c                      |  16 +-
 tools/virt-admin.c                 |  44 +--
 tools/virt-host-validate-ch.c      |   2 +-
 tools/virt-host-validate-common.c  |  22 +-
 tools/virt-host-validate-qemu.c    |   4 +-
 tools/virt-login-shell-helper.c    |  16 +-
 tools/virt-pki-query-dn.c          |   2 +-
 tools/vsh-table.c                  |  14 +-
 tools/vsh.c                        | 102 +++----
 32 files changed, 712 insertions(+), 712 deletions(-)

diff --git a/tools/virsh-backup.c b/tools/virsh-backup.c
index 7bac1923a6..7e13eb841c 100644
--- a/tools/virsh-backup.c
+++ b/tools/virsh-backup.c
@@ -68,13 +68,13 @@ cmdBackupBegin(vshControl *ctl,
     if (vshCommandOptBool(cmd, "reuse-external"))
         flags |= VIR_DOMAIN_BACKUP_BEGIN_REUSE_EXTERNAL;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "backupxml", &backup_from) < 0)
         return false;
 
-    if (!backup_from) {
+    VIR_UNLESS (backup_from) {
         backup_buffer = g_strdup("<domainbackup/>");
     } else {
         if (virFileReadAll(backup_from, VSH_MAX_XML_FILE, &backup_buffer) < 0) {
@@ -125,10 +125,10 @@ cmdBackupDumpXML(vshControl *ctl,
     g_autoptr(virshDomain) dom = NULL;
     g_autofree char *xml = NULL;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
-    if (!(xml = virDomainBackupGetXMLDesc(dom, 0)))
+    VIR_UNLESS ((xml = virDomainBackupGetXMLDesc(dom, 0)))
         return false;
 
     vshPrint(ctl, "%s", xml);
diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c
index 8ad37ece69..fd8cd8827f 100644
--- a/tools/virsh-checkpoint.c
+++ b/tools/virsh-checkpoint.c
@@ -55,7 +55,7 @@ virshCheckpointCreate(vshControl *ctl,
         return false;
 
     name = virDomainCheckpointGetName(checkpoint);
-    if (!name) {
+    VIR_UNLESS (name) {
         vshError(ctl, "%s", _("Could not get checkpoint name"));
         return false;
     }
@@ -124,12 +124,12 @@ cmdCheckpointCreate(vshControl *ctl,
     if (vshCommandOptBool(cmd, "quiesce"))
         flags |= VIR_DOMAIN_CHECKPOINT_CREATE_QUIESCE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "xmlfile", &from) < 0)
         return false;
-    if (!from) {
+    VIR_UNLESS (from) {
         buffer = g_strdup("<domaincheckpoint/>");
     } else {
         if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {
@@ -239,7 +239,7 @@ cmdCheckpointCreateAs(vshControl *ctl,
     if (vshCommandOptBool(cmd, "quiesce"))
         flags |= VIR_DOMAIN_CHECKPOINT_CREATE_QUIESCE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0 ||
@@ -298,7 +298,7 @@ virshLookupCheckpoint(vshControl *ctl,
         vshError(ctl, _("--%s is required"), arg);
         return -1;
     }
-    if (!*chk) {
+    VIR_UNLESS (*chk) {
         vshReportError(ctl);
         return -1;
     }
@@ -344,7 +344,7 @@ cmdCheckpointEdit(vshControl *ctl,
     unsigned int getxml_flags = VIR_DOMAIN_CHECKPOINT_XML_SECURE;
     unsigned int define_flags = VIR_DOMAIN_CHECKPOINT_CREATE_REDEFINE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (virshLookupCheckpoint(ctl, cmd, "checkpointname", dom,
@@ -513,7 +513,7 @@ virshCheckpointListFree(struct virshCheckpointList *checkpointlist)
 {
     size_t i;
 
-    if (!checkpointlist)
+    VIR_UNLESS (checkpointlist)
         return;
     if (checkpointlist->chks) {
         for (i = 0; i < checkpointlist->nchks; i++) {
@@ -535,7 +535,7 @@ virshChkSorter(const void *a,
 
     if (sa->chk && !sb->chk)
         return -1;
-    if (!sa->chk)
+    VIR_UNLESS (sa->chk)
         return sb->chk != NULL;
 
     return vshStrcasecmp(virDomainCheckpointGetName(sa->chk),
@@ -726,7 +726,7 @@ cmdCheckpointList(vshControl *ctl,
         flags |= VIR_DOMAIN_CHECKPOINT_LIST_ROOTS;
 
     if (vshCommandOptBool(cmd, "descendants")) {
-        if (!from) {
+        VIR_UNLESS (from) {
             vshError(ctl, "%s",
                      _("--descendants requires --from"));
             return false;
@@ -784,10 +784,10 @@ cmdCheckpointList(vshControl *ctl,
             continue;
         }
 
-        if (!(doc = virDomainCheckpointGetXMLDesc(checkpoint, 0)))
+        VIR_UNLESS ((doc = virDomainCheckpointGetXMLDesc(checkpoint, 0)))
             continue;
 
-        if (!(xml = virXMLParseStringCtxt(doc, _("(domain_checkpoint)"), &ctxt)))
+        VIR_UNLESS ((xml = virXMLParseStringCtxt(doc, _("(domain_checkpoint)"), &ctxt)))
             continue;
 
         if (parent)
@@ -874,14 +874,14 @@ cmdCheckpointDumpXML(vshControl *ctl,
     if (vshCommandOptBool(cmd, "size"))
         flags |= VIR_DOMAIN_CHECKPOINT_XML_SIZE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (virshLookupCheckpoint(ctl, cmd, "checkpointname", dom,
                               &checkpoint, &name) < 0)
         return false;
 
-    if (!(xml = virDomainCheckpointGetXMLDesc(checkpoint, flags)))
+    VIR_UNLESS ((xml = virDomainCheckpointGetXMLDesc(checkpoint, flags)))
         return false;
 
     vshPrint(ctl, "%s", xml);
@@ -931,7 +931,7 @@ cmdCheckpointParent(vshControl *ctl,
 
     if (virshGetCheckpointParent(ctl, checkpoint, &parent) < 0)
         return false;
-    if (!parent) {
+    VIR_UNLESS (parent) {
         vshError(ctl, _("checkpoint '%s' has no parent"), name);
         return false;
     }
diff --git a/tools/virsh-completer-checkpoint.c b/tools/virsh-completer-checkpoint.c
index b6d6c93e85..48d01e6aa6 100644
--- a/tools/virsh-completer-checkpoint.c
+++ b/tools/virsh-completer-checkpoint.c
@@ -43,7 +43,7 @@ virshCheckpointNameCompleter(vshControl *ctl,
     if (!priv->conn || virConnectIsAlive(priv->conn) <= 0)
         return NULL;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return NULL;
 
     if ((ncheckpoints = virDomainListAllCheckpoints(dom, &checkpoints,
diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c
index d4c877cd04..620a3a8ddb 100644
--- a/tools/virsh-completer-domain.c
+++ b/tools/virsh-completer-domain.c
@@ -177,7 +177,7 @@ virshDomainInterfaceCompleter(vshControl *ctl,
 
         /* In case we are dealing with inactive domain XML there's no
          * <target dev=''/>. Offer MAC addresses then. */
-        if (!(tmp[i] = virXPathString("string(./mac/@address)", ctxt)))
+        VIR_UNLESS ((tmp[i] = virXPathString("string(./mac/@address)", ctxt)))
             return NULL;
     }
 
@@ -214,7 +214,7 @@ virshDomainDiskTargetCompleter(vshControl *ctl,
 
     for (i = 0; i < ndisks; i++) {
         ctxt->node = disks[i];
-        if (!(tmp[i] = virXPathString("string(./target/@dev)", ctxt)))
+        VIR_UNLESS ((tmp[i] = virXPathString("string(./target/@dev)", ctxt)))
             return NULL;
     }
 
@@ -233,7 +233,7 @@ virshDomainDiskTargetListCompleter(vshControl *ctl,
     if (vshCommandOptStringQuiet(ctl, cmd, argname, &curval) < 0)
         return NULL;
 
-    if (!targets)
+    VIR_UNLESS (targets)
         return NULL;
 
     return virshCommaStringListComplete(curval, (const char **) targets);
@@ -276,7 +276,7 @@ virshDomainBlockjobBaseTopCompleteDisk(const char *target,
     for (i = 0; i < nindexlist; i++) {
         g_autofree char *idx = virXMLPropString(indexlist[i], "index");
 
-        if (!idx)
+        VIR_UNLESS (idx)
             continue;
 
         ret = g_slist_prepend(ret, g_strdup_printf("%s[%s]", target, idx));
@@ -335,7 +335,7 @@ virshDomainBlockjobBaseTopCompleter(vshControl *ctl,
 
         ctxt->node = disks[i];
 
-        if (!(disktarget = virXPathString("string(./target/@dev)", ctxt)))
+        VIR_UNLESS ((disktarget = virXPathString("string(./target/@dev)", ctxt)))
             return NULL;
 
         if (path && STRNEQ(path, disktarget))
@@ -446,7 +446,7 @@ virshDomainDeviceAliasCompleter(vshControl *ctl,
     tmp = g_new0(char *, naliases + 1);
 
     for (i = 0; i < naliases; i++) {
-        if (!(tmp[i] = virXMLPropString(aliases[i], "name")))
+        VIR_UNLESS ((tmp[i] = virXMLPropString(aliases[i], "name")))
             return NULL;
     }
 
@@ -561,7 +561,7 @@ virshDomainIOThreadIdCompleter(vshControl *ctl,
 
     virCheckFlags(0, NULL);
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return NULL;
 
     if ((rc = virDomainGetIOThreadInfo(dom, &info, flags)) < 0)
@@ -592,7 +592,7 @@ virshDomainVcpuCompleter(vshControl *ctl,
 
     virCheckFlags(0, NULL);
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return NULL;
 
     if (virshDomainGetXMLFromDom(ctl, dom, VIR_DOMAIN_XML_INACTIVE,
@@ -627,7 +627,7 @@ virshDomainVcpulistCompleter(vshControl *ctl,
 
     virCheckFlags(0, NULL);
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return NULL;
 
     if (vshCommandOptStringQuiet(ctl, cmd, "vcpulist", &vcpuid) < 0)
@@ -698,7 +698,7 @@ virshDomainVcpulistViaAgentCompleter(vshControl *ctl,
 
     virCheckFlags(0, NULL);
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return NULL;
 
     if (vshCommandOptStringQuiet(ctl, cmd, "cpulist", &vcpuid) < 0)
@@ -729,7 +729,7 @@ virshDomainVcpulistViaAgentCompleter(vshControl *ctl,
             goto cleanup;
 
         onlineVcpuStr = vshGetTypedParamValue(ctl, &params[1]);
-        if (!(onlineVcpus = virBitmapParseUnlimited(onlineVcpuStr)))
+        VIR_UNLESS ((onlineVcpus = virBitmapParseUnlimited(onlineVcpuStr)))
             goto cleanup;
 
         if (virBitmapToData(onlineVcpus, &onlineVcpumap, &dummy) < 0)
@@ -738,7 +738,7 @@ virshDomainVcpulistViaAgentCompleter(vshControl *ctl,
         if (enable) {
             offlinableVcpuStr = vshGetTypedParamValue(ctl, &params[2]);
 
-            if (!(offlinableVcpus = virBitmapParseUnlimited(offlinableVcpuStr)))
+            VIR_UNLESS ((offlinableVcpus = virBitmapParseUnlimited(offlinableVcpuStr)))
                 goto cleanup;
 
             if (virBitmapToData(offlinableVcpus, &offlinableVcpumap, &dummy) < 0)
@@ -937,13 +937,13 @@ virshKeycodeNameCompleter(vshControl *ctl,
         break;
     }
 
-    if (!names)
+    VIR_UNLESS (names)
         return NULL;
 
     tmp = g_new0(char *, len + 1);
 
     for (i = 0; i < len; i++) {
-        if (!names[i])
+        VIR_UNLESS (names[i])
             continue;
 
         tmp[j] = g_strdup(names[i]);
@@ -971,7 +971,7 @@ virshDomainFSMountpointsCompleter(vshControl *ctl,
 
     virCheckFlags(0, NULL);
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return NULL;
 
     rc = virDomainGetFSInfo(dom, &info, 0);
diff --git a/tools/virsh-completer-host.c b/tools/virsh-completer-host.c
index cbdc3f0d49..3b4da7fb78 100644
--- a/tools/virsh-completer-host.c
+++ b/tools/virsh-completer-host.c
@@ -71,10 +71,10 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl,
     if (!priv->conn || virConnectIsAlive(priv->conn) <= 0)
         return NULL;
 
-    if (!(cap_xml = virConnectGetCapabilities(priv->conn)))
+    VIR_UNLESS ((cap_xml = virConnectGetCapabilities(priv->conn)))
         return NULL;
 
-    if (!(doc = virXMLParseStringCtxt(cap_xml, _("capabilities"), &ctxt)))
+    VIR_UNLESS ((doc = virXMLParseStringCtxt(cap_xml, _("capabilities"), &ctxt)))
         return NULL;
 
     if (cellno && vshCommandOptStringQuiet(ctl, cmd, "cellno", &cellnum) > 0) {
@@ -91,7 +91,7 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl,
     tmp = g_new0(char *, npages + 1);
 
     for (i = 0; i < npages; i++) {
-        if (!(tmp[i] = virshPagesizeNodeToString(pages[i])))
+        VIR_UNLESS ((tmp[i] = virshPagesizeNodeToString(pages[i])))
             return NULL;
     }
 
@@ -118,10 +118,10 @@ virshCellnoCompleter(vshControl *ctl,
     if (!priv->conn || virConnectIsAlive(priv->conn) <= 0)
         return NULL;
 
-    if (!(cap_xml = virConnectGetCapabilities(priv->conn)))
+    VIR_UNLESS ((cap_xml = virConnectGetCapabilities(priv->conn)))
         return NULL;
 
-    if (!(doc = virXMLParseStringCtxt(cap_xml, _("capabilities"), &ctxt)))
+    VIR_UNLESS ((doc = virXMLParseStringCtxt(cap_xml, _("capabilities"), &ctxt)))
         return NULL;
 
     ncells = virXPathNodeSet("/capabilities/host/topology/cells/cell", ctxt, &cells);
@@ -131,7 +131,7 @@ virshCellnoCompleter(vshControl *ctl,
     tmp = g_new0(char *, ncells + 1);
 
     for (i = 0; i < ncells; i++) {
-        if (!(tmp[i] = virXMLPropString(cells[i], "id")))
+        VIR_UNLESS ((tmp[i] = virXMLPropString(cells[i], "id")))
             return NULL;
     }
 
diff --git a/tools/virsh-completer-network.c b/tools/virsh-completer-network.c
index 839d71e961..6629e4422f 100644
--- a/tools/virsh-completer-network.c
+++ b/tools/virsh-completer-network.c
@@ -103,7 +103,7 @@ virshNetworkPortUUIDCompleter(vshControl *ctl,
     if (!priv->conn || virConnectIsAlive(priv->conn) <= 0)
         return NULL;
 
-    if (!(net = virshCommandOptNetwork(ctl, cmd, NULL)))
+    VIR_UNLESS ((net = virshCommandOptNetwork(ctl, cmd, NULL)))
         return NULL;
 
     if ((nports = virNetworkListAllPorts(net, &ports, flags)) < 0)
@@ -195,7 +195,7 @@ virshNetworkDhcpMacCompleter(vshControl *ctl,
     if (!priv->conn || virConnectIsAlive(priv->conn) <= 0)
         return NULL;
 
-    if (!(network = virshCommandOptNetwork(ctl, cmd, NULL)))
+    VIR_UNLESS ((network = virshCommandOptNetwork(ctl, cmd, NULL)))
         return NULL;
 
     if ((nleases = virNetworkGetDHCPLeases(network, NULL, &leases, flags)) < 0)
diff --git a/tools/virsh-completer-snapshot.c b/tools/virsh-completer-snapshot.c
index 535841cf2e..de6aad4530 100644
--- a/tools/virsh-completer-snapshot.c
+++ b/tools/virsh-completer-snapshot.c
@@ -45,7 +45,7 @@ virshSnapshotNameCompleter(vshControl *ctl,
     if (!priv->conn || virConnectIsAlive(priv->conn) <= 0)
         return NULL;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return NULL;
 
     if ((rc = virDomainListAllSnapshots(dom, &snapshots, flags)) < 0)
diff --git a/tools/virsh-completer-volume.c b/tools/virsh-completer-volume.c
index a1ebadccac..276765c8e2 100644
--- a/tools/virsh-completer-volume.c
+++ b/tools/virsh-completer-volume.c
@@ -47,7 +47,7 @@ virshStorageVolNameCompleter(vshControl *ctl,
     if (!priv->conn || virConnectIsAlive(priv->conn) <= 0)
         return NULL;
 
-    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
+    VIR_UNLESS ((pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
         return NULL;
 
     if ((rc = virStoragePoolListAllVolumes(pool, &vols, flags)) < 0)
@@ -91,7 +91,7 @@ virshStorageVolKeyCompleter(vshControl *ctl,
         return NULL;
 
     list = virshStoragePoolListCollect(ctl, VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE);
-    if (!list)
+    VIR_UNLESS (list)
         goto cleanup;
 
     for (i = 0; i < list->npools; i++) {
diff --git a/tools/virsh-console.c b/tools/virsh-console.c
index b8780c714d..66c447c762 100644
--- a/tools/virsh-console.c
+++ b/tools/virsh-console.c
@@ -82,7 +82,7 @@ static void virConsoleDispose(void *obj);
 static int
 virConsoleOnceInit(void)
 {
-    if (!VIR_CLASS_NEW(virConsole, virClassForObjectLockable()))
+    VIR_UNLESS (VIR_CLASS_NEW(virConsole, virClassForObjectLockable()))
         return -1;
 
     return 0;
@@ -129,7 +129,7 @@ virConsoleShutdown(virConsole *con,
         virEventRemoveHandle(con->stdoutWatch);
     con->stdinWatch = -1;
     con->stdoutWatch = -1;
-    if (!con->quit) {
+    VIR_UNLESS (con->quit) {
         con->quit = true;
         virCondSignal(&con->cond);
     }
@@ -157,7 +157,7 @@ virConsoleEventOnStream(virStreamPtr st,
     virObjectLock(con);
 
     /* we got late event after console was shutdown */
-    if (!con->st)
+    VIR_UNLESS (con->st)
         goto cleanup;
 
     if (events & VIR_STREAM_EVENT_READABLE) {
@@ -213,7 +213,7 @@ virConsoleEventOnStream(virStreamPtr st,
             con->terminalToStream.length = con->terminalToStream.offset + 1024;
         }
     }
-    if (!con->terminalToStream.offset)
+    VIR_UNLESS (con->terminalToStream.offset)
         virStreamEventUpdateCallback(con->st,
                                      VIR_STREAM_EVENT_READABLE);
 
@@ -238,7 +238,7 @@ virConsoleEventOnStdin(int watch G_GNUC_UNUSED,
     virObjectLock(con);
 
     /* we got late event after console was shutdown */
-    if (!con->st)
+    VIR_UNLESS (con->st)
         goto cleanup;
 
     if (events & VIR_EVENT_HANDLE_READABLE) {
@@ -309,7 +309,7 @@ virConsoleEventOnStdout(int watch G_GNUC_UNUSED,
     virObjectLock(con);
 
     /* we got late event after console was shutdown */
-    if (!con->st)
+    VIR_UNLESS (con->st)
         goto cleanup;
 
     if (events & VIR_EVENT_HANDLE_WRITABLE &&
@@ -339,7 +339,7 @@ virConsoleEventOnStdout(int watch G_GNUC_UNUSED,
         }
     }
 
-    if (!con->streamToTerminal.offset)
+    VIR_UNLESS (con->streamToTerminal.offset)
         virEventUpdateHandle(con->stdoutWatch, 0);
 
     if (events & VIR_EVENT_HANDLE_ERROR) {
@@ -367,7 +367,7 @@ virConsoleNew(void)
     if (virConsoleInitialize() < 0)
         return NULL;
 
-    if (!(con = virObjectLockableNew(virConsoleClass)))
+    VIR_UNLESS ((con = virObjectLockableNew(virConsoleClass)))
         return NULL;
 
     if (virCondInit(&con->cond) < 0) {
@@ -424,7 +424,7 @@ virshRunConsole(vshControl *ctl,
     if (vshTTYMakeRaw(ctl, true) < 0)
         goto resettty;
 
-    if (!(con = virConsoleNew()))
+    VIR_UNLESS ((con = virConsoleNew()))
         goto resettty;
 
     virObjectLock(con);
@@ -441,7 +441,7 @@ virshRunConsole(vshControl *ctl,
     con->escapeChar = virshGetEscapeChar(priv->escapeChar);
     con->st = virStreamNew(virDomainGetConnect(dom),
                            VIR_STREAM_NONBLOCK);
-    if (!con->st)
+    VIR_UNLESS (con->st)
         goto cleanup;
 
     if (virDomainOpenConsole(dom, dev_name, con->st, flags) < 0)
diff --git a/tools/virsh-domain-event.c b/tools/virsh-domain-event.c
index 1a2f1cb6e0..3403f48483 100644
--- a/tools/virsh-domain-event.c
+++ b/tools/virsh-domain-event.c
@@ -299,7 +299,7 @@ virshEventPrint(virshDomEventData *data,
 {
     g_autofree char *msg = NULL;
 
-    if (!(msg = virBufferContentAndReset(buf)))
+    VIR_UNLESS ((msg = virBufferContentAndReset(buf)))
         return;
 
     if (!data->loop && *data->count)
@@ -317,7 +317,7 @@ virshEventPrint(virshDomEventData *data,
     }
 
     (*data->count)++;
-    if (!data->loop)
+    VIR_UNLESS (data->loop)
         vshEventDone(data->ctl);
 }
 
@@ -944,7 +944,7 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
 
     if (vshCommandOptBool(cmd, "domain")) {
-        if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+        VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
             goto cleanup;
     }
 
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 246e8a16c0..e66383af05 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -88,7 +88,7 @@ virshGetDomainDescription(vshControl *ctl, virDomainPtr dom, bool title,
     else
         desc = virXPathString("string(./description[1])", ctxt);
 
-    if (!desc)
+    VIR_UNLESS (desc)
         desc = g_strdup("");
 
     return desc;
@@ -311,7 +311,7 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     /* If none of the options were specified and we're active
@@ -456,7 +456,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
 
     VSH_EXCLUSIVE_OPTIONS("all", "device");
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     all = vshCommandOptBool(cmd, "all");
@@ -480,7 +480,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
 
         /* title */
         table = vshTableNew(_("Target"), _("Capacity"), _("Allocation"), _("Physical"), NULL);
-        if (!table)
+        VIR_UNLESS (table)
             return false;
 
         for (i = 0; i < ndisks; i++) {
@@ -517,7 +517,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
                 memset(&info, 0, sizeof(info));
             }
 
-            if (!cmdDomblkinfoGet(&info, &cap, &alloc, &phy, human))
+            VIR_UNLESS (cmdDomblkinfoGet(&info, &cap, &alloc, &phy, human))
                 return false;
             if (vshTableRowAppend(table, target, cap, alloc, phy, NULL) < 0)
                 return false;
@@ -533,7 +533,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
         if (virDomainGetBlockInfo(dom, device, &info, 0) < 0)
             return false;
 
-        if (!cmdDomblkinfoGet(&info, &cap, &alloc, &phy, human))
+        VIR_UNLESS (cmdDomblkinfoGet(&info, &cap, &alloc, &phy, human))
             return false;
         vshPrint(ctl, "%-15s %s\n", _("Capacity:"), cap);
         vshPrint(ctl, "%-15s %s\n", _("Allocation:"), alloc);
@@ -598,7 +598,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
     else
         table = vshTableNew(_("Target"), _("Source"), NULL);
 
-    if (!table)
+    VIR_UNLESS (table)
         return false;
 
     for (i = 0; i < ndisks; i++) {
@@ -619,7 +619,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
         }
 
         target = virXPathString("string(./target/@dev)", ctxt);
-        if (!target) {
+        VIR_UNLESS (target) {
             vshError(ctl, "unable to query block list");
             return false;
         }
@@ -705,7 +705,7 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd)
 
     table = vshTableNew(_("Interface"), _("Type"),
                         _("Source"), _("Model"), _("MAC"), NULL);
-    if (!table)
+    VIR_UNLESS (table)
         return false;
 
     for (i = 0; i < ninterfaces; i++) {
@@ -854,7 +854,7 @@ cmdDomControl(vshControl *ctl, const vshCmd *cmd)
     g_autoptr(virshDomain) dom = NULL;
     virDomainControlInfo info;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (virDomainGetControlInfo(dom, &info, 0) < 0)
@@ -957,7 +957,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
     size_t i;
     bool human = vshCommandOptBool(cmd, "human"); /* human readable output */
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     /* device argument is optional now. if it's missing, supply empty
@@ -967,7 +967,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "device", &device) < 0)
         return false;
 
-    if (!device)
+    VIR_UNLESS (device)
         device = "";
 
     rc = virDomainBlockStatsFlags(dom, device, NULL, &nparams, 0);
@@ -1018,7 +1018,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
         for (i = 0; domblkstat_output[i].field != NULL; i++) {
             g_autofree char *value = NULL;
 
-            if (!(par = virTypedParamsGet(params, nparams,
+            VIR_UNLESS ((par = virTypedParamsGet(params, nparams,
                                           domblkstat_output[i].field)))
                 continue;
 
@@ -1035,7 +1035,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
                 field = domblkstat_output[i].legacy;
 
             /* use the provided spelling if no translation is available */
-            if (!field)
+            VIR_UNLESS (field)
                 field = domblkstat_output[i].field;
 
             vshPrint(ctl, "%s %-*s %s\n", device,
@@ -1046,7 +1046,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
         for (i = 0; i < nparams; i++) {
             g_autofree char *value = NULL;
 
-            if (!*params[i].field)
+            VIR_UNLESS (*params[i].field)
                 continue;
 
             value = vshGetTypedParamValue(ctl, params+i);
@@ -1089,7 +1089,7 @@ cmdDomIfstat(vshControl *ctl, const vshCmd *cmd)
     const char *name = NULL, *device = NULL;
     virDomainInterfaceStatsStruct stats;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "interface", &device) < 0)
@@ -1155,7 +1155,7 @@ cmdDomBlkError(vshControl *ctl, const vshCmd *cmd)
     int count;
     bool ret = false;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if ((count = virDomainGetDiskErrors(dom, NULL, 0, 0)) < 0)
@@ -1223,7 +1223,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
     virshControl *priv = ctl->privData;
     g_auto(GStrv) messages = NULL;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     id = virDomainGetID(dom);
@@ -1277,7 +1277,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
         vshPrint(ctl, "%-15s %s\n", _("Persistent:"), persistent ? _("yes") : _("no"));
 
     /* Check and display whether the domain autostarts or not */
-    if (!virDomainGetAutostart(dom, &autostart)) {
+    VIR_UNLESS (virDomainGetAutostart(dom, &autostart)) {
         vshPrint(ctl, "%-15s %s\n", _("Autostart:"),
                  autostart ? _("enable") : _("disable"));
     }
@@ -1359,7 +1359,7 @@ cmdDomstate(vshControl *ctl, const vshCmd *cmd)
     bool showReason = vshCommandOptBool(cmd, "reason");
     int state, reason;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if ((state = virshDomainState(ctl, dom, &reason)) < 0)
@@ -1428,7 +1428,7 @@ cmdDomTime(vshControl *ctl, const vshCmd *cmd)
     VSH_EXCLUSIVE_OPTIONS("time", "sync");
     VSH_EXCLUSIVE_OPTIONS("now", "sync");
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     rv = vshCommandOptLongLong(ctl, cmd, "time", &seconds);
@@ -1499,7 +1499,7 @@ virshDomainSorter(const void *a, const void *b)
     if (*da && !*db)
         return -1;
 
-    if (!*da)
+    VIR_UNLESS (*da)
         return *db != NULL;
 
     ida = virDomainGetID(*da);
@@ -1636,14 +1636,14 @@ virshDomainListCollect(vshControl *ctl, unsigned int flags)
 
     /* get active domains */
     for (i = 0; i < nids; i++) {
-        if (!(dom = virDomainLookupByID(priv->conn, ids[i])))
+        VIR_UNLESS ((dom = virDomainLookupByID(priv->conn, ids[i])))
             continue;
         list->domains[list->ndomains++] = dom;
     }
 
     /* get inactive domains */
     for (i = 0; i < nnames; i++) {
-        if (!(dom = virDomainLookupByName(priv->conn, names[i])))
+        VIR_UNLESS ((dom = virDomainLookupByName(priv->conn, names[i])))
             continue;
         list->domains[list->ndomains++] = dom;
     }
@@ -1760,7 +1760,7 @@ virshDomainListCollect(vshControl *ctl, unsigned int flags)
     for (i = 0; nnames != -1 && i < nnames; i++)
         VIR_FREE(names[i]);
 
-    if (!success) {
+    VIR_UNLESS (success) {
         g_clear_pointer(&list, virshDomainListFree);
     }
 
@@ -1920,7 +1920,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
     if (!optUUID && !optName && !optID)
         optTable = true;
 
-    if (!(list = virshDomainListCollect(ctl, flags)))
+    VIR_UNLESS ((list = virshDomainListCollect(ctl, flags)))
         goto cleanup;
 
     /* print table header in legacy mode */
@@ -1930,7 +1930,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
         else
             table = vshTableNew(_("Id"), _("Name"), _("State"), NULL);
 
-        if (!table)
+        VIR_UNLESS (table)
             goto cleanup;
     }
 
@@ -1958,7 +1958,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
             if (optTitle) {
                 g_autofree char *title = NULL;
 
-                if (!(title = virshGetDomainDescription(ctl, dom, true, 0)))
+                VIR_UNLESS ((title = virshGetDomainDescription(ctl, dom, true, 0)))
                     goto cleanup;
                 if (vshTableRowAppend(table, id_buf,
                                       virDomainGetName(dom),
@@ -2131,7 +2131,7 @@ virshDomainStatsPrintRecord(vshControl *ctl G_GNUC_UNUSED,
     for (i = 0; i < record->nparams; i++) {
         g_autofree char *param = NULL;
 
-        if (!(param = vshGetTypedParamValue(ctl, record->params + i)))
+        VIR_UNLESS ((param = vshGetTypedParamValue(ctl, record->params + i)))
             return false;
 
         vshPrint(ctl, "  %s=%s\n", record->params[i].field, param);
@@ -2223,7 +2223,7 @@ cmdDomstats(vshControl *ctl, const vshCmd *cmd)
         ndoms = 1;
 
         while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
-            if (!(dom = virshLookupDomainBy(ctl, opt->data,
+            VIR_UNLESS ((dom = virshLookupDomainBy(ctl, opt->data,
                                             VIRSH_BYID |
                                             VIRSH_BYUUID | VIRSH_BYNAME)))
                 goto cleanup;
@@ -2247,7 +2247,7 @@ cmdDomstats(vshControl *ctl, const vshCmd *cmd)
 
     next = records;
     while (*next) {
-        if (!virshDomainStatsPrintRecord(ctl, *next, raw))
+        VIR_UNLESS (virshDomainStatsPrintRecord(ctl, *next, raw))
             goto cleanup;
 
         if (*(++next))
@@ -2319,7 +2319,7 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
         return false;
     }
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if ((ifaces_count = virDomainInterfaceAddresses(dom, &ifaces, source, 0)) < 0) {
@@ -2340,7 +2340,7 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
             continue;
 
         /* When the interface has no IP address */
-        if (!iface->naddrs) {
+        VIR_UNLESS (iface->naddrs) {
             vshPrint(ctl, " %-10s %-17s    %-12s %s\n",
                      iface->name,
                      iface->hwaddr ? iface->hwaddr : "N/A", "N/A", "N/A");
@@ -2366,7 +2366,7 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
 
             ip_addr_str = virBufferContentAndReset(&buf);
 
-            if (!ip_addr_str)
+            VIR_UNLESS (ip_addr_str)
                 ip_addr_str = g_strdup("");
 
             /* Don't repeat interface name */
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index d5fd8be7c3..bbebd8fd72 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -125,7 +125,7 @@ virshAddressParse(const char *str,
     g_autofree char *type = g_strdup(str);
     char *a = strchr(type, ':');
 
-    if (!a)
+    VIR_UNLESS (a)
         return -1;
 
     *a = '\0';
@@ -248,7 +248,7 @@ virshFetchPassFdsList(vshControl *ctl,
     if (vshCommandOptStringQuiet(ctl, cmd, "pass-fds", &fdopt) <= 0)
         return 0;
 
-    if (!(fdlist = g_strsplit(fdopt, ",", -1))) {
+    VIR_UNLESS ((fdlist = g_strsplit(fdopt, ",", -1))) {
         vshError(ctl, _("Unable to split FD list '%s'"), fdopt);
         return -1;
     }
@@ -290,14 +290,14 @@ virshDomainDefine(virConnectPtr conn, const char *xml, unsigned int flags)
 {
     virDomainPtr dom;
 
-    if (!flags)
+    VIR_UNLESS (flags)
         return virDomainDefineXML(conn, xml);
 
     dom = virDomainDefineXMLFlags(conn, xml, flags);
     /* If validate is the only flag, just drop it and
      * try again.
      */
-    if (!dom) {
+    VIR_UNLESS (dom) {
         if ((virGetLastErrorCode() == VIR_ERR_NO_SUPPORT) &&
             (flags == VIR_DOMAIN_DEFINE_VALIDATE))
             dom = virDomainDefineXML(conn, xml);
@@ -385,7 +385,7 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
@@ -791,7 +791,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
         return true;
     }
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (persistent &&
@@ -918,7 +918,7 @@ virshParseRateStr(vshControl *ctl,
     g_auto(GStrv) tok = NULL;
     size_t ntok;
 
-    if (!(tok = g_strsplit(rateStr, ",", 0)))
+    VIR_UNLESS ((tok = g_strsplit(rateStr, ",", 0)))
         return -1;
 
     if ((ntok = g_strv_length(tok)) > 4) {
@@ -1126,7 +1126,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
         return true;
     }
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (persistent &&
@@ -1177,7 +1177,7 @@ cmdAutostart(vshControl *ctl, const vshCmd *cmd)
     const char *name;
     int autostart;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     autostart = !vshCommandOptBool(cmd, "disable");
@@ -1412,7 +1412,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         goto cleanup;
 
     if (vshCommandOptStringReq(ctl, cmd, "device", &disk) < 0)
@@ -1604,7 +1604,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if ((rv = vshCommandOptInt(ctl, cmd, "weight", &weight)) < 0) {
@@ -1853,7 +1853,7 @@ virshBlockJobWaitFree(virshBlockJobWaitData *data)
 {
     virshControl *priv = NULL;
 
-    if (!data)
+    VIR_UNLESS (data)
         return;
 
     priv = data->ctl->privData;
@@ -1903,7 +1903,7 @@ virshBlockJobWait(virshBlockJobWaitData *data)
     virDomainBlockJobInfo info, last;
     int result;
 
-    if (!data)
+    VIR_UNLESS (data)
         return 0;
 
     if (data->async_abort)
@@ -2144,7 +2144,7 @@ cmdBlockcommit(vshControl *ctl, const vshCmd *cmd)
     if (timeout)
         blocking = true;
 
-    if (!blocking) {
+    VIR_UNLESS (blocking) {
         if (verbose) {
             vshError(ctl, "%s", _("--verbose requires at least one of --timeout, "
                                   "--wait, --pivot, or --keep-overlay"));
@@ -2161,7 +2161,7 @@ cmdBlockcommit(vshControl *ctl, const vshCmd *cmd)
     if (async)
         abort_flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (blocking &&
@@ -2172,7 +2172,7 @@ cmdBlockcommit(vshControl *ctl, const vshCmd *cmd)
     if (virDomainBlockCommit(dom, path, base, top, bandwidth, flags) < 0)
         goto cleanup;
 
-    if (!blocking) {
+    VIR_UNLESS (blocking) {
         if (active)
             vshPrintExtra(ctl, "%s", _("Active Block Commit started"));
         else
@@ -2402,12 +2402,12 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd)
     VSH_EXCLUSIVE_OPTIONS_VAR(blockdev, xml);
     VSH_EXCLUSIVE_OPTIONS_VAR(pivot, finish);
 
-    if (!dest && !xml) {
+    VIR_UNLESS (dest && !xml) {
         vshError(ctl, "%s", _("need either --dest or --xml"));
         return false;
     }
 
-    if (!blocking) {
+    VIR_UNLESS (blocking) {
         if (verbose) {
             vshError(ctl, "%s", _("--verbose requires at least one of --timeout, "
                                   "--wait, --pivot, or --finish"));
@@ -2421,7 +2421,7 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd)
         }
     }
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         goto cleanup;
 
     if (blocking &&
@@ -2442,7 +2442,7 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd)
         if (bandwidth || granularity || buf_size) {
             params = g_new0(virTypedParameter, 3);
             if (bandwidth) {
-                if (!bytes) {
+                VIR_UNLESS (bytes) {
                     /* bandwidth is ulong MiB/s, but the typed parameter is
                      * ullong bytes/s; make sure we don't overflow */
                     unsigned long long limit = MIN(ULONG_MAX, ULLONG_MAX >> 20);
@@ -2473,7 +2473,7 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd)
                 goto cleanup;
         }
 
-        if (!xmlstr) {
+        VIR_UNLESS (xmlstr) {
             g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
             g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
             g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
@@ -2508,7 +2508,7 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd)
             goto cleanup;
     }
 
-    if (!blocking) {
+    VIR_UNLESS (blocking) {
         vshPrintExtra(ctl, "%s", _("Block Copy started"));
         ret = true;
         goto cleanup;
@@ -2658,7 +2658,7 @@ virshBlockJobInfo(vshControl *ctl,
             return false;
         speed = info.bandwidth;
         /* Scale to bytes/s unless in raw mode */
-        if (!raw) {
+        VIR_UNLESS (raw) {
             speed <<= 20;
             if (speed >> 20 != info.bandwidth) {
                 vshError(ctl, _("overflow in converting %ld MiB/s to bytes\n"),
@@ -2669,7 +2669,7 @@ virshBlockJobInfo(vshControl *ctl,
     }
 
     if (rc == 0) {
-        if (!raw)
+        VIR_UNLESS (raw)
             vshPrintExtra(ctl, _("No current block job for %s"), path);
         return true;
     }
@@ -2764,7 +2764,7 @@ cmdBlockjob(vshControl *ctl, const vshCmd *cmd)
     VSH_EXCLUSIVE_OPTIONS_VAR(bytes, pivot);
     VSH_EXCLUSIVE_OPTIONS_VAR(bytes, async);
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     /* XXX Allow path to be optional to list info on all devices at once */
@@ -2869,7 +2869,7 @@ cmdBlockpull(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "keep-relative"))
         flags |= VIR_DOMAIN_BLOCK_REBASE_RELATIVE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (blocking &&
@@ -2891,7 +2891,7 @@ cmdBlockpull(vshControl *ctl, const vshCmd *cmd)
             goto cleanup;
     }
 
-    if (!blocking) {
+    VIR_UNLESS (blocking) {
         vshPrintExtra(ctl, "%s", _("Block Pull started"));
         ret = true;
         goto cleanup;
@@ -2974,7 +2974,7 @@ cmdBlockresize(vshControl *ctl, const vshCmd *cmd)
     else
         flags |= VIR_DOMAIN_BLOCK_RESIZE_BYTES;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (virDomainBlockResize(dom, path, size, flags) < 0) {
@@ -3036,7 +3036,7 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom,
         return false;
     }
 
-    if (!isatty(STDIN_FILENO)) {
+    VIR_UNLESS (isatty(STDIN_FILENO)) {
         vshError(ctl, "%s", _("Cannot run interactive console without a controlling TTY"));
         return false;
     }
@@ -3062,7 +3062,7 @@ cmdConsole(vshControl *ctl, const vshCmd *cmd)
     unsigned int flags = 0;
     const char *name = NULL;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "devname", &name) < 0) /* sc_prohibit_devname */
@@ -3131,7 +3131,7 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd)
     xmlNodePtr cur = NULL;
     g_autofree char *xml_buf = NULL;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "interface", &iface) < 0 ||
@@ -3208,20 +3208,20 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd)
         cur = cur->next;
     }
 
-    if (!cur) {
+    VIR_UNLESS (cur) {
         /* element <link> not found, add one */
         cur = xmlNewChild(obj->nodesetval->nodeTab[i],
                           NULL,
                           BAD_CAST "link",
                           NULL);
-        if (!cur)
+        VIR_UNLESS (cur)
             return false;
 
         if (xmlNewProp(cur, BAD_CAST "state", BAD_CAST state) == NULL)
             return false;
     }
 
-    if (!(xml_buf = virXMLNodeToString(xml, obj->nodesetval->nodeTab[i]))) {
+    VIR_UNLESS ((xml_buf = virXMLNodeToString(xml, obj->nodesetval->nodeTab[i]))) {
         vshSaveLibvirtError();
         vshError(ctl, _("Failed to create XML"));
         return false;
@@ -3298,7 +3298,7 @@ cmdDomIftune(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "interface", &device) < 0)
@@ -3458,7 +3458,7 @@ cmdSuspend(vshControl *ctl, const vshCmd *cmd)
     g_autoptr(virshDomain) dom = NULL;
     const char *name;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (virDomainSuspend(dom) != 0) {
@@ -3513,7 +3513,7 @@ cmdDomPMSuspend(vshControl *ctl, const vshCmd *cmd)
     int suspendTarget;
     unsigned long long duration = 0;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (vshCommandOptULongLong(ctl, cmd, "duration", &duration) < 0)
@@ -3566,7 +3566,7 @@ cmdDomPMWakeup(vshControl *ctl, const vshCmd *cmd)
     const char *name;
     unsigned int flags = 0;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (virDomainPMWakeup(dom, flags) < 0) {
@@ -3719,7 +3719,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
     if (keep_nvram)
         flags |= VIR_DOMAIN_UNDEFINE_KEEP_NVRAM;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     /* Do some flag manipulation.  The goal here is to disable bits
@@ -3729,7 +3729,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
     if ((running = virDomainIsActive(dom)) < 0)
         goto error;
 
-    if (!running) {
+    VIR_UNLESS (running) {
         /* Undefine with snapshots only fails for inactive domains,
          * and managed save only exists on inactive domains; if
          * running, then we don't want to remove anything.  */
@@ -3763,7 +3763,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
             }
         }
     }
-    if (!has_managed_save) {
+    VIR_UNLESS (has_managed_save) {
         flags &= ~VIR_DOMAIN_UNDEFINE_MANAGED_SAVE;
         managed_save_safe = true;
     }
@@ -3810,7 +3810,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
             ctxt->node = vol_nodes[i];
 
             /* get volume source and target paths */
-            if (!(target = virXPathString("string(./target/@dev)", ctxt)))
+            VIR_UNLESS ((target = virXPathString("string(./target/@dev)", ctxt)))
                 goto error;
 
             if (!(source = virXPathString("string("
@@ -3834,21 +3834,21 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
                         break;
                     }
                 }
-                if (!found)
+                VIR_UNLESS (found)
                     continue;
             }
 
             if (pool) {
                 g_autoptr(virshStoragePool) storagepool = NULL;
 
-                if (!source) {
+                VIR_UNLESS (source) {
                     vshError(ctl,
                              _("Missing storage volume name for disk '%s'"),
                              target);
                     continue;
                 }
 
-                if (!(storagepool = virStoragePoolLookupByName(priv->conn,
+                VIR_UNLESS ((storagepool = virStoragePoolLookupByName(priv->conn,
                                                                pool))) {
                     vshError(ctl,
                              _("Storage pool '%s' for volume '%s' not found."),
@@ -3863,7 +3863,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
                vol.vol = virStorageVolLookupByPath(priv->conn, source);
             }
 
-            if (!vol.vol) {
+            VIR_UNLESS (vol.vol) {
                 vshError(ctl,
                          _("Storage volume '%s'(%s) is not managed by libvirt. "
                            "Remove it manually.\n"), target, source);
@@ -3914,7 +3914,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
     /* The new API is unsupported or unsafe; fall back to doing things
      * piecewise.  */
     if (has_managed_save) {
-        if (!managed_save) {
+        VIR_UNLESS (managed_save) {
             vshError(ctl, "%s",
                      _("Refusing to undefine while domain managed save "
                        "image exists"));
@@ -4062,7 +4062,7 @@ cmdStart(vshControl *ctl, const vshCmd *cmd)
     size_t nfds = 0;
     g_autofree int *fds = NULL;
 
-    if (!(dom = virshCommandOptDomainBy(ctl, cmd, NULL,
+    VIR_UNLESS ((dom = virshCommandOptDomainBy(ctl, cmd, NULL,
                                         VIRSH_BYNAME | VIRSH_BYUUID)))
         return false;
 
@@ -4219,7 +4219,7 @@ doSave(void *opaque)
     if (vshCommandOptStringReq(ctl, cmd, "xml", &xmlfile) < 0)
         goto out;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         goto out;
 
     if (xmlfile &&
@@ -4309,7 +4309,7 @@ virshWatchProgress(gpointer opaque)
             vshTTYDisableInterrupt(data->ctl);
             data->jobStarted = true;
 
-            if (!data->verbose) {
+            VIR_UNLESS (data->verbose) {
                 vshDebug(data->ctl, VSH_ERR_DEBUG,
                          "watchJob: job started, disabling callback\n");
                 return G_SOURCE_REMOVE;
@@ -4469,7 +4469,7 @@ cmdSave(vshControl *ctl, const vshCmd *cmd)
         .ret = -1,
     };
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0)
@@ -4489,7 +4489,7 @@ cmdSave(vshControl *ctl, const vshCmd *cmd)
 
     virThreadJoin(&workerThread);
 
-    if (!data.ret)
+    VIR_UNLESS (data.ret)
         vshPrintExtra(ctl, _("\nDomain '%s' saved to %s\n"), name, to);
 
     return !data.ret;
@@ -4536,7 +4536,7 @@ cmdSaveImageDumpxml(vshControl *ctl, const vshCmd *cmd)
         return false;
 
     xml = virDomainSaveImageGetXMLDesc(priv->conn, file, flags);
-    if (!xml)
+    VIR_UNLESS (xml)
         return false;
 
     vshPrint(ctl, "%s", xml);
@@ -4746,7 +4746,7 @@ doManagedsave(void *opaque)
     if (vshCommandOptBool(cmd, "paused"))
         flags |= VIR_DOMAIN_SAVE_PAUSED;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         goto out;
 
     if (virDomainManagedSave(dom, flags) < 0) {
@@ -4779,7 +4779,7 @@ cmdManagedSave(vshControl *ctl, const vshCmd *cmd)
         .ret = -1,
     };
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (vshCommandOptBool(cmd, "verbose"))
@@ -4796,7 +4796,7 @@ cmdManagedSave(vshControl *ctl, const vshCmd *cmd)
 
     virThreadJoin(&workerThread);
 
-    if (!data.ret)
+    VIR_UNLESS (data.ret)
         vshPrintExtra(ctl, _("\nDomain '%s' state saved by libvirt\n"), name);
 
     return !data.ret;
@@ -4827,7 +4827,7 @@ cmdManagedSaveRemove(vshControl *ctl, const vshCmd *cmd)
     const char *name;
     int hassave;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     hassave = virDomainHasManagedSaveImage(dom, 0);
@@ -4950,10 +4950,10 @@ cmdManagedSaveDumpxml(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "security-info"))
         flags |= VIR_DOMAIN_XML_SECURE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
-    if (!(xml = virDomainManagedSaveGetXMLDesc(dom, flags)))
+    VIR_UNLESS ((xml = virDomainManagedSaveGetXMLDesc(dom, flags)))
         return false;
 
     vshPrint(ctl, "%s", xml);
@@ -5013,7 +5013,7 @@ cmdManagedSaveDefine(vshControl *ctl, const vshCmd *cmd)
     if (virFileReadAll(xmlfile, VSH_MAX_XML_FILE, &xml) < 0)
         return false;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (virDomainManagedSaveDefineXML(dom, xml, flags) < 0) {
@@ -5109,7 +5109,7 @@ cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd,
     while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
         g_autofree char *set_field = g_strdup(opt->data);
 
-        if (!(set_val = strchr(set_field, '='))) {
+        VIR_UNLESS ((set_val = strchr(set_field, '='))) {
             vshError(ctl, "%s", _("Invalid syntax for --set, "
                                   "expecting name=value"));
             goto cleanup;
@@ -5181,18 +5181,18 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
     else
         queryflags = flags;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     /* Print SchedulerType */
-    if (!(schedulertype = virDomainGetSchedulerType(dom, &nparams))) {
+    VIR_UNLESS ((schedulertype = virDomainGetSchedulerType(dom, &nparams))) {
         vshPrint(ctl, "%-15s: %s\n", _("Scheduler"), _("Unknown"));
         goto cleanup;
     }
 
     vshPrint(ctl, "%-15s: %s\n", _("Scheduler"), schedulertype);
 
-    if (!nparams)
+    VIR_UNLESS (nparams)
         goto cleanup;
 
     params = g_new0(virTypedParameter, nparams);
@@ -5417,7 +5417,7 @@ doDump(void *opaque)
     if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0)
         goto out;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         goto out;
 
     if (vshCommandOptBool(cmd, "live"))
@@ -5432,7 +5432,7 @@ doDump(void *opaque)
         flags |= VIR_DUMP_MEMORY_ONLY;
 
     if (vshCommandOptBool(cmd, "format")) {
-        if (!(flags & VIR_DUMP_MEMORY_ONLY)) {
+        VIR_UNLESS ((flags & VIR_DUMP_MEMORY_ONLY)) {
             vshError(ctl, "%s", _("--format only works with --memory-only"));
             goto out;
         }
@@ -5485,7 +5485,7 @@ cmdDump(vshControl *ctl, const vshCmd *cmd)
         .ret = -1,
     };
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0)
@@ -5548,7 +5548,7 @@ virshGenFileName(vshControl *ctl, virDomainPtr dom, const char *mime)
     g_autofree char *nowstr = NULL;
     const char *ext = NULL;
 
-    if (!dom) {
+    VIR_UNLESS (dom) {
         vshError(ctl, "%s", _("Invalid domain supplied"));
         return NULL;
     }
@@ -5588,20 +5588,20 @@ cmdScreenshot(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptUInt(ctl, cmd, "screen", &screen) < 0)
         return false;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
-    if (!(st = virStreamNew(priv->conn, 0)))
+    VIR_UNLESS ((st = virStreamNew(priv->conn, 0)))
         goto cleanup;
 
     mime = virDomainScreenshot(dom, st, screen, flags);
-    if (!mime) {
+    VIR_UNLESS (mime) {
         vshError(ctl, _("could not take a screenshot of %s"), name);
         goto cleanup;
     }
 
-    if (!file) {
-        if (!(file = virshGenFileName(ctl, dom, mime)))
+    VIR_UNLESS (file) {
+        VIR_UNLESS ((file = virshGenFileName(ctl, dom, mime)))
             goto cleanup;
         generated = true;
     }
@@ -5733,7 +5733,7 @@ cmdSetLifecycleAction(vshControl *ctl, const vshCmd *cmd)
     }
     action = tmpVal;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (virDomainSetLifecycleAction(dom, type, action, flags) < 0) {
@@ -5794,7 +5794,7 @@ cmdSetUserPassword(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "password", &password) < 0)
         return false;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (virDomainSetUserPassword(dom, user, password, flags) < 0)
@@ -5827,7 +5827,7 @@ cmdResume(vshControl *ctl, const vshCmd *cmd)
     g_autoptr(virshDomain) dom = NULL;
     const char *name;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (virDomainResume(dom) != 0) {
@@ -5903,7 +5903,7 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd)
         tmp++;
     }
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (flags)
@@ -5983,7 +5983,7 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd)
         tmp++;
     }
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (virDomainReboot(dom, flags) != 0) {
@@ -6019,7 +6019,7 @@ cmdReset(vshControl *ctl, const vshCmd *cmd)
     g_autoptr(virshDomain) dom = NULL;
     const char *name;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (virDomainReset(dom, 0) != 0) {
@@ -6161,7 +6161,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
 
     VSH_REQUIRE_OPTION("keep-completed", "completed");
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptBool(cmd, "completed"))
@@ -6475,7 +6475,7 @@ cmdDomjobabort(vshControl *ctl, const vshCmd *cmd)
 {
     g_autoptr(virshDomain) dom = NULL;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (virDomainAbortJob(dom) < 0)
@@ -6631,7 +6631,7 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
     if (guest)
         flags |= VIR_DOMAIN_VCPU_GUEST;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (all) {
@@ -6703,7 +6703,7 @@ virshVcpuinfoPrintAffinity(vshControl *ctl,
 
     vshPrint(ctl, "%-15s ", _("CPU Affinity:"));
     if (pretty) {
-        if (!(str = virBitmapDataFormat(cpumap, VIR_CPU_MAPLEN(maxcpu))))
+        VIR_UNLESS ((str = virBitmapDataFormat(cpumap, VIR_CPU_MAPLEN(maxcpu))))
             return -1;
         vshPrint(ctl, _("%s (out of %d)"), str, maxcpu);
     } else {
@@ -6796,7 +6796,7 @@ virshVcpuinfoInactive(vshControl *ctl,
     ssize_t nextvcpu = -1;
     bool first = true;
 
-    if (!(vcpus = virshDomainGetVcpuBitmap(ctl, dom, true)))
+    VIR_UNLESS ((vcpus = virshDomainGetVcpuBitmap(ctl, dom, true)))
         return false;
 
     cpumaplen = VIR_CPU_MAPLEN(maxcpu);
@@ -6808,7 +6808,7 @@ virshVcpuinfoInactive(vshControl *ctl,
         return false;
 
     while ((nextvcpu = virBitmapNextSetBit(vcpus, nextvcpu)) >= 0) {
-        if (!first)
+        VIR_UNLESS (first)
             vshPrint(ctl, "\n");
         first = false;
 
@@ -6840,7 +6840,7 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
     int n;
     virshControl *priv = ctl->privData;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if ((maxcpu = virshNodeGetCPUCount(priv->conn)) < 0)
@@ -6931,7 +6931,7 @@ virshPrintPinInfo(vshControl *ctl,
 {
     g_autofree char *str = NULL;
 
-    if (!(str = virBitmapDataFormat(cpumap, cpumaplen)))
+    VIR_UNLESS ((str = virBitmapDataFormat(cpumap, cpumaplen)))
         return false;
 
     vshPrint(ctl, "%s", str);
@@ -6983,7 +6983,7 @@ virshVcpuPinQuery(vshControl *ctl,
     if ((ncpus = virDomainGetVcpuPinInfo(dom, ncpus, cpumap,
                                          cpumaplen, flags)) >= 0) {
         table = vshTableNew(_("VCPU"), _("CPU Affinity"), NULL);
-        if (!table)
+        VIR_UNLESS (table)
             return false;
 
         for (i = 0; i < ncpus; i++) {
@@ -6992,7 +6992,7 @@ virshVcpuPinQuery(vshControl *ctl,
             if (got_vcpu && i != vcpu)
                 continue;
 
-            if (!(pinInfo = virBitmapDataFormat(VIR_GET_CPUMAP(cpumap, cpumaplen, i),
+            VIR_UNLESS ((pinInfo = virBitmapDataFormat(VIR_GET_CPUMAP(cpumap, cpumaplen, i),
                                                 cpumaplen)))
                 return false;
 
@@ -7068,7 +7068,7 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "cpulist", &cpulist) < 0)
         return false;
 
-    if (!cpulist)
+    VIR_UNLESS (cpulist)
         VSH_EXCLUSIVE_OPTIONS_VAR(live, config);
 
     if ((got_vcpu = vshCommandOptUInt(ctl, cmd, "vcpu", &vcpu)) < 0)
@@ -7083,16 +7083,16 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
     if ((maxcpu = virshNodeGetCPUCount(priv->conn)) < 0)
         return false;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     /* Query mode: show CPU affinity information then exit.*/
-    if (!cpulist) {
+    VIR_UNLESS (cpulist) {
         return virshVcpuPinQuery(ctl, dom, vcpu, got_vcpu, maxcpu, flags);
     }
 
     /* Pin mode: pinning specified vcpu to specified physical cpus */
-    if (!(cpumap = virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu)))
+    VIR_UNLESS ((cpumap = virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu)))
         return false;
 
     /* use old API without any explicit flags */
@@ -7160,7 +7160,7 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd)
     if (!current && !live && !config)
         flags = -1;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "cpulist", &cpulist) < 0) {
@@ -7195,7 +7195,7 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd)
     }
 
     /* Pin mode: pinning emulator threads to specified physical cpus */
-    if (!(cpumap = virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu)))
+    VIR_UNLESS ((cpumap = virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu)))
         return false;
 
     if (flags == -1)
@@ -7275,7 +7275,7 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
     if (hotpluggable)
         flags |= VIR_DOMAIN_VCPU_HOTPLUGGABLE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptUInt(ctl, cmd, "count", &count) < 0)
@@ -7357,7 +7357,7 @@ cmdGuestvcpus(vshControl *ctl, const vshCmd *cmd)
         return false;
     }
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (enable)
@@ -7450,7 +7450,7 @@ cmdSetvcpu(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "vcpulist", &vcpulist))
         return false;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (enable)
@@ -7507,7 +7507,7 @@ cmdDomblkthreshold(vshControl *ctl, const vshCmd *cmd)
                                &threshold, 1, ULLONG_MAX) < 0)
         return false;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (virDomainSetBlockThreshold(dom, dev, threshold, 0) < 0)
@@ -7560,7 +7560,7 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if ((rc = virDomainGetIOThreadInfo(dom, &info, flags)) < 0) {
@@ -7576,7 +7576,7 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd)
     }
 
     table = vshTableNew(_("IOThread ID"), _("CPU Affinity"), NULL);
-    if (!table)
+    VIR_UNLESS (table)
         goto cleanup;
 
     for (i = 0; i < niothreads; i++) {
@@ -7658,7 +7658,7 @@ cmdIOThreadPin(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptUInt(ctl, cmd, "iothread", &iothread_id) < 0)
@@ -7670,7 +7670,7 @@ cmdIOThreadPin(vshControl *ctl, const vshCmd *cmd)
     if ((maxcpu = virshNodeGetCPUCount(priv->conn)) < 0)
         return false;
 
-    if (!(cpumap = virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu)))
+    VIR_UNLESS ((cpumap = virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu)))
         return false;
 
     if (virDomainPinIOThread(dom, iothread_id,
@@ -7724,7 +7724,7 @@ cmdIOThreadAdd(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptInt(ctl, cmd, "id", &iothread_id) < 0)
@@ -7797,7 +7797,7 @@ cmdIOThreadSet(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptInt(ctl, cmd, "id", &id) < 0)
@@ -7889,7 +7889,7 @@ cmdIOThreadDel(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptInt(ctl, cmd, "id", &iothread_id) < 0)
@@ -7965,7 +7965,7 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd)
     bool ret = false;
     int rv = 0;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     show_total = vshCommandOptBool(cmd, "total");
@@ -7996,7 +7996,7 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd)
         show_per_cpu = true;
     }
 
-    if (!show_per_cpu) /* show total stats only */
+    VIR_UNLESS (show_per_cpu) /* show total stats only */
         goto do_show_total;
 
     /* get number of cpus on the node */
@@ -8019,7 +8019,7 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd)
     if ((nparams = virDomainGetCPUStats(dom, NULL, 0, 0, 1, 0)) < 0)
         goto failed_stats;
 
-    if (!nparams) {
+    VIR_UNLESS (nparams) {
         vshPrint(ctl, "%s", _("No per-CPU stats available"));
         if (show_total)
             goto do_show_total;
@@ -8048,7 +8048,7 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd)
     }
     VIR_FREE(params);
 
-    if (!show_total) {
+    VIR_UNLESS (show_total) {
         ret = true;
         goto cleanup;
     }
@@ -8058,7 +8058,7 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd)
     if ((nparams = virDomainGetCPUStats(dom, NULL, 0, -1, 1, 0)) < 0)
         goto failed_stats;
 
-    if (!nparams) {
+    VIR_UNLESS (nparams) {
         vshPrint(ctl, "%s", _("No total stats available"));
         goto cleanup;
     }
@@ -8168,7 +8168,7 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd)
     else
         dom = virDomainCreateXML(priv->conn, buffer, flags);
 
-    if (!dom) {
+    VIR_UNLESS (dom) {
         vshError(ctl, _("Failed to create domain from %s"), from);
         return false;
     }
@@ -8228,7 +8228,7 @@ cmdDefine(vshControl *ctl, const vshCmd *cmd)
         dom = virDomainDefineXML(priv->conn, buffer);
     VIR_FREE(buffer);
 
-    if (!dom) {
+    VIR_UNLESS (dom) {
         vshError(ctl, _("Failed to define domain from %s"), from);
         return false;
     }
@@ -8268,7 +8268,7 @@ cmdDestroy(vshControl *ctl, const vshCmd *cmd)
     unsigned int flags = 0;
     int result;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (vshCommandOptBool(cmd, "graceful"))
@@ -8351,7 +8351,7 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if ((state = virshDomainState(ctl, dom, NULL)) < 0)
@@ -8373,10 +8373,10 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
         g_autofree char *descDom = NULL;
         g_autofree char *descNew = NULL;
 
-        if (!(descDom = virshGetDomainDescription(ctl, dom, title, queryflags)))
+        VIR_UNLESS ((descDom = virshGetDomainDescription(ctl, dom, title, queryflags)))
             return false;
 
-        if (!descArg)
+        VIR_UNLESS (descArg)
             descArg = g_strdup(descDom);
 
         if (edit) {
@@ -8385,7 +8385,7 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
             char *tmpstr;
 
             /* Create and open the temporary file. */
-            if (!(tmp = vshEditWriteToTempFile(ctl, descArg)))
+            VIR_UNLESS ((tmp = vshEditWriteToTempFile(ctl, descArg)))
                 return false;
 
             /* Start the editor. */
@@ -8393,7 +8393,7 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
                 return false;
 
             /* Read back the edited file. */
-            if (!(desc_edited = vshEditReadBackFile(ctl, tmp)))
+            VIR_UNLESS ((desc_edited = vshEditReadBackFile(ctl, tmp)))
                 return false;
 
             /* strip a possible newline at the end of file; some
@@ -8435,7 +8435,7 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
 
     } else {
         g_autofree char *desc = virshGetDomainDescription(ctl, dom, title, queryflags);
-        if (!desc)
+        VIR_UNLESS (desc)
             return false;
 
         if (strlen(desc) > 0) {
@@ -8502,7 +8502,7 @@ virshDomainGetEditMetadata(vshControl *ctl G_GNUC_UNUSED,
 {
     char *ret;
 
-    if (!(ret = virDomainGetMetadata(dom, VIR_DOMAIN_METADATA_ELEMENT,
+    VIR_UNLESS ((ret = virDomainGetMetadata(dom, VIR_DOMAIN_METADATA_ELEMENT,
                                      uri, flags))) {
         vshResetLibvirtError();
         ret = g_strdup("\n");
@@ -8538,7 +8538,7 @@ cmdMetadata(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "uri", &uri) < 0 ||
@@ -8580,7 +8580,7 @@ cmdMetadata(vshControl *ctl, const vshCmd *cmd)
     } else {
         g_autofree char *data = NULL;
         /* get */
-        if (!(data = virDomainGetMetadata(dom, VIR_DOMAIN_METADATA_ELEMENT,
+        VIR_UNLESS ((data = virDomainGetMetadata(dom, VIR_DOMAIN_METADATA_ELEMENT,
                                           uri, flags)))
             return false;
 
@@ -8617,7 +8617,7 @@ cmdInjectNMI(vshControl *ctl, const vshCmd *cmd)
 {
     g_autoptr(virshDomain) dom = NULL;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (virDomainInjectNMI(dom, 0) < 0)
@@ -8683,7 +8683,7 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd)
     int keycode;
     unsigned int keycodes[VIR_DOMAIN_SEND_KEY_MAX_KEYS];
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringQuiet(ctl, cmd, "codeset", &codeset_option) <= 0)
@@ -8801,7 +8801,7 @@ cmdSendProcessSignal(vshControl *ctl, const vshCmd *cmd)
     long long pid_value;
     int signum;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptLongLong(ctl, cmd, "pid", &pid_value) < 0)
@@ -8876,7 +8876,7 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd)
             flags |= VIR_DOMAIN_AFFECT_LIVE;
     }
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     /* The API expects 'unsigned long' KiB, so depending on whether we
@@ -8945,7 +8945,7 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     /* The API expects 'unsigned long' KiB, so depending on whether we
@@ -9068,7 +9068,7 @@ virshGetUpdatedMemoryXML(char **updatedMemoryXML,
 
         requestedSizeNode = virXPathNode("./target/requested", ctxt);
 
-        if (!requestedSizeNode) {
+        VIR_UNLESS (requestedSizeNode) {
             vshError(ctl, _("virtio-mem device is missing <requested/>"));
             return -1;
         }
@@ -9077,7 +9077,7 @@ virshGetUpdatedMemoryXML(char **updatedMemoryXML,
         xmlNodeSetContent(requestedSizeNode, BAD_CAST kibibytesStr);
     }
 
-    if (!(*updatedMemoryXML = virXMLNodeToString(doc, mems[0]))) {
+    VIR_UNLESS ((*updatedMemoryXML = virXMLNodeToString(doc, mems[0]))) {
         vshSaveLibvirtError();
         return -1;
     }
@@ -9104,7 +9104,7 @@ cmdUpdateMemoryDevice(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (virshGetUpdatedMemoryXML(&updatedMemoryXML, ctl, cmd, dom, flags) < 0)
@@ -9226,7 +9226,7 @@ cmdMemtune(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
 #define PARSE_MEMTUNE_PARAM(NAME, FIELD) \
@@ -9340,7 +9340,7 @@ virshParseEventStr(const char *event,
     g_auto(GStrv) tok = NULL;
     GStrv next;
 
-    if (!(tok = g_strsplit(event, ",", 0)))
+    VIR_UNLESS ((tok = g_strsplit(event, ",", 0)))
         return -1;
 
     for (next = tok; *next; next++) {
@@ -9395,7 +9395,7 @@ cmdPerf(vshControl *ctl, const vshCmd *cmd)
         vshCommandOptStringReq(ctl, cmd, "disable", &disable) < 0)
         return false;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (enable && virshParseEventStr(enable, true, &params,
@@ -9486,7 +9486,7 @@ cmdNumatune(vshControl * ctl, const vshCmd * cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "nodeset", &nodeset) < 0)
@@ -9592,7 +9592,7 @@ cmdDomLaunchSecInfo(vshControl * ctl, const vshCmd * cmd)
     virTypedParameterPtr params = NULL;
     bool ret = false;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (virDomainGetLaunchSecurityInfo(dom, &params, &nparams, 0) != 0) {
@@ -9659,7 +9659,7 @@ cmdDomSetLaunchSecState(vshControl * ctl, const vshCmd * cmd)
     int rv;
     bool ret = false;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "secrethdr", &sechdrfile) < 0)
@@ -9817,7 +9817,7 @@ cmdQemuMonitorCommandQMPWrap(vshControl *ctl,
         virBufferTrim(&buf, ",");
         virBufferAddLit(&buf, "}");
 
-        if (!(arguments = virJSONValueFromString(virBufferCurrentContent(&buf)))) {
+        VIR_UNLESS ((arguments = virJSONValueFromString(virBufferCurrentContent(&buf)))) {
             vshError(ctl, _("failed to wrap arguments '%s' into a QMP command wrapper"),
                      fullargs);
             return NULL;
@@ -9852,7 +9852,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
     VSH_EXCLUSIVE_OPTIONS("hmp", "pretty");
     VSH_EXCLUSIVE_OPTIONS("hmp", "return-value");
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptBool(cmd, "hmp")) {
@@ -9862,7 +9862,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
         monitor_cmd = cmdQemuMonitorCommandQMPWrap(ctl, cmd);
     }
 
-    if (!monitor_cmd) {
+    VIR_UNLESS (monitor_cmd) {
         vshSaveLibvirtError();
         return NULL;
     }
@@ -9890,13 +9890,13 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
     }
 
     /* print raw non-prettified result */
-    if (!resultjson) {
+    VIR_UNLESS (resultjson) {
         vshPrint(ctl, "%s\n", result);
         return true;
     }
 
     if (returnval) {
-        if (!(formatjson = virJSONValueObjectGet(resultjson, "return"))) {
+        VIR_UNLESS ((formatjson = virJSONValueObjectGet(resultjson, "return"))) {
             vshError(ctl, "'return' member missing");
             return false;
         }
@@ -9958,7 +9958,7 @@ virshEventQemuPrint(virConnectPtr conn G_GNUC_UNUSED,
     }
 
     data->count++;
-    if (!data->loop)
+    VIR_UNLESS (data->loop)
         vshEventDone(data->ctl);
 }
 
@@ -10034,7 +10034,7 @@ cmdQemuMonitorEvent(vshControl *ctl, const vshCmd *cmd)
         return false;
 
     if (vshCommandOptBool(cmd, "domain"))
-        if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+        VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
             goto cleanup;
 
     if (vshEventStart(ctl, timeout) < 0)
@@ -10105,7 +10105,7 @@ cmdQemuAttach(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptUInt(ctl, cmd, "pid", &pid_value) <= 0)
         return false;
 
-    if (!(dom = virDomainQemuAttach(priv->conn, pid_value, flags))) {
+    VIR_UNLESS ((dom = virDomainQemuAttach(priv->conn, pid_value, flags))) {
         vshError(ctl, _("Failed to attach to pid %u"), pid_value);
         return false;
     }
@@ -10205,7 +10205,7 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd)
     }
 
     result = virDomainQemuAgentCommand(dom, guest_agent_cmd, timeout, flags);
-    if (!result)
+    VIR_UNLESS (result)
         goto cleanup;
 
     if (vshCommandOptBool(cmd, "pretty")) {
@@ -10400,10 +10400,10 @@ cmdDumpXML(vshControl *ctl, const vshCmd *cmd)
     if (migratable)
         flags |= VIR_DOMAIN_XML_MIGRATABLE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
-    if (!(dump = virDomainGetXMLDesc(dom, flags)))
+    VIR_UNLESS ((dump = virDomainGetXMLDesc(dom, flags)))
         return false;
 
     vshPrint(ctl, "%s", dump);
@@ -10456,7 +10456,7 @@ cmdDomXMLFromNative(vshControl *ctl, const vshCmd *cmd)
         return false;
 
     xmlData = virConnectDomainXMLFromNative(priv->conn, format, configData, flags);
-    if (!xmlData)
+    VIR_UNLESS (xmlData)
         return false;
 
     vshPrint(ctl, "%s", xmlData);
@@ -10522,12 +10522,12 @@ cmdDomXMLToNative(vshControl *ctl, const vshCmd *cmd)
         return false;
     }
 
-    if (!xmlData) {
+    VIR_UNLESS (xmlData) {
         vshError(ctl, "%s", _("failed to retrieve XML"));
         return false;
     }
 
-    if (!(configData = virConnectDomainXMLToNative(priv->conn, format, xmlData, flags)))
+    VIR_UNLESS ((configData = virConnectDomainXMLToNative(priv->conn, format, xmlData, flags)))
         return false;
 
     vshPrint(ctl, "%s", configData);
@@ -10563,7 +10563,7 @@ cmdDomname(vshControl *ctl, const vshCmd *cmd)
 {
     g_autoptr(virshDomain) dom = NULL;
 
-    if (!(dom = virshCommandOptDomainBy(ctl, cmd, NULL,
+    VIR_UNLESS ((dom = virshCommandOptDomainBy(ctl, cmd, NULL,
                                         VIRSH_BYID|VIRSH_BYUUID)))
         return false;
 
@@ -10602,7 +10602,7 @@ cmdDomrename(vshControl *ctl, const vshCmd *cmd)
     g_autoptr(virshDomain) dom = NULL;
     const char *new_name = NULL;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "new-name", &new_name) < 0)
@@ -10641,7 +10641,7 @@ cmdDomid(vshControl *ctl, const vshCmd *cmd)
     g_autoptr(virshDomain) dom = NULL;
     unsigned int id;
 
-    if (!(dom = virshCommandOptDomainBy(ctl, cmd, NULL,
+    VIR_UNLESS ((dom = virshCommandOptDomainBy(ctl, cmd, NULL,
                                         VIRSH_BYNAME|VIRSH_BYUUID)))
         return false;
 
@@ -10677,7 +10677,7 @@ cmdDomuuid(vshControl *ctl, const vshCmd *cmd)
     g_autoptr(virshDomain) dom = NULL;
     char uuid[VIR_UUID_STRING_BUFLEN];
 
-    if (!(dom = virshCommandOptDomainBy(ctl, cmd, NULL,
+    VIR_UNLESS ((dom = virshCommandOptDomainBy(ctl, cmd, NULL,
                                         VIRSH_BYNAME|VIRSH_BYID)))
         return false;
 
@@ -10931,7 +10931,7 @@ doMigrate(void *opaque)
         goto out_sig;
 #endif /* !WIN32 */
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         goto out;
 
     if (vshCommandOptStringReq(ctl, cmd, "desturi", &desturi) < 0)
@@ -11302,7 +11302,7 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd)
     VSH_REQUIRE_OPTION("persistent-xml", "persistent");
     VSH_REQUIRE_OPTION("tls-destination", "tls");
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptBool(cmd, "verbose"))
@@ -11352,7 +11352,7 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd)
             goto cleanup;
 
         dconn = virshConnect(ctl, desturi, false);
-        if (!dconn)
+        VIR_UNLESS (dconn)
             goto cleanup;
 
         data.dconn = dconn;
@@ -11407,7 +11407,7 @@ cmdMigrateSetMaxDowntime(vshControl *ctl, const vshCmd *cmd)
     g_autoptr(virshDomain) dom = NULL;
     unsigned long long downtime = 0;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptULongLong(ctl, cmd, "downtime", &downtime) < 0)
@@ -11446,7 +11446,7 @@ cmdMigrateGetMaxDowntime(vshControl *ctl, const vshCmd *cmd)
     g_autoptr(virshDomain) dom = NULL;
     unsigned long long downtime;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (virDomainMigrateGetMaxDowntime(dom, &downtime, 0) < 0)
@@ -11490,7 +11490,7 @@ cmdMigrateCompCache(vshControl *ctl, const vshCmd *cmd)
     double value;
     int rc;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     rc = vshCommandOptULongLong(ctl, cmd, "size", &size);
@@ -11545,7 +11545,7 @@ cmdMigrateSetMaxSpeed(vshControl *ctl, const vshCmd *cmd)
     unsigned long bandwidth = 0;
     unsigned int flags = 0;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptULWrap(ctl, cmd, "bandwidth", &bandwidth) < 0)
@@ -11589,7 +11589,7 @@ cmdMigrateGetMaxSpeed(vshControl *ctl, const vshCmd *cmd)
     unsigned long bandwidth;
     unsigned int flags = 0;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptBool(cmd, "postcopy"))
@@ -11627,7 +11627,7 @@ cmdMigratePostCopy(vshControl *ctl, const vshCmd *cmd)
 {
     g_autoptr(virshDomain) dom = NULL;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (virDomainMigrateStartPostCopy(dom, 0) < 0)
@@ -11717,7 +11717,7 @@ virshGetOneDisplay(vshControl *ctl,
     if (!port && !tls_port && !sockpath)
         return NULL;
 
-    if (!listen_addr) {
+    VIR_UNLESS (listen_addr) {
         g_autofree char *xpathListenAddress = NULL;
         /* The subelement address - <listen address='xyz'/> -
          * *should* have been automatically backfilled into its
@@ -11822,10 +11822,10 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
 
     VSH_EXCLUSIVE_OPTIONS("all", "type");
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
-    if (!virDomainIsActive(dom)) {
+    VIR_UNLESS (virDomainIsActive(dom)) {
         vshError(ctl, _("Domain is not running"));
         return false;
     }
@@ -11847,19 +11847,19 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
         if (!all && type && STRNEQ(type, scheme[iter]))
             continue;
 
-        if (!(display = virshGetOneDisplay(ctl, scheme[iter], ctxt)))
+        VIR_UNLESS ((display = virshGetOneDisplay(ctl, scheme[iter], ctxt)))
             continue;
 
         vshPrint(ctl, "%s", display);
 
         /* We got what we came for so return successfully */
         ret = true;
-        if (!all)
+        VIR_UNLESS (all)
             break;
         vshPrint(ctl, "\n");
     }
 
-    if (!ret) {
+    VIR_UNLESS (ret) {
         if (type)
             vshError(ctl, _("No graphical display with type '%s' found"), type);
         else
@@ -11896,11 +11896,11 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd)
     int port = 0;
     g_autofree char *listen_addr = NULL;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     /* Check if the domain is active and don't rely on -1 for this */
-    if (!virDomainIsActive(dom)) {
+    VIR_UNLESS (virDomainIsActive(dom)) {
         vshError(ctl, _("Domain is not running"));
         return false;
     }
@@ -11917,7 +11917,7 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd)
 
     listen_addr = virXPathString("string(/domain/devices/graphics"
                                  "[@type='vnc']/@listen)", ctxt);
-    if (!listen_addr) {
+    VIR_UNLESS (listen_addr) {
         /* The subelement address - <listen address='xyz'/> -
          * *should* have been automatically backfilled into its
          * parent <graphics listen='xyz'> (which we just tried to
@@ -11965,7 +11965,7 @@ cmdTTYConsole(vshControl *ctl, const vshCmd *cmd)
     if (virshDomainGetXML(ctl, cmd, 0, &xml, &ctxt) < 0)
         return false;
 
-    if (!(tty = virXPathString("string(/domain/devices/console/@tty)", ctxt)))
+    VIR_UNLESS ((tty = virXPathString("string(/domain/devices/console/@tty)", ctxt)))
         return false;
 
     vshPrint(ctl, "%s\n", tty);
@@ -12008,7 +12008,7 @@ cmdDomHostname(vshControl *ctl, const vshCmd *cmd)
     const char *sourcestr = NULL;
     int flags = 0; /* Use default value. Drivers can have its own default. */
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "source", &sourcestr) < 0)
@@ -12090,7 +12090,7 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (persistent &&
@@ -12165,7 +12165,7 @@ cmdDetachDeviceAlias(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "alias", &alias) < 0)
@@ -12230,7 +12230,7 @@ cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
@@ -12309,7 +12309,7 @@ virshDomainDetachInterface(char *doc,
     int diff_mac = -1;
     size_t i;
 
-    if (!(xml = virXMLParseStringCtxt(doc, _("(domain_definition)"), &ctxt))) {
+    VIR_UNLESS ((xml = virXMLParseStringCtxt(doc, _("(domain_definition)"), &ctxt))) {
         vshError(ctl, "%s", _("Failed to get interface information"));
         return false;
     }
@@ -12328,7 +12328,7 @@ virshDomainDetachInterface(char *doc,
         return false;
     }
 
-    if (!mac) {
+    VIR_UNLESS (mac) {
         matchNode = obj->nodesetval->nodeTab[0];
         goto hit;
     }
@@ -12341,7 +12341,7 @@ virshDomainDetachInterface(char *doc,
                 virXMLNodeNameEqual(cur, "mac")) {
                 g_autofree char *tmp_mac = virXMLPropString(cur, "address");
                 diff_mac = virMacAddrCompare(tmp_mac, mac);
-                if (!diff_mac) {
+                VIR_UNLESS (diff_mac) {
                     if (matchNode) {
                         /* this is the 2nd match, so it's ambiguous */
                         vshError(ctl, _("Domain has multiple interfaces matching "
@@ -12356,13 +12356,13 @@ virshDomainDetachInterface(char *doc,
             cur = cur->next;
         }
     }
-    if (!matchNode) {
+    VIR_UNLESS (matchNode) {
         vshError(ctl, _("No interface with MAC address %s was found"), mac);
         return false;
     }
 
  hit:
-    if (!(detach_xml = virXMLNodeToString(xml, matchNode))) {
+    VIR_UNLESS ((detach_xml = virXMLNodeToString(xml, matchNode))) {
         vshSaveLibvirtError();
         return false;
     }
@@ -12392,7 +12392,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
     VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
     VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0)
@@ -12404,9 +12404,9 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
     affect_config = (config || persistent);
 
     if (affect_config) {
-        if (!(doc_config = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_INACTIVE)))
+        VIR_UNLESS ((doc_config = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_INACTIVE)))
             goto cleanup;
-        if (!(ret = virshDomainDetachInterface(doc_config,
+        VIR_UNLESS ((ret = virshDomainDetachInterface(doc_config,
                                                flags | VIR_DOMAIN_AFFECT_CONFIG,
                                                dom, ctl, current, type, mac)))
             goto cleanup;
@@ -12420,7 +12420,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
         if (affect_live)
             flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-        if (!(doc_live = virDomainGetXMLDesc(dom, 0)))
+        VIR_UNLESS ((doc_live = virDomainGetXMLDesc(dom, 0)))
             goto cleanup;
 
         ret = virshDomainDetachInterface(doc_live, flags,
@@ -12428,7 +12428,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
     }
 
  cleanup:
-    if (!ret) {
+    VIR_UNLESS (ret) {
         vshError(ctl, "%s", _("Failed to detach interface"));
     } else {
         vshPrintExtra(ctl, "%s", _("Interface detached successfully\n"));
@@ -12478,7 +12478,7 @@ virshFindDisk(const char *doc,
     size_t i;
 
     xml = virXMLParseStringCtxt(doc, _("(domain_definition)"), &ctxt);
-    if (!xml) {
+    VIR_UNLESS (xml) {
         vshError(NULL, "%s", _("Failed to get disk information"));
         return NULL;
     }
@@ -12509,7 +12509,7 @@ virshFindDisk(const char *doc,
                     is_supported = true;
             }
 
-            if (!is_supported)
+            VIR_UNLESS (is_supported)
                 continue;
         }
 
@@ -12571,12 +12571,12 @@ virshUpdateDiskXML(xmlNodePtr disk_node,
     g_autofree char *startupPolicy = NULL;
     g_autofree char *source_path = NULL;
 
-    if (!disk_node)
+    VIR_UNLESS (disk_node)
         return NULL;
 
     device_type = virXMLPropString(disk_node, "device");
 
-    if (!(STREQ_NULLABLE(device_type, "cdrom") ||
+    VIR_UNLESS ((STREQ_NULLABLE(device_type, "cdrom") ||
           STREQ_NULLABLE(device_type, "floppy"))) {
         vshError(NULL, _("The disk device '%s' is not removable"), target);
         return NULL;
@@ -12611,7 +12611,7 @@ virshUpdateDiskXML(xmlNodePtr disk_node,
     }
 
     if (type == VIRSH_UPDATE_DISK_XML_EJECT) {
-        if (!source) {
+        VIR_UNLESS (source) {
             vshError(NULL, _("The disk device '%s' doesn't have media"), target);
             return NULL;
         }
@@ -12673,12 +12673,12 @@ virshUpdateDiskXML(xmlNodePtr disk_node,
          * so it's more easily readable.  And don't make it fatal.
          */
         if ((tmp = xmlCopyNode(text_node, 0))) {
-            if (!xmlAddPrevSibling(target_node, tmp))
+            VIR_UNLESS (xmlAddPrevSibling(target_node, tmp))
                 xmlFreeNode(tmp);
         }
     }
 
-    if (!(ret = virXMLNodeToString(NULL, disk_node))) {
+    VIR_UNLESS ((ret = virXMLNodeToString(NULL, disk_node))) {
         vshSaveLibvirtError();
         return NULL;
     }
@@ -12745,7 +12745,7 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "target", &target) < 0)
@@ -12756,17 +12756,17 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
     else
         doc = virDomainGetXMLDesc(dom, 0);
 
-    if (!doc)
+    VIR_UNLESS (doc)
         goto cleanup;
 
     if (persistent &&
         virDomainIsActive(dom) == 1)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(disk_node = virshFindDisk(doc, target, VIRSH_FIND_DISK_NORMAL)))
+    VIR_UNLESS ((disk_node = virshFindDisk(doc, target, VIRSH_FIND_DISK_NORMAL)))
         goto cleanup;
 
-    if (!(disk_xml = virXMLNodeToString(NULL, disk_node))) {
+    VIR_UNLESS ((disk_xml = virXMLNodeToString(NULL, disk_node))) {
         vshSaveLibvirtError();
         goto cleanup;
     }
@@ -12987,7 +12987,7 @@ cmdChangeMedia(vshControl *ctl, const vshCmd *cmd)
     if (force)
         flags |= VIR_DOMAIN_DEVICE_MODIFY_FORCE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0)
@@ -12997,13 +12997,13 @@ cmdChangeMedia(vshControl *ctl, const vshCmd *cmd)
         doc = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_INACTIVE);
     else
         doc = virDomainGetXMLDesc(dom, 0);
-    if (!doc)
+    VIR_UNLESS (doc)
         goto cleanup;
 
-    if (!(disk_node = virshFindDisk(doc, path, VIRSH_FIND_DISK_CHANGEABLE)))
+    VIR_UNLESS ((disk_node = virshFindDisk(doc, path, VIRSH_FIND_DISK_CHANGEABLE)))
         goto cleanup;
 
-    if (!(disk_xml = virshUpdateDiskXML(disk_node, source, block, path,
+    VIR_UNLESS ((disk_xml = virshUpdateDiskXML(disk_node, source, block, path,
                                         update_type)))
         goto cleanup;
 
@@ -13057,7 +13057,7 @@ cmdDomFSTrim(vshControl *ctl, const vshCmd *cmd)
     const char *mountPoint = NULL;
     unsigned int flags = 0;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptULongLong(ctl, cmd, "minimum", &minimum) < 0)
@@ -13102,7 +13102,7 @@ cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd)
     size_t nmountpoints = 0;
     int count = 0;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
@@ -13147,7 +13147,7 @@ cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd)
     size_t nmountpoints = 0;
     int count = 0;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
@@ -13190,7 +13190,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd)
     size_t ninfos = 0;
     bool ret = false;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     rc = virDomainGetFSInfo(dom, &info, 0);
@@ -13208,7 +13208,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd)
 
     if (info) {
         table = vshTableNew(_("Mountpoint"), _("Name"), _("Type"), _("Target"), NULL);
-        if (!table)
+        VIR_UNLESS (table)
             goto cleanup;
 
         for (i = 0; i < ninfos; i++) {
@@ -13274,7 +13274,7 @@ cmdGuestAgentTimeout(vshControl *ctl, const vshCmd *cmd)
     int timeout = VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK;
     const unsigned int flags = 0;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptInt(ctl, cmd, "timeout", &timeout) < 0)
@@ -13358,7 +13358,7 @@ cmdGuestInfo(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "interface"))
         types |= VIR_DOMAIN_GUEST_INFO_INTERFACES;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (virDomainGetGuestInfo(dom, types, &params, &nparams, 0) < 0)
@@ -13410,7 +13410,7 @@ cmdGetUserSSHKeys(vshControl *ctl, const vshCmd *cmd)
     size_t i;
     const unsigned int flags = 0;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "user", &user) < 0)
@@ -13479,7 +13479,7 @@ cmdSetUserSSHKeys(vshControl *ctl, const vshCmd *cmd)
     VSH_REQUIRE_OPTION("remove", "file");
     VSH_EXCLUSIVE_OPTIONS("reset", "remove");
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "user", &user) < 0)
@@ -13491,10 +13491,10 @@ cmdSetUserSSHKeys(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "remove")) {
         flags |= VIR_DOMAIN_AUTHORIZED_SSH_KEYS_SET_REMOVE;
     } else {
-        if (!vshCommandOptBool(cmd, "reset")) {
+        VIR_UNLESS (vshCommandOptBool(cmd, "reset")) {
             flags |= VIR_DOMAIN_AUTHORIZED_SSH_KEYS_SET_APPEND;
 
-            if (!from) {
+            VIR_UNLESS (from) {
                 vshError(ctl, _("Option --file is required"));
                 return false;
             }
@@ -13507,7 +13507,7 @@ cmdSetUserSSHKeys(vshControl *ctl, const vshCmd *cmd)
             return false;
         }
 
-        if (!(keys = g_strsplit(buffer, "\n", -1)))
+        VIR_UNLESS ((keys = g_strsplit(buffer, "\n", -1)))
             return false;
 
         nkeys = g_strv_length(keys);
@@ -13572,7 +13572,7 @@ cmdDomDirtyRateCalc(vshControl *ctl, const vshCmd *cmd)
     const char *modestr = NULL;
     unsigned int flags = 0;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptInt(ctl, cmd, "seconds", &seconds) < 0)
diff --git a/tools/virsh-edit.c b/tools/virsh-edit.c
index 5dc1a1fe5a..9bb053ea16 100644
--- a/tools/virsh-edit.c
+++ b/tools/virsh-edit.c
@@ -64,12 +64,12 @@ do {
 
     /* Get the XML configuration of the object. */
     doc = (EDIT_GET_XML);
-    if (!doc)
+    VIR_UNLESS (doc)
         goto edit_cleanup;
 
     /* Create and open the temporary file. */
     tmp = vshEditWriteToTempFile(ctl, doc);
-    if (!tmp)
+    VIR_UNLESS (tmp)
         goto edit_cleanup;
 
  reedit:
@@ -85,7 +85,7 @@ do {
     /* Read back the edited file. */
     VIR_FREE(doc_edited);
     doc_edited = vshEditReadBackFile(ctl, tmp);
-    if (!doc_edited)
+    VIR_UNLESS (doc_edited)
         goto edit_cleanup;
 
     /* Compare original XML with edited.  Has it changed at all? */
@@ -101,7 +101,7 @@ do {
      */
     VIR_FREE(doc_reread);
     doc_reread = (EDIT_GET_XML);
-    if (!doc_reread)
+    VIR_UNLESS (doc_reread)
         goto edit_cleanup;
 
     if (STRNEQ(doc, doc_reread)) {
@@ -157,7 +157,7 @@ do {
         VIR_FREE(tmp);
     }
 
-    if (!edit_success)
+    VIR_UNLESS (edit_success)
         goto cleanup;
 
 } while (0);
diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index 1e83d19fa1..c537db1516 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -113,7 +113,7 @@ cmdDomCapabilities(vshControl *ctl, const vshCmd *cmd)
 
     caps = virConnectGetDomainCapabilities(priv->conn, emulatorbin,
                                            arch, machine, virttype, flags);
-    if (!caps) {
+    VIR_UNLESS (caps) {
         vshError(ctl, "%s", _("failed to get emulator capabilities"));
         return false;
     }
@@ -170,7 +170,7 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
     if (cellno && vshCommandOptInt(ctl, cmd, "cellno", &cell) < 0)
         return false;
 
-    if (!all) {
+    VIR_UNLESS (all) {
         if (cellno) {
             if (virNodeGetCellsFreeMemory(priv->conn, &memory, cell, 1) != 1)
                 return false;
@@ -186,12 +186,12 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
         return true;
     }
 
-    if (!(cap_xml = virConnectGetCapabilities(priv->conn))) {
+    VIR_UNLESS ((cap_xml = virConnectGetCapabilities(priv->conn))) {
         vshError(ctl, "%s", _("unable to get node capabilities"));
         return false;
     }
 
-    if (!virXMLParseStringCtxt(cap_xml, _("(capabilities)"), &ctxt)) {
+    VIR_UNLESS (virXMLParseStringCtxt(cap_xml, _("(capabilities)"), &ctxt)) {
         vshError(ctl, "%s", _("unable to get node capabilities"));
         return false;
     }
@@ -304,17 +304,17 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd)
     kibibytes = VIR_DIV_UP(bytes, 1024);
 
     if (all) {
-        if (!(cap_xml = virConnectGetCapabilities(priv->conn))) {
+        VIR_UNLESS ((cap_xml = virConnectGetCapabilities(priv->conn))) {
             vshError(ctl, "%s", _("unable to get node capabilities"));
             goto cleanup;
         }
 
-        if (!(doc = virXMLParseStringCtxt(cap_xml, _("capabilities"), &ctxt))) {
+        VIR_UNLESS ((doc = virXMLParseStringCtxt(cap_xml, _("capabilities"), &ctxt))) {
             vshError(ctl, "%s", _("unable to parse node capabilities"));
             goto cleanup;
         }
 
-        if (!pagesz) {
+        VIR_UNLESS (pagesz) {
             nodes_cnt = virXPathNodeSet("/capabilities/host/cpu/pages", ctxt, &nodes);
 
             if (nodes_cnt <= 0) {
@@ -387,7 +387,7 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd)
         }
 
     } else {
-        if (!cellno) {
+        VIR_UNLESS (cellno) {
             vshError(ctl, "%s", _("missing cellno argument"));
             goto cleanup;
         }
@@ -401,7 +401,7 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd)
             goto cleanup;
         }
 
-        if (!pagesz) {
+        VIR_UNLESS (pagesz) {
             vshError(ctl, "%s", _("missing pagesize argument"));
             goto cleanup;
         }
@@ -501,13 +501,13 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd)
         unsigned long nodes_cnt;
         size_t i;
 
-        if (!(cap_xml = virConnectGetCapabilities(priv->conn))) {
+        VIR_UNLESS ((cap_xml = virConnectGetCapabilities(priv->conn))) {
             vshError(ctl, "%s", _("unable to get node capabilities"));
             return false;
         }
 
         xml = virXMLParseStringCtxt(cap_xml, _("(capabilities)"), &ctxt);
-        if (!xml) {
+        VIR_UNLESS (xml) {
             vshError(ctl, "%s", _("unable to get node capabilities"));
             return false;
         }
@@ -579,7 +579,7 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd)
 
     if ((caps = virConnectGetDomainCapabilities(priv->conn, NULL, NULL, NULL,
                                                 type, 0))) {
-        if (!(xml = virXMLParseStringCtxt(caps, _("(domainCapabilities)"), &ctxt)))
+        VIR_UNLESS ((xml = virXMLParseStringCtxt(caps, _("(domainCapabilities)"), &ctxt)))
             return false;
 
         ignore_value(virXPathInt("string(./vcpu[1]/@max)", ctxt, &vcpus));
@@ -675,7 +675,7 @@ cmdNodeCpuMap(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     if (pretty) {
         g_autofree char *str = virBitmapDataFormat(cpumap, VIR_CPU_MAPLEN(cpunum));
 
-        if (!str)
+        VIR_UNLESS (str)
             return false;
         vshPrint(ctl, "%s", str);
     } else {
@@ -796,7 +796,7 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
         sleep(1);
     }
 
-    if (!flag_percent) {
+    VIR_UNLESS (flag_percent) {
         for (i = 0; i < VIRSH_CPU_USAGE; i++) {
             if (present[i]) {
                 vshPrint(ctl, "%-15s %20llu\n", _(virshCPUOutput[i]),
@@ -1119,7 +1119,7 @@ vshExtractCPUDefXMLs(vshControl *ctl,
 
     xmlStr = g_strdup_printf("<container>%s</container>", doc);
 
-    if (!(xml = virXMLParseStringCtxt(xmlStr, xmlFile, &ctxt)))
+    VIR_UNLESS ((xml = virXMLParseStringCtxt(xmlStr, xmlFile, &ctxt)))
         return NULL;
 
     n = virXPathNodeSet("/container/cpu|"
@@ -1155,7 +1155,7 @@ vshExtractCPUDefXMLs(vshControl *ctl,
             }
         }
 
-        if (!(cpus[i] = virXMLNodeToString(xml, nodes[i]))) {
+        VIR_UNLESS ((cpus[i] = virXMLNodeToString(xml, nodes[i]))) {
             vshSaveLibvirtError();
             return NULL;
         }
@@ -1209,7 +1209,7 @@ cmdCPUCompare(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
         return false;
 
-    if (!(cpus = vshExtractCPUDefXMLs(ctl, from)))
+    VIR_UNLESS ((cpus = vshExtractCPUDefXMLs(ctl, from)))
         return false;
 
     result = virConnectCompareCPU(priv->conn, cpus[0], flags);
@@ -1283,10 +1283,10 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
         return false;
 
-    if (!(list = vshExtractCPUDefXMLs(ctl, from)))
+    VIR_UNLESS ((list = vshExtractCPUDefXMLs(ctl, from)))
         return false;
 
-    if (!(result = virConnectBaselineCPU(priv->conn, (const char **)list,
+    VIR_UNLESS ((result = virConnectBaselineCPU(priv->conn, (const char **)list,
                                          g_strv_length(list), flags)))
         return false;
 
@@ -1629,7 +1629,7 @@ cmdHypervisorCPUCompare(vshControl *ctl,
         vshCommandOptStringReq(ctl, cmd, "machine", &machine) < 0)
         return false;
 
-    if (!(cpus = vshExtractCPUDefXMLs(ctl, from)))
+    VIR_UNLESS ((cpus = vshExtractCPUDefXMLs(ctl, from)))
         return false;
 
     result = virConnectCompareHypervisorCPU(priv->conn, emulator, arch,
@@ -1738,7 +1738,7 @@ cmdHypervisorCPUBaseline(vshControl *ctl,
         vshCommandOptStringReq(ctl, cmd, "machine", &machine) < 0)
         return false;
 
-    if (!(list = vshExtractCPUDefXMLs(ctl, from)))
+    VIR_UNLESS ((list = vshExtractCPUDefXMLs(ctl, from)))
         return false;
 
     result = virConnectBaselineHypervisorCPU(priv->conn, emulator, arch,
diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c
index 55d3532c55..2d65425a0d 100644
--- a/tools/virsh-interface.c
+++ b/tools/virsh-interface.c
@@ -54,7 +54,7 @@ virshCommandOptInterfaceBy(vshControl *ctl, const vshCmd *cmd,
 
     virCheckFlags(VIRSH_BYNAME | VIRSH_BYMAC, NULL);
 
-    if (!optname)
+    VIR_UNLESS (optname)
        optname = "interface";
 
     if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0)
@@ -82,7 +82,7 @@ virshCommandOptInterfaceBy(vshControl *ctl, const vshCmd *cmd,
         iface = virInterfaceLookupByMACString(priv->conn, n);
     }
 
-    if (!iface)
+    VIR_UNLESS (iface)
         vshError(ctl, _("failed to get interface '%s'"), n);
 
     return iface;
@@ -149,7 +149,7 @@ virshInterfaceSorter(const void *a, const void *b)
     if (*ia && !*ib)
         return -1;
 
-    if (!*ia)
+    VIR_UNLESS (*ia)
         return *ib != NULL;
 
     return vshStrcasecmp(virInterfaceGetName(*ia),
@@ -260,7 +260,7 @@ virshInterfaceListCollect(vshControl *ctl,
 
     /* get active interfaces */
     for (i = 0; i < nActiveIfaces; i++) {
-        if (!(iface = virInterfaceLookupByName(priv->conn, activeNames[i]))) {
+        VIR_UNLESS ((iface = virInterfaceLookupByName(priv->conn, activeNames[i]))) {
             vshResetLibvirtError();
             continue;
         }
@@ -269,7 +269,7 @@ virshInterfaceListCollect(vshControl *ctl,
 
     /* get inactive interfaces */
     for (i = 0; i < nInactiveIfaces; i++) {
-        if (!(iface = virInterfaceLookupByName(priv->conn, inactiveNames[i]))) {
+        VIR_UNLESS ((iface = virInterfaceLookupByName(priv->conn, inactiveNames[i]))) {
             vshResetLibvirtError();
             continue;
         }
@@ -301,7 +301,7 @@ virshInterfaceListCollect(vshControl *ctl,
     VIR_FREE(activeNames);
     VIR_FREE(inactiveNames);
 
-    if (!success) {
+    VIR_UNLESS (success) {
         g_clear_pointer(&list, virshInterfaceListFree);
     }
 
@@ -352,11 +352,11 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
         flags = VIR_CONNECT_LIST_INTERFACES_INACTIVE |
                 VIR_CONNECT_LIST_INTERFACES_ACTIVE;
 
-    if (!(list = virshInterfaceListCollect(ctl, flags)))
+    VIR_UNLESS ((list = virshInterfaceListCollect(ctl, flags)))
         return false;
 
     table = vshTableNew(_("Name"), _("State"), _("MAC Address"), NULL);
-    if (!table)
+    VIR_UNLESS (table)
         goto cleanup;
 
     for (i = 0; i < list->nifaces; i++) {
@@ -407,7 +407,7 @@ cmdInterfaceName(vshControl *ctl, const vshCmd *cmd)
 {
     g_autoptr(virshInterface) iface = NULL;
 
-    if (!(iface = virshCommandOptInterfaceBy(ctl, cmd, NULL, NULL,
+    VIR_UNLESS ((iface = virshCommandOptInterfaceBy(ctl, cmd, NULL, NULL,
                                              VIRSH_BYMAC)))
         return false;
 
@@ -443,7 +443,7 @@ cmdInterfaceMAC(vshControl *ctl, const vshCmd *cmd)
 {
     g_autoptr(virshInterface) iface = NULL;
 
-    if (!(iface = virshCommandOptInterfaceBy(ctl, cmd, NULL, NULL,
+    VIR_UNLESS ((iface = virshCommandOptInterfaceBy(ctl, cmd, NULL, NULL,
                                              VIRSH_BYNAME)))
         return false;
 
@@ -483,10 +483,10 @@ cmdInterfaceDumpXML(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "inactive"))
         flags |= VIR_INTERFACE_XML_INACTIVE;
 
-    if (!(iface = virshCommandOptInterface(ctl, cmd, NULL)))
+    VIR_UNLESS ((iface = virshCommandOptInterface(ctl, cmd, NULL)))
         return false;
 
-    if (!(dump = virInterfaceGetXMLDesc(iface, flags)))
+    VIR_UNLESS ((dump = virInterfaceGetXMLDesc(iface, flags)))
         return false;
 
     vshPrint(ctl, "%s", dump);
@@ -534,7 +534,7 @@ cmdInterfaceDefine(vshControl *ctl, const vshCmd *cmd)
     if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
         return false;
 
-    if (!(iface = virInterfaceDefineXML(priv->conn, buffer, flags))) {
+    VIR_UNLESS ((iface = virInterfaceDefineXML(priv->conn, buffer, flags))) {
         vshError(ctl, _("Failed to define interface from %s"), from);
         return false;
     }
@@ -568,7 +568,7 @@ cmdInterfaceUndefine(vshControl *ctl, const vshCmd *cmd)
     g_autoptr(virshInterface) iface = NULL;
     const char *name;
 
-    if (!(iface = virshCommandOptInterface(ctl, cmd, &name)))
+    VIR_UNLESS ((iface = virshCommandOptInterface(ctl, cmd, &name)))
         return false;
 
     if (virInterfaceUndefine(iface) < 0) {
@@ -604,7 +604,7 @@ cmdInterfaceStart(vshControl *ctl, const vshCmd *cmd)
     g_autoptr(virshInterface) iface = NULL;
     const char *name;
 
-    if (!(iface = virshCommandOptInterface(ctl, cmd, &name)))
+    VIR_UNLESS ((iface = virshCommandOptInterface(ctl, cmd, &name)))
         return false;
 
     if (virInterfaceCreate(iface, 0) < 0) {
@@ -640,7 +640,7 @@ cmdInterfaceDestroy(vshControl *ctl, const vshCmd *cmd)
     g_autoptr(virshInterface) iface = NULL;
     const char *name;
 
-    if (!(iface = virshCommandOptInterface(ctl, cmd, &name)))
+    VIR_UNLESS ((iface = virshCommandOptInterface(ctl, cmd, &name)))
         return false;
 
     if (virInterfaceDestroy(iface, 0) < 0) {
@@ -806,7 +806,7 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd)
     virshControl *priv = ctl->privData;
 
     /* Get a handle to the original device */
-    if (!(if_handle = virshCommandOptInterfaceBy(ctl, cmd, "interface",
+    VIR_UNLESS ((if_handle = virshCommandOptInterfaceBy(ctl, cmd, "interface",
                                                  &if_name, VIRSH_BYNAME))) {
         goto cleanup;
     }
@@ -830,9 +830,9 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd)
     nostart = vshCommandOptBool(cmd, "no-start");
 
     /* Get the original interface into an xmlDoc */
-    if (!(if_xml = virInterfaceGetXMLDesc(if_handle, VIR_INTERFACE_XML_INACTIVE)))
+    VIR_UNLESS ((if_xml = virInterfaceGetXMLDesc(if_handle, VIR_INTERFACE_XML_INACTIVE)))
         goto cleanup;
-    if (!(xml_doc = virXMLParseStringCtxt(if_xml,
+    VIR_UNLESS ((xml_doc = virXMLParseStringCtxt(if_xml,
                                           _("(interface definition)"), &ctxt))) {
         vshError(ctl, _("Failed to parse configuration of %s"), if_name);
         goto cleanup;
@@ -840,7 +840,7 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd)
     top_node = ctxt->node;
 
     /* Verify that the original device isn't already a bridge. */
-    if (!(if_type = virXMLPropString(top_node, "type"))) {
+    VIR_UNLESS ((if_type = virXMLPropString(top_node, "type"))) {
         vshError(ctl, _("Existing device %s has no type"), if_name);
         goto cleanup;
     }
@@ -859,7 +859,7 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd)
     }
 
     /* Create a <bridge> node under <interface>. */
-    if (!(br_node = xmlNewChild(top_node, NULL, BAD_CAST "bridge", NULL))) {
+    VIR_UNLESS ((br_node = xmlNewChild(top_node, NULL, BAD_CAST "bridge", NULL))) {
         vshError(ctl, "%s", _("Failed to create bridge node in xml document"));
         goto cleanup;
     }
@@ -867,14 +867,14 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd)
     /* Set stp and delay attributes in <bridge> according to the
      * commandline options.
      */
-    if (!xmlSetProp(br_node, BAD_CAST "stp", BAD_CAST(stp ? "on" : "off"))) {
+    VIR_UNLESS (xmlSetProp(br_node, BAD_CAST "stp", BAD_CAST(stp ? "on" : "off"))) {
         vshError(ctl, "%s", _("Failed to set stp attribute in xml document"));
         goto cleanup;
     }
 
     if (stp) {
         delay_str = g_strdup_printf("%d", delay);
-        if (!xmlSetProp(br_node, BAD_CAST "delay", BAD_CAST delay_str)) {
+        VIR_UNLESS (xmlSetProp(br_node, BAD_CAST "delay", BAD_CAST delay_str)) {
             vshError(ctl, _("Failed to set bridge delay %d in xml document"), delay);
             goto cleanup;
         }
@@ -883,12 +883,12 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd)
     /* Change the type of the outer/master interface to "bridge" and the
      * name to the provided bridge name.
      */
-    if (!xmlSetProp(top_node, BAD_CAST "type", BAD_CAST "bridge")) {
+    VIR_UNLESS (xmlSetProp(top_node, BAD_CAST "type", BAD_CAST "bridge")) {
         vshError(ctl, "%s", _("Failed to set bridge interface type to 'bridge' in xml document"));
         goto cleanup;
     }
 
-    if (!xmlSetProp(top_node, BAD_CAST "name", BAD_CAST br_name)) {
+    VIR_UNLESS (xmlSetProp(top_node, BAD_CAST "name", BAD_CAST br_name)) {
         vshError(ctl, _("Failed to set master bridge interface name to '%s' in xml document"),
             br_name);
         goto cleanup;
@@ -897,7 +897,7 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd)
     /* Create an <interface> node under <bridge> that uses the
      * original interface's type and name.
      */
-    if (!(if_node = xmlNewChild(br_node, NULL, BAD_CAST "interface", NULL))) {
+    VIR_UNLESS ((if_node = xmlNewChild(br_node, NULL, BAD_CAST "interface", NULL))) {
         vshError(ctl, "%s", _("Failed to create interface node under bridge node in xml document"));
         goto cleanup;
     }
@@ -905,13 +905,13 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd)
     /* set the type of the attached interface to the original
      * if_type, and the name to the original if_name.
      */
-    if (!xmlSetProp(if_node, BAD_CAST "type", BAD_CAST if_type)) {
+    VIR_UNLESS (xmlSetProp(if_node, BAD_CAST "type", BAD_CAST if_type)) {
         vshError(ctl, _("Failed to set new attached interface type to '%s' in xml document"),
                  if_type);
         goto cleanup;
     }
 
-    if (!xmlSetProp(if_node, BAD_CAST "name", BAD_CAST if_name)) {
+    VIR_UNLESS (xmlSetProp(if_node, BAD_CAST "name", BAD_CAST if_name)) {
         vshError(ctl, _("Failed to set new attached interface name to '%s' in xml document"),
                  if_name);
         goto cleanup;
@@ -931,7 +931,7 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd)
              virXMLNodeNameEqual(old, "bond") || /* bond stuff to move down */
              virXMLNodeNameEqual(old, "vlan"))) { /* vlan stuff to move down */
             xmlUnlinkNode(old);
-            if (!xmlAddChild(if_node, old)) {
+            VIR_UNLESS (xmlAddChild(if_node, old)) {
                 vshError(ctl, _("Failed to move '%s' element in xml document"), old->name);
                 xmlFreeNode(old);
                 goto cleanup;
@@ -951,7 +951,7 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd)
     /* br_xml is the new interface to define. It will automatically undefine the
      * independent original interface.
      */
-    if (!(br_handle = virInterfaceDefineXML(priv->conn, (char *) br_xml, 0))) {
+    VIR_UNLESS ((br_handle = virInterfaceDefineXML(priv->conn, (char *) br_xml, 0))) {
         vshError(ctl, _("Failed to define new bridge interface %s"),
                  br_name);
         goto cleanup;
@@ -961,7 +961,7 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd)
                   br_name, if_name);
 
     /* start it up unless requested not to */
-    if (!nostart) {
+    VIR_UNLESS (nostart) {
         if (virInterfaceCreate(br_handle, 0) < 0) {
             vshError(ctl, _("Failed to start bridge interface %s"), br_name);
             goto cleanup;
@@ -1023,7 +1023,7 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd)
     virshControl *priv = ctl->privData;
 
     /* Get a handle to the original device */
-    if (!(br_handle = virshCommandOptInterfaceBy(ctl, cmd, "bridge",
+    VIR_UNLESS ((br_handle = virshCommandOptInterfaceBy(ctl, cmd, "bridge",
                                                  &br_name, VIRSH_BYNAME))) {
         goto cleanup;
     }
@@ -1031,9 +1031,9 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd)
     nostart = vshCommandOptBool(cmd, "no-start");
 
     /* Get the bridge xml into an xmlDoc */
-    if (!(br_xml = virInterfaceGetXMLDesc(br_handle, VIR_INTERFACE_XML_INACTIVE)))
+    VIR_UNLESS ((br_xml = virInterfaceGetXMLDesc(br_handle, VIR_INTERFACE_XML_INACTIVE)))
         goto cleanup;
-    if (!(xml_doc = virXMLParseStringCtxt(br_xml,
+    VIR_UNLESS ((xml_doc = virXMLParseStringCtxt(br_xml,
                                           _("(bridge interface definition)"),
                                           &ctxt))) {
         vshError(ctl, _("Failed to parse configuration of %s"), br_name);
@@ -1042,7 +1042,7 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd)
     top_node = ctxt->node;
 
     /* Verify that the device really is a bridge. */
-    if (!(if_type = virXMLPropString(top_node, "type"))) {
+    VIR_UNLESS ((if_type = virXMLPropString(top_node, "type"))) {
         vshError(ctl, _("Existing device %s has no type"), br_name);
         goto cleanup;
     }
@@ -1054,7 +1054,7 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd)
     VIR_FREE(if_type);
 
     /* verify the name in the XML matches the device name */
-    if (!(if_name = virXMLPropString(top_node, "name")) ||
+    VIR_UNLESS ((if_name = virXMLPropString(top_node, "name")) ||
         STRNEQ(if_name, br_name)) {
         vshError(ctl, _("Interface name from config %s doesn't match given supplied name %s"),
                  if_name, br_name);
@@ -1073,7 +1073,7 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
     }
 
-    if (!(if_node = virXPathNode("./bridge/interface", ctxt))) {
+    VIR_UNLESS ((if_node = virXPathNode("./bridge/interface", ctxt))) {
         vshError(ctl, "%s", _("No interface attached to bridge"));
         goto cleanup;
     }
@@ -1081,23 +1081,23 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd)
     /* Change the type and name of the bridge interface to
      * the type/name of the attached interface.
      */
-    if (!(if_name = virXMLPropString(if_node, "name"))) {
+    VIR_UNLESS ((if_name = virXMLPropString(if_node, "name"))) {
         vshError(ctl, _("Device attached to bridge %s has no name"), br_name);
         goto cleanup;
     }
 
-    if (!(if_type = virXMLPropString(if_node, "type"))) {
+    VIR_UNLESS ((if_type = virXMLPropString(if_node, "type"))) {
         vshError(ctl, _("Attached device %s has no type"), if_name);
         goto cleanup;
     }
 
-    if (!xmlSetProp(top_node, BAD_CAST "type", BAD_CAST if_type)) {
+    VIR_UNLESS (xmlSetProp(top_node, BAD_CAST "type", BAD_CAST if_type)) {
         vshError(ctl, _("Failed to set interface type to '%s' in xml document"),
                  if_type);
         goto cleanup;
     }
 
-    if (!xmlSetProp(top_node, BAD_CAST "name", BAD_CAST if_name)) {
+    VIR_UNLESS (xmlSetProp(top_node, BAD_CAST "name", BAD_CAST if_name)) {
         vshError(ctl, _("Failed to set interface name to '%s' in xml document"),
                  if_name);
         goto cleanup;
@@ -1117,7 +1117,7 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd)
              virXMLNodeNameEqual(old, "bond") || /* bond stuff to move down */
              virXMLNodeNameEqual(old, "vlan"))) { /* vlan stuff to move down */
             xmlUnlinkNode(old);
-            if (!xmlAddChild(top_node, old)) {
+            VIR_UNLESS (xmlAddChild(top_node, old)) {
                 vshError(ctl, _("Failed to move '%s' element in xml document"), old->name);
                 xmlFreeNode(old);
                 goto cleanup;
@@ -1148,7 +1148,7 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd)
 
     /* if_xml is the new interface to define.
      */
-    if (!(if_handle = virInterfaceDefineXML(priv->conn, (char *) if_xml, 0))) {
+    VIR_UNLESS ((if_handle = virInterfaceDefineXML(priv->conn, (char *) if_xml, 0))) {
         vshError(ctl, _("Failed to define new interface %s"), if_name);
         goto cleanup;
     }
@@ -1157,7 +1157,7 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd)
                   if_name, br_name);
 
     /* unless requested otherwise, undefine the bridge device */
-    if (!nostart) {
+    VIR_UNLESS (nostart) {
         if (virInterfaceCreate(if_handle, 0) < 0) {
             vshError(ctl, _("Failed to start interface %s"), if_name);
             goto cleanup;
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 97a160f772..a87c7b599e 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -96,7 +96,7 @@ virshCommandOptNetworkBy(vshControl *ctl, const vshCmd *cmd,
         network = virNetworkLookupByName(priv->conn, n);
     }
 
-    if (!network)
+    VIR_UNLESS (network)
         vshError(ctl, _("failed to get network '%s'"), n);
 
     return network;
@@ -125,7 +125,7 @@ virshCommandOptNetworkPort(vshControl *ctl, const vshCmd *cmd,
              cmd->def->name, optname);
     port = virNetworkPortLookupByUUIDString(net, n);
 
-    if (!port)
+    VIR_UNLESS (port)
         vshError(ctl, _("failed to get network port '%s'"), n);
 
     return port;
@@ -160,7 +160,7 @@ cmdNetworkAutostart(vshControl *ctl, const vshCmd *cmd)
     const char *name;
     int autostart;
 
-    if (!(network = virshCommandOptNetwork(ctl, cmd, &name)))
+    VIR_UNLESS ((network = virshCommandOptNetwork(ctl, cmd, &name)))
         return false;
 
     autostart = !vshCommandOptBool(cmd, "disable");
@@ -226,7 +226,7 @@ cmdNetworkCreate(vshControl *ctl, const vshCmd *cmd)
     else
         network = virNetworkCreateXML(priv->conn, buffer);
 
-    if (!network) {
+    VIR_UNLESS (network) {
         vshError(ctl, _("Failed to create network from %s"), from);
         return false;
     }
@@ -282,7 +282,7 @@ cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd)
     else
         network = virNetworkDefineXML(priv->conn, buffer);
 
-    if (!network) {
+    VIR_UNLESS (network) {
         vshError(ctl, _("Failed to define network from %s"), from);
         return false;
     }
@@ -317,7 +317,7 @@ cmdNetworkDestroy(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name;
 
-    if (!(network = virshCommandOptNetwork(ctl, cmd, &name)))
+    VIR_UNLESS ((network = virshCommandOptNetwork(ctl, cmd, &name)))
         return false;
 
     if (virNetworkDestroy(network) == 0) {
@@ -359,13 +359,13 @@ cmdNetworkDumpXML(vshControl *ctl, const vshCmd *cmd)
     g_autofree char *dump = NULL;
     unsigned int flags = 0;
 
-    if (!(network = virshCommandOptNetwork(ctl, cmd, NULL)))
+    VIR_UNLESS ((network = virshCommandOptNetwork(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptBool(cmd, "inactive"))
         flags |= VIR_NETWORK_XML_INACTIVE;
 
-    if (!(dump = virNetworkGetXMLDesc(network, flags))) {
+    VIR_UNLESS ((dump = virNetworkGetXMLDesc(network, flags))) {
         return false;
     }
 
@@ -401,7 +401,7 @@ cmdNetworkInfo(vshControl *ctl, const vshCmd *cmd)
     int active = -1;
     char *bridge = NULL;
 
-    if (!(network = virshCommandOptNetwork(ctl, cmd, NULL)))
+    VIR_UNLESS ((network = virshCommandOptNetwork(ctl, cmd, NULL)))
         return false;
 
     vshPrint(ctl, "%-15s %s\n", _("Name:"), virNetworkGetName(network));
@@ -441,7 +441,7 @@ virshNetworkSorter(const void *a, const void *b)
     if (*na && !*nb)
         return -1;
 
-    if (!*na)
+    VIR_UNLESS (*na)
         return *nb != NULL;
 
     return vshStrcasecmp(virNetworkGetName(*na),
@@ -570,14 +570,14 @@ virshNetworkListCollect(vshControl *ctl,
 
     /* get active networks */
     for (i = 0; i < nActiveNets; i++) {
-        if (!(net = virNetworkLookupByName(priv->conn, names[i])))
+        VIR_UNLESS ((net = virNetworkLookupByName(priv->conn, names[i])))
             continue;
         list->nets[list->nnets++] = net;
     }
 
     /* get inactive networks */
     for (i = 0; i < nInactiveNets; i++) {
-        if (!(net = virNetworkLookupByName(priv->conn, names[i])))
+        VIR_UNLESS ((net = virNetworkLookupByName(priv->conn, names[i])))
             continue;
         list->nets[list->nnets++] = net;
     }
@@ -639,7 +639,7 @@ virshNetworkListCollect(vshControl *ctl,
         VIR_FREE(names[i]);
     VIR_FREE(names);
 
-    if (!success) {
+    VIR_UNLESS (success) {
         g_clear_pointer(&list, virshNetworkListFree);
     }
 
@@ -738,13 +738,13 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     if (!optUUID && !optName)
         optTable = true;
 
-    if (!(list = virshNetworkListCollect(ctl, flags)))
+    VIR_UNLESS ((list = virshNetworkListCollect(ctl, flags)))
         return false;
 
     if (optTable) {
         table = vshTableNew(_("Name"), _("State"), _("Autostart"),
                             _("Persistent"), NULL);
-        if (!table)
+        VIR_UNLESS (table)
             goto cleanup;
     }
 
@@ -817,7 +817,7 @@ cmdNetworkName(vshControl *ctl, const vshCmd *cmd)
 {
     g_autoptr(virshNetwork) network = NULL;
 
-    if (!(network = virshCommandOptNetworkBy(ctl, cmd, NULL,
+    VIR_UNLESS ((network = virshCommandOptNetworkBy(ctl, cmd, NULL,
                                              VIRSH_BYUUID)))
         return false;
 
@@ -850,7 +850,7 @@ cmdNetworkStart(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name = NULL;
 
-    if (!(network = virshCommandOptNetwork(ctl, cmd, &name)))
+    VIR_UNLESS ((network = virshCommandOptNetwork(ctl, cmd, &name)))
          return false;
 
     if (virNetworkCreate(network) == 0) {
@@ -887,7 +887,7 @@ cmdNetworkUndefine(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name;
 
-    if (!(network = virshCommandOptNetwork(ctl, cmd, &name)))
+    VIR_UNLESS ((network = virshCommandOptNetwork(ctl, cmd, &name)))
         return false;
 
     if (virNetworkUndefine(network) == 0) {
@@ -972,7 +972,7 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd)
     VSH_EXCLUSIVE_OPTIONS("current", "live");
     VSH_EXCLUSIVE_OPTIONS("current", "config");
 
-    if (!(network = virshCommandOptNetwork(ctl, cmd, NULL)))
+    VIR_UNLESS ((network = virshCommandOptNetwork(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "command", &commandStr) < 0)
@@ -1085,7 +1085,7 @@ cmdNetworkUuid(vshControl *ctl, const vshCmd *cmd)
     g_autoptr(virshNetwork) network = NULL;
     char uuid[VIR_UUID_STRING_BUFLEN];
 
-    if (!(network = virshCommandOptNetworkBy(ctl, cmd, NULL,
+    VIR_UNLESS ((network = virshCommandOptNetworkBy(ctl, cmd, NULL,
                                              VIRSH_BYNAME)))
         return false;
 
@@ -1224,7 +1224,7 @@ vshEventLifecyclePrint(virConnectPtr conn G_GNUC_UNUSED,
     }
 
     data->count++;
-    if (!data->loop)
+    VIR_UNLESS (data->loop)
         vshEventDone(data->ctl);
 }
 
@@ -1292,7 +1292,7 @@ cmdNetworkEvent(vshControl *ctl, const vshCmd *cmd)
 
     if (vshCommandOptStringReq(ctl, cmd, "event", &eventName) < 0)
         return false;
-    if (!eventName) {
+    VIR_UNLESS (eventName) {
         vshError(ctl, "%s", _("either --list or --event <type> is required"));
         return false;
     }
@@ -1379,7 +1379,7 @@ virshNetworkDHCPLeaseSorter(const void *a, const void *b)
     if (*lease1 && !*lease2)
         return -1;
 
-    if (!*lease1)
+    VIR_UNLESS (*lease1)
         return *lease2 != NULL;
 
     return vshStrcasecmp((*lease1)->mac, (*lease2)->mac);
@@ -1401,7 +1401,7 @@ cmdNetworkDHCPLeases(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "mac", &mac) < 0)
         return false;
 
-    if (!(network = virshCommandOptNetwork(ctl, cmd, &name)))
+    VIR_UNLESS ((network = virshCommandOptNetwork(ctl, cmd, &name)))
         return false;
 
     if ((nleases = virNetworkGetDHCPLeases(network, mac, &leases, flags)) < 0) {
@@ -1415,7 +1415,7 @@ cmdNetworkDHCPLeases(vshControl *ctl, const vshCmd *cmd)
     table = vshTableNew(_("Expiry Time"), _("MAC address"), _("Protocol"),
                         _("IP address"), _("Hostname"), _("Client ID or DUID"),
                         NULL);
-    if (!table)
+    VIR_UNLESS (table)
         goto cleanup;
 
     for (i = 0; i < nleases; i++) {
@@ -1554,10 +1554,10 @@ cmdNetworkPortDumpXML(vshControl *ctl, const vshCmd *cmd)
     g_autofree char *dump = NULL;
     unsigned int flags = 0;
 
-    if (!(network = virshCommandOptNetwork(ctl, cmd, NULL)))
+    VIR_UNLESS ((network = virshCommandOptNetwork(ctl, cmd, NULL)))
         goto cleanup;
 
-    if (!(port = virshCommandOptNetworkPort(ctl, cmd, network, NULL)))
+    VIR_UNLESS ((port = virshCommandOptNetworkPort(ctl, cmd, network, NULL)))
         goto cleanup;
 
     dump = virNetworkPortGetXMLDesc(port, flags);
@@ -1602,10 +1602,10 @@ cmdNetworkPortDelete(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     char uuidstr[VIR_UUID_STRING_BUFLEN];
 
-    if (!(network = virshCommandOptNetwork(ctl, cmd, NULL)))
+    VIR_UNLESS ((network = virshCommandOptNetwork(ctl, cmd, NULL)))
         goto cleanup;
 
-    if (!(port = virshCommandOptNetworkPort(ctl, cmd, network, NULL)))
+    VIR_UNLESS ((port = virshCommandOptNetworkPort(ctl, cmd, network, NULL)))
         goto cleanup;
 
     if (virNetworkPortGetUUIDString(port, uuidstr) < 0)
@@ -1637,7 +1637,7 @@ virshNetworkPortSorter(const void *a, const void *b)
     if (*na && !*nb)
         return -1;
 
-    if (!*na)
+    VIR_UNLESS (*na)
         return *nb != NULL;
 
     if (virNetworkPortGetUUID(*na, uuida) < 0 ||
@@ -1677,7 +1677,7 @@ virshNetworkPortListCollect(vshControl *ctl,
     g_autoptr(virshNetwork) network = NULL;
     bool success = false;
 
-    if (!(network = virshCommandOptNetwork(ctl, cmd, NULL)))
+    VIR_UNLESS ((network = virshCommandOptNetwork(ctl, cmd, NULL)))
         goto cleanup;
 
     if ((ret = virNetworkListAllPorts(network,
@@ -1695,7 +1695,7 @@ virshNetworkPortListCollect(vshControl *ctl,
     success = true;
 
  cleanup:
-    if (!success) {
+    VIR_UNLESS (success) {
         g_clear_pointer(&list, virshNetworkPortListFree);
     }
 
@@ -1747,15 +1747,15 @@ cmdNetworkPortList(vshControl *ctl, const vshCmd *cmd)
         return false;
     }
 
-    if (!optUUID)
+    VIR_UNLESS (optUUID)
         optTable = true;
 
-    if (!(list = virshNetworkPortListCollect(ctl, cmd, flags)))
+    VIR_UNLESS ((list = virshNetworkPortListCollect(ctl, cmd, flags)))
         return false;
 
     if (optTable) {
         table = vshTableNew(_("UUID"), NULL);
-        if (!table)
+        VIR_UNLESS (table)
             goto cleanup;
     }
 
diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
index d01bdf699c..68e293339f 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -67,7 +67,7 @@ cmdNodeDeviceCreate(vshControl *ctl, const vshCmd *cmd)
     if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
         return false;
 
-    if (!(dev = virNodeDeviceCreateXML(priv->conn, buffer, 0))) {
+    VIR_UNLESS ((dev = virNodeDeviceCreateXML(priv->conn, buffer, 0))) {
         vshError(ctl, _("Failed to create node device from %s"), from);
         return false;
     }
@@ -129,7 +129,7 @@ vshFindNodeDevice(vshControl *ctl, const char *value)
         dev = virNodeDeviceLookupByName(priv->conn, value);
     }
 
-    if (!dev) {
+    VIR_UNLESS (dev) {
         vshError(ctl, "%s '%s'", _("Could not find matching device"), value);
         return NULL;
     }
@@ -147,7 +147,7 @@ cmdNodeDeviceDestroy(vshControl *ctl, const vshCmd *cmd)
         return false;
 
     dev = vshFindNodeDevice(ctl, device_value);
-    if (!dev)
+    VIR_UNLESS (dev)
         return false;
 
     if (virNodeDeviceDestroy(dev) == 0) {
@@ -183,7 +183,7 @@ virshNodeDeviceSorter(const void *a, const void *b)
     if (*na && !*nb)
         return -1;
 
-    if (!*na)
+    VIR_UNLESS (*na)
         return *nb != NULL;
 
     return vshStrcasecmp(virNodeDeviceGetName(*na),
@@ -268,7 +268,7 @@ virshNodeDeviceListCollect(vshControl *ctl,
 
     /* get the node devices */
     for (i = 0; i < ndevices; i++) {
-        if (!(device = virNodeDeviceLookupByName(priv->conn, names[i])))
+        VIR_UNLESS ((device = virNodeDeviceLookupByName(priv->conn, names[i])))
             continue;
         list->devices[list->ndevices++] = device;
     }
@@ -276,7 +276,7 @@ virshNodeDeviceListCollect(vshControl *ctl,
     /* truncate domains that weren't found */
     deleted = ndevices - list->ndevices;
 
-    if (!capnames)
+    VIR_UNLESS (capnames)
         goto finished;
 
     /* filter the list if the list was acquired by fallback means */
@@ -313,7 +313,7 @@ virshNodeDeviceListCollect(vshControl *ctl,
             }
         }
 
-        if (!match)
+        VIR_UNLESS (match)
             goto remove_entry;
 
         /* the device matched all filters, it may stay */
@@ -342,7 +342,7 @@ virshNodeDeviceListCollect(vshControl *ctl,
         VIR_FREE(names[i]);
     VIR_FREE(names);
 
-    if (!success) {
+    VIR_UNLESS (success) {
         g_clear_pointer(&list, virshNodeDeviceListFree);
     }
 
@@ -496,10 +496,10 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
 
     if (inactive || all)
         flags |= VIR_CONNECT_LIST_NODE_DEVICES_INACTIVE;
-    if (!inactive)
+    VIR_UNLESS (inactive)
         flags |= VIR_CONNECT_LIST_NODE_DEVICES_ACTIVE;
 
-    if (!(list = virshNodeDeviceListCollect(ctl, caps, ncaps, flags))) {
+    VIR_UNLESS ((list = virshNodeDeviceListCollect(ctl, caps, ncaps, flags))) {
         ret = false;
         goto cleanup;
     }
@@ -580,10 +580,10 @@ cmdNodeDeviceDumpXML(vshControl *ctl, const vshCmd *cmd)
 
     device = vshFindNodeDevice(ctl, device_value);
 
-    if (!device)
+    VIR_UNLESS (device)
         return false;
 
-    if (!(xml = virNodeDeviceGetXMLDesc(device, 0)))
+    VIR_UNLESS ((xml = virNodeDeviceGetXMLDesc(device, 0)))
         return false;
 
     vshPrint(ctl, "%s\n", xml);
@@ -632,7 +632,7 @@ cmdNodeDeviceDetach(vshControl *ctl, const vshCmd *cmd)
 
     ignore_value(vshCommandOptStringQuiet(ctl, cmd, "driver", &driverName));
 
-    if (!(device = virNodeDeviceLookupByName(priv->conn, name))) {
+    VIR_UNLESS ((device = virNodeDeviceLookupByName(priv->conn, name))) {
         vshError(ctl, _("Could not find matching device '%s'"), name);
         return false;
     }
@@ -691,7 +691,7 @@ cmdNodeDeviceReAttach(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "device", &name) < 0)
         return false;
 
-    if (!(device = virNodeDeviceLookupByName(priv->conn, name))) {
+    VIR_UNLESS ((device = virNodeDeviceLookupByName(priv->conn, name))) {
         vshError(ctl, _("Could not find matching device '%s'"), name);
         return false;
     }
@@ -741,7 +741,7 @@ cmdNodeDeviceReset(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "device", &name) < 0)
         return false;
 
-    if (!(device = virNodeDeviceLookupByName(priv->conn, name))) {
+    VIR_UNLESS ((device = virNodeDeviceLookupByName(priv->conn, name))) {
         vshError(ctl, _("Could not find matching device '%s'"), name);
         return false;
     }
@@ -810,7 +810,7 @@ vshEventLifecyclePrint(virConnectPtr conn G_GNUC_UNUSED,
     }
 
     data->count++;
-    if (!data->loop)
+    VIR_UNLESS (data->loop)
         vshEventDone(data->ctl);
 }
 
@@ -841,7 +841,7 @@ vshEventGenericPrint(virConnectPtr conn G_GNUC_UNUSED,
     }
 
     data->count++;
-    if (!data->loop)
+    VIR_UNLESS (data->loop)
         vshEventDone(data->ctl);
 }
 
@@ -916,7 +916,7 @@ cmdNodeDeviceEvent(vshControl *ctl, const vshCmd *cmd)
 
     if (vshCommandOptStringReq(ctl, cmd, "event", &eventName) < 0)
         return false;
-    if (!eventName) {
+    VIR_UNLESS (eventName) {
         vshError(ctl, "%s", _("either --list or --event <type> is required"));
         return false;
     }
@@ -940,7 +940,7 @@ cmdNodeDeviceEvent(vshControl *ctl, const vshCmd *cmd)
         return false;
 
     if (device_value) {
-        if (!(dev = virNodeDeviceLookupByName(priv->conn, device_value))) {
+        VIR_UNLESS ((dev = virNodeDeviceLookupByName(priv->conn, device_value))) {
             vshError(ctl, "%s '%s'",
                      _("Could not find matching device"), device_value);
             goto cleanup;
@@ -1012,7 +1012,7 @@ cmdNodeDeviceUndefine(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
 
     dev = vshFindNodeDevice(ctl, device_value);
 
-    if (!dev)
+    VIR_UNLESS (dev)
         return false;
 
     if (virNodeDeviceUndefine(dev, 0) < 0) {
@@ -1060,7 +1060,7 @@ cmdNodeDeviceDefine(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
         return false;
 
-    if (!(dev = virNodeDeviceDefineXML(priv->conn, buffer, 0))) {
+    VIR_UNLESS ((dev = virNodeDeviceDefineXML(priv->conn, buffer, 0))) {
         vshError(ctl, _("Failed to define node device from '%s'"), from);
         return false;
     }
@@ -1105,7 +1105,7 @@ cmdNodeDeviceStart(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "device", &name) < 0)
         return false;
 
-    if (!(device = virNodeDeviceLookupByName(priv->conn, name))) {
+    VIR_UNLESS ((device = virNodeDeviceLookupByName(priv->conn, name))) {
         vshError(ctl, _("Could not find matching device '%s'"), name);
         return false;
     }
@@ -1160,7 +1160,7 @@ cmdNodeDeviceAutostart(vshControl *ctl, const vshCmd *cmd)
 
     dev = vshFindNodeDevice(ctl, name);
 
-    if (!dev)
+    VIR_UNLESS (dev)
         return false;
 
     autostart = !vshCommandOptBool(cmd, "disable");
@@ -1219,7 +1219,7 @@ cmdNodeDeviceInfo(vshControl *ctl, const vshCmd *cmd)
 
     device = vshFindNodeDevice(ctl, device_value);
 
-    if (!device)
+    VIR_UNLESS (device)
         return false;
 
     parent = virNodeDeviceGetParent(device);
diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c
index 5a9e57e3f5..e260a1c28d 100644
--- a/tools/virsh-nwfilter.c
+++ b/tools/virsh-nwfilter.c
@@ -60,7 +60,7 @@ virshCommandOptNWFilterBy(vshControl *ctl, const vshCmd *cmd,
         nwfilter = virNWFilterLookupByName(priv->conn, n);
     }
 
-    if (!nwfilter)
+    VIR_UNLESS (nwfilter)
         vshError(ctl, _("failed to get nwfilter '%s'"), n);
 
     return nwfilter;
@@ -153,7 +153,7 @@ cmdNWFilterUndefine(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name;
 
-    if (!(nwfilter = virshCommandOptNWFilter(ctl, cmd, &name)))
+    VIR_UNLESS ((nwfilter = virshCommandOptNWFilter(ctl, cmd, &name)))
         return false;
 
     if (virNWFilterUndefine(nwfilter) == 0) {
@@ -196,7 +196,7 @@ cmdNWFilterDumpXML(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     g_autofree char *dump = NULL;
 
-    if (!(nwfilter = virshCommandOptNWFilter(ctl, cmd, NULL)))
+    VIR_UNLESS ((nwfilter = virshCommandOptNWFilter(ctl, cmd, NULL)))
         return false;
 
     dump = virNWFilterGetXMLDesc(nwfilter, 0);
@@ -218,7 +218,7 @@ virshNWFilterSorter(const void *a, const void *b)
     if (*fa && !*fb)
         return -1;
 
-    if (!*fa)
+    VIR_UNLESS (*fa)
         return *fb != NULL;
 
     return vshStrcasecmp(virNWFilterGetName(*fa),
@@ -303,7 +303,7 @@ virshNWFilterListCollect(vshControl *ctl,
 
     /* get the network filters */
     for (i = 0; i < nfilters; i++) {
-        if (!(filter = virNWFilterLookupByName(priv->conn, names[i])))
+        VIR_UNLESS ((filter = virNWFilterLookupByName(priv->conn, names[i])))
             continue;
         list->filters[list->nfilters++] = filter;
     }
@@ -328,7 +328,7 @@ virshNWFilterListCollect(vshControl *ctl,
         VIR_FREE(names[i]);
     VIR_FREE(names);
 
-    if (!success) {
+    VIR_UNLESS (success) {
         g_clear_pointer(&list, virshNWFilterListFree);
     }
 
@@ -361,11 +361,11 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     struct virshNWFilterList *list = NULL;
     g_autoptr(vshTable) table = NULL;
 
-    if (!(list = virshNWFilterListCollect(ctl, 0)))
+    VIR_UNLESS ((list = virshNWFilterListCollect(ctl, 0)))
         return false;
 
     table = vshTableNew(_("UUID"), _("Name"), NULL);
-    if (!table)
+    VIR_UNLESS (table)
         goto cleanup;
 
     for (i = 0; i < list->nfilters; i++) {
@@ -471,7 +471,7 @@ virshCommandOptNWFilterBindingBy(vshControl *ctl,
              cmd->def->name, optname);
     binding = virNWFilterBindingLookupByPortDev(priv->conn, n);
 
-    if (!binding)
+    VIR_UNLESS (binding)
         vshError(ctl, _("failed to get nwfilter binding '%s'"), n);
 
     return binding;
@@ -522,7 +522,7 @@ cmdNWFilterBindingCreate(vshControl *ctl, const vshCmd *cmd)
     binding = virNWFilterBindingCreateXML(priv->conn, buffer, flags);
     VIR_FREE(buffer);
 
-    if (!binding) {
+    VIR_UNLESS (binding) {
         vshError(ctl, _("Failed to create network filter from %s"), from);
         return false;
     }
@@ -564,7 +564,7 @@ cmdNWFilterBindingDelete(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *portdev;
 
-    if (!(binding = virshCommandOptNWFilterBinding(ctl, cmd, &portdev)))
+    VIR_UNLESS ((binding = virshCommandOptNWFilterBinding(ctl, cmd, &portdev)))
         return false;
 
     if (virNWFilterBindingDelete(binding) == 0) {
@@ -609,7 +609,7 @@ cmdNWFilterBindingDumpXML(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     g_autofree char *dump = NULL;
 
-    if (!(binding = virshCommandOptNWFilterBinding(ctl, cmd, NULL)))
+    VIR_UNLESS ((binding = virshCommandOptNWFilterBinding(ctl, cmd, NULL)))
         return false;
 
     dump = virNWFilterBindingGetXMLDesc(binding, 0);
@@ -633,7 +633,7 @@ virshNWFilterBindingSorter(const void *a, const void *b)
     if (*fa && !*fb)
         return -1;
 
-    if (!*fa)
+    VIR_UNLESS (*fa)
         return *fb != NULL;
 
     return vshStrcasecmp(virNWFilterBindingGetPortDev(*fa),
@@ -690,7 +690,7 @@ virshNWFilterBindingListCollect(vshControl *ctl,
     success = true;
 
  cleanup:
-    if (!success) {
+    VIR_UNLESS (success) {
         g_clear_pointer(&list, virshNWFilterBindingListFree);
     }
 
@@ -723,11 +723,11 @@ cmdNWFilterBindingList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     struct virshNWFilterBindingList *list = NULL;
     g_autoptr(vshTable) table = NULL;
 
-    if (!(list = virshNWFilterBindingListCollect(ctl, 0)))
+    VIR_UNLESS ((list = virshNWFilterBindingListCollect(ctl, 0)))
         return false;
 
     table = vshTableNew(_("Port Dev"), _("Filter"), NULL);
-    if (!table)
+    VIR_UNLESS (table)
         goto cleanup;
 
     for (i = 0; i < list->nbindings; i++) {
diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
index 7e7a8d511f..4026f9beb3 100644
--- a/tools/virsh-pool.c
+++ b/tools/virsh-pool.c
@@ -188,7 +188,7 @@ virshCommandOptPoolBy(vshControl *ctl, const vshCmd *cmd, const char *optname,
         pool = virStoragePoolLookupByName(priv->conn, n);
     }
 
-    if (!pool)
+    VIR_UNLESS (pool)
         vshError(ctl, _("failed to get pool '%s'"), n);
 
     return pool;
@@ -224,7 +224,7 @@ cmdPoolAutostart(vshControl *ctl, const vshCmd *cmd)
     const char *name;
     int autostart;
 
-    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", &name)))
+    VIR_UNLESS ((pool = virshCommandOptPool(ctl, cmd, "pool", &name)))
         return false;
 
     autostart = !vshCommandOptBool(cmd, "disable");
@@ -299,7 +299,7 @@ cmdPoolCreate(vshControl *ctl, const vshCmd *cmd)
     if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
         return false;
 
-    if (!(pool = virStoragePoolCreateXML(priv->conn, buffer, flags))) {
+    VIR_UNLESS ((pool = virStoragePoolCreateXML(priv->conn, buffer, flags))) {
         vshError(ctl, _("Failed to create pool from %s"), from);
         return false;
     }
@@ -484,7 +484,7 @@ cmdPoolCreateAs(vshControl *ctl, const vshCmd *cmd)
     if (no_overwrite)
         flags |= VIR_STORAGE_POOL_CREATE_WITH_BUILD_NO_OVERWRITE;
 
-    if (!virshBuildPoolXML(ctl, cmd, &name, &xml))
+    VIR_UNLESS (virshBuildPoolXML(ctl, cmd, &name, &xml))
         return false;
 
     if (printXML) {
@@ -492,7 +492,7 @@ cmdPoolCreateAs(vshControl *ctl, const vshCmd *cmd)
         return true;
     }
 
-    if (!(pool = virStoragePoolCreateXML(priv->conn, xml, flags))) {
+    VIR_UNLESS ((pool = virStoragePoolCreateXML(priv->conn, xml, flags))) {
         vshError(ctl, _("Failed to create pool %s"), name);
         return false;
     }
@@ -542,7 +542,7 @@ cmdPoolDefine(vshControl *ctl, const vshCmd *cmd)
     if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
         return false;
 
-    if (!(pool = virStoragePoolDefineXML(priv->conn, buffer, flags))) {
+    VIR_UNLESS ((pool = virStoragePoolDefineXML(priv->conn, buffer, flags))) {
         vshError(ctl, _("Failed to define pool from %s"), from);
         return false;
     }
@@ -574,7 +574,7 @@ cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd)
     bool printXML = vshCommandOptBool(cmd, "print-xml");
     virshControl *priv = ctl->privData;
 
-    if (!virshBuildPoolXML(ctl, cmd, &name, &xml))
+    VIR_UNLESS (virshBuildPoolXML(ctl, cmd, &name, &xml))
         return false;
 
     if (printXML) {
@@ -582,7 +582,7 @@ cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd)
         return true;
     }
 
-    if (!(pool = virStoragePoolDefineXML(priv->conn, xml, 0))) {
+    VIR_UNLESS ((pool = virStoragePoolDefineXML(priv->conn, xml, 0))) {
         vshError(ctl, _("Failed to define pool %s"), name);
         return false;
     }
@@ -620,7 +620,7 @@ cmdPoolBuild(vshControl *ctl, const vshCmd *cmd)
     const char *name;
     unsigned int flags = 0;
 
-    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", &name)))
+    VIR_UNLESS ((pool = virshCommandOptPool(ctl, cmd, "pool", &name)))
         return false;
 
     if (vshCommandOptBool(cmd, "no-overwrite"))
@@ -665,7 +665,7 @@ cmdPoolDestroy(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name;
 
-    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", &name)))
+    VIR_UNLESS ((pool = virshCommandOptPool(ctl, cmd, "pool", &name)))
         return false;
 
     if (virStoragePoolDestroy(pool) == 0) {
@@ -704,7 +704,7 @@ cmdPoolDelete(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name;
 
-    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", &name)))
+    VIR_UNLESS ((pool = virshCommandOptPool(ctl, cmd, "pool", &name)))
         return false;
 
     if (virStoragePoolDelete(pool, 0) == 0) {
@@ -743,7 +743,7 @@ cmdPoolRefresh(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name;
 
-    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", &name)))
+    VIR_UNLESS ((pool = virshCommandOptPool(ctl, cmd, "pool", &name)))
         return false;
 
     if (virStoragePoolRefresh(pool, 0) == 0) {
@@ -791,7 +791,7 @@ cmdPoolDumpXML(vshControl *ctl, const vshCmd *cmd)
     if (inactive)
         flags |= VIR_STORAGE_XML_INACTIVE;
 
-    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
+    VIR_UNLESS ((pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
         return false;
 
     dump = virStoragePoolGetXMLDesc(pool, flags);
@@ -813,7 +813,7 @@ virshStoragePoolSorter(const void *a, const void *b)
     if (*pa && !*pb)
         return -1;
 
-    if (!*pa)
+    VIR_UNLESS (*pa)
         return *pb != NULL;
 
     return vshStrcasecmp(virStoragePoolGetName(*pa),
@@ -942,14 +942,14 @@ virshStoragePoolListCollect(vshControl *ctl,
 
     /* get active pools */
     for (i = 0; i < nActivePools; i++) {
-        if (!(pool = virStoragePoolLookupByName(priv->conn, names[i])))
+        VIR_UNLESS ((pool = virStoragePoolLookupByName(priv->conn, names[i])))
             continue;
         list->pools[list->npools++] = pool;
     }
 
     /* get inactive pools */
     for (i = 0; i < nInactivePools; i++) {
-        if (!(pool = virStoragePoolLookupByName(priv->conn, names[i])))
+        VIR_UNLESS ((pool = virStoragePoolLookupByName(priv->conn, names[i])))
             continue;
         list->pools[list->npools++] = pool;
     }
@@ -1011,7 +1011,7 @@ virshStoragePoolListCollect(vshControl *ctl,
     for (i = 0; i < nAllPools; i++)
         VIR_FREE(names[i]);
 
-    if (!success) {
+    VIR_UNLESS (success) {
         g_clear_pointer(&list, virshStoragePoolListFree);
     }
 
@@ -1218,7 +1218,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
         }
     }
 
-    if (!(list = virshStoragePoolListCollect(ctl, flags)))
+    VIR_UNLESS ((list = virshStoragePoolListCollect(ctl, flags)))
         goto cleanup;
 
     poolInfoTexts = g_new0(struct poolInfoText, list->npools);
@@ -1301,7 +1301,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
      */
 
     /* Output basic info then return if --details option not selected */
-    if (!details) {
+    VIR_UNLESS (details) {
         if (uuid || name) {
             for (i = 0; i < list->npools; i++) {
                 if (uuid) {
@@ -1321,7 +1321,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
 
         /* Output old style header */
         table = vshTableNew(_("Name"), _("State"), _("Autostart"), NULL);
-        if (!table)
+        VIR_UNLESS (table)
             goto cleanup;
 
         /* Output old style pool info */
@@ -1347,7 +1347,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     /* Insert the header into table */
     table = vshTableNew(_("Name"), _("State"), _("Autostart"), _("Persistent"),
                         _("Capacity"), _("Allocation"), _("Available"), NULL);
-    if (!table)
+    VIR_UNLESS (table)
         goto cleanup;
 
     /* Insert the pool info rows into table */
@@ -1562,7 +1562,7 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd)
     bool bytes = false;
     char uuid[VIR_UUID_STRING_BUFLEN];
 
-    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
+    VIR_UNLESS ((pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
         return false;
 
     bytes = vshCommandOptBool(cmd, "bytes");
@@ -1643,7 +1643,7 @@ cmdPoolName(vshControl *ctl, const vshCmd *cmd)
 {
     g_autoptr(virshStoragePool) pool = NULL;
 
-    if (!(pool = virshCommandOptPoolBy(ctl, cmd, "pool", NULL, VIRSH_BYUUID)))
+    VIR_UNLESS ((pool = virshCommandOptPoolBy(ctl, cmd, "pool", NULL, VIRSH_BYUUID)))
         return false;
 
     vshPrint(ctl, "%s\n", virStoragePoolGetName(pool));
@@ -1683,7 +1683,7 @@ cmdPoolStart(vshControl *ctl, const vshCmd *cmd)
     bool no_overwrite;
     unsigned int flags = 0;
 
-    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", &name)))
+    VIR_UNLESS ((pool = virshCommandOptPool(ctl, cmd, "pool", &name)))
          return false;
 
     build = vshCommandOptBool(cmd, "build");
@@ -1736,7 +1736,7 @@ cmdPoolUndefine(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name;
 
-    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", &name)))
+    VIR_UNLESS ((pool = virshCommandOptPool(ctl, cmd, "pool", &name)))
         return false;
 
     if (virStoragePoolUndefine(pool) == 0) {
@@ -1774,7 +1774,7 @@ cmdPoolUuid(vshControl *ctl, const vshCmd *cmd)
     g_autoptr(virshStoragePool) pool = NULL;
     char uuid[VIR_UUID_STRING_BUFLEN];
 
-    if (!(pool = virshCommandOptPoolBy(ctl, cmd, "pool", NULL, VIRSH_BYNAME)))
+    VIR_UNLESS ((pool = virshCommandOptPoolBy(ctl, cmd, "pool", NULL, VIRSH_BYNAME)))
         return false;
 
     if (virStoragePoolGetUUIDString(pool, uuid) != -1)
@@ -1819,7 +1819,7 @@ cmdPoolEdit(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
 
     /* Some old daemons don't support _INACTIVE flag */
-    if (!(tmp_desc = virStoragePoolGetXMLDesc(pool, flags))) {
+    VIR_UNLESS ((tmp_desc = virStoragePoolGetXMLDesc(pool, flags))) {
         if (last_error->code == VIR_ERR_INVALID_ARG) {
             flags &= ~VIR_STORAGE_XML_INACTIVE;
             vshResetLibvirtError();
@@ -1908,7 +1908,7 @@ vshEventLifecyclePrint(virConnectPtr conn G_GNUC_UNUSED,
     }
 
     data->count++;
-    if (!data->loop)
+    VIR_UNLESS (data->loop)
         vshEventDone(data->ctl);
 }
 
@@ -1939,7 +1939,7 @@ vshEventGenericPrint(virConnectPtr conn G_GNUC_UNUSED,
     }
 
     data->count++;
-    if (!data->loop)
+    VIR_UNLESS (data->loop)
         vshEventDone(data->ctl);
 }
 
@@ -2013,7 +2013,7 @@ cmdPoolEvent(vshControl *ctl, const vshCmd *cmd)
 
     if (vshCommandOptStringReq(ctl, cmd, "event", &eventName) < 0)
         return false;
-    if (!eventName) {
+    VIR_UNLESS (eventName) {
         vshError(ctl, "%s", _("either --list or --event <type> is required"));
         return false;
     }
@@ -2094,7 +2094,7 @@ cmdPoolCapabilities(vshControl *ctl,
     g_autofree char *caps = NULL;
 
     caps = virConnectGetStoragePoolCapabilities(priv->conn, flags);
-    if (!caps) {
+    VIR_UNLESS (caps) {
         vshError(ctl, "%s", _("failed to get storage pool capabilities"));
         return false;
     }
diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c
index 842647cb17..0347a2e894 100644
--- a/tools/virsh-secret.c
+++ b/tools/virsh-secret.c
@@ -100,7 +100,7 @@ cmdSecretDefine(vshControl *ctl, const vshCmd *cmd)
     if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
         return false;
 
-    if (!(res = virSecretDefineXML(priv->conn, buffer, flags))) {
+    VIR_UNLESS ((res = virSecretDefineXML(priv->conn, buffer, flags))) {
         vshError(ctl, _("Failed to set attributes from %s"), from);
         goto cleanup;
     }
@@ -223,7 +223,7 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd)
     VSH_EXCLUSIVE_OPTIONS("interactive", "plain");
     VSH_EXCLUSIVE_OPTIONS("interactive", "file");
 
-    if (!(secret = virshCommandOptSecret(ctl, cmd, NULL)))
+    VIR_UNLESS ((secret = virshCommandOptSecret(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "base64", &base64) < 0)
@@ -249,7 +249,7 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd)
         vshPrint(ctl, "%s", _("Enter new value for secret:"));
         fflush(stdout);
 
-        if (!(secret_val = virGetPassword())) {
+        VIR_UNLESS ((secret_val = virGetPassword())) {
             vshError(ctl, "%s", _("Failed to read secret"));
             return false;
         }
@@ -260,7 +260,7 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd)
         return false;
     }
 
-    if (!plain) {
+    VIR_UNLESS (plain) {
         g_autofree char *tmp = g_steal_pointer(&secret_val);
         size_t tmp_len = secret_len;
 
@@ -314,10 +314,10 @@ cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd)
     size_t value_size;
     bool plain = vshCommandOptBool(cmd, "plain");
 
-    if (!(secret = virshCommandOptSecret(ctl, cmd, NULL)))
+    VIR_UNLESS ((secret = virshCommandOptSecret(ctl, cmd, NULL)))
         return false;
 
-    if (!(value = virSecretGetValue(secret, &value_size, 0)))
+    VIR_UNLESS ((value = virSecretGetValue(secret, &value_size, 0)))
         return false;
 
     if (plain) {
@@ -394,7 +394,7 @@ virshSecretSorter(const void *a, const void *b)
     if (*sa && !*sb)
         return -1;
 
-    if (!*sa)
+    VIR_UNLESS (*sa)
         return *sb != NULL;
 
     virSecretGetUUIDString(*sa, uuid_sa);
@@ -484,7 +484,7 @@ virshSecretListCollect(vshControl *ctl,
 
     /* get the secrets */
     for (i = 0; i < nsecrets; i++) {
-        if (!(secret = virSecretLookupByUUIDString(priv->conn, uuids[i])))
+        VIR_UNLESS ((secret = virSecretLookupByUUIDString(priv->conn, uuids[i])))
             continue;
         list->secrets[list->nsecrets++] = secret;
     }
@@ -511,7 +511,7 @@ virshSecretListCollect(vshControl *ctl,
         VIR_FREE(uuids);
     }
 
-    if (!success) {
+    VIR_UNLESS (success) {
         g_clear_pointer(&list, virshSecretListFree);
     }
 
@@ -572,11 +572,11 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     if (vshCommandOptBool(cmd, "no-private"))
         flags |= VIR_CONNECT_LIST_SECRETS_NO_PRIVATE;
 
-    if (!(list = virshSecretListCollect(ctl, flags)))
+    VIR_UNLESS ((list = virshSecretListCollect(ctl, flags)))
         return false;
 
     table = vshTableNew(_("UUID"), _("Usage"), NULL);
-    if (!table)
+    VIR_UNLESS (table)
         goto cleanup;
 
     for (i = 0; i < list->nsecrets; i++) {
@@ -596,7 +596,7 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
             virBufferStrcat(&buf, usageStr, " ",
                             virSecretGetUsageID(sec), NULL);
             usage = virBufferContentAndReset(&buf);
-            if (!usage)
+            VIR_UNLESS (usage)
                 goto cleanup;
 
             if (vshTableRowAppend(table, uuid, usage, NULL) < 0)
@@ -669,7 +669,7 @@ vshEventLifecyclePrint(virConnectPtr conn G_GNUC_UNUSED,
     }
 
     data->count++;
-    if (!data->loop)
+    VIR_UNLESS (data->loop)
         vshEventDone(data->ctl);
 }
 
@@ -703,7 +703,7 @@ vshEventGenericPrint(virConnectPtr conn G_GNUC_UNUSED,
     }
 
     data->count++;
-    if (!data->loop)
+    VIR_UNLESS (data->loop)
         vshEventDone(data->ctl);
 }
 
@@ -776,7 +776,7 @@ cmdSecretEvent(vshControl *ctl, const vshCmd *cmd)
 
     if (vshCommandOptStringReq(ctl, cmd, "event", &eventName) < 0)
         return false;
-    if (!eventName) {
+    VIR_UNLESS (eventName) {
         vshError(ctl, "%s", _("either --list or --event <type> is required"));
         return false;
     }
diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index 7cd76f39e2..3c0294ad68 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -65,7 +65,7 @@ virshSnapshotCreate(vshControl *ctl, virDomainPtr dom, const char *buffer,
             vshReportError(ctl);
             return false;
         }
-        if (!persistent) {
+        VIR_UNLESS (persistent) {
             vshError(ctl, "%s",
                      _("cannot halt after snapshot of transient domain"));
             return false;
@@ -85,7 +85,7 @@ virshSnapshotCreate(vshControl *ctl, virDomainPtr dom, const char *buffer,
     }
 
     name = virDomainSnapshotGetName(snapshot);
-    if (!name) {
+    VIR_UNLESS (name) {
         vshError(ctl, "%s", _("Could not get snapshot name"));
         return false;
     }
@@ -184,12 +184,12 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "validate"))
         flags |= VIR_DOMAIN_SNAPSHOT_CREATE_VALIDATE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "xmlfile", &from) < 0)
         return false;
-    if (!from) {
+    VIR_UNLESS (from) {
         buffer = g_strdup("<domainsnapshot/>");
     } else {
         if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {
@@ -214,7 +214,7 @@ virshParseSnapshotMemspec(vshControl *ctl, virBuffer *buf, const char *str)
     int narray;
     size_t i;
 
-    if (!str)
+    VIR_UNLESS (str)
         return 0;
 
     narray = vshStringToArray(str, &array);
@@ -406,7 +406,7 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "validate"))
         flags |= VIR_DOMAIN_SNAPSHOT_CREATE_VALIDATE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0 ||
@@ -475,7 +475,7 @@ virshLookupSnapshot(vshControl *ctl, const vshCmd *cmd,
         vshError(ctl, _("--%s or --current is required"), arg);
         return -1;
     }
-    if (!*snap) {
+    VIR_UNLESS (*snap) {
         vshReportError(ctl);
         return -1;
     }
@@ -536,7 +536,7 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd)
         vshCommandOptBool(cmd, "snapshotname"))
         define_flags |= VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (virshLookupSnapshot(ctl, cmd, "snapshotname", false, dom,
@@ -548,7 +548,7 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd)
 #define EDIT_NOT_CHANGED \
     do { \
         /* Depending on flags, we re-edit even if XML is unchanged.  */ \
-        if (!(define_flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT)) { \
+        VIR_UNLESS ((define_flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT)) { \
             vshPrintExtra(ctl, \
                           _("Snapshot %s XML configuration not changed.\n"), \
                           name); \
@@ -579,7 +579,7 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd)
                      rename_okay ? name : edited_name);
             goto cleanup;
         }
-        if (!rename_okay) {
+        VIR_UNLESS (rename_okay) {
             vshError(ctl, _("Must use --rename or --clone to change %s to %s"),
                      name, edited_name);
             goto cleanup;
@@ -642,7 +642,7 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd)
 
     VSH_EXCLUSIVE_OPTIONS("name", "snapshotname");
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, &domname)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, &domname)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "snapshotname", &snapshotname) < 0)
@@ -653,18 +653,18 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd)
         flags = (VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE |
                  VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT);
 
-        if (!(snapshot = virDomainSnapshotLookupByName(dom, snapshotname, 0)))
+        VIR_UNLESS ((snapshot = virDomainSnapshotLookupByName(dom, snapshotname, 0)))
             goto cleanup;
 
         xml = virDomainSnapshotGetXMLDesc(snapshot, VIR_DOMAIN_XML_SECURE);
-        if (!xml)
+        VIR_UNLESS (xml)
             goto cleanup;
 
         /* strstr is safe here, since xml came from libvirt API and not user */
         if (strstr(xml, "<state>disk-snapshot</state>"))
             flags |= VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY;
 
-        if (!(snapshot2 = virDomainSnapshotCreateXML(dom, xml, flags)))
+        VIR_UNLESS ((snapshot2 = virDomainSnapshotCreateXML(dom, xml, flags)))
             goto cleanup;
 
         vshPrintExtra(ctl, _("Snapshot %s set as current"), snapshotname);
@@ -675,21 +675,21 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd)
     if ((current = virDomainHasCurrentSnapshot(dom, 0)) < 0)
         goto cleanup;
 
-    if (!current) {
+    VIR_UNLESS (current) {
         vshError(ctl, _("domain '%s' has no current snapshot"), domname);
         goto cleanup;
     } else {
-        if (!(snapshot = virDomainSnapshotCurrent(dom, 0)))
+        VIR_UNLESS ((snapshot = virDomainSnapshotCurrent(dom, 0)))
             goto cleanup;
 
         if (vshCommandOptBool(cmd, "name")) {
             const char *name;
-            if (!(name = virDomainSnapshotGetName(snapshot)))
+            VIR_UNLESS ((name = virDomainSnapshotGetName(snapshot)))
                 goto cleanup;
 
             vshPrint(ctl, "%s", name);
         } else {
-            if (!(xml = virDomainSnapshotGetXMLDesc(snapshot, flags)))
+            VIR_UNLESS ((xml = virDomainSnapshotGetXMLDesc(snapshot, flags)))
                 goto cleanup;
 
             vshPrint(ctl, "%s", xml);
@@ -699,7 +699,7 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd)
     ret = true;
 
  cleanup:
-    if (!ret)
+    VIR_UNLESS (ret)
         vshReportError(ctl);
     return ret;
 }
@@ -722,7 +722,7 @@ virshGetSnapshotParent(vshControl *ctl, virDomainSnapshotPtr snapshot,
     *parent_name = NULL;
 
     /* Try new API, since it is faster. */
-    if (!priv->useSnapshotOld) {
+    VIR_UNLESS (priv->useSnapshotOld) {
         parent = virDomainSnapshotGetParent(snapshot, 0);
         if (parent) {
             /* API works, and virDomainSnapshotGetName will succeed */
@@ -740,11 +740,11 @@ virshGetSnapshotParent(vshControl *ctl, virDomainSnapshotPtr snapshot,
     }
 
     xml = virDomainSnapshotGetXMLDesc(snapshot, 0);
-    if (!xml)
+    VIR_UNLESS (xml)
         goto cleanup;
 
     xmldoc = virXMLParseStringCtxt(xml, _("(domain_snapshot)"), &ctxt);
-    if (!xmldoc)
+    VIR_UNLESS (xmldoc)
         goto cleanup;
 
     *parent_name = virXPathString("string(/domainsnapshot/parent/name)", ctxt);
@@ -773,15 +773,15 @@ virshSnapshotFilter(vshControl *ctl, virDomainSnapshotPtr snapshot,
     g_autoptr(xmlXPathContext) ctxt = NULL;
     g_autofree char *state = NULL;
 
-    if (!snapshot)
+    VIR_UNLESS (snapshot)
         return 1;
 
     xml = virDomainSnapshotGetXMLDesc(snapshot, 0);
-    if (!xml)
+    VIR_UNLESS (xml)
         return -1;
 
     xmldoc = virXMLParseStringCtxt(xml, _("(domain_snapshot)"), &ctxt);
-    if (!xmldoc)
+    VIR_UNLESS (xmldoc)
         return -1;
 
     /* Libvirt 1.0.1 and newer never call this function, because the
@@ -790,7 +790,7 @@ virshSnapshotFilter(vshControl *ctl, virDomainSnapshotPtr snapshot,
      * the types of snapshots it could create: if state was disk-only,
      * the snapshot is external; all other snapshots are internal.  */
     state = virXPathString("string(/domainsnapshot/state)", ctxt);
-    if (!state) {
+    VIR_UNLESS (state) {
         vshError(ctl, "%s", _("unable to perform snapshot filtering"));
         return -1;
     }
@@ -799,7 +799,7 @@ virshSnapshotFilter(vshControl *ctl, virDomainSnapshotPtr snapshot,
                   (flags & VIR_DOMAIN_SNAPSHOT_LIST_EXTERNAL));
     }
 
-    if (!(flags & VIR_DOMAIN_SNAPSHOT_LIST_INTERNAL))
+    VIR_UNLESS ((flags & VIR_DOMAIN_SNAPSHOT_LIST_INTERNAL))
         return 0;
     if (STREQ(state, "shutoff"))
         return !!(flags & VIR_DOMAIN_SNAPSHOT_LIST_INACTIVE);
@@ -872,15 +872,15 @@ cmdSnapshotInfo(vshControl *ctl, const vshCmd *cmd)
     /* Get the XML configuration of the snapshot to determine the
      * state of the machine at the time of the snapshot.  */
     doc = virDomainSnapshotGetXMLDesc(snapshot, 0);
-    if (!doc)
+    VIR_UNLESS (doc)
         return false;
 
     xmldoc = virXMLParseStringCtxt(doc, _("(domain_snapshot)"), &ctxt);
-    if (!xmldoc)
+    VIR_UNLESS (xmldoc)
         return false;
 
     state = virXPathString("string(/domainsnapshot/state)", ctxt);
-    if (!state) {
+    VIR_UNLESS (state) {
         vshError(ctl, "%s",
                  _("unexpected problem reading snapshot xml"));
         return false;
@@ -970,7 +970,7 @@ virshSnapshotListFree(struct virshSnapshotList *snaplist)
 {
     size_t i;
 
-    if (!snaplist)
+    VIR_UNLESS (snaplist)
         return;
     if (snaplist->snaps) {
         for (i = 0; i < snaplist->nsnaps; i++) {
@@ -990,7 +990,7 @@ virshSnapSorter(const void *a, const void *b)
 
     if (sa->snap && !sb->snap)
         return -1;
-    if (!sa->snap)
+    VIR_UNLESS (sa->snap)
         return sb->snap != NULL;
 
     return vshStrcasecmp(virDomainSnapshotGetName(sa->snap),
@@ -1022,7 +1022,7 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPtr dom,
     virshControl *priv = ctl->privData;
 
     /* Try the interface available in 0.9.13 and newer.  */
-    if (!priv->useSnapshotOld) {
+    VIR_UNLESS (priv->useSnapshotOld) {
         if (from)
             count = virDomainSnapshotListAllChildren(from, &snaps, flags);
         else
@@ -1117,7 +1117,7 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPtr dom,
      */
     if (from) {
         fromname = virDomainSnapshotGetName(from);
-        if (!fromname) {
+        VIR_UNLESS (fromname) {
             vshError(ctl, "%s", _("Could not get snapshot name"));
             goto cleanup;
         }
@@ -1156,12 +1156,12 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPtr dom,
     }
 
     if (count < 0) {
-        if (!last_error)
+        VIR_UNLESS (last_error)
             vshError(ctl, _("failed to collect snapshot list"));
         goto cleanup;
     }
 
-    if (!count)
+    VIR_UNLESS (count)
         goto success;
 
     names = g_new0(char *, count);
@@ -1190,7 +1190,7 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPtr dom,
     for (i = 0; i < count; i++) {
         snaplist->snaps[i].snap = virDomainSnapshotLookupByName(dom,
                                                                 names[i], 0);
-        if (!snaplist->snaps[i].snap)
+        VIR_UNLESS (snaplist->snaps[i].snap)
             goto cleanup;
     }
 
@@ -1252,7 +1252,7 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPtr dom,
                 remaining = true;
             }
         }
-        if (!changed) {
+        VIR_UNLESS (changed) {
             ret = g_new0(struct virshSnapshotList, 1);
             goto cleanup;
         }
@@ -1269,14 +1269,14 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPtr dom,
                         continue;
                     if (STREQ(snaplist->snaps[i].parent, names[j])) {
                         found_parent = true;
-                        if (!snaplist->snaps[j].parent)
+                        VIR_UNLESS (snaplist->snaps[j].parent)
                             VIR_FREE(snaplist->snaps[i].parent);
                         else
                             remaining = true;
                         break;
                     }
                 }
-                if (!found_parent) {
+                VIR_UNLESS (found_parent) {
                     changed = true;
                     VIR_FREE(names[i]);
                     g_clear_pointer(&snaplist->snaps[i].snap,
@@ -1311,7 +1311,7 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPtr dom,
             }
         }
     }
-    if (!(orig_flags & VIR_DOMAIN_SNAPSHOT_LIST_TOPOLOGICAL))
+    VIR_UNLESS ((orig_flags & VIR_DOMAIN_SNAPSHOT_LIST_TOPOLOGICAL))
         qsort(snaplist->snaps, snaplist->nsnaps, sizeof(*snaplist->snaps),
               virshSnapSorter);
     snaplist->nsnaps -= deleted;
@@ -1491,14 +1491,14 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
         flags |= VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS;
     }
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if ((from || current) &&
         virshLookupSnapshot(ctl, cmd, "from", true, dom, &start, &from_snap) < 0)
         goto cleanup;
 
-    if (!(snaplist = virshSnapshotListCollect(ctl, dom, start, flags, tree)))
+    VIR_UNLESS ((snaplist = virshSnapshotListCollect(ctl, dom, start, flags, tree)))
         goto cleanup;
 
     if (!tree && !name) {
@@ -1507,7 +1507,7 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
         else
             table = vshTableNew(_("Name"), _("Creation Time"), _("State"), NULL);
 
-        if (!table)
+        VIR_UNLESS (table)
             goto cleanup;
     }
 
@@ -1542,17 +1542,17 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
             continue;
         }
 
-        if (!(doc = virDomainSnapshotGetXMLDesc(snapshot, 0)))
+        VIR_UNLESS ((doc = virDomainSnapshotGetXMLDesc(snapshot, 0)))
             continue;
 
-        if (!(xml = virXMLParseStringCtxt(doc, _("(domain_snapshot)"), &ctxt)))
+        VIR_UNLESS ((xml = virXMLParseStringCtxt(doc, _("(domain_snapshot)"), &ctxt)))
             continue;
 
         if (parent)
             parent_snap = virXPathString("string(/domainsnapshot/parent/name)",
                                          ctxt);
 
-        if (!(state = virXPathString("string(/domainsnapshot/state)", ctxt)))
+        VIR_UNLESS ((state = virXPathString("string(/domainsnapshot/state)", ctxt)))
             continue;
 
         if (virXPathLongLong("string(/domainsnapshot/creationTime)", ctxt,
@@ -1626,13 +1626,13 @@ cmdSnapshotDumpXML(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "snapshotname", &name) < 0)
         return false;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
-    if (!(snapshot = virDomainSnapshotLookupByName(dom, name, 0)))
+    VIR_UNLESS ((snapshot = virDomainSnapshotLookupByName(dom, name, 0)))
         return false;
 
-    if (!(xml = virDomainSnapshotGetXMLDesc(snapshot, flags)))
+    VIR_UNLESS ((xml = virDomainSnapshotGetXMLDesc(snapshot, flags)))
         return false;
 
     vshPrint(ctl, "%s", xml);
@@ -1681,7 +1681,7 @@ cmdSnapshotParent(vshControl *ctl, const vshCmd *cmd)
 
     if (virshGetSnapshotParent(ctl, snapshot, &parent) < 0)
         return false;
-    if (!parent) {
+    VIR_UNLESS (parent) {
         vshError(ctl, _("snapshot '%s' has no parent"), name);
         return false;
     }
diff --git a/tools/virsh-util.c b/tools/virsh-util.c
index dc6ed7a86d..8b6b2501ed 100644
--- a/tools/virsh-util.c
+++ b/tools/virsh-util.c
@@ -63,7 +63,7 @@ virshLookupDomainInternal(vshControl *ctl,
 
     vshResetLibvirtError();
 
-    if (!dom)
+    VIR_UNLESS (dom)
         vshError(ctl, _("failed to get domain '%s'"), name);
 
     return dom;
@@ -122,7 +122,7 @@ virshDomainState(vshControl *ctl,
     if (reason)
         *reason = -1;
 
-    if (!priv->useGetInfo) {
+    VIR_UNLESS (priv->useGetInfo) {
         int state;
         if (virDomainGetState(dom, &state, reason, 0) < 0) {
             if (virGetLastErrorCode() == VIR_ERR_NO_SUPPORT)
@@ -255,7 +255,7 @@ virshStreamInData(virStreamPtr st G_GNUC_UNUSED,
 void
 virshDomainFree(virDomainPtr dom)
 {
-    if (!dom)
+    VIR_UNLESS (dom)
         return;
 
     vshSaveLibvirtHelperError();
@@ -266,7 +266,7 @@ virshDomainFree(virDomainPtr dom)
 void
 virshDomainCheckpointFree(virDomainCheckpointPtr chk)
 {
-    if (!chk)
+    VIR_UNLESS (chk)
         return;
 
     vshSaveLibvirtHelperError();
@@ -277,7 +277,7 @@ virshDomainCheckpointFree(virDomainCheckpointPtr chk)
 void
 virshDomainSnapshotFree(virDomainSnapshotPtr snap)
 {
-    if (!snap)
+    VIR_UNLESS (snap)
         return;
 
     vshSaveLibvirtHelperError();
@@ -288,7 +288,7 @@ virshDomainSnapshotFree(virDomainSnapshotPtr snap)
 void
 virshInterfaceFree(virInterfacePtr iface)
 {
-    if (!iface)
+    VIR_UNLESS (iface)
         return;
 
     vshSaveLibvirtHelperError();
@@ -299,7 +299,7 @@ virshInterfaceFree(virInterfacePtr iface)
 void
 virshNetworkFree(virNetworkPtr network)
 {
-    if (!network)
+    VIR_UNLESS (network)
         return;
 
     vshSaveLibvirtHelperError();
@@ -310,7 +310,7 @@ virshNetworkFree(virNetworkPtr network)
 void
 virshNodeDeviceFree(virNodeDevicePtr device)
 {
-    if (!device)
+    VIR_UNLESS (device)
         return;
 
     vshSaveLibvirtHelperError();
@@ -321,7 +321,7 @@ virshNodeDeviceFree(virNodeDevicePtr device)
 void
 virshNWFilterFree(virNWFilterPtr nwfilter)
 {
-    if (!nwfilter)
+    VIR_UNLESS (nwfilter)
         return;
 
     vshSaveLibvirtHelperError();
@@ -332,7 +332,7 @@ virshNWFilterFree(virNWFilterPtr nwfilter)
 void
 virshSecretFree(virSecretPtr secret)
 {
-    if (!secret)
+    VIR_UNLESS (secret)
         return;
 
     vshSaveLibvirtHelperError();
@@ -343,7 +343,7 @@ virshSecretFree(virSecretPtr secret)
 void
 virshStoragePoolFree(virStoragePoolPtr pool)
 {
-    if (!pool)
+    VIR_UNLESS (pool)
         return;
 
     vshSaveLibvirtHelperError();
@@ -354,7 +354,7 @@ virshStoragePoolFree(virStoragePoolPtr pool)
 void
 virshStorageVolFree(virStorageVolPtr vol)
 {
-    if (!vol)
+    VIR_UNLESS (vol)
         return;
 
     vshSaveLibvirtHelperError();
@@ -366,7 +366,7 @@ virshStorageVolFree(virStorageVolPtr vol)
 void
 virshStreamFree(virStreamPtr stream)
 {
-    if (!stream)
+    VIR_UNLESS (stream)
         return;
 
     vshSaveLibvirtHelperError();
@@ -383,14 +383,14 @@ virshDomainGetXMLFromDom(vshControl *ctl,
 {
     g_autofree char *desc = NULL;
 
-    if (!(desc = virDomainGetXMLDesc(dom, flags))) {
+    VIR_UNLESS ((desc = virDomainGetXMLDesc(dom, flags))) {
         vshError(ctl, _("Failed to get domain description xml"));
         return -1;
     }
 
     *xml = virXMLParseStringCtxt(desc, _("(domain_definition)"), ctxt);
 
-    if (!(*xml)) {
+    VIR_UNLESS ((*xml)) {
         vshError(ctl, _("Failed to parse domain description xml"));
         return -1;
     }
@@ -409,7 +409,7 @@ virshDomainGetXML(vshControl *ctl,
     virDomainPtr dom;
     int ret;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+    VIR_UNLESS ((dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return -1;
 
     ret = virshDomainGetXMLFromDom(ctl, dom, flags, xml, ctxt);
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
index 503acda874..d877944058 100644
--- a/tools/virsh-volume.c
+++ b/tools/virsh-volume.c
@@ -97,7 +97,7 @@ virshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd,
         return NULL;
 
     if (p) {
-        if (!(pool = virshCommandOptPoolBy(ctl, cmd, pooloptname, name, flags)))
+        VIR_UNLESS ((pool = virshCommandOptPoolBy(ctl, cmd, pooloptname, name, flags)))
             return NULL;
 
         if (virStoragePoolIsActive(pool) != 1) {
@@ -131,7 +131,7 @@ virshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd,
         vol = virStorageVolLookupByPath(priv->conn, n);
     }
 
-    if (!vol) {
+    VIR_UNLESS (vol) {
         if (pool || !pooloptname)
             vshError(ctl, _("failed to get vol '%s'"), n);
         else
@@ -242,7 +242,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "prealloc-metadata"))
         flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
 
-    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
+    VIR_UNLESS ((pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0)
@@ -350,7 +350,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
     if (printXML) {
         vshPrint(ctl, "%s", xml);
     } else {
-        if (!(vol = virStorageVolCreateXML(pool, xml, flags))) {
+        VIR_UNLESS ((vol = virStorageVolCreateXML(pool, xml, flags))) {
             vshError(ctl, _("Failed to create vol %s"), name);
             return false;
         }
@@ -395,7 +395,7 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "prealloc-metadata"))
         flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
 
-    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
+    VIR_UNLESS ((pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
@@ -406,7 +406,7 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd)
         return false;
     }
 
-    if (!(vol = virStorageVolCreateXML(pool, buffer, flags))) {
+    VIR_UNLESS ((vol = virStorageVolCreateXML(pool, buffer, flags))) {
         vshError(ctl, _("Failed to create vol from %s"), from);
         return false;
     }
@@ -459,7 +459,7 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd)
     g_autofree char *buffer = NULL;
     unsigned int flags = 0;
 
-    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
+    VIR_UNLESS ((pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
         return false;
 
     if (vshCommandOptBool(cmd, "prealloc-metadata"))
@@ -471,7 +471,7 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
         return false;
 
-    if (!(inputvol = virshCommandOptVol(ctl, cmd, "vol", "inputpool", NULL)))
+    VIR_UNLESS ((inputvol = virshCommandOptVol(ctl, cmd, "vol", "inputpool", NULL)))
         return false;
 
     if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {
@@ -481,7 +481,7 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd)
 
     newvol = virStorageVolCreateXMLFrom(pool, buffer, inputvol, flags);
 
-    if (!newvol) {
+    VIR_UNLESS (newvol) {
         vshError(ctl, _("Failed to create vol from %s"), from);
         return false;
     }
@@ -501,7 +501,7 @@ virshMakeCloneXML(const char *origxml, const char *newname)
     int size;
 
     doc = virXMLParseStringCtxt(origxml, _("(volume_definition)"), &ctxt);
-    if (!doc)
+    VIR_UNLESS (doc)
         return NULL;
 
     obj = xmlXPathEval(BAD_CAST "/volume/name", ctxt);
@@ -560,7 +560,7 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd)
     bool ret = false;
     unsigned int flags = 0;
 
-    if (!(origvol = virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
+    VIR_UNLESS ((origvol = virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
         goto cleanup;
 
     if (vshCommandOptBool(cmd, "prealloc-metadata"))
@@ -570,7 +570,7 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd)
         flags |= VIR_STORAGE_VOL_CREATE_REFLINK;
 
     origpool = virStoragePoolLookupByVolume(origvol);
-    if (!origpool) {
+    VIR_UNLESS (origpool) {
         vshError(ctl, "%s", _("failed to get parent pool"));
         goto cleanup;
     }
@@ -579,11 +579,11 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
 
     origxml = virStorageVolGetXMLDesc(origvol, 0);
-    if (!origxml)
+    VIR_UNLESS (origxml)
         goto cleanup;
 
     newxml = virshMakeCloneXML(origxml, name);
-    if (!newxml) {
+    VIR_UNLESS (newxml) {
         vshError(ctl, "%s", _("Failed to allocate XML buffer"));
         goto cleanup;
     }
@@ -658,7 +658,7 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptULongLongWrap(ctl, cmd, "length", &length) < 0)
         return false;
 
-    if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
+    VIR_UNLESS ((vol = virshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "file", &file) < 0)
@@ -681,7 +681,7 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "sparse"))
         flags |= VIR_STORAGE_VOL_UPLOAD_SPARSE_STREAM;
 
-    if (!(st = virStreamNew(priv->conn, 0))) {
+    VIR_UNLESS ((st = virStreamNew(priv->conn, 0))) {
         vshError(ctl, _("cannot create a new stream"));
         return false;
     }
@@ -773,7 +773,7 @@ cmdVolDownload(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptULongLongWrap(ctl, cmd, "length", &length) < 0)
         return false;
 
-    if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
+    VIR_UNLESS ((vol = virshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "file", &file) < 0)
@@ -801,7 +801,7 @@ cmdVolDownload(vshControl *ctl, const vshCmd *cmd)
     cbData.fd = fd;
     cbData.isBlock = !!S_ISBLK(sb.st_mode);
 
-    if (!(st = virStreamNew(priv->conn, 0))) {
+    VIR_UNLESS ((st = virStreamNew(priv->conn, 0))) {
         vshError(ctl, _("cannot create a new stream"));
         goto cleanup;
     }
@@ -868,7 +868,7 @@ cmdVolDelete(vshControl *ctl, const vshCmd *cmd)
     bool delete_snapshots = vshCommandOptBool(cmd, "delete-snapshots");
     unsigned int flags = 0;
 
-    if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
+    VIR_UNLESS ((vol = virshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
         return false;
 
     if (delete_snapshots)
@@ -922,7 +922,7 @@ cmdVolWipe(vshControl *ctl, const vshCmd *cmd)
     int algorithm = VIR_STORAGE_VOL_WIPE_ALG_ZERO;
     int funcRet;
 
-    if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
+    VIR_UNLESS ((vol = virshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "algorithm", &algorithm_str) < 0)
@@ -1005,7 +1005,7 @@ cmdVolInfo(vshControl *ctl, const vshCmd *cmd)
     int rc;
     unsigned int flags = 0;
 
-    if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
+    VIR_UNLESS ((vol = virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
         return false;
 
     vshPrint(ctl, "%-15s %s\n", _("Name:"), virStorageVolGetName(vol));
@@ -1101,7 +1101,7 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "shrink"))
         flags |= VIR_STORAGE_VOL_RESIZE_SHRINK;
 
-    if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
+    VIR_UNLESS ((vol = virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "capacity", &capacityStr) < 0)
@@ -1169,7 +1169,7 @@ cmdVolDumpXML(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     char *dump;
 
-    if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
+    VIR_UNLESS ((vol = virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
         return false;
 
     dump = virStorageVolGetXMLDesc(vol, 0);
@@ -1192,7 +1192,7 @@ virshStorageVolSorter(const void *a, const void *b)
     if (*va && !*vb)
         return -1;
 
-    if (!*va)
+    VIR_UNLESS (*va)
         return *vb != NULL;
 
     return vshStrcasecmp(virStorageVolGetName(*va),
@@ -1273,7 +1273,7 @@ virshStorageVolListCollect(vshControl *ctl,
 
     /* get the vols */
     for (i = 0; i < nvols; i++) {
-        if (!(vol = virStorageVolLookupByName(pool, names[i])))
+        VIR_UNLESS ((vol = virStorageVolLookupByName(pool, names[i])))
             continue;
         list->vols[list->nvols++] = vol;
     }
@@ -1297,7 +1297,7 @@ virshStorageVolListCollect(vshControl *ctl,
             VIR_FREE(names[i]);
     VIR_FREE(names);
 
-    if (!success) {
+    VIR_UNLESS (success) {
         g_clear_pointer(&list, virshStorageVolListFree);
     }
 
@@ -1347,10 +1347,10 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     g_autoptr(vshTable) table = NULL;
 
     /* Look up the pool information given to us by the user */
-    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
+    VIR_UNLESS ((pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
         return false;
 
-    if (!(list = virshStorageVolListCollect(ctl, pool, 0)))
+    VIR_UNLESS ((list = virshStorageVolListCollect(ctl, pool, 0)))
         goto cleanup;
 
     if (list->nvols > 0)
@@ -1396,10 +1396,10 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
      */
 
     /* Output basic info then return if --details option not selected */
-    if (!details) {
+    VIR_UNLESS (details) {
         /* The old output format */
         table = vshTableNew(_("Name"), _("Path"), NULL);
-        if (!table)
+        VIR_UNLESS (table)
             goto cleanup;
 
         for (i = 0; i < list->nvols; i++) {
@@ -1421,7 +1421,7 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
 
     /* Insert the header into table */
     table = vshTableNew(_("Name"), _("Path"), _("Type"), _("Capacity"), _("Allocation"), NULL);
-    if (!table)
+    VIR_UNLESS (table)
         goto cleanup;
 
     /* Insert the volume info rows into table */
@@ -1485,7 +1485,7 @@ cmdVolName(vshControl *ctl, const vshCmd *cmd)
 {
     g_autoptr(virshStorageVol) vol = NULL;
 
-    if (!(vol = virshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL,
+    VIR_UNLESS ((vol = virshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL,
                                      VIRSH_BYUUID)))
         return false;
 
@@ -1523,7 +1523,7 @@ cmdVolPool(vshControl *ctl, const vshCmd *cmd)
     char uuid[VIR_UUID_STRING_BUFLEN];
 
     /* Use the supplied string to locate the volume */
-    if (!(vol = virshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL,
+    VIR_UNLESS ((vol = virshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL,
                                      VIRSH_BYUUID))) {
         return false;
     }
@@ -1572,7 +1572,7 @@ cmdVolKey(vshControl *ctl, const vshCmd *cmd)
 {
     g_autoptr(virshStorageVol) vol = NULL;
 
-    if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
+    VIR_UNLESS ((vol = virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
         return false;
 
     vshPrint(ctl, "%s\n", virStorageVolGetKey(vol));
@@ -1604,7 +1604,7 @@ cmdVolPath(vshControl *ctl, const vshCmd *cmd)
     g_autoptr(virshStorageVol) vol = NULL;
     g_autofree char *StorageVolPath = NULL;
 
-    if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
+    VIR_UNLESS ((vol = virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
         return false;
 
     if ((StorageVolPath = virStorageVolGetPath(vol)) == NULL) {
diff --git a/tools/virsh.c b/tools/virsh.c
index f7adb90be8..bb80a1eb75 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -152,7 +152,7 @@ virshConnect(vshControl *ctl, const char *uri, bool readonly)
         if (!pkagent &&
             err && err->domain == VIR_FROM_POLKIT &&
             err->code == VIR_ERR_AUTH_UNAVAILABLE) {
-            if (!(pkagent = virPolkitAgentCreate()))
+            VIR_UNLESS ((pkagent = virPolkitAgentCreate()))
                 goto cleanup;
         } else if (err && err->domain == VIR_FROM_POLKIT &&
                    err->code == VIR_ERR_AUTH_FAILED) {
@@ -166,7 +166,7 @@ virshConnect(vshControl *ctl, const char *uri, bool readonly)
          */
     } while (authfail < 5);
 
-    if (!c)
+    VIR_UNLESS (c)
         goto cleanup;
 
     if (interval > 0 &&
@@ -222,7 +222,7 @@ virshReconnect(vshControl *ctl, const char *name, bool readonly, bool force)
 
     priv->conn = virshConnect(ctl, name ? name : ctl->connname, readonly);
 
-    if (!priv->conn) {
+    VIR_UNLESS (priv->conn) {
         if (disconnected)
             vshError(ctl, "%s", _("Failed to reconnect to the hypervisor"));
         else
@@ -860,7 +860,7 @@ main(int argc, char **argv)
     virshCtl.escapeChar = "^]";     /* Same default as telnet */
     ctl->privData = &virshCtl;
 
-    if (!(progname = strrchr(argv[0], '/')))
+    VIR_UNLESS ((progname = strrchr(argv[0], '/')))
         progname = argv[0];
     else
         progname++;
@@ -890,7 +890,7 @@ main(int argc, char **argv)
 
     virFileActivateDirOverrideForProg(argv[0]);
 
-    if (!vshInit(ctl, cmdGroups, NULL))
+    VIR_UNLESS (vshInit(ctl, cmdGroups, NULL))
         exit(EXIT_FAILURE);
 
     if (!virshParseArgv(ctl, argc, argv) ||
@@ -899,14 +899,14 @@ main(int argc, char **argv)
         exit(EXIT_FAILURE);
     }
 
-    if (!ctl->connname)
+    VIR_UNLESS (ctl->connname)
         ctl->connname = g_strdup(getenv("VIRSH_DEFAULT_CONNECT_URI"));
 
-    if (!ctl->imode) {
+    VIR_UNLESS (ctl->imode) {
         ret = vshCommandRun(ctl, ctl->cmd);
     } else {
         /* interactive mode */
-        if (!ctl->quiet) {
+        VIR_UNLESS (ctl->quiet) {
             vshPrint(ctl,
                      _("Welcome to %s, the virtualization interactive terminal.\n\n"),
                      progname);
diff --git a/tools/virt-admin.c b/tools/virt-admin.c
index e010763e21..d162be0155 100644
--- a/tools/virt-admin.c
+++ b/tools/virt-admin.c
@@ -110,7 +110,7 @@ vshAdmConnect(vshControl *ctl, unsigned int flags)
 
     priv->conn = virAdmConnectOpen(ctl->connname, flags);
 
-    if (!priv->conn) {
+    VIR_UNLESS (priv->conn) {
         if (priv->wantReconnect)
             vshError(ctl, "%s", _("Failed to reconnect to the admin server"));
         else
@@ -134,7 +134,7 @@ vshAdmDisconnect(vshControl *ctl)
     int ret = 0;
     vshAdmControl *priv = ctl->privData;
 
-    if (!priv->conn)
+    VIR_UNLESS (priv->conn)
         return ret;
 
     virAdmConnectUnregisterCloseCallback(priv->conn, vshAdmCatchDisconnect);
@@ -188,7 +188,7 @@ cmdURI(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     vshAdmControl *priv = ctl->privData;
 
     uri = virAdmConnectGetURI(priv->conn);
-    if (!uri) {
+    VIR_UNLESS (uri) {
         vshError(ctl, "%s", _("failed to get URI"));
         return false;
     }
@@ -343,7 +343,7 @@ cmdSrvList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     }
 
     table = vshTableNew(_("Id"), _("Name"), NULL);
-    if (!table)
+    VIR_UNLESS (table)
         goto cleanup;
 
     for (i = 0; i < nsrvs; i++) {
@@ -411,7 +411,7 @@ cmdSrvThreadpoolInfo(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "server", &srvname) < 0)
         return false;
 
-    if (!(srv = virAdmConnectLookupServer(priv->conn, srvname, 0)))
+    VIR_UNLESS ((srv = virAdmConnectLookupServer(priv->conn, srvname, 0)))
         goto cleanup;
 
     if (virAdmServerGetThreadPoolParameters(srv, &params,
@@ -503,7 +503,7 @@ cmdSrvThreadpoolSet(vshControl *ctl, const vshCmd *cmd)
 
 #undef PARSE_CMD_TYPED_PARAM
 
-    if (!nparams) {
+    VIR_UNLESS (nparams) {
         vshError(ctl, "%s",
                  _("At least one of options --min-workers, --max-workers, "
                    "--priority-workers is mandatory "));
@@ -519,7 +519,7 @@ cmdSrvThreadpoolSet(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
     }
 
-    if (!(srv = virAdmConnectLookupServer(priv->conn, srvname, 0)))
+    VIR_UNLESS ((srv = virAdmConnectLookupServer(priv->conn, srvname, 0)))
         goto cleanup;
 
     if (virAdmServerSetThreadPoolParameters(srv, params,
@@ -584,7 +584,7 @@ cmdSrvClientsList(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "server", &srvname) < 0)
         return false;
 
-    if (!(srv = virAdmConnectLookupServer(priv->conn, srvname, 0)))
+    VIR_UNLESS ((srv = virAdmConnectLookupServer(priv->conn, srvname, 0)))
         goto cleanup;
 
     /* Obtain a list of clients connected to server @srv */
@@ -595,7 +595,7 @@ cmdSrvClientsList(vshControl *ctl, const vshCmd *cmd)
     }
 
     table = vshTableNew(_("Id"), _("Transport"), _("Connected since"), NULL);
-    if (!table)
+    VIR_UNLESS (table)
         goto cleanup;
 
     for (i = 0; i < nclts; i++) {
@@ -764,10 +764,10 @@ cmdClientDisconnect(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptULongLongWrap(ctl, cmd, "client", &id) < 0)
         return false;
 
-    if (!(srv = virAdmConnectLookupServer(priv->conn, srvname, 0)))
+    VIR_UNLESS ((srv = virAdmConnectLookupServer(priv->conn, srvname, 0)))
         goto cleanup;
 
-    if (!(client = virAdmServerLookupClient(srv, id, 0)))
+    VIR_UNLESS ((client = virAdmServerLookupClient(srv, id, 0)))
         goto cleanup;
 
     if (virAdmClientClose(client, 0) < 0) {
@@ -823,7 +823,7 @@ cmdSrvClientsInfo(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "server", &srvname) < 0)
         return false;
 
-    if (!(srv = virAdmConnectLookupServer(priv->conn, srvname, 0)))
+    VIR_UNLESS ((srv = virAdmConnectLookupServer(priv->conn, srvname, 0)))
         goto cleanup;
 
     if (virAdmServerGetClientLimits(srv, &params, &nparams, 0) < 0) {
@@ -910,7 +910,7 @@ cmdSrvClientsSet(vshControl *ctl, const vshCmd *cmd)
 
 #undef PARSE_CMD_TYPED_PARAM
 
-    if (!nparams) {
+    VIR_UNLESS (nparams) {
         vshError(ctl, "%s", _("At least one of options --max-clients, "
                               "--max-unauth-clients is mandatory"));
         goto cleanup;
@@ -926,7 +926,7 @@ cmdSrvClientsSet(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
     }
 
-    if (!(srv = virAdmConnectLookupServer(priv->conn, srvname, 0)))
+    VIR_UNLESS ((srv = virAdmConnectLookupServer(priv->conn, srvname, 0)))
         goto cleanup;
 
     if (virAdmServerSetClientLimits(srv, params, nparams, 0) < 0)
@@ -986,7 +986,7 @@ cmdSrvUpdateTlsFiles(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "server", &srvname) < 0)
         return false;
 
-    if (!(srv = virAdmConnectLookupServer(priv->conn, srvname, 0)))
+    VIR_UNLESS ((srv = virAdmConnectLookupServer(priv->conn, srvname, 0)))
         goto cleanup;
 
     if (virAdmServerUpdateTlsFiles(srv, 0) < 0) {
@@ -1112,10 +1112,10 @@ vshAdmConnectionHandler(vshControl *ctl)
 {
     vshAdmControl *priv = ctl->privData;
 
-    if (!virAdmConnectIsAlive(priv->conn))
+    VIR_UNLESS (virAdmConnectIsAlive(priv->conn))
         vshAdmReconnect(ctl);
 
-    if (!virAdmConnectIsAlive(priv->conn)) {
+    VIR_UNLESS (virAdmConnectIsAlive(priv->conn)) {
         vshError(ctl, "%s", _("no valid connection"));
         return NULL;
     }
@@ -1157,7 +1157,7 @@ vshAdmInit(vshControl *ctl)
          * non-default connection, or might be 'help' which needs no
          * connection).
          */
-        if (!priv->conn) {
+        VIR_UNLESS (priv->conn) {
             vshReportError(ctl);
             return false;
         }
@@ -1532,7 +1532,7 @@ main(int argc, char **argv)
     ctl->eventPipe[1] = -1;
     ctl->privData = &virtAdminCtl;
 
-    if (!(progname = strrchr(argv[0], '/')))
+    VIR_UNLESS ((progname = strrchr(argv[0], '/')))
         progname = argv[0];
     else
         progname++;
@@ -1562,7 +1562,7 @@ main(int argc, char **argv)
 
     virFileActivateDirOverrideForProg(argv[0]);
 
-    if (!vshInit(ctl, cmdGroups, NULL))
+    VIR_UNLESS (vshInit(ctl, cmdGroups, NULL))
         exit(EXIT_FAILURE);
 
     if (!vshAdmParseArgv(ctl, argc, argv) ||
@@ -1571,11 +1571,11 @@ main(int argc, char **argv)
         exit(EXIT_FAILURE);
     }
 
-    if (!ctl->imode) {
+    VIR_UNLESS (ctl->imode) {
         ret = vshCommandRun(ctl, ctl->cmd);
     } else {
         /* interactive mode */
-        if (!ctl->quiet) {
+        VIR_UNLESS (ctl->quiet) {
             vshPrint(ctl,
                      _("Welcome to %s, the administrating virtualization "
                        "interactive terminal.\n\n"),
diff --git a/tools/virt-host-validate-ch.c b/tools/virt-host-validate-ch.c
index b26f82738d..8b4bb88061 100644
--- a/tools/virt-host-validate-ch.c
+++ b/tools/virt-host-validate-ch.c
@@ -36,7 +36,7 @@ int virHostValidateCh(void)
         _("Check that CPU and firmware supports virtualization "
           "and kvm module is loaded");
 
-    if (!(flags = virHostValidateGetCPUFlags()))
+    VIR_UNLESS ((flags = virHostValidateGetCPUFlags()))
         return -1;
 
     /* Cloud-Hypervisor only supports x86_64 and aarch64 */
diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-common.c
index 2ac96d1e19..25cd60888a 100644
--- a/tools/virt-host-validate-common.c
+++ b/tools/virt-host-validate-common.c
@@ -193,7 +193,7 @@ virBitmap *virHostValidateGetCPUFlags(void)
     FILE *fp;
     virBitmap *flags = NULL;
 
-    if (!(fp = fopen("/proc/cpuinfo", "r")))
+    VIR_UNLESS ((fp = fopen("/proc/cpuinfo", "r")))
         return NULL;
 
     flags = virBitmapNew(VIR_HOST_VALIDATE_CPU_FLAG_LAST);
@@ -204,7 +204,7 @@ virBitmap *virHostValidateGetCPUFlags(void)
         g_auto(GStrv) tokens = NULL;
         GStrv next;
 
-        if (!fgets(line, sizeof(line), fp))
+        VIR_UNLESS (fgets(line, sizeof(line), fp))
             break;
 
         /* The line we're interested in is marked differently depending
@@ -222,12 +222,12 @@ virBitmap *virHostValidateGetCPUFlags(void)
         line[strlen(line) - 1] = '\0';
 
         /* Skip to the separator */
-        if (!(start = strchr(line, ':')))
+        VIR_UNLESS ((start = strchr(line, ':')))
             continue;
 
         /* Split the line using " " as a delimiter. The first token
          * will always be ":", but that's okay */
-        if (!(tokens = g_strsplit(start, " ", 0)))
+        VIR_UNLESS ((tokens = g_strsplit(start, " ", 0)))
             continue;
 
         /* Go through all flags and check whether one of those we
@@ -300,12 +300,12 @@ int virHostValidateCGroupControllers(const char *hvname,
         int flag = 1 << i;
         const char *cg_name = virCgroupControllerTypeToString(i);
 
-        if (!(controllers & flag))
+        VIR_UNLESS ((controllers & flag))
             continue;
 
         virHostMsgCheck(hvname, "for cgroup '%s' controller support", cg_name);
 
-        if (!virCgroupHasController(group, i)) {
+        VIR_UNLESS (virCgroupHasController(group, i)) {
             ret = VIR_HOST_VALIDATE_FAILURE(level);
             virHostMsgFail(level, "Enable '%s' in kernel Kconfig file or "
                            "mount/enable cgroup controller in your system",
@@ -378,7 +378,7 @@ int virHostValidateIOMMU(const char *hvname,
          * devices (which is quite usual on s390x). If there are
          * no PCI devices the directory is still there but is
          * empty. */
-        if (!virDirOpen(&dir, "/sys/bus/pci/devices")) {
+        VIR_UNLESS (virDirOpen(&dir, "/sys/bus/pci/devices")) {
             virHostMsgFail(VIR_HOST_VALIDATE_NOTE,
                            "Skipped - PCI support disabled");
             return VIR_HOST_VALIDATE_FAILURE(VIR_HOST_VALIDATE_NOTE);
@@ -401,7 +401,7 @@ int virHostValidateIOMMU(const char *hvname,
     if (stat("/sys/kernel/iommu_groups", &sb) < 0)
         return 0;
 
-    if (!S_ISDIR(sb.st_mode))
+    VIR_UNLESS (S_ISDIR(sb.st_mode))
         return 0;
 
     virHostMsgCheck(hvname, "%s", _("if IOMMU is enabled by kernel"));
@@ -424,13 +424,13 @@ bool virHostKernelModuleIsLoaded(const char *module)
     FILE *fp;
     bool ret = false;
 
-    if (!(fp = fopen("/proc/modules", "r")))
+    VIR_UNLESS ((fp = fopen("/proc/modules", "r")))
         return false;
 
     do {
         char line[1024];
 
-        if (!fgets(line, sizeof(line), fp))
+        VIR_UNLESS (fgets(line, sizeof(line), fp))
             break;
 
         if (STRPREFIX(line, module)) {
@@ -467,7 +467,7 @@ int virHostValidateSecureGuests(const char *hvname,
     virHostMsgCheck(hvname, "%s", _("for secure guest support"));
     if (ARCH_IS_S390(arch)) {
         if (hasFac158) {
-            if (!virFileIsDir("/sys/firmware/uv")) {
+            VIR_UNLESS (virFileIsDir("/sys/firmware/uv")) {
                 virHostMsgFail(level, "IBM Secure Execution not supported by "
                                       "the currently used kernel");
                 return VIR_HOST_VALIDATE_FAILURE(level);
diff --git a/tools/virt-host-validate-qemu.c b/tools/virt-host-validate-qemu.c
index 46ff1d2494..b79c941153 100644
--- a/tools/virt-host-validate-qemu.c
+++ b/tools/virt-host-validate-qemu.c
@@ -37,7 +37,7 @@ int virHostValidateQEMU(void)
     const char *kvmhint = _("Check that CPU and firmware supports virtualization "
                             "and kvm module is loaded");
 
-    if (!(flags = virHostValidateGetCPUFlags()))
+    VIR_UNLESS ((flags = virHostValidateGetCPUFlags()))
         return -1;
 
     switch ((int)arch) {
@@ -91,7 +91,7 @@ int virHostValidateQEMU(void)
     if (arch == VIR_ARCH_PPC64 || arch == VIR_ARCH_PPC64LE) {
         virHostMsgCheck("QEMU", "%s", _("for PowerPC KVM module loaded"));
 
-        if (!virHostKernelModuleIsLoaded("kvm_hv"))
+        VIR_UNLESS (virHostKernelModuleIsLoaded("kvm_hv"))
             virHostMsgFail(VIR_HOST_VALIDATE_WARN,
                           _("Load kvm_hv for better performance"));
         else
diff --git a/tools/virt-login-shell-helper.c b/tools/virt-login-shell-helper.c
index 0fb03da697..19ec0ea970 100644
--- a/tools/virt-login-shell-helper.c
+++ b/tools/virt-login-shell-helper.c
@@ -62,10 +62,10 @@ static int virLoginShellAllowedUser(virConf *conf,
         */
         if (entry[0] == '%') {
             entry++;
-            if (!*entry)
+            VIR_UNLESS (*entry)
                 continue;
             for (i = 0; i < ngroups; i++) {
-                if (!(gname = virGetGroupName(groups[i])))
+                VIR_UNLESS ((gname = virGetGroupName(groups[i])))
                     continue;
                 if (g_pattern_match_simple(entry, gname)) {
                     ret = 0;
@@ -251,14 +251,14 @@ main(int argc, char **argv)
     gid = (gid_t)gidval;
 
     name = virGetUserName(uid);
-    if (!name)
+    VIR_UNLESS (name)
         goto cleanup;
 
     homedir = virGetUserDirectoryByUID(uid);
-    if (!homedir)
+    VIR_UNLESS (homedir)
         goto cleanup;
 
-    if (!(conf = virConfReadFile(login_shell_path, 0)))
+    VIR_UNLESS ((conf = virConfReadFile(login_shell_path, 0)))
         goto cleanup;
 
     if ((ngroups = virGetGroupList(uid, gid, &groups)) < 0)
@@ -274,11 +274,11 @@ main(int argc, char **argv)
         goto cleanup;
 
     conn = virConnectOpen("lxc:///system");
-    if (!conn)
+    VIR_UNLESS (conn)
         goto cleanup;
 
     dom = virDomainLookupByName(conn, name);
-    if (!dom)
+    VIR_UNLESS (dom)
         goto cleanup;
 
     if (!virDomainIsActive(dom) && virDomainCreate(dom) < 0) {
@@ -346,7 +346,7 @@ main(int argc, char **argv)
      * a leading '-' to indicate it is a login shell
      */
     shcmd = shargv[0];
-    if (!g_path_is_absolute(shcmd)) {
+    VIR_UNLESS (g_path_is_absolute(shcmd)) {
         virReportSystemError(errno,
                              _("Shell '%s' should have absolute path"),
                              shcmd);
diff --git a/tools/virt-pki-query-dn.c b/tools/virt-pki-query-dn.c
index ee3783c1b2..2dd38df29f 100644
--- a/tools/virt-pki-query-dn.c
+++ b/tools/virt-pki-query-dn.c
@@ -69,7 +69,7 @@ main(int argc,
     if (virGettextInitialize() < 0)
         return EXIT_FAILURE;
 
-    if (!(progname = strrchr(argv[0], '/')))
+    VIR_UNLESS ((progname = strrchr(argv[0], '/')))
         progname = argv[0];
     else
         progname++;
diff --git a/tools/vsh-table.c b/tools/vsh-table.c
index aa2deb8c72..67f5d24071 100644
--- a/tools/vsh-table.c
+++ b/tools/vsh-table.c
@@ -49,7 +49,7 @@ vshTableRowFree(vshTableRow *row)
 {
     size_t i;
 
-    if (!row)
+    VIR_UNLESS (row)
         return;
 
     for (i = 0; i < row->ncells; i++)
@@ -65,7 +65,7 @@ vshTableFree(vshTable *table)
 {
     size_t i;
 
-    if (!table)
+    VIR_UNLESS (table)
         return;
 
     for (i = 0; i < table->nrows; i++)
@@ -90,7 +90,7 @@ vshTableRowNew(const char *arg, va_list ap)
 {
     vshTableRow *row = NULL;
 
-    if (!arg) {
+    VIR_UNLESS (arg) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Table row cannot be empty"));
         goto error;
@@ -137,7 +137,7 @@ vshTableNew(const char *arg, ...)
     header = vshTableRowNew(arg, ap);
     va_end(ap);
 
-    if (!header)
+    VIR_UNLESS (header)
         goto error;
 
     VIR_APPEND_ELEMENT(table->rows, table->nrows, header);
@@ -172,7 +172,7 @@ vshTableRowAppend(vshTable *table, const char *arg, ...)
     row = vshTableRowNew(arg, ap);
     va_end(ap);
 
-    if (!row)
+    VIR_UNLESS (row)
         goto cleanup;
 
     if (ncolumns != row->ncells) {
@@ -234,7 +234,7 @@ vshTableSafeEncode(const char *s, size_t *width)
                  * Not valid multibyte sequence -- maybe it's
                  * printable char according to the current locales.
                  */
-                if (!g_ascii_isprint(*p)) {
+                VIR_UNLESS (g_ascii_isprint(*p)) {
                     g_snprintf(buf, HEX_ENCODE_LENGTH + 1, "\\x%02x", *p);
                     buf += HEX_ENCODE_LENGTH;
                     *width += HEX_ENCODE_LENGTH;
@@ -295,7 +295,7 @@ vshTableGetColumnsWidths(vshTable *table,
              * because width of some of those characters (e.g. \t, \v, \b ...)
              * cannot be counted properly */
             char *tmp = vshTableSafeEncode(row->cells[j], &size);
-            if (!tmp)
+            VIR_UNLESS (tmp)
                 return -1;
 
             VIR_FREE(row->cells[j]);
diff --git a/tools/vsh.c b/tools/vsh.c
index 499794c8fc..ecd9d3fcb1 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -272,12 +272,12 @@ vshCmddefCheckInternals(vshControl *ctl,
     if (cmd->flags & VSH_CMD_FLAG_ALIAS) {
         const vshCmdDef *alias;
 
-        if (!cmd->alias) {
+        VIR_UNLESS (cmd->alias) {
             vshError(ctl, _("command '%s' has inconsistent alias"), cmd->name);
             return -1;
         }
 
-        if (!(alias = vshCmddefSearch(cmd->alias))) {
+        VIR_UNLESS ((alias = vshCmddefSearch(cmd->alias))) {
             vshError(ctl, _("command alias '%s' is pointing to a non-existent command '%s'"),
                      cmd->name, cmd->alias);
             return -1;
@@ -319,7 +319,7 @@ vshCmddefCheckInternals(vshControl *ctl,
         return -1;
     }
 
-    if (!cmd->opts)
+    VIR_UNLESS (cmd->opts)
         return 0;
 
     for (i = 0; cmd->opts[i].name; i++) {
@@ -382,7 +382,7 @@ vshCmddefCheckInternals(vshControl *ctl,
                     return -1;
                 }
             }
-            if (!cmd->opts[j].name) {
+            VIR_UNLESS (cmd->opts[j].name) {
                 vshError(ctl, _("alias '%s' of command '%s' has missing alias option"),
                          opt->name, cmd->name);
                 return -1; /* alias option must map to a later option name */
@@ -398,7 +398,7 @@ vshCmddefCheckInternals(vshControl *ctl,
             break;
 
         case VSH_OT_DATA:
-            if (!(opt->flags & VSH_OFLAG_REQ)) {
+            VIR_UNLESS ((opt->flags & VSH_OFLAG_REQ)) {
                 vshError(ctl, _("parameter '%s' of command '%s' must use VSH_OFLAG_REQ flag"),
                          opt->name, cmd->name);
                 return -1; /* OT_DATA should always be required. */
@@ -447,7 +447,7 @@ vshCmddefOptParse(const vshCmdDef *cmd,
     *opts_need_arg = 0;
     *opts_required = 0;
 
-    if (!cmd->opts)
+    VIR_UNLESS (cmd->opts)
         return;
 
     for (i = 0; cmd->opts[i].name; i++) {
@@ -459,7 +459,7 @@ vshCmddefOptParse(const vshCmdDef *cmd,
         if (opt->type == VSH_OT_ALIAS)
             continue; /* skip the alias option */
 
-        if (!(opt->flags & VSH_OFLAG_REQ_OPT))
+        VIR_UNLESS ((opt->flags & VSH_OFLAG_REQ_OPT))
             *opts_need_arg |= 1ULL << i;
 
         if (opt->flags & VSH_OFLAG_REQ)
@@ -533,7 +533,7 @@ vshCmddefGetData(const vshCmdDef *cmd, uint64_t *opts_need_arg,
     size_t i;
     const vshCmdOptDef *opt;
 
-    if (!*opts_need_arg)
+    VIR_UNLESS (*opts_need_arg)
         return NULL;
 
     /* Grab least-significant set bit */
@@ -556,7 +556,7 @@ vshCommandCheckOpts(vshControl *ctl, const vshCmd *cmd, uint64_t opts_required,
     size_t i;
 
     opts_required &= ~opts_seen;
-    if (!opts_required)
+    VIR_UNLESS (opts_required)
         return 0;
 
     for (i = 0; def->opts[i].name; i++) {
@@ -668,18 +668,18 @@ vshCmddefHelp(const vshCmdDef *def)
                 /* xgettext:c-format */
                 fmt = ((opt->flags & VSH_OFLAG_REQ) ? "<%s>"
                        : _("[--%s <number>]"));
-                if (!(opt->flags & VSH_OFLAG_REQ_OPT))
+                VIR_UNLESS ((opt->flags & VSH_OFLAG_REQ_OPT))
                     shortopt = true;
                 break;
             case VSH_OT_STRING:
                 /* xgettext:c-format */
                 fmt = _("[--%s <string>]");
-                if (!(opt->flags & VSH_OFLAG_REQ_OPT))
+                VIR_UNLESS ((opt->flags & VSH_OFLAG_REQ_OPT))
                     shortopt = true;
                 break;
             case VSH_OT_DATA:
                 fmt = ((opt->flags & VSH_OFLAG_REQ) ? "<%s>" : "[<%s>]");
-                if (!(opt->flags & VSH_OFLAG_REQ_OPT))
+                VIR_UNLESS ((opt->flags & VSH_OFLAG_REQ_OPT))
                     shortopt = true;
                 break;
             case VSH_OT_ARGV:
@@ -814,7 +814,7 @@ vshCommandOpt(const vshCmd *cmd, const char *name, vshCmdOpt **opt,
         valid++;
     }
 
-    if (!cmd->skipChecks)
+    VIR_UNLESS (cmd->skipChecks)
         assert(valid && (!needData || valid->type != VSH_OT_BOOL));
 
     if (valid && valid->flags & VSH_OFLAG_REQ)
@@ -1055,7 +1055,7 @@ vshCommandOptStringReq(vshControl *ctl,
         error = N_("Option argument is empty");
 
     if (error) {
-        if (!cmd->skipChecks)
+        VIR_UNLESS (cmd->skipChecks)
             vshError(ctl, _("Failed to get option '%s': %s"), name, _(error));
         return -1;
     }
@@ -1278,7 +1278,7 @@ vshBlockJobOptionBandwidth(vshControl *ctl,
             return -1;
         }
 
-        if (!bytes)
+        VIR_UNLESS (bytes)
             bw >>= 20;
 
         *bandwidth = bw;
@@ -1314,7 +1314,7 @@ vshCommandRun(vshControl *ctl, const vshCmd *cmd)
         after = g_get_real_time();
 
         /* try to automatically catch disconnections */
-        if (!ret &&
+        VIR_UNLESS (ret &&
             ((last_error != NULL) &&
              (((last_error->code == VIR_ERR_SYSTEM_ERROR) &&
                (last_error->domain == VIR_FROM_REMOTE)) ||
@@ -1323,7 +1323,7 @@ vshCommandRun(vshControl *ctl, const vshCmd *cmd)
               (last_error->code == VIR_ERR_INVALID_CONN))))
             disconnected++;
 
-        if (!ret)
+        VIR_UNLESS (ret)
             vshReportError(ctl);
 
         if (STREQ(cmd->def->name, "quit") ||
@@ -1375,7 +1375,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd **partial)
     vshCmdOpt *first = NULL;
     const vshCmdDef *cmd = NULL;
 
-    if (!partial) {
+    VIR_UNLESS (partial) {
         g_clear_pointer(&ctl->cmd, vshCommandFree);
     }
 
@@ -1416,8 +1416,8 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd **partial)
                     } while (tk == VSH_TK_ARG);
                     VIR_FREE(tkdata);
                     break;
-                } else if (!(cmd = vshCmddefSearch(tkdata))) {
-                    if (!partial)
+                } else VIR_UNLESS ((cmd = vshCmddefSearch(tkdata))) {
+                    VIR_UNLESS (partial)
                         vshError(ctl, _("unknown command: '%s'"), tkdata);
                     goto syntaxError;   /* ... or ignore this command only? */
                 }
@@ -1443,7 +1443,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd **partial)
                     optstr = g_strdup(optstr + 1);
                 }
                 /* Special case 'help' to ignore all spurious options */
-                if (!(opt = vshCmddefGetOption(ctl, cmd, tkdata + 2,
+                VIR_UNLESS ((opt = vshCmddefGetOption(ctl, cmd, tkdata + 2,
                                                &opts_seen, &opt_index,
                                                &optstr, partial == NULL))) {
                     VIR_FREE(optstr);
@@ -1471,7 +1471,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd **partial)
                             if (parser->pos - parser->originalLine == parser->point - 1)
                                 arg->completeThis = true;
 
-                            if (!first)
+                            VIR_UNLESS (first)
                                 first = arg;
                             if (last)
                                 last->next = arg;
@@ -1490,7 +1490,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd **partial)
                 } else {
                     tkdata = NULL;
                     if (optstr) {
-                        if (!partial)
+                        VIR_UNLESS (partial)
                             vshError(ctl, _("invalid '=' after option --%s"),
                                      opt->name);
                         VIR_FREE(optstr);
@@ -1505,10 +1505,10 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd **partial)
             } else {
  get_data:
                 /* Special case 'help' to ignore spurious data */
-                if (!(opt = vshCmddefGetData(cmd, &opts_need_arg,
+                VIR_UNLESS ((opt = vshCmddefGetData(cmd, &opts_need_arg,
                                              &opts_seen)) &&
                      STRNEQ(cmd->name, "help")) {
-                    if (!partial)
+                    VIR_UNLESS (partial)
                         vshError(ctl, _("unexpected data '%s'"), tkdata);
                     goto syntaxError;
                 }
@@ -1524,13 +1524,13 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd **partial)
                 if (parser->pos - parser->originalLine == parser->point)
                     arg->completeThis = true;
 
-                if (!first)
+                VIR_UNLESS (first)
                     first = arg;
                 if (last)
                     last->next = arg;
                 last = arg;
 
-                if (!partial)
+                VIR_UNLESS (partial)
                     vshDebug(ctl, VSH_ERR_INFO, "%s: %s(%s): %s\n",
                              cmd->name,
                              opt->name,
@@ -1568,7 +1568,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd **partial)
             c->def = cmd;
             c->next = NULL;
 
-            if (!partial &&
+            VIR_UNLESS (partial &&
                 vshCommandCheckOpts(ctl, c, opts_required, opts_seen) < 0) {
                 vshCommandFree(c);
                 goto syntaxError;
@@ -1578,7 +1578,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd **partial)
                 vshCommandFree(*partial);
                 *partial = c;
             } else {
-                if (!ctl->cmd)
+                VIR_UNLESS (ctl->cmd)
                     ctl->cmd = c;
                 if (clast)
                     clast->next = c;
@@ -1924,7 +1924,7 @@ vshTTYDisableInterrupt(vshControl *ctl G_GNUC_UNUSED)
 #ifndef WIN32
     struct termios termset = ctl->termattr;
 
-    if (!ctl->istty)
+    VIR_UNLESS (ctl->istty)
         return -1;
 
     /* check if we need to set the terminal */
@@ -1946,7 +1946,7 @@ int
 vshTTYRestore(vshControl *ctl G_GNUC_UNUSED)
 {
 #ifndef WIN32
-    if (!ctl->istty)
+    VIR_UNLESS (ctl->istty)
         return 0;
 
     if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &ctl->termattr) < 0)
@@ -1965,7 +1965,7 @@ vshTTYMakeRaw(vshControl *ctl G_GNUC_UNUSED,
     struct termios rawattr = ctl->termattr;
 
 
-    if (!ctl->istty) {
+    VIR_UNLESS (ctl->istty) {
         if (report_errors) {
             vshError(ctl, "%s",
                      _("unable to make terminal raw: console isn't a tty"));
@@ -2152,7 +2152,7 @@ vshEventWait(vshControl *ctl)
     assert(ctl->eventPipe[0] >= 0);
     while ((rv = read(ctl->eventPipe[0], &buf, 1)) < 0 && errno == EINTR);
     if (rv != 1) {
-        if (!rv)
+        VIR_UNLESS (rv)
             errno = EPIPE;
         vshError(ctl, _("failed to determine loop exit status: %s"),
                  g_strerror(errno));
@@ -2325,7 +2325,7 @@ vshAskReedit(vshControl *ctl, const char *msg, bool relax_avail)
 {
     int c = -1;
 
-    if (!isatty(STDIN_FILENO))
+    VIR_UNLESS (isatty(STDIN_FILENO))
         return -1;
 
     vshReportError(ctl);
@@ -2384,7 +2384,7 @@ vshAskReedit(vshControl *ctl,
 void
 vshEditUnlinkTempfile(char *file)
 {
-    if (!file)
+    VIR_UNLESS (file)
         return;
 
     ignore_value(unlink(file));
@@ -2402,7 +2402,7 @@ vshEditWriteToTempFile(vshControl *ctl, const char *doc)
     VIR_AUTOCLOSE fd = -1;
 
     tmpdir = getenv("TMPDIR");
-    if (!tmpdir)
+    VIR_UNLESS (tmpdir)
         tmpdir = "/tmp";
     filename = g_strdup_printf("%s/virshXXXXXX.xml", tmpdir);
     fd = g_mkstemp_full(filename, O_RDWR | O_CLOEXEC, S_IRUSR | S_IWUSR);
@@ -2446,9 +2446,9 @@ vshEditFile(vshControl *ctl, const char *filename)
     int errfd = STDERR_FILENO;
 
     editor = getenv("VISUAL");
-    if (!editor)
+    VIR_UNLESS (editor)
         editor = getenv("EDITOR");
-    if (!editor)
+    VIR_UNLESS (editor)
         editor = DEFAULT_EDITOR;
 
     /* Check that filename doesn't contain shell meta-characters, and
@@ -2520,7 +2520,7 @@ vshTreePrintInternal(vshControl *ctl,
              root ? "" : "+- ", dev);
 
     /* Update indent to show '|' or ' ' for child devices */
-    if (!root) {
+    VIR_UNLESS (root) {
         virBufferAddChar(indent, devid == lastdev ? ' ' : '|');
         virBufferAddChar(indent, ' ');
     }
@@ -2555,7 +2555,7 @@ vshTreePrintInternal(vshControl *ctl,
     if (nextlastdev == -1 && devid == lastdev)
         vshPrint(ctl, "%s\n", virBufferCurrentContent(indent));
 
-    if (!root)
+    VIR_UNLESS (root)
         virBufferTrimLen(indent, 2);
 
     return 0;
@@ -2634,10 +2634,10 @@ vshReadlineOptionsGenerator(const vshCmdDef *cmd,
     size_t ret_size = 0;
     g_auto(GStrv) ret = NULL;
 
-    if (!cmd)
+    VIR_UNLESS (cmd)
         return NULL;
 
-    if (!cmd->opts)
+    VIR_UNLESS (cmd->opts)
         return NULL;
 
     for (list_index = 0; cmd->opts[list_index].name; list_index++) {
@@ -2710,7 +2710,7 @@ vshCompleterFilter(char ***list,
     newList = g_new0(char *, list_len + 1);
 
     for (i = 0; i < list_len; i++) {
-        if (!STRPREFIX((*list)[i], text)) {
+        VIR_UNLESS (STRPREFIX((*list)[i], text)) {
             g_clear_pointer(&(*list)[i], g_free);
             continue;
         }
@@ -2737,7 +2737,7 @@ vshReadlineParse(const char *text, int state)
      * the very first call @state is zero which means we should
      * initialize those static variables above. On subsequent
      * calls @state is non zero. */
-    if (!state) {
+    VIR_UNLESS (state) {
         g_autoptr(vshCmd) partial = NULL;
         const vshCmdDef *cmd = NULL;
         const vshCmdOptDef *opt = NULL;
@@ -2768,7 +2768,7 @@ vshReadlineParse(const char *text, int state)
 
         opt = vshReadlineCommandFindOpt(partial);
 
-        if (!cmd) {
+        VIR_UNLESS (cmd) {
             list = vshReadlineCommandGenerator();
         } else if (!opt || opt->type == VSH_OT_BOOL) {
             list = vshReadlineOptionsGenerator(cmd, partial);
@@ -2808,7 +2808,7 @@ vshReadlineParse(const char *text, int state)
     }
 
  cleanup:
-    if (!ret) {
+    VIR_UNLESS (ret) {
         g_clear_pointer(&list, g_strfreev);
         list_index = 0;
     }
@@ -3007,7 +3007,7 @@ vshInitDebug(vshControl *ctl)
 bool
 vshInit(vshControl *ctl, const vshCmdGrp *groups, const vshCmdDef *set)
 {
-    if (!ctl->hooks) {
+    VIR_UNLESS (ctl->hooks) {
         vshError(ctl, "%s", _("client hooks cannot be NULL"));
         return false;
     }
@@ -3155,14 +3155,14 @@ cmdCd(vshControl *ctl, const vshCmd *cmd)
     const char *dir = NULL;
     g_autofree char *dir_malloced = NULL;
 
-    if (!ctl->imode) {
+    VIR_UNLESS (ctl->imode) {
         vshError(ctl, "%s", _("cd: command valid only in interactive mode"));
         return false;
     }
 
     if (vshCommandOptStringQuiet(ctl, cmd, "dir", &dir) <= 0)
         dir = dir_malloced = virGetUserDirectory();
-    if (!dir)
+    VIR_UNLESS (dir)
         dir = "/";
 
     if (chdir(dir) == -1) {
@@ -3399,14 +3399,14 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd)
 
     vshReadlineInit(ctl);
 
-    if (!(rl_line_buffer = virBufferContentAndReset(&buf)))
+    VIR_UNLESS ((rl_line_buffer = virBufferContentAndReset(&buf)))
         rl_line_buffer = g_strdup("");
 
     /* rl_point is current cursor position in rl_line_buffer.
      * In our case it's at the end of the whole line. */
     rl_point = strlen(rl_line_buffer);
 
-    if (!(matches = vshReadlineCompletion(arg, 0, 0)))
+    VIR_UNLESS ((matches = vshReadlineCompletion(arg, 0, 0)))
         return false;
 
     for (iter = matches; *iter; iter++) {
-- 
2.34.1




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

  Powered by Linux