[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCHv4 36/51] 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.
---
 src/libxl/libxl_conf.c  |    5 +++++
 src/qemu/qemu_command.c |    5 +++++
 src/xenxs/xen_sxpr.c    |    5 +++++
 src/xenxs/xen_xm.c      |    5 +++++
 4 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 09f3be8..b9bce14 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -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;

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 44a553b..24b34b6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1504,6 +1504,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))
diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c
index 1a8a541..5e278ae 100644
--- a/src/xenxs/xen_sxpr.c
+++ b/src/xenxs/xen_sxpr.c
@@ -1710,6 +1710,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, ")");
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index cb31226..03857c8 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -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();
-- 
1.7.4.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]