conf: store disk source as pointer, for easier manipulation

As part of the work on backing chains, I'm finding that it would
be easier to directly manipulate chains of pointers (adding a
snapshot merely adjusts pointers to form the correct list) rather
than copy data from one struct to another.  This patch converts
domain disk source to be a pointer.

In this patch, the pointer is ALWAYS allocated (thanks in part to
the previous patch forwarding all disk def allocation through a
common point), and all other changse are just mechanical fallout of
the new type; there should be no functional change.  It is possible
that we may want to leave the pointer NULL for a cdrom with no
medium in a later patch, but as that requires a closer audit of the
source to ensure we don't fault on a null dereference, I didn't do
it here.

* src/conf/domain_conf.h (_virDomainDiskDef): Change type of src.
* src/conf/domain_conf.c: Adjust all clients.
* src/security/security_selinux.c: Likewise.
* src/qemu/qemu_domain.c: Likewise.
* src/qemu/qemu_command.c: Likewise.
* src/qemu/qemu_conf.c: Likewise.
* src/qemu/qemu_process.c: Likewise.
* src/qemu/qemu_migration.c: Likewise.
* src/qemu/qemu_driver.c: Likewise.
* src/lxc/lxc_driver.c: Likewise.
* src/lxc/lxc_controller.c: Likewise.
* tests/securityselinuxlabeltest.c: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Eric Blake 2014-05-21 17:13:12 -06:00
parent bc3f5f190e
commit c123ef7104
13 changed files with 405 additions and 398 deletions

View File

