storage: Move readonly and shared flags to disk source from disk def

In the future we might need to track state of individual images. Move
the readonly and shared flags to the virStorageSource struct so that we
can keep them in a per-image basis.
This commit is contained in:
Peter Krempa 2014-06-24 15:15:55 +02:00
parent f2b26dff1f
commit 63834faadb
19 changed files with 77 additions and 67 deletions

View File

@ -5495,9 +5495,9 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error;
}
} else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) {
def->readonly = true;
def->src->readonly = true;
} else if (xmlStrEqual(cur->name, BAD_CAST "shareable")) {
def->shared = true;
def->src->shared = true;
} else if (xmlStrEqual(cur->name, BAD_CAST "transient")) {
def->transient = true;
} else if ((flags & VIR_DOMAIN_XML_INTERNAL_STATUS) &&
@ -5624,7 +5624,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
/* Force CDROM to be listed as read only */
if (def->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
def->readonly = true;
def->src->readonly = true;
if ((def->device == VIR_DOMAIN_DISK_DEVICE_DISK ||
def->device == VIR_DOMAIN_DISK_DEVICE_LUN) &&
@ -5646,7 +5646,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
snapshot);
goto error;
}
} else if (def->readonly) {
} else if (def->src->readonly) {
def->snapshot = VIR_DOMAIN_SNAPSHOT_LOCATION_NONE;
}
@ -13349,7 +13349,8 @@ virDomainDiskDefCheckABIStability(virDomainDiskDefPtr src,
return false;
}
if (src->readonly != dst->readonly || src->shared != dst->shared) {
if (src->src->readonly != dst->src->readonly ||
src->src->shared != dst->src->shared) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Target disk access mode does not match source"));
return false;
@ -15096,7 +15097,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
virBufferAsprintf(buf, " sgio='%s'", sgio);
if (def->snapshot &&
!(def->snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_NONE && def->readonly))
!(def->snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_NONE &&
def->src->readonly))
virBufferAsprintf(buf, " snapshot='%s'",
virDomainSnapshotLocationTypeToString(def->snapshot));
virBufferAddLit(buf, ">\n");
@ -15235,9 +15237,9 @@ virDomainDiskDefFormat(virBufferPtr buf,
virBufferAddLit(buf, "</iotune>\n");
}
if (def->readonly)
if (def->src->readonly)
virBufferAddLit(buf, "<readonly/>\n");
if (def->shared)
if (def->src->shared)
virBufferAddLit(buf, "<shareable/>\n");
if (def->transient)
virBufferAddLit(buf, "<transient/>\n");

View File

@ -636,8 +636,6 @@ struct _virDomainDiskDef {
int copy_on_read; /* enum virDomainDiskCopyOnRead */
int snapshot; /* virDomainSnapshotLocation, snapshot_conf.h */
int startupPolicy; /* enum virDomainStartupPolicy */
bool readonly;
bool shared;
bool transient;
virDomainDeviceInfo info;
bool rawio_specified;

View File

@ -827,7 +827,7 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk)
/* XXX is this right? */
x_disk->removable = 1;
x_disk->readwrite = !l_disk->readonly;
x_disk->readwrite = !l_disk->src->readonly;
x_disk->is_cdrom = l_disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM ? 1 : 0;
/* An empty CDROM must have the empty format, otherwise libxl fails. */
if (x_disk->is_cdrom && !x_disk->pdev_path)

View File

@ -83,9 +83,9 @@ static int virDomainLockManagerAddDisk(virLockManagerPtr lock,
type == VIR_STORAGE_TYPE_DIR))
return 0;
if (disk->readonly)
if (disk->src->readonly)
diskFlags |= VIR_LOCK_MANAGER_RESOURCE_READONLY;
if (disk->shared)
if (disk->src->shared)
diskFlags |= VIR_LOCK_MANAGER_RESOURCE_SHARED;
VIR_DEBUG("Add disk %s", src);

View File

