]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Introduce 'shareBacking' for <transient> disks
authorPeter Krempa <pkrempa@redhat.com>
Tue, 18 May 2021 09:11:02 +0000 (11:11 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 24 May 2021 18:38:08 +0000 (20:38 +0200)
In case the user wants to share the disk image between multiple VMs the
qemu driver needs to hotplug such disks to instantiate the backends.
Since that doesn't work for all disk configs add a switch to force this
behaviour.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
docs/formatdomain.rst
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h

index e115165ad20f2a92f43703ba4115523a82317213..aa7bb8da14c8045b264cd55f304d8a7b9075eddb 100644 (file)
@@ -3135,6 +3135,12 @@ paravirtualized driver is specified via the ``disk`` element.
    disk transient prevents the domain from participating in migration,
    snapshots, or blockjobs. Only supported in vmx hypervisor
    (:since:`Since 0.9.5`) and ``qemu`` hypervisor (:since:`Since 6.9.0`).
+
+   In cases where the source image of the ``<transient/>`` disk is supposed to
+   be shared between multiple concurrently running VMs the optional
+   ``shareBacking`` attribute should be set to ``yes``. Note that hypervisor
+   drivers may need to hotplug such disk and thus it works only with
+   configurations supporting hotplug. :since:`Since 7.4.0`
 ``serial``
    If present, this specify serial number of virtual hard drive. For example, it
    may look like ``<serial>WD-WMAP9A966149</serial>``. Not supported for
index 66a581c5140bb37cca1dc8954ef00333cee00d94..38f9d3f5997a1534236622bc2d3262bae237e578 100644 (file)
       </optional>
       <optional>
         <element name="transient">
+          <optional>
+            <attribute name="shareBacking">
+              <ref name='virYesNo'/>
+            </attribute>
+          </optional>
           <empty/>
         </element>
       </optional>
index e27154f22d8d0758809fc4546364e12fb8aafb75..4f78b7b43dbbf8c071f9192cd05dd2a78f1eb747 100644 (file)
@@ -9047,6 +9047,7 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
     xmlNodePtr blockioNode;
     xmlNodePtr driverNode;
     xmlNodePtr mirrorNode;
+    xmlNodePtr transientNode;
     g_autoptr(virStorageSource) src = NULL;
 
     if (!(src = virDomainDiskDefParseSourceXML(xmlopt, node, ctxt, flags)))
@@ -9155,9 +9156,15 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
         }
     }
 
-    if (virXPathNode("./transient", ctxt))
+    if ((transientNode = virXPathNode("./transient", ctxt))) {
         def->transient = true;
 
+        if (virXMLPropTristateBool(transientNode, "shareBacking",
+                                   VIR_XML_PROP_NONE,
+                                   &def->transientShareBacking) < 0)
+            return NULL;
+    }
+
     if (virDomainDiskDefIotuneParse(def, ctxt) < 0)
         return NULL;
 
@@ -23551,8 +23558,12 @@ virDomainDiskDefFormat(virBuffer *buf,
         virBufferAddLit(buf, "<readonly/>\n");
     if (def->src->shared)
         virBufferAddLit(buf, "<shareable/>\n");
-    if (def->transient)
-        virBufferAddLit(buf, "<transient/>\n");
+    if (def->transient) {
+        virBufferAddLit(buf, "<transient");
+        if (def->transientShareBacking == VIR_TRISTATE_BOOL_YES)
+            virBufferAddLit(buf, " shareBacking='yes'");
+        virBufferAddLit(buf, "/>\n");
+    }
     virBufferEscapeString(buf, "<serial>%s</serial>\n", def->serial);
     virBufferEscapeString(buf, "<wwn>%s</wwn>\n", def->wwn);
     virBufferEscapeString(buf, "<vendor>%s</vendor>\n", def->vendor);
index f38ab21a3b7b3e3a96630cee51315ec166633e84..bf1249571d4a1b71efb8bb156e0ab376183cdb83 100644 (file)
@@ -575,6 +575,7 @@ struct _virDomainDiskDef {
     unsigned int snapshot; /* virDomainSnapshotLocation, snapshot_conf.h */
     virDomainStartupPolicy startupPolicy;
     bool transient;
+    virTristateBool transientShareBacking;
     virDomainDeviceInfo info;
     virTristateBool rawio;
     virDomainDeviceSGIO sgio;