[PATCH 03/13] tools: apply s/vshX/virshX to all virsh specific data

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

 



Since majority of virsh methods should be generic enough to be used by
other clients, it's much easier to rename virsh specific data to virshX
than doing this vice versa.
---
 tools/virsh-console.c        |  12 +-
 tools/virsh-console.h        |   8 +-
 tools/virsh-domain-monitor.c | 178 +++++++++---------
 tools/virsh-domain-monitor.h |   4 +-
 tools/virsh-domain.c         | 434 +++++++++++++++++++++----------------------
 tools/virsh-domain.h         |  14 +-
 tools/virsh-edit.c           |   8 +-
 tools/virsh-host.c           |  53 +++---
 tools/virsh-interface.c      |  34 ++--
 tools/virsh-interface.h      |  12 +-
 tools/virsh-network.c        |  36 ++--
 tools/virsh-network.h        |  10 +-
 tools/virsh-nodedev.c        |   6 +-
 tools/virsh-nwfilter.c       |  12 +-
 tools/virsh-nwfilter.h       |  10 +-
 tools/virsh-pool.c           |  60 +++---
 tools/virsh-pool.h           |  10 +-
 tools/virsh-secret.c         |  12 +-
 tools/virsh-snapshot.c       |  50 ++---
 tools/virsh-volume.c         |  86 ++++-----
 tools/virsh-volume.h         |  14 +-
 tools/virsh.c                | 302 ++++++++++--------------------
 tools/virsh.h                |  34 ++--
 tools/vsh.c                  |   4 +-
 tools/vsh.h                  |   1 +
 25 files changed, 654 insertions(+), 750 deletions(-)

