]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Whiteclean/indentation cleanup/fixup. No functional change
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 7 Feb 2007 13:50:18 +0000 (13:50 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 7 Feb 2007 13:50:18 +0000 (13:50 +0000)
src/virsh.c
src/xml.c

index 3c71a085beba51fa4ad577f94903f334beb12e3e..212d6d6b45e2cb5e89a124d05e4d64542b9c9aba 100644 (file)
@@ -84,7 +84,7 @@ virshErrorHandler(void *unused, virErrorPtr error)
  *    bool_option     =     --optionname
  *    int_option      =     --optionname <number>
  *    string_option   =     --optionname <string>
- *        
+ *
  *    keyword         =     [a-zA-Z]
  *    number          =     [0-9]+
  *    string          =     [^[:blank:]] | "[[:alnum:]]"$
@@ -92,7 +92,7 @@ virshErrorHandler(void *unused, virErrorPtr error)
  */
 
 /*
- * vshCmdOptType - command option type 
+ * vshCmdOptType - command option type
  */
 typedef enum {
     VSH_OT_NONE = 0,            /* none */
@@ -199,12 +199,12 @@ static int vshCommandOptBool(vshCmd * cmd, const char *name);
 #define VSH_DOMBYNAME   (1 << 3)
 
 static virDomainPtr vshCommandOptDomainBy(vshControl * ctl, vshCmd * cmd,
-                            const char *optname, char **name, int flag);
+                                          const char *optname, char **name, int flag);
 
 /* default is lookup by Id, Name and UUID */
-#define vshCommandOptDomain(_ctl, _cmd, _optname, _name) \
-                            vshCommandOptDomainBy(_ctl, _cmd, _optname, _name,\
-                                        VSH_DOMBYID|VSH_DOMBYUUID|VSH_DOMBYNAME)
+#define vshCommandOptDomain(_ctl, _cmd, _optname, _name)            \
+    vshCommandOptDomainBy(_ctl, _cmd, _optname, _name,              \
+                          VSH_DOMBYID|VSH_DOMBYUUID|VSH_DOMBYNAME)
 
 static void vshPrintExtra(vshControl * ctl, const char *format, ...);
 static void vshDebug(vshControl * ctl, int level, const char *format, ...);
@@ -232,7 +232,7 @@ static char *_vshStrdup(vshControl * ctl, const char *s, const char *filename, i
  */
 
 /*
- * "help" command 
+ * "help" command
  */
 static vshCmdInfo info_help[] = {
     {"syntax", "help [<command>]"},
@@ -265,7 +265,7 @@ cmdHelp(vshControl * ctl, vshCmd * cmd)
 }
 
 /*
- * "connect" command 
+ * "connect" command
  */
 static vshCmdInfo info_connect[] = {
     {"syntax", "connect [name] [--readonly]"},
@@ -285,7 +285,7 @@ static int
 cmdConnect(vshControl * ctl, vshCmd * cmd)
 {
     int ro = vshCommandOptBool(cmd, "readonly");
-    
+
     if (ctl->conn) {
         if (virConnectClose(ctl->conn) != 0) {
             vshError(ctl, FALSE,
@@ -294,7 +294,7 @@ cmdConnect(vshControl * ctl, vshCmd * cmd)
         }
         ctl->conn = NULL;
     }
-    
+
     if (ctl->name)
         free(ctl->name);
     ctl->name = vshStrdup(ctl, vshCommandOptString(cmd, "name", NULL));
@@ -311,7 +311,7 @@ cmdConnect(vshControl * ctl, vshCmd * cmd)
 }
 
 /*
- * "console" command 
+ * "console" command
  */
 static vshCmdInfo info_console[] = {
     {"syntax", "console <domain>"},
@@ -344,11 +344,11 @@ cmdConsole(vshControl * ctl, vshCmd * cmd)
 
     doc = virDomainGetXMLDesc(dom, 0);
     if (!doc)
-       goto cleanup;
+        goto cleanup;
 
     xml = xmlReadDoc((const xmlChar *) doc, "domain.xml", NULL,
-                    XML_PARSE_NOENT | XML_PARSE_NONET |
-                    XML_PARSE_NOWARNING);
+                     XML_PARSE_NOENT | XML_PARSE_NONET |
+                     XML_PARSE_NOWARNING);
     free(doc);
     if (!xml)
         goto cleanup;
@@ -358,7 +358,7 @@ cmdConsole(vshControl * ctl, vshCmd * cmd)
 
     obj = xmlXPathEval(BAD_CAST "string(/domain/devices/console/@tty)", ctxt);
     if ((obj != NULL) && ((obj->type == XPATH_STRING) &&
-        (obj->stringval != NULL) && (obj->stringval[0] != 0))) {
+                          (obj->stringval != NULL) && (obj->stringval[0] != 0))) {
         if (vshRunConsole((const char *)obj->stringval) == 0)
             ret = TRUE;
     } else {
@@ -393,20 +393,20 @@ static vshCmdOptDef opts_list[] = {
 
 
 static int domidsorter(const void *a, const void *b) {
-  const int *ia = (const int *)a;
-  const int *ib = (const int *)b;
+    const int *ia = (const int *)a;
+    const int *ib = (const int *)b;
 
-  if (*ia > *ib)
-    return 1;
-  else if (*ia < *ib)
-    return -1;
-  return 0;
+    if (*ia > *ib)
+        return 1;
+    else if (*ia < *ib)
+        return -1;
+    return 0;
 }
 static int domnamesorter(const void *a, const void *b) {
-  const char **sa = (const char**)a;
-  const char **sb = (const char**)b;
+    const char **sa = (const char**)a;
+    const char **sb = (const char**)b;
 
-  return strcasecmp(*sa, *sb);
+    return strcasecmp(*sa, *sb);
 }
 static int
 cmdList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
@@ -421,46 +421,46 @@ cmdList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
 
     if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
         return FALSE;
-    
+
     if (active) {
-      maxid = virConnectNumOfDomains(ctl->conn);
-      if (maxid < 0) {
-        vshError(ctl, FALSE, _("Failed to list active domains"));
-        return FALSE;
-      }
-      if (maxid) {
-        ids = vshMalloc(ctl, sizeof(int) * maxid);
-       
-        if ((maxid = virConnectListDomains(ctl->conn, &ids[0], maxid)) < 0) {
-         vshError(ctl, FALSE, _("Failed to list active domains"));
-         free(ids);
-         return FALSE;
+        maxid = virConnectNumOfDomains(ctl->conn);
+        if (maxid < 0) {
+            vshError(ctl, FALSE, _("Failed to list active domains"));
+            return FALSE;
+        }
+        if (maxid) {
+            ids = vshMalloc(ctl, sizeof(int) * maxid);
+
+            if ((maxid = virConnectListDomains(ctl->conn, &ids[0], maxid)) < 0) {
+                vshError(ctl, FALSE, _("Failed to list active domains"));
+                free(ids);
+                return FALSE;
+            }
+
+            qsort(&ids[0], maxid, sizeof(int), domidsorter);
         }
-       
-       qsort(&ids[0], maxid, sizeof(int), domidsorter);
-      }
     }
     if (inactive) {
-      maxname = virConnectNumOfDefinedDomains(ctl->conn);
-      if (maxname < 0) {
-        vshError(ctl, FALSE, _("Failed to list inactive domains"));
-       if (ids)
-         free(ids);
-        return FALSE;
-      }
-      if (maxname) {
-        names = vshMalloc(ctl, sizeof(char *) * maxname);
-       
-        if ((maxname = virConnectListDefinedDomains(ctl->conn, names, maxname)) < 0) {
-         vshError(ctl, FALSE, _("Failed to list inactive domains"));
-         if (ids)
-           free(ids);
-         free(names);
-         return FALSE;
+        maxname = virConnectNumOfDefinedDomains(ctl->conn);
+        if (maxname < 0) {
+            vshError(ctl, FALSE, _("Failed to list inactive domains"));
+            if (ids)
+                free(ids);
+            return FALSE;
         }
+        if (maxname) {
+            names = vshMalloc(ctl, sizeof(char *) * maxname);
+
+            if ((maxname = virConnectListDefinedDomains(ctl->conn, names, maxname)) < 0) {
+                vshError(ctl, FALSE, _("Failed to list inactive domains"));
+                if (ids)
+                    free(ids);
+                free(names);
+                return FALSE;
+            }
 
-       qsort(&names[0], maxname, sizeof(char*), domnamesorter);
-      }
+            qsort(&names[0], maxname, sizeof(char*), domnamesorter);
+        }
     }
     vshPrintExtra(ctl, "%3s %-20s %s\n", _("Id"), _("Name"), _("State"));
     vshPrintExtra(ctl, "----------------------------------\n");
@@ -490,28 +490,28 @@ cmdList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
 
         /* this kind of work with domains is not atomic operation */
         if (!dom) {
-           free(names[i]);
+            free(names[i]);
             continue;
-       }
+        }
         ret = virDomainGetInfo(dom, &info);
-       id = virDomainGetID(dom);
-
-       if (id == ((unsigned int)-1)) {
-         vshPrint(ctl, "%3s %-20s %s\n",
-                  "-",
-                  names[i],
-                  ret <
-                  0 ? "no state" : vshDomainStateToString(info.state));
-       } else {
-         vshPrint(ctl, "%3d %-20s %s\n",
-                  id,
-                  names[i],
-                  ret <
-                  0 ? "no state" : vshDomainStateToString(info.state));
-       }
+        id = virDomainGetID(dom);
+
+        if (id == ((unsigned int)-1)) {
+            vshPrint(ctl, "%3s %-20s %s\n",
+                     "-",
+                     names[i],
+                     ret <
+                     0 ? "no state" : vshDomainStateToString(info.state));
+        } else {
+            vshPrint(ctl, "%3d %-20s %s\n",
+                     id,
+                     names[i],
+                     ret <
+                     0 ? "no state" : vshDomainStateToString(info.state));
+        }
 
         virDomainFree(dom);
-       free(names[i]);
+        free(names[i]);
     }
     if (ids)
         free(ids);
@@ -789,7 +789,7 @@ cmdStart(vshControl * ctl, vshCmd * cmd)
         vshPrint(ctl, _("Domain %s started\n"),
                  name);
     } else {
-      vshError(ctl, FALSE, _("Failed to start domain %s"), name);
+        vshError(ctl, FALSE, _("Failed to start domain %s"), name);
         ret = FALSE;
     }
     return ret;
@@ -1110,9 +1110,9 @@ cmdDominfo(vshControl * ctl, vshCmd * cmd)
 
     id = virDomainGetID(dom);
     if (id == ((unsigned int)-1))
-      vshPrint(ctl, "%-15s %s\n", _("Id:"), "-");
+        vshPrint(ctl, "%-15s %s\n", _("Id:"), "-");
     else
-      vshPrint(ctl, "%-15s %d\n", _("Id:"), id);
+        vshPrint(ctl, "%-15s %d\n", _("Id:"), id);
     vshPrint(ctl, "%-15s %s\n", _("Name:"), virDomainGetName(dom));
 
     if (virDomainGetUUIDString(dom, &uuid[0])==0)
@@ -1130,7 +1130,7 @@ cmdDominfo(vshControl * ctl, vshCmd * cmd)
         vshPrint(ctl, "%-15s %d\n", _("CPU(s):"), info.nrVirtCpu);
 
         if (info.cpuTime != 0) {
-           double cpuUsed = info.cpuTime;
+            double cpuUsed = info.cpuTime;
 
             cpuUsed /= 1000000000.0;
 
@@ -1139,7 +1139,7 @@ cmdDominfo(vshControl * ctl, vshCmd * cmd)
 
         vshPrint(ctl, "%-15s %lu kB\n", _("Max memory:"),
                  info.maxMem);
-       vshPrint(ctl, "%-15s %lu kB\n", _("Used memory:"),
+        vshPrint(ctl, "%-15s %lu kB\n", _("Used memory:"),
                  info.memory);
 
     } else {
@@ -1185,7 +1185,7 @@ cmdVcpuinfo(vshControl * ctl, vshCmd * cmd)
 
     if (virNodeGetInfo(ctl->conn, &nodeinfo) != 0) {
         virDomainFree(dom);
-       return FALSE;
+        return FALSE;
     }
 
     if (virDomainGetInfo(dom, &info) != 0) {
@@ -1197,32 +1197,32 @@ cmdVcpuinfo(vshControl * ctl, vshCmd * cmd)
     cpumaplen = VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo));
     cpumap = malloc(info.nrVirtCpu * cpumaplen);
 
-    if ((ncpus = virDomainGetVcpus(dom, 
-                                  cpuinfo, info.nrVirtCpu,
-                                  cpumap, cpumaplen)) >= 0) {
+    if ((ncpus = virDomainGetVcpus(dom,
+                                   cpuinfo, info.nrVirtCpu,
+                                   cpumap, cpumaplen)) >= 0) {
         int n;
-       for (n = 0 ; n < ncpus ; n++) {
-           unsigned int m;
-           vshPrint(ctl, "%-15s %d\n", _("VCPU:"), n);
-           vshPrint(ctl, "%-15s %d\n", _("CPU:"), cpuinfo[n].cpu);
-           vshPrint(ctl, "%-15s %s\n", _("State:"),
-                    _N(vshDomainVcpuStateToString(cpuinfo[n].state)));
-           if (cpuinfo[n].cpuTime != 0) {
-               double cpuUsed = cpuinfo[n].cpuTime;
-               
-               cpuUsed /= 1000000000.0;
-               
-               vshPrint(ctl, "%-15s %.1lfs\n", _("CPU time:"), cpuUsed);
-           }
-           vshPrint(ctl, "%-15s ", _("CPU Affinity:"));
-           for (m = 0 ; m < VIR_NODEINFO_MAXCPUS(nodeinfo) ; m++) {
-               vshPrint(ctl, "%c", VIR_CPU_USABLE(cpumap, cpumaplen, n, m) ? 'y' : '-');
-           }
-           vshPrint(ctl, "\n");
-           if (n < (ncpus - 1)) {
-               vshPrint(ctl, "\n");
-           }
-       }
+        for (n = 0 ; n < ncpus ; n++) {
+            unsigned int m;
+            vshPrint(ctl, "%-15s %d\n", _("VCPU:"), n);
+            vshPrint(ctl, "%-15s %d\n", _("CPU:"), cpuinfo[n].cpu);
+            vshPrint(ctl, "%-15s %s\n", _("State:"),
+                     _N(vshDomainVcpuStateToString(cpuinfo[n].state)));
+            if (cpuinfo[n].cpuTime != 0) {
+                double cpuUsed = cpuinfo[n].cpuTime;
+
+                cpuUsed /= 1000000000.0;
+
+                vshPrint(ctl, "%-15s %.1lfs\n", _("CPU time:"), cpuUsed);
+            }
+            vshPrint(ctl, "%-15s ", _("CPU Affinity:"));
+            for (m = 0 ; m < VIR_NODEINFO_MAXCPUS(nodeinfo) ; m++) {
+                vshPrint(ctl, "%c", VIR_CPU_USABLE(cpumap, cpumaplen, n, m) ? 'y' : '-');
+            }
+            vshPrint(ctl, "\n");
+            if (n < (ncpus - 1)) {
+                vshPrint(ctl, "\n");
+            }
+        }
     } else {
         ret = FALSE;
     }
@@ -1279,7 +1279,7 @@ cmdVcpupin(vshControl * ctl, vshCmd * cmd)
         virDomainFree(dom);
         return FALSE;
     }
-      
+
     if (virNodeGetInfo(ctl->conn, &nodeinfo) != 0) {
         virDomainFree(dom);
         return FALSE;
@@ -1543,8 +1543,8 @@ cmdDomname(vshControl * ctl, vshCmd * cmd)
 
     if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
         return FALSE;
-    if (!(dom = vshCommandOptDomainBy(ctl, cmd, "domain", NULL, 
-                                    VSH_DOMBYID|VSH_DOMBYUUID)))
+    if (!(dom = vshCommandOptDomainBy(ctl, cmd, "domain", NULL,
+                                      VSH_DOMBYID|VSH_DOMBYUUID)))
         return FALSE;
 
     vshPrint(ctl, "%s\n", virDomainGetName(dom));
@@ -1574,15 +1574,15 @@ cmdDomid(vshControl * ctl, vshCmd * cmd)
 
     if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
         return FALSE;
-    if (!(dom = vshCommandOptDomainBy(ctl, cmd, "domain", NULL, 
-                                    VSH_DOMBYNAME|VSH_DOMBYUUID)))
+    if (!(dom = vshCommandOptDomainBy(ctl, cmd, "domain", NULL,
+                                      VSH_DOMBYNAME|VSH_DOMBYUUID)))
         return FALSE;
-    
+
     id = virDomainGetID(dom);
     if (id == ((unsigned int)-1))
-      vshPrint(ctl, "%s\n", "-");
+        vshPrint(ctl, "%s\n", "-");
     else
-      vshPrint(ctl, "%d\n", id);
+        vshPrint(ctl, "%d\n", id);
     virDomainFree(dom);
     return TRUE;
 }
@@ -1610,7 +1610,7 @@ cmdDomuuid(vshControl * ctl, vshCmd * cmd)
     if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
         return FALSE;
     if (!(dom = vshCommandOptDomainBy(ctl, cmd, "domain", NULL,
-                                    VSH_DOMBYNAME|VSH_DOMBYID)))
+                                      VSH_DOMBYNAME|VSH_DOMBYID)))
         return FALSE;
 
     if (virDomainGetUUIDString(dom, uuid) != -1)
@@ -1736,11 +1736,11 @@ cmdVNCDisplay(vshControl * ctl, vshCmd * cmd)
 
     doc = virDomainGetXMLDesc(dom, 0);
     if (!doc)
-       goto cleanup;
+        goto cleanup;
 
     xml = xmlReadDoc((const xmlChar *) doc, "domain.xml", NULL,
-                    XML_PARSE_NOENT | XML_PARSE_NONET |
-                    XML_PARSE_NOWARNING);
+                     XML_PARSE_NOENT | XML_PARSE_NONET |
+                     XML_PARSE_NOWARNING);
     free(doc);
     if (!xml)
         goto cleanup;
@@ -1750,18 +1750,18 @@ cmdVNCDisplay(vshControl * ctl, vshCmd * cmd)
 
     obj = xmlXPathEval(BAD_CAST "string(/domain/devices/graphics[@type='vnc']/@port)", ctxt);
     if ((obj == NULL) || (obj->type != XPATH_STRING) ||
-       (obj->stringval == NULL) || (obj->stringval[0] == 0)) {
+        (obj->stringval == NULL) || (obj->stringval[0] == 0)) {
         goto cleanup;
     }
     port = strtol((const char *)obj->stringval, NULL, 10);
     if (port == -1) {
-      goto cleanup;
+        goto cleanup;
     }
     xmlXPathFreeObject(obj);
 
     obj = xmlXPathEval(BAD_CAST "string(/domain/devices/graphics[@type='vnc']/@listen)", ctxt);
     if ((obj == NULL) || (obj->type != XPATH_STRING) ||
-       (obj->stringval == NULL) || (obj->stringval[0] == 0)) {
+        (obj->stringval == NULL) || (obj->stringval[0] == 0)) {
         goto cleanup;
     }
     if (!strcmp((const char*)obj->stringval, "0.0.0.0")) {
@@ -1774,7 +1774,7 @@ cmdVNCDisplay(vshControl * ctl, vshCmd * cmd)
 
  cleanup:
     if (obj)
-      xmlXPathFreeObject(obj);
+        xmlXPathFreeObject(obj);
     if (ctxt)
         xmlXPathFreeContext(ctxt);
     if (xml)
@@ -1905,7 +1905,7 @@ vshCommandCheckOpts(vshControl * ctl, vshCmd * cmd)
                 vshError(ctl, FALSE,
                          d->type == VSH_OT_DATA ?
                          _("command '%s' requires <%s> option") :
-                        _("command '%s' requires --%s option"),
+                         _("command '%s' requires --%s option"),
                          def->name, d->name);
                 err = 1;
             }
@@ -2070,7 +2070,7 @@ vshCommandOptBool(vshCmd * cmd, const char *name)
 
 static virDomainPtr
 vshCommandOptDomainBy(vshControl * ctl, vshCmd * cmd, const char *optname,
-                    char **name, int flag)
+                      char **name, int flag)
 {
     virDomainPtr dom = NULL;
     char *n, *end = NULL;
@@ -2099,7 +2099,7 @@ vshCommandOptDomainBy(vshControl * ctl, vshCmd * cmd, const char *optname,
     /* try it by UUID */
     if (dom==NULL && (flag & VSH_DOMBYUUID) && strlen(n)==VIR_UUID_STRING_BUFLEN-1) {
         vshDebug(ctl, 5, "%s: <%s> tring as domain UUID\n",
-                cmd->def->name, optname);
+                 cmd->def->name, optname);
         dom = virDomainLookupByUUIDString(ctl->conn, n);
     }
     /* try it by NAME */
@@ -2359,7 +2359,7 @@ vshCommandParse(vshControl * ctl, char *cmdstr)
 
     return TRUE;
 
 syntaxError:
+ syntaxError:
     if (ctl->cmd)
         vshCommandFree(ctl->cmd);
     if (first)
@@ -2371,27 +2371,27 @@ vshCommandParse(vshControl * ctl, char *cmdstr)
 
 
 /* ---------------
- * Misc utils  
+ * Misc utils
  * ---------------
  */
 static const char *
 vshDomainStateToString(int state)
 {
     switch (state) {
-        case VIR_DOMAIN_RUNNING:
-            return gettext_noop("running");
-        case VIR_DOMAIN_BLOCKED:
-            return gettext_noop("blocked");
-        case VIR_DOMAIN_PAUSED:
-            return gettext_noop("paused");
-        case VIR_DOMAIN_SHUTDOWN:
-            return gettext_noop("in shutdown");
-        case VIR_DOMAIN_SHUTOFF:
-            return gettext_noop("shut off");
-        case VIR_DOMAIN_CRASHED:
-            return gettext_noop("crashed");
-        default:
-            return gettext_noop("no state");  /* = dom0 state */
+    case VIR_DOMAIN_RUNNING:
+        return gettext_noop("running");
+    case VIR_DOMAIN_BLOCKED:
+        return gettext_noop("blocked");
+    case VIR_DOMAIN_PAUSED:
+        return gettext_noop("paused");
+    case VIR_DOMAIN_SHUTDOWN:
+        return gettext_noop("in shutdown");
+    case VIR_DOMAIN_SHUTOFF:
+        return gettext_noop("shut off");
+    case VIR_DOMAIN_CRASHED:
+        return gettext_noop("crashed");
+    default:
+        return gettext_noop("no state");  /* = dom0 state */
     }
     return NULL;
 }
@@ -2400,14 +2400,14 @@ static const char *
 vshDomainVcpuStateToString(int state)
 {
     switch (state) {
-        case VIR_VCPU_OFFLINE:
-            return gettext_noop("offline");
-        case VIR_VCPU_BLOCKED:
-            return gettext_noop("blocked");
-        case VIR_VCPU_RUNNING:
-            return gettext_noop("running");
-        default:
-            return gettext_noop("no state");
+    case VIR_VCPU_OFFLINE:
+        return gettext_noop("offline");
+    case VIR_VCPU_BLOCKED:
+        return gettext_noop("blocked");
+    case VIR_VCPU_RUNNING:
+        return gettext_noop("running");
+    default:
+        return gettext_noop("no state");
     }
     return NULL;
 }
@@ -2415,8 +2415,8 @@ vshDomainVcpuStateToString(int state)
 static int
 vshConnectionUsability(vshControl * ctl, virConnectPtr conn, int showerror)
 {
-    /* TODO: use something like virConnectionState() to 
-     *       check usability of the connection 
+    /* TODO: use something like virConnectionState() to
+     *       check usability of the connection
      */
     if (!conn) {
         if (showerror)
@@ -2484,7 +2484,7 @@ _vshMalloc(vshControl * ctl, size_t size, const char *filename, int line)
     if ((x = malloc(size)))
         return x;
     vshError(ctl, TRUE, _("%s: %d: failed to allocate %d bytes"),
-            filename, line, (int) size);
+             filename, line, (int) size);
     return NULL;
 }
 
@@ -2496,7 +2496,7 @@ _vshCalloc(vshControl * ctl, size_t nmemb, size_t size, const char *filename, in
     if ((x = calloc(nmemb, size)))
         return x;
     vshError(ctl, TRUE, _("%s: %d: failed to allocate %d bytes"),
-            filename, line, (int) (size*nmemb));
+             filename, line, (int) (size*nmemb));
     return NULL;
 }
 
