Re: [libvirt] [PATCH v3 5/5] blockcommit: turn on active commit

2014-06-19 Thread Peter Krempa
On 06/19/14 01:22, Eric Blake wrote:
 With this in place, I can (finally!) now do:
 
 virsh blockcommit $dom vda --shallow --verbose --pivot
 
 and watch qemu shorten the backing chain by one, followed by
 libvirt automatically updating the dumpxml output, effectively
 undoing the work of virsh snapshot-commit --no-metadata --disk-only.
 Commit is S much faster than blockpull, when I'm still fairly
 close in time to when the temporary qcow2 wrapper file was created
 via a snapshot operation!
 
 Still not done: the persistent XML is not updated; which means
 stopping and restarting a persistent guest will use the wrong
 file and likely fail to boot.
 
 * src/qemu/qemu_driver.c (qemuDomainBlockCommit): Implement live
 commit to regular files.
 
 Signed-off-by: Eric Blake ebl...@redhat.com
 ---
  src/qemu/qemu_driver.c | 40 +++-
  1 file changed, 35 insertions(+), 5 deletions(-)
 
 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 index d19ca18..089668d 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c

 @@ -15607,6 +15615,21 @@ qemuDomainBlockCommit(virDomainPtr dom,
 VIR_DISK_CHAIN_READ_WRITE)  
 0))
  goto endjob;
 
 +/* For an active commit, clone enough of the base to act as the mirror */
 +if (mirror) {
 +/* XXX Support network commits */

This will be really easy with my deep-copy of the source struct.

 +if (baseSource-type != VIR_STORAGE_TYPE_FILE 
 +baseSource-type != VIR_STORAGE_TYPE_BLOCK) {
 +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
 +   _(active commit to non-file not supported yet));
 +goto endjob;
 +}
 +mirror-type = baseSource-type;
 +if (VIR_STRDUP(mirror-path, baseSource-path)  0)
 +goto endjob;
 +mirror-format = baseSource-format;
 +}
 +
  /* Start the commit operation.  Pass the user's original spelling,
   * if any, through to qemu, since qemu may behave differently
   * depending on whether the input was specified as relative or

ACK,

Peter



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH v3 5/5] blockcommit: turn on active commit

2014-06-18 Thread Eric Blake
With this in place, I can (finally!) now do:

virsh blockcommit $dom vda --shallow --verbose --pivot

and watch qemu shorten the backing chain by one, followed by
libvirt automatically updating the dumpxml output, effectively
undoing the work of virsh snapshot-commit --no-metadata --disk-only.
Commit is S much faster than blockpull, when I'm still fairly
close in time to when the temporary qcow2 wrapper file was created
via a snapshot operation!

Still not done: the persistent XML is not updated; which means
stopping and restarting a persistent guest will use the wrong
file and likely fail to boot.

* src/qemu/qemu_driver.c (qemuDomainBlockCommit): Implement live
commit to regular files.

Signed-off-by: Eric Blake ebl...@redhat.com
---
 src/qemu/qemu_driver.c | 40 +++-
 1 file changed, 35 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d19ca18..089668d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15495,9 +15495,12 @@ qemuDomainBlockCommit(virDomainPtr dom,
 unsigned int baseIndex = 0;
 const char *top_parent = NULL;
 bool clean_access = false;
+virStorageSourcePtr mirror = NULL;
+

-/* XXX Add support for COMMIT_ACTIVE, COMMIT_DELETE */
-virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW, -1);
+/* XXX Add support for COMMIT_DELETE */
+virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW |
+  VIR_DOMAIN_BLOCK_COMMIT_ACTIVE, -1);

 if (!(vm = qemuDomObjFromDomain(dom)))
 goto cleanup;
@@ -15545,9 +15548,6 @@ qemuDomainBlockCommit(virDomainPtr dom,
  top_parent)))
 goto endjob;

-/* FIXME: qemu 2.0 supports active commit, but as a two-stage
- * process; qemu 2.1 is further improving active commit. We need
- * to start supporting it in libvirt. */
 if (topSource == disk-src) {
 if (!virQEMUCapsGet(priv-qemuCaps, QEMU_CAPS_ACTIVE_COMMIT)) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
@@ -15561,6 +15561,14 @@ qemuDomainBlockCommit(virDomainPtr dom,
disk-dst);
 goto endjob;
 }
