1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-23 02:04:16 +03:00

conf: prepare to track multiple host source files per <disk>

It's finally time to start tracking disk backing chains in
<domain> XML.  The first step is to start refactoring code
so that we have an object more convenient for representing
each host source resource in the context of a single guest
<disk>.  Ultimately, I plan to move the new type into src/util
where it can be reused by virStorageFile, but to make the
transition easier to review, this patch just creates the
new type then fixes everything until it compiles again.

* src/conf/domain_conf.h (_virDomainDiskDef): Split...
(_virDomainDiskSourceDef): ...to new struct.
(virDomainDiskAuthClear): Use new type.
* src/conf/domain_conf.c (virDomainDiskDefFree): Split...
(virDomainDiskSourceDefClear): ...to new function.
(virDomainDiskGetType, virDomainDiskSetType)
(virDomainDiskGetSource, virDomainDiskSetSource)
(virDomainDiskGetDriver, virDomainDiskSetDriver)
(virDomainDiskGetFormat, virDomainDiskSetFormat)
(virDomainDiskAuthClear, virDomainDiskGetActualType)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormat)
(virDomainDiskDefFormat, virDomainDiskDefForeachPath)
(virDomainDiskDefGetSecurityLabelDef)
(virDomainDiskSourceIsBlockType): Adjust all users.
* src/lxc/lxc_controller.c (virLXCControllerSetupDisk):
Likewise.
* src/lxc/lxc_driver.c (lxcDomainAttachDeviceMknodHelper):
Likewise.
* src/qemu/qemu_command.c (qemuAddRBDHost, qemuParseRBDString)
(qemuParseDriveURIString, qemuParseGlusterString)
(qemuParseISCSIString, qemuParseNBDString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuAddISCSIPoolSourceHost, qemuTranslateDiskSourcePool):
Likewise.
* src/qemu/qemu_driver.c (qemuDomainUpdateDeviceConfig)
(qemuDomainPrepareDiskChainElement)
(qemuDomainSnapshotCreateInactiveExternal)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive)
(qemuDomainSnapshotUndoSingleDiskActive)
(qemuDomainBlockPivot, qemuDomainBlockJobImpl)
(qemuDomainBlockCopy, qemuDomainBlockCommit): Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/qemu/qemu_process.c (qemuProcessGetVolumeQcowPassphrase)
(qemuProcessInitPasswords): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxSetSecurityFileLabel): Likewise.
* src/storage/storage_driver.c (virStorageFileInitFromDiskDef):
Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Eric Blake 2014-03-19 11:11:16 -06:00
parent 41a32b0a9b
commit 4f20226664
12 changed files with 441 additions and 408 deletions

View File