@@ -2508,7 +2508,7 @@ _vshStrdup(vshControl * ctl, const char *s, const char *filename, int line)
     if ((x = strdup(s)))
         return x;
     vshError(ctl, TRUE, _("%s: %d: failed to allocate %d bytes"),
-            filename, line, strlen(s));
+             filename, line, strlen(s));
     return NULL;
 }
 
@@ -2545,10 +2545,10 @@ vshInit(vshControl * ctl)
  * -----------------
  */
 
-/* 
+/*
  * Generator function for command completion.  STATE lets us
  * know whether to start from scratch; without any state
- * (i.e. STATE == 0), then we start at the top of the list. 
+ * (i.e. STATE == 0), then we start at the top of the list.
  */
 static char *
 vshReadlineCommandGenerator(const char *text, int state)
@@ -2558,7 +2558,7 @@ vshReadlineCommandGenerator(const char *text, int state)
 
     /* If this is a new word to complete, initialize now.  This
      * includes saving the length of TEXT for efficiency, and
-     * initializing the index variable to 0. 
+     * initializing the index variable to 0.
      */
     if (!state) {
         list_index = 0;
@@ -2566,7 +2566,7 @@ vshReadlineCommandGenerator(const char *text, int state)
     }
 
     /* Return the next name which partially matches from the
-     * command list. 
+     * command list.
      */
     while ((name = commands[list_index].name)) {
         list_index++;
@@ -2681,19 +2681,19 @@ vshUsage(vshControl * ctl, const char *cmdname)
     /* global help */
     if (!cmdname) {
         fprintf(stdout, _("\n%s [options] [commands]\n\n"
-                         "  options:\n"
-                         "    -c | --connect <uri>    hypervisor connection URI\n"
-                         "    -d | --debug <num>      debug level [0-5]\n"
-                         "    -h | --help             this help\n"
-                         "    -q | --quiet            quiet mode\n"
-                         "    -t | --timing           print timing information\n"
-                         "    -v | --version          program version\n\n"
-                         "  commands (non interactive mode):\n"), progname);
+                          "  options:\n"
+                          "    -c | --connect <uri>    hypervisor connection URI\n"
+                          "    -d | --debug <num>      debug level [0-5]\n"
+                          "    -h | --help             this help\n"
+                          "    -q | --quiet            quiet mode\n"
+                          "    -t | --timing           print timing information\n"
+                          "    -v | --version          program version\n\n"
+                          "  commands (non interactive mode):\n"), progname);
 
         for (cmd = commands; cmd->name; cmd++)
             fprintf(stdout,
                     "    %-15s %s\n", cmd->name, _N(vshCmddefGetInfo(cmd,
-                                                                    "help")));
+                                                                     "help")));
 
         fprintf(stdout,
                 _("\n  (specify --help <command> for details about the command)\n\n"));
