def->state = tmp;
}
- if (!(def->store = virStorageSourceNew()))
- return -1;
+ def->store = virStorageSourceNew();
if ((type = virXMLPropString(node, "type"))) {
if ((def->store->type = virStorageTypeFromString(type)) <= 0) {
}
} else if (!disk->store) {
if (virStorageSourceGetActualType(src) == VIR_STORAGE_TYPE_FILE) {
- if (!(disk->store = virStorageSourceNew()))
- return -1;
-
+ disk->store = virStorageSourceNew();
disk->store->type = VIR_STORAGE_TYPE_FILE;
disk->store->path = g_strdup_printf("%s.%s", src->path, suffix);
} else {
if (VIR_ALLOC(ret) < 0)
return NULL;
- if (!(ret->src = virStorageSourceNew()))
- goto error;
+ ret->src = virStorageSourceNew();
if (xmlopt &&
xmlopt->privateData.diskNew &&
if (VIR_ALLOC(ret) < 0)
return NULL;
- if (!(ret->src = virStorageSourceNew()))
- goto cleanup;
+ ret->src = virStorageSourceNew();
if (xmlopt &&
xmlopt->privateData.fsNew &&
if (flags & VIR_DOMAIN_DEF_PARSE_STATUS &&
xmlopt && xmlopt->privateData.storageParse) {
if ((ctxt->node = virXPathNode("./privateData", ctxt))) {
- if (!scsihostsrc->src &&
- !(scsihostsrc->src = virStorageSourceNew()))
- return -1;
+ if (!scsihostsrc->src)
+ scsihostsrc->src = virStorageSourceNew();
if (xmlopt->privateData.storageParse(ctxt, scsihostsrc->src) < 0)
return -1;
}
/* For the purposes of command line creation, this needs to look
* like a disk storage source */
- if (!(iscsisrc->src = virStorageSourceNew()))
- return -1;
+ iscsisrc->src = virStorageSourceNew();
iscsisrc->src->type = VIR_STORAGE_TYPE_NETWORK;
iscsisrc->src->protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI;
{
g_autoptr(virStorageSource) src = NULL;
- if (!(src = virStorageSourceNew()))
- return NULL;
-
+ src = virStorageSourceNew();
src->type = VIR_STORAGE_TYPE_FILE;
if (type &&
/* terminator does not have a type */
if (!(type = virXMLPropString(ctxt->node, "type"))) {
- if (!(src->backingStore = virStorageSourceNew()))
- return -1;
+ src->backingStore = virStorageSourceNew();
return 0;
}
ctxt->node = node;
- if (!(def->src = virStorageSourceNew()))
- goto cleanup;
-
+ def->src = virStorageSourceNew();
def->name = virXMLPropString(node, "name");
if (!def->name) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
if (virBitmapIsBitSet(map, i))
continue;
disk = &def->disks[ndisks++];
- if (!(disk->src = virStorageSourceNew()))
- goto cleanup;
+ disk->src = virStorageSourceNew();
disk->name = g_strdup(def->parent.dom->disks[i]->dst);
disk->idx = i;
}
if ((backingStore = virXPathString("string(./backingStore/path)", ctxt))) {
- if (!(def->target.backingStore = virStorageSourceNew()))
- return NULL;
-
+ def->target.backingStore = virStorageSourceNew();
def->target.backingStore->type = VIR_STORAGE_TYPE_FILE;
def->target.backingStore->path = backingStore;
switch ((virDomainHostdevSCSIProtocolType) scsisrc->protocol) {
case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE:
- if (!scsisrc->u.host.src &&
- !(scsisrc->u.host.src = virStorageSourceNew()))
- return -1;
+ if (!scsisrc->u.host.src)
+ scsisrc->u.host.src = virStorageSourceNew();
src = scsisrc->u.host.src;
break;
}
/* terminate the chain for such images as the code below would do */
- if (!disksrc->backingStore &&
- !(disksrc->backingStore = virStorageSourceNew()))
- return -1;
+ if (!disksrc->backingStore)
+ disksrc->backingStore = virStorageSourceNew();
/* host cdrom requires special treatment in qemu, so we need to check
* whether a block device is a cdrom */
switch ((virDomainHostdevSCSIProtocolType) scsisrc->protocol) {
case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE:
virObjectUnref(scsisrc->u.host.src);
- if (!(scsisrc->u.host.src = virStorageSourceNew()))
- return -1;
+ scsisrc->u.host.src = virStorageSourceNew();
src = scsisrc->u.host.src;
break;
if (!virDomainDefHasOldStyleUEFI(def))
return 0;
- if (!(pflash0 = virStorageSourceNew()))
- return -1;
-
+ pflash0 = virStorageSourceNew();
pflash0->type = VIR_STORAGE_TYPE_FILE;
pflash0->format = VIR_STORAGE_FILE_RAW;
pflash0->path = g_strdup(def->os.loader->path);
if (def->os.loader->nvram) {
- if (!(pflash1 = virStorageSourceNew()))
- return -1;
-
+ pflash1 = virStorageSourceNew();
pflash1->type = VIR_STORAGE_TYPE_FILE;
pflash1->format = VIR_STORAGE_FILE_RAW;
pflash1->path = g_strdup(def->os.loader->nvram);
{
if (!virStorageSourceHasBacking(mirror)) {
/* for deep copy there won't be backing chain so we can terminate it */
- if (!mirror->backingStore &&
- !shallow &&
- !(mirror->backingStore = virStorageSourceNew()))
- return -1;
+ if (!mirror->backingStore && !shallow)
+ mirror->backingStore = virStorageSourceNew();
/* When reusing an external image we document that the user must ensure
* that the <mirror> image must expose data as the original image did
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_SNAPSHOT_ALLOW_WRITE_ONLY)) {
g_autoptr(virStorageSource) terminator = virStorageSourceNew();
- if (!terminator)
- goto endjob;
-
if (!(data = qemuBuildStorageSourceChainAttachPrepareBlockdevTop(mirror,
terminator,
priv->qemuCaps)))
return qemuDomainBlockPullCommon(vm, path, base, bandwidth, flags);
/* If we got here, we are doing a block copy rebase. */
- if (!(dest = virStorageSourceNew()))
- goto cleanup;
+ dest = virStorageSourceNew();
dest->type = (flags & VIR_DOMAIN_BLOCK_REBASE_COPY_DEV) ?
VIR_STORAGE_TYPE_BLOCK : VIR_STORAGE_TYPE_FILE;
dest->path = g_strdup(base);
{
g_autoptr(virStorageSource) copysrc = NULL;
- if (!(copysrc = virStorageSourceNew()))
- return NULL;
-
+ copysrc = virStorageSourceNew();
copysrc->type = VIR_STORAGE_TYPE_NETWORK;
copysrc->protocol = VIR_STORAGE_NET_PROTOCOL_NBD;
copysrc->format = VIR_STORAGE_FILE_RAW;
- if (!(copysrc->backingStore = virStorageSourceNew()))
- return NULL;
+ copysrc->backingStore = virStorageSourceNew();
if (!(copysrc->path = qemuAliasDiskDriveFromDisk(disk)))
return NULL;
/* create a terminator for the snapshot disks so that qemu does not try
* to open them at first */
- if (!(terminator = virStorageSourceNew()))
- return -1;
+ terminator = virStorageSourceNew();
if (qemuDomainPrepareStorageSourceBlockdev(dd->disk, dd->src,
priv, cfg) < 0)
goto cleanup;
if (meta->backingStoreRaw) {
- if (!(vol->target.backingStore = virStorageSourceNew()))
- goto cleanup;
-
+ vol->target.backingStore = virStorageSourceNew();
vol->target.backingStore->type = VIR_STORAGE_TYPE_NETWORK;
-
vol->target.backingStore->path = g_steal_pointer(&meta->backingStoreRaw);
vol->target.backingStore->format = meta->backingStoreRawFormat;
* lv is created with "--virtualsize").
*/
if (groups[1] && STRNEQ(groups[1], "") && (groups[1][0] != '[')) {
- if (!(vol->target.backingStore = virStorageSourceNew()))
- goto cleanup;
-
+ vol->target.backingStore = virStorageSourceNew();
vol->target.backingStore->path = g_strdup_printf("%s/%s",
def->target.path, groups[1]);
return -1;
if (meta->backingStoreRaw) {
- if (virStorageSourceNewFromBacking(meta, &target->backingStore) < 0)
- return -1;
+ virStorageSourceNewFromBacking(meta, &target->backingStore);
/* XXX: Remote storage doesn't play nicely with volumes backed by
* remote storage. To avoid trouble, just fake the backing store is RAW
if (!virStorageSourceIsLocalStorage(target->backingStore)) {
virObjectUnref(target->backingStore);
- if (!(target->backingStore = virStorageSourceNew()))
- return -1;
-
+ target->backingStore = virStorageSourceNew();
target->backingStore->type = VIR_STORAGE_TYPE_NETWORK;
target->backingStore->path = meta->backingStoreRaw;
meta->backingStoreRaw = NULL;
goto cleanup;
VIR_DIR_CLOSE(dir);
- if (!(target = virStorageSourceNew()))
- goto cleanup;
+ target = virStorageSourceNew();
if ((fd = open(def->target.path, O_RDONLY)) < 0) {
virReportSystemError(errno,
virStorageFileMetadataNew(const char *path,
int format)
{
- g_autoptr(virStorageSource) def = NULL;
-
- if (!(def = virStorageSourceNew()))
- return NULL;
+ g_autoptr(virStorageSource) def = virStorageSourceNew();
def->format = format;
def->type = VIR_STORAGE_TYPE_FILE;
virStorageSourceCopy(const virStorageSource *src,
bool backingChain)
{
- g_autoptr(virStorageSource) def = NULL;
-
- if (!(def = virStorageSourceNew()))
- return NULL;
+ g_autoptr(virStorageSource) def = virStorageSourceNew();
def->id = src->id;
def->type = src->type;
virStorageSourcePtr
virStorageSourceNew(void)
{
+ virStorageSourcePtr ret;
+
if (virStorageSourceInitialize() < 0)
- return NULL;
+ abort();
+
+ if (!(ret = virObjectNew(virStorageSourceClass)))
+ abort();
- return virObjectNew(virStorageSourceClass);
+ return ret;
}
const char *rel)
{
g_autofree char *dirname = NULL;
- g_autoptr(virStorageSource) def = NULL;
-
- if (!(def = virStorageSourceNew()))
- return NULL;
+ g_autoptr(virStorageSource) def = virStorageSourceNew();
/* store relative name */
def->relPath = g_strdup(rel);
const char *json;
const char *dirpath;
int rc = 0;
- g_autoptr(virStorageSource) def = NULL;
+ g_autoptr(virStorageSource) def = virStorageSourceNew();
*src = NULL;
- if (!(def = virStorageSourceNew()))
- return -1;
-
if (virStorageIsFile(path)) {
def->type = VIR_STORAGE_TYPE_FILE;
src->backingStore = g_steal_pointer(&backingStore);
} else {
/* add terminator */
- if (!(src->backingStore = virStorageSourceNew()))
- return -1;
+ src->backingStore = virStorageSourceNew();
}
return 0;
if (data->legacy)
backendpropsflags |= QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_LEGACY;
- if (!(xmlsrc = virStorageSourceNew()))
- return -1;
-
+ xmlsrc = virStorageSourceNew();
xmlsrc->type = data->type;
if (!(xml = virXMLParseStringCtxt(data->xml, "(test storage source XML)", &ctxt)))
static virStorageSourcePtr
testQemuBackupIncrementalBitmapCalculateGetFakeImage(size_t idx)
{
- virStorageSourcePtr ret;
-
- if (!(ret = virStorageSourceNew()))
- abort();
+ virStorageSourcePtr ret = virStorageSourceNew();
ret->id = idx;
ret->type = VIR_STORAGE_TYPE_FILE;
return -1;
}
- if (!(target = virStorageSourceNew()))
- return -1;
-
+ target = virStorageSourceNew();
target->nodeformat = g_strdup_printf("target_node");
if (qemuBackupDiskPrepareOneBitmapsChain(data->chain,
g_autoptr(virStorageSource) fakemirror = virStorageSourceNew();
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
- if (!fakemirror)
- return -1;
-
fakemirror->nodeformat = g_strdup("mirror-format-node");
expectpath = g_strdup_printf("%s/%s%s-out.json", abs_srcdir,
uid_t uid, gid_t gid)
{
struct stat st;
- g_autoptr(virStorageSource) def = NULL;
-
- if (!(def = virStorageSourceNew()))
- return NULL;
+ g_autoptr(virStorageSource) def = virStorageSourceNew();
def->type = VIR_STORAGE_TYPE_FILE;
def->format = format;