]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuDomainDiskChangeSupported: Deny changing reservations
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 14 Dec 2017 10:47:02 +0000 (11:47 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 11 May 2018 07:02:56 +0000 (09:02 +0200)
Couple of reasons for that:

a) there's no monitor command to change path where the pr-helper
connects to, or
b) there's no monitor command to introduce a new pr-helper for a
disk that already exists.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/libvirt_private.syms
src/qemu/qemu_domain.c
src/util/virstoragefile.c
src/util/virstoragefile.h

index e3326a9a4a81ec54308afb1f4292751130aacbbf..7b93b42264575b1e008aa34742b010466bd9611f 100644 (file)
@@ -2803,6 +2803,7 @@ virStorageNetHostTransportTypeToString;
 virStorageNetProtocolTypeToString;
 virStoragePRDefFormat;
 virStoragePRDefFree;
+virStoragePRDefIsEqual;
 virStoragePRDefParseXML;
 virStorageSourceBackingStoreClear;
 virStorageSourceClear;
index 9bb6d8a5be98c0cf08eb23a4486cd823f1e3d911..c14615fa7364447b5068f82c6dc251949cf6ec51 100644 (file)
@@ -7842,6 +7842,14 @@ qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk,
     CHECK_EQ(src->readonly, "readonly", true);
     CHECK_EQ(src->shared, "shared", true);
 
+    if (!virStoragePRDefIsEqual(disk->src->pr,
+                                orig_disk->src->pr)) {
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
+                       _("cannot modify field '%s' of the disk"),
+                       "reservations");
+        return false;
+    }
+
 #undef CHECK_EQ
 
     return true;
index 10e09f01e6dd5742cf0a95a96ab872bc8681d42d..46ae1ba8fb51fa074dc07a9df4a2db914a6dd9da 100644 (file)
@@ -2022,6 +2022,25 @@ virStoragePRDefFormat(virBufferPtr buf,
 }
 
 
+bool
+virStoragePRDefIsEqual(virStoragePRDefPtr a,
+                       virStoragePRDefPtr b)
+{
+    if (!a && !b)
+        return true;
+
+    if (!a || !b)
+        return false;
+
+    if (a->enabled != b->enabled ||
+        a->managed != b->managed ||
+        STRNEQ_NULLABLE(a->path, b->path))
+        return false;
+
+    return true;
+}
+
+
 virSecurityDeviceLabelDefPtr
 virStorageSourceGetSecurityLabelDef(virStorageSourcePtr src,
                                     const char *model)
index ce2d684d07ef3d44467c53411ecf5b007a49ae8b..7240a20fd60058ce8e1b4d1460b1c51f11688dd7 100644 (file)
@@ -395,6 +395,8 @@ void virStoragePRDefFree(virStoragePRDefPtr prd);
 virStoragePRDefPtr virStoragePRDefParseXML(xmlXPathContextPtr ctxt);
 void virStoragePRDefFormat(virBufferPtr buf,
                            virStoragePRDefPtr prd);
+bool virStoragePRDefIsEqual(virStoragePRDefPtr a,
+                            virStoragePRDefPtr b);
 
 virSecurityDeviceLabelDefPtr
 virStorageSourceGetSecurityLabelDef(virStorageSourcePtr src,