@@ -2762,28 +2762,28 @@ vshParseArgv(vshControl * ctl, int argc, char **argv)
     /* standard (non-command) options */
     while ((arg = getopt_long(end, argv, "d:hqtcv", opt, &idx)) != -1) {
         switch (arg) {
-            case 'd':
-                ctl->debug = atoi(optarg);
-                break;
-            case 'h':
-                help = 1;
-                break;
-            case 'q':
-                ctl->quiet = TRUE;
-                break;
-            case 't':
-                ctl->timing = TRUE;
-                break;
-            case 'c':
-                ctl->name = vshStrdup(ctl, optarg);
-                break;
-            case 'v':
-                fprintf(stdout, "%s\n", VERSION);
-                exit(EXIT_SUCCESS);
-            default:
-                vshError(ctl, TRUE,
-                        _("unsupported option '-%c'. See --help."), arg);
-                break;
+        case 'd':
+            ctl->debug = atoi(optarg);
+            break;
+        case 'h':
+            help = 1;
+            break;
+        case 'q':
+            ctl->quiet = TRUE;
+            break;
+        case 't':
+            ctl->timing = TRUE;
+            break;
+        case 'c':
+            ctl->name = vshStrdup(ctl, optarg);
+            break;
+        case 'v':
+            fprintf(stdout, "%s\n", VERSION);
+            exit(EXIT_SUCCESS);
+        default:
+            vshError(ctl, TRUE,
+                     _("unsupported option '-%c'. See --help."), arg);
+            break;
         }
     }
 