@ -1248,25 +1248,19 @@ virDomainDiskSourcePoolDefFree(virDomainDiskSourcePoolDefPtr def)
VIR_FREE(def);
}
void virDomainDiskDefFree(virDomainDiskDefPtr def)
static void
virDomainDiskSourceDefClear(virDomainDiskSourceDefPtr def)
{
size_t i;
if (!def)
return;
VIR_FREE(def->serial);
VIR_FREE(def->src);
VIR_FREE(def->path);
virDomainDiskSourcePoolDefFree(def->srcpool);
VIR_FREE(def->dst);
VIR_FREE(def->driverName);
virStorageFileFreeMetadata(def->backingChain);
VIR_FREE(def->mirror);
VIR_FREE(def->wwn);
VIR_FREE(def->vendor);
VIR_FREE(def->product);
virStorageEncryptionFree(def->encryption);
virDomainDeviceInfoClear(&def->info);
if (def->seclabels) {
for (i = 0; i < def->nseclabels; i++)
@ -1276,13 +1270,31 @@ void virDomainDiskDefFree(virDomainDiskDefPtr def)
virDomainDiskHostDefFree(def->nhosts, def->hosts);
virDomainDiskAuthClear(def);
}
void
virDomainDiskDefFree(virDomainDiskDefPtr def)
{
if (!def)
return;
virDomainDiskSourceDefClear(&def->src);
VIR_FREE(def->serial);
VIR_FREE(def->dst);
virStorageFileFreeMetadata(def->backingChain);
VIR_FREE(def->mirror);
VIR_FREE(def->wwn);
VIR_FREE(def->vendor);
VIR_FREE(def->product);
virDomainDeviceInfoClear(&def->info);
VIR_FREE(def);
}
void
virDomainDiskAuthClear(virDomainDiskDefPtr def)
virDomainDiskAuthClear(virDomainDiskSourceDefPtr def)
{
VIR_FREE(def->auth.username);
@ -1357,31 +1369,31 @@ error:
int
virDomainDiskGetType(virDomainDiskDefPtr def)
{
return def->type;
return def->src.type;
}
void
virDomainDiskSetType(virDomainDiskDefPtr def, int type)
{
def->type = type;
def->src.type = type;
}
int
virDomainDiskGetActualType(virDomainDiskDefPtr def)
{
if (def->type == VIR_DOMAIN_DISK_TYPE_VOLUME && def->srcpool)
return def->srcpool->actualtype;
if (def->src.type == VIR_DOMAIN_DISK_TYPE_VOLUME && def->src.srcpool)
return def->src.srcpool->actualtype;
return def->type;
return def->src.type;
}
const char *
virDomainDiskGetSource(virDomainDiskDefPtr def)
{
return def->src;
return def->src.path;
}
@ -1389,11 +1401,11 @@ int
virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
{
int ret;
char *tmp = def->src;
char *tmp = def->src.path;
ret = VIR_STRDUP(def->src, src);
ret = VIR_STRDUP(def->src.path, src);
if (ret < 0)
def->src = tmp;
def->src.path = tmp;
else
VIR_FREE(tmp);
return ret;
@ -1403,7 +1415,7 @@ virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
const char *
virDomainDiskGetDriver(virDomainDiskDefPtr def)
{
return def->driverName;
return def->src.driverName;
}
@ -1411,11 +1423,11 @@ int
virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
{
int ret;
char *tmp = def->driverName;
char *tmp = def->src.driverName;
ret = VIR_STRDUP(def->driverName, name);
ret = VIR_STRDUP(def->src.driverName, name);
if (ret < 0)
def->driverName = tmp;
def->src.driverName = tmp;
else
VIR_FREE(tmp);
return ret;
@ -1425,14 +1437,14 @@ virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
int
virDomainDiskGetFormat(virDomainDiskDefPtr def)
{
return def->format;
return def->src.format;
}
void
virDomainDiskSetFormat(virDomainDiskDefPtr def, int format)
{
def->format = format;
def->src.format = format;
}
@ -5309,13 +5321,13 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
type = virXMLPropString(node, "type");
if (type) {
if ((def->type = virDomainDiskTypeFromString(type)) < 0) {
if ((def->src.type = virDomainDiskTypeFromString(type)) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk type '%s'"), type);
goto error;
}
} else {
def->type = VIR_DOMAIN_DISK_TYPE_FILE;
def->src.type = VIR_DOMAIN_DISK_TYPE_FILE;
}
snapshot = virXMLPropString(node, "snapshot");
@ -5326,22 +5338,22 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
cur = node->children;
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE) {
if (!source && !def->hosts && !def->srcpool &&
if (!source && !def->src.hosts && !def->src.srcpool &&
xmlStrEqual(cur->name, BAD_CAST "source")) {
sourceNode = cur;
if (virDomainDiskSourceDefParse(cur, def->type,
if (virDomainDiskSourceDefParse(cur, def->src.type,
&source,
&def->protocol,
&def->nhosts,
&def->hosts,
&def->srcpool) < 0)
&def->src.protocol,
&def->src.nhosts,
&def->src.hosts,
&def->src.srcpool) < 0)
goto error;
if (def->type == VIR_DOMAIN_DISK_TYPE_NETWORK) {
if (def->protocol == VIR_DOMAIN_DISK_PROTOCOL_ISCSI)
if (def->src.type == VIR_DOMAIN_DISK_TYPE_NETWORK) {
if (def->src.protocol == VIR_DOMAIN_DISK_PROTOCOL_ISCSI)
expected_secret_usage = VIR_SECRET_USAGE_TYPE_ISCSI;
else if (def->protocol == VIR_DOMAIN_DISK_PROTOCOL_RBD)
else if (def->src.protocol == VIR_DOMAIN_DISK_PROTOCOL_RBD)
expected_secret_usage = VIR_SECRET_USAGE_TYPE_CEPH;
}
@ -5450,7 +5462,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error;
}
def->auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_NONE;
def->src.auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_NONE;
child = cur->children;
while (child != NULL) {
if (child->type == XML_ELEMENT_NODE &&
@ -5487,17 +5499,17 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
}
if (authUUID != NULL) {
def->auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_UUID;
def->src.auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_UUID;
if (virUUIDParse(authUUID,
def->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->auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_USAGE;
def->auth.secret.usage = authUsage;
def->src.auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_USAGE;
def->src.auth.secret.usage = authUsage;
authUsage = NULL;
}
}
@ -5642,7 +5654,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->hosts == NULL && !def->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) {
@ -5655,8 +5667,8 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
if (sourceNode) {
xmlNodePtr saved_node = ctxt->node;
ctxt->node = sourceNode;
if (virSecurityDeviceLabelDefParseXML(&def->seclabels,
&def->nseclabels,
if (virSecurityDeviceLabelDefParseXML(&def->src.seclabels,
&def->src.nseclabels,
vmSeclabels,
nvmSeclabels,
ctxt,
@ -5666,10 +5678,10 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
}
if (target == NULL) {
if (def->srcpool) {
if (def->src.srcpool) {
char *tmp;
if (virAsprintf(&tmp, "pool = '%s', volume = '%s'",
def->srcpool->pool, def->srcpool->volume) < 0)
def->src.srcpool->pool, def->src.srcpool->volume) < 0)
goto error;
virReportError(VIR_ERR_NO_TARGET, "%s", tmp);
@ -5934,7 +5946,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error;
}
if (def->type == VIR_DOMAIN_DISK_TYPE_NETWORK) {
if (def->src.type == VIR_DOMAIN_DISK_TYPE_NETWORK) {
virReportError(VIR_ERR_XML_ERROR,
_("Setting disk %s is not allowed for "
"disk of network type"),
@ -5953,18 +5965,18 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
def->startupPolicy = val;
}
def->src = source;
def->src.path = source;
source = NULL;
def->dst = target;
target = NULL;
def->auth.username = authUsername;
def->src.auth.username = authUsername;
authUsername = NULL;
def->driverName = driverName;
def->src.driverName = driverName;
driverName = NULL;
def->mirror = mirror;
mirror = NULL;
def->mirroring = mirroring;
def->encryption = encryption;
def->src.encryption = encryption;
encryption = NULL;
def->serial = serial;
serial = NULL;
@ -5976,8 +5988,8 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
product = NULL;
if (driverType) {
def->format = virStorageFileFormatTypeFromString(driverType);
if (def->format <= 0) {
def->src.format = virStorageFileFormatTypeFromString(driverType);
if (def->src.format <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown driver format value '%s'"),
driverType);
@ -14950,15 +14962,15 @@ virDomainDiskSourceDefFormat(virBufferPtr buf,
unsigned int flags)
{
return virDomainDiskSourceDefFormatInternal(buf,
def->type,
def->src,
def->src.type,
def->src.path,
def->startupPolicy,
def->protocol,
def->nhosts,
def->hosts,
def->nseclabels,
def->seclabels,
def->srcpool,
def->src.protocol,
def->src.nhosts,
def->src.hosts,
def->src.nseclabels,
def->src.seclabels,
def->src.srcpool,
flags);
}
@ -14968,7 +14980,7 @@ virDomainDiskDefFormat(virBufferPtr buf,
virDomainDiskDefPtr def,
unsigned int flags)
{
const char *type = virDomainDiskTypeToString(def->type);
const char *type = virDomainDiskTypeToString(def->src.type);
const char *device = virDomainDiskDeviceTypeToString(def->device);
const char *bus = virDomainDiskBusTypeToString(def->bus);
const char *cachemode = virDomainDiskCacheTypeToString(def->cachemode);
@ -14985,7 +14997,7 @@ virDomainDiskDefFormat(virBufferPtr buf,
if (!type) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected disk type %d"), def->type);
_("unexpected disk type %d"), def->src.type);
return -1;
}
if (!device) {
@ -15035,14 +15047,14 @@ virDomainDiskDefFormat(virBufferPtr buf,
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
if (def->driverName || def->format > 0 || def->cachemode ||
if (def->src.driverName || def->src.format > 0 || def->cachemode ||
def->ioeventfd || def->event_idx || def->copy_on_read) {
virBufferAddLit(buf, "<driver");
if (def->driverName)
virBufferAsprintf(buf, " name='%s'", def->driverName);
if (def->format > 0)
if (def->src.driverName)
virBufferAsprintf(buf, " name='%s'", def->src.driverName);
if (def->src.format > 0)
virBufferAsprintf(buf, " type='%s'",
virStorageFileFormatTypeToString(def->format));
virStorageFileFormatTypeToString(def->src.format));
if (def->cachemode)
virBufferAsprintf(buf, " cache='%s'", cachemode);
if (def->error_policy)
@ -15062,23 +15074,23 @@ virDomainDiskDefFormat(virBufferPtr buf,
virBufferAddLit(buf, "/>\n");
}
if (def->auth.username) {
if (def->src.auth.username) {
virBufferEscapeString(buf, "<auth username='%s'>\n",
def->auth.username);
def->src.auth.username);
virBufferAdjustIndent(buf, 2);
if (def->protocol == VIR_DOMAIN_DISK_PROTOCOL_ISCSI) {
if (def->src.protocol == VIR_DOMAIN_DISK_PROTOCOL_ISCSI) {
virBufferAddLit(buf, "<secret type='iscsi'");
} else if (def->protocol == VIR_DOMAIN_DISK_PROTOCOL_RBD) {
} else if (def->src.protocol == VIR_DOMAIN_DISK_PROTOCOL_RBD) {
virBufferAddLit(buf, "<secret type='ceph'");
}
if (def->auth.secretType == VIR_DOMAIN_DISK_SECRET_TYPE_UUID) {
virUUIDFormat(def->auth.secret.uuid, uuidstr);
if (def->src.auth.secretType == VIR_DOMAIN_DISK_SECRET_TYPE_UUID) {
virUUIDFormat(def->src.auth.secret.uuid, uuidstr);
virBufferAsprintf(buf, " uuid='%s'/>\n", uuidstr);
}
if (def->auth.secretType == VIR_DOMAIN_DISK_SECRET_TYPE_USAGE) {
if (def->src.auth.secretType == VIR_DOMAIN_DISK_SECRET_TYPE_USAGE) {
virBufferEscapeString(buf, " usage='%s'/>\n",
def->auth.secret.usage);
def->src.auth.secret.usage);
}
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</auth>\n");
@ -15169,7 +15181,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->encryption && virStorageEncryptionFormat(buf, def->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)
@ -18622,8 +18635,8 @@ virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
if (!path || type == VIR_DOMAIN_DISK_TYPE_NETWORK ||
(type == VIR_DOMAIN_DISK_TYPE_VOLUME &&
disk->srcpool &&
disk->srcpool->mode == VIR_DOMAIN_DISK_SOURCE_POOL_MODE_DIRECT))
disk->src.srcpool &&
disk->src.srcpool->mode == VIR_DOMAIN_DISK_SOURCE_POOL_MODE_DIRECT))
return 0;
if (iter(disk, path, 0, opaque) < 0)
@ -19385,9 +19398,9 @@ virDomainDiskDefGetSecurityLabelDef(virDomainDiskDefPtr def, const char *model)
if (def == NULL)
return NULL;
for (i = 0; i < def->nseclabels; i++) {
if (STREQ_NULLABLE(def->seclabels[i]->model, model))
return def->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;
}
@ -19506,14 +19519,14 @@ virDomainDiskSourceIsBlockType(virDomainDiskDefPtr def)
* If it's a block type source pool, then it's possible
*/
if (virDomainDiskGetType(def) == VIR_DOMAIN_DISK_TYPE_VOLUME &&
def->srcpool &&
def->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->srcpool->pooltype == VIR_STORAGE_POOL_ISCSI &&
def->srcpool->mode == VIR_DOMAIN_DISK_SOURCE_POOL_MODE_DIRECT)
if (def->src.srcpool->pooltype == VIR_STORAGE_POOL_ISCSI &&
def->src.srcpool->mode == VIR_DOMAIN_DISK_SOURCE_POOL_MODE_DIRECT)
return false;
return true;

View File

@ -705,15 +705,15 @@ struct _virDomainDiskSourcePoolDef {
};
typedef virDomainDiskSourcePoolDef *virDomainDiskSourcePoolDefPtr;
/* Stores the virtual disk configuration */
struct _virDomainDiskDef {
typedef struct _virDomainDiskSourceDef virDomainDiskSourceDef;
typedef virDomainDiskSourceDef *virDomainDiskSourceDefPtr;
/* Stores information related to a host resource. In the case of
* backing chains, multiple source disks join to form a single guest
* view. TODO Move this to util/ */
struct _virDomainDiskSourceDef {
int type; /* enum virDomainDiskType */
int device; /* enum virDomainDiskDevice */
int bus; /* enum virDomainDiskBus */
char *src;
char *dst;
int tray_status; /* enum virDomainDiskTray */
int removable; /* enum virDomainFeatureState */
char *path;
int protocol; /* enum virDomainDiskProtocol */
size_t nhosts;
virDomainDiskHostDefPtr hosts;
@ -726,8 +726,23 @@ struct _virDomainDiskDef {
char *usage;
} secret;
} auth;
virStorageEncryptionPtr encryption;
char *driverName;
int format; /* enum virStorageFileFormat */
size_t nseclabels;
virSecurityDeviceLabelDefPtr *seclabels;
};
/* Stores the virtual disk configuration */
struct _virDomainDiskDef {
virDomainDiskSourceDef src;
int device; /* enum virDomainDiskDevice */
int bus; /* enum virDomainDiskBus */
char *dst;
int tray_status; /* enum virDomainDiskTray */
int removable; /* enum virDomainFeatureState */
virStorageFileMetadataPtr backingChain;
char *mirror;
@ -765,14 +780,10 @@ struct _virDomainDiskDef {
bool shared;
bool transient;
virDomainDeviceInfo info;
virStorageEncryptionPtr encryption;
bool rawio_specified;
int rawio; /* no = 0, yes = 1 */
int sgio; /* enum virDomainDeviceSGIO */
int discard; /* enum virDomainDiskDiscard */
size_t nseclabels;
virSecurityDeviceLabelDefPtr *seclabels;
};
@ -2251,7 +2262,7 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
void virDomainInputDefFree(virDomainInputDefPtr def);
void virDomainDiskDefFree(virDomainDiskDefPtr def);
void virDomainLeaseDefFree(virDomainLeaseDefPtr def);
void virDomainDiskAuthClear(virDomainDiskDefPtr def);
void virDomainDiskAuthClear(virDomainDiskSourceDefPtr def);
void virDomainDiskHostDefClear(virDomainDiskHostDefPtr def);
void virDomainDiskHostDefFree(size_t nhosts, virDomainDiskHostDefPtr hosts);
virDomainDiskHostDefPtr virDomainDiskHostDefCopy(size_t nhosts,

View File

@ -1669,7 +1669,7 @@ static int virLXCControllerSetupDisk(virLXCControllerPtr ctrl,
int ret = -1;
struct stat sb;
mode_t mode;
char *tmpsrc = def->src;
char *tmpsrc = def->src.path;
if (virDomainDiskGetType(def) != VIR_DOMAIN_DISK_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, &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 = dst;
def->src.path = dst;
if (virSecurityManagerSetImageLabel(securityDriver, ctrl->def, def) < 0)
goto cleanup;
ret = 0;
cleanup:
def->src = tmpsrc;
def->src.path = tmpsrc;
VIR_FREE(dst);
return ret;
}

View File

@ -3911,14 +3911,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;
def->src = data->file;
char *tmpsrc = def->src.path;
def->src.path = data->file;
if (virSecurityManagerSetImageLabel(data->driver->securityManager,
data->vm->def, def) < 0) {
def->src = tmpsrc;
def->src.path = tmpsrc;
goto cleanup;
}
def->src = tmpsrc;
def->src.path = tmpsrc;
} break;
case VIR_DOMAIN_DEVICE_HOSTDEV: {

View File

@ -3255,7 +3255,7 @@ static int qemuAddRBDHost(virDomainDiskDefPtr disk, char *hostport)
size_t skip;
char **parts;
if (VIR_EXPAND_N(disk->hosts, disk->nhosts, 1) < 0)
if (VIR_EXPAND_N(disk->src.hosts, disk->src.nhosts, 1) < 0)
return -1;
if ((port = strchr(hostport, ']'))) {
@ -3270,29 +3270,29 @@ static int qemuAddRBDHost(virDomainDiskDefPtr disk, char *hostport)
if (port) {
*port = '\0';
port += skip;
if (VIR_STRDUP(disk->hosts[disk->nhosts - 1].port, port) < 0)
if (VIR_STRDUP(disk->src.hosts[disk->src.nhosts - 1].port, port) < 0)
goto error;
} else {
if (VIR_STRDUP(disk->hosts[disk->nhosts - 1].port, "6789") < 0)
if (VIR_STRDUP(disk->src.hosts[disk->src.nhosts - 1].port, "6789") < 0)
goto error;
}
parts = virStringSplit(hostport, "\\:", 0);
if (!parts)
goto error;
disk->hosts[disk->nhosts-1].name = virStringJoin((const char **)parts, ":");
disk->src.hosts[disk->src.nhosts-1].name = virStringJoin((const char **)parts, ":");
virStringFreeList(parts);
if (!disk->hosts[disk->nhosts-1].name)
if (!disk->src.hosts[disk->src.nhosts-1].name)
goto error;
disk->hosts[disk->nhosts-1].transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP;
disk->hosts[disk->nhosts-1].socket = NULL;
disk->src.hosts[disk->src.nhosts-1].transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP;
disk->src.hosts[disk->src.nhosts-1].socket = NULL;
return 0;
error:
VIR_FREE(disk->hosts[disk->nhosts-1].port);
VIR_FREE(disk->hosts[disk->nhosts-1].name);
VIR_FREE(disk->src.hosts[disk->src.nhosts-1].port);
VIR_FREE(disk->src.hosts[disk->src.nhosts-1].name);
return -1;
}
@ -3302,7 +3302,7 @@ static int qemuParseRBDString(virDomainDiskDefPtr disk)
char *options = NULL;
char *p, *e, *next;
p = strchr(disk->src, ':');
p = strchr(disk->src.path, ':');
if (p) {
if (VIR_STRDUP(options, p + 1) < 0)
goto error;
@ -3331,7 +3331,7 @@ static int qemuParseRBDString(virDomainDiskDefPtr disk)
}
if (STRPREFIX(p, "id=") &&
VIR_STRDUP(disk->auth.username, p + strlen("id=")) < 0)
VIR_STRDUP(disk->src.auth.username, p + strlen("id=")) < 0)
goto error;
if (STRPREFIX(p, "mon_host=")) {
char *h, *sep;
@ -3374,7 +3374,7 @@ qemuParseDriveURIString(virDomainDiskDefPtr def, virURIPtr uri,
char *volimg = NULL;
char *secret = NULL;
if (VIR_ALLOC(def->hosts) < 0)
if (VIR_ALLOC(def->src.hosts) < 0)
goto error;
transp = strchr(uri->scheme, '+');
@ -3388,30 +3388,30 @@ qemuParseDriveURIString(virDomainDiskDefPtr def, virURIPtr uri,
}
if (!transp) {
def->hosts->transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP;
def->src.hosts->transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP;
} else {
def->hosts->transport = virDomainDiskProtocolTransportTypeFromString(transp);
if (def->hosts->transport < 0) {
def->src.hosts->transport = virDomainDiskProtocolTransportTypeFromString(transp);
if (def->src.hosts->transport < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid %s transport type '%s'"), scheme, transp);
goto error;
}
}
def->nhosts = 0; /* set to 1 once everything succeeds */
def->src.nhosts = 0; /* set to 1 once everything succeeds */
if (def->hosts->transport != VIR_DOMAIN_DISK_PROTO_TRANS_UNIX) {
if (VIR_STRDUP(def->hosts->name, uri->server) < 0)
if (def->src.hosts->transport != VIR_DOMAIN_DISK_PROTO_TRANS_UNIX) {
if (VIR_STRDUP(def->src.hosts->name, uri->server) < 0)
goto error;
if (virAsprintf(&def->hosts->port, "%d", uri->port) < 0)
if (virAsprintf(&def->src.hosts->port, "%d", uri->port) < 0)
goto error;
} else {
def->hosts->name = NULL;
def->hosts->port = 0;
def->src.hosts->name = NULL;
def->src.hosts->port = 0;
if (uri->query) {
if (STRPREFIX(uri->query, "socket=")) {
sock = strchr(uri->query, '=') + 1;
if (VIR_STRDUP(def->hosts->socket, sock) < 0)
if (VIR_STRDUP(def->src.hosts->socket, sock) < 0)
goto error;
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
@ -3422,12 +3422,11 @@ qemuParseDriveURIString(virDomainDiskDefPtr def, virURIPtr uri,
}
if (uri->path) {
volimg = uri->path + 1; /* skip the prefix slash */
VIR_FREE(def->src);
if (VIR_STRDUP(def->src, volimg) < 0)
VIR_FREE(def->src.path);
if (VIR_STRDUP(def->src.path, volimg) < 0)
goto error;
} else {
VIR_FREE(def->src);
def->src = NULL;
VIR_FREE(def->src.path);
}
if (uri->user) {
@ -3435,11 +3434,11 @@ qemuParseDriveURIString(virDomainDiskDefPtr def, virURIPtr uri,
if (secret)
*secret = '\0';
if (VIR_STRDUP(def->auth.username, uri->user) < 0)
if (VIR_STRDUP(def->src.auth.username, uri->user) < 0)
goto error;
}
def->nhosts = 1;
def->src.nhosts = 1;
ret = 0;
cleanup:
@ -3448,8 +3447,8 @@ cleanup:
return ret;
error:
virDomainDiskHostDefClear(def->hosts);
VIR_FREE(def->hosts);
virDomainDiskHostDefClear(def->src.hosts);
VIR_FREE(def->src.hosts);
goto cleanup;
}
@ -3458,7 +3457,7 @@ qemuParseGlusterString(virDomainDiskDefPtr def)
{
virURIPtr uri = NULL;
if (!(uri = virURIParse(def->src)))
if (!(uri = virURIParse(def->src.path)))
return -1;
return qemuParseDriveURIString(def, uri, "gluster");
@ -3471,7 +3470,7 @@ qemuParseISCSIString(virDomainDiskDefPtr def)
char *slash;
unsigned lun;
if (!(uri = virURIParse(def->src)))
if (!(uri = virURIParse(def->src.path)))
return -1;
if (uri->path &&
@ -3481,7 +3480,8 @@ qemuParseISCSIString(virDomainDiskDefPtr def)
*slash = '\0';
else if (virStrToLong_ui(slash + 1, NULL, 10, &lun) == -1) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("invalid name '%s' for iSCSI disk"), def->src);
_("invalid name '%s' for iSCSI disk"),
def->src.path);
return -1;
}
}
@ -3498,8 +3498,8 @@ qemuParseNBDString(virDomainDiskDefPtr disk)
virURIPtr uri = NULL;
if (strstr(disk->src, "://")) {
if (!(uri = virURIParse(disk->src)))
if (strstr(disk->src.path, "://")) {
if (!(uri = virURIParse(disk->src.path)))
return -1;
return qemuParseDriveURIString(disk, uri, "nbd");
}
@ -3507,7 +3507,7 @@ qemuParseNBDString(virDomainDiskDefPtr disk)
if (VIR_ALLOC(h) < 0)
goto error;
host = disk->src + strlen("nbd:");
host = disk->src.path + strlen("nbd:");
if (STRPREFIX(host, "unix:/")) {
src = strchr(host + strlen("unix:"), ':');
if (src)
@ -3520,7 +3520,7 @@ qemuParseNBDString(virDomainDiskDefPtr disk)
port = strchr(host, ':');
if (!port) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse nbd filename '%s'"), disk->src);
_("cannot parse nbd filename '%s'"), disk->src.path);
goto error;
}
@ -3543,10 +3543,10 @@ qemuParseNBDString(virDomainDiskDefPtr disk)
src = NULL;
}
VIR_FREE(disk->src);
disk->src = src;
disk->nhosts = 1;
disk->hosts = h;
VIR_FREE(disk->src.path);
disk->src.path = src;
disk->src.nhosts = 1;
disk->src.hosts = h;
return 0;
error:
@ -3875,35 +3875,35 @@ qemuDomainDiskGetSourceString(virConnectPtr conn,
*source = NULL;
if (actualType == VIR_DOMAIN_DISK_TYPE_NETWORK &&
disk->auth.username &&
(disk->protocol == VIR_DOMAIN_DISK_PROTOCOL_ISCSI ||
disk->protocol == VIR_DOMAIN_DISK_PROTOCOL_RBD)) {
disk->src.auth.username &&
(disk->src.protocol == VIR_DOMAIN_DISK_PROTOCOL_ISCSI ||
disk->src.protocol == VIR_DOMAIN_DISK_PROTOCOL_RBD)) {
bool encode = false;
int secretType = VIR_SECRET_USAGE_TYPE_ISCSI;
if (disk->protocol == VIR_DOMAIN_DISK_PROTOCOL_RBD) {
if (disk->src.protocol == VIR_DOMAIN_DISK_PROTOCOL_RBD) {
/* qemu requires the secret to be encoded for RBD */
encode = true;
secretType = VIR_SECRET_USAGE_TYPE_CEPH;
}
if (!(secret = qemuGetSecretString(conn,
virDomainDiskProtocolTypeToString(disk->protocol),
virDomainDiskProtocolTypeToString(disk->src.protocol),
encode,
disk->auth.secretType,
disk->auth.username,
disk->auth.secret.uuid,
disk->auth.secret.usage,
disk->src.auth.secretType,
disk->src.auth.username,
disk->src.auth.secret.uuid,
disk->src.auth.secret.usage,
secretType)))
goto cleanup;
}
ret = qemuGetDriveSourceString(virDomainDiskGetActualType(disk),
disk->src,
disk->protocol,
disk->nhosts,
disk->hosts,
disk->auth.username,
disk->src.path,
disk->src.protocol,
disk->src.nhosts,
disk->src.hosts,
disk->src.auth.username,
secret,
source);
@ -4021,10 +4021,11 @@ qemuBuildDriveStr(virConnectPtr conn,
switch (actualType) {
case VIR_DOMAIN_DISK_TYPE_DIR:
/* QEMU only supports magic FAT format for now */
if (disk->format > 0 && disk->format != VIR_STORAGE_FILE_FAT) {
if (disk->src.format > 0 &&
disk->src.format != VIR_STORAGE_FILE_FAT) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unsupported disk driver type for '%s'"),
virStorageFileFormatTypeToString(disk->format));
virStorageFileFormatTypeToString(disk->src.format));
goto error;
}
@ -4044,7 +4045,7 @@ qemuBuildDriveStr(virConnectPtr conn,
case VIR_DOMAIN_DISK_TYPE_BLOCK:
if (disk->tray_status == VIR_DOMAIN_DISK_TRAY_OPEN) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
disk->type == VIR_DOMAIN_DISK_TYPE_VOLUME ?
disk->src.type == VIR_DOMAIN_DISK_TYPE_VOLUME ?
_("tray status 'open' is invalid for block type volume") :
_("tray status 'open' is invalid for block type disk"));
goto error;
@ -4104,11 +4105,11 @@ qemuBuildDriveStr(virConnectPtr conn,
_("transient disks not supported yet"));
goto error;
}
if (disk->format > 0 &&
disk->type != VIR_DOMAIN_DISK_TYPE_DIR &&
if (disk->src.format > 0 &&
disk->src.type != VIR_DOMAIN_DISK_TYPE_DIR &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_FORMAT))
virBufferAsprintf(&opt, ",format=%s",
virStorageFileFormatTypeToString(disk->format));
virStorageFileFormatTypeToString(disk->src.format));
/* generate geometry command string */
if (disk->geometry.cylinders > 0 &&
@ -4319,11 +4320,11 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
bus);
goto error;
}
if (disk->type == VIR_DOMAIN_DISK_TYPE_NETWORK) {
if (disk->protocol != VIR_DOMAIN_DISK_PROTOCOL_ISCSI) {
if (disk->src.type == VIR_DOMAIN_DISK_TYPE_NETWORK) {
if (disk->src.protocol != VIR_DOMAIN_DISK_PROTOCOL_ISCSI) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("disk device='lun' is not supported for protocol='%s'"),
virDomainDiskProtocolTypeToString(disk->protocol));
virDomainDiskProtocolTypeToString(disk->src.protocol));
goto error;
}
} else if (!virDomainDiskSourceIsBlockType(disk)) {
@ -8414,11 +8415,11 @@ qemuBuildCommandLine(virConnectPtr conn,
for (i = 0; i < def->ndisks; i++) {
virDomainDiskDefPtr disk = def->disks[i];
if (disk->driverName != NULL &&
!STREQ(disk->driverName, "qemu")) {
if (disk->src.driverName != NULL &&
!STREQ(disk->src.driverName, "qemu")) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported driver name '%s' for disk '%s'"),
disk->driverName, disk->src);
disk->src.driverName, disk->src.path);
goto error;
}
}
@ -8542,11 +8543,11 @@ qemuBuildCommandLine(virConnectPtr conn,
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
virCommandAddArg(cmd, "-usbdevice");
virCommandAddArgFormat(cmd, "disk:%s", disk->src);
virCommandAddArgFormat(cmd, "disk:%s", disk->src.path);
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unsupported usb disk type for '%s'"),
disk->src);
disk->src.path);
goto error;
}
continue;
@ -8632,7 +8633,7 @@ qemuBuildCommandLine(virConnectPtr conn,
const char *fmt;
virDomainDiskDefPtr disk = def->disks[i];
if ((disk->type == VIR_DOMAIN_DISK_TYPE_BLOCK) &&
if ((disk->src.type == VIR_DOMAIN_DISK_TYPE_BLOCK) &&
(disk->tray_status == VIR_DOMAIN_DISK_TRAY_OPEN)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("tray status 'open' is invalid for "
@ -8643,11 +8644,11 @@ qemuBuildCommandLine(virConnectPtr conn,
if (disk->bus == VIR_DOMAIN_DISK_BUS_USB) {
if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
virCommandAddArg(cmd, "-usbdevice");
virCommandAddArgFormat(cmd, "disk:%s", disk->src);
virCommandAddArgFormat(cmd, "disk:%s", disk->src.path);
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unsupported usb disk type for '%s'"),
disk->src);
disk->src.path);
goto error;
}
continue;
@ -8655,7 +8656,7 @@ qemuBuildCommandLine(virConnectPtr conn,
if (STREQ(disk->dst, "hdc") &&
disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
if (disk->src) {
if (disk->src.path) {
snprintf(dev, NAME_MAX, "-%s", "cdrom");
} else {
continue;
@ -8671,12 +8672,13 @@ qemuBuildCommandLine(virConnectPtr conn,
}
}
if (disk->type == VIR_DOMAIN_DISK_TYPE_DIR) {
if (disk->src.type == VIR_DOMAIN_DISK_TYPE_DIR) {
/* QEMU only supports magic FAT format for now */
if (disk->format > 0 && disk->format != VIR_STORAGE_FILE_FAT) {
if (disk->src.format > 0 &&
disk->src.format != VIR_STORAGE_FILE_FAT) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unsupported disk driver type for '%s'"),
virStorageFileFormatTypeToString(disk->format));
virStorageFileFormatTypeToString(disk->src.format));
goto error;
}
if (!disk->readonly) {
@ -8691,11 +8693,11 @@ qemuBuildCommandLine(virConnectPtr conn,
if (virAsprintf(&file, fmt, disk->src) < 0)
goto error;
} else if (disk->type == VIR_DOMAIN_DISK_TYPE_NETWORK) {
} else if (disk->src.type == VIR_DOMAIN_DISK_TYPE_NETWORK) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("network disks are only supported with -drive"));
} else {
if (VIR_STRDUP(file, disk->src) < 0) {
if (VIR_STRDUP(file, disk->src.path) < 0) {
goto error;
}
}
@ -10199,28 +10201,28 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
else
def->bus = VIR_DOMAIN_DISK_BUS_IDE;
def->device = VIR_DOMAIN_DISK_DEVICE_DISK;
def->type = VIR_DOMAIN_DISK_TYPE_FILE;
def->src.type = VIR_DOMAIN_DISK_TYPE_FILE;
for (i = 0; i < nkeywords; i++) {
if (STREQ(keywords[i], "file")) {
if (values[i] && STRNEQ(values[i], "")) {
def->src = values[i];
def->src.path = values[i];
values[i] = NULL;
if (STRPREFIX(def->src, "/dev/"))
def->type = VIR_DOMAIN_DISK_TYPE_BLOCK;
else if (STRPREFIX(def->src, "nbd:") ||
STRPREFIX(def->src, "nbd+")) {
def->type = VIR_DOMAIN_DISK_TYPE_NETWORK;
def->protocol = VIR_DOMAIN_DISK_PROTOCOL_NBD;
if (STRPREFIX(def->src.path, "/dev/"))
def->src.type = VIR_DOMAIN_DISK_TYPE_BLOCK;
else if (STRPREFIX(def->src.path, "nbd:") ||
STRPREFIX(def->src.path, "nbd+")) {
def->src.type = VIR_DOMAIN_DISK_TYPE_NETWORK;
def->src.protocol = VIR_DOMAIN_DISK_PROTOCOL_NBD;
if (qemuParseNBDString(def) < 0)
goto error;
} else if (STRPREFIX(def->src, "rbd:")) {
char *p = def->src;
} else if (STRPREFIX(def->src.path, "rbd:")) {
char *p = def->src.path;
def->type = VIR_DOMAIN_DISK_TYPE_NETWORK;
def->protocol = VIR_DOMAIN_DISK_PROTOCOL_RBD;
if (VIR_STRDUP(def->src, p + strlen("rbd:")) < 0)
def->src.type = VIR_DOMAIN_DISK_TYPE_NETWORK;
def->src.protocol = VIR_DOMAIN_DISK_PROTOCOL_RBD;
if (VIR_STRDUP(def->src.path, p + strlen("rbd:")) < 0)
goto error;
/* old-style CEPH_ARGS env variable is parsed later */
if (!old_style_ceph_args && qemuParseRBDString(def) < 0) {
@ -10229,57 +10231,58 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
}
VIR_FREE(p);
} else if (STRPREFIX(def->src, "gluster:") ||
STRPREFIX(def->src, "gluster+")) {
def->type = VIR_DOMAIN_DISK_TYPE_NETWORK;
def->protocol = VIR_DOMAIN_DISK_PROTOCOL_GLUSTER;
} else if (STRPREFIX(def->src.path, "gluster:") ||
STRPREFIX(def->src.path, "gluster+")) {
def->src.type = VIR_DOMAIN_DISK_TYPE_NETWORK;
def->src.protocol = VIR_DOMAIN_DISK_PROTOCOL_GLUSTER;
if (qemuParseGlusterString(def) < 0)
goto error;
} else if (STRPREFIX(def->src, "iscsi:")) {
def->type = VIR_DOMAIN_DISK_TYPE_NETWORK;
def->protocol = VIR_DOMAIN_DISK_PROTOCOL_ISCSI;
} else if (STRPREFIX(def->src.path, "iscsi:")) {
def->src.type = VIR_DOMAIN_DISK_TYPE_NETWORK;
def->src.protocol = VIR_DOMAIN_DISK_PROTOCOL_ISCSI;
if (qemuParseISCSIString(def) < 0)
goto error;
} else if (STRPREFIX(def->src, "sheepdog:")) {
char *p = def->src;
} else if (STRPREFIX(def->src.path, "sheepdog:")) {
char *p = def->src.path;
char *port, *vdi;
def->type = VIR_DOMAIN_DISK_TYPE_NETWORK;
def->protocol = VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG;
if (VIR_STRDUP(def->src, p + strlen("sheepdog:")) < 0)
def->src.type = VIR_DOMAIN_DISK_TYPE_NETWORK;
def->src.protocol = VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG;
if (VIR_STRDUP(def->src.path, p + strlen("sheepdog:")) < 0)
goto error;
VIR_FREE(p);
/* def->src must be [vdiname] or [host]:[port]:[vdiname] */
port = strchr(def->src, ':');
/* def->src.path must be [vdiname] or [host]:[port]:[vdiname] */
port = strchr(def->src.path, ':');
if (port) {
*port = '\0';
vdi = strchr(port + 1, ':');
if (!vdi) {
*port = ':';
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse sheepdog filename '%s'"), def->src);
_("cannot parse sheepdog filename '%s'"),
def->src.path);
goto error;
}
port++;
*vdi++ = '\0';
if (VIR_ALLOC(def->hosts) < 0)
if (VIR_ALLOC(def->src.hosts) < 0)
goto error;
def->nhosts = 1;
def->hosts->name = def->src;
if (VIR_STRDUP(def->hosts->port, port) < 0)
def->src.nhosts = 1;
def->src.hosts->name = def->src.path;
if (VIR_STRDUP(def->src.hosts->port, port) < 0)
goto error;
def->hosts->transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP;
def->hosts->socket = NULL;
if (VIR_STRDUP(def->src, vdi) < 0)
def->src.hosts->transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP;
def->src.hosts->socket = NULL;
if (VIR_STRDUP(def->src.path, vdi) < 0)
goto error;
}
} else
def->type = VIR_DOMAIN_DISK_TYPE_FILE;
def->src.type = VIR_DOMAIN_DISK_TYPE_FILE;
} else {
def->type = VIR_DOMAIN_DISK_TYPE_FILE;
def->src.type = VIR_DOMAIN_DISK_TYPE_FILE;
}
} else if (STREQ(keywords[i], "if")) {
if (STREQ(values[i], "ide")) {
@ -10305,9 +10308,9 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
} else if (STREQ(values[i], "floppy"))
def->device = VIR_DOMAIN_DISK_DEVICE_FLOPPY;
} else if (STREQ(keywords[i], "format")) {
if (VIR_STRDUP(def->driverName, "qemu") < 0)
if (VIR_STRDUP(def->src.driverName, "qemu") < 0)
goto error;
def->format = virStorageFileFormatTypeFromString(values[i]);
def->src.format = virStorageFileFormatTypeFromString(values[i]);
} else if (STREQ(keywords[i], "cache")) {
if (STREQ(values[i], "off") ||
STREQ(values[i], "none"))
@ -10412,9 +10415,9 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
if (def->rerror_policy == def->error_policy)
def->rerror_policy = 0;
if (!def->src &&
if (!def->src.path &&
def->device == VIR_DOMAIN_DISK_DEVICE_DISK &&
def->type != VIR_DOMAIN_DISK_TYPE_NETWORK) {
def->src.type != VIR_DOMAIN_DISK_TYPE_NETWORK) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("missing file parameter in drive '%s'"), val);
goto error;
@ -11499,23 +11502,23 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
goto error;
if (STRPREFIX(val, "/dev/"))
disk->type = VIR_DOMAIN_DISK_TYPE_BLOCK;
disk->src.type = VIR_DOMAIN_DISK_TYPE_BLOCK;
else if (STRPREFIX(val, "nbd:")) {
disk->type = VIR_DOMAIN_DISK_TYPE_NETWORK;
disk->protocol = VIR_DOMAIN_DISK_PROTOCOL_NBD;
disk->src.type = VIR_DOMAIN_DISK_TYPE_NETWORK;
disk->src.protocol = VIR_DOMAIN_DISK_PROTOCOL_NBD;
} else if (STRPREFIX(val, "rbd:")) {
disk->type = VIR_DOMAIN_DISK_TYPE_NETWORK;
disk->protocol = VIR_DOMAIN_DISK_PROTOCOL_RBD;
disk->src.type = VIR_DOMAIN_DISK_TYPE_NETWORK;
disk->src.protocol = VIR_DOMAIN_DISK_PROTOCOL_RBD;
val += strlen("rbd:");
} else if (STRPREFIX(val, "gluster")) {
disk->type = VIR_DOMAIN_DISK_TYPE_NETWORK;
disk->protocol = VIR_DOMAIN_DISK_PROTOCOL_GLUSTER;
disk->src.type = VIR_DOMAIN_DISK_TYPE_NETWORK;
disk->src.protocol = VIR_DOMAIN_DISK_PROTOCOL_GLUSTER;
} else if (STRPREFIX(val, "sheepdog:")) {
disk->type = VIR_DOMAIN_DISK_TYPE_NETWORK;
disk->protocol = VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG;
disk->src.type = VIR_DOMAIN_DISK_TYPE_NETWORK;
disk->src.protocol = VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG;
val += strlen("sheepdog:");
} else
disk->type = VIR_DOMAIN_DISK_TYPE_FILE;
disk->src.type = VIR_DOMAIN_DISK_TYPE_FILE;
if (STREQ(arg, "-cdrom")) {
disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM;
if (((def->os.arch == VIR_ARCH_PPC64) &&
@ -11541,13 +11544,13 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
if (VIR_STRDUP(disk->dst, arg + 1) < 0)
goto error;
}
if (VIR_STRDUP(disk->src, val) < 0)
if (VIR_STRDUP(disk->src.path, val) < 0)
goto error;
if (disk->type == VIR_DOMAIN_DISK_TYPE_NETWORK) {
if (disk->src.type == VIR_DOMAIN_DISK_TYPE_NETWORK) {
char *port;
switch (disk->protocol) {
switch (disk->src.protocol) {
case VIR_DOMAIN_DISK_PROTOCOL_NBD:
if (qemuParseNBDString(disk) < 0)
goto error;
@ -11559,7 +11562,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
break;
case VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG:
/* disk->src must be [vdiname] or [host]:[port]:[vdiname] */
port = strchr(disk->src, ':');
port = strchr(disk->src.path, ':');
if (port) {
char *vdi;
@ -11571,13 +11574,13 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
goto error;
}
*vdi++ = '\0';
if (VIR_ALLOC(disk->hosts) < 0)
if (VIR_ALLOC(disk->src.hosts) < 0)
goto error;
disk->nhosts = 1;
disk->hosts->name = disk->src;
if (VIR_STRDUP(disk->hosts->port, port) < 0)
disk->src.nhosts = 1;
disk->src.hosts->name = disk->src.path;
if (VIR_STRDUP(disk->src.hosts->port, port) < 0)
goto error;
if (VIR_STRDUP(disk->src, vdi) < 0)
if (VIR_STRDUP(disk->src.path, vdi) < 0)
goto error;
}
break;
@ -11788,12 +11791,12 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
} else if (STRPREFIX(val, "disk:")) {
if (VIR_ALLOC(disk) < 0)
goto error;
if (VIR_STRDUP(disk->src, val + strlen("disk:")) < 0)
if (VIR_STRDUP(disk->src.path, val + strlen("disk:")) < 0)
goto error;
if (STRPREFIX(disk->src, "/dev/"))
disk->type = VIR_DOMAIN_DISK_TYPE_BLOCK;
if (STRPREFIX(disk->src.path, "/dev/"))
disk->src.type = VIR_DOMAIN_DISK_TYPE_BLOCK;
else
disk->type = VIR_DOMAIN_DISK_TYPE_FILE;
disk->src.type = VIR_DOMAIN_DISK_TYPE_FILE;
disk->device = VIR_DOMAIN_DISK_DEVICE_DISK;
disk->bus = VIR_DOMAIN_DISK_BUS_USB;
disk->removable = VIR_DOMAIN_FEATURE_STATE_DEFAULT;
@ -12024,8 +12027,8 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
char *hosts, *port, *saveptr = NULL, *token;
virDomainDiskDefPtr first_rbd_disk = NULL;
for (i = 0; i < def->ndisks; i++) {
if (def->disks[i]->type == VIR_DOMAIN_DISK_TYPE_NETWORK &&
def->disks[i]->protocol == VIR_DOMAIN_DISK_PROTOCOL_RBD) {
if (def->disks[i]->src.type == VIR_DOMAIN_DISK_TYPE_NETWORK &&
def->disks[i]->src.protocol == VIR_DOMAIN_DISK_PROTOCOL_RBD) {
first_rbd_disk = def->disks[i];
break;
}
@ -12045,10 +12048,11 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
}
if (VIR_STRDUP(hosts, strchr(ceph_args, ' ') + 1) < 0)
goto error;
first_rbd_disk->nhosts = 0;
first_rbd_disk->src.nhosts = 0;
token = strtok_r(hosts, ",", &saveptr);
while (token != NULL) {
if (VIR_REALLOC_N(first_rbd_disk->hosts, first_rbd_disk->nhosts + 1) < 0) {
if (VIR_REALLOC_N(first_rbd_disk->src.hosts,
first_rbd_disk->src.nhosts + 1) < 0) {
VIR_FREE(hosts);
goto error;
}
@ -12060,21 +12064,21 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
goto error;
}
}
first_rbd_disk->hosts[first_rbd_disk->nhosts].port = port;
if (VIR_STRDUP(first_rbd_disk->hosts[first_rbd_disk->nhosts].name,
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,
token) < 0) {
VIR_FREE(hosts);
goto error;
}
first_rbd_disk->hosts[first_rbd_disk->nhosts].transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP;
first_rbd_disk->hosts[first_rbd_disk->nhosts].socket = NULL;
first_rbd_disk->src.hosts[first_rbd_disk->src.nhosts].transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP;
first_rbd_disk->src.hosts[first_rbd_disk->src.nhosts].socket = NULL;
first_rbd_disk->nhosts++;
first_rbd_disk->src.nhosts++;
token = strtok_r(NULL, ",", &saveptr);
}
VIR_FREE(hosts);
if (first_rbd_disk->nhosts == 0) {
if (first_rbd_disk->src.nhosts == 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("found no rbd hosts in CEPH_ARGS '%s'"), ceph_args);
goto error;

View File

@ -797,8 +797,8 @@ qemuCheckSharedDevice(virHashTablePtr sharedDevices,
virReportError(VIR_ERR_OPERATION_INVALID,
_("sgio of shared disk 'pool=%s' 'volume=%s' conflicts "
"with other active domains"),
disk->srcpool->pool,
disk->srcpool->volume);
disk->src.srcpool->pool,
disk->src.srcpool->volume);
} else {
virReportError(VIR_ERR_OPERATION_INVALID,
_("sgio of shared disk '%s' conflicts with other "
@ -1158,33 +1158,33 @@ qemuAddISCSIPoolSourceHost(virDomainDiskDefPtr def,
}
/* iscsi pool only supports one host */
def->nhosts = 1;
def->src.nhosts = 1;
if (VIR_ALLOC_N(def->hosts, def->nhosts) < 0)
if (VIR_ALLOC_N(def->src.hosts, def->src.nhosts) < 0)
goto cleanup;
if (VIR_STRDUP(def->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->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->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->srcpool->volume);
def->src.srcpool->volume);
goto cleanup;
}
/* iscsi pool has only one source device path */
if (virAsprintf(&def->src, "%s/%s",
if (virAsprintf(&def->src.path, "%s/%s",
pooldef->source.devices[0].path,
tokens[3]) < 0)
goto cleanup;
@ -1192,10 +1192,10 @@ qemuAddISCSIPoolSourceHost(virDomainDiskDefPtr def,
/* Storage pool have not supported these 2 attributes yet,
* use the defaults.
*/
def->hosts[0].transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP;
def->hosts[0].socket = NULL;
def->src.hosts[0].transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP;
def->src.hosts[0].socket = NULL;
def->protocol = VIR_DOMAIN_DISK_PROTOCOL_ISCSI;
def->src.protocol = VIR_DOMAIN_DISK_PROTOCOL_ISCSI;
ret = 0;
@ -1220,34 +1220,34 @@ qemuTranslateDiskSourcePoolAuth(virDomainDiskDefPtr def,
* into the virDomainDiskDef
*/
if (pooldef->source.authType == VIR_STORAGE_POOL_AUTH_CHAP) {
if (VIR_STRDUP(def->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->auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_UUID;
memcpy(def->auth.secret.uuid,
def->src.auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_UUID;
memcpy(def->src.auth.secret.uuid,
pooldef->source.auth.chap.secret.uuid,
VIR_UUID_BUFLEN);
} else {
if (VIR_STRDUP(def->auth.secret.usage,
if (VIR_STRDUP(def->src.auth.secret.usage,
pooldef->source.auth.chap.secret.usage) < 0)
goto cleanup;
def->auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_USAGE;
def->src.auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_USAGE;
}
} else if (pooldef->source.authType == VIR_STORAGE_POOL_AUTH_CEPHX) {
if (VIR_STRDUP(def->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->auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_UUID;
memcpy(def->auth.secret.uuid,
def->src.auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_UUID;
memcpy(def->src.auth.secret.uuid,
pooldef->source.auth.cephx.secret.uuid,
VIR_UUID_BUFLEN);
} else {
if (VIR_STRDUP(def->auth.secret.usage,
if (VIR_STRDUP(def->src.auth.secret.usage,
pooldef->source.auth.cephx.secret.usage) < 0)
goto cleanup;
def->auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_USAGE;
def->src.auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_USAGE;
}
}
ret = 0;
@ -1269,24 +1269,24 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
int ret = -1;
virErrorPtr savedError = NULL;
if (def->type != VIR_DOMAIN_DISK_TYPE_VOLUME)
if (def->src.type != VIR_DOMAIN_DISK_TYPE_VOLUME)
return 0;
if (!def->srcpool)
if (!def->src.srcpool)
return 0;
if (!(pool = virStoragePoolLookupByName(conn, def->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->srcpool->pool, def->srcpool->volume);
def->src.srcpool->pool, def->src.srcpool->volume);
goto cleanup;
}
if (!(vol = virStorageVolLookupByName(pool, def->srcpool->volume)))
if (!(vol = virStorageVolLookupByName(pool, def->src.srcpool->volume)))
goto cleanup;
if (virStorageVolGetInfo(vol, &info) < 0)
@ -1298,19 +1298,19 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
if (!(pooldef = virStoragePoolDefParseString(poolxml)))
goto cleanup;
def->srcpool->pooltype = pooldef->type;
def->srcpool->voltype = info.type;
def->src.srcpool->pooltype = pooldef->type;
def->src.srcpool->voltype = info.type;
if (def->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);
virDomainDiskHostDefFree(def->nhosts, def->hosts);
virDomainDiskAuthClear(def);
VIR_FREE(def->src.path);
virDomainDiskHostDefFree(def->src.nhosts, def->src.hosts);
virDomainDiskAuthClear(&def->src);
switch ((enum virStoragePoolType) pooldef->type) {
case VIR_STORAGE_POOL_DIR:
@ -1319,7 +1319,7 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
case VIR_STORAGE_POOL_LOGICAL:
case VIR_STORAGE_POOL_DISK:
case VIR_STORAGE_POOL_SCSI:
if (!(def->src = virStorageVolGetPath(vol)))
if (!(def->src.path = virStorageVolGetPath(vol)))
goto cleanup;
if (def->startupPolicy && info.type != VIR_STORAGE_VOL_FILE) {
@ -1332,15 +1332,15 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
switch (info.type) {
case VIR_STORAGE_VOL_FILE:
def->srcpool->actualtype = VIR_DOMAIN_DISK_TYPE_FILE;
def->src.srcpool->actualtype = VIR_DOMAIN_DISK_TYPE_FILE;
break;
case VIR_STORAGE_VOL_DIR:
def->srcpool->actualtype = VIR_DOMAIN_DISK_TYPE_DIR;
def->src.srcpool->actualtype = VIR_DOMAIN_DISK_TYPE_DIR;
break;
case VIR_STORAGE_VOL_BLOCK:
def->srcpool->actualtype = VIR_DOMAIN_DISK_TYPE_BLOCK;
def->src.srcpool->actualtype = VIR_DOMAIN_DISK_TYPE_BLOCK;
break;
case VIR_STORAGE_VOL_NETWORK:
@ -1363,20 +1363,20 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
goto cleanup;
}
switch (def->srcpool->mode) {
switch (def->src.srcpool->mode) {
case VIR_DOMAIN_DISK_SOURCE_POOL_MODE_DEFAULT:
case VIR_DOMAIN_DISK_SOURCE_POOL_MODE_LAST:
def->srcpool->mode = VIR_DOMAIN_DISK_SOURCE_POOL_MODE_HOST;
def->src.srcpool->mode = VIR_DOMAIN_DISK_SOURCE_POOL_MODE_HOST;
/* fallthrough */
case VIR_DOMAIN_DISK_SOURCE_POOL_MODE_HOST:
def->srcpool->actualtype = VIR_DOMAIN_DISK_TYPE_BLOCK;
if (!(def->src = virStorageVolGetPath(vol)))
def->src.srcpool->actualtype = VIR_DOMAIN_DISK_TYPE_BLOCK;
if (!(def->src.path = virStorageVolGetPath(vol)))
goto cleanup;
break;
case VIR_DOMAIN_DISK_SOURCE_POOL_MODE_DIRECT:
def->srcpool->actualtype = VIR_DOMAIN_DISK_TYPE_NETWORK;
def->protocol = VIR_DOMAIN_DISK_PROTOCOL_ISCSI;
def->src.srcpool->actualtype = VIR_DOMAIN_DISK_TYPE_NETWORK;
def->src.protocol = VIR_DOMAIN_DISK_PROTOCOL_ISCSI;
if (qemuTranslateDiskSourcePoolAuth(def, pooldef) < 0)
goto cleanup;

View File

@ -6839,18 +6839,18 @@ qemuDomainUpdateDeviceConfig(virQEMUCapsPtr qemuCaps,
* Update 'orig'
* We allow updating src/type//driverType/cachemode/
*/
VIR_FREE(orig->src);
orig->src = disk->src;
orig->type = disk->type;
VIR_FREE(orig->src.path);
orig->src.path = disk->src.path;
orig->src.type = disk->src.type;
orig->cachemode = disk->cachemode;
if (disk->driverName) {
VIR_FREE(orig->driverName);
orig->driverName = disk->driverName;
disk->driverName = NULL;
if (disk->src.driverName) {
VIR_FREE(orig->src.driverName);
orig->src.driverName = disk->src.driverName;
disk->src.driverName = NULL;
}
if (disk->format)
orig->format = disk->format;
disk->src = NULL;
if (disk->src.format)
orig->src.format = disk->src.format;
disk->src.path = NULL;
break;
case VIR_DOMAIN_DEVICE_NET:
@ -12003,26 +12003,27 @@ qemuDomainPrepareDiskChainElement(virQEMUDriverPtr driver,
/* The easiest way to label a single file with the same
* permissions it would have as if part of the disk chain is to
* temporarily modify the disk in place. */
char *origsrc = disk->src;
int origformat = disk->format;
char *origsrc = disk->src.path;
int origformat = disk->src.format;
virStorageFileMetadataPtr origchain = disk->backingChain;
bool origreadonly = disk->readonly;
int ret = -1;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
disk->src = (char *) file; /* casting away const is safe here */
disk->format = VIR_STORAGE_FILE_RAW;
disk->src.path = (char *) file; /* casting away const is safe here */
disk->src.format = VIR_STORAGE_FILE_RAW;
disk->backingChain = NULL;
disk->readonly = mode == VIR_DISK_CHAIN_READ_ONLY;
if (mode == VIR_DISK_CHAIN_NO_ACCESS) {
if (virSecurityManagerRestoreImageLabel(driver->securityManager,
vm->def, disk) < 0)
VIR_WARN("Unable to restore security label on %s", disk->src);
VIR_WARN("Unable to restore security label on %s", disk->src.path);
if (qemuTeardownDiskCgroup(vm, disk) < 0)
VIR_WARN("Failed to teardown cgroup for disk path %s", disk->src);
VIR_WARN("Failed to teardown cgroup for disk path %s",
disk->src.path);
if (virDomainLockDiskDetach(driver->lockManager, vm, disk) < 0)
VIR_WARN("Unable to release lock on %s", disk->src);
VIR_WARN("Unable to release lock on %s", disk->src.path);
} else if (virDomainLockDiskAttach(driver->lockManager, cfg->uri,
vm, disk) < 0 ||
qemuSetupDiskCgroup(vm, disk) < 0 ||
@ -12034,8 +12035,8 @@ qemuDomainPrepareDiskChainElement(virQEMUDriverPtr driver,
ret = 0;
cleanup:
disk->src = origsrc;
disk->format = origformat;
disk->src.path = origsrc;
disk->src.format = origformat;
disk->backingChain = origchain;
disk->readonly = origreadonly;
virObjectUnref(cfg);
@ -12133,22 +12134,22 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDriverPtr driver,
NULL)))
goto cleanup;
if (defdisk->format > 0) {
if (defdisk->src.format > 0) {
/* adds cmd line arg: backing_file=/path/to/backing/file,backing_fmd=format */
virCommandAddArgFormat(cmd, "backing_file=%s,backing_fmt=%s",
defdisk->src,
virStorageFileFormatTypeToString(defdisk->format));
defdisk->src.path,
virStorageFileFormatTypeToString(defdisk->src.format));
} else {
if (!cfg->allowDiskFormatProbing) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown image format of '%s' and "
"format probing is disabled"),
defdisk->src);
defdisk->src.path);
goto cleanup;
}
/* adds cmd line arg: backing_file=/path/to/backing/file */
virCommandAddArgFormat(cmd, "backing_file=%s", defdisk->src);
virCommandAddArgFormat(cmd, "backing_file=%s", defdisk->src.path);
}
/* adds cmd line args: /path/to/target/file */
@ -12171,12 +12172,12 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDriverPtr driver,
defdisk = vm->def->disks[snapdisk->index];
if (snapdisk->snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) {
VIR_FREE(defdisk->src);
if (VIR_STRDUP(defdisk->src, snapdisk->file) < 0) {
VIR_FREE(defdisk->src.path);
if (VIR_STRDUP(defdisk->src.path, snapdisk->file) < 0) {
/* we cannot rollback here in a sane way */
goto cleanup;
}
defdisk->format = snapdisk->format;
defdisk->src.format = snapdisk->format;
}
}
@ -12299,7 +12300,7 @@ qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
return 0;
case VIR_DOMAIN_DISK_TYPE_NETWORK:
switch ((enum virDomainDiskProtocol) disk->protocol) {
switch ((enum virDomainDiskProtocol) disk->src.protocol) {
case VIR_DOMAIN_DISK_PROTOCOL_NBD:
case VIR_DOMAIN_DISK_PROTOCOL_RBD:
case VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG:
@ -12314,7 +12315,7 @@ qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
virReportError(VIR_ERR_INTERNAL_ERROR,
_("external inactive snapshots are not supported on "
"'network' disks using '%s' protocol"),
virDomainDiskProtocolTypeToString(disk->protocol));
virDomainDiskProtocolTypeToString(disk->src.protocol));
return -1;
}
break;
@ -12504,7 +12505,7 @@ qemuDomainSnapshotPrepareDiskInternal(virConnectPtr conn,
return 0;
case VIR_DOMAIN_DISK_TYPE_NETWORK:
switch ((enum virDomainDiskProtocol) disk->protocol) {
switch ((enum virDomainDiskProtocol) disk->src.protocol) {
case VIR_DOMAIN_DISK_PROTOCOL_NBD:
case VIR_DOMAIN_DISK_PROTOCOL_RBD:
case VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG:
@ -12519,7 +12520,7 @@ qemuDomainSnapshotPrepareDiskInternal(virConnectPtr conn,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("internal inactive snapshots are not supported on "
"'network' disks using '%s' protocol"),
virDomainDiskProtocolTypeToString(disk->protocol));
virDomainDiskProtocolTypeToString(disk->src.protocol));
return -1;
}
break;
@ -12579,19 +12580,19 @@ qemuDomainSnapshotPrepare(virConnectPtr conn,
active) < 0)
goto cleanup;
if (dom_disk->type == VIR_DOMAIN_DISK_TYPE_NETWORK &&
(dom_disk->protocol == VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG ||
dom_disk->protocol == VIR_DOMAIN_DISK_PROTOCOL_RBD)) {
if (dom_disk->src.type == VIR_DOMAIN_DISK_TYPE_NETWORK &&
(dom_disk->src.protocol == VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG ||
dom_disk->src.protocol == VIR_DOMAIN_DISK_PROTOCOL_RBD)) {
break;
}
if (vm->def->disks[i]->format > 0 &&
vm->def->disks[i]->format != VIR_STORAGE_FILE_QCOW2) {
if (vm->def->disks[i]->src.format > 0 &&
vm->def->disks[i]->src.format != VIR_STORAGE_FILE_QCOW2) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("internal snapshot for disk %s unsupported "
"for storage type %s"),
disk->name,
virStorageFileFormatTypeToString(
vm->def->disks[i]->format));
vm->def->disks[i]->src.format));
goto cleanup;
}
break;
@ -12805,36 +12806,37 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
}
}
virDomainAuditDisk(vm, disk->src, source, "snapshot", ret >= 0);
virDomainAuditDisk(vm, disk->src.path, source, "snapshot", ret >= 0);
if (ret < 0)
goto cleanup;
/* Update vm in place to match changes. */
need_unlink = false;
VIR_FREE(disk->src);
virDomainDiskHostDefFree(disk->nhosts, disk->hosts);
VIR_FREE(disk->src.path);
virDomainDiskHostDefFree(disk->src.nhosts, disk->src.hosts);
disk->src = newsource;
disk->format = format;
disk->type = snap->type;
disk->protocol = snap->protocol;
disk->nhosts = snap->nhosts;
disk->hosts = newhosts;
disk->src.path = newsource;
disk->src.format = format;
disk->src.type = snap->type;
disk->src.protocol = snap->protocol;
disk->src.nhosts = snap->nhosts;
disk->src.hosts = newhosts;
newsource = NULL;
newhosts = NULL;
if (persistDisk) {
VIR_FREE(persistDisk->src);
virDomainDiskHostDefFree(persistDisk->nhosts, persistDisk->hosts);
VIR_FREE(persistDisk->src.path);
virDomainDiskHostDefFree(persistDisk->src.nhosts,
persistDisk->src.hosts);
persistDisk->src = persistSource;
persistDisk->format = format;
persistDisk->type = snap->type;
persistDisk->protocol = snap->protocol;
persistDisk->nhosts = snap->nhosts;
persistDisk->hosts = persistHosts;
persistDisk->src.path = persistSource;
persistDisk->src.format = format;
persistDisk->src.type = snap->type;
persistDisk->src.protocol = snap->protocol;
persistDisk->src.nhosts = snap->nhosts;
persistDisk->src.hosts = persistHosts;
persistSource = NULL;
persistHosts = NULL;
@ -12871,37 +12873,40 @@ qemuDomainSnapshotUndoSingleDiskActive(virQEMUDriverPtr driver,
diskfile = virStorageFileInitFromDiskDef(disk);
if (VIR_STRDUP(source, origdisk->src) < 0 ||
if (VIR_STRDUP(source, origdisk->src.path) < 0 ||
(persistDisk && VIR_STRDUP(persistSource, source) < 0))
goto cleanup;
qemuDomainPrepareDiskChainElement(driver, vm, disk, disk->src,
qemuDomainPrepareDiskChainElement(driver, vm, disk, disk->src.path,
VIR_DISK_CHAIN_NO_ACCESS);
if (need_unlink && diskfile &&
virStorageFileStat(diskfile, &st) == 0 && S_ISREG(st.st_mode) &&
virStorageFileUnlink(diskfile) < 0)
VIR_WARN("Unable to remove just-created %s", disk->src);
VIR_WARN("Unable to remove just-created %s", disk->src.path);
/* Update vm in place to match changes. */
VIR_FREE(disk->src);
disk->src = source;
VIR_FREE(disk->src.path);
disk->src.path = source;
source = NULL;
disk->format = origdisk->format;
disk->type = origdisk->type;
disk->protocol = origdisk->protocol;
virDomainDiskHostDefFree(disk->nhosts, disk->hosts);
disk->nhosts = origdisk->nhosts;
disk->hosts = virDomainDiskHostDefCopy(origdisk->nhosts, origdisk->hosts);
disk->src.format = origdisk->src.format;
disk->src.type = origdisk->src.type;
disk->src.protocol = origdisk->src.protocol;
virDomainDiskHostDefFree(disk->src.nhosts, disk->src.hosts);
disk->src.nhosts = origdisk->src.nhosts;
disk->src.hosts = virDomainDiskHostDefCopy(origdisk->src.nhosts,
origdisk->src.hosts);
if (persistDisk) {
VIR_FREE(persistDisk->src);
persistDisk->src = persistSource;
VIR_FREE(persistDisk->src.path);
persistDisk->src.path = persistSource;
persistSource = NULL;
persistDisk->format = origdisk->format;
persistDisk->type = origdisk->type;
persistDisk->protocol = origdisk->protocol;
virDomainDiskHostDefFree(persistDisk->nhosts, persistDisk->hosts);
persistDisk->nhosts = origdisk->nhosts;
persistDisk->hosts = virDomainDiskHostDefCopy(origdisk->nhosts, origdisk->hosts);
persistDisk->src.format = origdisk->src.format;
persistDisk->src.type = origdisk->src.type;
persistDisk->src.protocol = origdisk->src.protocol;
virDomainDiskHostDefFree(persistDisk->src.nhosts,
persistDisk->src.hosts);
persistDisk->src.nhosts = origdisk->src.nhosts;
persistDisk->src.hosts = virDomainDiskHostDefCopy(origdisk->src.nhosts,
origdisk->src.hosts);
}
cleanup:
@ -14744,15 +14749,15 @@ qemuDomainBlockPivot(virConnectPtr conn,
* label the entire chain. This action is safe even if the
* backing chain has already been labeled; but only necessary when
* we know for sure that there is a backing chain. */
oldsrc = disk->src;
oldformat = disk->format;
oldsrc = disk->src.path;
oldformat = disk->src.format;
oldchain = disk->backingChain;
disk->src = disk->mirror;
disk->format = disk->mirrorFormat;
disk->src.path = disk->mirror;
disk->src.format = disk->mirrorFormat;
disk->backingChain = NULL;
if (qemuDomainDetermineDiskChain(driver, vm, disk, false) < 0) {
disk->src = oldsrc;
disk->format = oldformat;
disk->src.path = oldsrc;
disk->src.format = oldformat;
disk->backingChain = oldchain;
goto cleanup;
}
@ -14762,8 +14767,8 @@ qemuDomainBlockPivot(virConnectPtr conn,
qemuSetupDiskCgroup(vm, disk) < 0 ||
virSecurityManagerSetImageLabel(driver->securityManager, vm->def,
disk) < 0)) {
disk->src = oldsrc;
disk->format = oldformat;
disk->src.path = oldsrc;
disk->src.format = oldformat;
disk->backingChain = oldchain;
goto cleanup;
}
@ -14793,8 +14798,8 @@ qemuDomainBlockPivot(virConnectPtr conn,
* 'query-block', to see what state we really got left in
* before killing the mirroring job? And just as on the
* success case, there's security labeling to worry about. */
disk->src = oldsrc;
disk->format = oldformat;
disk->src.path = oldsrc;
disk->src.format = oldformat;
virStorageFileFreeMetadata(disk->backingChain);
disk->backingChain = oldchain;
VIR_FREE(disk->mirror);
@ -14933,7 +14938,7 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
if (!async) {
int type = VIR_DOMAIN_BLOCK_JOB_TYPE_PULL;
int status = VIR_DOMAIN_BLOCK_JOB_CANCELED;
event = virDomainEventBlockJobNewFromObj(vm, disk->src, type,
event = virDomainEventBlockJobNewFromObj(vm, disk->src.path, type,
status);
} else if (!(flags & VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC)) {
while (1) {
@ -15142,7 +15147,7 @@ qemuDomainBlockCopy(virDomainObjPtr vm,
goto endjob;
VIR_FORCE_CLOSE(fd);
if (!format)
disk->mirrorFormat = disk->format;
disk->mirrorFormat = disk->src.format;
} else if (format) {
disk->mirrorFormat = virStorageFileFormatTypeFromString(format);
if (disk->mirrorFormat <= 0) {
@ -15302,7 +15307,7 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base,
goto endjob;
disk = vm->def->disks[idx];
if (!disk->src) {
if (!disk->src.path) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("disk %s has no source file to be committed"),
disk->dst);
@ -15312,10 +15317,10 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base,
goto endjob;
if (!top) {
top_canon = disk->src;
top_canon = disk->src.path;
top_meta = disk->backingChain;
} else if (!(top_canon = virStorageFileChainLookup(disk->backingChain,
disk->src,
disk->src.path,
top, &top_meta,
&top_parent))) {
virReportError(VIR_ERR_INVALID_ARG,
@ -15361,7 +15366,7 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base,
clean_access = true;
if (qemuDomainPrepareDiskChainElement(driver, vm, disk, base_canon,
VIR_DISK_CHAIN_READ_WRITE) < 0 ||
(top_parent && top_parent != disk->src &&
(top_parent && top_parent != disk->src.path &&
qemuDomainPrepareDiskChainElement(driver, vm, disk,
top_parent,
VIR_DISK_CHAIN_READ_WRITE) < 0))
@ -15383,7 +15388,7 @@ endjob:
/* Revert access to read-only, if possible. */
qemuDomainPrepareDiskChainElement(driver, vm, disk, base_canon,
VIR_DISK_CHAIN_READ_ONLY);
if (top_parent && top_parent != disk->src)
if (top_parent && top_parent != disk->src.path)
qemuDomainPrepareDiskChainElement(driver, vm, disk,
top_parent,
VIR_DISK_CHAIN_READ_ONLY);

View File

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

View File

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

View File

@ -1237,7 +1237,7 @@ virSecuritySELinuxSetSecurityFileLabel(virDomainDiskDefPtr disk,
if (!disk_seclabel)
return -1;
disk_seclabel->labelskip = true;
if (VIR_APPEND_ELEMENT(disk->seclabels, disk->nseclabels,
if (VIR_APPEND_ELEMENT(disk->src.seclabels, disk->src.nseclabels,
disk_seclabel) < 0) {
virSecurityDeviceLabelDefFree(disk_seclabel);
return -1;

View File

@ -2791,10 +2791,10 @@ virStorageFilePtr
virStorageFileInitFromDiskDef(virDomainDiskDefPtr disk)
{
return virStorageFileInitInternal(virDomainDiskGetActualType(disk),
disk->src,
disk->protocol,
disk->nhosts,
disk->hosts);
disk->src.path,
disk->src.protocol,
disk->src.nhosts,
disk->src.hosts);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2013 Red Hat, Inc.
* Copyright (C) 2011-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -169,11 +169,11 @@ testSELinuxLoadDef(const char *testname)
goto cleanup;
for (i = 0; i < def->ndisks; i++) {
if (def->disks[i]->type != VIR_DOMAIN_DISK_TYPE_FILE &&
def->disks[i]->type != VIR_DOMAIN_DISK_TYPE_BLOCK)
if (def->disks[i]->src.type != VIR_DOMAIN_DISK_TYPE_FILE &&
def->disks[i]->src.type != VIR_DOMAIN_DISK_TYPE_BLOCK)
continue;
if (testSELinuxMungePath(&def->disks[i]->src) < 0)
if (testSELinuxMungePath(&def->disks[i]->src.path) < 0)
goto cleanup;
}