1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-27 18:03:50 +03:00

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

View File

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

View File

@ -827,7 +827,7 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk)
/* XXX is this right? */ /* XXX is this right? */
x_disk->removable = 1; 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; 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. */ /* An empty CDROM must have the empty format, otherwise libxl fails. */
if (x_disk->is_cdrom && !x_disk->pdev_path) 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)) type == VIR_STORAGE_TYPE_DIR))
return 0; return 0;
if (disk->readonly) if (disk->src->readonly)
diskFlags |= VIR_LOCK_MANAGER_RESOURCE_READONLY; diskFlags |= VIR_LOCK_MANAGER_RESOURCE_READONLY;
if (disk->shared) if (disk->src->shared)
diskFlags |= VIR_LOCK_MANAGER_RESOURCE_SHARED; diskFlags |= VIR_LOCK_MANAGER_RESOURCE_SHARED;
VIR_DEBUG("Add disk %s", src); VIR_DEBUG("Add disk %s", src);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -906,7 +906,7 @@ qemuAddSharedDevice(virQEMUDriverPtr driver,
if (dev->type == VIR_DOMAIN_DEVICE_DISK) { if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
disk = dev->data.disk; disk = dev->data.disk;
if (!disk->shared || !virDomainDiskSourceIsBlockType(disk)) if (!disk->src->shared || !virDomainDiskSourceIsBlockType(disk))
return 0; return 0;
} else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) { } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
hostdev = dev->data.hostdev; hostdev = dev->data.hostdev;
@ -1013,7 +1013,7 @@ qemuRemoveSharedDevice(virQEMUDriverPtr driver,
if (dev->type == VIR_DOMAIN_DEVICE_DISK) { if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
disk = dev->data.disk; disk = dev->data.disk;
if (!disk->shared || !virDomainDiskSourceIsBlockType(disk)) if (!disk->src->shared || !virDomainDiskSourceIsBlockType(disk))
return 0; return 0;
} else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) { } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
hostdev = dev->data.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 * permissions it would have as if part of the disk chain is to
* temporarily modify the disk in place. */ * temporarily modify the disk in place. */
virStorageSource origdisk; virStorageSource origdisk;
bool origreadonly = disk->readonly; bool origreadonly = disk->src->readonly;
virQEMUDriverConfigPtr cfg = NULL; virQEMUDriverConfigPtr cfg = NULL;
int ret = -1; int ret = -1;
@ -12097,7 +12097,7 @@ qemuDomainPrepareDiskChainElement(virQEMUDriverPtr driver,
* than a full virDomainDiskDef. */ * than a full virDomainDiskDef. */
memcpy(&origdisk, disk->src, sizeof(origdisk)); memcpy(&origdisk, disk->src, sizeof(origdisk));
memcpy(disk->src, elem, sizeof(*elem)); 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 (mode == VIR_DISK_CHAIN_NO_ACCESS) {
if (virSecurityManagerRestoreDiskLabel(driver->securityManager, if (virSecurityManagerRestoreDiskLabel(driver->securityManager,
@ -12120,7 +12120,7 @@ qemuDomainPrepareDiskChainElement(virQEMUDriverPtr driver,
cleanup: cleanup:
memcpy(disk->src, &origdisk, sizeof(origdisk)); memcpy(disk->src, &origdisk, sizeof(origdisk));
disk->readonly = origreadonly; disk->src->readonly = origreadonly;
virObjectUnref(cfg); virObjectUnref(cfg);
return ret; return ret;
} }
@ -12772,7 +12772,7 @@ qemuDomainSnapshotPrepare(virConnectPtr conn,
case VIR_DOMAIN_SNAPSHOT_LOCATION_NONE: case VIR_DOMAIN_SNAPSHOT_LOCATION_NONE:
/* Remember seeing a disk that has snapshot disabled */ /* Remember seeing a disk that has snapshot disabled */
if (!dom_disk->readonly) if (!dom_disk->src->readonly)
forbid_internal = true; forbid_internal = true;
break; break;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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