if (VIR_ALLOC(ret) < 0)
return NULL;
- if (VIR_ALLOC(ret->src) < 0)
+ if (!(ret->src = virStorageSourceNew()))
goto error;
if (xmlopt &&
if (VIR_ALLOC(ret) < 0)
return NULL;
- if (VIR_ALLOC(ret->src) < 0)
+ if (!(ret->src = virStorageSourceNew()))
goto cleanup;
return ret;
/* For the purposes of command line creation, this needs to look
* like a disk storage source */
- if (VIR_ALLOC(iscsisrc->src) < 0)
+ if (!(iscsisrc->src = virStorageSourceNew()))
return -1;
iscsisrc->src->type = VIR_STORAGE_TYPE_NETWORK;
iscsisrc->src->protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI;
goto cleanup;
}
- if (VIR_ALLOC(backingStore) < 0)
+ if (!(backingStore = virStorageSourceNew()))
goto cleanup;
/* backing store is always read-only */
char *blockJob = NULL;
int ret = -1;
- if (VIR_ALLOC(def->mirror) < 0)
+ if (!(def->mirror = virStorageSourceNew()))
goto cleanup;
if ((blockJob = virXMLPropString(cur, "job"))) {
ctxt->node = node;
- if (VIR_ALLOC(def->src) < 0)
+ if (!(def->src = virStorageSourceNew()))
goto cleanup;
def->name = virXMLPropString(node, "name");
if (virBitmapIsBitSet(map, i))
continue;
disk = &def->disks[ndisks++];
- if (VIR_ALLOC(disk->src) < 0)
+ if (!(disk->src = virStorageSourceNew()))
goto cleanup;
if (VIR_STRDUP(disk->name, def->dom->disks[i]->dst) < 0)
goto cleanup;
}
if ((backingStore = virXPathString("string(./backingStore/path)", ctxt))) {
- if (VIR_ALLOC(def->target.backingStore) < 0)
+ if (!(def->target.backingStore = virStorageSourceNew()))
return NULL;
def->target.backingStore->type = VIR_STORAGE_TYPE_FILE;
virStorageSourceIsRelative;
virStorageSourceIsSameLocation;
virStorageSourceNetworkAssignDefaultPorts;
+virStorageSourceNew;
virStorageSourceNewFromBacking;
virStorageSourceNewFromBackingAbsolute;
virStorageSourceParseRBDColonString;
goto cleanup;
}
- if (VIR_ALLOC(migrSource) < 0)
+ if (!(migrSource = virStorageSourceNew()))
goto cleanup;
if (!(type = virXMLPropString(ctxt->node, "type"))) {
/* terminate the chain for such images as the code below would do */
if (!disksrc->backingStore &&
- VIR_ALLOC(disksrc->backingStore) < 0)
+ !(disksrc->backingStore = virStorageSourceNew()))
goto cleanup;
/* host cdrom requires special treatment in qemu, so we need to check
return qemuDomainBlockPullCommon(driver, vm, path, base, bandwidth, flags);
/* If we got here, we are doing a block copy rebase. */
- if (VIR_ALLOC(dest) < 0)
+ if (!(dest = virStorageSourceNew()))
goto cleanup;
dest->type = (flags & VIR_DOMAIN_BLOCK_REBASE_COPY_DEV) ?
VIR_STORAGE_TYPE_BLOCK : VIR_STORAGE_TYPE_FILE;
VIR_DEBUG("starting blockdev mirror for disk=%s to host=%s", diskAlias, host);
- if (VIR_ALLOC(copysrc) < 0)
+ if (!(copysrc = virStorageSourceNew()))
goto cleanup;
copysrc->type = VIR_STORAGE_TYPE_NETWORK;
copysrc->protocol = VIR_STORAGE_NET_PROTOCOL_NBD;
copysrc->format = VIR_STORAGE_FILE_RAW;
- if (VIR_ALLOC(copysrc->backingStore) < 0)
+ if (!(copysrc->backingStore = virStorageSourceNew()))
goto cleanup;
if (VIR_STRDUP(copysrc->path, diskAlias) < 0)
goto cleanup;
if (meta->backingStoreRaw) {
- if (VIR_ALLOC(vol->target.backingStore) < 0)
+ if (!(vol->target.backingStore = virStorageSourceNew()))
goto cleanup;
vol->target.backingStore->type = VIR_STORAGE_TYPE_NETWORK;
* lv is created with "--virtualsize").
*/
if (groups[1] && STRNEQ(groups[1], "") && (groups[1][0] != '[')) {
- if (VIR_ALLOC(vol->target.backingStore) < 0)
+ if (!(vol->target.backingStore = virStorageSourceNew()))
goto cleanup;
if (virAsprintf(&vol->target.backingStore->path, "%s/%s",
if (!virStorageSourceIsLocalStorage(target->backingStore)) {
virStorageSourceFree(target->backingStore);
- if (VIR_ALLOC(target->backingStore) < 0)
+ if (!(target->backingStore = virStorageSourceNew()))
return -1;
target->backingStore->type = VIR_STORAGE_TYPE_NETWORK;
goto cleanup;
VIR_DIR_CLOSE(dir);
- if (VIR_ALLOC(target))
+ if (!(target = virStorageSourceNew()))
goto cleanup;
if ((fd = open(def->target.path, O_RDONLY)) < 0) {
{
virStorageSourcePtr def = NULL;
- if (VIR_ALLOC(def) < 0)
+ if (!(def = virStorageSourceNew()))
return NULL;
def->id = src->id;
}
+virStorageSourcePtr
+virStorageSourceNew(void)
+{
+ virStorageSourcePtr ret = NULL;
+
+ if (VIR_ALLOC(ret) < 0)
+ return NULL;
+
+ return ret;
+}
+
+
void
virStorageSourceFree(virStorageSourcePtr def)
{
virStorageSourcePtr def;
VIR_AUTOFREE(char *) dirname = NULL;
- if (VIR_ALLOC(def) < 0)
+ if (!(def = virStorageSourceNew()))
return NULL;
/* store relative name */
virStorageSourcePtr def;
int rc;
- if (VIR_ALLOC(def) < 0)
+ if (!(def = virStorageSourceNew()))
return NULL;
if (virStorageIsFile(path)) {
}
} else {
/* add terminator */
- if (VIR_ALLOC(backingStore) < 0)
+ if (!(backingStore = virStorageSourceNew()))
goto cleanup;
}
bool virStorageSourceIsLocalStorage(const virStorageSource *src);
bool virStorageSourceIsEmpty(virStorageSourcePtr src);
bool virStorageSourceIsBlockLocal(const virStorageSource *src);
+virStorageSourcePtr virStorageSourceNew(void);
void virStorageSourceFree(virStorageSourcePtr def);
void virStorageSourceBackingStoreClear(virStorageSourcePtr def);
int virStorageSourceUpdatePhysicalSize(virStorageSourcePtr src,
VIR_AUTOPTR(virStorageSource) xmlsrc = NULL;
VIR_AUTOPTR(virStorageSource) jsonsrc = NULL;
- if (VIR_ALLOC(xmlsrc) < 0)
+ if (!(xmlsrc = virStorageSourceNew()))
return -1;
xmlsrc->type = data->type;
virStorageSourcePtr ret = NULL;
VIR_AUTOPTR(virStorageSource) def = NULL;
- if (VIR_ALLOC(def) < 0)
+ if (!(def = virStorageSourceNew()))
return NULL;
def->type = VIR_STORAGE_TYPE_FILE;