diff --git a/tools/virsh-console.c b/tools/virsh-console.c
index f0faf8c..86ba456 100644
--- a/tools/virsh-console.c
+++ b/tools/virsh-console.c
@@ -295,7 +295,7 @@ virConsoleEventOnStdout(int watch ATTRIBUTE_UNUSED,
 
 
 static char
-vshGetEscapeChar(const char *s)
+virshGetEscapeChar(const char *s)
 {
     if (*s == '^')
         return CONTROL(c_toupper(s[1]));
@@ -305,10 +305,10 @@ vshGetEscapeChar(const char *s)
 
 
 int
-vshRunConsole(vshControl *ctl,
-              virDomainPtr dom,
-              const char *dev_name,
-              unsigned int flags)
+virshRunConsole(vshControl *ctl,
+                virDomainPtr dom,
+                const char *dev_name,
+                unsigned int flags)
 {
     virConsolePtr con = NULL;
     int ret = -1;
@@ -341,7 +341,7 @@ vshRunConsole(vshControl *ctl,
     if (VIR_ALLOC(con) < 0)
         goto cleanup;
 
-    con->escapeChar = vshGetEscapeChar(ctl->escapeChar);
+    con->escapeChar = virshGetEscapeChar(ctl->escapeChar);
     con->st = virStreamNew(virDomainGetConnect(dom),
                            VIR_STREAM_NONBLOCK);
     if (!con->st)
diff --git a/tools/virsh-console.h b/tools/virsh-console.h
index 5b82e28..598d353 100644
--- a/tools/virsh-console.h
+++ b/tools/virsh-console.h
@@ -28,10 +28,10 @@
 
 #  include <virsh.h>
 
-int vshRunConsole(vshControl *ctl,
-                  virDomainPtr dom,
-                  const char *dev_name,
-                  unsigned int flags);
+int virshRunConsole(vshControl *ctl,
+                    virDomainPtr dom,
+                    const char *dev_name,
+                    unsigned int flags);
 
 # endif /* !WIN32 */
 
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 1d4dc25..1f53428 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -40,24 +40,24 @@
 #include "virxml.h"
 #include "virstring.h"
 
-VIR_ENUM_DECL(vshDomainIOError)
-VIR_ENUM_IMPL(vshDomainIOError,
+VIR_ENUM_DECL(virshDomainIOError)
+VIR_ENUM_IMPL(virshDomainIOError,
               VIR_DOMAIN_DISK_ERROR_LAST,
               N_("no error"),
               N_("unspecified error"),
               N_("no space"))
 
 static const char *
-vshDomainIOErrorToString(int error)
+virshDomainIOErrorToString(int error)
 {
-    const char *str = vshDomainIOErrorTypeToString(error);
+    const char *str = virshDomainIOErrorTypeToString(error);
     return str ? _(str) : _("unknown error");
 }
 
 /* extract description or title from domain xml */
 char *
-vshGetDomainDescription(vshControl *ctl, virDomainPtr dom, bool title,
-                        unsigned int flags)
+virshGetDomainDescription(vshControl *ctl, virDomainPtr dom, bool title,
+                          unsigned int flags)
 {
     char *desc = NULL;
     char *domxml = NULL;
@@ -113,8 +113,8 @@ vshGetDomainDescription(vshControl *ctl, virDomainPtr dom, bool title,
     return desc;
 }
 
-VIR_ENUM_DECL(vshDomainControlState)
-VIR_ENUM_IMPL(vshDomainControlState,
+VIR_ENUM_DECL(virshDomainControlState)
+VIR_ENUM_IMPL(virshDomainControlState,
               VIR_DOMAIN_CONTROL_LAST,
               N_("ok"),
               N_("background job"),
@@ -122,14 +122,14 @@ VIR_ENUM_IMPL(vshDomainControlState,
               N_("error"))
 
 static const char *
-vshDomainControlStateToString(int state)
+virshDomainControlStateToString(int state)
 {
-    const char *str = vshDomainControlStateTypeToString(state);
+    const char *str = virshDomainControlStateTypeToString(state);
     return str ? _(str) : _("unknown");
 }
 
-VIR_ENUM_DECL(vshDomainControlErrorReason)
-VIR_ENUM_IMPL(vshDomainControlErrorReason,
+VIR_ENUM_DECL(virshDomainControlErrorReason)
+VIR_ENUM_IMPL(virshDomainControlErrorReason,
               VIR_DOMAIN_CONTROL_ERROR_REASON_LAST,
               "",
               N_("unknown"),
@@ -137,14 +137,14 @@ VIR_ENUM_IMPL(vshDomainControlErrorReason,
               N_("internal (locking) error"))
 
 static const char *
-vshDomainControlErrorReasonToString(int reason)
+virshDomainControlErrorReasonToString(int reason)
 {
-    const char *ret = vshDomainControlErrorReasonTypeToString(reason);
+    const char *ret = virshDomainControlErrorReasonTypeToString(reason);
     return ret ? _(ret) : _("unknown");
 }
 
-VIR_ENUM_DECL(vshDomainState)
-VIR_ENUM_IMPL(vshDomainState,
+VIR_ENUM_DECL(virshDomainState)
+VIR_ENUM_IMPL(virshDomainState,
               VIR_DOMAIN_LAST,
               N_("no state"),
               N_("running"),
@@ -156,19 +156,19 @@ VIR_ENUM_IMPL(vshDomainState,
               N_("pmsuspended"))
 
 static const char *
-vshDomainStateToString(int state)
+virshDomainStateToString(int state)
 {
-    const char *str = vshDomainStateTypeToString(state);
+    const char *str = virshDomainStateTypeToString(state);
     return str ? _(str) : _("no state");
 }
 
-VIR_ENUM_DECL(vshDomainNostateReason)
-VIR_ENUM_IMPL(vshDomainNostateReason,
+VIR_ENUM_DECL(virshDomainNostateReason)
+VIR_ENUM_IMPL(virshDomainNostateReason,
               VIR_DOMAIN_NOSTATE_LAST,
               N_("unknown"))
 
-VIR_ENUM_DECL(vshDomainRunningReason)
-VIR_ENUM_IMPL(vshDomainRunningReason,
+VIR_ENUM_DECL(virshDomainRunningReason)
+VIR_ENUM_IMPL(virshDomainRunningReason,
               VIR_DOMAIN_RUNNING_LAST,
               N_("unknown"),
               N_("booted"),
@@ -181,13 +181,13 @@ VIR_ENUM_IMPL(vshDomainRunningReason,
               N_("event wakeup"),
               N_("crashed"))
 
-VIR_ENUM_DECL(vshDomainBlockedReason)
-VIR_ENUM_IMPL(vshDomainBlockedReason,
+VIR_ENUM_DECL(virshDomainBlockedReason)
+VIR_ENUM_IMPL(virshDomainBlockedReason,
               VIR_DOMAIN_BLOCKED_LAST,
               N_("unknown"))
 
-VIR_ENUM_DECL(vshDomainPausedReason)
-VIR_ENUM_IMPL(vshDomainPausedReason,
+VIR_ENUM_DECL(virshDomainPausedReason)
+VIR_ENUM_IMPL(virshDomainPausedReason,
               VIR_DOMAIN_PAUSED_LAST,
               N_("unknown"),
               N_("user"),
@@ -202,14 +202,14 @@ VIR_ENUM_IMPL(vshDomainPausedReason,
               N_("crashed"),
               N_("starting up"))
 
-VIR_ENUM_DECL(vshDomainShutdownReason)
-VIR_ENUM_IMPL(vshDomainShutdownReason,
+VIR_ENUM_DECL(virshDomainShutdownReason)
+VIR_ENUM_IMPL(virshDomainShutdownReason,
               VIR_DOMAIN_SHUTDOWN_LAST,
               N_("unknown"),
               N_("user"))
 
-VIR_ENUM_DECL(vshDomainShutoffReason)
-VIR_ENUM_IMPL(vshDomainShutoffReason,
+VIR_ENUM_DECL(virshDomainShutoffReason)
+VIR_ENUM_IMPL(virshDomainShutoffReason,
               VIR_DOMAIN_SHUTOFF_LAST,
               N_("unknown"),
               N_("shutdown"),
@@ -220,45 +220,45 @@ VIR_ENUM_IMPL(vshDomainShutoffReason,
               N_("failed"),
               N_("from snapshot"))
 
-VIR_ENUM_DECL(vshDomainCrashedReason)
-VIR_ENUM_IMPL(vshDomainCrashedReason,
+VIR_ENUM_DECL(virshDomainCrashedReason)
+VIR_ENUM_IMPL(virshDomainCrashedReason,
               VIR_DOMAIN_CRASHED_LAST,
               N_("unknown"),
               N_("panicked"))
 
-VIR_ENUM_DECL(vshDomainPMSuspendedReason)
-VIR_ENUM_IMPL(vshDomainPMSuspendedReason,
+VIR_ENUM_DECL(virshDomainPMSuspendedReason)
+VIR_ENUM_IMPL(virshDomainPMSuspendedReason,
               VIR_DOMAIN_PMSUSPENDED_LAST,
               N_("unknown"))
 
 static const char *
-vshDomainStateReasonToString(int state, int reason)
+virshDomainStateReasonToString(int state, int reason)
 {
     const char *str = NULL;
     switch ((virDomainState) state) {
     case VIR_DOMAIN_NOSTATE:
-        str = vshDomainNostateReasonTypeToString(reason);
+        str = virshDomainNostateReasonTypeToString(reason);
         break;
     case VIR_DOMAIN_RUNNING:
-        str = vshDomainRunningReasonTypeToString(reason);
+        str = virshDomainRunningReasonTypeToString(reason);
         break;
     case VIR_DOMAIN_BLOCKED:
-        str = vshDomainBlockedReasonTypeToString(reason);
+        str = virshDomainBlockedReasonTypeToString(reason);
         break;
     case VIR_DOMAIN_PAUSED:
-        str = vshDomainPausedReasonTypeToString(reason);
+        str = virshDomainPausedReasonTypeToString(reason);
         break;
     case VIR_DOMAIN_SHUTDOWN:
-        str = vshDomainShutdownReasonTypeToString(reason);
+        str = virshDomainShutdownReasonTypeToString(reason);
         break;
     case VIR_DOMAIN_SHUTOFF:
-        str = vshDomainShutoffReasonTypeToString(reason);
+        str = virshDomainShutoffReasonTypeToString(reason);
         break;
     case VIR_DOMAIN_CRASHED:
-        str = vshDomainCrashedReasonTypeToString(reason);
+        str = virshDomainCrashedReasonTypeToString(reason);
         break;
     case VIR_DOMAIN_PMSUSPENDED:
-        str = vshDomainPMSuspendedReasonTypeToString(reason);
+        str = virshDomainPMSuspendedReasonTypeToString(reason);
         break;
     case VIR_DOMAIN_LAST:
         ;
@@ -329,7 +329,7 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     /* If none of the options were specified and we're active
@@ -423,7 +423,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
     bool ret = false;
     const char *device = NULL;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "device", &device) < 0)
@@ -492,7 +492,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
 
     details = vshCommandOptBool(cmd, "details");
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     xml = virDomainGetXMLDesc(dom, flags);
@@ -608,7 +608,7 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "inactive"))
         flags |= VIR_DOMAIN_XML_INACTIVE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     xml = virDomainGetXMLDesc(dom, flags);
@@ -726,7 +726,7 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "interface", &iface) < 0)
         return false;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptBool(cmd, "config"))
@@ -815,7 +815,7 @@ cmdDomControl(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     virDomainControlInfo info;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (virDomainGetControlInfo(dom, &info, 0) < 0) {
@@ -826,15 +826,15 @@ cmdDomControl(vshControl *ctl, const vshCmd *cmd)
     if (info.state != VIR_DOMAIN_CONTROL_OK &&
         info.state != VIR_DOMAIN_CONTROL_ERROR) {
         vshPrint(ctl, "%s (%0.3fs)\n",
-                 vshDomainControlStateToString(info.state),
+                 virshDomainControlStateToString(info.state),
                  info.stateTime / 1000.0);
     } else if (info.state == VIR_DOMAIN_CONTROL_ERROR && info.details > 0) {
         vshPrint(ctl, "%s: %s\n",
-                 vshDomainControlStateToString(info.state),
-                 vshDomainControlErrorReasonToString(info.details));
+                 virshDomainControlStateToString(info.state),
+                 virshDomainControlErrorReasonToString(info.details));
     } else {
         vshPrint(ctl, "%s\n",
-                 vshDomainControlStateToString(info.state));
+                 virshDomainControlStateToString(info.state));
     }
 
  cleanup:
@@ -927,7 +927,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
     bool ret = false;
     bool human = vshCommandOptBool(cmd, "human"); /* human readable output */
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     /* device argument is optional now. if it's missing, supply empty
@@ -1068,7 +1068,7 @@ cmdDomIfstat(vshControl *ctl, const vshCmd *cmd)
     virDomainInterfaceStatsStruct stats;
     bool ret = false;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "interface", &device) < 0)
@@ -1142,7 +1142,7 @@ cmdDomBlkError(vshControl *ctl, const vshCmd *cmd)
     int count;
     bool ret = false;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if ((count = virDomainGetDiskErrors(dom, NULL, 0, 0)) < 0)
@@ -1163,7 +1163,7 @@ cmdDomBlkError(vshControl *ctl, const vshCmd *cmd)
         for (i = 0; i < count; i++) {
             vshPrint(ctl, "%s: %s\n",
                      disks[i].disk,
-                     vshDomainIOErrorToString(disks[i].error));
+                     virshDomainIOErrorToString(disks[i].error));
         }
     }
 
@@ -1211,7 +1211,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
     char *str, uuid[VIR_UUID_STRING_BUFLEN];
     int has_managed_save = 0;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     id = virDomainGetID(dom);
@@ -1231,7 +1231,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
 
     if (virDomainGetInfo(dom, &info) == 0) {
         vshPrint(ctl, "%-15s %s\n", _("State:"),
-                 vshDomainStateToString(info.state));
+                 virshDomainStateToString(info.state));
 
         vshPrint(ctl, "%-15s %d\n", _("CPU(s):"), info.nrVirtCpu);
 
@@ -1351,21 +1351,21 @@ cmdDomstate(vshControl *ctl, const vshCmd *cmd)
     bool showReason = vshCommandOptBool(cmd, "reason");
     int state, reason;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
-    if ((state = vshDomainState(ctl, dom, &reason)) < 0) {
+    if ((state = virshDomainState(ctl, dom, &reason)) < 0) {
         ret = false;
         goto cleanup;
     }
 
     if (showReason) {
         vshPrint(ctl, "%s (%s)\n",
-                 vshDomainStateToString(state),
-                 vshDomainStateReasonToString(state, reason));
+                 virshDomainStateToString(state),
+                 virshDomainStateReasonToString(state, reason));
     } else {
         vshPrint(ctl, "%s\n",
-                 vshDomainStateToString(state));
+                 virshDomainStateToString(state));
     }
 
  cleanup:
@@ -1429,7 +1429,7 @@ cmdDomTime(vshControl *ctl, const vshCmd *cmd)
     VSH_EXCLUSIVE_OPTIONS("time", "sync");
     VSH_EXCLUSIVE_OPTIONS("now", "sync");
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     rv = vshCommandOptLongLong(ctl, cmd, "time", &seconds);
@@ -1496,7 +1496,7 @@ static const vshCmdInfo info_list[] = {
 
 /* compare domains, pack NULLed ones at the end*/
 static int
-vshDomainSorter(const void *a, const void *b)
+virshDomainSorter(const void *a, const void *b)
 {
     virDomainPtr *da = (virDomainPtr *) a;
     virDomainPtr *db = (virDomainPtr *) b;
@@ -1529,14 +1529,14 @@ vshDomainSorter(const void *a, const void *b)
         return 1;
 }
 
-struct vshDomainList {
+struct virshDomainList {
     virDomainPtr *domains;
     size_t ndomains;
 };
-typedef struct vshDomainList *vshDomainListPtr;
+typedef struct virshDomainList *virshDomainListPtr;
 
 static void
-vshDomainListFree(vshDomainListPtr domlist)
+virshDomainListFree(virshDomainListPtr domlist)
 {
     size_t i;
 
@@ -1550,10 +1550,10 @@ vshDomainListFree(vshDomainListPtr domlist)
     VIR_FREE(domlist);
 }
 
-static vshDomainListPtr
-vshDomainListCollect(vshControl *ctl, unsigned int flags)
+static virshDomainListPtr
+virshDomainListCollect(vshControl *ctl, unsigned int flags)
 {
-    vshDomainListPtr list = vshMalloc(ctl, sizeof(*list));
+    virshDomainListPtr list = vshMalloc(ctl, sizeof(*list));
     size_t i;
     int ret;
     int *ids = NULL;
@@ -1747,7 +1747,7 @@ vshDomainListCollect(vshControl *ctl, unsigned int flags)
     /* sort the list */
     if (list->domains && list->ndomains)
         qsort(list->domains, list->ndomains, sizeof(*list->domains),
-              vshDomainSorter);
+              virshDomainSorter);
 
     /* truncate the list if filter simulation deleted entries */
     if (deleted)
@@ -1760,7 +1760,7 @@ vshDomainListCollect(vshControl *ctl, unsigned int flags)
         VIR_FREE(names[i]);
 
     if (!success) {
-        vshDomainListFree(list);
+        virshDomainListFree(list);
         list = NULL;
     }
 
@@ -1865,7 +1865,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
     char uuid[VIR_UUID_STRING_BUFLEN];
     int state;
     bool ret = false;
-    vshDomainListPtr list = NULL;
+    virshDomainListPtr list = NULL;
     virDomainPtr dom;
     char id_buf[INT_BUFSIZE_BOUND(unsigned int)];
     unsigned int id;
@@ -1906,7 +1906,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
     if (!optUUID && !optName)
         optTable = true;
 
-    if (!(list = vshDomainListCollect(ctl, flags)))
+    if (!(list = virshDomainListCollect(ctl, flags)))
         goto cleanup;
 
     /* print table header in legacy mode */
@@ -1931,7 +1931,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
         else
             ignore_value(virStrcpyStatic(id_buf, "-"));
 
-        state = vshDomainState(ctl, dom, NULL);
+        state = virshDomainState(ctl, dom, NULL);
 
         /* Domain could've been removed in the meantime */
         if (state < 0)
@@ -1943,19 +1943,21 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
 
         if (optTable) {
             if (optTitle) {
-                if (!(title = vshGetDomainDescription(ctl, dom, true, 0)))
+                if (!(title = virshGetDomainDescription(ctl, dom, true, 0)))
                     goto cleanup;
 
                 vshPrint(ctl, " %-5s %-30s %-10s %-20s\n", id_buf,
                          virDomainGetName(dom),
-                         state == -2 ? _("saved") : vshDomainStateToString(state),
+                         state == -2 ? _("saved")
+                         : virshDomainStateToString(state),
                          title);
 
                 VIR_FREE(title);
             } else {
                 vshPrint(ctl, " %-5s %-30s %s\n", id_buf,
                          virDomainGetName(dom),
-                         state == -2 ? _("saved") : vshDomainStateToString(state));
+                         state == -2 ? _("saved")
+                         : virshDomainStateToString(state));
             }
         } else if (optUUID) {
             if (virDomainGetUUIDString(dom, uuid) < 0) {
@@ -1970,7 +1972,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
 
     ret = true;
  cleanup:
-    vshDomainListFree(list);
+    virshDomainListFree(list);
     return ret;
 }
 #undef FILTER
@@ -2067,9 +2069,9 @@ static const vshCmdOptDef opts_domstats[] = {
 
 
 static bool
-vshDomainStatsPrintRecord(vshControl *ctl ATTRIBUTE_UNUSED,
-                          virDomainStatsRecordPtr record,
-                          bool raw ATTRIBUTE_UNUSED)
+virshDomainStatsPrintRecord(vshControl *ctl ATTRIBUTE_UNUSED,
+                            virDomainStatsRecordPtr record,
+                            bool raw ATTRIBUTE_UNUSED)
 {
     char *param;
     size_t i;
@@ -2159,8 +2161,8 @@ cmdDomstats(vshControl *ctl, const vshCmd *cmd)
         ndoms = 1;
 
         while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
-            if (!(dom = vshLookupDomainBy(ctl, opt->data,
-                                          VSH_BYID | VSH_BYUUID | VSH_BYNAME)))
+            if (!(dom = virshLookupDomainBy(ctl, opt->data,
+                                            VSH_BYID | VSH_BYUUID | VSH_BYNAME)))
                 goto cleanup;
 
             if (VIR_INSERT_ELEMENT(domlist, ndoms - 1, ndoms, dom) < 0)
@@ -2181,7 +2183,7 @@ cmdDomstats(vshControl *ctl, const vshCmd *cmd)
     }
 
     for (next = records; *next; next++) {
-        if (!vshDomainStatsPrintRecord(ctl, *next, raw))
+        if (!virshDomainStatsPrintRecord(ctl, *next, raw))
             goto cleanup;
     }
 
@@ -2234,7 +2236,7 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
     const char *sourcestr = NULL;
     int source = VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptString(ctl, cmd, "interface", &ifacestr) < 0)
diff --git a/tools/virsh-domain-monitor.h b/tools/virsh-domain-monitor.h
index 9df3a8c..08ccab5 100644
--- a/tools/virsh-domain-monitor.h
+++ b/tools/virsh-domain-monitor.h
@@ -28,8 +28,8 @@
 
 # include "virsh.h"
 
-char *vshGetDomainDescription(vshControl *ctl, virDomainPtr dom,
-                              bool title, unsigned int flags)
+char *virshGetDomainDescription(vshControl *ctl, virDomainPtr dom,
+                                bool title, unsigned int flags)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
 
 extern const vshCmdDef domMonitoringCmds[];
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 27d62e9..bf53a24 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -63,10 +63,10 @@
 
 
 static virDomainPtr
-vshLookupDomainInternal(vshControl *ctl,
-                        const char *cmdname,
-                        const char *name,
-                        unsigned int flags)
+virshLookupDomainInternal(vshControl *ctl,
+                          const char *cmdname,
+                          const char *name,
+                          unsigned int flags)
 {
     virDomainPtr dom = NULL;
     int id;
@@ -104,17 +104,17 @@ vshLookupDomainInternal(vshControl *ctl,
 
 
 virDomainPtr
-vshLookupDomainBy(vshControl *ctl,
+virshLookupDomainBy(vshControl *ctl,
                   const char *name,
                   unsigned int flags)
 {
-    return vshLookupDomainInternal(ctl, "unknown", name, flags);
+    return virshLookupDomainInternal(ctl, "unknown", name, flags);
 }
 
 
 virDomainPtr
-vshCommandOptDomainBy(vshControl *ctl, const vshCmd *cmd,
-                      const char **name, unsigned int flags)
+virshCommandOptDomainBy(vshControl *ctl, const vshCmd *cmd,
+                        const char **name, unsigned int flags)
 {
     const char *n = NULL;
     const char *optname = "domain";
@@ -128,11 +128,11 @@ vshCommandOptDomainBy(vshControl *ctl, const vshCmd *cmd,
     if (name)
         *name = n;
 
-    return vshLookupDomainInternal(ctl, cmd->def->name, n, flags);
+    return virshLookupDomainInternal(ctl, cmd->def->name, n, flags);
 }
 
 static virDomainPtr
-vshDomainDefine(virConnectPtr conn, const char *xml, unsigned int flags)
+virshDomainDefine(virConnectPtr conn, const char *xml, unsigned int flags)
 {
     virDomainPtr dom;
     if (flags) {
@@ -153,17 +153,17 @@ vshDomainDefine(virConnectPtr conn, const char *xml, unsigned int flags)
     return dom;
 }
 
-VIR_ENUM_DECL(vshDomainVcpuState)
-VIR_ENUM_IMPL(vshDomainVcpuState,
+VIR_ENUM_DECL(virshDomainVcpuState)
+VIR_ENUM_IMPL(virshDomainVcpuState,
               VIR_VCPU_LAST,
               N_("offline"),
               N_("running"),
               N_("blocked"))
 
 static const char *
-vshDomainVcpuStateToString(int state)
+virshDomainVcpuStateToString(int state)
 {
-    const char *str = vshDomainVcpuStateTypeToString(state);
+    const char *str = virshDomainVcpuStateTypeToString(state);
     return str ? _(str) : _("no state");
 }
 
@@ -173,7 +173,7 @@ vshDomainVcpuStateToString(int state)
  * if needed.
  */
 static int
-vshNodeGetCPUCount(virConnectPtr conn)
+virshNodeGetCPUCount(virConnectPtr conn)
 {
     int ret;
     virNodeInfo nodeinfo;
@@ -254,7 +254,7 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
@@ -264,7 +264,7 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
         virDomainIsActive(dom) == 1)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {
+    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
         vshReportError(ctl);
         goto cleanup;
     }
@@ -762,7 +762,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
     }
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         goto cleanup;
 
     if (persistent &&
@@ -925,7 +925,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (persistent &&
@@ -1095,7 +1095,7 @@ cmdAutostart(vshControl *ctl, const vshCmd *cmd)
     const char *name;
     int autostart;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     autostart = !vshCommandOptBool(cmd, "disable");
@@ -1286,7 +1286,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         goto cleanup;
 
     if (vshCommandOptStringReq(ctl, cmd, "device", &disk) < 0)
@@ -1548,7 +1548,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if ((rv = vshCommandOptInt(ctl, cmd, "weight", &weight)) < 0) {
@@ -1665,15 +1665,15 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
 }
 
 typedef enum {
-    VSH_CMD_BLOCK_JOB_ABORT,
-    VSH_CMD_BLOCK_JOB_SPEED,
-    VSH_CMD_BLOCK_JOB_PULL,
-    VSH_CMD_BLOCK_JOB_COMMIT,
-} vshCmdBlockJobMode;
+    VIRSH_CMD_BLOCK_JOB_ABORT,
+    VIRSH_CMD_BLOCK_JOB_SPEED,
+    VIRSH_CMD_BLOCK_JOB_PULL,
+    VIRSH_CMD_BLOCK_JOB_COMMIT,
+} virshCmdBlockJobMode;
 
 static bool
 blockJobImpl(vshControl *ctl, const vshCmd *cmd,
-             vshCmdBlockJobMode mode, virDomainPtr *pdom)
+             virshCmdBlockJobMode mode, virDomainPtr *pdom)
 {
     virDomainPtr dom = NULL;
     const char *path;
@@ -1683,7 +1683,7 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
     const char *top = NULL;
     unsigned int flags = 0;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         goto cleanup;
 
     if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0)
@@ -1693,7 +1693,7 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
         goto cleanup;
 
     switch (mode) {
-    case VSH_CMD_BLOCK_JOB_ABORT:
+    case VIRSH_CMD_BLOCK_JOB_ABORT:
         if (vshCommandOptBool(cmd, "async"))
             flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC;
         if (vshCommandOptBool(cmd, "pivot"))
@@ -1701,11 +1701,11 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
         if (virDomainBlockJobAbort(dom, path, flags) < 0)
             goto cleanup;
         break;
-    case VSH_CMD_BLOCK_JOB_SPEED:
+    case VIRSH_CMD_BLOCK_JOB_SPEED:
         if (virDomainBlockJobSetSpeed(dom, path, bandwidth, 0) < 0)
             goto cleanup;
         break;
-    case VSH_CMD_BLOCK_JOB_PULL:
+    case VIRSH_CMD_BLOCK_JOB_PULL:
         if (vshCommandOptStringReq(ctl, cmd, "base", &base) < 0)
             goto cleanup;
         if (vshCommandOptBool(cmd, "keep-relative"))
@@ -1720,7 +1720,7 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
         }
 
         break;
-    case VSH_CMD_BLOCK_JOB_COMMIT:
+    case VIRSH_CMD_BLOCK_JOB_COMMIT:
         if (vshCommandOptStringReq(ctl, cmd, "base", &base) < 0 ||
             vshCommandOptStringReq(ctl, cmd, "top", &top) < 0)
             goto cleanup;
@@ -1750,8 +1750,8 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
 }
 
 static void
-vshPrintJobProgress(const char *label, unsigned long long remaining,
-                    unsigned long long total)
+virshPrintJobProgress(const char *label, unsigned long long remaining,
+                      unsigned long long total)
 {
     int progress;
 
@@ -1787,12 +1787,12 @@ static void vshCatchInt(int sig ATTRIBUTE_UNUSED,
 }
 
 static void
-vshBlockJobStatusHandler(virConnectPtr conn ATTRIBUTE_UNUSED,
-                         virDomainPtr dom ATTRIBUTE_UNUSED,
-                         const char *disk ATTRIBUTE_UNUSED,
-                         int type ATTRIBUTE_UNUSED,
-                         int status,
-                         void *opaque)
+virshBlockJobStatusHandler(virConnectPtr conn ATTRIBUTE_UNUSED,
+                           virDomainPtr dom ATTRIBUTE_UNUSED,
+                           const char *disk ATTRIBUTE_UNUSED,
+                           int type ATTRIBUTE_UNUSED,
+                           int status,
+                           void *opaque)
 {
     *(int *) opaque = status;
 }
@@ -1905,7 +1905,7 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd)
             vshError(ctl, "%s", _("cannot mix --pivot and --keep-overlay"));
             return false;
         }
-        if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
+        if (virshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
             return false;
         if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0)
             return false;
@@ -1928,7 +1928,7 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd)
     }
 
     virConnectDomainEventGenericCallback cb =
-        VIR_DOMAIN_EVENT_CALLBACK(vshBlockJobStatusHandler);
+        VIR_DOMAIN_EVENT_CALLBACK(virshBlockJobStatusHandler);
 
     if ((cb_id = virConnectDomainEventRegisterAny(ctl->conn,
                                                   dom,
@@ -1938,7 +1938,7 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd)
                                                   NULL)) < 0)
         vshResetLibvirtError();
 
-    if (!blockJobImpl(ctl, cmd, VSH_CMD_BLOCK_JOB_COMMIT, &dom))
+    if (!blockJobImpl(ctl, cmd, VIRSH_CMD_BLOCK_JOB_COMMIT, &dom))
         goto cleanup;
 
     if (!blocking) {
@@ -1965,8 +1965,8 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd)
             break;
 
         if (verbose)
-            vshPrintJobProgress(_("Block Commit"),
-                                info.end - info.cur, info.end);
+            virshPrintJobProgress(_("Block Commit"),
+                                  info.end - info.cur, info.end);
         if (active && info.cur == info.end)
             break;
 
@@ -1996,7 +1996,7 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd)
 
     if (verbose && !quit) {
         /* printf [100 %] */
-        vshPrintJobProgress(_("Block Commit"), 0, 1);
+        virshPrintJobProgress(_("Block Commit"), 0, 1);
     }
     if (!quit && pivot) {
         abort_flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT;
@@ -2171,7 +2171,7 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd)
             vshError(ctl, "%s", _("cannot mix --pivot and --finish"));
             return false;
         }
-        if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
+        if (virshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
             return false;
         if (vshCommandOptBool(cmd, "async"))
             abort_flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC;
@@ -2192,7 +2192,7 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd)
     }
 
     virConnectDomainEventGenericCallback cb =
-        VIR_DOMAIN_EVENT_CALLBACK(vshBlockJobStatusHandler);
+        VIR_DOMAIN_EVENT_CALLBACK(virshBlockJobStatusHandler);
 
     if ((cb_id = virConnectDomainEventRegisterAny(ctl->conn,
                                                   dom,
@@ -2202,7 +2202,7 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd)
                                                   NULL)) < 0)
         vshResetLibvirtError();
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         goto cleanup;
 
     /* XXX: Parse bandwidth as scaled input, rather than forcing
@@ -2217,7 +2217,7 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
 
     if (xml) {
-        if (virFileReadAll(xml, VSH_MAX_XML_FILE, &xmlstr) < 0) {
+        if (virFileReadAll(xml, VIRSH_MAX_XML_FILE, &xmlstr) < 0) {
             vshReportError(ctl);
             goto cleanup;
         }
@@ -2319,7 +2319,7 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd)
         }
 
         if (verbose)
-            vshPrintJobProgress(_("Block Copy"), info.end - info.cur, info.end);
+            virshPrintJobProgress(_("Block Copy"), info.end - info.cur, info.end);
         if (info.cur == info.end)
             break;
 
@@ -2481,12 +2481,12 @@ cmdBlockJob(vshControl *ctl, const vshCmd *cmd)
     }
 
     if (abortMode)
-        return blockJobImpl(ctl, cmd, VSH_CMD_BLOCK_JOB_ABORT, NULL);
+        return blockJobImpl(ctl, cmd, VIRSH_CMD_BLOCK_JOB_ABORT, NULL);
     if (bandwidth)
-        return blockJobImpl(ctl, cmd, VSH_CMD_BLOCK_JOB_SPEED, NULL);
+        return blockJobImpl(ctl, cmd, VIRSH_CMD_BLOCK_JOB_SPEED, NULL);
 
     /* Everything below here is for --info mode */
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         goto cleanup;
 
     /* XXX Allow path to be optional to list info on all devices at once */
@@ -2546,11 +2546,11 @@ cmdBlockJob(vshControl *ctl, const vshCmd *cmd)
                  vshDomainBlockJobTypeToString(info.type),
                  info.bandwidth, info.cur, info.end);
     } else {
-        vshPrintJobProgress(vshDomainBlockJobToString(info.type),
-                            info.end - info.cur, info.end);
+        virshPrintJobProgress(vshDomainBlockJobToString(info.type),
+                              info.end - info.cur, info.end);
         if (speed) {
             const char *unit;
-            double val = vshPrettyCapacity(speed, &unit);
+            double val = virshPrettyCapacity(speed, &unit);
             vshPrint(ctl, _("    Bandwidth limit: %llu bytes/s (%-.3lf %s/s)"),
                      speed, val, unit);
         }
@@ -2638,7 +2638,7 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
     int cb_id = -1;
 
     if (blocking) {
-        if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
+        if (virshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
             return false;
         if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0)
             return false;
@@ -2662,7 +2662,7 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
     }
 
     virConnectDomainEventGenericCallback cb =
-        VIR_DOMAIN_EVENT_CALLBACK(vshBlockJobStatusHandler);
+        VIR_DOMAIN_EVENT_CALLBACK(virshBlockJobStatusHandler);
 
     if ((cb_id = virConnectDomainEventRegisterAny(ctl->conn,
                                                   dom,
@@ -2672,7 +2672,7 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
                                                   NULL)) < 0)
         vshResetLibvirtError();
 
-    if (!blockJobImpl(ctl, cmd, VSH_CMD_BLOCK_JOB_PULL, &dom))
+    if (!blockJobImpl(ctl, cmd, VIRSH_CMD_BLOCK_JOB_PULL, &dom))
         goto cleanup;
 
     if (!blocking) {
@@ -2697,7 +2697,7 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
             break;
 
         if (verbose)
-            vshPrintJobProgress(_("Block Pull"), info.end - info.cur, info.end);
+            virshPrintJobProgress(_("Block Pull"), info.end - info.cur, info.end);
 
         GETTIMEOFDAY(&curr);
         if (intCaught || (timeout &&
@@ -2725,7 +2725,7 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
 
     if (verbose && !quit) {
         /* printf [100 %] */
-        vshPrintJobProgress(_("Block Pull"), 0, 1);
+        virshPrintJobProgress(_("Block Pull"), 0, 1);
     }
     vshPrint(ctl, "\n%s", quit ? _("Pull aborted") : _("Pull complete"));
 
@@ -2793,7 +2793,7 @@ cmdBlockResize(vshControl *ctl, const vshCmd *cmd)
     else
         flags |= VIR_DOMAIN_BLOCK_RESIZE_BYTES;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (virDomainBlockResize(dom, path, size, flags) < 0) {
@@ -2850,7 +2850,7 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom,
     bool ret = false;
     int state;
 
-    if ((state = vshDomainState(ctl, dom, NULL)) < 0) {
+    if ((state = virshDomainState(ctl, dom, NULL)) < 0) {
         vshError(ctl, "%s", _("Unable to get domain status"));
         goto cleanup;
     }
@@ -2868,7 +2868,7 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom,
     vshPrintExtra(ctl, _("Connected to domain %s\n"), virDomainGetName(dom));
     vshPrintExtra(ctl, _("Escape character is %s\n"), ctl->escapeChar);
     fflush(stdout);
-    if (vshRunConsole(ctl, dom, name, flags) == 0)
+    if (virshRunConsole(ctl, dom, name, flags) == 0)
         ret = true;
 
  cleanup:
@@ -2886,7 +2886,7 @@ cmdConsole(vshControl *ctl, const vshCmd *cmd)
     unsigned int flags = 0;
     const char *name = NULL;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "devname", &name) < 0) /* sc_prohibit_devname */
@@ -2966,7 +2966,7 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd)
     xmlNodePtr cur = NULL;
     char *xml_buf = NULL;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "interface", &iface) < 0 ||
@@ -3164,7 +3164,7 @@ cmdDomIftune(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "interface", &device) < 0)
@@ -3322,7 +3322,7 @@ cmdSuspend(vshControl *ctl, const vshCmd *cmd)
     const char *name;
     bool ret = true;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (virDomainSuspend(dom) == 0) {
@@ -3383,7 +3383,7 @@ cmdDomPMSuspend(vshControl *ctl, const vshCmd *cmd)
     unsigned int suspendTarget;
     unsigned long long duration = 0;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (vshCommandOptULongLong(ctl, cmd, "duration", &duration) < 0)
@@ -3451,7 +3451,7 @@ cmdDomPMWakeup(vshControl *ctl, const vshCmd *cmd)
     bool ret = false;
     unsigned int flags = 0;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (virDomainPMWakeup(dom, flags) < 0) {
@@ -3583,7 +3583,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
     if (nvram)
         flags |= VIR_DOMAIN_UNDEFINE_NVRAM;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     /* Do some flag manipulation.  The goal here is to disable bits
@@ -3988,8 +3988,8 @@ cmdStart(vshControl *ctl, const vshCmd *cmd)
     size_t nfds = 0;
     int *fds = NULL;
 
-    if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL,
-                                      VSH_BYNAME | VSH_BYUUID)))
+    if (!(dom = virshCommandOptDomainBy(ctl, cmd, NULL,
+                                        VSH_BYNAME | VSH_BYUUID)))
         return false;
 
     if (virDomainGetID(dom) != (unsigned int)-1) {
@@ -4108,7 +4108,7 @@ static const vshCmdOptDef opts_save[] = {
 static void
 doSave(void *opaque)
 {
-    vshCtrlData *data = opaque;
+    virshCtrlData *data = opaque;
     vshControl *ctl = data->ctl;
     const vshCmd *cmd = data->cmd;
     char ret = '1';
@@ -4138,11 +4138,11 @@ doSave(void *opaque)
     if (vshCommandOptStringReq(ctl, cmd, "xml", &xmlfile) < 0)
         goto out;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         goto out;
 
     if (xmlfile &&
-        virFileReadAll(xmlfile, VSH_MAX_XML_FILE, &xml) < 0) {
+        virFileReadAll(xmlfile, VIRSH_MAX_XML_FILE, &xml) < 0) {
         vshReportError(ctl);
         goto out;
     }
@@ -4220,7 +4220,7 @@ vshWatchJob(vshControl *ctl,
                 retchar == '0') {
                 if (verbose) {
                     /* print [100 %] */
-                    vshPrintJobProgress(label, 0, 1);
+                    virshPrintJobProgress(label, 0, 1);
                 }
                 break;
             }
@@ -4255,8 +4255,8 @@ vshWatchJob(vshControl *ctl,
             pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL);
             if (ret == 0) {
                 if (verbose)
-                    vshPrintJobProgress(label, jobinfo.dataRemaining,
-                                        jobinfo.dataTotal);
+                    virshPrintJobProgress(label, jobinfo.dataRemaining,
+                                          jobinfo.dataTotal);
 
                 if (!jobStarted &&
                     (jobinfo.type == VIR_DOMAIN_JOB_BOUNDED ||
@@ -4286,11 +4286,11 @@ cmdSave(vshControl *ctl, const vshCmd *cmd)
     int p[2] = {-1. -1};
     virThread workerThread;
     bool verbose = false;
-    vshCtrlData data;
+    virshCtrlData data;
     const char *to = NULL;
     const char *name = NULL;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0)
@@ -4431,7 +4431,7 @@ cmdSaveImageDefine(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "xml", &xmlfile) < 0)
         return false;
 
-    if (virFileReadAll(xmlfile, VSH_MAX_XML_FILE, &xml) < 0)
+    if (virFileReadAll(xmlfile, VIRSH_MAX_XML_FILE, &xml) < 0)
         goto cleanup;
 
     if (virDomainSaveImageDefineXML(ctl->conn, file, xml, flags) < 0) {
@@ -4567,7 +4567,7 @@ static void
 doManagedsave(void *opaque)
 {
     char ret = '1';
-    vshCtrlData *data = opaque;
+    virshCtrlData *data = opaque;
     vshControl *ctl = data->ctl;
     const vshCmd *cmd = data->cmd;
     virDomainPtr dom = NULL;
@@ -4587,7 +4587,7 @@ doManagedsave(void *opaque)
     if (vshCommandOptBool(cmd, "paused"))
         flags |= VIR_DOMAIN_SAVE_PAUSED;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         goto out;
 
     if (virDomainManagedSave(dom, flags) < 0) {
@@ -4612,10 +4612,10 @@ cmdManagedSave(vshControl *ctl, const vshCmd *cmd)
     bool ret = false;
     bool verbose = false;
     const char *name = NULL;
-    vshCtrlData data;
+    virshCtrlData data;
     virThread workerThread;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (vshCommandOptBool(cmd, "verbose"))
@@ -4679,7 +4679,7 @@ cmdManagedSaveRemove(vshControl *ctl, const vshCmd *cmd)
     bool ret = false;
     int hassave;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     hassave = virDomainHasManagedSaveImage(dom, 0);
@@ -4876,7 +4876,7 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     /* Print SchedulerType */
@@ -5017,7 +5017,7 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd)
         return false;
 
     if (xmlfile &&
-        virFileReadAll(xmlfile, VSH_MAX_XML_FILE, &xml) < 0)
+        virFileReadAll(xmlfile, VIRSH_MAX_XML_FILE, &xml) < 0)
         goto cleanup;
 
     if (((flags || xml)
@@ -5094,7 +5094,7 @@ static void
 doDump(void *opaque)
 {
     char ret = '1';
-    vshCtrlData *data = opaque;
+    virshCtrlData *data = opaque;
     vshControl *ctl = data->ctl;
     const vshCmd *cmd = data->cmd;
     virDomainPtr dom = NULL;
@@ -5113,7 +5113,7 @@ doDump(void *opaque)
     if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0)
         goto out;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         goto out;
 
     if (vshCommandOptBool(cmd, "live"))
@@ -5181,10 +5181,10 @@ cmdDump(vshControl *ctl, const vshCmd *cmd)
     bool verbose = false;
     const char *name = NULL;
     const char *to = NULL;
-    vshCtrlData data;
+    virshCtrlData data;
     virThread workerThread;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0)
@@ -5305,7 +5305,7 @@ cmdScreenshot(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptUInt(ctl, cmd, "screen", &screen) < 0)
         return false;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (!(st = virStreamNew(ctl->conn, 0)))
@@ -5333,7 +5333,7 @@ cmdScreenshot(vshControl *ctl, const vshCmd *cmd)
         created = true;
     }
 
-    if (virStreamRecvAll(st, vshStreamSink, &fd) < 0) {
+    if (virStreamRecvAll(st, virshStreamSink, &fd) < 0) {
         vshError(ctl, _("could not receive data from domain %s"), name);
         goto cleanup;
     }
@@ -5419,7 +5419,7 @@ cmdSetUserPassword(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "password", &password) < 0)
         return false;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (virDomainSetUserPassword(dom, user, password, flags) < 0)
@@ -5461,7 +5461,7 @@ cmdResume(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (virDomainResume(dom) == 0) {
@@ -5542,7 +5542,7 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd)
         tmp++;
     }
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         goto cleanup;
 
     if (flags)
@@ -5630,7 +5630,7 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd)
         tmp++;
     }
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         goto cleanup;
 
     if (virDomainReboot(dom, flags) == 0) {
@@ -5677,7 +5677,7 @@ cmdReset(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (virDomainReset(dom, 0) == 0) {
@@ -5748,7 +5748,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
     unsigned int flags = 0;
     int rc;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptBool(cmd, "completed"))
@@ -5830,20 +5830,20 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
                  info.timeRemaining);
 
     if (info.dataTotal || info.dataRemaining || info.dataProcessed) {
-        val = vshPrettyCapacity(info.dataProcessed, &unit);
+        val = virshPrettyCapacity(info.dataProcessed, &unit);
         vshPrint(ctl, "%-17s %-.3lf %s\n", _("Data processed:"), val, unit);
-        val = vshPrettyCapacity(info.dataRemaining, &unit);
+        val = virshPrettyCapacity(info.dataRemaining, &unit);
         vshPrint(ctl, "%-17s %-.3lf %s\n", _("Data remaining:"), val, unit);
-        val = vshPrettyCapacity(info.dataTotal, &unit);
+        val = virshPrettyCapacity(info.dataTotal, &unit);
         vshPrint(ctl, "%-17s %-.3lf %s\n", _("Data total:"), val, unit);
     }
 
     if (info.memTotal || info.memRemaining || info.memProcessed) {
-        val = vshPrettyCapacity(info.memProcessed, &unit);
+        val = virshPrettyCapacity(info.memProcessed, &unit);
         vshPrint(ctl, "%-17s %-.3lf %s\n", _("Memory processed:"), val, unit);
-        val = vshPrettyCapacity(info.memRemaining, &unit);
+        val = virshPrettyCapacity(info.memRemaining, &unit);
         vshPrint(ctl, "%-17s %-.3lf %s\n", _("Memory remaining:"), val, unit);
-        val = vshPrettyCapacity(info.memTotal, &unit);
+        val = virshPrettyCapacity(info.memTotal, &unit);
         vshPrint(ctl, "%-17s %-.3lf %s\n", _("Memory total:"), val, unit);
 
         if ((rc = virTypedParamsGetULLong(params, nparams,
@@ -5851,18 +5851,18 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
                                           &value)) < 0) {
             goto save_error;
         } else if (rc && value) {
-            val = vshPrettyCapacity(value, &unit);
+            val = virshPrettyCapacity(value, &unit);
             vshPrint(ctl, "%-17s %-.3lf %s/s\n",
                      _("Memory bandwidth:"), val, unit);
         }
     }
 
     if (info.fileTotal || info.fileRemaining || info.fileProcessed) {
-        val = vshPrettyCapacity(info.fileProcessed, &unit);
+        val = virshPrettyCapacity(info.fileProcessed, &unit);
         vshPrint(ctl, "%-17s %-.3lf %s\n", _("File processed:"), val, unit);
-        val = vshPrettyCapacity(info.fileRemaining, &unit);
+        val = virshPrettyCapacity(info.fileRemaining, &unit);
         vshPrint(ctl, "%-17s %-.3lf %s\n", _("File remaining:"), val, unit);
-        val = vshPrettyCapacity(info.fileTotal, &unit);
+        val = virshPrettyCapacity(info.fileTotal, &unit);
         vshPrint(ctl, "%-17s %-.3lf %s\n", _("File total:"), val, unit);
 
         if ((rc = virTypedParamsGetULLong(params, nparams,
@@ -5870,7 +5870,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
                                           &value)) < 0) {
             goto save_error;
         } else if (rc && value) {
-            val = vshPrettyCapacity(value, &unit);
+            val = virshPrettyCapacity(value, &unit);
             vshPrint(ctl, "%-17s %-.3lf %s/s\n",
                      _("File bandwidth:"), val, unit);
         }
@@ -5895,7 +5895,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
                                       &value)) < 0) {
         goto save_error;
     } else if (rc) {
-        val = vshPrettyCapacity(value, &unit);
+        val = virshPrettyCapacity(value, &unit);
         vshPrint(ctl, "%-17s %-.3lf %s\n", _("Normal data:"), val, unit);
     }
 
@@ -5932,7 +5932,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
                                       &value)) < 0) {
         goto save_error;
     } else if (rc) {
-        val = vshPrettyCapacity(value, &unit);
+        val = virshPrettyCapacity(value, &unit);
         vshPrint(ctl, "%-17s %-.3lf %s\n", _("Compression cache:"), val, unit);
     }
     if ((rc = virTypedParamsGetULLong(params, nparams,
@@ -5940,7 +5940,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
                                       &value)) < 0) {
         goto save_error;
     } else if (rc) {
-        val = vshPrettyCapacity(value, &unit);
+        val = virshPrettyCapacity(value, &unit);
         vshPrint(ctl, "%-17s %-.3lf %s\n", _("Compressed data:"), val, unit);
     }
     if ((rc = virTypedParamsGetULLong(params, nparams,
@@ -6005,7 +6005,7 @@ cmdDomjobabort(vshControl *ctl, const vshCmd *cmd)
     virDomainPtr dom;
     bool ret = true;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (virDomainAbortJob(dom) < 0)
@@ -6188,7 +6188,7 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
     if (guest)
         flags |= VIR_DOMAIN_VCPU_GUEST;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (all) {
@@ -6265,10 +6265,10 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
     bool pretty = vshCommandOptBool(cmd, "pretty");
     int n, m;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
-    if ((maxcpu = vshNodeGetCPUCount(ctl->conn)) < 0)
+    if ((maxcpu = virshNodeGetCPUCount(ctl->conn)) < 0)
         goto cleanup;
 
     if (virDomainGetInfo(dom, &info) != 0)
@@ -6297,7 +6297,7 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
         if (cpuinfo) {
             vshPrint(ctl, "%-15s %d\n", _("CPU:"), cpuinfo[n].cpu);
             vshPrint(ctl, "%-15s %s\n", _("State:"),
-                     vshDomainVcpuStateToString(cpuinfo[n].state));
+                     virshDomainVcpuStateToString(cpuinfo[n].state));
             if (cpuinfo[n].cpuTime != 0) {
                 double cpuUsed = cpuinfo[n].cpuTime;
 
@@ -6474,10 +6474,10 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
         return false;
     }
 
-    if ((maxcpu = vshNodeGetCPUCount(ctl->conn)) < 0)
+    if ((maxcpu = virshNodeGetCPUCount(ctl->conn)) < 0)
         return false;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     /* Query mode: show CPU affinity information then exit.*/
@@ -6601,7 +6601,7 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd)
     if (!current && !live && !config)
         flags = -1;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "cpulist", &cpulist) < 0) {
@@ -6610,7 +6610,7 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd)
     }
     query = !cpulist;
 
-    if ((maxcpu = vshNodeGetCPUCount(ctl->conn)) < 0) {
+    if ((maxcpu = virshNodeGetCPUCount(ctl->conn)) < 0) {
         virDomainFree(dom);
         return false;
     }
@@ -6727,7 +6727,7 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
     if (maximum)
         flags |= VIR_DOMAIN_VCPU_MAXIMUM;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptInt(ctl, cmd, "count", &count) < 0 || count <= 0)
@@ -6803,10 +6803,10 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
-    if ((maxcpu = vshNodeGetCPUCount(ctl->conn)) < 0)
+    if ((maxcpu = virshNodeGetCPUCount(ctl->conn)) < 0)
         goto cleanup;
 
     if ((niothreads = virDomainGetIOThreadInfo(dom, &info, flags)) < 0) {
@@ -6903,7 +6903,7 @@ cmdIOThreadPin(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptUInt(ctl, cmd, "iothread", &iothread_id) < 0)
@@ -6914,7 +6914,7 @@ cmdIOThreadPin(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
     }
 
-    if ((maxcpu = vshNodeGetCPUCount(ctl->conn)) < 0)
+    if ((maxcpu = virshNodeGetCPUCount(ctl->conn)) < 0)
         goto cleanup;
 
     if (!(cpumap = vshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu)))
@@ -6990,7 +6990,7 @@ cmdIOThreadAdd(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptInt(ctl, cmd, "id", &iothread_id) < 0)
@@ -7068,7 +7068,7 @@ cmdIOThreadDel(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptInt(ctl, cmd, "id", &iothread_id) < 0)
@@ -7133,7 +7133,7 @@ cmdCPUCompare(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
         return false;
 
-    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
+    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
         return false;
 
     /* try to extract the CPU element from as it would appear in a domain XML*/
@@ -7244,7 +7244,7 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
         return false;
 
-    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
+    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
         return false;
 
     /* add a separate container around the xml */
@@ -7351,7 +7351,7 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd)
     bool ret = false;
     int rv = 0;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     show_total = vshCommandOptBool(cmd, "total");
@@ -7555,7 +7555,7 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
         return false;
 
-    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
+    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
         return false;
 
     if (cmdStartGetFDs(ctl, cmd, &nfds, &fds) < 0)
@@ -7634,7 +7634,7 @@ cmdDefine(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "validate"))
         flags |= VIR_DOMAIN_DEFINE_VALIDATE;
 
-    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
+    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
         return false;
 
     if (flags)
@@ -7689,7 +7689,7 @@ cmdDestroy(vshControl *ctl, const vshCmd *cmd)
     unsigned int flags = 0;
     int result;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
         return false;
 
     if (vshCommandOptBool(cmd, "graceful"))
@@ -7788,10 +7788,10 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
-    if ((state = vshDomainState(ctl, dom, NULL)) < 0)
+    if ((state = virshDomainState(ctl, dom, NULL)) < 0)
         goto cleanup;
 
     while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
@@ -7814,7 +7814,7 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
 
     if (edit || desc) {
         if (!desc) {
-                desc = vshGetDomainDescription(ctl, dom, title,
+                desc = virshGetDomainDescription(ctl, dom, title,
                                            config?VIR_DOMAIN_XML_INACTIVE:0);
                 if (!desc)
                     goto cleanup;
@@ -7822,15 +7822,15 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
 
         if (edit) {
             /* Create and open the temporary file. */
-            if (!(tmp = vshEditWriteToTempFile(ctl, desc)))
+            if (!(tmp = virshEditWriteToTempFile(ctl, desc)))
                 goto cleanup;
 
             /* Start the editor. */
-            if (vshEditFile(ctl, tmp) == -1)
+            if (virshEditFile(ctl, tmp) == -1)
                 goto cleanup;
 
             /* Read back the edited file. */
-            if (!(desc_edited = vshEditReadBackFile(ctl, tmp)))
+            if (!(desc_edited = virshEditReadBackFile(ctl, tmp)))
                 goto cleanup;
 
             /* strip a possible newline at the end of file; some
@@ -7865,7 +7865,7 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
                  title ? _("Domain title updated successfully") :
                          _("Domain description updated successfully"));
     } else {
-        desc = vshGetDomainDescription(ctl, dom, title,
+        desc = virshGetDomainDescription(ctl, dom, title,
                                        config?VIR_DOMAIN_XML_INACTIVE:0);
         if (!desc)
             goto cleanup;
@@ -7991,7 +7991,7 @@ cmdMetadata(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "uri", &uri) < 0 ||
@@ -8077,7 +8077,7 @@ cmdInjectNMI(vshControl *ctl, const vshCmd *cmd)
     virDomainPtr dom;
     bool ret = true;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (virDomainInjectNMI(dom, 0) < 0)
@@ -8147,7 +8147,7 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd)
     int keycode;
     unsigned int keycodes[VIR_DOMAIN_SEND_KEY_MAX_KEYS];
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptString(ctl, cmd, "codeset", &codeset_option) <= 0)
@@ -8272,7 +8272,7 @@ cmdSendProcessSignal(vshControl *ctl, const vshCmd *cmd)
     long long pid_value;
     int signum;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptLongLong(ctl, cmd, "pid", &pid_value) < 0)
@@ -8363,7 +8363,7 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd)
     if (!current && !live && !config)
         flags = -1;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     /* The API expects 'unsigned long' KiB, so depending on whether we
@@ -8457,7 +8457,7 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd)
     if (!current && !live && !config)
         flags = -1;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     /* The API expects 'unsigned long' KiB, so depending on whether we
@@ -8605,7 +8605,7 @@ cmdMemtune(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
 #define PARSE_MEMTUNE_PARAM(NAME, FIELD)                                    \
@@ -8747,7 +8747,7 @@ cmdNumatune(vshControl * ctl, const vshCmd * cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "nodeset", &nodeset) < 0)
@@ -8876,7 +8876,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
     bool pad = false;
     virJSONValuePtr pretty = NULL;
 
-    dom = vshCommandOptDomain(ctl, cmd, NULL);
+    dom = virshCommandOptDomain(ctl, cmd, NULL);
     if (dom == NULL)
         goto cleanup;
 
@@ -8931,20 +8931,20 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
  * "qemu-monitor-event" command
  */
 
-struct vshQemuEventData {
+struct virshQemuEventData {
     vshControl *ctl;
     bool loop;
     bool pretty;
     int count;
 };
-typedef struct vshQemuEventData vshQemuEventData;
+typedef struct virshQemuEventData virshQemuEventData;
 
 static void
 vshEventPrint(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainPtr dom,
               const char *event, long long seconds, unsigned int micros,
               const char *details, void *opaque)
 {
-    vshQemuEventData *data = opaque;
+    virshQemuEventData *data = opaque;
     virJSONValuePtr pretty = NULL;
     char *str = NULL;
 
@@ -9015,7 +9015,7 @@ cmdQemuMonitorEvent(vshControl *ctl, const vshCmd *cmd)
     int eventId = -1;
     int timeout = 0;
     const char *event = NULL;
-    vshQemuEventData data;
+    virshQemuEventData data;
 
     if (vshCommandOptBool(cmd, "regex"))
         flags |= VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_REGEX;
@@ -9026,13 +9026,13 @@ cmdQemuMonitorEvent(vshControl *ctl, const vshCmd *cmd)
     data.loop = vshCommandOptBool(cmd, "loop");
     data.pretty = vshCommandOptBool(cmd, "pretty");
     data.count = 0;
-    if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
+    if (virshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
         return false;
     if (vshCommandOptString(ctl, cmd, "event", &event) < 0)
         return false;
 
     if (vshCommandOptBool(cmd, "domain"))
-        dom = vshCommandOptDomain(ctl, cmd, NULL);
+        dom = virshCommandOptDomain(ctl, cmd, NULL);
     if (vshEventStart(ctl, timeout) < 0)
         goto cleanup;
 
@@ -9175,7 +9175,7 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd)
     bool pad = false;
     virJSONValuePtr pretty = NULL;
 
-    dom = vshCommandOptDomain(ctl, cmd, NULL);
+    dom = virshCommandOptDomain(ctl, cmd, NULL);
     if (dom == NULL)
         goto cleanup;
 
@@ -9290,7 +9290,7 @@ cmdLxcEnterNamespace(vshControl *ctl, const vshCmd *cmd)
     virSecurityModelPtr secmodel = NULL;
     virSecurityLabelPtr seclabel = NULL;
 
-    dom = vshCommandOptDomain(ctl, cmd, NULL);
+    dom = virshCommandOptDomain(ctl, cmd, NULL);
     if (dom == NULL)
         goto cleanup;
 
@@ -9444,7 +9444,7 @@ cmdDumpXML(vshControl *ctl, const vshCmd *cmd)
     if (migratable)
         flags |= VIR_DOMAIN_XML_MIGRATABLE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     dump = virDomainGetXMLDesc(dom, flags);
@@ -9500,7 +9500,7 @@ cmdDomXMLFromNative(vshControl *ctl, const vshCmd *cmd)
         vshCommandOptStringReq(ctl, cmd, "config", &configFile) < 0)
         return false;
 
-    if (virFileReadAll(configFile, VSH_MAX_XML_FILE, &configData) < 0)
+    if (virFileReadAll(configFile, VIRSH_MAX_XML_FILE, &configData) < 0)
         return false;
 
     xmlData = virConnectDomainXMLFromNative(ctl->conn, format, configData, flags);
@@ -9556,7 +9556,7 @@ cmdDomXMLToNative(vshControl *ctl, const vshCmd *cmd)
         vshCommandOptStringReq(ctl, cmd, "xml", &xmlFile) < 0)
         return false;
 
-    if (virFileReadAll(xmlFile, VSH_MAX_XML_FILE, &xmlData) < 0)
+    if (virFileReadAll(xmlFile, VIRSH_MAX_XML_FILE, &xmlData) < 0)
         return false;
 
     configData = virConnectDomainXMLToNative(ctl->conn, format, xmlData, flags);
@@ -9598,8 +9598,8 @@ cmdDomname(vshControl *ctl, const vshCmd *cmd)
 {
     virDomainPtr dom;
 
-    if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL,
-                                      VSH_BYID|VSH_BYUUID)))
+    if (!(dom = virshCommandOptDomainBy(ctl, cmd, NULL,
+                                        VSH_BYID|VSH_BYUUID)))
         return false;
 
     vshPrint(ctl, "%s\n", virDomainGetName(dom));
@@ -9635,8 +9635,8 @@ cmdDomid(vshControl *ctl, const vshCmd *cmd)
     virDomainPtr dom;
     unsigned int id;
 
-    if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL,
-                                      VSH_BYNAME|VSH_BYUUID)))
+    if (!(dom = virshCommandOptDomainBy(ctl, cmd, NULL,
+                                        VSH_BYNAME|VSH_BYUUID)))
         return false;
 
     id = virDomainGetID(dom);
@@ -9676,8 +9676,8 @@ cmdDomuuid(vshControl *ctl, const vshCmd *cmd)
     virDomainPtr dom;
     char uuid[VIR_UUID_STRING_BUFLEN];
 
-    if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL,
-                                      VSH_BYNAME|VSH_BYID)))
+    if (!(dom = virshCommandOptDomainBy(ctl, cmd, NULL,
+                                        VSH_BYNAME|VSH_BYID)))
         return false;
 
     if (virDomainGetUUIDString(dom, uuid) != -1)
@@ -9824,7 +9824,7 @@ doMigrate(void *opaque)
     const char *desturi = NULL;
     const char *opt = NULL;
     unsigned int flags = 0;
-    vshCtrlData *data = opaque;
+    virshCtrlData *data = opaque;
     vshControl *ctl = data->ctl;
     const vshCmd *cmd = data->cmd;
     sigset_t sigmask, oldsigmask;
@@ -9838,7 +9838,7 @@ doMigrate(void *opaque)
     if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0)
         goto out_sig;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         goto out;
 
     if (vshCommandOptStringReq(ctl, cmd, "desturi", &desturi) < 0)
@@ -9896,7 +9896,7 @@ doMigrate(void *opaque)
     if (opt) {
         char *xml;
 
-        if (virFileReadAll(opt, VSH_MAX_XML_FILE, &xml) < 0) {
+        if (virFileReadAll(opt, VIRSH_MAX_XML_FILE, &xml) < 0) {
             vshError(ctl, _("cannot read file '%s'"), opt);
             goto save_error;
         }
@@ -9998,9 +9998,9 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd)
     bool functionReturn = false;
     int timeout = 0;
     bool live_flag = false;
-    vshCtrlData data = { .dconn = NULL };
+    virshCtrlData data = { .dconn = NULL };
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptBool(cmd, "verbose"))
@@ -10008,7 +10008,7 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd)
 
     if (vshCommandOptBool(cmd, "live"))
         live_flag = true;
-    if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0) {
+    if (virshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0) {
         goto cleanup;
     } else if (timeout > 0 && !live_flag) {
         vshError(ctl, "%s",
@@ -10033,7 +10033,7 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd)
         if (vshCommandOptStringReq(ctl, cmd, "desturi", &desturi) < 0)
             goto cleanup;
 
-        dconn = vshConnect(ctl, desturi, false);
+        dconn = virshConnect(ctl, desturi, false);
         if (!dconn)
             goto cleanup;
 
@@ -10093,7 +10093,7 @@ cmdMigrateSetMaxDowntime(vshControl *ctl, const vshCmd *cmd)
     long long downtime = 0;
     bool ret = false;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptLongLong(ctl, cmd, "downtime", &downtime) < 0)
@@ -10151,7 +10151,7 @@ cmdMigrateCompCache(vshControl *ctl, const vshCmd *cmd)
     double value;
     int rc;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     rc = vshCommandOptULongLong(ctl, cmd, "size", &size);
@@ -10165,7 +10165,7 @@ cmdMigrateCompCache(vshControl *ctl, const vshCmd *cmd)
     if (virDomainMigrateGetCompressionCache(dom, &size, 0) < 0)
         goto cleanup;
 
-    value = vshPrettyCapacity(size, &unit);
+    value = virshPrettyCapacity(size, &unit);
     vshPrint(ctl, _("Compression cache: %.3lf %s"), value, unit);
 
     ret = true;
@@ -10209,7 +10209,7 @@ cmdMigrateSetMaxSpeed(vshControl *ctl, const vshCmd *cmd)
     unsigned long bandwidth = 0;
     bool ret = false;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptULWrap(ctl, cmd, "bandwidth", &bandwidth) < 0)
@@ -10254,7 +10254,7 @@ cmdMigrateGetMaxSpeed(vshControl *ctl, const vshCmd *cmd)
     unsigned long bandwidth;
     bool ret = false;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (virDomainMigrateGetMaxSpeed(dom, &bandwidth, 0) < 0)
@@ -10324,7 +10324,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
     const char *xpath_fmt = "string(/domain/devices/graphics[@type='%s']/%s)";
     virSocketAddr addr;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (!virDomainIsActive(dom)) {
@@ -10526,7 +10526,7 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd)
     char *doc = NULL;
     char *listen_addr = NULL;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     /* Check if the domain is active and don't rely on -1 for this */
@@ -10610,7 +10610,7 @@ cmdTTYConsole(vshControl *ctl, const vshCmd *cmd)
     bool ret = false;
     char *doc;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     doc = virDomainGetXMLDesc(dom, 0);
@@ -10667,7 +10667,7 @@ cmdDomHostname(vshControl *ctl, const vshCmd *cmd)
     virDomainPtr dom;
     bool ret = false;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     hostname = virDomainGetHostname(dom, 0);
@@ -10868,7 +10868,7 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (persistent &&
@@ -10878,7 +10878,7 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
         goto cleanup;
 
-    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {
+    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
         vshReportError(ctl);
         goto cleanup;
     }
@@ -10972,7 +10972,7 @@ cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
@@ -10982,7 +10982,7 @@ cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd)
         virDomainIsActive(dom) == 1)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {
+    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
         vshReportError(ctl);
         goto cleanup;
     }
@@ -11083,7 +11083,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0)
@@ -11186,14 +11186,14 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
 }
 
 typedef enum {
-    VSH_FIND_DISK_NORMAL,
-    VSH_FIND_DISK_CHANGEABLE,
+    VIRSH_FIND_DISK_NORMAL,
+    VIRSH_FIND_DISK_CHANGEABLE,
 } vshFindDiskType;
 
 /* Helper function to find disk device in XML doc.  Returns the disk
  * node on success, or NULL on failure. Caller must free the result
  * @path: Fully-qualified path or target of disk device.
- * @type: Either VSH_FIND_DISK_NORMAL or VSH_FIND_DISK_CHANGEABLE.
+ * @type: Either VIRSH_FIND_DISK_NORMAL or VIRSH_FIND_DISK_CHANGEABLE.
  */
 static xmlNodePtr
 vshFindDisk(const char *doc,
@@ -11226,7 +11226,7 @@ vshFindDisk(const char *doc,
     for (i = 0; i < obj->nodesetval->nodeNr; i++) {
         bool is_supported = true;
 
-        if (type == VSH_FIND_DISK_CHANGEABLE) {
+        if (type == VIRSH_FIND_DISK_CHANGEABLE) {
             xmlNodePtr n = obj->nodesetval->nodeTab[i];
             is_supported = false;
 
@@ -11281,9 +11281,9 @@ vshFindDisk(const char *doc,
 }
 
 typedef enum {
-    VSH_UPDATE_DISK_XML_EJECT,
-    VSH_UPDATE_DISK_XML_INSERT,
-    VSH_UPDATE_DISK_XML_UPDATE,
+    VIRSH_UPDATE_DISK_XML_EJECT,
+    VIRSH_UPDATE_DISK_XML_INSERT,
+    VIRSH_UPDATE_DISK_XML_UPDATE,
 } vshUpdateDiskXMLType;
 
 /* Helper function to prepare disk XML. Could be used for disk
@@ -11320,7 +11320,7 @@ vshUpdateDiskXML(xmlNodePtr disk_node,
             break;
     }
 
-    if (type == VSH_UPDATE_DISK_XML_EJECT) {
+    if (type == VIRSH_UPDATE_DISK_XML_EJECT) {
         if (!source) {
             vshError(NULL, _("The disk device '%s' doesn't have media"), target);
             goto cleanup;
@@ -11334,7 +11334,7 @@ vshUpdateDiskXML(xmlNodePtr disk_node,
         goto cleanup;
     }
 
-    if (type == VSH_UPDATE_DISK_XML_INSERT && source) {
+    if (type == VIRSH_UPDATE_DISK_XML_INSERT && source) {
         vshError(NULL, _("The disk device '%s' already has media"), target);
         goto cleanup;
     }
@@ -11447,7 +11447,7 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "target", &target) < 0)
@@ -11465,7 +11465,7 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
         virDomainIsActive(dom) == 1)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(disk_node = vshFindDisk(doc, target, VSH_FIND_DISK_NORMAL)))
+    if (!(disk_node = vshFindDisk(doc, target, VIRSH_FIND_DISK_NORMAL)))
         goto cleanup;
 
     if (!(disk_xml = virXMLNodeToString(NULL, disk_node))) {
@@ -11529,7 +11529,7 @@ cmdEdit(vshControl *ctl, const vshCmd *cmd)
     unsigned int query_flags = VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_INACTIVE;
     unsigned int define_flags = VIR_DOMAIN_DEFINE_VALIDATE;
 
-    dom = vshCommandOptDomain(ctl, cmd, NULL);
+    dom = virshCommandOptDomain(ctl, cmd, NULL);
     if (dom == NULL)
         goto cleanup;
 
@@ -11545,7 +11545,7 @@ cmdEdit(vshControl *ctl, const vshCmd *cmd)
         goto edit_cleanup;                                              \
     } while (0)
 #define EDIT_DEFINE \
-    (dom_edited = vshDomainDefine(ctl->conn, doc_edited, define_flags))
+    (dom_edited = virshDomainDefine(ctl->conn, doc_edited, define_flags))
 #define EDIT_RELAX                                      \
     do {                                                \
         define_flags &= ~VIR_DOMAIN_DEFINE_VALIDATE;    \
@@ -12285,11 +12285,11 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd)
         data[0].cb = &vshEventCallbacks[event];
         data[0].id = -1;
     }
-    if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
+    if (virshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
         goto cleanup;
 
     if (vshCommandOptBool(cmd, "domain"))
-        dom = vshCommandOptDomain(ctl, cmd, NULL);
+        dom = virshCommandOptDomain(ctl, cmd, NULL);
     if (vshEventStart(ctl, timeout) < 0)
         goto cleanup;
 
@@ -12448,19 +12448,19 @@ cmdChangeMedia(vshControl *ctl, const vshCmd *cmd)
     }
 
     if (eject) {
-        update_type = VSH_UPDATE_DISK_XML_EJECT;
+        update_type = VIRSH_UPDATE_DISK_XML_EJECT;
         action = "eject";
         success_msg = _("Successfully ejected media.");
     }
 
     if (insert) {
-        update_type = VSH_UPDATE_DISK_XML_INSERT;
+        update_type = VIRSH_UPDATE_DISK_XML_INSERT;
         action = "insert";
         success_msg = _("Successfully inserted media.");
     }
 
     if (update || (!eject && !insert)) {
-        update_type = VSH_UPDATE_DISK_XML_UPDATE;
+        update_type = VIRSH_UPDATE_DISK_XML_UPDATE;
         action = "update";
         success_msg = _("Successfully updated media.");
     }
@@ -12475,7 +12475,7 @@ cmdChangeMedia(vshControl *ctl, const vshCmd *cmd)
     if (force)
         flags |= VIR_DOMAIN_DEVICE_MODIFY_FORCE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0)
@@ -12488,7 +12488,7 @@ cmdChangeMedia(vshControl *ctl, const vshCmd *cmd)
     if (!doc)
         goto cleanup;
 
-    if (!(disk_node = vshFindDisk(doc, path, VSH_FIND_DISK_CHANGEABLE)))
+    if (!(disk_node = vshFindDisk(doc, path, VIRSH_FIND_DISK_CHANGEABLE)))
         goto cleanup;
 
     if (!(disk_xml = vshUpdateDiskXML(disk_node, source, block, path,
@@ -12552,7 +12552,7 @@ cmdDomFSTrim(vshControl *ctl, const vshCmd *cmd)
     const char *mountPoint = NULL;
     unsigned int flags = 0;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return ret;
 
     if (vshCommandOptULongLong(ctl, cmd, "minimum", &minimum) < 0)
@@ -12604,7 +12604,7 @@ cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd)
     const char **mountpoints = NULL;
     size_t nmountpoints = 0;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
@@ -12661,7 +12661,7 @@ cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd)
     const char **mountpoints = NULL;
     size_t nmountpoints = 0;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
@@ -12714,7 +12714,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd)
     size_t i, j;
     virDomainFSInfoPtr *info;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     ret = virDomainGetFSInfo(dom, &info, 0);
diff --git a/tools/virsh-domain.h b/tools/virsh-domain.h
index f46538f..2f3ec30 100644
--- a/tools/virsh-domain.h
+++ b/tools/virsh-domain.h
@@ -28,16 +28,16 @@
 
 # include "virsh.h"
 
-virDomainPtr vshLookupDomainBy(vshControl *ctl,
-                               const char *name,
-                               unsigned int flags);
+virDomainPtr virshLookupDomainBy(vshControl *ctl,
+                                 const char *name,
+                                 unsigned int flags);
 
-virDomainPtr vshCommandOptDomainBy(vshControl *ctl, const vshCmd *cmd,
-                                   const char **name, unsigned int flags);
+virDomainPtr virshCommandOptDomainBy(vshControl *ctl, const vshCmd *cmd,
+                                     const char **name, unsigned int flags);
 
 /* default is lookup by Id, Name and UUID */
-# define vshCommandOptDomain(_ctl, _cmd, _name)                      \
-    vshCommandOptDomainBy(_ctl, _cmd, _name, VSH_BYID|VSH_BYUUID|VSH_BYNAME)
+# define virshCommandOptDomain(_ctl, _cmd, _name)                      \
+    virshCommandOptDomainBy(_ctl, _cmd, _name, VSH_BYID|VSH_BYUUID|VSH_BYNAME)
 
 extern const vshCmdDef domManagementCmds[];
 
diff --git a/tools/virsh-edit.c b/tools/virsh-edit.c
index 1b39cb7..49d4a5a 100644
--- a/tools/virsh-edit.c
+++ b/tools/virsh-edit.c
@@ -70,7 +70,7 @@ do {
         goto edit_cleanup;
 
     /* Create and open the temporary file. */
-    tmp = vshEditWriteToTempFile(ctl, doc);
+    tmp = virshEditWriteToTempFile(ctl, doc);
     if (!tmp)
         goto edit_cleanup;
 
@@ -81,12 +81,12 @@ do {
 #endif
 
     /* Start the editor. */
-    if (vshEditFile(ctl, tmp) == -1)
+    if (virshEditFile(ctl, tmp) == -1)
         goto edit_cleanup;
 
     /* Read back the edited file. */
     VIR_FREE(doc_edited);
-    doc_edited = vshEditReadBackFile(ctl, tmp);
+    doc_edited = virshEditReadBackFile(ctl, tmp);
     if (!doc_edited)
         goto edit_cleanup;
 
@@ -118,7 +118,7 @@ do {
         msg = _("Failed.");
 
     if (msg) {
-        int c = vshAskReedit(ctl, msg, relax_avail);
+        int c = virshAskReedit(ctl, msg, relax_avail);
         switch (c) {
         case 'y':
             goto reedit;
diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index 66f7fd9..24341ae 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -703,17 +703,17 @@ static const vshCmdOptDef opts_node_cpustats[] = {
 };
 
 typedef enum {
-    VSH_CPU_USER,
-    VSH_CPU_SYSTEM,
-    VSH_CPU_IDLE,
-    VSH_CPU_IOWAIT,
-    VSH_CPU_INTR,
-    VSH_CPU_USAGE,
-    VSH_CPU_LAST
-} vshCPUStats;
-
-VIR_ENUM_DECL(vshCPUStats);
-VIR_ENUM_IMPL(vshCPUStats, VSH_CPU_LAST,
+    VIRSH_CPU_USER,
+    VIRSH_CPU_SYSTEM,
+    VIRSH_CPU_IDLE,
+    VIRSH_CPU_IOWAIT,
+    VIRSH_CPU_INTR,
+    VIRSH_CPU_USAGE,
+    VIRSH_CPU_LAST
+} virshCPUStats;
+
+VIR_ENUM_DECL(virshCPUStats);
+VIR_ENUM_IMPL(virshCPUStats, VIRSH_CPU_LAST,
               VIR_NODE_CPU_STATS_USER,
               VIR_NODE_CPU_STATS_KERNEL,
               VIR_NODE_CPU_STATS_IDLE,
@@ -721,7 +721,7 @@ VIR_ENUM_IMPL(vshCPUStats, VSH_CPU_LAST,
               VIR_NODE_CPU_STATS_INTR,
               VIR_NODE_CPU_STATS_UTILIZATION);
 
-const char *vshCPUOutput[] = {
+const char *virshCPUOutput[] = {
     N_("user:"),
     N_("system:"),
     N_("idle:"),
@@ -739,8 +739,8 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
     virNodeCPUStatsPtr params;
     int nparams = 0;
     bool ret = false;
-    unsigned long long cpu_stats[VSH_CPU_LAST] = { 0 };
-    bool present[VSH_CPU_LAST] = { false };
+    unsigned long long cpu_stats[VIRSH_CPU_LAST] = { 0 };
+    bool present[VIRSH_CPU_LAST] = { false };
 
     if (vshCommandOptInt(ctl, cmd, "cpu", &cpuNum) < 0)
         return false;
@@ -765,7 +765,7 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
         }
 
         for (j = 0; j < nparams; j++) {
-            int field = vshCPUStatsTypeFromString(params[j].field);
+            int field = virshCPUStatsTypeFromString(params[j].field);
 
             if (field < 0)
                 continue;
@@ -778,34 +778,37 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
             }
         }
 
-        if (present[VSH_CPU_USAGE] || !flag_percent)
+        if (present[VIRSH_CPU_USAGE] || !flag_percent)
             break;
 
         sleep(1);
     }
 
     if (!flag_percent) {
-        for (i = 0; i < VSH_CPU_USAGE; i++) {
+        for (i = 0; i < VIRSH_CPU_USAGE; i++) {
             if (present[i]) {
-                vshPrint(ctl, "%-15s %20llu\n", _(vshCPUOutput[i]),
+                vshPrint(ctl, "%-15s %20llu\n", _(virshCPUOutput[i]),
                          cpu_stats[i]);
             }
         }
     } else {
-        if (present[VSH_CPU_USAGE]) {
-            vshPrint(ctl, "%-15s %5.1llu%%\n", _("usage:"), cpu_stats[VSH_CPU_USAGE]);
-            vshPrint(ctl, "%-15s %5.1llu%%\n", _("idle:"), 100 - cpu_stats[VSH_CPU_USAGE]);
+        if (present[VIRSH_CPU_USAGE]) {
+            vshPrint(ctl, "%-15s %5.1llu%%\n",
+                     _("usage:"), cpu_stats[VIRSH_CPU_USAGE]);
+            vshPrint(ctl, "%-15s %5.1llu%%\n",
+                     _("idle:"), 100 - cpu_stats[VIRSH_CPU_USAGE]);
         } else {
             double usage, total_time = 0;
-            for (i = 0; i < VSH_CPU_USAGE; i++)
+            for (i = 0; i < VIRSH_CPU_USAGE; i++)
                 total_time += cpu_stats[i];
 
-            usage = (cpu_stats[VSH_CPU_USER] + cpu_stats[VSH_CPU_SYSTEM]) / total_time * 100;
+            usage = (cpu_stats[VIRSH_CPU_USER] + cpu_stats[VIRSH_CPU_SYSTEM])
+                / total_time * 100;
 
             vshPrint(ctl, "%-15s %5.1lf%%\n", _("usage:"), usage);
-            for (i = 0; i < VSH_CPU_USAGE; i++) {
+            for (i = 0; i < VIRSH_CPU_USAGE; i++) {
                 if (present[i]) {
-                    vshPrint(ctl, "%-15s %5.1lf%%\n", _(vshCPUOutput[i]),
+                    vshPrint(ctl, "%-15s %5.1lf%%\n", _(virshCPUOutput[i]),
                              cpu_stats[i] / total_time * 100);
                 }
             }
diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c
index 6ad5345..8b085cd 100644
--- a/tools/virsh-interface.c
+++ b/tools/virsh-interface.c
@@ -41,9 +41,9 @@
 #include "virstring.h"
 
 virInterfacePtr
-vshCommandOptInterfaceBy(vshControl *ctl, const vshCmd *cmd,
-                         const char *optname,
-                         const char **name, unsigned int flags)
+virshCommandOptInterfaceBy(vshControl *ctl, const vshCmd *cmd,
+                           const char *optname,
+                           const char **name, unsigned int flags)
 {
     virInterfacePtr iface = NULL;
     const char *n = NULL;
@@ -115,7 +115,7 @@ cmdInterfaceEdit(vshControl *ctl, const vshCmd *cmd)
     virInterfacePtr iface_edited = NULL;
     unsigned int flags = VIR_INTERFACE_XML_INACTIVE;
 
-    iface = vshCommandOptInterface(ctl, cmd, NULL);
+    iface = virshCommandOptInterface(ctl, cmd, NULL);
     if (iface == NULL)
         goto cleanup;
 
@@ -402,8 +402,8 @@ cmdInterfaceName(vshControl *ctl, const vshCmd *cmd)
 {
     virInterfacePtr iface;
 
-    if (!(iface = vshCommandOptInterfaceBy(ctl, cmd, NULL, NULL,
-                                           VSH_BYMAC)))
+    if (!(iface = virshCommandOptInterfaceBy(ctl, cmd, NULL, NULL,
+                                             VSH_BYMAC)))
         return false;
 
     vshPrint(ctl, "%s\n", virInterfaceGetName(iface));
@@ -438,8 +438,8 @@ cmdInterfaceMAC(vshControl *ctl, const vshCmd *cmd)
 {
     virInterfacePtr iface;
 
-    if (!(iface = vshCommandOptInterfaceBy(ctl, cmd, NULL, NULL,
-                                           VSH_BYNAME)))
+    if (!(iface = virshCommandOptInterfaceBy(ctl, cmd, NULL, NULL,
+                                             VSH_BYNAME)))
         return false;
 
     vshPrint(ctl, "%s\n", virInterfaceGetMACString(iface));
@@ -485,7 +485,7 @@ cmdInterfaceDumpXML(vshControl *ctl, const vshCmd *cmd)
     if (inactive)
         flags |= VIR_INTERFACE_XML_INACTIVE;
 
-    if (!(iface = vshCommandOptInterface(ctl, cmd, NULL)))
+    if (!(iface = virshCommandOptInterface(ctl, cmd, NULL)))
         return false;
 
     dump = virInterfaceGetXMLDesc(iface, flags);
@@ -534,7 +534,7 @@ cmdInterfaceDefine(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
         return false;
 
-    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
+    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
         return false;
 
     iface = virInterfaceDefineXML(ctl->conn, buffer, 0);
@@ -580,7 +580,7 @@ cmdInterfaceUndefine(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name;
 
-    if (!(iface = vshCommandOptInterface(ctl, cmd, &name)))
+    if (!(iface = virshCommandOptInterface(ctl, cmd, &name)))
         return false;
 
     if (virInterfaceUndefine(iface) == 0) {
@@ -623,7 +623,7 @@ cmdInterfaceStart(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name;
 
-    if (!(iface = vshCommandOptInterface(ctl, cmd, &name)))
+    if (!(iface = virshCommandOptInterface(ctl, cmd, &name)))
         return false;
 
     if (virInterfaceCreate(iface, 0) == 0) {
@@ -666,7 +666,7 @@ cmdInterfaceDestroy(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name;
 
-    if (!(iface = vshCommandOptInterface(ctl, cmd, &name)))
+    if (!(iface = virshCommandOptInterface(ctl, cmd, &name)))
         return false;
 
     if (virInterfaceDestroy(iface, 0) == 0) {
@@ -825,8 +825,8 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd)
     xmlNodePtr top_node, br_node, if_node, cur;
 
     /* Get a handle to the original device */
-    if (!(if_handle = vshCommandOptInterfaceBy(ctl, cmd, "interface",
-                                               &if_name, VSH_BYNAME))) {
+    if (!(if_handle = virshCommandOptInterfaceBy(ctl, cmd, "interface",
+                                                 &if_name, VSH_BYNAME))) {
         goto cleanup;
     }
 
@@ -1045,8 +1045,8 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd)
     xmlNodePtr top_node, if_node, cur;
 
     /* Get a handle to the original device */
-    if (!(br_handle = vshCommandOptInterfaceBy(ctl, cmd, "bridge",
-                                               &br_name, VSH_BYNAME))) {
+    if (!(br_handle = virshCommandOptInterfaceBy(ctl, cmd, "bridge",
+                                                 &br_name, VSH_BYNAME))) {
         goto cleanup;
     }
 
diff --git a/tools/virsh-interface.h b/tools/virsh-interface.h
index 6272aab..be756ec 100644
--- a/tools/virsh-interface.h
+++ b/tools/virsh-interface.h
@@ -28,14 +28,14 @@
 
 # include "virsh.h"
 
-virInterfacePtr vshCommandOptInterfaceBy(vshControl *ctl, const vshCmd *cmd,
-                                         const char *optname,
-                                         const char **name, unsigned int flags);
+virInterfacePtr virshCommandOptInterfaceBy(vshControl *ctl, const vshCmd *cmd,
+                                           const char *optname,
+                                           const char **name, unsigned int flags);
 
 /* default is lookup by Name and MAC */
-# define vshCommandOptInterface(_ctl, _cmd, _name)                    \
-    vshCommandOptInterfaceBy(_ctl, _cmd, NULL, _name,                \
-                             VSH_BYMAC|VSH_BYNAME)
+# define virshCommandOptInterface(_ctl, _cmd, _name)                    \
+    virshCommandOptInterfaceBy(_ctl, _cmd, NULL, _name,                 \
+                               VSH_BYMAC|VSH_BYNAME)
 
 extern const vshCmdDef ifaceCmds[];
 
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 66123c4..79909d9 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -34,8 +34,8 @@
 #include "conf/network_conf.h"
 
 virNetworkPtr
-vshCommandOptNetworkBy(vshControl *ctl, const vshCmd *cmd,
-                       const char **name, unsigned int flags)
+virshCommandOptNetworkBy(vshControl *ctl, const vshCmd *cmd,
+                         const char **name, unsigned int flags)
 {
     virNetworkPtr network = NULL;
     const char *n = NULL;
@@ -103,7 +103,7 @@ cmdNetworkAutostart(vshControl *ctl, const vshCmd *cmd)
     const char *name;
     int autostart;
 
-    if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))
+    if (!(network = virshCommandOptNetwork(ctl, cmd, &name)))
         return false;
 
     autostart = !vshCommandOptBool(cmd, "disable");
@@ -159,7 +159,7 @@ cmdNetworkCreate(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
         return false;
 
-    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
+    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
         return false;
 
     network = virNetworkCreateXML(ctl->conn, buffer);
@@ -210,7 +210,7 @@ cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
         return false;
 
-    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
+    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
         return false;
 
     network = virNetworkDefineXML(ctl->conn, buffer);
@@ -256,7 +256,7 @@ cmdNetworkDestroy(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name;
 
-    if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))
+    if (!(network = virshCommandOptNetwork(ctl, cmd, &name)))
         return false;
 
     if (virNetworkDestroy(network) == 0) {
@@ -305,7 +305,7 @@ cmdNetworkDumpXML(vshControl *ctl, const vshCmd *cmd)
     unsigned int flags = 0;
     int inactive;
 
-    if (!(network = vshCommandOptNetwork(ctl, cmd, NULL)))
+    if (!(network = virshCommandOptNetwork(ctl, cmd, NULL)))
         return false;
 
     inactive = vshCommandOptBool(cmd, "inactive");
@@ -357,7 +357,7 @@ cmdNetworkInfo(vshControl *ctl, const vshCmd *cmd)
     int active = -1;
     char *bridge = NULL;
 
-    if (!(network = vshCommandOptNetwork(ctl, cmd, NULL)))
+    if (!(network = virshCommandOptNetwork(ctl, cmd, NULL)))
         return false;
 
     vshPrint(ctl, "%-15s %s\n", _("Name:"), virNetworkGetName(network));
@@ -768,7 +768,7 @@ cmdNetworkName(vshControl *ctl, const vshCmd *cmd)
 {
     virNetworkPtr network;
 
-    if (!(network = vshCommandOptNetworkBy(ctl, cmd, NULL,
+    if (!(network = virshCommandOptNetworkBy(ctl, cmd, NULL,
                                            VSH_BYUUID)))
         return false;
 
@@ -806,7 +806,7 @@ cmdNetworkStart(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name = NULL;
 
-    if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))
+    if (!(network = virshCommandOptNetwork(ctl, cmd, &name)))
          return false;
 
     if (virNetworkCreate(network) == 0) {
@@ -848,7 +848,7 @@ cmdNetworkUndefine(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name;
 
-    if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))
+    if (!(network = virshCommandOptNetwork(ctl, cmd, &name)))
         return false;
 
     if (virNetworkUndefine(network) == 0) {
@@ -943,7 +943,7 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd)
     unsigned int flags = 0;
     const char *affected;
 
-    if (!(network = vshCommandOptNetwork(ctl, cmd, NULL)))
+    if (!(network = virshCommandOptNetwork(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "command", &commandStr) < 0)
@@ -986,7 +986,7 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd)
         /* contents of xmldata is actually the name of a file that
          * contains the xml.
          */
-        if (virFileReadAll(xml, VSH_MAX_XML_FILE, &xmlFromFile) < 0)
+        if (virFileReadAll(xml, VIRSH_MAX_XML_FILE, &xmlFromFile) < 0)
             goto cleanup;
         /* NB: the original xml is just a const char * that points
          * to a string owned by the vshCmd object, and will be freed
@@ -1066,7 +1066,7 @@ cmdNetworkUuid(vshControl *ctl, const vshCmd *cmd)
     virNetworkPtr network;
     char uuid[VIR_UUID_STRING_BUFLEN];
 
-    if (!(network = vshCommandOptNetworkBy(ctl, cmd, NULL,
+    if (!(network = virshCommandOptNetworkBy(ctl, cmd, NULL,
                                            VSH_BYNAME)))
         return false;
 
@@ -1124,7 +1124,7 @@ cmdNetworkEdit(vshControl *ctl, const vshCmd *cmd)
     virNetworkPtr network = NULL;
     virNetworkPtr network_edited = NULL;
 
-    network = vshCommandOptNetwork(ctl, cmd, NULL);
+    network = virshCommandOptNetwork(ctl, cmd, NULL);
     if (network == NULL)
         goto cleanup;
 
@@ -1270,11 +1270,11 @@ cmdNetworkEvent(vshControl *ctl, const vshCmd *cmd)
     data.ctl = ctl;
     data.loop = vshCommandOptBool(cmd, "loop");
     data.count = 0;
-    if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
+    if (virshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
         return false;
 
     if (vshCommandOptBool(cmd, "network"))
-        net = vshCommandOptNetwork(ctl, cmd, NULL);
+        net = virshCommandOptNetwork(ctl, cmd, NULL);
     if (vshEventStart(ctl, timeout) < 0)
         goto cleanup;
 
@@ -1369,7 +1369,7 @@ cmdNetworkDHCPLeases(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptString(ctl, cmd, "mac", &mac) < 0)
         return false;
 
-    if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))
+    if (!(network = virshCommandOptNetwork(ctl, cmd, &name)))
         return false;
 
     if ((nleases = virNetworkGetDHCPLeases(network, mac, &leases, flags)) < 0) {
diff --git a/tools/virsh-network.h b/tools/virsh-network.h
index 3beeeb9..49823a8 100644
--- a/tools/virsh-network.h
+++ b/tools/virsh-network.h
@@ -29,13 +29,13 @@
 # include "virsh.h"
 
 virNetworkPtr
-vshCommandOptNetworkBy(vshControl *ctl, const vshCmd *cmd,
-                       const char **name, unsigned int flags);
+virshCommandOptNetworkBy(vshControl *ctl, const vshCmd *cmd,
+                         const char **name, unsigned int flags);
 
 /* default is lookup by Name and UUID */
-# define vshCommandOptNetwork(_ctl, _cmd, _name)                    \
-    vshCommandOptNetworkBy(_ctl, _cmd, _name,                      \
-                           VSH_BYUUID|VSH_BYNAME)
+# define virshCommandOptNetwork(_ctl, _cmd, _name)                    \
+    virshCommandOptNetworkBy(_ctl, _cmd, _name,                       \
+                             VSH_BYUUID|VSH_BYNAME)
 
 extern const vshCmdDef networkCmds[];
 
diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
index 8c578d1..adf4423 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -69,7 +69,7 @@ cmdNodeDeviceCreate(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
         return false;
 
-    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
+    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
         return false;
 
     dev = virNodeDeviceCreateXML(ctl->conn, buffer, 0);
@@ -480,8 +480,8 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
 
         for (i = 0; i < list->ndevices; i++) {
             if (parents[i] == NULL &&
-                vshTreePrint(ctl, vshNodeListLookup, &arrays,
-                             list->ndevices, i) < 0)
+                virshTreePrint(ctl, vshNodeListLookup, &arrays,
+                               list->ndevices, i) < 0)
                 ret = false;
         }
 
diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c
index 63c1c7e..d2c8a79 100644
--- a/tools/virsh-nwfilter.c
+++ b/tools/virsh-nwfilter.c
@@ -33,8 +33,8 @@
 #include "virutil.h"
 
 virNWFilterPtr
-vshCommandOptNWFilterBy(vshControl *ctl, const vshCmd *cmd,
-                        const char **name, unsigned int flags)
+virshCommandOptNWFilterBy(vshControl *ctl, const vshCmd *cmd,
+                          const char **name, unsigned int flags)
 {
     virNWFilterPtr nwfilter = NULL;
     const char *n = NULL;
@@ -102,7 +102,7 @@ cmdNWFilterDefine(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
         return false;
 
-    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
+    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
         return false;
 
     nwfilter = virNWFilterDefineXML(ctl->conn, buffer);
@@ -148,7 +148,7 @@ cmdNWFilterUndefine(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name;
 
-    if (!(nwfilter = vshCommandOptNWFilter(ctl, cmd, &name)))
+    if (!(nwfilter = virshCommandOptNWFilter(ctl, cmd, &name)))
         return false;
 
     if (virNWFilterUndefine(nwfilter) == 0) {
@@ -191,7 +191,7 @@ cmdNWFilterDumpXML(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     char *dump;
 
-    if (!(nwfilter = vshCommandOptNWFilter(ctl, cmd, NULL)))
+    if (!(nwfilter = virshCommandOptNWFilter(ctl, cmd, NULL)))
         return false;
 
     dump = virNWFilterGetXMLDesc(nwfilter, 0);
@@ -407,7 +407,7 @@ cmdNWFilterEdit(vshControl *ctl, const vshCmd *cmd)
     virNWFilterPtr nwfilter = NULL;
     virNWFilterPtr nwfilter_edited = NULL;
 
-    nwfilter = vshCommandOptNWFilter(ctl, cmd, NULL);
+    nwfilter = virshCommandOptNWFilter(ctl, cmd, NULL);
     if (nwfilter == NULL)
         goto cleanup;
 
diff --git a/tools/virsh-nwfilter.h b/tools/virsh-nwfilter.h
index a9a995f..a570813 100644
--- a/tools/virsh-nwfilter.h
+++ b/tools/virsh-nwfilter.h
@@ -29,13 +29,13 @@
 # include "virsh.h"
 
 virNWFilterPtr
-vshCommandOptNWFilterBy(vshControl *ctl, const vshCmd *cmd,
-                        const char **name, unsigned int flags);
+virshCommandOptNWFilterBy(vshControl *ctl, const vshCmd *cmd,
+                          const char **name, unsigned int flags);
 
 /* default is lookup by Name and UUID */
-# define vshCommandOptNWFilter(_ctl, _cmd, _name)                    \
-    vshCommandOptNWFilterBy(_ctl, _cmd, _name,                      \
-                            VSH_BYUUID|VSH_BYNAME)
+# define virshCommandOptNWFilter(_ctl, _cmd, _name)                    \
+    virshCommandOptNWFilterBy(_ctl, _cmd, _name,                       \
+                              VSH_BYUUID|VSH_BYNAME)
 
 extern const vshCmdDef nwfilterCmds[];
 
diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
index b420fe2..19c1f28 100644
--- a/tools/virsh-pool.c
+++ b/tools/virsh-pool.c
@@ -34,8 +34,8 @@
 #include "virstring.h"
 
 virStoragePoolPtr
-vshCommandOptPoolBy(vshControl *ctl, const vshCmd *cmd, const char *optname,
-                    const char **name, unsigned int flags)
+virshCommandOptPoolBy(vshControl *ctl, const vshCmd *cmd, const char *optname,
+                      const char **name, unsigned int flags)
 {
     virStoragePoolPtr pool = NULL;
     const char *n = NULL;
@@ -102,7 +102,7 @@ cmdPoolAutostart(vshControl *ctl, const vshCmd *cmd)
     const char *name;
     int autostart;
 
-    if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
+    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", &name)))
         return false;
 
     autostart = !vshCommandOptBool(cmd, "disable");
@@ -158,7 +158,7 @@ cmdPoolCreate(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
         return false;
 
-    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
+    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
         return false;
 
     pool = virStoragePoolCreateXML(ctl->conn, buffer, 0);
@@ -421,7 +421,7 @@ cmdPoolDefine(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
         return false;
 
-    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
+    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
         return false;
 
     pool = virStoragePoolDefineXML(ctl->conn, buffer, 0);
@@ -518,7 +518,7 @@ cmdPoolBuild(vshControl *ctl, const vshCmd *cmd)
     const char *name;
     unsigned int flags = 0;
 
-    if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
+    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", &name)))
         return false;
 
     if (vshCommandOptBool(cmd, "no-overwrite"))
@@ -568,7 +568,7 @@ cmdPoolDestroy(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name;
 
-    if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
+    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", &name)))
         return false;
 
     if (virStoragePoolDestroy(pool) == 0) {
@@ -611,7 +611,7 @@ cmdPoolDelete(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name;
 
-    if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
+    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", &name)))
         return false;
 
     if (virStoragePoolDelete(pool, 0) == 0) {
@@ -654,7 +654,7 @@ cmdPoolRefresh(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name;
 
-    if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
+    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", &name)))
         return false;
 
     if (virStoragePoolRefresh(pool, 0) == 0) {
@@ -706,7 +706,7 @@ cmdPoolDumpXML(vshControl *ctl, const vshCmd *cmd)
     if (inactive)
         flags |= VIR_STORAGE_XML_INACTIVE;
 
-    if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
+    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
         return false;
 
     dump = virStoragePoolGetXMLDesc(pool, flags);
@@ -946,8 +946,8 @@ vshStoragePoolListCollect(vshControl *ctl,
 }
 
 
-VIR_ENUM_DECL(vshStoragePoolState)
-VIR_ENUM_IMPL(vshStoragePoolState,
+VIR_ENUM_DECL(virshStoragePoolState)
+VIR_ENUM_IMPL(virshStoragePoolState,
               VIR_STORAGE_POOL_STATE_LAST,
               N_("inactive"),
               N_("building"),
@@ -956,9 +956,9 @@ VIR_ENUM_IMPL(vshStoragePoolState,
               N_("inaccessible"))
 
 static const char *
-vshStoragePoolStateToString(int state)
+virshStoragePoolStateToString(int state)
 {
-    const char *str = vshStoragePoolStateTypeToString(state);
+    const char *str = virshStoragePoolStateTypeToString(state);
     return str ? _(str) : _("unknown");
 }
 
@@ -1168,7 +1168,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
         } else {
             /* Decide which state string to display */
             if (details) {
-                const char *state = vshStoragePoolStateToString(info.state);
+                const char *state = virshStoragePoolStateToString(info.state);
 
                 poolInfoTexts[i].state = vshStrdup(ctl, state);
 
@@ -1178,17 +1178,17 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
                     double val;
                     const char *unit;
 
-                    val = vshPrettyCapacity(info.capacity, &unit);
+                    val = virshPrettyCapacity(info.capacity, &unit);
                     if (virAsprintf(&poolInfoTexts[i].capacity,
                                     "%.2lf %s", val, unit) < 0)
                         goto cleanup;
 
-                    val = vshPrettyCapacity(info.allocation, &unit);
+                    val = virshPrettyCapacity(info.allocation, &unit);
                     if (virAsprintf(&poolInfoTexts[i].allocation,
                                     "%.2lf %s", val, unit) < 0)
                         goto cleanup;
 
-                    val = vshPrettyCapacity(info.available, &unit);
+                    val = virshPrettyCapacity(info.available, &unit);
                     if (virAsprintf(&poolInfoTexts[i].available,
                                     "%.2lf %s", val, unit) < 0)
                         goto cleanup;
@@ -1503,7 +1503,7 @@ cmdPoolDiscoverSources(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
     if (vshCommandOptStringReq(ctl, cmd, "srcSpec", &srcSpecFile) < 0)
         return false;
 
-    if (srcSpecFile && virFileReadAll(srcSpecFile, VSH_MAX_XML_FILE,
+    if (srcSpecFile && virFileReadAll(srcSpecFile, VIRSH_MAX_XML_FILE,
                                       &srcSpec) < 0)
         return false;
 
@@ -1551,7 +1551,7 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     char uuid[VIR_UUID_STRING_BUFLEN];
 
-    if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
+    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
         return false;
 
     vshPrint(ctl, "%-15s %s\n", _("Name:"), virStoragePoolGetName(pool));
@@ -1563,7 +1563,7 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd)
         double val;
         const char *unit;
         vshPrint(ctl, "%-15s %s\n", _("State:"),
-                 vshStoragePoolStateToString(info.state));
+                 virshStoragePoolStateToString(info.state));
 
         /* Check and display whether the pool is persistent or not */
         persistent = virStoragePoolIsPersistent(pool);
@@ -1582,13 +1582,13 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd)
 
         if (info.state == VIR_STORAGE_POOL_RUNNING ||
             info.state == VIR_STORAGE_POOL_DEGRADED) {
-            val = vshPrettyCapacity(info.capacity, &unit);
+            val = virshPrettyCapacity(info.capacity, &unit);
             vshPrint(ctl, "%-15s %2.2lf %s\n", _("Capacity:"), val, unit);
 
-            val = vshPrettyCapacity(info.allocation, &unit);
+            val = virshPrettyCapacity(info.allocation, &unit);
             vshPrint(ctl, "%-15s %2.2lf %s\n", _("Allocation:"), val, unit);
 
-            val = vshPrettyCapacity(info.available, &unit);
+            val = virshPrettyCapacity(info.available, &unit);
             vshPrint(ctl, "%-15s %2.2lf %s\n", _("Available:"), val, unit);
         }
     } else {
@@ -1626,8 +1626,7 @@ cmdPoolName(vshControl *ctl, const vshCmd *cmd)
 {
     virStoragePoolPtr pool;
 
-    if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
-                                           VSH_BYUUID)))
+    if (!(pool = virshCommandOptPoolBy(ctl, cmd, "pool", NULL, VSH_BYUUID)))
         return false;
 
     vshPrint(ctl, "%s\n", virStoragePoolGetName(pool));
@@ -1664,7 +1663,7 @@ cmdPoolStart(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name = NULL;
 
-    if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
+    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", &name)))
          return false;
 
     if (virStoragePoolCreate(pool, 0) == 0) {
@@ -1707,7 +1706,7 @@ cmdPoolUndefine(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name;
 
-    if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
+    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", &name)))
         return false;
 
     if (virStoragePoolUndefine(pool) == 0) {
@@ -1749,8 +1748,7 @@ cmdPoolUuid(vshControl *ctl, const vshCmd *cmd)
     virStoragePoolPtr pool;
     char uuid[VIR_UUID_STRING_BUFLEN];
 
-    if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
-                                           VSH_BYNAME)))
+    if (!(pool = virshCommandOptPoolBy(ctl, cmd, "pool", NULL, VSH_BYNAME)))
         return false;
 
     if (virStoragePoolGetUUIDString(pool, uuid) != -1)
@@ -1793,7 +1791,7 @@ cmdPoolEdit(vshControl *ctl, const vshCmd *cmd)
     unsigned int flags = VIR_STORAGE_XML_INACTIVE;
     char *tmp_desc = NULL;
 
-    pool = vshCommandOptPool(ctl, cmd, "pool", NULL);
+    pool = virshCommandOptPool(ctl, cmd, "pool", NULL);
     if (pool == NULL)
         goto cleanup;
 
diff --git a/tools/virsh-pool.h b/tools/virsh-pool.h
index 4f6759c..b5b0836 100644
--- a/tools/virsh-pool.h
+++ b/tools/virsh-pool.h
@@ -29,13 +29,13 @@
 # include "virsh.h"
 
 virStoragePoolPtr
-vshCommandOptPoolBy(vshControl *ctl, const vshCmd *cmd, const char *optname,
-                    const char **name, unsigned int flags);
+virshCommandOptPoolBy(vshControl *ctl, const vshCmd *cmd, const char *optname,
+                      const char **name, unsigned int flags);
 
 /* default is lookup by Name and UUID */
-# define vshCommandOptPool(_ctl, _cmd, _optname, _name)           \
-    vshCommandOptPoolBy(_ctl, _cmd, _optname, _name,             \
-                           VSH_BYUUID|VSH_BYNAME)
+# define virshCommandOptPool(_ctl, _cmd, _optname, _name)           \
+    virshCommandOptPoolBy(_ctl, _cmd, _optname, _name,              \
+                          VSH_BYUUID|VSH_BYNAME)
 
 extern const vshCmdDef storagePoolCmds[];
 
diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c
index c6ceabd..d78ef9d 100644
--- a/tools/virsh-secret.c
+++ b/tools/virsh-secret.c
@@ -35,7 +35,7 @@
 #include "conf/secret_conf.h"
 
 static virSecretPtr
-vshCommandOptSecret(vshControl *ctl, const vshCmd *cmd, const char **name)
+virshCommandOptSecret(vshControl *ctl, const vshCmd *cmd, const char **name)
 {
     virSecretPtr secret = NULL;
     const char *n = NULL;
@@ -92,7 +92,7 @@ cmdSecretDefine(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
         return false;
 
-    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
+    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
         return false;
 
     if (!(res = virSecretDefineXML(ctl->conn, buffer, 0))) {
@@ -144,7 +144,7 @@ cmdSecretDumpXML(vshControl *ctl, const vshCmd *cmd)
     bool ret = false;
     char *xml;
 
-    secret = vshCommandOptSecret(ctl, cmd, NULL);
+    secret = virshCommandOptSecret(ctl, cmd, NULL);
     if (secret == NULL)
         return false;
 
@@ -197,7 +197,7 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd)
     int res;
     bool ret = false;
 
-    if (!(secret = vshCommandOptSecret(ctl, cmd, NULL)))
+    if (!(secret = virshCommandOptSecret(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "base64", &base64) < 0)
@@ -259,7 +259,7 @@ cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd)
     size_t value_size;
     bool ret = false;
 
-    secret = vshCommandOptSecret(ctl, cmd, NULL);
+    secret = virshCommandOptSecret(ctl, cmd, NULL);
     if (secret == NULL)
         return false;
 
@@ -314,7 +314,7 @@ cmdSecretUndefine(vshControl *ctl, const vshCmd *cmd)
     bool ret = false;
     const char *uuid;
 
-    secret = vshCommandOptSecret(ctl, cmd, &uuid);
+    secret = virshCommandOptSecret(ctl, cmd, &uuid);
     if (secret == NULL)
         return false;
 
diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index de84175..5130479 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -44,8 +44,8 @@
 
 /* Helper for snapshot-create and snapshot-create-as */
 static bool
-vshSnapshotCreate(vshControl *ctl, virDomainPtr dom, const char *buffer,
-                  unsigned int flags, const char *from)
+virshSnapshotCreate(vshControl *ctl, virDomainPtr dom, const char *buffer,
+                    unsigned int flags, const char *from)
 {
     bool ret = false;
     virDomainSnapshotPtr snapshot;
@@ -199,7 +199,7 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "live"))
         flags |= VIR_DOMAIN_SNAPSHOT_CREATE_LIVE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         goto cleanup;
 
     if (vshCommandOptStringReq(ctl, cmd, "xmlfile", &from) < 0)
@@ -207,13 +207,13 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd)
     if (!from) {
         buffer = vshStrdup(ctl, "<domainsnapshot/>");
     } else {
-        if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {
+        if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
             vshSaveLibvirtError();
             goto cleanup;
         }
     }
 
-    ret = vshSnapshotCreate(ctl, dom, buffer, flags, from);
+    ret = virshSnapshotCreate(ctl, dom, buffer, flags, from);
 
  cleanup:
     VIR_FREE(buffer);
@@ -419,7 +419,7 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "live"))
         flags |= VIR_DOMAIN_SNAPSHOT_CREATE_LIVE;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0 ||
@@ -463,7 +463,7 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
     }
 
-    ret = vshSnapshotCreate(ctl, dom, buffer, flags, NULL);
+    ret = virshSnapshotCreate(ctl, dom, buffer, flags, NULL);
 
  cleanup:
     virBufferFreeAndReset(&buf);
@@ -568,7 +568,7 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd)
         vshCommandOptBool(cmd, "snapshotname"))
         define_flags |= VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (vshLookupSnapshot(ctl, cmd, "snapshotname", false, dom,
@@ -682,7 +682,7 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd)
 
     VSH_EXCLUSIVE_OPTIONS("name", "snapshotname");
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, &domname)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, &domname)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "snapshotname", &snapshotname) < 0)
@@ -915,7 +915,7 @@ cmdSnapshotInfo(vshControl *ctl, const vshCmd *cmd)
     int current;
     int metadata;
 
-    dom = vshCommandOptDomain(ctl, cmd, NULL);
+    dom = virshCommandOptDomain(ctl, cmd, NULL);
     if (dom == NULL)
         return false;
 
@@ -1051,10 +1051,10 @@ struct vshSnapshotList {
     struct vshSnap *snaps;
     int nsnaps;
 };
-typedef struct vshSnapshotList *vshSnapshotListPtr;
+typedef struct vshSnapshotList *virshSnapshotListPtr;
 
 static void
-vshSnapshotListFree(vshSnapshotListPtr snaplist)
+vshSnapshotListFree(virshSnapshotListPtr snaplist)
 {
     size_t i;
 
@@ -1090,7 +1090,7 @@ vshSnapSorter(const void *a, const void *b)
  * list is limited to descendants of the given snapshot.  If FLAGS is
  * given, the list is filtered.  If TREE is specified, then all but
  * FROM or the roots will also have parent information.  */
-static vshSnapshotListPtr
+static virshSnapshotListPtr
 vshSnapshotListCollect(vshControl *ctl, virDomainPtr dom,
                        virDomainSnapshotPtr from,
                        unsigned int orig_flags, bool tree)
@@ -1101,8 +1101,8 @@ vshSnapshotListCollect(vshControl *ctl, virDomainPtr dom,
     bool descendants = false;
     bool roots = false;
     virDomainSnapshotPtr *snaps;
-    vshSnapshotListPtr snaplist = vshMalloc(ctl, sizeof(*snaplist));
-    vshSnapshotListPtr ret = NULL;
+    virshSnapshotListPtr snaplist = vshMalloc(ctl, sizeof(*snaplist));
+    virshSnapshotListPtr ret = NULL;
     const char *fromname = NULL;
     int start_index = -1;
     int deleted = 0;
@@ -1416,9 +1416,9 @@ vshSnapshotListCollect(vshControl *ctl, virDomainPtr dom,
 }
 
 static const char *
-vshSnapshotListLookup(int id, bool parent, void *opaque)
+virshSnapshotListLookup(int id, bool parent, void *opaque)
 {
-    vshSnapshotListPtr snaplist = opaque;
+    virshSnapshotListPtr snaplist = opaque;
     if (parent)
         return snaplist->snaps[id].parent;
     return virDomainSnapshotGetName(snaplist->snaps[id].snap);
@@ -1536,7 +1536,7 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
     const char *from_snap = NULL;
     char *parent_snap = NULL;
     virDomainSnapshotPtr start = NULL;
-    vshSnapshotListPtr snaplist = NULL;
+    virshSnapshotListPtr snaplist = NULL;
 
     VSH_EXCLUSIVE_OPTIONS_VAR(tree, name);
     VSH_EXCLUSIVE_OPTIONS_VAR(parent, roots);
@@ -1585,7 +1585,7 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
         flags |= VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS;
     }
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if ((from || current) &&
@@ -1611,8 +1611,8 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
     if (tree) {
         for (i = 0; i < snaplist->nsnaps; i++) {
             if (!snaplist->snaps[i].parent &&
-                vshTreePrint(ctl, vshSnapshotListLookup, snaplist,
-                             snaplist->nsnaps, i) < 0)
+                virshTreePrint(ctl, virshSnapshotListLookup, snaplist,
+                               snaplist->nsnaps, i) < 0)
                 goto cleanup;
         }
         ret = true;
@@ -1735,7 +1735,7 @@ cmdSnapshotDumpXML(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "snapshotname", &name) < 0)
         return false;
 
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
 
     if (!(snapshot = virDomainSnapshotLookupByName(dom, name, 0)))
@@ -1795,7 +1795,7 @@ cmdSnapshotParent(vshControl *ctl, const vshCmd *cmd)
     virDomainSnapshotPtr snapshot = NULL;
     char *parent = NULL;
 
-    dom = vshCommandOptDomain(ctl, cmd, NULL);
+    dom = virshCommandOptDomain(ctl, cmd, NULL);
     if (dom == NULL)
         goto cleanup;
 
@@ -1888,7 +1888,7 @@ cmdDomainSnapshotRevert(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "force"))
         force = true;
 
-    dom = vshCommandOptDomain(ctl, cmd, NULL);
+    dom = virshCommandOptDomain(ctl, cmd, NULL);
     if (dom == NULL)
         goto cleanup;
 
@@ -1968,7 +1968,7 @@ cmdSnapshotDelete(vshControl *ctl, const vshCmd *cmd)
     virDomainSnapshotPtr snapshot = NULL;
     unsigned int flags = 0;
 
-    dom = vshCommandOptDomain(ctl, cmd, NULL);
+    dom = virshCommandOptDomain(ctl, cmd, NULL);
     if (dom == NULL)
         goto cleanup;
 
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
index bb1bfc2..21b7fb0 100644
--- a/tools/virsh-volume.c
+++ b/tools/virsh-volume.c
@@ -43,10 +43,10 @@
 #include "virstring.h"
 
 virStorageVolPtr
-vshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd,
-                   const char *optname,
-                   const char *pooloptname,
-                   const char **name, unsigned int flags)
+virshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd,
+                     const char *optname,
+                     const char *pooloptname,
+                     const char **name, unsigned int flags)
 {
     virStorageVolPtr vol = NULL;
     virStoragePoolPtr pool = NULL;
@@ -61,7 +61,7 @@ vshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd,
         return NULL;
 
     if (p) {
-        if (!(pool = vshCommandOptPoolBy(ctl, cmd, pooloptname, name, flags)))
+        if (!(pool = virshCommandOptPoolBy(ctl, cmd, pooloptname, name, flags)))
             return NULL;
 
         if (virStoragePoolIsActive(pool) != 1) {
@@ -205,7 +205,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "prealloc-metadata"))
         flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
 
-    if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
+    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0)
@@ -380,13 +380,13 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "prealloc-metadata"))
         flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
 
-    if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
+    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
         goto cleanup;
 
-    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {
+    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
         vshSaveLibvirtError();
         goto cleanup;
     }
@@ -460,7 +460,7 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd)
     char *buffer = NULL;
     unsigned int flags = 0;
 
-    if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
+    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
         goto cleanup;
 
     if (vshCommandOptBool(cmd, "prealloc-metadata"))
@@ -472,10 +472,10 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
         goto cleanup;
 
-    if (!(inputvol = vshCommandOptVol(ctl, cmd, "vol", "inputpool", NULL)))
+    if (!(inputvol = virshCommandOptVol(ctl, cmd, "vol", "inputpool", NULL)))
         goto cleanup;
 
-    if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {
+    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) {
         vshReportError(ctl);
         goto cleanup;
     }
@@ -581,7 +581,7 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd)
     bool ret = false;
     unsigned int flags = 0;
 
-    if (!(origvol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
+    if (!(origvol = virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
         goto cleanup;
 
     if (vshCommandOptBool(cmd, "prealloc-metadata"))
@@ -699,7 +699,7 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptULongLongWrap(ctl, cmd, "length", &length) < 0)
         return false;
 
-    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
+    if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "file", &file) < 0)
@@ -804,7 +804,7 @@ cmdVolDownload(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptULongLongWrap(ctl, cmd, "length", &length) < 0)
         return false;
 
-    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
+    if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "file", &file) < 0)
@@ -830,7 +830,7 @@ cmdVolDownload(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
     }
 
-    if (virStreamRecvAll(st, vshStreamSink, &fd) < 0) {
+    if (virStreamRecvAll(st, virshStreamSink, &fd) < 0) {
         vshError(ctl, _("cannot receive data from volume %s"), name);
         goto cleanup;
     }
@@ -892,7 +892,7 @@ cmdVolDelete(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     const char *name;
 
-    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
+    if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
         return false;
 
     if (virStorageVolDelete(vol, 0) == 0) {
@@ -951,7 +951,7 @@ cmdVolWipe(vshControl *ctl, const vshCmd *cmd)
     int algorithm = VIR_STORAGE_VOL_WIPE_ALG_ZERO;
     int funcRet;
 
-    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
+    if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "algorithm", &algorithm_str) < 0)
@@ -1032,7 +1032,7 @@ cmdVolInfo(vshControl *ctl, const vshCmd *cmd)
     virStorageVolPtr vol;
     bool ret = true;
 
-    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
+    if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
         return false;
 
     vshPrint(ctl, "%-15s %s\n", _("Name:"), virStorageVolGetName(vol));
@@ -1044,10 +1044,10 @@ cmdVolInfo(vshControl *ctl, const vshCmd *cmd)
         vshPrint(ctl, "%-15s %s\n", _("Type:"),
                  vshVolumeTypeToString(info.type));
 
-        val = vshPrettyCapacity(info.capacity, &unit);
+        val = virshPrettyCapacity(info.capacity, &unit);
         vshPrint(ctl, "%-15s %2.2lf %s\n", _("Capacity:"), val, unit);
 
-        val = vshPrettyCapacity(info.allocation, &unit);
+        val = virshPrettyCapacity(info.allocation, &unit);
         vshPrint(ctl, "%-15s %2.2lf %s\n", _("Allocation:"), val, unit);
     } else {
         ret = false;
@@ -1115,7 +1115,7 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "shrink"))
         flags |= VIR_STORAGE_VOL_RESIZE_SHRINK;
 
-    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
+    if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
         return false;
 
     if (vshCommandOptStringReq(ctl, cmd, "capacity", &capacityStr) < 0)
@@ -1194,7 +1194,7 @@ cmdVolDumpXML(vshControl *ctl, const vshCmd *cmd)
     bool ret = true;
     char *dump;
 
-    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
+    if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
         return false;
 
     dump = virStorageVolGetXMLDesc(vol, 0);
@@ -1225,14 +1225,14 @@ vshStorageVolSorter(const void *a, const void *b)
                       virStorageVolGetName(*vb));
 }
 
-struct vshStorageVolList {
+struct virshStorageVolList {
     virStorageVolPtr *vols;
     size_t nvols;
 };
-typedef struct vshStorageVolList *vshStorageVolListPtr;
+typedef struct virshStorageVolList *virshStorageVolListPtr;
 
 static void
-vshStorageVolListFree(vshStorageVolListPtr list)
+virshStorageVolListFree(virshStorageVolListPtr list)
 {
     size_t i;
 
@@ -1246,12 +1246,12 @@ vshStorageVolListFree(vshStorageVolListPtr list)
     VIR_FREE(list);
 }
 
-static vshStorageVolListPtr
-vshStorageVolListCollect(vshControl *ctl,
-                         virStoragePoolPtr pool,
-                         unsigned int flags)
+static virshStorageVolListPtr
+virshStorageVolListCollect(vshControl *ctl,
+                           virStoragePoolPtr pool,
+                           unsigned int flags)
 {
-    vshStorageVolListPtr list = vshMalloc(ctl, sizeof(*list));
+    virshStorageVolListPtr list = vshMalloc(ctl, sizeof(*list));
     size_t i;
     char **names = NULL;
     virStorageVolPtr vol = NULL;
@@ -1328,7 +1328,7 @@ vshStorageVolListCollect(vshControl *ctl,
     VIR_FREE(names);
 
     if (!success) {
-        vshStorageVolListFree(list);
+        virshStorageVolListFree(list);
         list = NULL;
     }
 
@@ -1383,13 +1383,13 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
         char *type;
     };
     struct volInfoText *volInfoTexts = NULL;
-    vshStorageVolListPtr list = NULL;
+    virshStorageVolListPtr list = NULL;
 
     /* Look up the pool information given to us by the user */
-    if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
+    if (!(pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
         return false;
 
-    if (!(list = vshStorageVolListCollect(ctl, pool, 0)))
+    if (!(list = virshStorageVolListCollect(ctl, pool, 0)))
         goto cleanup;
 
     if (list->nvols > 0)
@@ -1420,12 +1420,12 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
                 volInfoTexts[i].type = vshStrdup(ctl,
                                                  vshVolumeTypeToString(volumeInfo.type));
 
-                val = vshPrettyCapacity(volumeInfo.capacity, &unit);
+                val = virshPrettyCapacity(volumeInfo.capacity, &unit);
                 if (virAsprintf(&volInfoTexts[i].capacity,
                                 "%.2lf %s", val, unit) < 0)
                     goto cleanup;
 
-                val = vshPrettyCapacity(volumeInfo.allocation, &unit);
+                val = virshPrettyCapacity(volumeInfo.allocation, &unit);
                 if (virAsprintf(&volInfoTexts[i].allocation,
                                 "%.2lf %s", val, unit) < 0)
                     goto cleanup;
@@ -1571,7 +1571,7 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
     VIR_FREE(outputStr);
     VIR_FREE(volInfoTexts);
     virStoragePoolFree(pool);
-    vshStorageVolListFree(list);
+    virshStorageVolListFree(list);
 
     /* Return the desired value */
     return ret;
@@ -1604,8 +1604,8 @@ cmdVolName(vshControl *ctl, const vshCmd *cmd)
 {
     virStorageVolPtr vol;
 
-    if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL,
-                                   VSH_BYUUID)))
+    if (!(vol = virshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL,
+                                     VSH_BYUUID)))
         return false;
 
     vshPrint(ctl, "%s\n", virStorageVolGetName(vol));
@@ -1647,8 +1647,8 @@ cmdVolPool(vshControl *ctl, const vshCmd *cmd)
     char uuid[VIR_UUID_STRING_BUFLEN];
 
     /* Use the supplied string to locate the volume */
-    if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL,
-                                   VSH_BYUUID))) {
+    if (!(vol = virshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL,
+                                     VSH_BYUUID))) {
         return false;
     }
 
@@ -1707,7 +1707,7 @@ cmdVolKey(vshControl *ctl, const vshCmd *cmd)
 {
     virStorageVolPtr vol;
 
-    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
+    if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
         return false;
 
     vshPrint(ctl, "%s\n", virStorageVolGetKey(vol));
@@ -1747,7 +1747,7 @@ cmdVolPath(vshControl *ctl, const vshCmd *cmd)
     virStorageVolPtr vol;
     char * StorageVolPath;
 
-    if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
+    if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
         return false;
 
     if ((StorageVolPath = virStorageVolGetPath(vol)) == NULL) {
diff --git a/tools/virsh-volume.h b/tools/virsh-volume.h
index b719d7f..be56928 100644
--- a/tools/virsh-volume.h
+++ b/tools/virsh-volume.h
@@ -28,15 +28,15 @@
 
 # include "virsh.h"
 
-virStorageVolPtr vshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd,
-                                    const char *optname,
-                                    const char *pooloptname,
-                                    const char **name, unsigned int flags);
+virStorageVolPtr virshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd,
+                                      const char *optname,
+                                      const char *pooloptname,
+                                      const char **name, unsigned int flags);
 
 /* default is lookup by Name and UUID */
-# define vshCommandOptVol(_ctl, _cmd, _optname, _pooloptname, _name)   \
-    vshCommandOptVolBy(_ctl, _cmd, _optname, _pooloptname, _name,     \
-                           VSH_BYUUID|VSH_BYNAME)
+# define virshCommandOptVol(_ctl, _cmd, _optname, _pooloptname, _name)   \
+    virshCommandOptVolBy(_ctl, _cmd, _optname, _pooloptname, _name,      \
+                         VSH_BYUUID|VSH_BYNAME)
 
 extern const vshCmdDef storageVolCmds[];
 
diff --git a/tools/virsh.c b/tools/virsh.c
index e833b26..f293d0f 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -139,7 +139,7 @@ vshNameSorter(const void *a, const void *b)
 }
 
 double
-vshPrettyCapacity(unsigned long long val, const char **unit)
+virshPrettyCapacity(unsigned long long val, const char **unit)
 {
     double limit = 1024;
 
@@ -178,146 +178,20 @@ vshPrettyCapacity(unsigned long long val, const char **unit)
 }
 
 /*
- * Convert the strings separated by ',' into array. The returned
- * array is a NULL terminated string list. The caller has to free
- * the array using virStringFreeList or a similar method.
- *
- * Returns the length of the filled array on success, or -1
- * on error.
- */
-int
-vshStringToArray(const char *str,
-                 char ***array)
-{
-    char *str_copied = vshStrdup(NULL, str);
-    char *str_tok = NULL;
-    char *tmp;
-    unsigned int nstr_tokens = 0;
-    char **arr = NULL;
-    size_t len = strlen(str_copied);
-
-    /* tokenize the string from user and save its parts into an array */
-    nstr_tokens = 1;
-
-    /* count the delimiters, recognizing ,, as an escape for a
-     * literal comma */
-    str_tok = str_copied;
-    while ((str_tok = strchr(str_tok, ','))) {
-        if (str_tok[1] == ',')
-            str_tok++;
-        else
-            nstr_tokens++;
-        str_tok++;
-    }
-
-    /* reserve the NULL element at the end */
-    if (VIR_ALLOC_N(arr, nstr_tokens + 1) < 0) {
-        VIR_FREE(str_copied);
-        return -1;
-    }
-
-    /* tokenize the input string, while treating ,, as a literal comma */
-    nstr_tokens = 0;
-    tmp = str_tok = str_copied;
-    while ((tmp = strchr(tmp, ','))) {
-        if (tmp[1] == ',') {
-            memmove(&tmp[1], &tmp[2], len - (tmp - str_copied) - 2 + 1);
-            len--;
-            tmp++;
-            continue;
-        }
-        *tmp++ = '\0';
-        arr[nstr_tokens++] = vshStrdup(NULL, str_tok);
-        str_tok = tmp;
-    }
-    arr[nstr_tokens++] = vshStrdup(NULL, str_tok);
-
-    *array = arr;
-    VIR_FREE(str_copied);
-    return nstr_tokens;
-}
-
-virErrorPtr last_error;
-
-/*
- * Quieten libvirt until we're done with the command.
- */
-static void
-virshErrorHandler(void *unused ATTRIBUTE_UNUSED, virErrorPtr error)
-{
-    virFreeError(last_error);
-    last_error = virSaveLastError();
-    if (virGetEnvAllowSUID("VIRSH_DEBUG") != NULL)
-        virDefaultErrorFunc(error);
-}
-
-/* Store a libvirt error that is from a helper API that doesn't raise errors
- * so it doesn't get overwritten */
-void
-vshSaveLibvirtError(void)
-{
-    virFreeError(last_error);
-    last_error = virSaveLastError();
-}
-
-/*
- * Reset libvirt error on graceful fallback paths
- */
-void
-vshResetLibvirtError(void)
-{
-    virFreeError(last_error);
-    last_error = NULL;
-}
-
-/*
- * Report an error when a command finishes.  This is better than before
- * (when correct operation would report errors), but it has some
- * problems: we lose the smarter formatting of virDefaultErrorFunc(),
- * and it can become harder to debug problems, if errors get reported
- * twice during one command.  This case shouldn't really happen anyway,
- * and it's IMHO a bug that libvirt does that sometimes.
- */
-void
-vshReportError(vshControl *ctl)
-{
-    if (last_error == NULL) {
-        /* Calling directly into libvirt util functions won't trigger the
-         * error callback (which sets last_error), so check it ourselves.
-         *
-         * If the returned error has CODE_OK, this most likely means that
-         * no error was ever raised, so just ignore */
-        last_error = virSaveLastError();
-        if (!last_error || last_error->code == VIR_ERR_OK)
-            goto out;
-    }
-
-    if (last_error->code == VIR_ERR_OK) {
-        vshError(ctl, "%s", _("unknown error"));
-        goto out;
-    }
-
-    vshError(ctl, "%s", last_error->message);
-
- out:
-    vshResetLibvirtError();
-}
-
-/*
  * Detection of disconnections and automatic reconnection support
  */
 static int disconnected; /* we may have been disconnected */
 
 /*
- * vshCatchDisconnect:
+ * virshCatchDisconnect:
  *
  * We get here when the connection was closed.  We can't do much in the
  * handler, just save the fact it was raised.
  */
 static void
-vshCatchDisconnect(virConnectPtr conn ATTRIBUTE_UNUSED,
-                   int reason,
-                   void *opaque ATTRIBUTE_UNUSED)
+virshCatchDisconnect(virConnectPtr conn ATTRIBUTE_UNUSED,
+                     int reason,
+                     void *opaque ATTRIBUTE_UNUSED)
 {
     if (reason != VIR_CONNECT_CLOSE_REASON_CLIENT)
         disconnected++;
@@ -326,7 +200,7 @@ vshCatchDisconnect(virConnectPtr conn ATTRIBUTE_UNUSED,
 /* Main Function which should be used for connecting.
  * This function properly handles keepalive settings. */
 virConnectPtr
-vshConnect(vshControl *ctl, const char *uri, bool readonly)
+virshConnect(vshControl *ctl, const char *uri, bool readonly)
 {
     virConnectPtr c = NULL;
     int interval = 5; /* Default */
@@ -364,13 +238,13 @@ vshConnect(vshControl *ctl, const char *uri, bool readonly)
 }
 
 /*
- * vshReconnect:
+ * virshReconnect:
  *
  * Reconnect after a disconnect from libvirtd
  *
  */
 static void
-vshReconnect(vshControl *ctl)
+virshReconnect(vshControl *ctl)
 {
     bool connected = false;
 
@@ -379,8 +253,8 @@ vshReconnect(vshControl *ctl)
 
         connected = true;
 
-        virConnectUnregisterCloseCallback(ctl->conn, vshCatchDisconnect);
-        ret = virConnectClose(ctl->conn);
+        virConnectUnregisterCloseCallback(priv->conn, virshCatchDisconnect);
+        ret = virConnectClose(priv->conn);
         if (ret < 0)
             vshError(ctl, "%s", _("Failed to disconnect from the hypervisor"));
         else if (ret > 0)
@@ -388,7 +262,7 @@ vshReconnect(vshControl *ctl)
                                   "disconnect from the hypervisor"));
     }
 
-    ctl->conn = vshConnect(ctl, ctl->name, ctl->readonly);
+    ctl->conn = virshConnect(ctl, ctl->name, ctl->readonly);
 
     if (!ctl->conn) {
         if (disconnected)
@@ -396,7 +270,7 @@ vshReconnect(vshControl *ctl)
         else
             vshError(ctl, "%s", _("failed to connect to the hypervisor"));
     } else {
-        if (virConnectRegisterCloseCallback(ctl->conn, vshCatchDisconnect,
+        if (virConnectRegisterCloseCallback(ctl->conn, virshCatchDisconnect,
                                             NULL, NULL) < 0)
             vshError(ctl, "%s", _("Unable to register disconnect callback"));
         if (connected)
@@ -445,8 +319,8 @@ cmdConnect(vshControl *ctl, const vshCmd *cmd)
     if (ctl->conn) {
         int ret;
 
-        virConnectUnregisterCloseCallback(ctl->conn, vshCatchDisconnect);
         ret = virConnectClose(ctl->conn);
+        virConnectUnregisterCloseCallback(priv->conn, virshCatchDisconnect);
         if (ret < 0)
             vshError(ctl, "%s", _("Failed to disconnect from the hypervisor"));
         else if (ret > 0)
@@ -466,14 +340,14 @@ cmdConnect(vshControl *ctl, const vshCmd *cmd)
     ctl->blockJobNoBytes = false;
     ctl->readonly = ro;
 
-    ctl->conn = vshConnect(ctl, ctl->name, ctl->readonly);
+    ctl->conn = virshConnect(ctl, ctl->name, ctl->readonly);
 
     if (!ctl->conn) {
         vshError(ctl, "%s", _("Failed to connect to the hypervisor"));
         return false;
     }
 
-    if (virConnectRegisterCloseCallback(ctl->conn, vshCatchDisconnect,
+    if (virConnectRegisterCloseCallback(ctl->conn, virshCatchDisconnect,
                                         NULL, NULL) < 0)
         vshError(ctl, "%s", _("Unable to register disconnect callback"));
 
@@ -483,7 +357,7 @@ cmdConnect(vshControl *ctl, const vshCmd *cmd)
 
 #ifndef WIN32
 static void
-vshPrintRaw(vshControl *ctl, ...)
+virshPrintRaw(vshControl *ctl, ...)
 {
     va_list ap;
     char *key;
@@ -509,7 +383,7 @@ vshPrintRaw(vshControl *ctl, ...)
  *          0  otherwise
  */
 int
-vshAskReedit(vshControl *ctl, const char *msg, bool relax_avail)
+virshAskReedit(vshControl *ctl, const char *msg, bool relax_avail)
 {
     int c = -1;
 
@@ -527,22 +401,23 @@ vshAskReedit(vshControl *ctl, const char *msg, bool relax_avail)
         c = c_tolower(getchar());
 
         if (c == '?') {
-            vshPrintRaw(ctl,
-                        "",
-                        _("y - yes, start editor again"),
-                        _("n - no, throw away my changes"),
-                        NULL);
+            virshPrintRaw(ctl,
+                          "",
+                          _("y - yes, start editor again"),
+                          _("n - no, throw away my changes"),
+                          NULL);
 
             if (relax_avail) {
-                vshPrintRaw(ctl,
-                            _("i - turn off validation and try to redefine again"),
-                            NULL);
+                virshPrintRaw(ctl,
+                              _("i - turn off validation and try to redefine "
+                                "again"),
+                              NULL);
             }
 
-            vshPrintRaw(ctl,
-                        _("f - force, try to redefine again"),
-                        _("? - print this help"),
-                        NULL);
+            virshPrintRaw(ctl,
+                          _("f - force, try to redefine again"),
+                          _("? - print this help"),
+                          NULL);
             continue;
         } else if (c == 'y' || c == 'n' || c == 'f' ||
                    (relax_avail && c == 'i')) {
@@ -557,9 +432,9 @@ vshAskReedit(vshControl *ctl, const char *msg, bool relax_avail)
 }
 #else /* WIN32 */
 int
-vshAskReedit(vshControl *ctl,
-             const char *msg ATTRIBUTE_UNUSED,
-             bool relax_avail ATTRIBUTE_UNUSED)
+virshAskReedit(vshControl *ctl,
+               const char *msg ATTRIBUTE_UNUSED,
+               bool relax_avail ATTRIBUTE_UNUSED)
 {
     vshDebug(ctl, VSH_ERR_WARNING, "%s", _("This function is not "
                                            "supported on WIN32 platform"));
@@ -567,8 +442,8 @@ vshAskReedit(vshControl *ctl,
 }
 #endif /* WIN32 */
 
-int vshStreamSink(virStreamPtr st ATTRIBUTE_UNUSED,
-                  const char *bytes, size_t nbytes, void *opaque)
+int virshStreamSink(virStreamPtr st ATTRIBUTE_UNUSED,
+                    const char *bytes, size_t nbytes, void *opaque)
 {
     int *fd = opaque;
 
@@ -643,14 +518,14 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd)
 /* Tree listing helpers.  */
 
 static int
-vshTreePrintInternal(vshControl *ctl,
-                     vshTreeLookup lookup,
-                     void *opaque,
-                     int num_devices,
-                     int devid,
-                     int lastdev,
-                     bool root,
-                     virBufferPtr indent)
+virshTreePrintInternal(vshControl *ctl,
+                       vshTreeLookup lookup,
+                       void *opaque,
+                       int num_devices,
+                       int devid,
+                       int lastdev,
+                       bool root,
+                       virBufferPtr indent)
 {
     size_t i;
     int nextlastdev = -1;
@@ -692,7 +567,7 @@ vshTreePrintInternal(vshControl *ctl,
         const char *parent = (lookup)(i, true, opaque);
 
         if (parent && STREQ(parent, dev) &&
-            vshTreePrintInternal(ctl, lookup, opaque,
+            virshTreePrintInternal(ctl, lookup, opaque,
                                  num_devices, i, nextlastdev,
                                  false, indent) < 0)
             goto cleanup;
@@ -712,13 +587,13 @@ vshTreePrintInternal(vshControl *ctl,
 }
 
 int
-vshTreePrint(vshControl *ctl, vshTreeLookup lookup, void *opaque,
-             int num_devices, int devid)
+virshTreePrint(vshControl *ctl, vshTreeLookup lookup, void *opaque,
+               int num_devices, int devid)
 {
     int ret;
     virBuffer indent = VIR_BUFFER_INITIALIZER;
 
-    ret = vshTreePrintInternal(ctl, lookup, opaque, num_devices,
+    ret = virshTreePrintInternal(ctl, lookup, opaque, num_devices,
                                devid, devid, true, &indent);
     if (ret < 0)
         vshError(ctl, "%s", _("Failed to complete tree listing"));
@@ -728,7 +603,7 @@ vshTreePrint(vshControl *ctl, vshTreeLookup lookup, void *opaque,
 
 /* Common code for the edit / net-edit / pool-edit functions which follow. */
 char *
-vshEditWriteToTempFile(vshControl *ctl, const char *doc)
+virshEditWriteToTempFile(vshControl *ctl, const char *doc)
 {
     char *ret;
     const char *tmpdir;
@@ -774,7 +649,7 @@ vshEditWriteToTempFile(vshControl *ctl, const char *doc)
   "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-/_.:@"
 
 int
-vshEditFile(vshControl *ctl, const char *filename)
+virshEditFile(vshControl *ctl, const char *filename)
 {
     const char *editor;
     virCommandPtr cmd;
@@ -826,12 +701,12 @@ vshEditFile(vshControl *ctl, const char *filename)
 }
 
 char *
-vshEditReadBackFile(vshControl *ctl, const char *filename)
+virshEditReadBackFile(vshControl *ctl, const char *filename)
 {
     char *ret;
     char ebuf[1024];
 
-    if (virFileReadAll(filename, VSH_MAX_XML_FILE, &ret) == -1) {
+    if (virFileReadAll(filename, VIRSH_MAX_XML_FILE, &ret) == -1) {
         vshError(ctl,
                  _("%s: failed to read temporary file: %s"),
                  filename, virStrerror(errno, ebuf, sizeof(ebuf)));
@@ -1057,6 +932,18 @@ vshCmddefGetInfo(const vshCmdDef * cmd, const char *name)
 static int
 vshCmddefOptParse(const vshCmdDef *cmd, uint32_t *opts_need_arg,
                   uint32_t *opts_required)
+/*
+ * virshCommandOptTimeoutToMs:
+ * @ctl virsh control structure
+ * @cmd command reference
+ * @timeout result
+ *
+ * Parse an optional --timeout parameter in seconds, but store the
+ * value of the timeout in milliseconds.
+ * See vshCommandOptInt()
+ */
+int
+virshCommandOptTimeoutToMs(vshControl *ctl, const vshCmd *cmd, int *timeout)
 {
     size_t i;
     bool optional = false;
@@ -1134,6 +1021,8 @@ static vshCmdOptDef helpopt = {
 static const vshCmdOptDef *
 vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name,
                    uint32_t *opts_seen, int *opt_index, char **optstr)
+static bool
+virshConnectionUsability(vshControl *ctl, virConnectPtr conn)
 {
     size_t i;
     const vshCmdOptDef *ret = NULL;
@@ -1214,6 +1103,8 @@ vshCmddefGetData(const vshCmdDef *cmd, uint32_t *opts_need_arg,
 static int
 vshCommandCheckOpts(vshControl *ctl, const vshCmd *cmd, uint32_t opts_required,
                     uint32_t opts_seen)
+int
+virshDomainState(vshControl *ctl, virDomainPtr dom, int *reason)
 {
     const vshCmdDef *def = cmd->def;
     size_t i;
@@ -1238,6 +1129,11 @@ vshCommandCheckOpts(vshControl *ctl, const vshCmd *cmd, uint32_t opts_required,
 
 const vshCmdDef *
 vshCmddefSearch(const char *cmdname)
+/*
+ * Initialize connection.
+ */
+static bool
+virshInit(vshControl *ctl)
 {
     const vshCmdGrp *g;
     const vshCmdDef *c;
@@ -1291,6 +1187,8 @@ vshCmdGrpHelp(vshControl *ctl, const char *grpname)
 
 bool
 vshCmddefHelp(vshControl *ctl, const char *cmdname)
+static void
+virshDeinitTimer(int timer ATTRIBUTE_UNUSED, void *opaque ATTRIBUTE_UNUSED)
 {
     const vshCmdDef *def = vshCmddefSearch(cmdname);
 
@@ -1427,6 +1325,8 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname)
  */
 static void
 vshCommandOptFree(vshCmdOpt * arg)
+static bool
+virshDeinit(vshControl *ctl)
 {
     vshCmdOpt *a = arg;
 
@@ -3245,7 +3145,7 @@ vshDeinit(vshControl *ctl)
         virMutexLock(&ctl->lock);
         ctl->quit = true;
         /* HACK: Add a dummy timeout to break event loop */
-        timer = virEventAddTimeout(0, vshDeinitTimer, NULL, NULL);
+        timer = virEventAddTimeout(0, virshDeinitTimer, NULL, NULL);
         virMutexUnlock(&ctl->lock);
 
         virThreadJoin(&ctl->eventLoop);
@@ -3268,7 +3168,7 @@ vshDeinit(vshControl *ctl)
  * Print usage
  */
 static void
-vshUsage(void)
+virshUsage(void)
 {
     const vshCmdGrp *grp;
     const vshCmdDef *cmd;
@@ -3317,7 +3217,7 @@ vshUsage(void)
  * Show version and options compiled in
  */
 static void
-vshShowVersion(vshControl *ctl ATTRIBUTE_UNUSED)
+virshShowVersion(vshControl *ctl ATTRIBUTE_UNUSED)
 {
     /* FIXME - list a copyright blurb, as in GNU programs?  */
     vshPrint(ctl, _("Virsh command line tool of libvirt %s\n"), VERSION);
@@ -3460,7 +3360,7 @@ vshShowVersion(vshControl *ctl ATTRIBUTE_UNUSED)
 }
 
 static bool
-vshAllowedEscapeChar(char c)
+virshAllowedEscapeChar(char c)
 {
     /* Allowed escape characters:
      * a-z A-Z @ [ \ ] ^ _
@@ -3474,7 +3374,7 @@ vshAllowedEscapeChar(char c)
  *
  */
 static bool
-vshParseArgv(vshControl *ctl, int argc, char **argv)
+virshParseArgv(vshControl *ctl, int argc, char **argv)
 {
     int arg, len, debug, keepalive;
     size_t i;
@@ -3519,7 +3419,7 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
             len = strlen(optarg);
 
             if ((len == 2 && *optarg == '^' &&
-                 vshAllowedEscapeChar(optarg[1])) ||
+                 virshAllowedEscapeChar(optarg[1])) ||
                 (len == 1 && *optarg != '^')) {
                 ctl->escapeChar = optarg;
             } else {
@@ -3529,7 +3429,7 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
             }
             break;
         case 'h':
-            vshUsage();
+            virshUsage();
             exit(EXIT_SUCCESS);
             break;
         case 'k':
@@ -3585,7 +3485,7 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
             }
             /* fall through */
         case 'V':
-            vshShowVersion(ctl);
+            virshShowVersion(ctl);
             exit(EXIT_SUCCESS);
         case ':':
             for (i = 0; opt[i].name != NULL; i++) {
@@ -3671,18 +3571,18 @@ static const vshCmdDef virshCmds[] = {
 };
 
 static const vshCmdGrp cmdGroups[] = {
-    {VSH_CMD_GRP_DOM_MANAGEMENT, "domain", domManagementCmds},
-    {VSH_CMD_GRP_DOM_MONITORING, "monitor", domMonitoringCmds},
-    {VSH_CMD_GRP_HOST_AND_HV, "host", hostAndHypervisorCmds},
-    {VSH_CMD_GRP_IFACE, "interface", ifaceCmds},
-    {VSH_CMD_GRP_NWFILTER, "filter", nwfilterCmds},
-    {VSH_CMD_GRP_NETWORK, "network", networkCmds},
-    {VSH_CMD_GRP_NODEDEV, "nodedev", nodedevCmds},
-    {VSH_CMD_GRP_SECRET, "secret", secretCmds},
-    {VSH_CMD_GRP_SNAPSHOT, "snapshot", snapshotCmds},
-    {VSH_CMD_GRP_STORAGE_POOL, "pool", storagePoolCmds},
-    {VSH_CMD_GRP_STORAGE_VOL, "volume", storageVolCmds},
-    {VSH_CMD_GRP_VIRSH, "virsh", virshCmds},
+    {VIRSH_CMD_GRP_DOM_MANAGEMENT, "domain", domManagementCmds},
+    {VIRSH_CMD_GRP_DOM_MONITORING, "monitor", domMonitoringCmds},
+    {VIRSH_CMD_GRP_HOST_AND_HV, "host", hostAndHypervisorCmds},
+    {VIRSH_CMD_GRP_IFACE, "interface", ifaceCmds},
+    {VIRSH_CMD_GRP_NWFILTER, "filter", nwfilterCmds},
+    {VIRSH_CMD_GRP_NETWORK, "network", networkCmds},
+    {VIRSH_CMD_GRP_NODEDEV, "nodedev", nodedevCmds},
+    {VIRSH_CMD_GRP_SECRET, "secret", secretCmds},
+    {VIRSH_CMD_GRP_SNAPSHOT, "snapshot", snapshotCmds},
+    {VIRSH_CMD_GRP_STORAGE_POOL, "pool", storagePoolCmds},
+    {VIRSH_CMD_GRP_STORAGE_VOL, "volume", storageVolCmds},
+    {VIRSH_CMD_GRP_VIRSH, "virsh", virshCmds},
     {NULL, NULL, NULL}
 };
 
@@ -3751,9 +3651,9 @@ main(int argc, char **argv)
 
     vshInitDebug(ctl);
 
-    if (!vshParseArgv(ctl, argc, argv) ||
-        !vshInit(ctl)) {
-        vshDeinit(ctl);
+    if (!virshParseArgv(ctl, argc, argv) ||
+        !virshInit(ctl)) {
+        virshDeinit(ctl);
         exit(EXIT_FAILURE);
     }
 
@@ -3771,7 +3671,7 @@ main(int argc, char **argv)
         }
 
         if (vshReadlineInit(ctl) < 0) {
-            vshDeinit(ctl);
+            virshDeinit(ctl);
             exit(EXIT_FAILURE);
         }
 
@@ -3795,6 +3695,6 @@ main(int argc, char **argv)
             fputc('\n', stdout);        /* line break after alone prompt */
     }
 
-    vshDeinit(ctl);
+    virshDeinit(ctl);
     exit(ret ? EXIT_SUCCESS : EXIT_FAILURE);
 }
diff --git a/tools/virsh.h b/tools/virsh.h
index 977b0fc..945eb23 100644
--- a/tools/virsh.h
+++ b/tools/virsh.h
@@ -37,10 +37,10 @@
 # include "virerror.h"
 # include "virthread.h"
 
-# define VSH_MAX_XML_FILE (10*1024*1024)
+# define VIRSH_MAX_XML_FILE (10*1024*1024)
 
-# define VSH_PROMPT_RW    "virsh # "
-# define VSH_PROMPT_RO    "virsh > "
+# define VIRSH_PROMPT_RW    "virsh # "
+# define VIRSH_PROMPT_RO    "virsh > "
 
 # define VIR_FROM_THIS VIR_FROM_NONE
 
@@ -112,18 +112,6 @@ typedef enum {
 /*
  * Command group types
  */
-# define VSH_CMD_GRP_DOM_MANAGEMENT   "Domain Management"
-# define VSH_CMD_GRP_DOM_MONITORING   "Domain Monitoring"
-# define VSH_CMD_GRP_STORAGE_POOL     "Storage Pool"
-# define VSH_CMD_GRP_STORAGE_VOL      "Storage Volume"
-# define VSH_CMD_GRP_NETWORK          "Networking"
-# define VSH_CMD_GRP_NODEDEV          "Node Device"
-# define VSH_CMD_GRP_IFACE            "Interface"
-# define VSH_CMD_GRP_NWFILTER         "Network Filter"
-# define VSH_CMD_GRP_SECRET           "Secret"
-# define VSH_CMD_GRP_SNAPSHOT         "Snapshot"
-# define VSH_CMD_GRP_HOST_AND_HV      "Host and Hypervisor"
-# define VSH_CMD_GRP_VIRSH            "Virsh itself"
 
 /*
  * Command Option Flags
@@ -191,6 +179,18 @@ enum {
     VSH_CMD_FLAG_NOCONNECT = (1 << 0),  /* no prior connection needed */
     VSH_CMD_FLAG_ALIAS     = (1 << 1),  /* command is an alias */
 };
+# define VIRSH_CMD_GRP_DOM_MANAGEMENT   "Domain Management"
+# define VIRSH_CMD_GRP_DOM_MONITORING   "Domain Monitoring"
+# define VIRSH_CMD_GRP_STORAGE_POOL     "Storage Pool"
+# define VIRSH_CMD_GRP_STORAGE_VOL      "Storage Volume"
+# define VIRSH_CMD_GRP_NETWORK          "Networking"
+# define VIRSH_CMD_GRP_NODEDEV          "Node Device"
+# define VIRSH_CMD_GRP_IFACE            "Interface"
+# define VIRSH_CMD_GRP_NWFILTER         "Network Filter"
+# define VIRSH_CMD_GRP_SECRET           "Secret"
+# define VIRSH_CMD_GRP_SNAPSHOT         "Snapshot"
+# define VIRSH_CMD_GRP_HOST_AND_HV      "Host and Hypervisor"
+# define VIRSH_CMD_GRP_VIRSH            "Virsh itself"
 
 /*
  * vshCmdDef - command definition
@@ -215,8 +215,8 @@ struct _vshCmd {
 /*
  * vshControl
  */
-struct _vshControl {
     char *name;                 /* connection name */
+struct _virshControl {
     virConnectPtr conn;         /* connection to hypervisor (MAY BE NULL) */
     vshCmd *cmd;                /* the current command */
     char *cmdstr;               /* string with command */
@@ -365,7 +365,7 @@ int vshStringToArray(const char *str, char ***array);
  * There are used by some long lingering commands like
  * migrate, dump, save, managedsave.
  */
-struct _vshCtrlData {
+struct _virshCtrlData {
     vshControl *ctl;
     const vshCmd *cmd;
     int writefd;
diff --git a/tools/vsh.c b/tools/vsh.c
index 8ef04b9..b1d8dbc 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -188,8 +188,8 @@ virErrorPtr last_error;
 /*
  * Quieten libvirt until we're done with the command.
  */
-static void
-virshErrorHandler(void *unused ATTRIBUTE_UNUSED, virErrorPtr error)
+void
+vshErrorHandler(void *opaque ATTRIBUTE_UNUSED, virErrorPtr error)
 {
     virFreeError(last_error);
     last_error = virSaveLastError();
diff --git a/tools/vsh.h b/tools/vsh.h
index 4b99b65..76704a1 100644
--- a/tools/vsh.h
+++ b/tools/vsh.h
@@ -310,6 +310,7 @@ int vshStringToArray(const char *str, char ***array);
 
 /* error handling */
 extern virErrorPtr last_error;
+void vshErrorHandler(void *opaque, virErrorPtr error);
 void vshReportError(vshControl *ctl);
 void vshResetLibvirtError(void);
 void vshSaveLibvirtError(void);
-- 
1.9.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]