+if (disk-mirror) {
+virReportError(VIR_ERR_BLOCK_COPY_ACTIVE,
+   _(disk '%s' already in active block job),
+   disk-dst);
+goto endjob;
+}
+if (VIR_ALLOC(mirror)  0)
+goto endjob;
 } else if (flags  VIR_DOMAIN_BLOCK_COMMIT_ACTIVE) {
 virReportError(VIR_ERR_INVALID_ARG,
_(active commit requested but '%s' is not active),
@@ -15607,6 +15615,21 @@ qemuDomainBlockCommit(virDomainPtr dom,
VIR_DISK_CHAIN_READ_WRITE)  0))
 goto endjob;

+/* For an active commit, clone enough of the base to act as the mirror */
+if (mirror) {
+/* XXX Support network commits */
+if (baseSource-type != VIR_STORAGE_TYPE_FILE 
+baseSource-type != VIR_STORAGE_TYPE_BLOCK) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(active commit to non-file not supported yet));
+goto endjob;
+}
+mirror-type = baseSource-type;
+if (VIR_STRDUP(mirror-path, baseSource-path)  0)
+goto endjob;
+mirror-format = baseSource-format;
+}
+
 /* Start the commit operation.  Pass the user's original spelling,
  * if any, through to qemu, since qemu may behave differently
  * depending on whether the input was specified as relative or
@@ -15619,6 +15642,12 @@ qemuDomainBlockCommit(virDomainPtr dom,
  bandwidth);
 qemuDomainObjExitMonitor(driver, vm);

+if (ret == 0  mirror) {
+disk-mirror = mirror;
+mirror = NULL;
+disk-mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT;
+}
+
  endjob:
 if (ret  0  clean_access) {
 /* Revert access to read-only, if possible.  */
@@ -15629,6 +15658,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
   top_parent,
   VIR_DISK_CHAIN_READ_ONLY);
 }
+virStorageSourceFree(mirror);
 if (!qemuDomainObjEndJob(driver, vm))
 vm = NULL;

-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v3 5/5] blockcommit: turn on active commit