@ -1186,7 +1186,10 @@ virDomainDiskDefNew(void)
{ {
virDomainDiskDefPtr ret; virDomainDiskDefPtr ret;
ignore_value(VIR_ALLOC(ret)); if (VIR_ALLOC(ret) < 0)
return NULL;
if (VIR_ALLOC(ret->src) < 0)
VIR_FREE(ret);
return ret; return ret;
} }
@ -1197,7 +1200,7 @@ virDomainDiskDefFree(virDomainDiskDefPtr def)
if (!def) if (!def)
return; return;
virStorageSourceClear(&def->src); virStorageSourceFree(def->src);
VIR_FREE(def->serial); VIR_FREE(def->serial);
VIR_FREE(def->dst); VIR_FREE(def->dst);
VIR_FREE(def->mirror); VIR_FREE(def->mirror);
@ -1213,21 +1216,21 @@ virDomainDiskDefFree(virDomainDiskDefPtr def)
int int
virDomainDiskGetType(virDomainDiskDefPtr def) virDomainDiskGetType(virDomainDiskDefPtr def)
{ {
return def->src.type; return def->src->type;
} }
void void
virDomainDiskSetType(virDomainDiskDefPtr def, int type) virDomainDiskSetType(virDomainDiskDefPtr def, int type)
{ {
def->src.type = type; def->src->type = type;
} }
const char * const char *
virDomainDiskGetSource(virDomainDiskDefPtr def) virDomainDiskGetSource(virDomainDiskDefPtr def)
{ {
return def->src.path; return def->src->path;
} }
@ -1235,11 +1238,11 @@ int
virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src) virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
{ {
int ret; int ret;
char *tmp = def->src.path; char *tmp = def->src->path;
ret = VIR_STRDUP(def->src.path, src); ret = VIR_STRDUP(def->src->path, src);
if (ret < 0) if (ret < 0)
def->src.path = tmp; def->src->path = tmp;
else else
VIR_FREE(tmp); VIR_FREE(tmp);
return ret; return ret;
@ -1249,7 +1252,7 @@ virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
const char * const char *
virDomainDiskGetDriver(virDomainDiskDefPtr def) virDomainDiskGetDriver(virDomainDiskDefPtr def)
{ {
return def->src.driverName; return def->src->driverName;
} }
@ -1257,11 +1260,11 @@ int
virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name) virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
{ {
int ret; int ret;
char *tmp = def->src.driverName; char *tmp = def->src->driverName;
ret = VIR_STRDUP(def->src.driverName, name); ret = VIR_STRDUP(def->src->driverName, name);
if (ret < 0) if (ret < 0)
def->src.driverName = tmp; def->src->driverName = tmp;
else else
VIR_FREE(tmp); VIR_FREE(tmp);
return ret; return ret;
@ -1271,14 +1274,14 @@ virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
int int
virDomainDiskGetFormat(virDomainDiskDefPtr def) virDomainDiskGetFormat(virDomainDiskDefPtr def)
{ {
return def->src.format; return def->src->format;
} }
void void
virDomainDiskSetFormat(virDomainDiskDefPtr def, int format) virDomainDiskSetFormat(virDomainDiskDefPtr def, int format)
{ {
def->src.format = format; def->src->format = format;
} }
@ -5257,13 +5260,13 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
type = virXMLPropString(node, "type"); type = virXMLPropString(node, "type");
if (type) { if (type) {
if ((def->src.type = virStorageTypeFromString(type)) <= 0) { if ((def->src->type = virStorageTypeFromString(type)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk type '%s'"), type); _("unknown disk type '%s'"), type);
goto error; goto error;
} }
} else { } else {
def->src.type = VIR_STORAGE_TYPE_FILE; def->src->type = VIR_STORAGE_TYPE_FILE;
} }
snapshot = virXMLPropString(node, "snapshot"); snapshot = virXMLPropString(node, "snapshot");
@ -5274,18 +5277,18 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
cur = node->children; cur = node->children;
while (cur != NULL) { while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE) { if (cur->type == XML_ELEMENT_NODE) {
if (!source && !def->src.hosts && !def->src.srcpool && if (!source && !def->src->hosts && !def->src->srcpool &&
xmlStrEqual(cur->name, BAD_CAST "source")) { xmlStrEqual(cur->name, BAD_CAST "source")) {
sourceNode = cur; sourceNode = cur;
if (virDomainDiskSourceParse(cur, &def->src) < 0) if (virDomainDiskSourceParse(cur, def->src) < 0)
goto error; goto error;
source = def->src.path; source = def->src->path;
if (def->src.type == VIR_STORAGE_TYPE_NETWORK) { if (def->src->type == VIR_STORAGE_TYPE_NETWORK) {
if (def->src.protocol == VIR_STORAGE_NET_PROTOCOL_ISCSI) if (def->src->protocol == VIR_STORAGE_NET_PROTOCOL_ISCSI)
expected_secret_usage = VIR_SECRET_USAGE_TYPE_ISCSI; expected_secret_usage = VIR_SECRET_USAGE_TYPE_ISCSI;
else if (def->src.protocol == VIR_STORAGE_NET_PROTOCOL_RBD) else if (def->src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD)
expected_secret_usage = VIR_SECRET_USAGE_TYPE_CEPH; expected_secret_usage = VIR_SECRET_USAGE_TYPE_CEPH;
} }
@ -5394,7 +5397,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error; goto error;
} }
def->src.auth.secretType = VIR_STORAGE_SECRET_TYPE_NONE; def->src->auth.secretType = VIR_STORAGE_SECRET_TYPE_NONE;
child = cur->children; child = cur->children;
while (child != NULL) { while (child != NULL) {
if (child->type == XML_ELEMENT_NODE && if (child->type == XML_ELEMENT_NODE &&
@ -5431,17 +5434,17 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
} }
if (authUUID != NULL) { if (authUUID != NULL) {
def->src.auth.secretType = VIR_STORAGE_SECRET_TYPE_UUID; def->src->auth.secretType = VIR_STORAGE_SECRET_TYPE_UUID;
if (virUUIDParse(authUUID, if (virUUIDParse(authUUID,
def->src.auth.secret.uuid) < 0) { def->src->auth.secret.uuid) < 0) {
virReportError(VIR_ERR_XML_ERROR, virReportError(VIR_ERR_XML_ERROR,
_("malformed uuid %s"), _("malformed uuid %s"),
authUUID); authUUID);
goto error; goto error;
} }
} else if (authUsage != NULL) { } else if (authUsage != NULL) {
def->src.auth.secretType = VIR_STORAGE_SECRET_TYPE_USAGE; def->src->auth.secretType = VIR_STORAGE_SECRET_TYPE_USAGE;
def->src.auth.secret.usage = authUsage; def->src->auth.secret.usage = authUsage;
authUsage = NULL; authUsage = NULL;
} }
} }
@ -5586,7 +5589,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
/* Only CDROM and Floppy devices are allowed missing source path /* Only CDROM and Floppy devices are allowed missing source path
* to indicate no media present. LUN is for raw access CD-ROMs * to indicate no media present. LUN is for raw access CD-ROMs
* that are not attached to a physical device presently */ * that are not attached to a physical device presently */
if (source == NULL && def->src.hosts == NULL && !def->src.srcpool && if (source == NULL && def->src->hosts == NULL && !def->src->srcpool &&
def->device != VIR_DOMAIN_DISK_DEVICE_CDROM && def->device != VIR_DOMAIN_DISK_DEVICE_CDROM &&
def->device != VIR_DOMAIN_DISK_DEVICE_LUN && def->device != VIR_DOMAIN_DISK_DEVICE_LUN &&
def->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY) { def->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
@ -5599,8 +5602,8 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
if (sourceNode) { if (sourceNode) {
xmlNodePtr saved_node = ctxt->node; xmlNodePtr saved_node = ctxt->node;
ctxt->node = sourceNode; ctxt->node = sourceNode;
if (virSecurityDeviceLabelDefParseXML(&def->src.seclabels, if (virSecurityDeviceLabelDefParseXML(&def->src->seclabels,
&def->src.nseclabels, &def->src->nseclabels,
vmSeclabels, vmSeclabels,
nvmSeclabels, nvmSeclabels,
ctxt, ctxt,
@ -5610,10 +5613,10 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
} }
if (target == NULL) { if (target == NULL) {
if (def->src.srcpool) { if (def->src->srcpool) {
char *tmp; char *tmp;
if (virAsprintf(&tmp, "pool = '%s', volume = '%s'", if (virAsprintf(&tmp, "pool = '%s', volume = '%s'",
def->src.srcpool->pool, def->src.srcpool->volume) < 0) def->src->srcpool->pool, def->src->srcpool->volume) < 0)
goto error; goto error;
virReportError(VIR_ERR_NO_TARGET, "%s", tmp); virReportError(VIR_ERR_NO_TARGET, "%s", tmp);
@ -5878,7 +5881,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error; goto error;
} }
if (def->src.type == VIR_STORAGE_TYPE_NETWORK) { if (def->src->type == VIR_STORAGE_TYPE_NETWORK) {
virReportError(VIR_ERR_XML_ERROR, virReportError(VIR_ERR_XML_ERROR,
_("Setting disk %s is not allowed for " _("Setting disk %s is not allowed for "
"disk of network type"), "disk of network type"),
@ -5899,14 +5902,14 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
def->dst = target; def->dst = target;
target = NULL; target = NULL;
def->src.auth.username = authUsername; def->src->auth.username = authUsername;
authUsername = NULL; authUsername = NULL;
def->src.driverName = driverName; def->src->driverName = driverName;
driverName = NULL; driverName = NULL;
def->mirror = mirror; def->mirror = mirror;
mirror = NULL; mirror = NULL;
def->mirroring = mirroring; def->mirroring = mirroring;
def->src.encryption = encryption; def->src->encryption = encryption;
encryption = NULL; encryption = NULL;
def->serial = serial; def->serial = serial;
serial = NULL; serial = NULL;
@ -5918,8 +5921,8 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
product = NULL; product = NULL;
if (driverType) { if (driverType) {
def->src.format = virStorageFileFormatTypeFromString(driverType); def->src->format = virStorageFileFormatTypeFromString(driverType);
if (def->src.format <= 0) { if (def->src->format <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown driver format value '%s'"), _("unknown driver format value '%s'"),
driverType); driverType);
@ -5941,7 +5944,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
&& virDomainDiskDefAssignAddress(xmlopt, def) < 0) && virDomainDiskDefAssignAddress(xmlopt, def) < 0)
goto error; goto error;
if (virDomainDiskBackingStoreParse(ctxt, &def->src) < 0) if (virDomainDiskBackingStoreParse(ctxt, def->src) < 0)
goto error; goto error;
cleanup: cleanup:
@ -15021,7 +15024,7 @@ virDomainDiskDefFormat(virBufferPtr buf,
virDomainDiskDefPtr def, virDomainDiskDefPtr def,
unsigned int flags) unsigned int flags)
{ {
const char *type = virStorageTypeToString(def->src.type); const char *type = virStorageTypeToString(def->src->type);
const char *device = virDomainDiskDeviceTypeToString(def->device); const char *device = virDomainDiskDeviceTypeToString(def->device);
const char *bus = virDomainDiskBusTypeToString(def->bus); const char *bus = virDomainDiskBusTypeToString(def->bus);
const char *cachemode = virDomainDiskCacheTypeToString(def->cachemode); const char *cachemode = virDomainDiskCacheTypeToString(def->cachemode);
@ -15036,9 +15039,9 @@ virDomainDiskDefFormat(virBufferPtr buf,
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
if (!type || !def->src.type) { if (!type || !def->src->type) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected disk type %d"), def->src.type); _("unexpected disk type %d"), def->src->type);
return -1; return -1;
} }
if (!device) { if (!device) {
@ -15088,16 +15091,16 @@ virDomainDiskDefFormat(virBufferPtr buf,
virBufferAddLit(buf, ">\n"); virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2); virBufferAdjustIndent(buf, 2);
if (def->src.driverName || def->src.format > 0 || def->cachemode || if (def->src->driverName || def->src->format > 0 || def->cachemode ||
def->error_policy || def->rerror_policy || def->iomode || def->error_policy || def->rerror_policy || def->iomode ||
def->ioeventfd || def->event_idx || def->copy_on_read || def->ioeventfd || def->event_idx || def->copy_on_read ||
def->discard) { def->discard) {
virBufferAddLit(buf, "<driver"); virBufferAddLit(buf, "<driver");
if (def->src.driverName) if (def->src->driverName)
virBufferAsprintf(buf, " name='%s'", def->src.driverName); virBufferAsprintf(buf, " name='%s'", def->src->driverName);
if (def->src.format > 0) if (def->src->format > 0)
virBufferAsprintf(buf, " type='%s'", virBufferAsprintf(buf, " type='%s'",
virStorageFileFormatTypeToString(def->src.format)); virStorageFileFormatTypeToString(def->src->format));
if (def->cachemode) if (def->cachemode)
virBufferAsprintf(buf, " cache='%s'", cachemode); virBufferAsprintf(buf, " cache='%s'", cachemode);
if (def->error_policy) if (def->error_policy)
@ -15117,37 +15120,37 @@ virDomainDiskDefFormat(virBufferPtr buf,
virBufferAddLit(buf, "/>\n"); virBufferAddLit(buf, "/>\n");
} }
if (def->src.auth.username) { if (def->src->auth.username) {
virBufferEscapeString(buf, "<auth username='%s'>\n", virBufferEscapeString(buf, "<auth username='%s'>\n",
def->src.auth.username); def->src->auth.username);
virBufferAdjustIndent(buf, 2); virBufferAdjustIndent(buf, 2);
if (def->src.protocol == VIR_STORAGE_NET_PROTOCOL_ISCSI) { if (def->src->protocol == VIR_STORAGE_NET_PROTOCOL_ISCSI) {
virBufferAddLit(buf, "<secret type='iscsi'"); virBufferAddLit(buf, "<secret type='iscsi'");
} else if (def->src.protocol == VIR_STORAGE_NET_PROTOCOL_RBD) { } else if (def->src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD) {
virBufferAddLit(buf, "<secret type='ceph'"); virBufferAddLit(buf, "<secret type='ceph'");
} }
if (def->src.auth.secretType == VIR_STORAGE_SECRET_TYPE_UUID) { if (def->src->auth.secretType == VIR_STORAGE_SECRET_TYPE_UUID) {
virUUIDFormat(def->src.auth.secret.uuid, uuidstr); virUUIDFormat(def->src->auth.secret.uuid, uuidstr);
virBufferAsprintf(buf, " uuid='%s'/>\n", uuidstr); virBufferAsprintf(buf, " uuid='%s'/>\n", uuidstr);
} }
if (def->src.auth.secretType == VIR_STORAGE_SECRET_TYPE_USAGE) { if (def->src->auth.secretType == VIR_STORAGE_SECRET_TYPE_USAGE) {
virBufferEscapeString(buf, " usage='%s'/>\n", virBufferEscapeString(buf, " usage='%s'/>\n",
def->src.auth.secret.usage); def->src->auth.secret.usage);
} }
virBufferAdjustIndent(buf, -2); virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</auth>\n"); virBufferAddLit(buf, "</auth>\n");
} }
if (virDomainDiskSourceFormat(buf, &def->src, def->startupPolicy, if (virDomainDiskSourceFormat(buf, def->src, def->startupPolicy,
flags) < 0) flags) < 0)
return -1; return -1;
/* Don't format backingStore to inactive XMLs until the code for /* Don't format backingStore to inactive XMLs until the code for
* persistent storage of backing chains is ready. */ * persistent storage of backing chains is ready. */
if (!(flags & VIR_DOMAIN_XML_INACTIVE) && if (!(flags & VIR_DOMAIN_XML_INACTIVE) &&
virDomainDiskBackingStoreFormat(buf, def->src.backingStore, virDomainDiskBackingStoreFormat(buf, def->src->backingStore,
def->src.backingStoreRaw, 1) < 0) def->src->backingStoreRaw, 1) < 0)
return -1; return -1;
virDomainDiskGeometryDefFormat(buf, def); virDomainDiskGeometryDefFormat(buf, def);
@ -15233,8 +15236,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
virBufferEscapeString(buf, "<wwn>%s</wwn>\n", def->wwn); virBufferEscapeString(buf, "<wwn>%s</wwn>\n", def->wwn);
virBufferEscapeString(buf, "<vendor>%s</vendor>\n", def->vendor); virBufferEscapeString(buf, "<vendor>%s</vendor>\n", def->vendor);
virBufferEscapeString(buf, "<product>%s</product>\n", def->product); virBufferEscapeString(buf, "<product>%s</product>\n", def->product);
if (def->src.encryption && if (def->src->encryption &&
virStorageEncryptionFormat(buf, def->src.encryption) < 0) virStorageEncryptionFormat(buf, def->src->encryption) < 0)
return -1; return -1;
if (virDomainDeviceInfoFormat(buf, &def->info, if (virDomainDeviceInfoFormat(buf, &def->info,
flags | VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT) < 0) flags | VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT) < 0)
@ -18682,7 +18685,7 @@ virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
char *brokenRaw = NULL; char *brokenRaw = NULL;
if (!ignoreOpenFailure) { if (!ignoreOpenFailure) {
if (virStorageFileChainGetBroken(&disk->src, &brokenRaw) < 0) if (virStorageFileChainGetBroken(disk->src, &brokenRaw) < 0)
goto cleanup; goto cleanup;
if (brokenRaw) { if (brokenRaw) {
@ -18693,7 +18696,7 @@ virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
} }
} }
for (tmp = &disk->src; tmp; tmp = tmp->backingStore) { for (tmp = disk->src; tmp; tmp = tmp->backingStore) {
int actualType = virStorageSourceGetActualType(tmp); int actualType = virStorageSourceGetActualType(tmp);
/* execute the callback only for local storage */ /* execute the callback only for local storage */
if (actualType != VIR_STORAGE_TYPE_NETWORK && if (actualType != VIR_STORAGE_TYPE_NETWORK &&
@ -19450,9 +19453,9 @@ virDomainDiskDefGetSecurityLabelDef(virDomainDiskDefPtr def, const char *model)
if (def == NULL) if (def == NULL)
return NULL; return NULL;
for (i = 0; i < def->src.nseclabels; i++) { for (i = 0; i < def->src->nseclabels; i++) {
if (STREQ_NULLABLE(def->src.seclabels[i]->model, model)) if (STREQ_NULLABLE(def->src->seclabels[i]->model, model))
return def->src.seclabels[i]; return def->src->seclabels[i];
} }
return NULL; return NULL;
} }
@ -19543,14 +19546,14 @@ virDomainDiskSourceIsBlockType(virDomainDiskDefPtr def)
* If it's a block type source pool, then it's possible * If it's a block type source pool, then it's possible
*/ */
if (virDomainDiskGetType(def) == VIR_STORAGE_TYPE_VOLUME && if (virDomainDiskGetType(def) == VIR_STORAGE_TYPE_VOLUME &&
def->src.srcpool && def->src->srcpool &&
def->src.srcpool->voltype == VIR_STORAGE_VOL_BLOCK) { def->src->srcpool->voltype == VIR_STORAGE_VOL_BLOCK) {
/* We don't think the volume accessed by remote URI is /* We don't think the volume accessed by remote URI is
* block type source, since we can't/shouldn't manage it * block type source, since we can't/shouldn't manage it
* (e.g. set sgio=filtered|unfiltered for it) in libvirt. * (e.g. set sgio=filtered|unfiltered for it) in libvirt.
*/ */
if (def->src.srcpool->pooltype == VIR_STORAGE_POOL_ISCSI && if (def->src->srcpool->pooltype == VIR_STORAGE_POOL_ISCSI &&
def->src.srcpool->mode == VIR_STORAGE_SOURCE_POOL_MODE_DIRECT) def->src->srcpool->mode == VIR_STORAGE_SOURCE_POOL_MODE_DIRECT)
return false; return false;
return true; return true;

View File

@ -598,7 +598,7 @@ typedef virDomainBlockIoTuneInfo *virDomainBlockIoTuneInfoPtr;
/* Stores the virtual disk configuration */ /* Stores the virtual disk configuration */
struct _virDomainDiskDef { struct _virDomainDiskDef {
virStorageSource src; virStorageSourcePtr src; /* non-NULL. XXX Allow NULL for empty cdrom? */
int device; /* enum virDomainDiskDevice */ int device; /* enum virDomainDiskDevice */
int bus; /* enum virDomainDiskBus */ int bus; /* enum virDomainDiskBus */

View File

@ -1669,7 +1669,7 @@ static int virLXCControllerSetupDisk(virLXCControllerPtr ctrl,
int ret = -1; int ret = -1;
struct stat sb; struct stat sb;
mode_t mode; mode_t mode;
char *tmpsrc = def->src.path; char *tmpsrc = def->src->path;
if (virDomainDiskGetType(def) != VIR_STORAGE_TYPE_BLOCK) { if (virDomainDiskGetType(def) != VIR_STORAGE_TYPE_BLOCK) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@ -1686,7 +1686,7 @@ static int virLXCControllerSetupDisk(virLXCControllerPtr ctrl,
LXC_STATE_DIR, ctrl->def->name, def->dst) < 0) LXC_STATE_DIR, ctrl->def->name, def->dst) < 0)
goto cleanup; goto cleanup;
if (stat(def->src.path, &sb) < 0) { if (stat(def->src->path, &sb) < 0) {
virReportSystemError(errno, virReportSystemError(errno,
_("Unable to access %s"), tmpsrc); _("Unable to access %s"), tmpsrc);
goto cleanup; goto cleanup;
@ -1726,14 +1726,14 @@ static int virLXCControllerSetupDisk(virLXCControllerPtr ctrl,
/* Labelling normally operates on src, but we need /* Labelling normally operates on src, but we need
* to actually label the dst here, so hack the config */ * to actually label the dst here, so hack the config */
def->src.path = dst; def->src->path = dst;
if (virSecurityManagerSetImageLabel(securityDriver, ctrl->def, def) < 0) if (virSecurityManagerSetImageLabel(securityDriver, ctrl->def, def) < 0)
goto cleanup; goto cleanup;
ret = 0; ret = 0;
cleanup: cleanup:
def->src.path = tmpsrc; def->src->path = tmpsrc;
VIR_FREE(dst); VIR_FREE(dst);
return ret; return ret;
} }

View File

@ -3897,14 +3897,14 @@ lxcDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED,
switch (data->def->type) { switch (data->def->type) {
case VIR_DOMAIN_DEVICE_DISK: { case VIR_DOMAIN_DEVICE_DISK: {
virDomainDiskDefPtr def = data->def->data.disk; virDomainDiskDefPtr def = data->def->data.disk;
char *tmpsrc = def->src.path; char *tmpsrc = def->src->path;
def->src.path = data->file; def->src->path = data->file;
if (virSecurityManagerSetImageLabel(data->driver->securityManager, if (virSecurityManagerSetImageLabel(data->driver->securityManager,
data->vm->def, def) < 0) { data->vm->def, def) < 0) {
def->src.path = tmpsrc; def->src->path = tmpsrc;
goto cleanup; goto cleanup;
} }
def->src.path = tmpsrc; def->src->path = tmpsrc;
} break; } break;
case VIR_DOMAIN_DEVICE_HOSTDEV: { case VIR_DOMAIN_DEVICE_HOSTDEV: {

View File

@ -2700,7 +2700,7 @@ static int qemuAddRBDHost(virDomainDiskDefPtr disk, char *hostport)
size_t skip; size_t skip;
char **parts; char **parts;
if (VIR_EXPAND_N(disk->src.hosts, disk->src.nhosts, 1) < 0) if (VIR_EXPAND_N(disk->src->hosts, disk->src->nhosts, 1) < 0)
return -1; return -1;
if ((port = strchr(hostport, ']'))) { if ((port = strchr(hostport, ']'))) {
@ -2715,29 +2715,29 @@ static int qemuAddRBDHost(virDomainDiskDefPtr disk, char *hostport)
if (port) { if (port) {
*port = '\0'; *port = '\0';
port += skip; port += skip;
if (VIR_STRDUP(disk->src.hosts[disk->src.nhosts - 1].port, port) < 0) if (VIR_STRDUP(disk->src->hosts[disk->src->nhosts - 1].port, port) < 0)
goto error; goto error;
} else { } else {
if (VIR_STRDUP(disk->src.hosts[disk->src.nhosts - 1].port, "6789") < 0) if (VIR_STRDUP(disk->src->hosts[disk->src->nhosts - 1].port, "6789") < 0)
goto error; goto error;
} }
parts = virStringSplit(hostport, "\\:", 0); parts = virStringSplit(hostport, "\\:", 0);
if (!parts) if (!parts)
goto error; goto error;
disk->src.hosts[disk->src.nhosts-1].name = virStringJoin((const char **)parts, ":"); disk->src->hosts[disk->src->nhosts-1].name = virStringJoin((const char **)parts, ":");
virStringFreeList(parts); virStringFreeList(parts);
if (!disk->src.hosts[disk->src.nhosts-1].name) if (!disk->src->hosts[disk->src->nhosts-1].name)
goto error; goto error;
disk->src.hosts[disk->src.nhosts-1].transport = VIR_STORAGE_NET_HOST_TRANS_TCP; disk->src->hosts[disk->src->nhosts-1].transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
disk->src.hosts[disk->src.nhosts-1].socket = NULL; disk->src->hosts[disk->src->nhosts-1].socket = NULL;
return 0; return 0;
error: error:
VIR_FREE(disk->src.hosts[disk->src.nhosts-1].port); VIR_FREE(disk->src->hosts[disk->src->nhosts-1].port);
VIR_FREE(disk->src.hosts[disk->src.nhosts-1].name); VIR_FREE(disk->src->hosts[disk->src->nhosts-1].name);
return -1; return -1;
} }
@ -2747,7 +2747,7 @@ static int qemuParseRBDString(virDomainDiskDefPtr disk)
char *options = NULL; char *options = NULL;
char *p, *e, *next; char *p, *e, *next;
p = strchr(disk->src.path, ':'); p = strchr(disk->src->path, ':');
if (p) { if (p) {
if (VIR_STRDUP(options, p + 1) < 0) if (VIR_STRDUP(options, p + 1) < 0)
goto error; goto error;
@ -2776,7 +2776,7 @@ static int qemuParseRBDString(virDomainDiskDefPtr disk)
} }
if (STRPREFIX(p, "id=") && if (STRPREFIX(p, "id=") &&
VIR_STRDUP(disk->src.auth.username, p + strlen("id=")) < 0) VIR_STRDUP(disk->src->auth.username, p + strlen("id=")) < 0)
goto error; goto error;
if (STRPREFIX(p, "mon_host=")) { if (STRPREFIX(p, "mon_host=")) {
char *h, *sep; char *h, *sep;
@ -2819,7 +2819,7 @@ qemuParseDriveURIString(virDomainDiskDefPtr def, virURIPtr uri,
char *volimg = NULL; char *volimg = NULL;
char *secret = NULL; char *secret = NULL;
if (VIR_ALLOC(def->src.hosts) < 0) if (VIR_ALLOC(def->src->hosts) < 0)
goto error; goto error;
transp = strchr(uri->scheme, '+'); transp = strchr(uri->scheme, '+');
@ -2833,30 +2833,30 @@ qemuParseDriveURIString(virDomainDiskDefPtr def, virURIPtr uri,
} }
if (!transp) { if (!transp) {
def->src.hosts->transport = VIR_STORAGE_NET_HOST_TRANS_TCP; def->src->hosts->transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
} else { } else {
def->src.hosts->transport = virStorageNetHostTransportTypeFromString(transp); def->src->hosts->transport = virStorageNetHostTransportTypeFromString(transp);
if (def->src.hosts->transport < 0) { if (def->src->hosts->transport < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid %s transport type '%s'"), scheme, transp); _("Invalid %s transport type '%s'"), scheme, transp);
goto error; goto error;
} }
} }
def->src.nhosts = 0; /* set to 1 once everything succeeds */ def->src->nhosts = 0; /* set to 1 once everything succeeds */
if (def->src.hosts->transport != VIR_STORAGE_NET_HOST_TRANS_UNIX) { if (def->src->hosts->transport != VIR_STORAGE_NET_HOST_TRANS_UNIX) {
if (VIR_STRDUP(def->src.hosts->name, uri->server) < 0) if (VIR_STRDUP(def->src->hosts->name, uri->server) < 0)
goto error; goto error;
if (virAsprintf(&def->src.hosts->port, "%d", uri->port) < 0) if (virAsprintf(&def->src->hosts->port, "%d", uri->port) < 0)
goto error; goto error;
} else { } else {
def->src.hosts->name = NULL; def->src->hosts->name = NULL;
def->src.hosts->port = 0; def->src->hosts->port = 0;
if (uri->query) { if (uri->query) {
if (STRPREFIX(uri->query, "socket=")) { if (STRPREFIX(uri->query, "socket=")) {
sock = strchr(uri->query, '=') + 1; sock = strchr(uri->query, '=') + 1;
if (VIR_STRDUP(def->src.hosts->socket, sock) < 0) if (VIR_STRDUP(def->src->hosts->socket, sock) < 0)
goto error; goto error;
} else { } else {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
@ -2867,11 +2867,11 @@ qemuParseDriveURIString(virDomainDiskDefPtr def, virURIPtr uri,
} }
if (uri->path) { if (uri->path) {
volimg = uri->path + 1; /* skip the prefix slash */ volimg = uri->path + 1; /* skip the prefix slash */
VIR_FREE(def->src.path); VIR_FREE(def->src->path);
if (VIR_STRDUP(def->src.path, volimg) < 0) if (VIR_STRDUP(def->src->path, volimg) < 0)
goto error; goto error;
} else { } else {
VIR_FREE(def->src.path); VIR_FREE(def->src->path);
} }
if (uri->user) { if (uri->user) {
@ -2879,11 +2879,11 @@ qemuParseDriveURIString(virDomainDiskDefPtr def, virURIPtr uri,
if (secret) if (secret)
*secret = '\0'; *secret = '\0';
if (VIR_STRDUP(def->src.auth.username, uri->user) < 0) if (VIR_STRDUP(def->src->auth.username, uri->user) < 0)
goto error; goto error;
} }
def->src.nhosts = 1; def->src->nhosts = 1;
ret = 0; ret = 0;
cleanup: cleanup:
@ -2892,8 +2892,8 @@ qemuParseDriveURIString(virDomainDiskDefPtr def, virURIPtr uri,
return ret; return ret;
error: error:
virStorageNetHostDefClear(def->src.hosts); virStorageNetHostDefClear(def->src->hosts);
VIR_FREE(def->src.hosts); VIR_FREE(def->src->hosts);
goto cleanup; goto cleanup;
} }
@ -2902,7 +2902,7 @@ qemuParseGlusterString(virDomainDiskDefPtr def)
{ {
virURIPtr uri = NULL; virURIPtr uri = NULL;
if (!(uri = virURIParse(def->src.path))) if (!(uri = virURIParse(def->src->path)))
return -1; return -1;
return qemuParseDriveURIString(def, uri, "gluster"); return qemuParseDriveURIString(def, uri, "gluster");
@ -2915,7 +2915,7 @@ qemuParseISCSIString(virDomainDiskDefPtr def)
char *slash; char *slash;
unsigned lun; unsigned lun;
if (!(uri = virURIParse(def->src.path))) if (!(uri = virURIParse(def->src->path)))
return -1; return -1;
if (uri->path && if (uri->path &&
@ -2926,7 +2926,7 @@ qemuParseISCSIString(virDomainDiskDefPtr def)
else if (virStrToLong_ui(slash + 1, NULL, 10, &lun) == -1) { else if (virStrToLong_ui(slash + 1, NULL, 10, &lun) == -1) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("invalid name '%s' for iSCSI disk"), _("invalid name '%s' for iSCSI disk"),
def->src.path); def->src->path);
return -1; return -1;
} }
} }
@ -2943,8 +2943,8 @@ qemuParseNBDString(virDomainDiskDefPtr disk)
virURIPtr uri = NULL; virURIPtr uri = NULL;
if (strstr(disk->src.path, "://")) { if (strstr(disk->src->path, "://")) {
if (!(uri = virURIParse(disk->src.path))) if (!(uri = virURIParse(disk->src->path)))
return -1; return -1;
return qemuParseDriveURIString(disk, uri, "nbd"); return qemuParseDriveURIString(disk, uri, "nbd");
} }
@ -2952,7 +2952,7 @@ qemuParseNBDString(virDomainDiskDefPtr disk)
if (VIR_ALLOC(h) < 0) if (VIR_ALLOC(h) < 0)
goto error; goto error;
host = disk->src.path + strlen("nbd:"); host = disk->src->path + strlen("nbd:");
if (STRPREFIX(host, "unix:/")) { if (STRPREFIX(host, "unix:/")) {
src = strchr(host + strlen("unix:"), ':'); src = strchr(host + strlen("unix:"), ':');
if (src) if (src)
@ -2965,7 +2965,7 @@ qemuParseNBDString(virDomainDiskDefPtr disk)
port = strchr(host, ':'); port = strchr(host, ':');
if (!port) { if (!port) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse nbd filename '%s'"), disk->src.path); _("cannot parse nbd filename '%s'"), disk->src->path);
goto error; goto error;
} }
@ -2988,10 +2988,10 @@ qemuParseNBDString(virDomainDiskDefPtr disk)
src = NULL; src = NULL;
} }
VIR_FREE(disk->src.path); VIR_FREE(disk->src->path);
disk->src.path = src; disk->src->path = src;
disk->src.nhosts = 1; disk->src->nhosts = 1;
disk->src.hosts = h; disk->src->hosts = h;
return 0; return 0;
error: error:
@ -3369,7 +3369,7 @@ qemuBuildDriveStr(virConnectPtr conn,
int idx = virDiskNameToIndex(disk->dst); int idx = virDiskNameToIndex(disk->dst);
int busid = -1, unitid = -1; int busid = -1, unitid = -1;
char *source = NULL; char *source = NULL;
int actualType = virStorageSourceGetActualType(&disk->src); int actualType = virStorageSourceGetActualType(disk->src);
if (idx < 0) { if (idx < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
@ -3451,7 +3451,7 @@ qemuBuildDriveStr(virConnectPtr conn,
break; break;
} }
if (qemuGetDriveSourceString(&disk->src, conn, &source) < 0) if (qemuGetDriveSourceString(disk->src, conn, &source) < 0)
goto error; goto error;
if (source && if (source &&
@ -3464,11 +3464,11 @@ qemuBuildDriveStr(virConnectPtr conn,
switch (actualType) { switch (actualType) {
case VIR_STORAGE_TYPE_DIR: case VIR_STORAGE_TYPE_DIR:
/* QEMU only supports magic FAT format for now */ /* QEMU only supports magic FAT format for now */
if (disk->src.format > 0 && if (disk->src->format > 0 &&
disk->src.format != VIR_STORAGE_FILE_FAT) { disk->src->format != VIR_STORAGE_FILE_FAT) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unsupported disk driver type for '%s'"), _("unsupported disk driver type for '%s'"),
virStorageFileFormatTypeToString(disk->src.format)); virStorageFileFormatTypeToString(disk->src->format));
goto error; goto error;
} }
@ -3488,7 +3488,7 @@ qemuBuildDriveStr(virConnectPtr conn,
case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_BLOCK:
if (disk->tray_status == VIR_DOMAIN_DISK_TRAY_OPEN) { if (disk->tray_status == VIR_DOMAIN_DISK_TRAY_OPEN) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
disk->src.type == VIR_STORAGE_TYPE_VOLUME ? disk->src->type == VIR_STORAGE_TYPE_VOLUME ?
_("tray status 'open' is invalid for block type volume") : _("tray status 'open' is invalid for block type volume") :
_("tray status 'open' is invalid for block type disk")); _("tray status 'open' is invalid for block type disk"));
goto error; goto error;
@ -3548,11 +3548,11 @@ qemuBuildDriveStr(virConnectPtr conn,
_("transient disks not supported yet")); _("transient disks not supported yet"));
goto error; goto error;
} }
if (disk->src.format > 0 && if (disk->src->format > 0 &&
disk->src.type != VIR_STORAGE_TYPE_DIR && disk->src->type != VIR_STORAGE_TYPE_DIR &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_FORMAT)) virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_FORMAT))
virBufferAsprintf(&opt, ",format=%s", virBufferAsprintf(&opt, ",format=%s",
virStorageFileFormatTypeToString(disk->src.format)); virStorageFileFormatTypeToString(disk->src->format));
/* generate geometry command string */ /* generate geometry command string */
if (disk->geometry.cylinders > 0 && if (disk->geometry.cylinders > 0 &&
@ -3763,11 +3763,11 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
bus); bus);
goto error; goto error;
} }
if (disk->src.type == VIR_STORAGE_TYPE_NETWORK) { if (disk->src->type == VIR_STORAGE_TYPE_NETWORK) {
if (disk->src.protocol != VIR_STORAGE_NET_PROTOCOL_ISCSI) { if (disk->src->protocol != VIR_STORAGE_NET_PROTOCOL_ISCSI) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("disk device='lun' is not supported for protocol='%s'"), _("disk device='lun' is not supported for protocol='%s'"),
virStorageNetProtocolTypeToString(disk->src.protocol)); virStorageNetProtocolTypeToString(disk->src->protocol));
goto error; goto error;
} }
} else if (!virDomainDiskSourceIsBlockType(disk)) { } else if (!virDomainDiskSourceIsBlockType(disk)) {
@ -7908,11 +7908,11 @@ qemuBuildCommandLine(virConnectPtr conn,
for (i = 0; i < def->ndisks; i++) { for (i = 0; i < def->ndisks; i++) {
virDomainDiskDefPtr disk = def->disks[i]; virDomainDiskDefPtr disk = def->disks[i];
if (disk->src.driverName != NULL && if (disk->src->driverName != NULL &&
!STREQ(disk->src.driverName, "qemu")) { !STREQ(disk->src->driverName, "qemu")) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported driver name '%s' for disk '%s'"), _("unsupported driver name '%s' for disk '%s'"),
disk->src.driverName, disk->src.path); disk->src->driverName, disk->src->path);
goto error; goto error;
} }
} }
@ -8037,11 +8037,11 @@ qemuBuildCommandLine(virConnectPtr conn,
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) { if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
virCommandAddArg(cmd, "-usbdevice"); virCommandAddArg(cmd, "-usbdevice");
virCommandAddArgFormat(cmd, "disk:%s", disk->src.path); virCommandAddArgFormat(cmd, "disk:%s", disk->src->path);
} else { } else {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unsupported usb disk type for '%s'"), _("unsupported usb disk type for '%s'"),
disk->src.path); disk->src->path);
goto error; goto error;
} }
continue; continue;
@ -8127,7 +8127,7 @@ qemuBuildCommandLine(virConnectPtr conn,
const char *fmt; const char *fmt;
virDomainDiskDefPtr disk = def->disks[i]; virDomainDiskDefPtr disk = def->disks[i];
if ((disk->src.type == VIR_STORAGE_TYPE_BLOCK) && if ((disk->src->type == VIR_STORAGE_TYPE_BLOCK) &&
(disk->tray_status == VIR_DOMAIN_DISK_TRAY_OPEN)) { (disk->tray_status == VIR_DOMAIN_DISK_TRAY_OPEN)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("tray status 'open' is invalid for " _("tray status 'open' is invalid for "
@ -8138,11 +8138,11 @@ qemuBuildCommandLine(virConnectPtr conn,
if (disk->bus == VIR_DOMAIN_DISK_BUS_USB) { if (disk->bus == VIR_DOMAIN_DISK_BUS_USB) {
if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) { if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
virCommandAddArg(cmd, "-usbdevice"); virCommandAddArg(cmd, "-usbdevice");
virCommandAddArgFormat(cmd, "disk:%s", disk->src.path); virCommandAddArgFormat(cmd, "disk:%s", disk->src->path);
} else { } else {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unsupported usb disk type for '%s'"), _("unsupported usb disk type for '%s'"),
disk->src.path); disk->src->path);
goto error; goto error;
} }
continue; continue;
@ -8150,7 +8150,7 @@ qemuBuildCommandLine(virConnectPtr conn,
if (STREQ(disk->dst, "hdc") && if (STREQ(disk->dst, "hdc") &&
disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) { disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
if (disk->src.path) { if (disk->src->path) {
snprintf(dev, NAME_MAX, "-%s", "cdrom"); snprintf(dev, NAME_MAX, "-%s", "cdrom");
} else { } else {
continue; continue;
@ -8166,13 +8166,13 @@ qemuBuildCommandLine(virConnectPtr conn,
} }
} }
if (disk->src.type == VIR_STORAGE_TYPE_DIR) { if (disk->src->type == VIR_STORAGE_TYPE_DIR) {
/* QEMU only supports magic FAT format for now */ /* QEMU only supports magic FAT format for now */
if (disk->src.format > 0 && if (disk->src->format > 0 &&
disk->src.format != VIR_STORAGE_FILE_FAT) { disk->src->format != VIR_STORAGE_FILE_FAT) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unsupported disk driver type for '%s'"), _("unsupported disk driver type for '%s'"),
virStorageFileFormatTypeToString(disk->src.format)); virStorageFileFormatTypeToString(disk->src->format));
goto error; goto error;
} }
if (!disk->readonly) { if (!disk->readonly) {
@ -8187,12 +8187,12 @@ qemuBuildCommandLine(virConnectPtr conn,
if (virAsprintf(&file, fmt, disk->src) < 0) if (virAsprintf(&file, fmt, disk->src) < 0)
goto error; goto error;
} else if (disk->src.type == VIR_STORAGE_TYPE_NETWORK) { } else if (disk->src->type == VIR_STORAGE_TYPE_NETWORK) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("network disks are only supported with -drive")); _("network disks are only supported with -drive"));
goto error; goto error;
} else { } else {
if (VIR_STRDUP(file, disk->src.path) < 0) { if (VIR_STRDUP(file, disk->src->path) < 0) {
goto error; goto error;
} }
} }
@ -9693,6 +9693,8 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
if (VIR_ALLOC(def) < 0) if (VIR_ALLOC(def) < 0)
goto cleanup; goto cleanup;
if (VIR_ALLOC(def->src) < 0)
goto error;
if (((dom->os.arch == VIR_ARCH_PPC64) && if (((dom->os.arch == VIR_ARCH_PPC64) &&
dom->os.machine && STREQ(dom->os.machine, "pseries"))) dom->os.machine && STREQ(dom->os.machine, "pseries")))
@ -9700,28 +9702,28 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
else else
def->bus = VIR_DOMAIN_DISK_BUS_IDE; def->bus = VIR_DOMAIN_DISK_BUS_IDE;
def->device = VIR_DOMAIN_DISK_DEVICE_DISK; def->device = VIR_DOMAIN_DISK_DEVICE_DISK;
def->src.type = VIR_STORAGE_TYPE_FILE; def->src->type = VIR_STORAGE_TYPE_FILE;
for (i = 0; i < nkeywords; i++) { for (i = 0; i < nkeywords; i++) {
if (STREQ(keywords[i], "file")) { if (STREQ(keywords[i], "file")) {
if (values[i] && STRNEQ(values[i], "")) { if (values[i] && STRNEQ(values[i], "")) {
def->src.path = values[i]; def->src->path = values[i];
values[i] = NULL; values[i] = NULL;
if (STRPREFIX(def->src.path, "/dev/")) if (STRPREFIX(def->src->path, "/dev/"))
def->src.type = VIR_STORAGE_TYPE_BLOCK; def->src->type = VIR_STORAGE_TYPE_BLOCK;
else if (STRPREFIX(def->src.path, "nbd:") || else if (STRPREFIX(def->src->path, "nbd:") ||
STRPREFIX(def->src.path, "nbd+")) { STRPREFIX(def->src->path, "nbd+")) {
def->src.type = VIR_STORAGE_TYPE_NETWORK; def->src->type = VIR_STORAGE_TYPE_NETWORK;
def->src.protocol = VIR_STORAGE_NET_PROTOCOL_NBD; def->src->protocol = VIR_STORAGE_NET_PROTOCOL_NBD;
if (qemuParseNBDString(def) < 0) if (qemuParseNBDString(def) < 0)
goto error; goto error;
} else if (STRPREFIX(def->src.path, "rbd:")) { } else if (STRPREFIX(def->src->path, "rbd:")) {
char *p = def->src.path; char *p = def->src->path;
def->src.type = VIR_STORAGE_TYPE_NETWORK; def->src->type = VIR_STORAGE_TYPE_NETWORK;
def->src.protocol = VIR_STORAGE_NET_PROTOCOL_RBD; def->src->protocol = VIR_STORAGE_NET_PROTOCOL_RBD;
if (VIR_STRDUP(def->src.path, p + strlen("rbd:")) < 0) if (VIR_STRDUP(def->src->path, p + strlen("rbd:")) < 0)
goto error; goto error;
/* old-style CEPH_ARGS env variable is parsed later */ /* old-style CEPH_ARGS env variable is parsed later */
if (!old_style_ceph_args && qemuParseRBDString(def) < 0) { if (!old_style_ceph_args && qemuParseRBDString(def) < 0) {
@ -9730,31 +9732,31 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
} }
VIR_FREE(p); VIR_FREE(p);
} else if (STRPREFIX(def->src.path, "gluster:") || } else if (STRPREFIX(def->src->path, "gluster:") ||
STRPREFIX(def->src.path, "gluster+")) { STRPREFIX(def->src->path, "gluster+")) {
def->src.type = VIR_STORAGE_TYPE_NETWORK; def->src->type = VIR_STORAGE_TYPE_NETWORK;
def->src.protocol = VIR_STORAGE_NET_PROTOCOL_GLUSTER; def->src->protocol = VIR_STORAGE_NET_PROTOCOL_GLUSTER;
if (qemuParseGlusterString(def) < 0) if (qemuParseGlusterString(def) < 0)
goto error; goto error;
} else if (STRPREFIX(def->src.path, "iscsi:")) { } else if (STRPREFIX(def->src->path, "iscsi:")) {
def->src.type = VIR_STORAGE_TYPE_NETWORK; def->src->type = VIR_STORAGE_TYPE_NETWORK;
def->src.protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI; def->src->protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI;
if (qemuParseISCSIString(def) < 0) if (qemuParseISCSIString(def) < 0)
goto error; goto error;
} else if (STRPREFIX(def->src.path, "sheepdog:")) { } else if (STRPREFIX(def->src->path, "sheepdog:")) {
char *p = def->src.path; char *p = def->src->path;
char *port, *vdi; char *port, *vdi;
def->src.type = VIR_STORAGE_TYPE_NETWORK; def->src->type = VIR_STORAGE_TYPE_NETWORK;
def->src.protocol = VIR_STORAGE_NET_PROTOCOL_SHEEPDOG; def->src->protocol = VIR_STORAGE_NET_PROTOCOL_SHEEPDOG;
if (VIR_STRDUP(def->src.path, p + strlen("sheepdog:")) < 0) if (VIR_STRDUP(def->src->path, p + strlen("sheepdog:")) < 0)
goto error; goto error;
VIR_FREE(p); VIR_FREE(p);
/* def->src.path must be [vdiname] or [host]:[port]:[vdiname] */ /* def->src->path must be [vdiname] or [host]:[port]:[vdiname] */
port = strchr(def->src.path, ':'); port = strchr(def->src->path, ':');
if (port) { if (port) {
*port = '\0'; *port = '\0';
vdi = strchr(port + 1, ':'); vdi = strchr(port + 1, ':');
@ -9762,26 +9764,26 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
*port = ':'; *port = ':';
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse sheepdog filename '%s'"), _("cannot parse sheepdog filename '%s'"),
def->src.path); def->src->path);
goto error; goto error;
} }
port++; port++;
*vdi++ = '\0'; *vdi++ = '\0';
if (VIR_ALLOC(def->src.hosts) < 0) if (VIR_ALLOC(def->src->hosts) < 0)
goto error; goto error;
def->src.nhosts = 1; def->src->nhosts = 1;
def->src.hosts->name = def->src.path; def->src->hosts->name = def->src->path;
if (VIR_STRDUP(def->src.hosts->port, port) < 0) if (VIR_STRDUP(def->src->hosts->port, port) < 0)
goto error; goto error;
def->src.hosts->transport = VIR_STORAGE_NET_HOST_TRANS_TCP; def->src->hosts->transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
def->src.hosts->socket = NULL; def->src->hosts->socket = NULL;
if (VIR_STRDUP(def->src.path, vdi) < 0) if (VIR_STRDUP(def->src->path, vdi) < 0)
goto error; goto error;
} }
} else } else
def->src.type = VIR_STORAGE_TYPE_FILE; def->src->type = VIR_STORAGE_TYPE_FILE;
} else { } else {
def->src.type = VIR_STORAGE_TYPE_FILE; def->src->type = VIR_STORAGE_TYPE_FILE;
} }
} else if (STREQ(keywords[i], "if")) { } else if (STREQ(keywords[i], "if")) {
if (STREQ(values[i], "ide")) { if (STREQ(values[i], "ide")) {
@ -9807,9 +9809,9 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
} else if (STREQ(values[i], "floppy")) } else if (STREQ(values[i], "floppy"))
def->device = VIR_DOMAIN_DISK_DEVICE_FLOPPY; def->device = VIR_DOMAIN_DISK_DEVICE_FLOPPY;
} else if (STREQ(keywords[i], "format")) { } else if (STREQ(keywords[i], "format")) {
if (VIR_STRDUP(def->src.driverName, "qemu") < 0) if (VIR_STRDUP(def->src->driverName, "qemu") < 0)
goto error; goto error;
def->src.format = virStorageFileFormatTypeFromString(values[i]); def->src->format = virStorageFileFormatTypeFromString(values[i]);
} else if (STREQ(keywords[i], "cache")) { } else if (STREQ(keywords[i], "cache")) {
if (STREQ(values[i], "off") || if (STREQ(values[i], "off") ||
STREQ(values[i], "none")) STREQ(values[i], "none"))
@ -9914,9 +9916,9 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
if (def->rerror_policy == def->error_policy) if (def->rerror_policy == def->error_policy)
def->rerror_policy = 0; def->rerror_policy = 0;
if (!def->src.path && if (!def->src->path &&
def->device == VIR_DOMAIN_DISK_DEVICE_DISK && def->device == VIR_DOMAIN_DISK_DEVICE_DISK &&
def->src.type != VIR_STORAGE_TYPE_NETWORK) { def->src->type != VIR_STORAGE_TYPE_NETWORK) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("missing file parameter in drive '%s'"), val); _("missing file parameter in drive '%s'"), val);
goto error; goto error;
@ -11001,23 +11003,23 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
goto error; goto error;
if (STRPREFIX(val, "/dev/")) if (STRPREFIX(val, "/dev/"))
disk->src.type = VIR_STORAGE_TYPE_BLOCK; disk->src->type = VIR_STORAGE_TYPE_BLOCK;
else if (STRPREFIX(val, "nbd:")) { else if (STRPREFIX(val, "nbd:")) {
disk->src.type = VIR_STORAGE_TYPE_NETWORK; disk->src->type = VIR_STORAGE_TYPE_NETWORK;
disk->src.protocol = VIR_STORAGE_NET_PROTOCOL_NBD; disk->src->protocol = VIR_STORAGE_NET_PROTOCOL_NBD;
} else if (STRPREFIX(val, "rbd:")) { } else if (STRPREFIX(val, "rbd:")) {
disk->src.type = VIR_STORAGE_TYPE_NETWORK; disk->src->type = VIR_STORAGE_TYPE_NETWORK;
disk->src.protocol = VIR_STORAGE_NET_PROTOCOL_RBD; disk->src->protocol = VIR_STORAGE_NET_PROTOCOL_RBD;
val += strlen("rbd:"); val += strlen("rbd:");
} else if (STRPREFIX(val, "gluster")) { } else if (STRPREFIX(val, "gluster")) {
disk->src.type = VIR_STORAGE_TYPE_NETWORK; disk->src->type = VIR_STORAGE_TYPE_NETWORK;
disk->src.protocol = VIR_STORAGE_NET_PROTOCOL_GLUSTER; disk->src->protocol = VIR_STORAGE_NET_PROTOCOL_GLUSTER;
} else if (STRPREFIX(val, "sheepdog:")) { } else if (STRPREFIX(val, "sheepdog:")) {
disk->src.type = VIR_STORAGE_TYPE_NETWORK; disk->src->type = VIR_STORAGE_TYPE_NETWORK;
disk->src.protocol = VIR_STORAGE_NET_PROTOCOL_SHEEPDOG; disk->src->protocol = VIR_STORAGE_NET_PROTOCOL_SHEEPDOG;
val += strlen("sheepdog:"); val += strlen("sheepdog:");
} else } else
disk->src.type = VIR_STORAGE_TYPE_FILE; disk->src->type = VIR_STORAGE_TYPE_FILE;
if (STREQ(arg, "-cdrom")) { if (STREQ(arg, "-cdrom")) {
disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM; disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM;
if (((def->os.arch == VIR_ARCH_PPC64) && if (((def->os.arch == VIR_ARCH_PPC64) &&
@ -11043,13 +11045,13 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
if (VIR_STRDUP(disk->dst, arg + 1) < 0) if (VIR_STRDUP(disk->dst, arg + 1) < 0)
goto error; goto error;
} }
if (VIR_STRDUP(disk->src.path, val) < 0) if (VIR_STRDUP(disk->src->path, val) < 0)
goto error; goto error;
if (disk->src.type == VIR_STORAGE_TYPE_NETWORK) { if (disk->src->type == VIR_STORAGE_TYPE_NETWORK) {
char *port; char *port;
switch ((virStorageNetProtocol) disk->src.protocol) { switch ((virStorageNetProtocol) disk->src->protocol) {
case VIR_STORAGE_NET_PROTOCOL_NBD: case VIR_STORAGE_NET_PROTOCOL_NBD:
if (qemuParseNBDString(disk) < 0) if (qemuParseNBDString(disk) < 0)
goto error; goto error;
@ -11061,7 +11063,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
break; break;
case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG:
/* disk->src must be [vdiname] or [host]:[port]:[vdiname] */ /* disk->src must be [vdiname] or [host]:[port]:[vdiname] */
port = strchr(disk->src.path, ':'); port = strchr(disk->src->path, ':');
if (port) { if (port) {
char *vdi; char *vdi;
@ -11073,13 +11075,13 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
goto error; goto error;
} }
*vdi++ = '\0'; *vdi++ = '\0';
if (VIR_ALLOC(disk->src.hosts) < 0) if (VIR_ALLOC(disk->src->hosts) < 0)
goto error; goto error;
disk->src.nhosts = 1; disk->src->nhosts = 1;
disk->src.hosts->name = disk->src.path; disk->src->hosts->name = disk->src->path;
if (VIR_STRDUP(disk->src.hosts->port, port) < 0) if (VIR_STRDUP(disk->src->hosts->port, port) < 0)
goto error; goto error;
if (VIR_STRDUP(disk->src.path, vdi) < 0) if (VIR_STRDUP(disk->src->path, vdi) < 0)
goto error; goto error;
} }
break; break;
@ -11299,12 +11301,12 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
} else if (STRPREFIX(val, "disk:")) { } else if (STRPREFIX(val, "disk:")) {
if (!(disk = virDomainDiskDefNew())) if (!(disk = virDomainDiskDefNew()))
goto error; goto error;
if (VIR_STRDUP(disk->src.path, val + strlen("disk:")) < 0) if (VIR_STRDUP(disk->src->path, val + strlen("disk:")) < 0)
goto error; goto error;
if (STRPREFIX(disk->src.path, "/dev/")) if (STRPREFIX(disk->src->path, "/dev/"))
disk->src.type = VIR_STORAGE_TYPE_BLOCK; disk->src->type = VIR_STORAGE_TYPE_BLOCK;
else else
disk->src.type = VIR_STORAGE_TYPE_FILE; disk->src->type = VIR_STORAGE_TYPE_FILE;
disk->device = VIR_DOMAIN_DISK_DEVICE_DISK; disk->device = VIR_DOMAIN_DISK_DEVICE_DISK;
disk->bus = VIR_DOMAIN_DISK_BUS_USB; disk->bus = VIR_DOMAIN_DISK_BUS_USB;
disk->removable = VIR_DOMAIN_FEATURE_STATE_DEFAULT; disk->removable = VIR_DOMAIN_FEATURE_STATE_DEFAULT;
@ -11535,8 +11537,8 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
char *hosts, *port, *saveptr = NULL, *token; char *hosts, *port, *saveptr = NULL, *token;
virDomainDiskDefPtr first_rbd_disk = NULL; virDomainDiskDefPtr first_rbd_disk = NULL;
for (i = 0; i < def->ndisks; i++) { for (i = 0; i < def->ndisks; i++) {
if (def->disks[i]->src.type == VIR_STORAGE_TYPE_NETWORK && if (def->disks[i]->src->type == VIR_STORAGE_TYPE_NETWORK &&
def->disks[i]->src.protocol == VIR_STORAGE_NET_PROTOCOL_RBD) { def->disks[i]->src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD) {
first_rbd_disk = def->disks[i]; first_rbd_disk = def->disks[i];
break; break;
} }
@ -11556,11 +11558,11 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
} }
if (VIR_STRDUP(hosts, strchr(ceph_args, ' ') + 1) < 0) if (VIR_STRDUP(hosts, strchr(ceph_args, ' ') + 1) < 0)
goto error; goto error;
first_rbd_disk->src.nhosts = 0; first_rbd_disk->src->nhosts = 0;
token = strtok_r(hosts, ",", &saveptr); token = strtok_r(hosts, ",", &saveptr);
while (token != NULL) { while (token != NULL) {
if (VIR_REALLOC_N(first_rbd_disk->src.hosts, if (VIR_REALLOC_N(first_rbd_disk->src->hosts,
first_rbd_disk->src.nhosts + 1) < 0) { first_rbd_disk->src->nhosts + 1) < 0) {
VIR_FREE(hosts); VIR_FREE(hosts);
goto error; goto error;
} }
@ -11572,21 +11574,21 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
goto error; goto error;
} }
} }
first_rbd_disk->src.hosts[first_rbd_disk->src.nhosts].port = port; first_rbd_disk->src->hosts[first_rbd_disk->src->nhosts].port = port;
if (VIR_STRDUP(first_rbd_disk->src.hosts[first_rbd_disk->src.nhosts].name, if (VIR_STRDUP(first_rbd_disk->src->hosts[first_rbd_disk->src->nhosts].name,
token) < 0) { token) < 0) {
VIR_FREE(hosts); VIR_FREE(hosts);
goto error; goto error;
} }
first_rbd_disk->src.hosts[first_rbd_disk->src.nhosts].transport = VIR_STORAGE_NET_HOST_TRANS_TCP; first_rbd_disk->src->hosts[first_rbd_disk->src->nhosts].transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
first_rbd_disk->src.hosts[first_rbd_disk->src.nhosts].socket = NULL; first_rbd_disk->src->hosts[first_rbd_disk->src->nhosts].socket = NULL;
first_rbd_disk->src.nhosts++; first_rbd_disk->src->nhosts++;
token = strtok_r(NULL, ",", &saveptr); token = strtok_r(NULL, ",", &saveptr);
} }
VIR_FREE(hosts); VIR_FREE(hosts);
if (first_rbd_disk->src.nhosts == 0) { if (first_rbd_disk->src->nhosts == 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("found no rbd hosts in CEPH_ARGS '%s'"), ceph_args); _("found no rbd hosts in CEPH_ARGS '%s'"), ceph_args);
goto error; goto error;

View File

@ -802,8 +802,8 @@ qemuCheckSharedDevice(virHashTablePtr sharedDevices,
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("sgio of shared disk 'pool=%s' 'volume=%s' conflicts " _("sgio of shared disk 'pool=%s' 'volume=%s' conflicts "
"with other active domains"), "with other active domains"),
disk->src.srcpool->pool, disk->src->srcpool->pool,
disk->src.srcpool->volume); disk->src->srcpool->volume);
} else { } else {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("sgio of shared disk '%s' conflicts with other " _("sgio of shared disk '%s' conflicts with other "
@ -1163,33 +1163,33 @@ qemuAddISCSIPoolSourceHost(virDomainDiskDefPtr def,
} }
/* iscsi pool only supports one host */ /* iscsi pool only supports one host */
def->src.nhosts = 1; def->src->nhosts = 1;
if (VIR_ALLOC_N(def->src.hosts, def->src.nhosts) < 0) if (VIR_ALLOC_N(def->src->hosts, def->src->nhosts) < 0)
goto cleanup; goto cleanup;
if (VIR_STRDUP(def->src.hosts[0].name, pooldef->source.hosts[0].name) < 0) if (VIR_STRDUP(def->src->hosts[0].name, pooldef->source.hosts[0].name) < 0)
goto cleanup; goto cleanup;
if (virAsprintf(&def->src.hosts[0].port, "%d", if (virAsprintf(&def->src->hosts[0].port, "%d",
pooldef->source.hosts[0].port ? pooldef->source.hosts[0].port ?
pooldef->source.hosts[0].port : pooldef->source.hosts[0].port :
3260) < 0) 3260) < 0)
goto cleanup; goto cleanup;
/* iscsi volume has name like "unit:0:0:1" */ /* iscsi volume has name like "unit:0:0:1" */
if (!(tokens = virStringSplit(def->src.srcpool->volume, ":", 0))) if (!(tokens = virStringSplit(def->src->srcpool->volume, ":", 0)))
goto cleanup; goto cleanup;
if (virStringListLength(tokens) != 4) { if (virStringListLength(tokens) != 4) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected iscsi volume name '%s'"), _("unexpected iscsi volume name '%s'"),
def->src.srcpool->volume); def->src->srcpool->volume);
goto cleanup; goto cleanup;
} }
/* iscsi pool has only one source device path */ /* iscsi pool has only one source device path */
if (virAsprintf(&def->src.path, "%s/%s", if (virAsprintf(&def->src->path, "%s/%s",
pooldef->source.devices[0].path, pooldef->source.devices[0].path,
tokens[3]) < 0) tokens[3]) < 0)
goto cleanup; goto cleanup;
@ -1197,10 +1197,10 @@ qemuAddISCSIPoolSourceHost(virDomainDiskDefPtr def,
/* Storage pool have not supported these 2 attributes yet, /* Storage pool have not supported these 2 attributes yet,
* use the defaults. * use the defaults.
*/ */
def->src.hosts[0].transport = VIR_STORAGE_NET_HOST_TRANS_TCP; def->src->hosts[0].transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
def->src.hosts[0].socket = NULL; def->src->hosts[0].socket = NULL;
def->src.protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI; def->src->protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI;
ret = 0; ret = 0;
@ -1225,34 +1225,34 @@ qemuTranslateDiskSourcePoolAuth(virDomainDiskDefPtr def,
* into the virDomainDiskDef * into the virDomainDiskDef
*/ */
if (pooldef->source.authType == VIR_STORAGE_POOL_AUTH_CHAP) { if (pooldef->source.authType == VIR_STORAGE_POOL_AUTH_CHAP) {
if (VIR_STRDUP(def->src.auth.username, if (VIR_STRDUP(def->src->auth.username,
pooldef->source.auth.chap.username) < 0) pooldef->source.auth.chap.username) < 0)
goto cleanup; goto cleanup;
if (pooldef->source.auth.chap.secret.uuidUsable) { if (pooldef->source.auth.chap.secret.uuidUsable) {
def->src.auth.secretType = VIR_STORAGE_SECRET_TYPE_UUID; def->src->auth.secretType = VIR_STORAGE_SECRET_TYPE_UUID;
memcpy(def->src.auth.secret.uuid, memcpy(def->src->auth.secret.uuid,
pooldef->source.auth.chap.secret.uuid, pooldef->source.auth.chap.secret.uuid,
VIR_UUID_BUFLEN); VIR_UUID_BUFLEN);
} else { } else {
if (VIR_STRDUP(def->src.auth.secret.usage, if (VIR_STRDUP(def->src->auth.secret.usage,
pooldef->source.auth.chap.secret.usage) < 0) pooldef->source.auth.chap.secret.usage) < 0)
goto cleanup; goto cleanup;
def->src.auth.secretType = VIR_STORAGE_SECRET_TYPE_USAGE; def->src->auth.secretType = VIR_STORAGE_SECRET_TYPE_USAGE;
} }
} else if (pooldef->source.authType == VIR_STORAGE_POOL_AUTH_CEPHX) { } else if (pooldef->source.authType == VIR_STORAGE_POOL_AUTH_CEPHX) {
if (VIR_STRDUP(def->src.auth.username, if (VIR_STRDUP(def->src->auth.username,
pooldef->source.auth.cephx.username) < 0) pooldef->source.auth.cephx.username) < 0)
goto cleanup; goto cleanup;
if (pooldef->source.auth.cephx.secret.uuidUsable) { if (pooldef->source.auth.cephx.secret.uuidUsable) {
def->src.auth.secretType = VIR_STORAGE_SECRET_TYPE_UUID; def->src->auth.secretType = VIR_STORAGE_SECRET_TYPE_UUID;
memcpy(def->src.auth.secret.uuid, memcpy(def->src->auth.secret.uuid,
pooldef->source.auth.cephx.secret.uuid, pooldef->source.auth.cephx.secret.uuid,
VIR_UUID_BUFLEN); VIR_UUID_BUFLEN);
} else { } else {
if (VIR_STRDUP(def->src.auth.secret.usage, if (VIR_STRDUP(def->src->auth.secret.usage,
pooldef->source.auth.cephx.secret.usage) < 0) pooldef->source.auth.cephx.secret.usage) < 0)
goto cleanup; goto cleanup;
def->src.auth.secretType = VIR_STORAGE_SECRET_TYPE_USAGE; def->src->auth.secretType = VIR_STORAGE_SECRET_TYPE_USAGE;
} }
} }
ret = 0; ret = 0;
@ -1274,24 +1274,24 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
int ret = -1; int ret = -1;
virErrorPtr savedError = NULL; virErrorPtr savedError = NULL;
if (def->src.type != VIR_STORAGE_TYPE_VOLUME) if (def->src->type != VIR_STORAGE_TYPE_VOLUME)
return 0; return 0;
if (!def->src.srcpool) if (!def->src->srcpool)
return 0; return 0;
if (!(pool = virStoragePoolLookupByName(conn, def->src.srcpool->pool))) if (!(pool = virStoragePoolLookupByName(conn, def->src->srcpool->pool)))
return -1; return -1;
if (virStoragePoolIsActive(pool) != 1) { if (virStoragePoolIsActive(pool) != 1) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("storage pool '%s' containing volume '%s' " _("storage pool '%s' containing volume '%s' "
"is not active"), "is not active"),
def->src.srcpool->pool, def->src.srcpool->volume); def->src->srcpool->pool, def->src->srcpool->volume);
goto cleanup; goto cleanup;
} }
if (!(vol = virStorageVolLookupByName(pool, def->src.srcpool->volume))) if (!(vol = virStorageVolLookupByName(pool, def->src->srcpool->volume)))
goto cleanup; goto cleanup;
if (virStorageVolGetInfo(vol, &info) < 0) if (virStorageVolGetInfo(vol, &info) < 0)
@ -1303,19 +1303,19 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
if (!(pooldef = virStoragePoolDefParseString(poolxml))) if (!(pooldef = virStoragePoolDefParseString(poolxml)))
goto cleanup; goto cleanup;
def->src.srcpool->pooltype = pooldef->type; def->src->srcpool->pooltype = pooldef->type;
def->src.srcpool->voltype = info.type; def->src->srcpool->voltype = info.type;
if (def->src.srcpool->mode && pooldef->type != VIR_STORAGE_POOL_ISCSI) { if (def->src->srcpool->mode && pooldef->type != VIR_STORAGE_POOL_ISCSI) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("disk source mode is only valid when " _("disk source mode is only valid when "
"storage pool is of iscsi type")); "storage pool is of iscsi type"));
goto cleanup; goto cleanup;
} }
VIR_FREE(def->src.path); VIR_FREE(def->src->path);
virStorageNetHostDefFree(def->src.nhosts, def->src.hosts); virStorageNetHostDefFree(def->src->nhosts, def->src->hosts);
virStorageSourceAuthClear(&def->src); virStorageSourceAuthClear(def->src);
switch ((virStoragePoolType) pooldef->type) { switch ((virStoragePoolType) pooldef->type) {
case VIR_STORAGE_POOL_DIR: case VIR_STORAGE_POOL_DIR:
@ -1324,7 +1324,7 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
case VIR_STORAGE_POOL_LOGICAL: case VIR_STORAGE_POOL_LOGICAL:
case VIR_STORAGE_POOL_DISK: case VIR_STORAGE_POOL_DISK:
case VIR_STORAGE_POOL_SCSI: case VIR_STORAGE_POOL_SCSI:
if (!(def->src.path = virStorageVolGetPath(vol))) if (!(def->src->path = virStorageVolGetPath(vol)))
goto cleanup; goto cleanup;
if (def->startupPolicy && info.type != VIR_STORAGE_VOL_FILE) { if (def->startupPolicy && info.type != VIR_STORAGE_VOL_FILE) {
@ -1337,15 +1337,15 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
switch (info.type) { switch (info.type) {
case VIR_STORAGE_VOL_FILE: case VIR_STORAGE_VOL_FILE:
def->src.srcpool->actualtype = VIR_STORAGE_TYPE_FILE; def->src->srcpool->actualtype = VIR_STORAGE_TYPE_FILE;
break; break;
case VIR_STORAGE_VOL_DIR: case VIR_STORAGE_VOL_DIR:
def->src.srcpool->actualtype = VIR_STORAGE_TYPE_DIR; def->src->srcpool->actualtype = VIR_STORAGE_TYPE_DIR;
break; break;
case VIR_STORAGE_VOL_BLOCK: case VIR_STORAGE_VOL_BLOCK:
def->src.srcpool->actualtype = VIR_STORAGE_TYPE_BLOCK; def->src->srcpool->actualtype = VIR_STORAGE_TYPE_BLOCK;
break; break;
case VIR_STORAGE_VOL_NETWORK: case VIR_STORAGE_VOL_NETWORK:
@ -1368,20 +1368,20 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
goto cleanup; goto cleanup;
} }
switch (def->src.srcpool->mode) { switch (def->src->srcpool->mode) {
case VIR_STORAGE_SOURCE_POOL_MODE_DEFAULT: case VIR_STORAGE_SOURCE_POOL_MODE_DEFAULT:
case VIR_STORAGE_SOURCE_POOL_MODE_LAST: case VIR_STORAGE_SOURCE_POOL_MODE_LAST:
def->src.srcpool->mode = VIR_STORAGE_SOURCE_POOL_MODE_HOST; def->src->srcpool->mode = VIR_STORAGE_SOURCE_POOL_MODE_HOST;
/* fallthrough */ /* fallthrough */
case VIR_STORAGE_SOURCE_POOL_MODE_HOST: case VIR_STORAGE_SOURCE_POOL_MODE_HOST:
def->src.srcpool->actualtype = VIR_STORAGE_TYPE_BLOCK; def->src->srcpool->actualtype = VIR_STORAGE_TYPE_BLOCK;
if (!(def->src.path = virStorageVolGetPath(vol))) if (!(def->src->path = virStorageVolGetPath(vol)))
goto cleanup; goto cleanup;
break; break;
case VIR_STORAGE_SOURCE_POOL_MODE_DIRECT: case VIR_STORAGE_SOURCE_POOL_MODE_DIRECT:
def->src.srcpool->actualtype = VIR_STORAGE_TYPE_NETWORK; def->src->srcpool->actualtype = VIR_STORAGE_TYPE_NETWORK;
def->src.protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI; def->src->protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI;
if (qemuTranslateDiskSourcePoolAuth(def, pooldef) < 0) if (qemuTranslateDiskSourcePoolAuth(def, pooldef) < 0)
goto cleanup; goto cleanup;

View File

@ -2258,7 +2258,7 @@ qemuDiskChainCheckBroken(virDomainDiskDefPtr disk)
if (!virDomainDiskGetSource(disk)) if (!virDomainDiskGetSource(disk))
return 0; return 0;
if (virStorageFileChainGetBroken(&disk->src, &brokenFile) < 0) if (virStorageFileChainGetBroken(disk->src, &brokenFile) < 0)
return -1; return -1;
if (brokenFile) { if (brokenFile) {
@ -2286,7 +2286,7 @@ qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
virDomainDiskDefPtr disk = vm->def->disks[idx]; virDomainDiskDefPtr disk = vm->def->disks[idx];
const char *path = virDomainDiskGetSource(disk); const char *path = virDomainDiskGetSource(disk);
virStorageFileFormat format = virDomainDiskGetFormat(disk); virStorageFileFormat format = virDomainDiskGetFormat(disk);
virStorageType type = virStorageSourceGetActualType(&disk->src); virStorageType type = virStorageSourceGetActualType(disk->src);
if (!path) if (!path)
continue; continue;
@ -2428,22 +2428,22 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
int ret = 0; int ret = 0;
uid_t uid; uid_t uid;
gid_t gid; gid_t gid;
int type = virStorageSourceGetActualType(&disk->src); int type = virStorageSourceGetActualType(disk->src);
if (type != VIR_STORAGE_TYPE_NETWORK && if (type != VIR_STORAGE_TYPE_NETWORK &&
!disk->src.path) !disk->src->path)
goto cleanup; goto cleanup;
if (disk->src.backingStore) { if (disk->src->backingStore) {
if (force) if (force)
virStorageSourceClearBackingStore(&disk->src); virStorageSourceClearBackingStore(disk->src);
else else
goto cleanup; goto cleanup;
} }
qemuDomainGetImageIds(cfg, vm, disk, &uid, &gid); qemuDomainGetImageIds(cfg, vm, disk, &uid, &gid);
if (virStorageFileGetMetadata(&disk->src, if (virStorageFileGetMetadata(disk->src,
uid, gid, uid, gid,
cfg->allowDiskFormatProbing) < 0) cfg->allowDiskFormatProbing) < 0)
ret = -1; ret = -1;

View File

@ -6917,18 +6917,18 @@ qemuDomainUpdateDeviceConfig(virQEMUCapsPtr qemuCaps,
* Update 'orig' * Update 'orig'
* We allow updating src/type//driverType/cachemode/ * We allow updating src/type//driverType/cachemode/
*/ */
VIR_FREE(orig->src.path); VIR_FREE(orig->src->path);
orig->src.path = disk->src.path; orig->src->path = disk->src->path;
orig->src.type = disk->src.type; orig->src->type = disk->src->type;
orig->cachemode = disk->cachemode; orig->cachemode = disk->cachemode;
if (disk->src.driverName) { if (disk->src->driverName) {
VIR_FREE(orig->src.driverName); VIR_FREE(orig->src->driverName);
orig->src.driverName = disk->src.driverName; orig->src->driverName = disk->src->driverName;
disk->src.driverName = NULL; disk->src->driverName = NULL;
} }
if (disk->src.format) if (disk->src->format)
orig->src.format = disk->src.format; orig->src->format = disk->src->format;
disk->src.path = NULL; disk->src->path = NULL;
break; break;
case VIR_DOMAIN_DEVICE_NET: case VIR_DOMAIN_DEVICE_NET:
@ -9500,8 +9500,8 @@ qemuDomainBlockResize(virDomainPtr dom,
/* qcow2 and qed must be sized on 512 byte blocks/sectors, /* qcow2 and qed must be sized on 512 byte blocks/sectors,
* so adjust size if necessary to round up. * so adjust size if necessary to round up.
*/ */
if (disk->src.format == VIR_STORAGE_FILE_QCOW2 || if (disk->src->format == VIR_STORAGE_FILE_QCOW2 ||
disk->src.format == VIR_STORAGE_FILE_QED) disk->src->format == VIR_STORAGE_FILE_QED)
size = VIR_ROUND_UP(size, 512); size = VIR_ROUND_UP(size, 512);
if (virAsprintf(&device, "%s%s", QEMU_DRIVE_HOST_PREFIX, if (virAsprintf(&device, "%s%s", QEMU_DRIVE_HOST_PREFIX,
@ -12070,25 +12070,27 @@ qemuDomainPrepareDiskChainElement(virQEMUDriverPtr driver,
int ret = -1; int ret = -1;
/* XXX Labelling of non-local files isn't currently supported */ /* XXX Labelling of non-local files isn't currently supported */
if (virStorageSourceGetActualType(&disk->src) == VIR_STORAGE_TYPE_NETWORK) if (virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_NETWORK)
return 0; return 0;
cfg = virQEMUDriverGetConfig(driver); cfg = virQEMUDriverGetConfig(driver);
/* XXX This would be easier when disk->src will be a pointer */ /* XXX Need to refactor the security manager and lock daemon to
memcpy(&origdisk, &disk->src, sizeof(origdisk)); * operate directly on a virStorageSourcePtr plus tidbits rather
memcpy(&disk->src, elem, sizeof(*elem)); * than a full virDomainDiskDef. */
memcpy(&origdisk, disk->src, sizeof(origdisk));
memcpy(disk->src, elem, sizeof(*elem));
disk->readonly = mode == VIR_DISK_CHAIN_READ_ONLY; disk->readonly = mode == VIR_DISK_CHAIN_READ_ONLY;
if (mode == VIR_DISK_CHAIN_NO_ACCESS) { if (mode == VIR_DISK_CHAIN_NO_ACCESS) {
if (virSecurityManagerRestoreImageLabel(driver->securityManager, if (virSecurityManagerRestoreImageLabel(driver->securityManager,
vm->def, disk) < 0) vm->def, disk) < 0)
VIR_WARN("Unable to restore security label on %s", disk->src.path); VIR_WARN("Unable to restore security label on %s", disk->src->path);
if (qemuTeardownDiskCgroup(vm, disk) < 0) if (qemuTeardownDiskCgroup(vm, disk) < 0)
VIR_WARN("Failed to teardown cgroup for disk path %s", VIR_WARN("Failed to teardown cgroup for disk path %s",
disk->src.path); disk->src->path);
if (virDomainLockDiskDetach(driver->lockManager, vm, disk) < 0) if (virDomainLockDiskDetach(driver->lockManager, vm, disk) < 0)
VIR_WARN("Unable to release lock on %s", disk->src.path); VIR_WARN("Unable to release lock on %s", disk->src->path);
} else if (virDomainLockDiskAttach(driver->lockManager, cfg->uri, } else if (virDomainLockDiskAttach(driver->lockManager, cfg->uri,
vm, disk) < 0 || vm, disk) < 0 ||
qemuSetupDiskCgroup(vm, disk) < 0 || qemuSetupDiskCgroup(vm, disk) < 0 ||
@ -12100,7 +12102,7 @@ qemuDomainPrepareDiskChainElement(virQEMUDriverPtr driver,
ret = 0; ret = 0;
cleanup: cleanup:
memcpy(&disk->src, &origdisk, sizeof(origdisk)); memcpy(disk->src, &origdisk, sizeof(origdisk));
disk->readonly = origreadonly; disk->readonly = origreadonly;
virObjectUnref(cfg); virObjectUnref(cfg);
return ret; return ret;
@ -12261,22 +12263,22 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDriverPtr driver,
NULL))) NULL)))
goto cleanup; goto cleanup;
if (defdisk->src.format > 0) { if (defdisk->src->format > 0) {
/* adds cmd line arg: backing_file=/path/to/backing/file,backing_fmd=format */ /* adds cmd line arg: backing_file=/path/to/backing/file,backing_fmd=format */
virCommandAddArgFormat(cmd, "backing_file=%s,backing_fmt=%s", virCommandAddArgFormat(cmd, "backing_file=%s,backing_fmt=%s",
defdisk->src.path, defdisk->src->path,
virStorageFileFormatTypeToString(defdisk->src.format)); virStorageFileFormatTypeToString(defdisk->src->format));
} else { } else {
if (!cfg->allowDiskFormatProbing) { if (!cfg->allowDiskFormatProbing) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown image format of '%s' and " _("unknown image format of '%s' and "
"format probing is disabled"), "format probing is disabled"),
defdisk->src.path); defdisk->src->path);
goto cleanup; goto cleanup;
} }
/* adds cmd line arg: backing_file=/path/to/backing/file */ /* adds cmd line arg: backing_file=/path/to/backing/file */
virCommandAddArgFormat(cmd, "backing_file=%s", defdisk->src.path); virCommandAddArgFormat(cmd, "backing_file=%s", defdisk->src->path);
} }
/* adds cmd line args: /path/to/target/file */ /* adds cmd line args: /path/to/target/file */
@ -12299,12 +12301,12 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDriverPtr driver,
defdisk = vm->def->disks[snapdisk->index]; defdisk = vm->def->disks[snapdisk->index];
if (snapdisk->snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) { if (snapdisk->snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) {
VIR_FREE(defdisk->src.path); VIR_FREE(defdisk->src->path);
if (VIR_STRDUP(defdisk->src.path, snapdisk->src->path) < 0) { if (VIR_STRDUP(defdisk->src->path, snapdisk->src->path) < 0) {
/* we cannot rollback here in a sane way */ /* we cannot rollback here in a sane way */
goto cleanup; goto cleanup;
} }
defdisk->src.format = snapdisk->src->format; defdisk->src->format = snapdisk->src->format;
} }
} }
@ -12419,7 +12421,7 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr conn,
static int static int
qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk) qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
{ {
int actualType = virStorageSourceGetActualType(&disk->src); int actualType = virStorageSourceGetActualType(disk->src);
switch ((virStorageType) actualType) { switch ((virStorageType) actualType) {
case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_BLOCK:
@ -12427,7 +12429,7 @@ qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
return 0; return 0;
case VIR_STORAGE_TYPE_NETWORK: case VIR_STORAGE_TYPE_NETWORK:
switch ((virStorageNetProtocol) disk->src.protocol) { switch ((virStorageNetProtocol) disk->src->protocol) {
case VIR_STORAGE_NET_PROTOCOL_NONE: case VIR_STORAGE_NET_PROTOCOL_NONE:
case VIR_STORAGE_NET_PROTOCOL_NBD: case VIR_STORAGE_NET_PROTOCOL_NBD:
case VIR_STORAGE_NET_PROTOCOL_RBD: case VIR_STORAGE_NET_PROTOCOL_RBD:
@ -12443,7 +12445,7 @@ qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("external inactive snapshots are not supported on " _("external inactive snapshots are not supported on "
"'network' disks using '%s' protocol"), "'network' disks using '%s' protocol"),
virStorageNetProtocolTypeToString(disk->src.protocol)); virStorageNetProtocolTypeToString(disk->src->protocol));
return -1; return -1;
} }
break; break;
@ -12465,7 +12467,7 @@ qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
static int static int
qemuDomainSnapshotPrepareDiskExternalBackingActive(virDomainDiskDefPtr disk) qemuDomainSnapshotPrepareDiskExternalBackingActive(virDomainDiskDefPtr disk)
{ {
int actualType = virStorageSourceGetActualType(&disk->src); int actualType = virStorageSourceGetActualType(disk->src);
if (actualType == VIR_STORAGE_TYPE_BLOCK && if (actualType == VIR_STORAGE_TYPE_BLOCK &&
disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) { disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) {
@ -12628,7 +12630,7 @@ qemuDomainSnapshotPrepareDiskInternal(virConnectPtr conn,
if (qemuTranslateDiskSourcePool(conn, disk) < 0) if (qemuTranslateDiskSourcePool(conn, disk) < 0)
return -1; return -1;
actualType = virStorageSourceGetActualType(&disk->src); actualType = virStorageSourceGetActualType(disk->src);
switch ((virStorageType) actualType) { switch ((virStorageType) actualType) {
case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_BLOCK:
@ -12636,7 +12638,7 @@ qemuDomainSnapshotPrepareDiskInternal(virConnectPtr conn,
return 0; return 0;
case VIR_STORAGE_TYPE_NETWORK: case VIR_STORAGE_TYPE_NETWORK:
switch ((virStorageNetProtocol) disk->src.protocol) { switch ((virStorageNetProtocol) disk->src->protocol) {
case VIR_STORAGE_NET_PROTOCOL_NONE: case VIR_STORAGE_NET_PROTOCOL_NONE:
case VIR_STORAGE_NET_PROTOCOL_NBD: case VIR_STORAGE_NET_PROTOCOL_NBD:
case VIR_STORAGE_NET_PROTOCOL_RBD: case VIR_STORAGE_NET_PROTOCOL_RBD:
@ -12652,7 +12654,7 @@ qemuDomainSnapshotPrepareDiskInternal(virConnectPtr conn,
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("internal inactive snapshots are not supported on " _("internal inactive snapshots are not supported on "
"'network' disks using '%s' protocol"), "'network' disks using '%s' protocol"),
virStorageNetProtocolTypeToString(disk->src.protocol)); virStorageNetProtocolTypeToString(disk->src->protocol));
return -1; return -1;
} }
break; break;
@ -12714,19 +12716,19 @@ qemuDomainSnapshotPrepare(virConnectPtr conn,
active) < 0) active) < 0)
goto cleanup; goto cleanup;
if (dom_disk->src.type == VIR_STORAGE_TYPE_NETWORK && if (dom_disk->src->type == VIR_STORAGE_TYPE_NETWORK &&
(dom_disk->src.protocol == VIR_STORAGE_NET_PROTOCOL_SHEEPDOG || (dom_disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_SHEEPDOG ||
dom_disk->src.protocol == VIR_STORAGE_NET_PROTOCOL_RBD)) { dom_disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD)) {
break; break;
} }
if (vm->def->disks[i]->src.format > 0 && if (vm->def->disks[i]->src->format > 0 &&
vm->def->disks[i]->src.format != VIR_STORAGE_FILE_QCOW2) { vm->def->disks[i]->src->format != VIR_STORAGE_FILE_QCOW2) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("internal snapshot for disk %s unsupported " _("internal snapshot for disk %s unsupported "
"for storage type %s"), "for storage type %s"),
disk->name, disk->name,
virStorageFileFormatTypeToString( virStorageFileFormatTypeToString(
vm->def->disks[i]->src.format)); vm->def->disks[i]->src->format));
goto cleanup; goto cleanup;
} }
break; break;
@ -12862,7 +12864,7 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
* recompute it. Better would be storing the chain ourselves rather than * recompute it. Better would be storing the chain ourselves rather than
* reprobing, but this requires modifying domain_conf and our XML to fully * reprobing, but this requires modifying domain_conf and our XML to fully
* track the chain across libvirtd restarts. */ * track the chain across libvirtd restarts. */
virStorageSourceClearBackingStore(&disk->src); virStorageSourceClearBackingStore(disk->src);
if (virStorageFileInit(snap->src) < 0) if (virStorageFileInit(snap->src) < 0)
goto cleanup; goto cleanup;
@ -12956,37 +12958,37 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
} }
} }
virDomainAuditDisk(vm, disk->src.path, source, "snapshot", ret >= 0); virDomainAuditDisk(vm, disk->src->path, source, "snapshot", ret >= 0);
if (ret < 0) if (ret < 0)
goto cleanup; goto cleanup;
/* Update vm in place to match changes. */ /* Update vm in place to match changes. */
need_unlink = false; need_unlink = false;
VIR_FREE(disk->src.path); VIR_FREE(disk->src->path);
virStorageNetHostDefFree(disk->src.nhosts, disk->src.hosts); virStorageNetHostDefFree(disk->src->nhosts, disk->src->hosts);
disk->src.path = newsource; disk->src->path = newsource;
disk->src.format = format; disk->src->format = format;
disk->src.type = snap->src->type; disk->src->type = snap->src->type;
disk->src.protocol = snap->src->protocol; disk->src->protocol = snap->src->protocol;
disk->src.nhosts = snap->src->nhosts; disk->src->nhosts = snap->src->nhosts;
disk->src.hosts = newhosts; disk->src->hosts = newhosts;
newsource = NULL; newsource = NULL;
newhosts = NULL; newhosts = NULL;
if (persistDisk) { if (persistDisk) {
VIR_FREE(persistDisk->src.path); VIR_FREE(persistDisk->src->path);
virStorageNetHostDefFree(persistDisk->src.nhosts, virStorageNetHostDefFree(persistDisk->src->nhosts,
persistDisk->src.hosts); persistDisk->src->hosts);
persistDisk->src.path = persistSource; persistDisk->src->path = persistSource;
persistDisk->src.format = format; persistDisk->src->format = format;
persistDisk->src.type = snap->src->type; persistDisk->src->type = snap->src->type;
persistDisk->src.protocol = snap->src->protocol; persistDisk->src->protocol = snap->src->protocol;
persistDisk->src.nhosts = snap->src->nhosts; persistDisk->src->nhosts = snap->src->nhosts;
persistDisk->src.hosts = persistHosts; persistDisk->src->hosts = persistHosts;
persistSource = NULL; persistSource = NULL;
persistHosts = NULL; persistHosts = NULL;
@ -13020,46 +13022,46 @@ qemuDomainSnapshotUndoSingleDiskActive(virQEMUDriverPtr driver,
char *persistSource = NULL; char *persistSource = NULL;
struct stat st; struct stat st;
ignore_value(virStorageFileInit(&disk->src)); ignore_value(virStorageFileInit(disk->src));
if (VIR_STRDUP(source, origdisk->src.path) < 0 || if (VIR_STRDUP(source, origdisk->src->path) < 0 ||
(persistDisk && VIR_STRDUP(persistSource, source) < 0)) (persistDisk && VIR_STRDUP(persistSource, source) < 0))
goto cleanup; goto cleanup;
qemuDomainPrepareDiskChainElement(driver, vm, disk, &disk->src, qemuDomainPrepareDiskChainElement(driver, vm, disk, disk->src,
VIR_DISK_CHAIN_NO_ACCESS); VIR_DISK_CHAIN_NO_ACCESS);
if (need_unlink && if (need_unlink &&
virStorageFileStat(&disk->src, &st) == 0 && S_ISREG(st.st_mode) && virStorageFileStat(disk->src, &st) == 0 && S_ISREG(st.st_mode) &&
virStorageFileUnlink(&disk->src) < 0) virStorageFileUnlink(disk->src) < 0)
VIR_WARN("Unable to remove just-created %s", disk->src.path); VIR_WARN("Unable to remove just-created %s", disk->src->path);
/* Update vm in place to match changes. */ /* Update vm in place to match changes. */
VIR_FREE(disk->src.path); VIR_FREE(disk->src->path);
disk->src.path = source; disk->src->path = source;
source = NULL; source = NULL;
disk->src.format = origdisk->src.format; disk->src->format = origdisk->src->format;
disk->src.type = origdisk->src.type; disk->src->type = origdisk->src->type;
disk->src.protocol = origdisk->src.protocol; disk->src->protocol = origdisk->src->protocol;
virStorageNetHostDefFree(disk->src.nhosts, disk->src.hosts); virStorageNetHostDefFree(disk->src->nhosts, disk->src->hosts);
disk->src.nhosts = origdisk->src.nhosts; disk->src->nhosts = origdisk->src->nhosts;
disk->src.hosts = virStorageNetHostDefCopy(origdisk->src.nhosts, disk->src->hosts = virStorageNetHostDefCopy(origdisk->src->nhosts,
origdisk->src.hosts); origdisk->src->hosts);
if (persistDisk) { if (persistDisk) {
VIR_FREE(persistDisk->src.path); VIR_FREE(persistDisk->src->path);
persistDisk->src.path = persistSource; persistDisk->src->path = persistSource;
persistSource = NULL; persistSource = NULL;
persistDisk->src.format = origdisk->src.format; persistDisk->src->format = origdisk->src->format;
persistDisk->src.type = origdisk->src.type; persistDisk->src->type = origdisk->src->type;
persistDisk->src.protocol = origdisk->src.protocol; persistDisk->src->protocol = origdisk->src->protocol;
virStorageNetHostDefFree(persistDisk->src.nhosts, virStorageNetHostDefFree(persistDisk->src->nhosts,
persistDisk->src.hosts); persistDisk->src->hosts);
persistDisk->src.nhosts = origdisk->src.nhosts; persistDisk->src->nhosts = origdisk->src->nhosts;
persistDisk->src.hosts = virStorageNetHostDefCopy(origdisk->src.nhosts, persistDisk->src->hosts = virStorageNetHostDefCopy(origdisk->src->nhosts,
origdisk->src.hosts); origdisk->src->hosts);
} }
cleanup: cleanup:
virStorageFileDeinit(&disk->src); virStorageFileDeinit(disk->src);
VIR_FREE(source); VIR_FREE(source);
VIR_FREE(persistSource); VIR_FREE(persistSource);
} }
@ -14923,16 +14925,16 @@ qemuDomainBlockPivot(virConnectPtr conn,
* label the entire chain. This action is safe even if the * label the entire chain. This action is safe even if the
* backing chain has already been labeled; but only necessary when * backing chain has already been labeled; but only necessary when
* we know for sure that there is a backing chain. */ * we know for sure that there is a backing chain. */
oldsrc = disk->src.path; oldsrc = disk->src->path;
oldformat = disk->src.format; oldformat = disk->src->format;
oldchain = disk->src.backingStore; oldchain = disk->src->backingStore;
disk->src.path = disk->mirror; disk->src->path = disk->mirror;
disk->src.format = disk->mirrorFormat; disk->src->format = disk->mirrorFormat;
disk->src.backingStore = NULL; disk->src->backingStore = NULL;
if (qemuDomainDetermineDiskChain(driver, vm, disk, false) < 0) { if (qemuDomainDetermineDiskChain(driver, vm, disk, false) < 0) {
disk->src.path = oldsrc; disk->src->path = oldsrc;
disk->src.format = oldformat; disk->src->format = oldformat;
disk->src.backingStore = oldchain; disk->src->backingStore = oldchain;
goto cleanup; goto cleanup;
} }
if (disk->mirrorFormat && disk->mirrorFormat != VIR_STORAGE_FILE_RAW && if (disk->mirrorFormat && disk->mirrorFormat != VIR_STORAGE_FILE_RAW &&
@ -14941,9 +14943,9 @@ qemuDomainBlockPivot(virConnectPtr conn,
qemuSetupDiskCgroup(vm, disk) < 0 || qemuSetupDiskCgroup(vm, disk) < 0 ||
virSecurityManagerSetImageLabel(driver->securityManager, vm->def, virSecurityManagerSetImageLabel(driver->securityManager, vm->def,
disk) < 0)) { disk) < 0)) {
disk->src.path = oldsrc; disk->src->path = oldsrc;
disk->src.format = oldformat; disk->src->format = oldformat;
disk->src.backingStore = oldchain; disk->src->backingStore = oldchain;
goto cleanup; goto cleanup;
} }
@ -14972,10 +14974,10 @@ qemuDomainBlockPivot(virConnectPtr conn,
* 'query-block', to see what state we really got left in * 'query-block', to see what state we really got left in
* before killing the mirroring job? And just as on the * before killing the mirroring job? And just as on the
* success case, there's security labeling to worry about. */ * success case, there's security labeling to worry about. */
disk->src.path = oldsrc; disk->src->path = oldsrc;
disk->src.format = oldformat; disk->src->format = oldformat;
virStorageSourceFree(disk->src.backingStore); virStorageSourceFree(disk->src->backingStore);
disk->src.backingStore = oldchain; disk->src->backingStore = oldchain;
VIR_FREE(disk->mirror); VIR_FREE(disk->mirror);
} }
disk->mirrorFormat = VIR_STORAGE_FILE_NONE; disk->mirrorFormat = VIR_STORAGE_FILE_NONE;
@ -15081,8 +15083,8 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
if (base && if (base &&
(virStorageFileParseChainIndex(disk->dst, base, &baseIndex) < 0 || (virStorageFileParseChainIndex(disk->dst, base, &baseIndex) < 0 ||
!(baseSource = virStorageFileChainLookup(&disk->src, !(baseSource = virStorageFileChainLookup(disk->src,
disk->src.backingStore, disk->src->backingStore,
base, baseIndex, NULL)))) base, baseIndex, NULL))))
goto endjob; goto endjob;
@ -15119,7 +15121,7 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
if (!async) { if (!async) {
int type = VIR_DOMAIN_BLOCK_JOB_TYPE_PULL; int type = VIR_DOMAIN_BLOCK_JOB_TYPE_PULL;
int status = VIR_DOMAIN_BLOCK_JOB_CANCELED; int status = VIR_DOMAIN_BLOCK_JOB_CANCELED;
event = virDomainEventBlockJobNewFromObj(vm, disk->src.path, type, event = virDomainEventBlockJobNewFromObj(vm, disk->src->path, type,
status); status);
} else if (!(flags & VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC)) { } else if (!(flags & VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC)) {
while (1) { while (1) {
@ -15292,7 +15294,7 @@ qemuDomainBlockCopy(virDomainObjPtr vm,
if ((flags & VIR_DOMAIN_BLOCK_REBASE_SHALLOW) && if ((flags & VIR_DOMAIN_BLOCK_REBASE_SHALLOW) &&
STREQ_NULLABLE(format, "raw") && STREQ_NULLABLE(format, "raw") &&
disk->src.backingStore->path) { disk->src->backingStore->path) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("disk '%s' has backing file, so raw shallow copy " _("disk '%s' has backing file, so raw shallow copy "
"is not possible"), "is not possible"),
@ -15328,7 +15330,7 @@ qemuDomainBlockCopy(virDomainObjPtr vm,
goto endjob; goto endjob;
VIR_FORCE_CLOSE(fd); VIR_FORCE_CLOSE(fd);
if (!format) if (!format)
disk->mirrorFormat = disk->src.format; disk->mirrorFormat = disk->src->format;
} else if (format) { } else if (format) {
disk->mirrorFormat = virStorageFileFormatTypeFromString(format); disk->mirrorFormat = virStorageFileFormatTypeFromString(format);
if (disk->mirrorFormat <= 0) { if (disk->mirrorFormat <= 0) {
@ -15492,7 +15494,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
goto endjob; goto endjob;
disk = vm->def->disks[idx]; disk = vm->def->disks[idx];
if (!disk->src.path) { if (!disk->src->path) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("disk %s has no source file to be committed"), _("disk %s has no source file to be committed"),
disk->dst); disk->dst);
@ -15502,10 +15504,10 @@ qemuDomainBlockCommit(virDomainPtr dom,
goto endjob; goto endjob;
if (!top) if (!top)
topSource = &disk->src; topSource = disk->src;
else if (virStorageFileParseChainIndex(disk->dst, top, &topIndex) < 0 || else if (virStorageFileParseChainIndex(disk->dst, top, &topIndex) < 0 ||
!(topSource = virStorageFileChainLookup(&disk->src, !(topSource = virStorageFileChainLookup(disk->src,
disk->src.backingStore, disk->src->backingStore,
top, topIndex, top, topIndex,
&top_parent))) &top_parent)))
goto endjob; goto endjob;
@ -15513,7 +15515,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
/* FIXME: qemu 2.0 supports active commit, but as a two-stage /* FIXME: qemu 2.0 supports active commit, but as a two-stage
* process; qemu 2.1 is further improving active commit. We need * process; qemu 2.1 is further improving active commit. We need
* to start supporting it in libvirt. */ * to start supporting it in libvirt. */
if (topSource == &disk->src) { if (topSource == disk->src) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("committing the active layer not supported yet")); _("committing the active layer not supported yet"));
goto endjob; goto endjob;
@ -15529,7 +15531,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
if (!base && (flags & VIR_DOMAIN_BLOCK_COMMIT_SHALLOW)) if (!base && (flags & VIR_DOMAIN_BLOCK_COMMIT_SHALLOW))
baseSource = topSource->backingStore; baseSource = topSource->backingStore;
else if (virStorageFileParseChainIndex(disk->dst, base, &baseIndex) < 0 || else if (virStorageFileParseChainIndex(disk->dst, base, &baseIndex) < 0 ||
!(baseSource = virStorageFileChainLookup(&disk->src, topSource, !(baseSource = virStorageFileChainLookup(disk->src, topSource,
base, baseIndex, NULL))) base, baseIndex, NULL)))
goto endjob; goto endjob;
@ -15552,7 +15554,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
clean_access = true; clean_access = true;
if (qemuDomainPrepareDiskChainElement(driver, vm, disk, baseSource, if (qemuDomainPrepareDiskChainElement(driver, vm, disk, baseSource,
VIR_DISK_CHAIN_READ_WRITE) < 0 || VIR_DISK_CHAIN_READ_WRITE) < 0 ||
(top_parent && top_parent != disk->src.path && (top_parent && top_parent != disk->src->path &&
qemuDomainPrepareDiskChainElementPath(driver, vm, disk, qemuDomainPrepareDiskChainElementPath(driver, vm, disk,
top_parent, top_parent,
VIR_DISK_CHAIN_READ_WRITE) < 0)) VIR_DISK_CHAIN_READ_WRITE) < 0))
@ -15575,7 +15577,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
/* Revert access to read-only, if possible. */ /* Revert access to read-only, if possible. */
qemuDomainPrepareDiskChainElement(driver, vm, disk, baseSource, qemuDomainPrepareDiskChainElement(driver, vm, disk, baseSource,
VIR_DISK_CHAIN_READ_ONLY); VIR_DISK_CHAIN_READ_ONLY);
if (top_parent && top_parent != disk->src.path) if (top_parent && top_parent != disk->src->path)
qemuDomainPrepareDiskChainElementPath(driver, vm, disk, qemuDomainPrepareDiskChainElementPath(driver, vm, disk,
top_parent, top_parent,
VIR_DISK_CHAIN_READ_ONLY); VIR_DISK_CHAIN_READ_ONLY);

View File

@ -1542,8 +1542,8 @@ qemuMigrationIsSafe(virDomainDefPtr def)
return false; return false;
else if (rc == 1) else if (rc == 1)
continue; continue;
} else if (disk->src.type == VIR_STORAGE_TYPE_NETWORK && } else if (disk->src->type == VIR_STORAGE_TYPE_NETWORK &&
disk->src.protocol == VIR_STORAGE_NET_PROTOCOL_RBD) { disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD) {
continue; continue;
} }

View File

@ -421,13 +421,13 @@ qemuProcessGetVolumeQcowPassphrase(virConnectPtr conn,
int ret = -1; int ret = -1;
virStorageEncryptionPtr enc; virStorageEncryptionPtr enc;
if (!disk->src.encryption) { if (!disk->src->encryption) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("disk %s does not have any encryption information"), _("disk %s does not have any encryption information"),
disk->src.path); disk->src->path);
return -1; return -1;
} }
enc = disk->src.encryption; enc = disk->src->encryption;
if (!conn) { if (!conn) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
@ -2234,7 +2234,7 @@ qemuProcessInitPasswords(virConnectPtr conn,
size_t secretLen; size_t secretLen;
const char *alias; const char *alias;
if (!vm->def->disks[i]->src.encryption || if (!vm->def->disks[i]->src->encryption ||
!virDomainDiskGetSource(vm->def->disks[i])) !virDomainDiskGetSource(vm->def->disks[i]))
continue; continue;

View File

@ -1148,7 +1148,7 @@ virSecuritySELinuxRestoreSecurityImageLabelInt(virSecurityManagerPtr mgr,
* be tracked in domain XML, at which point labelskip should be a * be tracked in domain XML, at which point labelskip should be a
* per-file attribute instead of a disk attribute. */ * per-file attribute instead of a disk attribute. */
if (disk_seclabel && disk_seclabel->labelskip && if (disk_seclabel && disk_seclabel->labelskip &&
!disk->src.backingStore) !disk->src->backingStore)
return 0; return 0;
/* Don't restore labels on readoly/shared disks, because /* Don't restore labels on readoly/shared disks, because
@ -1236,7 +1236,7 @@ virSecuritySELinuxSetSecurityFileLabel(virDomainDiskDefPtr disk,
if (!disk_seclabel) if (!disk_seclabel)
return -1; return -1;
disk_seclabel->labelskip = true; disk_seclabel->labelskip = true;
if (VIR_APPEND_ELEMENT(disk->src.seclabels, disk->src.nseclabels, if (VIR_APPEND_ELEMENT(disk->src->seclabels, disk->src->nseclabels,
disk_seclabel) < 0) { disk_seclabel) < 0) {
virSecurityDeviceLabelDefFree(disk_seclabel); virSecurityDeviceLabelDefFree(disk_seclabel);
return -1; return -1;

View File

@ -951,9 +951,9 @@ get_files(vahControl * ctl)
/* XXX - if we knew the qemu user:group here we could send it in /* XXX - if we knew the qemu user:group here we could send it in
* so that the open could be re-tried as that user:group. * so that the open could be re-tried as that user:group.
*/ */
if (!disk->src.backingStore) { if (!disk->src->backingStore) {
bool probe = ctl->allowDiskFormatProbing; bool probe = ctl->allowDiskFormatProbing;
virStorageFileGetMetadata(&disk->src, -1, -1, probe); virStorageFileGetMetadata(disk->src, -1, -1, probe);
} }
/* XXX passing ignoreOpenFailure = true to get back to the behavior /* XXX passing ignoreOpenFailure = true to get back to the behavior

View File

@ -169,11 +169,11 @@ testSELinuxLoadDef(const char *testname)
goto cleanup; goto cleanup;
for (i = 0; i < def->ndisks; i++) { for (i = 0; i < def->ndisks; i++) {
if (def->disks[i]->src.type != VIR_STORAGE_TYPE_FILE && if (def->disks[i]->src->type != VIR_STORAGE_TYPE_FILE &&
def->disks[i]->src.type != VIR_STORAGE_TYPE_BLOCK) def->disks[i]->src->type != VIR_STORAGE_TYPE_BLOCK)
continue; continue;
if (testSELinuxMungePath(&def->disks[i]->src.path) < 0) if (testSELinuxMungePath(&def->disks[i]->src->path) < 0)
goto cleanup; goto cleanup;
} }