@@ -2828,15 +2828,15 @@ main(int argc, char **argv)
 
     if (!setlocale(LC_ALL, "")) {
         perror("setlocale");
-       return -1;
+        return -1;
     }
     if (!bindtextdomain(GETTEXT_PACKAGE, LOCALEBASEDIR)) {
         perror("bindtextdomain");
-       return -1;
+        return -1;
     }
     if (!textdomain(GETTEXT_PACKAGE)) {
         perror("textdomain");
-       return -1;
+        return -1;
     }
 
     if (!(progname = strrchr(argv[0], '/')))
@@ -2848,7 +2848,7 @@ main(int argc, char **argv)
     ctl->imode = TRUE;          /* default is interactive mode */
 
     if ((defaultConn = getenv("VIRSH_DEFAULT_CONNECT_URI"))) {
-      ctl->name = strdup(defaultConn);
+        ctl->name = strdup(defaultConn);
     }
 
     if (!vshParseArgv(ctl, argc, argv))
@@ -2867,7 +2867,7 @@ main(int argc, char **argv)
                      progname);
             vshPrint(ctl,
                      _("Type:  'help' for help with commands\n"
-                      "       'quit' to quit\n\n"));
+                       "       'quit' to quit\n\n"));
         }
         vshReadlineInit();
         do {
@@ -2897,3 +2897,11 @@ main(int argc, char **argv)
  * vim: set shiftwidth=4:
  * vim: set expandtab:
  */
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
index 343d5f2e9f7f2d05e6b1ab8b6e7ffa1462e7c4c8..15f4938993cb7b2a97362264c57f4615a99922da 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -127,14 +127,14 @@ virBufferNew(unsigned int size)
 
     return buf;
 }
