]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: storage: Allow passing <source> also for managed PR case
authorPeter Krempa <pkrempa@redhat.com>
Mon, 14 May 2018 05:25:43 +0000 (07:25 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 16 May 2018 04:32:28 +0000 (06:32 +0200)
To allow storing status information in the XML move the validation that
the 'path' is not valid for managed PR daemon case into
qemuDomainValidateStorageSource and allow parsing of the data even in
case when managed='yes'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_domain.c
src/util/virstoragefile.c

index 9c9a1bda6aa0593bf1543cac7a8d9482e27b7b2d..7e37d778f855313a6a9331b3e5096967c8ee03d8 100644 (file)
@@ -4204,11 +4204,19 @@ qemuDomainValidateStorageSource(virStorageSourcePtr src,
         }
     }
 
-    if (src->pr &&
-        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_PR_MANAGER_HELPER)) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("reservations not supported with this QEMU binary"));
-        return -1;
+    if (src->pr) {
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PR_MANAGER_HELPER)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("reservations not supported with this QEMU binary"));
+            return -1;
+        }
+
+        if (virStoragePRDefIsManaged(src->pr) && src->pr->path) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("'path' attribute should not be provided for "
+                             "managed reservations"));
+            return -1;
+        }
     }
 
     return 0;
index c89bdb9e494487914a65ff693522b9b051f2b020..dbbe758f30f2984eba8de7a8b0b7e602efd8f968 100644 (file)
@@ -1928,11 +1928,11 @@ virStoragePRDefParseXML(xmlXPathContextPtr ctxt)
         goto cleanup;
     }
 
-    if (prd->managed == VIR_TRISTATE_BOOL_NO) {
-        type = virXPathString("string(./source[1]/@type)", ctxt);
-        path = virXPathString("string(./source[1]/@path)", ctxt);
-        mode = virXPathString("string(./source[1]/@mode)", ctxt);
+    type = virXPathString("string(./source[1]/@type)", ctxt);
+    path = virXPathString("string(./source[1]/@path)", ctxt);
+    mode = virXPathString("string(./source[1]/@mode)", ctxt);
 
+    if (prd->managed == VIR_TRISTATE_BOOL_NO || type || path || mode) {
         if (!type) {
             virReportError(VIR_ERR_XML_ERROR, "%s",
                            _("missing connection type for <reservations/>"));
@@ -1950,24 +1950,23 @@ virStoragePRDefParseXML(xmlXPathContextPtr ctxt)
                            _("missing connection mode for <reservations/>"));
             goto cleanup;
         }
+    }
 
-        if (STRNEQ(type, "unix")) {
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("unsupported connection type for <reservations/>: %s"),
-                           type);
-            goto cleanup;
-        }
-
-        if (STRNEQ(mode, "client")) {
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("unsupported connection mode for <reservations/>: %s"),
-                           mode);
-            goto cleanup;
-        }
+    if (type && STRNEQ(type, "unix")) {
+        virReportError(VIR_ERR_XML_ERROR,
+                       _("unsupported connection type for <reservations/>: %s"),
+                       type);
+        goto cleanup;
+    }
 
-        VIR_STEAL_PTR(prd->path, path);
+    if (mode && STRNEQ(mode, "client")) {
+        virReportError(VIR_ERR_XML_ERROR,
+                       _("unsupported connection mode for <reservations/>: %s"),
+                       mode);
+        goto cleanup;
     }
 
+    VIR_STEAL_PTR(prd->path, path);
     VIR_STEAL_PTR(ret, prd);
 
  cleanup:
@@ -1986,7 +1985,7 @@ virStoragePRDefFormat(virBufferPtr buf,
 {
     virBufferAsprintf(buf, "<reservations managed='%s'",
                       virTristateBoolTypeToString(prd->managed));
-    if (prd->managed == VIR_TRISTATE_BOOL_NO) {
+    if (prd->path) {
         virBufferAddLit(buf, ">\n");
         virBufferAdjustIndent(buf, 2);
         virBufferAddLit(buf, "<source type='unix'");