]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Conditionally allow block-copy for persistent domains
authorPeter Krempa <pkrempa@redhat.com>
Tue, 6 Jun 2017 13:13:51 +0000 (15:13 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 7 Jun 2017 11:13:22 +0000 (13:13 +0200)
Allow starting the block-copy job for a persistent domain if a user
declares by using a flag that the job will not be recovered if the VM is
switched off while the job is active.

This allows to use the block-copy job with persistent VMs under the same
conditions as would apply to transient domains.

include/libvirt/libvirt-domain.h
src/libvirt-domain.c
src/qemu/qemu_driver.c

index 720db32f766318046d8f8ebc12089197951421c1..45f939a8cc37e8e29bea13316a222338b53774fe 100644 (file)
@@ -2428,6 +2428,9 @@ typedef enum {
                                                  backing chain */
     VIR_DOMAIN_BLOCK_COPY_REUSE_EXT = 1 << 1, /* Reuse existing external
                                                  file for a copy */
+    VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB = 1 << 2, /* Don't force usage of
+                                                     recoverable job for the
+                                                     copy operation */
 } virDomainBlockCopyFlags;
 
 /**
index 310b91b37396864bb4036277d2c92bb7c51741e4..e8af013456eb4df9be65b02b6dd136b8d4d92b80 100644 (file)
@@ -10027,6 +10027,10 @@ virDomainBlockRebase(virDomainPtr dom, const char *disk,
  * or virDomainDetachDevice(), while a copy job is active; they may
  * also restrict a copy job to transient domains.
  *
+ * If @flags contains VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB the job will not be
+ * recoverable if the VM is turned off while job is active. This flag will
+ * remove the restriction of copy jobs to transient domains.
+ *
  * The @disk parameter is either an unambiguous source name of the
  * block device (the <source file='...'/> sub-element, such as
  * "/path/to/image"), or the device target shorthand (the
index f0cdea6594ee7efd4bceb9766a53acabf67e8b64..29efda198073b9ef45a197e421ba1ae4affd9a37 100644 (file)
@@ -16507,7 +16507,8 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
 
     /* Preliminaries: find the disk we are editing, sanity checks */
     virCheckFlags(VIR_DOMAIN_BLOCK_COPY_SHALLOW |
-                  VIR_DOMAIN_BLOCK_COPY_REUSE_EXT, -1);
+                  VIR_DOMAIN_BLOCK_COPY_REUSE_EXT |
+                  VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB, -1);
 
     priv = vm->privateData;
     cfg = virQEMUDriverGetConfig(driver);
@@ -16546,7 +16547,8 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
                        _("block copy is not supported with this QEMU binary"));
         goto endjob;
     }
-    if (vm->persistent) {
+    if (!(flags & VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB) &&
+        vm->persistent) {
         /* XXX if qemu ever lets us start a new domain with mirroring
          * already active, we can relax this; but for now, the risk of
          * 'managedsave' due to libvirt-guests means we can't risk
@@ -16773,7 +16775,8 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *disk, const char *destxml,
     size_t i;
 
     virCheckFlags(VIR_DOMAIN_BLOCK_COPY_SHALLOW |
-                  VIR_DOMAIN_BLOCK_COPY_REUSE_EXT, -1);
+                  VIR_DOMAIN_BLOCK_COPY_REUSE_EXT |
+                  VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB, -1);
     if (virTypedParamsValidate(params, nparams,
                                VIR_DOMAIN_BLOCK_COPY_BANDWIDTH,
                                VIR_TYPED_PARAM_ULLONG,