2014-06-12 Thread Peter Krempa
On 06/11/14 18:27, Eric Blake wrote:
 With this in place, I can (finally!) now do:
 
 virsh blockcommit $dom vda --shallow --wait --verbose --pivot
 
 and watch qemu shorten the backing chain by one, followed by
 libvirt automatically updating the dumpxml output, effectively
 undoing the work of virsh snapshot-commit --no-metadata --disk-only.
 Commit is S much faster than blockpull, when I'm still fairly
 close in time to when the temporary qcow2 wrapper file was created
 via a snapshot operation!
 
 * src/qemu/qemu_driver.c (qemuDomainBlockCommit): Implement live
 commit to regular files.
 
 Signed-off-by: Eric Blake ebl...@redhat.com
 ---
  src/qemu/qemu_driver.c | 43 ++-
  1 file changed, 38 insertions(+), 5 deletions(-)
 
 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 index 728aa85..60dc9c6 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
 @@ -15529,9 +15529,11 @@ qemuDomainBlockCommit(virDomainPtr dom,
  char *topPath = NULL;
  char *basePath = NULL;
  char *backingPath = NULL;
 +virStorageSourcePtr mirror = NULL;
 
 -/* XXX Add support for COMMIT_ACTIVE, COMMIT_DELETE */
 +/* XXX Add support for COMMIT_DELETE */
  virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW |
 +  VIR_DOMAIN_BLOCK_COMMIT_ACTIVE |

Rebase needed if this should go before my series.

VIR_DOMAIN_BLOCK_COMMIT_RELATIVE, -1);
 
  if (!(vm = qemuDomObjFromDomain(dom)))
 @@ -15578,13 +15580,14 @@ qemuDomainBlockCommit(virDomainPtr dom,
   top_parent)))
  goto endjob;
 
 -/* FIXME: qemu 2.0 supports active commit, but as a two-stage
 - * process; qemu 2.1 is further improving active commit. We need
 - * to start supporting it in libvirt. */
  if (topSource == disk-src) {
  /* We assume that no one will backport qemu 2.0 active commit
   * to an earlier qemu without also backporting the block job
 - * ready event; but this makes sure of that fact */
 + * ready event; but this makes sure of that fact.
 + *
 + * XXX Also need to check other capability bit(s): qemu 1.7
 + * supports async blockjob but not active commit; and qemu 2.0
 + * active commit misbehaves on 0-byte file.  */

How about tying the support to qemu 2.1 if it makes things easier? I
don't see any problem with supporting stuff from later-than-introduced
versions. The only question that remains is whether there's anything
relevant to trigger the capability of.


  if (!virQEMUCapsGet(priv-qemuCaps, QEMU_CAPS_BLOCKJOB_ASYNC)) {
  virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
 _(active commit not supported with this QEMU 
 binary));

 @@ -15667,6 +15678,21 @@ qemuDomainBlockCommit(virDomainPtr dom,
  }
  }
 
 +/* For an active commit, clone enough of the base to act as the mirror */
 +if (mirror) {
 +/* XXX Support network commits */
 +if (baseSource-type != VIR_STORAGE_TYPE_FILE 
 +baseSource-type != VIR_STORAGE_TYPE_BLOCK) {
 +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
 +   _(active commit to non-file not supported yet));
 +goto endjob;
 +}
 +mirror-type = baseSource-type;
 +if (VIR_STRDUP(mirror-path, baseSource-path)  0)
 +goto endjob;
 +mirror-format = baseSource-format;
 +}
 +
  /* Start the commit operation.  Pass the user's original spelling,
   * if any, through to qemu, since qemu may behave differently
   * depending on whether the input was specified as relative or

Hmmm, this commit is invalid here as we are not passing user's spelling
to qemu. It also doesn't make sense to do that. I should revert that
patch explicitly apparently as a part of my series.


Still needs the capability bit figured out. Otherwise looks good.

Peter



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v3 5/5] blockcommit: turn on active commit

2014-06-12 Thread Eric Blake
On 06/12/2014 06:01 AM, Peter Krempa wrote:
 On 06/11/14 18:27, Eric Blake wrote:
 With this in place, I can (finally!) now do:

 virsh blockcommit $dom vda --shallow --wait --verbose --pivot


 -/* FIXME: qemu 2.0 supports active commit, but as a two-stage
 - * process; qemu 2.1 is further improving active commit. We need
 - * to start supporting it in libvirt. */
  if (topSource == disk-src) {
  /* We assume that no one will backport qemu 2.0 active commit
   * to an earlier qemu without also backporting the block job
 - * ready event; but this makes sure of that fact */
 + * ready event; but this makes sure of that fact.
 + *
 + * XXX Also need to check other capability bit(s): qemu 1.7
 + * supports async blockjob but not active commit; and qemu 2.0
 + * active commit misbehaves on 0-byte file.  */
 
 How about tying the support to qemu 2.1 if it makes things easier? I
 don't see any problem with supporting stuff from later-than-introduced
 versions. The only question that remains is whether there's anything
 relevant to trigger the capability of.

Testing qemu 2.1 is easier - merely check whether 'block-commit' with an
omitted top argument is accepted or rejected.

I just realized - rather than trying to go for 2.0 to begin with, it may
be easier to just require 2.1 for now; we can always relax things later
if people complain that they are still stuck on 2.0, but right now,
there's enough other things going on at once (such as your relative
backing naming stuff) that also depends on 2.1 that it just feels easier
to stick to a single version as our baseline, rather than delaying this
further.

But if I require qemu 2.1, then I'm in the same boat as you as not
having anything to push until I have an actual commit in qemu.git to
point to.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH v3 5/5] blockcommit: turn on active commit

2014-06-11 Thread Eric Blake
With this in place, I can (finally!) now do:

virsh blockcommit $dom vda --shallow --wait --verbose --pivot