-       
+
 void
 virBufferFree(virBufferPtr buf)
 {
     if (buf) {
         if (buf->content)
-          free(buf->content);
-               free(buf);
+            free(buf->content);
+        free(buf);
     }
 }
 
@@ -190,17 +190,17 @@ virBufferStrcat(virBufferPtr buf, ...)
 {
     va_list ap;
     char *str;
-    
+
     va_start(ap, buf);
-    
+
     while ((str = va_arg(ap, char *)) != NULL) {
         unsigned int len = strlen(str);
         unsigned int needSize = buf->use + len + 2;
 
         if (needSize > buf->size) {
-           if (!virBufferGrow(buf, needSize))
-              return -1;
-       }
+            if (!virBufferGrow(buf, needSize))
+                return -1;
+        }
         memcpy(&buf->content[buf->use], str, len);
         buf->use += len;
         buf->content[buf->use] = 0;
@@ -352,7 +352,7 @@ virDomainGetXMLDevices(virDomainPtr domain, virBufferPtr buf)
         virDomainGetXMLDevice(domain, buf, id);
     }
 
 done:
+ done:
     if (list != NULL)
         free(list);
 
@@ -450,7 +450,7 @@ virDomainGetXMLInterfaces(virDomainPtr domain, virBufferPtr buf)
         virDomainGetXMLInterface(domain, buf, id);
     }
 
 done:
+ done:
     if (list != NULL)
         free(list);
 
@@ -548,12 +548,12 @@ virDomainGetXMLDesc(virDomainPtr domain, int flags)
     virBufferVSprintf(&buf, "  <name>%s</name>\n",
                       virDomainGetName(domain));
     if (virDomainGetUUID(domain, &uuid[0]) == 0) {
-    virBufferVSprintf(&buf,
-"  <uuid>%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x</uuid>\n",
-                      uuid[0], uuid[1], uuid[2], uuid[3],
-                      uuid[4], uuid[5], uuid[6], uuid[7],
-                      uuid[8], uuid[9], uuid[10], uuid[11],
-                      uuid[12], uuid[13], uuid[14], uuid[15]);
+        virBufferVSprintf(&buf,
+                          "  <uuid>%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x</uuid>\n",
+                          uuid[0], uuid[1], uuid[2], uuid[3],
+                          uuid[4], uuid[5], uuid[6], uuid[7],
+                          uuid[8], uuid[9], uuid[10], uuid[11],
+                          uuid[12], uuid[13], uuid[14], uuid[15]);
     }
     virDomainGetXMLBoot(domain, &buf);
     virBufferVSprintf(&buf, "  <memory>%lu</memory>\n", info.maxMem);
@@ -577,9 +577,9 @@ virDomainGetXMLDesc(virDomainPtr domain, int flags)
  * @buf: a buffer for the result S-Expr
  * @xendConfigVersion: xend configuration file format
  *
- * Parse the graphics part of the XML description and add it to the S-Expr 
- * in buf.  This is a temporary interface as the S-Expr interface will be 
- * replaced by XML-RPC in the future. However the XML format should stay 
+ * Parse the graphics part of the XML description and add it to the S-Expr
+ * in buf.  This is a temporary interface as the S-Expr interface will be
+ * replaced by XML-RPC in the future. However the XML format should stay
  * valid over time.
  *
  * Returns 0 in case of success, -1 in case of error
