提交 c123ef71 编写于 作者: E Eric Blake

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: NEric Blake <eblake@redhat.com>
上级 bc3f5f19
......@@ -1186,7 +1186,10 @@ virDomainDiskDefNew(void)
{
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;
}
......@@ -1197,7 +1200,7 @@ virDomainDiskDefFree(virDomainDiskDefPtr def)
if (!def)
return;
virStorageSourceClear(&def->src);
virStorageSourceFree(def->src);
VIR_FREE(def->serial);
VIR_FREE(def->dst);
VIR_FREE(def->mirror);
......@@ -1213,21 +1216,21 @@ virDomainDiskDefFree(virDomainDiskDefPtr def)
int
virDomainDiskGetType(virDomainDiskDefPtr def)
{
return def->src.type;
return def->src->type;
}
void
virDomainDiskSetType(virDomainDiskDefPtr def, int type)
{
def->src.type = type;
def->src->type = type;
}
const char *
virDomainDiskGetSource(virDomainDiskDefPtr def)
{
return def->src.path;
return def->src->path;
}
......@@ -1235,11 +1238,11 @@ int
virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
{
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)
def->src.path = tmp;
def->src->path = tmp;
else
VIR_FREE(tmp);
return ret;
......@@ -1249,7 +1252,7 @@ virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
const char *
virDomainDiskGetDriver(virDomainDiskDefPtr def)
{
return def->src.driverName;
return def->src->driverName;
}
......@@ -1257,11 +1260,11 @@ int
virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
{
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)
def->src.driverName = tmp;
def->src->driverName = tmp;
else
VIR_FREE(tmp);
return ret;
......@@ -1271,14 +1274,14 @@ virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
int
virDomainDiskGetFormat(virDomainDiskDefPtr def)
{
return def->src.format;
return def->src->format;
}
void
virDomainDiskSetFormat(virDomainDiskDefPtr def, int format)
{
def->src.format = format;
def->src->format = format;
}
......@@ -5257,13 +5260,13 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
type = virXMLPropString(node, "type");
if (type) {
if ((def->src.type = virStorageTypeFromString(type)) <= 0) {
if ((def->src->type = virStorageTypeFromString(type)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk type '%s'"), type);
goto error;
}
} else {
def->src.type = VIR_STORAGE_TYPE_FILE;
def->src->type = VIR_STORAGE_TYPE_FILE;
}
snapshot = virXMLPropString(node, "snapshot");
......@@ -5274,18 +5277,18 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
cur = node->children;
while (cur != NULL) {
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")) {
sourceNode = cur;
if (virDomainDiskSourceParse(cur, &def->src) < 0)
if (virDomainDiskSourceParse(cur, def->src) < 0)
goto error;
source = def->src.path;
source = def->src->path;
if (def->src.type == VIR_STORAGE_TYPE_NETWORK) {
if (def->src.protocol == VIR_STORAGE_NET_PROTOCOL_ISCSI)
if (def->src->type == VIR_STORAGE_TYPE_NETWORK) {
if (def->src->protocol == VIR_STORAGE_NET_PROTOCOL_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;
}
......@@ -5394,7 +5397,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error;
}
def->src.auth.secretType = VIR_STORAGE_SECRET_TYPE_NONE;
def->src->auth.secretType = VIR_STORAGE_SECRET_TYPE_NONE;
child = cur->children;
while (child != NULL) {
if (child->type == XML_ELEMENT_NODE &&
......@@ -5431,17 +5434,17 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
}
if (authUUID != NULL) {
def->src.auth.secretType = VIR_STORAGE_SECRET_TYPE_UUID;
def->src->auth.secretType = VIR_STORAGE_SECRET_TYPE_UUID;
if (virUUIDParse(authUUID,
def->src.auth.secret.uuid) < 0) {
def->src->auth.secret.uuid) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("malformed uuid %s"),
authUUID);
goto error;
}
} else if (authUsage != NULL) {
def->src.auth.secretType = VIR_STORAGE_SECRET_TYPE_USAGE;
def->src.auth.secret.usage = authUsage;
def->src->auth.secretType = VIR_STORAGE_SECRET_TYPE_USAGE;
def->src->auth.secret.usage = authUsage;
authUsage = NULL;
}
}
......@@ -5586,7 +5589,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
/* Only CDROM and Floppy devices are allowed missing source path
* to indicate no media present. LUN is for raw access CD-ROMs
* 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_LUN &&
def->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
......@@ -5599,8 +5602,8 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
if (sourceNode) {
xmlNodePtr saved_node = ctxt->node;
ctxt->node = sourceNode;
if (virSecurityDeviceLabelDefParseXML(&def->src.seclabels,
&def->src.nseclabels,
if (virSecurityDeviceLabelDefParseXML(&def->src->seclabels,
&def->src->nseclabels,
vmSeclabels,
nvmSeclabels,
ctxt,
......@@ -5610,10 +5613,10 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
}
if (target == NULL) {
if (def->src.srcpool) {
if (def->src->srcpool) {
char *tmp;
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;
virReportError(VIR_ERR_NO_TARGET, "%s", tmp);
......@@ -5878,7 +5881,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error;
}
if (def->src.type == VIR_STORAGE_TYPE_NETWORK) {
if (def->src->type == VIR_STORAGE_TYPE_NETWORK) {
virReportError(VIR_ERR_XML_ERROR,
_("Setting disk %s is not allowed for "
"disk of network type"),
......@@ -5899,14 +5902,14 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
def->dst = target;
target = NULL;
def->src.auth.username = authUsername;
def->src->auth.username = authUsername;
authUsername = NULL;
def->src.driverName = driverName;
def->src->driverName = driverName;
driverName = NULL;
def->mirror = mirror;
mirror = NULL;
def->mirroring = mirroring;
def->src.encryption = encryption;
def->src->encryption = encryption;
encryption = NULL;
def->serial = serial;
serial = NULL;
......@@ -5918,8 +5921,8 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
product = NULL;
if (driverType) {
def->src.format = virStorageFileFormatTypeFromString(driverType);
if (def->src.format <= 0) {
def->src->format = virStorageFileFormatTypeFromString(driverType);
if (def->src->format <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown driver format value '%s'"),
driverType);
......@@ -5941,7 +5944,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
&& virDomainDiskDefAssignAddress(xmlopt, def) < 0)
goto error;
if (virDomainDiskBackingStoreParse(ctxt, &def->src) < 0)
if (virDomainDiskBackingStoreParse(ctxt, def->src) < 0)
goto error;
cleanup:
......@@ -15021,7 +15024,7 @@ virDomainDiskDefFormat(virBufferPtr buf,
virDomainDiskDefPtr def,
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 *bus = virDomainDiskBusTypeToString(def->bus);
const char *cachemode = virDomainDiskCacheTypeToString(def->cachemode);
......@@ -15036,9 +15039,9 @@ virDomainDiskDefFormat(virBufferPtr buf,
char uuidstr[VIR_UUID_STRING_BUFLEN];
if (!type || !def->src.type) {
if (!type || !def->src->type) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected disk type %d"), def->src.type);
_("unexpected disk type %d"), def->src->type);
return -1;
}
if (!device) {
......@@ -15088,16 +15091,16 @@ virDomainDiskDefFormat(virBufferPtr buf,
virBufferAddLit(buf, ">\n");
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->ioeventfd || def->event_idx || def->copy_on_read ||
def->discard) {
virBufferAddLit(buf, "<driver");
if (def->src.driverName)
virBufferAsprintf(buf, " name='%s'", def->src.driverName);
if (def->src.format > 0)
if (def->src->driverName)
virBufferAsprintf(buf, " name='%s'", def->src->driverName);
if (def->src->format > 0)
virBufferAsprintf(buf, " type='%s'",
virStorageFileFormatTypeToString(def->src.format));
virStorageFileFormatTypeToString(def->src->format));
if (def->cachemode)
virBufferAsprintf(buf, " cache='%s'", cachemode);
if (def->error_policy)
......@@ -15117,37 +15120,37 @@ virDomainDiskDefFormat(virBufferPtr buf,
virBufferAddLit(buf, "/>\n");
}
if (def->src.auth.username) {
if (def->src->auth.username) {
virBufferEscapeString(buf, "<auth username='%s'>\n",
def->src.auth.username);
def->src->auth.username);
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'");
} 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'");
}
if (def->src.auth.secretType == VIR_STORAGE_SECRET_TYPE_UUID) {
virUUIDFormat(def->src.auth.secret.uuid, uuidstr);
if (def->src->auth.secretType == VIR_STORAGE_SECRET_TYPE_UUID) {
virUUIDFormat(def->src->auth.secret.uuid, 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",
def->src.auth.secret.usage);
def->src->auth.secret.usage);
}
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</auth>\n");
}
if (virDomainDiskSourceFormat(buf, &def->src, def->startupPolicy,
if (virDomainDiskSourceFormat(buf, def->src, def->startupPolicy,
flags) < 0)
return -1;
/* Don't format backingStore to inactive XMLs until the code for
* persistent storage of backing chains is ready. */
if (!(flags & VIR_DOMAIN_XML_INACTIVE) &&
virDomainDiskBackingStoreFormat(buf, def->src.backingStore,
def->src.backingStoreRaw, 1) < 0)
virDomainDiskBackingStoreFormat(buf, def->src->backingStore,
def->src->backingStoreRaw, 1) < 0)
return -1;
virDomainDiskGeometryDefFormat(buf, def);
......@@ -15233,8 +15236,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
virBufferEscapeString(buf, "<wwn>%s</wwn>\n", def->wwn);
virBufferEscapeString(buf, "<vendor>%s</vendor>\n", def->vendor);
virBufferEscapeString(buf, "<product>%s</product>\n", def->product);
if (def->src.encryption &&
virStorageEncryptionFormat(buf, def->src.encryption) < 0)
if (def->src->encryption &&
virStorageEncryptionFormat(buf, def->src->encryption) < 0)
return -1;
if (virDomainDeviceInfoFormat(buf, &def->info,
flags | VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT) < 0)
......@@ -18682,7 +18685,7 @@ virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
char *brokenRaw = NULL;
if (!ignoreOpenFailure) {
if (virStorageFileChainGetBroken(&disk->src, &brokenRaw) < 0)
if (virStorageFileChainGetBroken(disk->src, &brokenRaw) < 0)
goto cleanup;
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);
/* execute the callback only for local storage */
if (actualType != VIR_STORAGE_TYPE_NETWORK &&
......@@ -19450,9 +19453,9 @@ virDomainDiskDefGetSecurityLabelDef(virDomainDiskDefPtr def, const char *model)
if (def == NULL)
return NULL;
for (i = 0; i < def->src.nseclabels; i++) {
if (STREQ_NULLABLE(def->src.seclabels[i]->model, model))
return def->src.seclabels[i];
for (i = 0; i < def->src->nseclabels; i++) {
if (STREQ_NULLABLE(def->src->seclabels[i]->model, model))
return def->src->seclabels[i];
}
return NULL;
}
......@@ -19543,14 +19546,14 @@ virDomainDiskSourceIsBlockType(virDomainDiskDefPtr def)
* If it's a block type source pool, then it's possible
*/
if (virDomainDiskGetType(def) == VIR_STORAGE_TYPE_VOLUME &&
def->src.srcpool &&
def->src.srcpool->voltype == VIR_STORAGE_VOL_BLOCK) {
def->src->srcpool &&
def->src->srcpool->voltype == VIR_STORAGE_VOL_BLOCK) {
/* We don't think the volume accessed by remote URI is
* block type source, since we can't/shouldn't manage it
* (e.g. set sgio=filtered|unfiltered for it) in libvirt.
*/
if (def->src.srcpool->pooltype == VIR_STORAGE_POOL_ISCSI &&
def->src.srcpool->mode == VIR_STORAGE_SOURCE_POOL_MODE_DIRECT)
if (def->src->srcpool->pooltype == VIR_STORAGE_POOL_ISCSI &&
def->src->srcpool->mode == VIR_STORAGE_SOURCE_POOL_MODE_DIRECT)
return false;
return true;
......
......@@ -598,7 +598,7 @@ typedef virDomainBlockIoTuneInfo *virDomainBlockIoTuneInfoPtr;
/* Stores the virtual disk configuration */
struct _virDomainDiskDef {
virStorageSource src;
virStorageSourcePtr src; /* non-NULL. XXX Allow NULL for empty cdrom? */
int device; /* enum virDomainDiskDevice */
int bus; /* enum virDomainDiskBus */
......
......@@ -1669,7 +1669,7 @@ static int virLXCControllerSetupDisk(virLXCControllerPtr ctrl,
int ret = -1;
struct stat sb;
mode_t mode;
char *tmpsrc = def->src.path;
char *tmpsrc = def->src->path;
if (virDomainDiskGetType(def) != VIR_STORAGE_TYPE_BLOCK) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
......@@ -1686,7 +1686,7 @@ static int virLXCControllerSetupDisk(virLXCControllerPtr ctrl,
LXC_STATE_DIR, ctrl->def->name, def->dst) < 0)
goto cleanup;
if (stat(def->src.path, &sb) < 0) {
if (stat(def->src->path, &sb) < 0) {
virReportSystemError(errno,
_("Unable to access %s"), tmpsrc);
goto cleanup;
......@@ -1726,14 +1726,14 @@ static int virLXCControllerSetupDisk(virLXCControllerPtr ctrl,
/* Labelling normally operates on src, but we need
* 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)
goto cleanup;
ret = 0;
cleanup:
def->src.path = tmpsrc;
def->src->path = tmpsrc;
VIR_FREE(dst);
return ret;
}
......
......@@ -3897,14 +3897,14 @@ lxcDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED,
switch (data->def->type) {
case VIR_DOMAIN_DEVICE_DISK: {
virDomainDiskDefPtr def = data->def->data.disk;
char *tmpsrc = def->src.path;
def->src.path = data->file;
char *tmpsrc = def->src->path;
def->src->path = data->file;
if (virSecurityManagerSetImageLabel(data->driver->securityManager,
data->vm->def, def) < 0) {
def->src.path = tmpsrc;
def->src->path = tmpsrc;
goto cleanup;
}
def->src.path = tmpsrc;
def->src->path = tmpsrc;
} break;
case VIR_DOMAIN_DEVICE_HOSTDEV: {
......
此差异已折叠。
......@@ -802,8 +802,8 @@ qemuCheckSharedDevice(virHashTablePtr sharedDevices,
virReportError(VIR_ERR_OPERATION_INVALID,
_("sgio of shared disk 'pool=%s' 'volume=%s' conflicts "
"with other active domains"),
disk->src.srcpool->pool,
disk->src.srcpool->volume);
disk->src->srcpool->pool,
disk->src->srcpool->volume);
} else {
virReportError(VIR_ERR_OPERATION_INVALID,
_("sgio of shared disk '%s' conflicts with other "
......@@ -1163,33 +1163,33 @@ qemuAddISCSIPoolSourceHost(virDomainDiskDefPtr def,
}
/* 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;
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;
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 :
3260) < 0)
goto cleanup;
/* 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;
if (virStringListLength(tokens) != 4) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected iscsi volume name '%s'"),
def->src.srcpool->volume);
def->src->srcpool->volume);
goto cleanup;
}
/* 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,
tokens[3]) < 0)
goto cleanup;
......@@ -1197,10 +1197,10 @@ qemuAddISCSIPoolSourceHost(virDomainDiskDefPtr def,
/* Storage pool have not supported these 2 attributes yet,
* use the defaults.
*/
def->src.hosts[0].transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
def->src.hosts[0].socket = NULL;
def->src->hosts[0].transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
def->src->hosts[0].socket = NULL;
def->src.protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI;
def->src->protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI;
ret = 0;
......@@ -1225,34 +1225,34 @@ qemuTranslateDiskSourcePoolAuth(virDomainDiskDefPtr def,
* into the virDomainDiskDef
*/
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)
goto cleanup;
if (pooldef->source.auth.chap.secret.uuidUsable) {
def->src.auth.secretType = VIR_STORAGE_SECRET_TYPE_UUID;
memcpy(def->src.auth.secret.uuid,
def->src->auth.secretType = VIR_STORAGE_SECRET_TYPE_UUID;
memcpy(def->src->auth.secret.uuid,
pooldef->source.auth.chap.secret.uuid,
VIR_UUID_BUFLEN);
} else {
if (VIR_STRDUP(def->src.auth.secret.usage,
if (VIR_STRDUP(def->src->auth.secret.usage,
pooldef->source.auth.chap.secret.usage) < 0)
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) {
if (VIR_STRDUP(def->src.auth.username,
if (VIR_STRDUP(def->src->auth.username,
pooldef->source.auth.cephx.username) < 0)
goto cleanup;
if (pooldef->source.auth.cephx.secret.uuidUsable) {
def->src.auth.secretType = VIR_STORAGE_SECRET_TYPE_UUID;
memcpy(def->src.auth.secret.uuid,
def->src->auth.secretType = VIR_STORAGE_SECRET_TYPE_UUID;
memcpy(def->src->auth.secret.uuid,
pooldef->source.auth.cephx.secret.uuid,
VIR_UUID_BUFLEN);
} else {
if (VIR_STRDUP(def->src.auth.secret.usage,
if (VIR_STRDUP(def->src->auth.secret.usage,
pooldef->source.auth.cephx.secret.usage) < 0)
goto cleanup;
def->src.auth.secretType = VIR_STORAGE_SECRET_TYPE_USAGE;
def->src->auth.secretType = VIR_STORAGE_SECRET_TYPE_USAGE;
}
}
ret = 0;
......@@ -1274,24 +1274,24 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
int ret = -1;
virErrorPtr savedError = NULL;
if (def->src.type != VIR_STORAGE_TYPE_VOLUME)
if (def->src->type != VIR_STORAGE_TYPE_VOLUME)
return 0;
if (!def->src.srcpool)
if (!def->src->srcpool)
return 0;
if (!(pool = virStoragePoolLookupByName(conn, def->src.srcpool->pool)))
if (!(pool = virStoragePoolLookupByName(conn, def->src->srcpool->pool)))
return -1;
if (virStoragePoolIsActive(pool) != 1) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("storage pool '%s' containing volume '%s' "
"is not active"),
def->src.srcpool->pool, def->src.srcpool->volume);
def->src->srcpool->pool, def->src->srcpool->volume);
goto cleanup;
}
if (!(vol = virStorageVolLookupByName(pool, def->src.srcpool->volume)))
if (!(vol = virStorageVolLookupByName(pool, def->src->srcpool->volume)))
goto cleanup;
if (virStorageVolGetInfo(vol, &info) < 0)
......@@ -1303,19 +1303,19 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
if (!(pooldef = virStoragePoolDefParseString(poolxml)))
goto cleanup;
def->src.srcpool->pooltype = pooldef->type;
def->src.srcpool->voltype = info.type;
def->src->srcpool->pooltype = pooldef->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",
_("disk source mode is only valid when "
"storage pool is of iscsi type"));
goto cleanup;
}
VIR_FREE(def->src.path);
virStorageNetHostDefFree(def->src.nhosts, def->src.hosts);
virStorageSourceAuthClear(&def->src);
VIR_FREE(def->src->path);
virStorageNetHostDefFree(def->src->nhosts, def->src->hosts);
virStorageSourceAuthClear(def->src);
switch ((virStoragePoolType) pooldef->type) {
case VIR_STORAGE_POOL_DIR:
......@@ -1324,7 +1324,7 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
case VIR_STORAGE_POOL_LOGICAL:
case VIR_STORAGE_POOL_DISK:
case VIR_STORAGE_POOL_SCSI:
if (!(def->src.path = virStorageVolGetPath(vol)))
if (!(def->src->path = virStorageVolGetPath(vol)))
goto cleanup;
if (def->startupPolicy && info.type != VIR_STORAGE_VOL_FILE) {
......@@ -1337,15 +1337,15 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
switch (info.type) {
case VIR_STORAGE_VOL_FILE:
def->src.srcpool->actualtype = VIR_STORAGE_TYPE_FILE;
def->src->srcpool->actualtype = VIR_STORAGE_TYPE_FILE;
break;
case VIR_STORAGE_VOL_DIR:
def->src.srcpool->actualtype = VIR_STORAGE_TYPE_DIR;
def->src->srcpool->actualtype = VIR_STORAGE_TYPE_DIR;
break;
case VIR_STORAGE_VOL_BLOCK:
def->src.srcpool->actualtype = VIR_STORAGE_TYPE_BLOCK;
def->src->srcpool->actualtype = VIR_STORAGE_TYPE_BLOCK;
break;
case VIR_STORAGE_VOL_NETWORK:
......@@ -1368,20 +1368,20 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
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_LAST:
def->src.srcpool->mode = VIR_STORAGE_SOURCE_POOL_MODE_HOST;
def->src->srcpool->mode = VIR_STORAGE_SOURCE_POOL_MODE_HOST;
/* fallthrough */
case VIR_STORAGE_SOURCE_POOL_MODE_HOST:
def->src.srcpool->actualtype = VIR_STORAGE_TYPE_BLOCK;
if (!(def->src.path = virStorageVolGetPath(vol)))
def->src->srcpool->actualtype = VIR_STORAGE_TYPE_BLOCK;
if (!(def->src->path = virStorageVolGetPath(vol)))
goto cleanup;
break;
case VIR_STORAGE_SOURCE_POOL_MODE_DIRECT:
def->src.srcpool->actualtype = VIR_STORAGE_TYPE_NETWORK;
def->src.protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI;
def->src->srcpool->actualtype = VIR_STORAGE_TYPE_NETWORK;
def->src->protocol = VIR_STORAGE_NET_PROTOCOL_ISCSI;
if (qemuTranslateDiskSourcePoolAuth(def, pooldef) < 0)
goto cleanup;
......
......@@ -2258,7 +2258,7 @@ qemuDiskChainCheckBroken(virDomainDiskDefPtr disk)
if (!virDomainDiskGetSource(disk))
return 0;
if (virStorageFileChainGetBroken(&disk->src, &brokenFile) < 0)
if (virStorageFileChainGetBroken(disk->src, &brokenFile) < 0)
return -1;
if (brokenFile) {
......@@ -2286,7 +2286,7 @@ qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
virDomainDiskDefPtr disk = vm->def->disks[idx];
const char *path = virDomainDiskGetSource(disk);
virStorageFileFormat format = virDomainDiskGetFormat(disk);
virStorageType type = virStorageSourceGetActualType(&disk->src);
virStorageType type = virStorageSourceGetActualType(disk->src);
if (!path)
continue;
......@@ -2428,22 +2428,22 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
int ret = 0;
uid_t uid;
gid_t gid;
int type = virStorageSourceGetActualType(&disk->src);
int type = virStorageSourceGetActualType(disk->src);
if (type != VIR_STORAGE_TYPE_NETWORK &&
!disk->src.path)
!disk->src->path)
goto cleanup;
if (disk->src.backingStore) {
if (disk->src->backingStore) {
if (force)
virStorageSourceClearBackingStore(&disk->src);
virStorageSourceClearBackingStore(disk->src);
else
goto cleanup;
}
qemuDomainGetImageIds(cfg, vm, disk, &uid, &gid);
if (virStorageFileGetMetadata(&disk->src,
if (virStorageFileGetMetadata(disk->src,
uid, gid,
cfg->allowDiskFormatProbing) < 0)
ret = -1;
......
此差异已折叠。
......@@ -1542,8 +1542,8 @@ qemuMigrationIsSafe(virDomainDefPtr def)
return false;
else if (rc == 1)
continue;
} else if (disk->src.type == VIR_STORAGE_TYPE_NETWORK &&
disk->src.protocol == VIR_STORAGE_NET_PROTOCOL_RBD) {
} else if (disk->src->type == VIR_STORAGE_TYPE_NETWORK &&
disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD) {
continue;
}
......
......@@ -421,13 +421,13 @@ qemuProcessGetVolumeQcowPassphrase(virConnectPtr conn,
int ret = -1;
virStorageEncryptionPtr enc;
if (!disk->src.encryption) {
if (!disk->src->encryption) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("disk %s does not have any encryption information"),
disk->src.path);
disk->src->path);
return -1;
}
enc = disk->src.encryption;
enc = disk->src->encryption;
if (!conn) {
virReportError(VIR_ERR_INTERNAL_ERROR,
......@@ -2234,7 +2234,7 @@ qemuProcessInitPasswords(virConnectPtr conn,
size_t secretLen;
const char *alias;
if (!vm->def->disks[i]->src.encryption ||
if (!vm->def->disks[i]->src->encryption ||
!virDomainDiskGetSource(vm->def->disks[i]))
continue;
......
......@@ -1148,7 +1148,7 @@ virSecuritySELinuxRestoreSecurityImageLabelInt(virSecurityManagerPtr mgr,
* be tracked in domain XML, at which point labelskip should be a
* per-file attribute instead of a disk attribute. */
if (disk_seclabel && disk_seclabel->labelskip &&
!disk->src.backingStore)
!disk->src->backingStore)
return 0;
/* Don't restore labels on readoly/shared disks, because
......@@ -1236,7 +1236,7 @@ virSecuritySELinuxSetSecurityFileLabel(virDomainDiskDefPtr disk,
if (!disk_seclabel)
return -1;
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) {
virSecurityDeviceLabelDefFree(disk_seclabel);
return -1;
......
......@@ -951,9 +951,9 @@ get_files(vahControl * ctl)
/* 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.
*/
if (!disk->src.backingStore) {
if (!disk->src->backingStore) {
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
......
......@@ -169,11 +169,11 @@ testSELinuxLoadDef(const char *testname)
goto cleanup;
for (i = 0; i < def->ndisks; i++) {
if (def->disks[i]->src.type != VIR_STORAGE_TYPE_FILE &&
def->disks[i]->src.type != VIR_STORAGE_TYPE_BLOCK)
if (def->disks[i]->src->type != VIR_STORAGE_TYPE_FILE &&
def->disks[i]->src->type != VIR_STORAGE_TYPE_BLOCK)
continue;
if (testSELinuxMungePath(&def->disks[i]->src.path) < 0)
if (testSELinuxMungePath(&def->disks[i]->src->path) < 0)
goto cleanup;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册