and watch qemu shorten the backing chain by one, followed by
libvirt automatically updating the dumpxml output, effectively
undoing the work of virsh snapshot-commit --no-metadata --disk-only.
Commit is S much faster than blockpull, when I'm still fairly
close in time to when the temporary qcow2 wrapper file was created
via a snapshot operation!

* src/qemu/qemu_driver.c (qemuDomainBlockCommit): Implement live
commit to regular files.

Signed-off-by: Eric Blake ebl...@redhat.com
---
 src/qemu/qemu_driver.c | 43 ++-
 1 file changed, 38 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 728aa85..60dc9c6 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15529,9 +15529,11 @@ qemuDomainBlockCommit(virDomainPtr dom,
 char *topPath = NULL;
 char *basePath = NULL;
 char *backingPath = NULL;
+virStorageSourcePtr mirror = NULL;

-/* XXX Add support for COMMIT_ACTIVE, COMMIT_DELETE */
+/* XXX Add support for COMMIT_DELETE */
 virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW |
+  VIR_DOMAIN_BLOCK_COMMIT_ACTIVE |
   VIR_DOMAIN_BLOCK_COMMIT_RELATIVE, -1);

 if (!(vm = qemuDomObjFromDomain(dom)))
@@ -15578,13 +15580,14 @@ qemuDomainBlockCommit(virDomainPtr dom,
  top_parent)))
 goto endjob;

-/* FIXME: qemu 2.0 supports active commit, but as a two-stage
- * process; qemu 2.1 is further improving active commit. We need
- * to start supporting it in libvirt. */
 if (topSource == disk-src) {
 /* We assume that no one will backport qemu 2.0 active commit
  * to an earlier qemu without also backporting the block job
- * ready event; but this makes sure of that fact */
+ * ready event; but this makes sure of that fact.
+ *
+ * XXX Also need to check other capability bit(s): qemu 1.7
+ * supports async blockjob but not active commit; and qemu 2.0
+ * active commit misbehaves on 0-byte file.  */
 if (!virQEMUCapsGet(priv-qemuCaps, QEMU_CAPS_BLOCKJOB_ASYNC)) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
_(active commit not supported with this QEMU 
binary));
@@ -15597,6 +15600,14 @@ qemuDomainBlockCommit(virDomainPtr dom,
disk-dst);
 goto endjob;
 }
+if (disk-mirror) {
+virReportError(VIR_ERR_BLOCK_COPY_ACTIVE,
+   _(disk '%s' already in active block job),
+   disk-dst);
+goto endjob;
+}
+if (VIR_ALLOC(mirror)  0)
+goto endjob;
 } else if (flags  VIR_DOMAIN_BLOCK_COMMIT_ACTIVE) {
 virReportError(VIR_ERR_INVALID_ARG,
_(active commit requested but '%s' is not active),
@@ -15667,6 +15678,21 @@ qemuDomainBlockCommit(virDomainPtr dom,
 }
 }

+/* For an active commit, clone enough of the base to act as the mirror */
+if (mirror) {
+/* XXX Support network commits */
+if (baseSource-type != VIR_STORAGE_TYPE_FILE 
+baseSource-type != VIR_STORAGE_TYPE_BLOCK) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(active commit to non-file not supported yet));
+goto endjob;
+}
+mirror-type = baseSource-type;
+if (VIR_STRDUP(mirror-path, baseSource-path)  0)
+goto endjob;
+mirror-format = baseSource-format;
+}
+
 /* Start the commit operation.  Pass the user's original spelling,
  * if any, through to qemu, since qemu may behave differently
  * depending on whether the input was specified as relative or
@@ -15678,6 +15704,12 @@ qemuDomainBlockCommit(virDomainPtr dom,
  bandwidth);
 qemuDomainObjExitMonitor(driver, vm);

+if (ret == 0  mirror) {
+disk-mirror = mirror;
+mirror = NULL;
+disk-mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT;
+}
+
  endjob:
 if (ret  0  clean_access) {
 /* Revert access to read-only, if possible.  */
@@ -15688,6 +15720,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
   top_parent,
   VIR_DISK_CHAIN_READ_ONLY);
 }
+virStorageSourceFree(mirror);
 if (!qemuDomainObjEndJob(driver, vm))
 vm = NULL;

-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list