* bool_option = --optionname
* int_option = --optionname <number>
* string_option = --optionname <string>
- *
+ *
* keyword = [a-zA-Z]
* number = [0-9]+
* string = [^[:blank:]] | "[[:alnum:]]"$
*/
/*
- * vshCmdOptType - command option type
+ * vshCmdOptType - command option type
*/
typedef enum {
VSH_OT_NONE = 0, /* none */
#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, ...);
*/
/*
- * "help" command
+ * "help" command
*/
static vshCmdInfo info_help[] = {
{"syntax", "help [<command>]"},
}
/*
- * "connect" command
+ * "connect" command
*/
static vshCmdInfo info_connect[] = {
{"syntax", "connect [name] [--readonly]"},
cmdConnect(vshControl * ctl, vshCmd * cmd)
{
int ro = vshCommandOptBool(cmd, "readonly");
-
+
if (ctl->conn) {
if (virConnectClose(ctl->conn) != 0) {
vshError(ctl, FALSE,
}
ctl->conn = NULL;
}
-
+
if (ctl->name)
free(ctl->name);
ctl->name = vshStrdup(ctl, vshCommandOptString(cmd, "name", NULL));
}
/*
- * "console" command
+ * "console" command
*/
static vshCmdInfo info_console[] = {
{"syntax", "console <domain>"},
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;
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 {
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)
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");
/* 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);
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;
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)
vshPrint(ctl, "%-15s %d\n", _("CPU(s):"), info.nrVirtCpu);
if (info.cpuTime != 0) {
- double cpuUsed = info.cpuTime;
+ double cpuUsed = info.cpuTime;
cpuUsed /= 1000000000.0;
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 {
if (virNodeGetInfo(ctl->conn, &nodeinfo) != 0) {
virDomainFree(dom);
- return FALSE;
+ return FALSE;
}
if (virDomainGetInfo(dom, &info) != 0) {
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;
}
virDomainFree(dom);
return FALSE;
}
-
+
if (virNodeGetInfo(ctl->conn, &nodeinfo) != 0) {
virDomainFree(dom);
return FALSE;
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));
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;
}
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)
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;
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")) {
cleanup:
if (obj)
- xmlXPathFreeObject(obj);
+ xmlXPathFreeObject(obj);
if (ctxt)
xmlXPathFreeContext(ctxt);
if (xml)
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;
}
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;
/* 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 */
return TRUE;
- syntaxError:
+ syntaxError:
if (ctl->cmd)
vshCommandFree(ctl->cmd);
if (first)
/* ---------------
- * 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;
}
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;
}
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)
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;
}
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;
}
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;
}
* -----------------
*/
-/*
+/*
* 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)
/* 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;
}
/* Return the next name which partially matches from the
- * command list.
+ * command list.
*/
while ((name = commands[list_index].name)) {
list_index++;
/* 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"));
/* 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;
}
}
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], '/')))
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))
progname);
vshPrint(ctl,
_("Type: 'help' for help with commands\n"
- " 'quit' to quit\n\n"));
+ " 'quit' to quit\n\n"));
}
vshReadlineInit();
do {
* 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:
+ */
return buf;
}
-
+
void
virBufferFree(virBufferPtr buf)
{
if (buf) {
if (buf->content)
- free(buf->content);
- free(buf);
+ free(buf->content);
+ free(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;
virDomainGetXMLDevice(domain, buf, id);
}
- done:
+ done:
if (list != NULL)
free(list);
virDomainGetXMLInterface(domain, buf, id);
}
- done:
+ done:
if (list != NULL)
free(list);
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);
* @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
* @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
&& (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"))) {
}
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 */
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) &&
xmlFree(boot_dev);
return (0);
-error:
+ error:
if (boot_dev)
xmlFree(boot_dev);
if (obj != NULL)
&& (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;
}
}
}
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);
(ctxt->lastError.level == XML_ERR_FATAL) &&
(ctxt->lastError.message != NULL)) {
virXMLError(VIR_ERR_XML_DETAIL, ctxt->lastError.message,
- ctxt->lastError.line);
+ ctxt->lastError.line);
}
}
} 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;
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);
}
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);
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);
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);
return (ret);
- error:
+ error:
if (nam != NULL)
free(nam);
if (name != NULL)
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;
for (i = 0; i < VIR_UUID_BUFLEN; i++)
dst_uuid[i] = rawuuid[i] & 0xFF;
-error:
+ error:
return(dst_uuid);
}
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;
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;
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)