snapshot: reject transient disks where code is not ready

The previous patch introduced new config, but if a hypervisor does
not support that new config, someone can write XML that does not
behave as documented.  This prevents some of those cases by
explicitly rejecting transient disks for several hypervisors.

Disk snapshots will require a new flag to actually affect a snapshot
creation, so there's not much to reject there.

* src/qemu/qemu_command.c (qemuBuildDriveStr): Reject transient
disks for now.
* src/libxl/libxl_conf.c (libxlMakeDisk): Likewise.
* src/xenxs/xen_sxpr.c (xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenFormatXMDisk): Likewise.
This commit is contained in:
Eric Blake 2011-08-13 15:42:48 -06:00
parent 471235307f
commit e91d27ee45
4 changed files with 20 additions and 0 deletions

View File

@ -537,6 +537,11 @@ libxlMakeDisk(virDomainDefPtr def, virDomainDiskDefPtr l_disk,
x_disk->unpluggable = 1;
x_disk->readwrite = !l_disk->readonly;
x_disk->is_cdrom = l_disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM ? 1 : 0;
if (l_disk->transient) {
libxlError(VIR_ERR_INTERNAL_ERROR, "%s",
_("libxenlight does not support transient disks"));
return -1;
}
x_disk->domid = def->id;

View File

@ -1594,6 +1594,11 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
if (disk->readonly &&
qemuCapsGet(qemuCaps, QEMU_CAPS_DRIVE_READONLY))
virBufferAddLit(&opt, ",readonly=on");
if (disk->transient) {
qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("transient disks not supported yet"));
goto error;
}
if (disk->driverType && *disk->driverType != '\0' &&
disk->type != VIR_DOMAIN_DISK_TYPE_DIR &&
qemuCapsGet(qemuCaps, QEMU_CAPS_DRIVE_FORMAT))

View File

@ -1713,6 +1713,11 @@ xenFormatSxprDisk(virDomainDiskDefPtr def,
virBufferAddLit(buf, "(mode 'w!')");
else
virBufferAddLit(buf, "(mode 'w')");
if (def->transient) {
XENXS_ERROR(VIR_ERR_CONFIG_UNSUPPORTED,
_("transient disks not supported yet"));
return -1;
}
if (!isAttach)
virBufferAddLit(buf, ")");

View File

@ -1164,6 +1164,11 @@ static int xenFormatXMDisk(virConfValuePtr list,
virBufferAddLit(&buf, ",!");
else
virBufferAddLit(&buf, ",w");
if (disk->transient) {
XENXS_ERROR(VIR_ERR_CONFIG_UNSUPPORTED,
_("transient disks not supported yet"));
return -1;
}
if (virBufferError(&buf)) {
virReportOOMError();