@@ -634,9 +634,9 @@ static int virDomainParseXMLGraphicsDescImage(xmlNodePtr node, virBufferPtr buf,
  * @node: node containing graphics description
  * @buf: a buffer for the result S-Expr
  *
- * Parse the graphics part of the XML description and add it to the S-Expr 
- * in buf.  This is a temporary interface as the S-Expr interface will be 
- * replaced by XML-RPC in the future. However the XML format should stay 
+ * Parse the graphics part of the XML description and add it to the S-Expr
+ * in buf.  This is a temporary interface as the S-Expr interface will be
+ * replaced by XML-RPC in the future. However the XML format should stay
  * valid over time.
  *
  * Returns 0 in case of success, -1 in case of error
@@ -719,13 +719,13 @@ virDomainParseXMLOSDescHVM(xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr
                 && (xmlStrEqual(cur->name, BAD_CAST "type"))) {
                 txt = cur->children;
                 if ((txt != NULL) && (txt->type == XML_TEXT_NODE) &&
-                   (txt->next == NULL))
+                    (txt->next == NULL))
                     type = txt->content;
             } else if ((loader == NULL) &&
                        (xmlStrEqual(cur->name, BAD_CAST "loader"))) {
                 txt = cur->children;
                 if ((txt != NULL) && (txt->type == XML_TEXT_NODE) &&
-                   (txt->next == NULL))
+                    (txt->next == NULL))
                     loader = txt->content;
             } else if ((boot_dev == NULL) &&
                        (xmlStrEqual(cur->name, BAD_CAST "boot"))) {
@@ -741,10 +741,10 @@ virDomainParseXMLOSDescHVM(xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr
     }
     virBufferAdd(buf, "(image (hvm ", 12);
     if (loader == NULL) {
-       virXMLError(VIR_ERR_NO_KERNEL, NULL, 0);
-       goto error;
+        virXMLError(VIR_ERR_NO_KERNEL, NULL, 0);
+        goto error;
     } else {
-       virBufferVSprintf(buf, "(kernel '%s')", (const char *) loader);
+        virBufferVSprintf(buf, "(kernel '%s')", (const char *) loader);
     }
 
     /* get the device emulation model */
@@ -762,104 +762,104 @@ virDomainParseXMLOSDescHVM(xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr
     virBufferVSprintf(buf, "(vcpus %d)", vcpus);
 
     if (boot_dev) {
-       if (xmlStrEqual(boot_dev, BAD_CAST "fd")) {
-          virBufferVSprintf(buf, "(boot a)", (const char *) boot_dev);
-       } else if (xmlStrEqual(boot_dev, BAD_CAST "cdrom")) {
-          virBufferVSprintf(buf, "(boot d)", (const char *) boot_dev);
-       } else if (xmlStrEqual(boot_dev, BAD_CAST "hd")) {
-          virBufferVSprintf(buf, "(boot c)", (const char *) boot_dev);
-       } else {
-         /* Any other type of boot dev is unsupported right now */
-         virXMLError(VIR_ERR_XML_ERROR, NULL, 0);
-       }
-
-       /* get the 1st floppy device file */
-       obj = xmlXPathEval(BAD_CAST "/domain/devices/disk[@device='floppy' and target/@dev='fda']/source", ctxt);
-       if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
-           (obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
-           cur = obj->nodesetval->nodeTab[0];
-           virBufferVSprintf(buf, "(fda '%s')",
-                             (const char *) xmlGetProp(cur, BAD_CAST "file"));
-           cur = NULL;
-       }
-       if (obj) {
-           xmlXPathFreeObject(obj);
-           obj = NULL;
-       }
-
-       /* get the 2nd floppy device file */
-       obj = xmlXPathEval(BAD_CAST "/domain/devices/disk[@device='floppy' and target/@dev='fdb']/source", ctxt);
-       if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
-           (obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
-           xmlChar *fdfile = NULL;
-           cur = obj->nodesetval->nodeTab[0];
-           fdfile = xmlGetProp(cur, BAD_CAST "file");
-           virBufferVSprintf(buf, "(fdb '%s')",
-                             (const char *) fdfile);
-           xmlFree(fdfile);
-           cur = NULL;
-       }
-       if (obj) {
-           xmlXPathFreeObject(obj);
-           obj = NULL;
-       }
-
-
-       /* get the cdrom device file */
-       /* Only XenD <= 3.0.2 wants cdrom config here */
-       if (xendConfigVersion == 1) {
-           obj = xmlXPathEval(BAD_CAST "/domain/devices/disk[@device='cdrom' and target/@dev='hdc']/source", ctxt);
-           if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
-               (obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
-               xmlChar *cdfile = NULL;
-               cur = obj->nodesetval->nodeTab[0];
-               cdfile = xmlGetProp(cur, BAD_CAST "file");
-               virBufferVSprintf(buf, "(cdrom '%s')",
-                                 (const char *)cdfile);
-               xmlFree(cdfile);
-               cur = NULL;
-           }
-           if (obj) {
-               xmlXPathFreeObject(obj);
-               obj = NULL;
-           }
-       }
-
-       obj = xmlXPathEval(BAD_CAST "/domain/features/acpi", ctxt);
-       if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
-           (obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
-           virBufferAdd(buf, "(acpi 1)", 8);
-       }
-       if (obj)
-           xmlXPathFreeObject(obj);
-       obj = xmlXPathEval(BAD_CAST "/domain/features/apic", ctxt);
-       if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
-           (obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
-           virBufferAdd(buf, "(apic 1)", 8);
-       }
-       if (obj)
-           xmlXPathFreeObject(obj);
-       obj = xmlXPathEval(BAD_CAST "/domain/features/pae", ctxt);
-       if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
-           (obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
-           virBufferAdd(buf, "(pae 1)", 7);
-       }
-       if (obj)
-           xmlXPathFreeObject(obj);
-       obj = NULL;
+        if (xmlStrEqual(boot_dev, BAD_CAST "fd")) {
+            virBufferVSprintf(buf, "(boot a)", (const char *) boot_dev);
+        } else if (xmlStrEqual(boot_dev, BAD_CAST "cdrom")) {
+            virBufferVSprintf(buf, "(boot d)", (const char *) boot_dev);
+        } else if (xmlStrEqual(boot_dev, BAD_CAST "hd")) {
+            virBufferVSprintf(buf, "(boot c)", (const char *) boot_dev);
+        } else {
+            /* Any other type of boot dev is unsupported right now */
+            virXMLError(VIR_ERR_XML_ERROR, NULL, 0);
+        }
+
+        /* get the 1st floppy device file */
+        obj = xmlXPathEval(BAD_CAST "/domain/devices/disk[@device='floppy' and target/@dev='fda']/source", ctxt);
+        if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
+            (obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
+            cur = obj->nodesetval->nodeTab[0];
+            virBufferVSprintf(buf, "(fda '%s')",
+                              (const char *) xmlGetProp(cur, BAD_CAST "file"));
+            cur = NULL;
+        }
+        if (obj) {
+            xmlXPathFreeObject(obj);
+            obj = NULL;
+        }
+
+        /* get the 2nd floppy device file */
+        obj = xmlXPathEval(BAD_CAST "/domain/devices/disk[@device='floppy' and target/@dev='fdb']/source", ctxt);
+        if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
+            (obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
+            xmlChar *fdfile = NULL;
+            cur = obj->nodesetval->nodeTab[0];
+            fdfile = xmlGetProp(cur, BAD_CAST "file");
+            virBufferVSprintf(buf, "(fdb '%s')",
+                              (const char *) fdfile);
+            xmlFree(fdfile);
+            cur = NULL;
+        }
+        if (obj) {
+            xmlXPathFreeObject(obj);
+            obj = NULL;
+        }
+
+
+        /* get the cdrom device file */
+        /* Only XenD <= 3.0.2 wants cdrom config here */
+        if (xendConfigVersion == 1) {
+            obj = xmlXPathEval(BAD_CAST "/domain/devices/disk[@device='cdrom' and target/@dev='hdc']/source", ctxt);
+            if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
+                (obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
+                xmlChar *cdfile = NULL;
+                cur = obj->nodesetval->nodeTab[0];
+                cdfile = xmlGetProp(cur, BAD_CAST "file");
+                virBufferVSprintf(buf, "(cdrom '%s')",
+                                  (const char *)cdfile);
+                xmlFree(cdfile);
+                cur = NULL;
+            }
+            if (obj) {
+                xmlXPathFreeObject(obj);
+                obj = NULL;
+            }
+        }
+
+        obj = xmlXPathEval(BAD_CAST "/domain/features/acpi", ctxt);
+        if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
+            (obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
+            virBufferAdd(buf, "(acpi 1)", 8);
+        }
+        if (obj)
+            xmlXPathFreeObject(obj);
+        obj = xmlXPathEval(BAD_CAST "/domain/features/apic", ctxt);
+        if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
+            (obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
+            virBufferAdd(buf, "(apic 1)", 8);
+        }
+        if (obj)
+            xmlXPathFreeObject(obj);
+        obj = xmlXPathEval(BAD_CAST "/domain/features/pae", ctxt);
+        if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
+            (obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
+            virBufferAdd(buf, "(pae 1)", 7);
+        }
+        if (obj)
+            xmlXPathFreeObject(obj);
+        obj = NULL;
     }
 
     obj = xmlXPathEval(BAD_CAST "count(domain/devices/console) > 0", ctxt);
     if ((obj == NULL) || (obj->type != XPATH_BOOLEAN)) {
-      virXMLError(VIR_ERR_XML_ERROR, NULL, 0);
-      goto error;
+        virXMLError(VIR_ERR_XML_ERROR, NULL, 0);
+        goto error;
     }
     if (obj->boolval) {
-      virBufferAdd(buf, "(serial pty)", 12);
+        virBufferAdd(buf, "(serial pty)", 12);
     }
     xmlXPathFreeObject(obj);
     obj = NULL;
-    
+
     /* Is a graphics device specified? */
     obj = xmlXPathEval(BAD_CAST "/domain/devices/graphics[1]", ctxt);
     if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
@@ -877,7 +877,7 @@ virDomainParseXMLOSDescHVM(xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr
         xmlFree(boot_dev);
 
     return (0);
-error:
+ error:
     if (boot_dev)
         xmlFree(boot_dev);
     if (obj != NULL)
@@ -918,31 +918,31 @@ virDomainParseXMLOSDescPV(xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr
                 && (xmlStrEqual(cur->name, BAD_CAST "type"))) {
                 txt = cur->children;
                 if ((txt != NULL) && (txt->type == XML_TEXT_NODE) &&
-                   (txt->next == NULL))
+                    (txt->next == NULL))
                     type = txt->content;
             } else if ((kernel == NULL) &&
                        (xmlStrEqual(cur->name, BAD_CAST "kernel"))) {
                 txt = cur->children;
                 if ((txt != NULL) && (txt->type == XML_TEXT_NODE) &&
-                   (txt->next == NULL))
+                    (txt->next == NULL))
                     kernel = txt->content;
             } else if ((root == NULL) &&
                        (xmlStrEqual(cur->name, BAD_CAST "root"))) {
                 txt = cur->children;
                 if ((txt != NULL) && (txt->type == XML_TEXT_NODE) &&
-                   (txt->next == NULL))
+                    (txt->next == NULL))
                     root = txt->content;
             } else if ((initrd == NULL) &&
                        (xmlStrEqual(cur->name, BAD_CAST "initrd"))) {
                 txt = cur->children;
                 if ((txt != NULL) && (txt->type == XML_TEXT_NODE) &&
-                   (txt->next == NULL))
+                    (txt->next == NULL))
                     initrd = txt->content;
             } else if ((cmdline == NULL) &&
                        (xmlStrEqual(cur->name, BAD_CAST "cmdline"))) {
                 txt = cur->children;
                 if ((txt != NULL) && (txt->type == XML_TEXT_NODE) &&
-                   (txt->next == NULL))
+                    (txt->next == NULL))
                     cmdline = txt->content;
             }
         }