@ -380,7 +380,7 @@ static int virLXCCgroupSetupDeviceACL(virDomainDefPtr def,
if (virCgroupAllowDevicePath(cgroup,
virDomainDiskGetSource(def->disks[i]),
(def->disks[i]->readonly ?
(def->disks[i]->src->readonly ?
VIR_CGROUP_DEVICE_READ :
VIR_CGROUP_DEVICE_RW) |
VIR_CGROUP_DEVICE_MKNOD) < 0)

View File

@ -455,7 +455,7 @@ static int virLXCControllerSetupNBDDeviceDisk(virDomainDiskDefPtr disk)
if (virFileNBDDeviceAssociate(src,
format,
disk->readonly,
disk->src->readonly,
&dev) < 0)
return -1;

View File

@ -4057,7 +4057,7 @@ lxcDomainAttachDeviceDiskLive(virLXCDriverPtr driver,
goto cleanup;
}
perms = (def->readonly ?
perms = (def->src->readonly ?
VIR_CGROUP_DEVICE_READ :
VIR_CGROUP_DEVICE_RW) |
VIR_CGROUP_DEVICE_MKNOD;

View File

@ -61,10 +61,10 @@ qemuSetupDiskPathAllow(virDomainDiskDefPtr disk,
VIR_DEBUG("Process path %s for disk", path);
ret = virCgroupAllowDevicePath(priv->cgroup, path,
(disk->readonly ? VIR_CGROUP_DEVICE_READ
(disk->src->readonly ? VIR_CGROUP_DEVICE_READ
: VIR_CGROUP_DEVICE_RW));
virDomainAuditCgroupPath(vm, priv->cgroup, "allow", path,
disk->readonly ? "r" : "rw", ret == 0);
disk->src->readonly ? "r" : "rw", ret == 0);
/* Get this for root squash NFS */
if (ret < 0 &&

View File

@ -3344,7 +3344,7 @@ qemuBuildDriveStr(virConnectPtr conn,
goto error;
}
if (!disk->readonly) {
if (!disk->src->readonly) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot create virtual FAT disks in read-write mode"));
goto error;
@ -3412,7 +3412,7 @@ qemuBuildDriveStr(virConnectPtr conn,
disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) &&
disk->bus != VIR_DOMAIN_DISK_BUS_IDE)
virBufferAddLit(&opt, ",boot=on");
if (disk->readonly &&
if (disk->src->readonly &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_READONLY)) {
if (disk->bus == VIR_DOMAIN_DISK_BUS_IDE &&
disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
@ -3478,7 +3478,7 @@ qemuBuildDriveStr(virConnectPtr conn,
}
virBufferAsprintf(&opt, ",cache=%s", mode);
} else if (disk->shared && !disk->readonly) {
} else if (disk->src->shared && !disk->src->readonly) {
virBufferAddLit(&opt, ",cache=off");
}
@ -8005,7 +8005,7 @@ qemuBuildCommandLine(virConnectPtr conn,
virStorageFileFormatTypeToString(disk->src->format));
goto error;
}
if (!disk->readonly) {
if (!disk->src->readonly) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot create virtual FAT disks in read-write mode"));
goto error;
@ -9629,7 +9629,7 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
} else if (STREQ(keywords[i], "media")) {
if (STREQ(values[i], "cdrom")) {
def->device = VIR_DOMAIN_DISK_DEVICE_CDROM;
def->readonly = true;
def->src->readonly = true;
} else if (STREQ(values[i], "floppy"))
def->device = VIR_DOMAIN_DISK_DEVICE_FLOPPY;
} else if (STREQ(keywords[i], "format")) {
@ -9685,7 +9685,7 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
}
} else if (STREQ(keywords[i], "readonly")) {
if ((values[i] == NULL) || STREQ(values[i], "on"))
def->readonly = true;
def->src->readonly = true;
} else if (STREQ(keywords[i], "aio")) {
if ((def->iomode = virDomainDiskIoTypeFromString(values[i])) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@ -10853,7 +10853,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
disk->bus = VIR_DOMAIN_DISK_BUS_SCSI;
if (VIR_STRDUP(disk->dst, "hdc") < 0)
goto error;
disk->readonly = true;
disk->src->readonly = true;
} else {
if (STRPREFIX(arg, "-fd")) {
disk->device = VIR_DOMAIN_DISK_DEVICE_FLOPPY;

View File

@ -906,7 +906,7 @@ qemuAddSharedDevice(virQEMUDriverPtr driver,
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
disk = dev->data.disk;
if (!disk->shared || !virDomainDiskSourceIsBlockType(disk))
if (!disk->src->shared || !virDomainDiskSourceIsBlockType(disk))
return 0;
} else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
hostdev = dev->data.hostdev;
@ -1013,7 +1013,7 @@ qemuRemoveSharedDevice(virQEMUDriverPtr driver,
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
disk = dev->data.disk;
if (!disk->shared || !virDomainDiskSourceIsBlockType(disk))
if (!disk->src->shared || !virDomainDiskSourceIsBlockType(disk))
return 0;
} else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
hostdev = dev->data.hostdev;

View File

@ -12082,7 +12082,7 @@ qemuDomainPrepareDiskChainElement(virQEMUDriverPtr driver,
* permissions it would have as if part of the disk chain is to
* temporarily modify the disk in place. */
virStorageSource origdisk;
bool origreadonly = disk->readonly;
bool origreadonly = disk->src->readonly;
virQEMUDriverConfigPtr cfg = NULL;
int ret = -1;
@ -12097,7 +12097,7 @@ qemuDomainPrepareDiskChainElement(virQEMUDriverPtr driver,
* than a full virDomainDiskDef. */
memcpy(&origdisk, disk->src, sizeof(origdisk));
memcpy(disk->src, elem, sizeof(*elem));
disk->readonly = mode == VIR_DISK_CHAIN_READ_ONLY;
disk->src->readonly = mode == VIR_DISK_CHAIN_READ_ONLY;
if (mode == VIR_DISK_CHAIN_NO_ACCESS) {
if (virSecurityManagerRestoreDiskLabel(driver->securityManager,
@ -12120,7 +12120,7 @@ qemuDomainPrepareDiskChainElement(virQEMUDriverPtr driver,
cleanup:
memcpy(disk->src, &origdisk, sizeof(origdisk));
disk->readonly = origreadonly;
disk->src->readonly = origreadonly;
virObjectUnref(cfg);
return ret;
}
@ -12772,7 +12772,7 @@ qemuDomainSnapshotPrepare(virConnectPtr conn,
case VIR_DOMAIN_SNAPSHOT_LOCATION_NONE:
/* Remember seeing a disk that has snapshot disabled */
if (!dom_disk->readonly)
if (!dom_disk->src->readonly)
forbid_internal = true;
break;

View File

@ -1156,7 +1156,8 @@ qemuMigrationStartNBDServer(virQEMUDriverPtr driver,
virDomainDiskDefPtr disk = vm->def->disks[i];
/* skip shared, RO and source-less disks */
if (disk->shared || disk->readonly || !virDomainDiskGetSource(disk))
if (disk->src->shared || disk->src->readonly ||
!virDomainDiskGetSource(disk))
continue;
VIR_FREE(diskAlias);
@ -1262,7 +1263,8 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
virDomainBlockJobInfo info;
/* skip shared, RO and source-less disks */
if (disk->shared || disk->readonly || !virDomainDiskGetSource(disk))
if (disk->src->shared || disk->src->readonly ||
!virDomainDiskGetSource(disk))
continue;
VIR_FREE(diskAlias);
@ -1348,7 +1350,8 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
virDomainDiskDefPtr disk = vm->def->disks[--lastGood];
/* skip shared, RO disks */
if (disk->shared || disk->readonly || !virDomainDiskGetSource(disk))
if (disk->src->shared || disk->src->readonly ||
!virDomainDiskGetSource(disk))
continue;
VIR_FREE(diskAlias);
@ -1411,7 +1414,8 @@ qemuMigrationCancelDriveMirror(qemuMigrationCookiePtr mig,
virDomainDiskDefPtr disk = vm->def->disks[i];
/* skip shared, RO and source-less disks */
if (disk->shared || disk->readonly || !virDomainDiskGetSource(disk))
if (disk->src->shared || disk->src->readonly ||
!virDomainDiskGetSource(disk))
continue;
VIR_FREE(diskAlias);
@ -1540,8 +1544,8 @@ qemuMigrationIsSafe(virDomainDefPtr def)
/* Our code elsewhere guarantees shared disks are either readonly (in
* which case cache mode doesn't matter) or used with cache=none */
if (src &&
!disk->shared &&
!disk->readonly &&
!disk->src->shared &&
!disk->src->readonly &&
disk->cachemode != VIR_DOMAIN_DISK_CACHE_DISABLE) {
int rc;

View File

@ -383,7 +383,7 @@ virSecurityDACRestoreSecurityImageLabelInt(virSecurityManagerPtr mgr,
* we can't see running VMs using the file on other nodes
* Safest bet is thus to skip the restore step.
*/
if (disk->readonly || disk->shared)
if (disk->src->readonly || disk->src->shared)
return 0;
if (!src)

View File

@ -1155,7 +1155,7 @@ virSecuritySELinuxRestoreSecurityImageLabelInt(virSecurityManagerPtr mgr,
* we can't see running VMs using the file on other nodes
* Safest bet is thus to skip the restore step.
*/
if (disk->readonly || disk->shared)
if (disk->src->readonly || disk->src->shared)
return 0;
if (!src || virDomainDiskGetType(disk) == VIR_STORAGE_TYPE_NETWORK)
@ -1213,9 +1213,9 @@ virSecuritySELinuxSetSecurityFileLabel(virDomainDiskDefPtr disk,
ret = virSecuritySELinuxSetFilecon(path, disk_seclabel->label);
} else if (depth == 0) {
if (disk->shared) {
if (disk->src->shared) {
ret = virSecuritySELinuxSetFileconOptional(path, data->file_context);
} else if (disk->readonly) {
} else if (disk->src->readonly) {
ret = virSecuritySELinuxSetFileconOptional(path, data->content_context);
} else if (secdef->imagelabel) {
ret = virSecuritySELinuxSetFileconOptional(path, secdef->imagelabel);

View File

@ -907,7 +907,7 @@ add_file_path(virDomainDiskDefPtr disk,
int ret;
if (depth == 0) {
if (disk->readonly)
if (disk->src->readonly)
ret = vah_add_file(buf, path, "r");
else
ret = vah_add_file(buf, path, "rw");

View File

@ -255,6 +255,12 @@ struct _virStorageSource {
size_t nseclabels;
virSecurityDeviceLabelDefPtr *seclabels;
/* Don't ever write to the image */
bool readonly;
/* image is shared across hosts */
bool shared;
/* backing chain of the storage source */
virStorageSourcePtr backingStore;

View File

@ -2791,7 +2791,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) {
hardDiskPM->vtbl->GetType(hardDiskPM, &hddType);
if (hddType == HardDiskType_Immutable)
def->disks[hddNum]->readonly = true;
def->disks[hddNum]->src->readonly = true;
ignore_value(virDomainDiskSetSource(def->disks[hddNum],
hddlocation));
ignore_value(VIR_STRDUP(def->disks[hddNum]->dst, "hda"));
@ -2813,7 +2813,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) {
hardDiskPS->vtbl->GetType(hardDiskPS, &hddType);
if (hddType == HardDiskType_Immutable)
def->disks[hddNum]->readonly = true;
def->disks[hddNum]->src->readonly = true;
ignore_value(virDomainDiskSetSource(def->disks[hddNum],
hddlocation));
ignore_value(VIR_STRDUP(def->disks[hddNum]->dst, "hdb"));
@ -2835,7 +2835,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) {
hardDiskSS->vtbl->GetType(hardDiskSS, &hddType);
if (hddType == HardDiskType_Immutable)
def->disks[hddNum]->readonly = true;
def->disks[hddNum]->src->readonly = true;
ignore_value(virDomainDiskSetSource(def->disks[hddNum],
hddlocation));
ignore_value(VIR_STRDUP(def->disks[hddNum]->dst, "hdd"));
@ -2977,7 +2977,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) {
medium->vtbl->GetReadOnly(medium, &readOnly);
if (readOnly == PR_TRUE)
def->disks[diskCount]->readonly = true;
def->disks[diskCount]->src->readonly = true;
virDomainDiskSetType(def->disks[diskCount],
VIR_STORAGE_TYPE_FILE);
@ -3257,7 +3257,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) {
def->disks[def->ndisks - 1]->bus = VIR_DOMAIN_DISK_BUS_IDE;
virDomainDiskSetType(def->disks[def->ndisks - 1],
VIR_STORAGE_TYPE_FILE);
def->disks[def->ndisks - 1]->readonly = true;
def->disks[def->ndisks - 1]->src->readonly = true;
ignore_value(virDomainDiskSetSource(def->disks[def->ndisks - 1], location));
ignore_value(VIR_STRDUP(def->disks[def->ndisks - 1]->dst, "hdc"));
def->ndisks--;
@ -3304,7 +3304,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) {
def->disks[def->ndisks - 1]->bus = VIR_DOMAIN_DISK_BUS_FDC;
virDomainDiskSetType(def->disks[def->ndisks - 1],
VIR_STORAGE_TYPE_FILE);
def->disks[def->ndisks - 1]->readonly = false;
def->disks[def->ndisks - 1]->src->readonly = false;
ignore_value(virDomainDiskSetSource(def->disks[def->ndisks - 1], location));
ignore_value(VIR_STRDUP(def->disks[def->ndisks - 1]->dst, "fda"));
def->ndisks--;
@ -3910,9 +3910,9 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
VIR_DEBUG("disk(%zu) driverType: %s", i,
virStorageFileFormatTypeToString(format));
VIR_DEBUG("disk(%zu) cachemode: %d", i, def->disks[i]->cachemode);
VIR_DEBUG("disk(%zu) readonly: %s", i, (def->disks[i]->readonly
VIR_DEBUG("disk(%zu) readonly: %s", i, (def->disks[i]->src->readonly
? "True" : "False"));
VIR_DEBUG("disk(%zu) shared: %s", i, (def->disks[i]->shared
VIR_DEBUG("disk(%zu) shared: %s", i, (def->disks[i]->src->shared
? "True" : "False"));
if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
@ -4014,11 +4014,11 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
"attached as harddisk: %s, rc=%08x"),
src, (unsigned)rc);
} else {
if (def->disks[i]->readonly) {
if (def->disks[i]->src->readonly) {
hardDisk->vtbl->SetType(hardDisk,
HardDiskType_Immutable);
VIR_DEBUG("setting harddisk to readonly");
} else if (!def->disks[i]->readonly) {
} else if (!def->disks[i]->src->readonly) {
hardDisk->vtbl->SetType(hardDisk,
HardDiskType_Normal);
VIR_DEBUG("setting harddisk type to normal");
@ -4193,9 +4193,9 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
VIR_DEBUG("disk(%zu) driverType: %s", i,
virStorageFileFormatTypeToString(format));
VIR_DEBUG("disk(%zu) cachemode: %d", i, def->disks[i]->cachemode);
VIR_DEBUG("disk(%zu) readonly: %s", i, (def->disks[i]->readonly
VIR_DEBUG("disk(%zu) readonly: %s", i, (def->disks[i]->src->readonly
? "True" : "False"));
VIR_DEBUG("disk(%zu) shared: %s", i, (def->disks[i]->shared
VIR_DEBUG("disk(%zu) shared: %s", i, (def->disks[i]->src->shared
? "True" : "False"));
if (type == VIR_STORAGE_TYPE_FILE && src) {
@ -4317,10 +4317,10 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
}
if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
if (def->disks[i]->readonly) {
if (def->disks[i]->src->readonly) {
medium->vtbl->SetType(medium, MediumType_Immutable);
VIR_DEBUG("setting harddisk to immutable");
} else if (!def->disks[i]->readonly) {
} else if (!def->disks[i]->src->readonly) {
medium->vtbl->SetType(medium, MediumType_Normal);
VIR_DEBUG("setting harddisk type to normal");
}
@ -7500,7 +7500,7 @@ int vboxSnapshotGetReadOnlyDisks(virDomainSnapshotPtr snapshot,
goto cleanup;
}
if (readOnly == PR_TRUE)
def->dom->disks[diskCount]->readonly = true;
def->dom->disks[diskCount]->src->readonly = true;
def->dom->disks[diskCount]->src->type = VIR_STORAGE_TYPE_FILE;
def->dom->disks[diskCount]->dst = vboxGenerateMediumName(storageBus,
deviceInst,

View File

@ -495,10 +495,10 @@ xenParseSxprDisks(virDomainDefPtr def,
if (mode &&
strchr(mode, 'r'))
disk->readonly = true;
disk->src->readonly = true;
if (mode &&
strchr(mode, '!'))
disk->shared = true;
disk->src->shared = true;
if (VIR_REALLOC_N(def->disks, def->ndisks+1) < 0)
goto error;
@ -1321,7 +1321,7 @@ xenParseSxpr(const struct sexpr *root,
goto error;
}
disk->bus = VIR_DOMAIN_DISK_BUS_IDE;
disk->readonly = true;
disk->src->readonly = true;
if (VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk) < 0) {
virDomainDiskDefFree(disk);
@ -1816,9 +1816,9 @@ xenFormatSxprDisk(virDomainDiskDefPtr def,
}
}
if (def->readonly)
if (def->src->readonly)
virBufferAddLit(buf, "(mode 'r')");
else if (def->shared)
else if (def->src->shared)
virBufferAddLit(buf, "(mode 'w!')");
else
virBufferAddLit(buf, "(mode 'w')");

View File

@ -625,10 +625,10 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
if (STREQ(head, "r") ||
STREQ(head, "ro"))
disk->readonly = true;
disk->src->readonly = true;
else if ((STREQ(head, "w!")) ||
(STREQ(head, "!")))
disk->shared = true;
disk->src->shared = true;
/* Maintain list in sorted order according to target device name */
if (VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk) < 0)
@ -656,7 +656,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
if (VIR_STRDUP(disk->dst, "hdc") < 0)
goto cleanup;
disk->bus = VIR_DOMAIN_DISK_BUS_IDE;
disk->readonly = true;
disk->src->readonly = true;
if (VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk) < 0)
goto cleanup;
@ -1249,9 +1249,9 @@ xenFormatXMDisk(virConfValuePtr list,
if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
virBufferAddLit(&buf, ":cdrom");
if (disk->readonly)
if (disk->src->readonly)
virBufferAddLit(&buf, ",r");
else if (disk->shared)
else if (disk->src->shared)
virBufferAddLit(&buf, ",!");
else
virBufferAddLit(&buf, ",w");