}
}
volimg = uri->path + 1; /* skip the prefix slash */
+ VIR_FREE(def->src);
def->src = strdup(volimg);
if (!def->src)
goto no_memory;
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("reboot timeout is not supported "
"by this QEMU binary"));
+ virBufferFreeAndReset(&boot_buf);
goto error;
}
if (boot_nparams < 2 || emitBootindex) {
virCommandAddArgBuffer(cmd, &boot_buf);
+ virBufferFreeAndReset(&boot_buf);
} else {
+ char *str = virBufferContentAndReset(&boot_buf);
virCommandAddArgFormat(cmd,
"order=%s",
- virBufferContentAndReset(&boot_buf));
+ str);
+ VIR_FREE(str);
}
}
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse nbd filename '%s'"),
def->src);
- def = NULL;
- goto cleanup;
+ goto error;
}
*port++ = '\0';
if (VIR_ALLOC(def->hosts) < 0) {
virReportOOMError();
- goto cleanup;
+ goto error;
}
def->nhosts = 1;
def->hosts->name = strdup(host);
if (!def->hosts->name) {
virReportOOMError();
- goto cleanup;
+ goto error;
}
def->hosts->port = strdup(port);
if (!def->hosts->port) {
virReportOOMError();
- goto cleanup;
+ goto error;
}
def->hosts->transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP;
def->hosts->socket = NULL;
def->src = strdup(p + strlen("rbd:"));
if (!def->src) {
virReportOOMError();
- goto cleanup;
+ goto error;
}
/* old-style CEPH_ARGS env variable is parsed later */
if (!old_style_ceph_args && qemuParseRBDString(def) < 0)
def->protocol = VIR_DOMAIN_DISK_PROTOCOL_GLUSTER;
if (qemuParseGlusterString(def) < 0)
- goto cleanup;
+ goto error;
} else if (STRPREFIX(def->src, "sheepdog:")) {
char *p = def->src;
char *port, *vdi;
def->src = strdup(p + strlen("sheepdog:"));
if (!def->src) {
virReportOOMError();
- goto cleanup;
+ goto error;
}
/* def->src must be [vdiname] or [host]:[port]:[vdiname] */
*port++ = '\0';
vdi = strchr(port, ':');
if (!vdi) {
- def = NULL;
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse sheepdog filename '%s'"), p);
- goto cleanup;
+ goto error;
}
*vdi++ = '\0';
if (VIR_ALLOC(def->hosts) < 0) {
virReportOOMError();
- goto cleanup;
+ goto error;
}
def->nhosts = 1;
def->hosts->name = def->src;
def->hosts->port = strdup(port);
if (!def->hosts->port) {
virReportOOMError();
- goto cleanup;
+ goto error;
}
def->hosts->transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP;
def->hosts->socket = NULL;
def->src = strdup(vdi);
if (!def->src) {
virReportOOMError();
- goto cleanup;
+ goto error;
}
}
} else if (STREQ(keywords[i], "format")) {
def->driverName = strdup("qemu");
if (!def->driverName) {
- virDomainDiskDefFree(def);
- def = NULL;
virReportOOMError();
- goto cleanup;
+ goto error;
}
def->format = virStorageFileFormatTypeFromString(values[i]);
- values[i] = NULL;
} else if (STREQ(keywords[i], "cache")) {
if (STREQ(values[i], "off") ||
STREQ(values[i], "none"))
def->rerror_policy = VIR_DOMAIN_DISK_ERROR_POLICY_IGNORE;
} else if (STREQ(keywords[i], "index")) {
if (virStrToLong_i(values[i], NULL, 10, &idx) < 0) {
- virDomainDiskDefFree(def);
- def = NULL;
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse drive index '%s'"), val);
- goto cleanup;
+ goto error;
}
} else if (STREQ(keywords[i], "bus")) {
if (virStrToLong_i(values[i], NULL, 10, &busid) < 0) {
- virDomainDiskDefFree(def);
- def = NULL;
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse drive bus '%s'"), val);
- goto cleanup;
+ goto error;
}
} else if (STREQ(keywords[i], "unit")) {
if (virStrToLong_i(values[i], NULL, 10, &unitid) < 0) {
- virDomainDiskDefFree(def);
- def = NULL;
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse drive unit '%s'"), val);
- goto cleanup;
+ goto error;
}
} else if (STREQ(keywords[i], "readonly")) {
if ((values[i] == NULL) || STREQ(values[i], "on"))
def->type != VIR_DOMAIN_DISK_TYPE_NETWORK) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("missing file parameter in drive '%s'"), val);
- virDomainDiskDefFree(def);
- def = NULL;
- goto cleanup;
+ goto error;
}
if (idx == -1 &&
def->bus == VIR_DOMAIN_DISK_BUS_VIRTIO)
unitid == -1 &&
busid == -1) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("missing index/unit/bus parameter in drive '%s'"), val);
- virDomainDiskDefFree(def);
- def = NULL;
- goto cleanup;
+ _("missing index/unit/bus parameter in drive '%s'"),
+ val);
+ goto error;
}
if (idx == -1) {
}
if (!def->dst) {
- virDomainDiskDefFree(def);
- def = NULL;
virReportOOMError();
- goto cleanup;
+ goto error;
}
if (STREQ(def->dst, "xvda"))
def->dst[3] = 'a' + idx;
VIR_FREE(keywords);
VIR_FREE(values);
return def;
+
+error:
+ virDomainDiskDefFree(def);
+ def = NULL;
+ goto cleanup;
}
/*