@@ -955,10 +955,10 @@ virDomainParseXMLOSDescPV(xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr
     }
     virBufferAdd(buf, "(image (linux ", 14);
     if (kernel == NULL) {
-       virXMLError(VIR_ERR_NO_KERNEL, NULL, 0);
-       return (-1);
+        virXMLError(VIR_ERR_NO_KERNEL, NULL, 0);
+        return (-1);
     } else {
-       virBufferVSprintf(buf, "(kernel '%s')", (const char *) kernel);
+        virBufferVSprintf(buf, "(kernel '%s')", (const char *) kernel);
     }
     if (initrd != NULL)
         virBufferVSprintf(buf, "(ramdisk '%s')", (const char *) initrd);
@@ -1003,7 +1003,7 @@ virCatchXMLParseError(void *ctx, const char *msg ATTRIBUTE_UNUSED, ...) {
         (ctxt->lastError.level == XML_ERR_FATAL) &&
         (ctxt->lastError.message != NULL)) {
         virXMLError(VIR_ERR_XML_DETAIL, ctxt->lastError.message,
-                   ctxt->lastError.line);
+                    ctxt->lastError.line);
     }
 }
 
@@ -1066,7 +1066,7 @@ virDomainParseXMLDiskDesc(xmlNodePtr node, virBufferPtr buf, int hvm, int xendCo
             } else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) {
                 ro = 1;
             } else if (xmlStrEqual(cur->name, BAD_CAST "shareable")) {
-               shareable = 1;
+                shareable = 1;
             }
         }
         cur = cur->next;
@@ -1350,7 +1350,7 @@ virDomainParseXMLDesc(const char *xmldesc, char **name, int xendConfigVersion)
     obj = xmlXPathEval(BAD_CAST "number(/domain/memory[1])", ctxt);
     if ((obj == NULL) || (obj->type != XPATH_NUMBER) ||
         (isnan(obj->floatval)) || (obj->floatval < 64000)) {
-       max_mem = 128;
+        max_mem = 128;
     } else {
         max_mem = (obj->floatval / 1024);
     }
@@ -1361,9 +1361,9 @@ virDomainParseXMLDesc(const char *xmldesc, char **name, int xendConfigVersion)
         mem = max_mem;
     } else {
         mem = (obj->floatval / 1024);
-       if (mem > max_mem) {
-           max_mem = mem;
-       }
+        if (mem > max_mem) {
+            max_mem = mem;
+        }
     }
     xmlXPathFreeObject(obj);
     virBufferVSprintf(&buf, "(memory %lu)(maxmem %lu)", mem, max_mem);
@@ -1378,7 +1378,7 @@ virDomainParseXMLDesc(const char *xmldesc, char **name, int xendConfigVersion)
 
     obj = xmlXPathEval(BAD_CAST "string(/domain/uuid[1])", ctxt);
     if ((obj == NULL) || ((obj->type == XPATH_STRING) &&
-        (obj->stringval != NULL) && (obj->stringval[0] != 0))) {
+                          (obj->stringval != NULL) && (obj->stringval[0] != 0))) {
         virBufferVSprintf(&buf, "(uuid '%s')", obj->stringval);
     }
     xmlXPathFreeObject(obj);
@@ -1386,84 +1386,84 @@ virDomainParseXMLDesc(const char *xmldesc, char **name, int xendConfigVersion)
     obj = xmlXPathEval(BAD_CAST "string(/domain/bootloader[1])", ctxt);
     if ((obj != NULL) && (obj->type == XPATH_STRING) &&
         (obj->stringval != NULL) && (obj->stringval[0] != 0)) {
-       virBufferVSprintf(&buf, "(bootloader '%s')", obj->stringval);
-       /*
-        * if using pygrub, the kernel and initrd strings are not 
-        * significant and should be discarded
-        */
-       if (xmlStrstr(obj->stringval, BAD_CAST "pygrub"))
-           bootloader = 2;
-       else
-           bootloader = 1;
+        virBufferVSprintf(&buf, "(bootloader '%s')", obj->stringval);
+        /*
+         * if using pygrub, the kernel and initrd strings are not
+         * significant and should be discarded
+         */
+        if (xmlStrstr(obj->stringval, BAD_CAST "pygrub"))
+            bootloader = 2;
+        else
+            bootloader = 1;
     }
     xmlXPathFreeObject(obj);
 
     obj = xmlXPathEval(BAD_CAST "string(/domain/on_poweroff[1])", ctxt);
     if ((obj != NULL) && (obj->type == XPATH_STRING) &&
         (obj->stringval != NULL) && (obj->stringval[0] != 0)) {
-       virBufferVSprintf(&buf, "(on_poweroff '%s')", obj->stringval);
+        virBufferVSprintf(&buf, "(on_poweroff '%s')", obj->stringval);
     }
     xmlXPathFreeObject(obj);
 
     obj = xmlXPathEval(BAD_CAST "string(/domain/on_reboot[1])", ctxt);
     if ((obj != NULL) && (obj->type == XPATH_STRING) &&
         (obj->stringval != NULL) && (obj->stringval[0] != 0)) {
-       virBufferVSprintf(&buf, "(on_reboot '%s')", obj->stringval);
+        virBufferVSprintf(&buf, "(on_reboot '%s')", obj->stringval);
     }
     xmlXPathFreeObject(obj);
 
     obj = xmlXPathEval(BAD_CAST "string(/domain/on_crash[1])", ctxt);
     if ((obj != NULL) && (obj->type == XPATH_STRING) &&
         (obj->stringval != NULL) && (obj->stringval[0] != 0)) {
-       virBufferVSprintf(&buf, "(on_crash '%s')", obj->stringval);
+        virBufferVSprintf(&buf, "(on_crash '%s')", obj->stringval);
     }
     xmlXPathFreeObject(obj);
 
     if (bootloader != 2) {
-       obj = xmlXPathEval(BAD_CAST "/domain/os[1]", ctxt);
-       if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
-           (obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
-           /* Analyze of the os description, based on HVM or PV. */
-           tmpobj = xmlXPathEval(BAD_CAST "string(/domain/os/type[1])", ctxt);
-           if ((tmpobj != NULL) &&
-               ((tmpobj->type != XPATH_STRING) || (tmpobj->stringval == NULL)
-                || (tmpobj->stringval[0] == 0))) {
-               xmlXPathFreeObject(tmpobj);
-               virXMLError(VIR_ERR_OS_TYPE, nam, 0);
-               goto error;
-           }
-
-           if ((tmpobj == NULL)
-               || !xmlStrEqual(tmpobj->stringval, BAD_CAST "hvm")) {
-               res = virDomainParseXMLOSDescPV(obj->nodesetval->nodeTab[0],
-                                               &buf, ctxt, xendConfigVersion);
-           } else {
-               hvm = 1;
-               res = virDomainParseXMLOSDescHVM(obj->nodesetval->nodeTab[0],
-                                         &buf, ctxt, vcpus, xendConfigVersion);
-           }
-
-           xmlXPathFreeObject(tmpobj);
-
-           if (res != 0)
-               goto error;
-       } else if (bootloader == 0) {
-           virXMLError(VIR_ERR_NO_OS, nam, 0);
-           goto error;
-       }
-       xmlXPathFreeObject(obj);
+        obj = xmlXPathEval(BAD_CAST "/domain/os[1]", ctxt);
+        if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
+            (obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
+            /* Analyze of the os description, based on HVM or PV. */
+            tmpobj = xmlXPathEval(BAD_CAST "string(/domain/os/type[1])", ctxt);
+            if ((tmpobj != NULL) &&
+                ((tmpobj->type != XPATH_STRING) || (tmpobj->stringval == NULL)
+                 || (tmpobj->stringval[0] == 0))) {
+                xmlXPathFreeObject(tmpobj);
+                virXMLError(VIR_ERR_OS_TYPE, nam, 0);
+                goto error;
+            }
+
+            if ((tmpobj == NULL)
+                || !xmlStrEqual(tmpobj->stringval, BAD_CAST "hvm")) {
+                res = virDomainParseXMLOSDescPV(obj->nodesetval->nodeTab[0],
+                                                &buf, ctxt, xendConfigVersion);
+            } else {
+                hvm = 1;
+                res = virDomainParseXMLOSDescHVM(obj->nodesetval->nodeTab[0],
+                                                 &buf, ctxt, vcpus, xendConfigVersion);
+            }
+
+            xmlXPathFreeObject(tmpobj);
+
+            if (res != 0)
+                goto error;
+        } else if (bootloader == 0) {
+            virXMLError(VIR_ERR_NO_OS, nam, 0);
+            goto error;
+        }
+        xmlXPathFreeObject(obj);
     }
 
     /* analyze of the devices */
     obj = xmlXPathEval(BAD_CAST "/domain/devices/disk", ctxt);
     if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
         (obj->nodesetval != NULL) && (obj->nodesetval->nodeNr >= 0)) {
-       for (i = 0; i < obj->nodesetval->nodeNr; i++) {
-         res = virDomainParseXMLDiskDesc(obj->nodesetval->nodeTab[i], &buf, hvm, xendConfigVersion);
-           if (res != 0) {
-               goto error;
-           }
-       }
+        for (i = 0; i < obj->nodesetval->nodeNr; i++) {
+            res = virDomainParseXMLDiskDesc(obj->nodesetval->nodeTab[i], &buf, hvm, xendConfigVersion);
+            if (res != 0) {
+                goto error;
+            }
+        }
     }
     xmlXPathFreeObject(obj);
 
@@ -1511,7 +1511,7 @@ virDomainParseXMLDesc(const char *xmldesc, char **name, int xendConfigVersion)
 
     return (ret);
 
 error:
+ error:
     if (nam != NULL)
         free(nam);
     if (name != NULL)
@@ -1550,33 +1550,33 @@ unsigned char *virParseUUID(char **ptr, const char *uuid) {
     for (i = 0;i < VIR_UUID_BUFLEN;) {
         rawuuid[i] = 0;
         if (*cur == 0)
-           goto error;
-       if ((*cur == '-') || (*cur == ' ')) {
-           cur++;
-           continue;
-       }
-       if ((*cur >= '0') && (*cur <= '9'))
-           rawuuid[i] = *cur - '0';
-       else if ((*cur >= 'a') && (*cur <= 'f'))
-           rawuuid[i] = *cur - 'a' + 10;
-       else if ((*cur >= 'A') && (*cur <= 'F'))
-           rawuuid[i] = *cur - 'A' + 10;
-       else
-           goto error;
-       rawuuid[i] *= 16;
-       cur++;
+            goto error;
+        if ((*cur == '-') || (*cur == ' ')) {
+            cur++;
+            continue;
+        }
+        if ((*cur >= '0') && (*cur <= '9'))
+            rawuuid[i] = *cur - '0';
+        else if ((*cur >= 'a') && (*cur <= 'f'))
+            rawuuid[i] = *cur - 'a' + 10;
+        else if ((*cur >= 'A') && (*cur <= 'F'))
+            rawuuid[i] = *cur - 'A' + 10;
+        else
+            goto error;
+        rawuuid[i] *= 16;
+        cur++;
         if (*cur == 0)
-           goto error;
-       if ((*cur >= '0') && (*cur <= '9'))
-           rawuuid[i] += *cur - '0';
-       else if ((*cur >= 'a') && (*cur <= 'f'))
-           rawuuid[i] += *cur - 'a' + 10;
-       else if ((*cur >= 'A') && (*cur <= 'F'))
-           rawuuid[i] += *cur - 'A' + 10;
-       else
-           goto error;
+            goto error;
+        if ((*cur >= '0') && (*cur <= '9'))
+            rawuuid[i] += *cur - '0';
+        else if ((*cur >= 'a') && (*cur <= 'f'))
+            rawuuid[i] += *cur - 'a' + 10;
+        else if ((*cur >= 'A') && (*cur <= 'F'))
+            rawuuid[i] += *cur - 'A' + 10;
+        else
+            goto error;
         i++;
-       cur++;
+        cur++;
     }
 
     dst_uuid = (unsigned char *) *ptr;
@@ -1585,7 +1585,7 @@ unsigned char *virParseUUID(char **ptr, const char *uuid) {
     for (i = 0; i < VIR_UUID_BUFLEN; i++)
         dst_uuid[i] = rawuuid[i] & 0xFF;
 
-error:
+ error:
     return(dst_uuid);
 }
 
@@ -1632,11 +1632,11 @@ virParseXMLDevice(char *xmldesc, int hvm, int xendConfigVersion)
         if (virDomainParseXMLIfDesc(node, &buf, hvm) != 0)
             goto error;
     }
-cleanup:
+ cleanup:
     if (xml != NULL)
         xmlFreeDoc(xml);
     return buf.content;
-error:
+ error:
     free(buf.content);
     buf.content = NULL;
     goto cleanup;
@@ -1677,7 +1677,7 @@ virDomainXMLDevID(virDomainPtr domain, char *xmldesc, char *class, char *ref)
         strcpy(class, "vbd");
         for (cur = node->children; cur != NULL; cur = cur->next) {
             if ((cur->type != XML_ELEMENT_NODE) ||
-               (!xmlStrEqual(cur->name, BAD_CAST "target"))) continue;
+                (!xmlStrEqual(cur->name, BAD_CAST "target"))) continue;
             attr = xmlGetProp(cur, BAD_CAST "dev");
             if (attr == NULL)
                 goto error;
@@ -1695,19 +1695,19 @@ virDomainXMLDevID(virDomainPtr domain, char *xmldesc, char *class, char *ref)
                 goto error;
 
             xref = xenStoreDomainGetNetworkID(domain->conn, domain->id,
-                                            (char *) attr);
-           if (xref != NULL) {
-               strcpy(ref, xref);
-               free(xref);
-               goto cleanup;
-           }
-                                            
+                                              (char *) attr);
+            if (xref != NULL) {
+                strcpy(ref, xref);
+                free(xref);
+                goto cleanup;
+            }
+
             goto error;
         }
     }
-error:
+ error:
     ret = -1;
-cleanup:
+ cleanup:
     if (xml != NULL)
         xmlFreeDoc(xml);
     if (attr != NULL)