Re: [libvirt] [PATCHv5 06/23] blockjob: enhance xml to track mirrors across libvirtd restart

2012-04-18 Thread Jiri Denemark
On Mon, Apr 16, 2012 at 23:05:57 -0600, Eric Blake wrote:
 In order to track a block copy job across libvirtd restarts, we
 need to save internal XML that tracks the name of the file
 holding the mirror.  Displaying this name in dumpxml might also
 be useful to the user, even if we don't yet have a way to (re-)
 start a domain with mirroring enabled up front.  This is done
 with a new mirror sub-element to disk, as in:
 
 disk type='file' device='disk'
   driver name='qemu' type='raw'/
   source file='/var/lib/libvirt/images/original.img'/
   mirror file='/var/lib/libvirt/images/copy.img' format='qcow2' 
 ready='yes'/
   ...
 /disk
 
 For now, the element is output-only, in live domains; it is ignored
 when defining a domain or hot-plugging a disk (since those contexts
 use VIR_DOMAIN_XML_INACTIVE in parsing).  The 'ready' attribute appears
 when libvirt knows that the job has changed from the initial pulling
 phase over to the mirroring phase, although absence of the attribute
 is not a sure indicator of the current phase.  If we come up with a way
 to make qemu start with mirroring enabled, we can relax the xml
 restriction, and allow mirror (but not attribute 'ready') on input.
 Testing active-only XML meant tweaking the testsuite slightly, but it
 was worth it.
 
 * docs/schemas/domaincommon.rng (diskspec): Add diskMirror.
 * docs/formatdomain.html.in (elementsDisks): Document it.
 * src/conf/domain_conf.h (_virDomainDiskDef): New members.
 * src/conf/domain_conf.c (virDomainDiskDefFree): Clean them.
 (virDomainDiskDefParseXML): Parse them, but only internally.
 (virDomainDiskDefFormat): Output them.
 * tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml: New test file.
 * tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror.xml: Likewise.
 * tests/qemuxml2xmltest.c (testInfo): Alter members.
 (testCompareXMLToXMLHelper): Allow more test control.
 (mymain): Run new test.
 ---
 
 was 7/18 in v4
 v5: allow but ignore mirror on inactive, and add tests
 
  docs/formatdomain.html.in  |   13 
  docs/schemas/domaincommon.rng  |   24 +++-
  src/conf/domain_conf.c |   62 
 +---
  src/conf/domain_conf.h |4 +
  .../qemuxml2argvdata/qemuxml2argv-disk-mirror.xml  |   42 +
  .../qemuxml2xmlout-disk-mirror.xml |   40 +
  tests/qemuxml2xmltest.c|   42 --
  7 files changed, 198 insertions(+), 29 deletions(-)
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml
  create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror.xml

OK, looks good as well with the comment from 4/23 applied. BTW, not removing
unrelated () would make the patch a bit smaller for review ;-)

Jirka

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


Re: [libvirt] [PATCHv5 06/23] blockjob: enhance xml to track mirrors across libvirtd restart

2012-04-18 Thread Eric Blake
On 04/18/2012 08:23 AM, Jiri Denemark wrote:
 On Mon, Apr 16, 2012 at 23:05:57 -0600, Eric Blake wrote:
 In order to track a block copy job across libvirtd restarts, we
 need to save internal XML that tracks the name of the file
 holding the mirror.  Displaying this name in dumpxml might also
 be useful to the user, even if we don't yet have a way to (re-)
 start a domain with mirroring enabled up front.  This is done
 with a new mirror sub-element to disk, as in:


 v5: allow but ignore mirror on inactive, and add tests

  docs/formatdomain.html.in  |   13 
  docs/schemas/domaincommon.rng  |   24 +++-
  src/conf/domain_conf.c |   62 
 +---
  src/conf/domain_conf.h |4 +
  .../qemuxml2argvdata/qemuxml2argv-disk-mirror.xml  |   42 +
  .../qemuxml2xmlout-disk-mirror.xml |   40 +
  tests/qemuxml2xmltest.c|   42 --
  7 files changed, 198 insertions(+), 29 deletions(-)
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml
  create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror.xml
 
 OK, looks good as well with the comment from 4/23 applied. BTW, not removing
 unrelated () would make the patch a bit smaller for review ;-)

I'll work on splitting the () trimming into a separate patch, which can
be applied now, similar to what I already did for virsh in patch 1/23.

-- 
Eric Blake   ebl...@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] [PATCHv5 06/23] blockjob: enhance xml to track mirrors across libvirtd restart

2012-04-16 Thread Eric Blake
In order to track a block copy job across libvirtd restarts, we
need to save internal XML that tracks the name of the file
holding the mirror.  Displaying this name in dumpxml might also
be useful to the user, even if we don't yet have a way to (re-)
start a domain with mirroring enabled up front.  This is done
with a new mirror sub-element to disk, as in:

disk type='file' device='disk'
  driver name='qemu' type='raw'/
  source file='/var/lib/libvirt/images/original.img'/
  mirror file='/var/lib/libvirt/images/copy.img' format='qcow2' 
ready='yes'/
  ...
/disk

For now, the element is output-only, in live domains; it is ignored
when defining a domain or hot-plugging a disk (since those contexts
use VIR_DOMAIN_XML_INACTIVE in parsing).  The 'ready' attribute appears
when libvirt knows that the job has changed from the initial pulling
phase over to the mirroring phase, although absence of the attribute
is not a sure indicator of the current phase.  If we come up with a way
to make qemu start with mirroring enabled, we can relax the xml
restriction, and allow mirror (but not attribute 'ready') on input.
Testing active-only XML meant tweaking the testsuite slightly, but it
was worth it.

* docs/schemas/domaincommon.rng (diskspec): Add diskMirror.
* docs/formatdomain.html.in (elementsDisks): Document it.
* src/conf/domain_conf.h (_virDomainDiskDef): New members.
* src/conf/domain_conf.c (virDomainDiskDefFree): Clean them.
(virDomainDiskDefParseXML): Parse them, but only internally.
(virDomainDiskDefFormat): Output them.
* tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml: New test file.
* tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror.xml: Likewise.
* tests/qemuxml2xmltest.c (testInfo): Alter members.
(testCompareXMLToXMLHelper): Allow more test control.
(mymain): Run new test.
---

was 7/18 in v4
v5: allow but ignore mirror on inactive, and add tests

 docs/formatdomain.html.in  |   13 
 docs/schemas/domaincommon.rng  |   24 +++-
 src/conf/domain_conf.c |   62 +---
 src/conf/domain_conf.h |4 +
 .../qemuxml2argvdata/qemuxml2argv-disk-mirror.xml  |   42 +
 .../qemuxml2xmlout-disk-mirror.xml |   40 +
 tests/qemuxml2xmltest.c|   42 --
 7 files changed, 198 insertions(+), 29 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index f8ec6ff..a99281d 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1296,6 +1296,19 @@
 /table
 span class=sinceSince 0.9.7/span
 /dd
+  dtcodemirror/code/dt
+  dd
+This element is present if the hypervisor has started a block
+copy operation (via the codevirDomainBlockCopy/code API),
+where the mirror location in attribute codefile/code will
+eventually have the same contents as the source, and with the
+file format in attribute codeformat/code (which might
+differ from the format of the source).  If
+attribute codeready/code is present, then it is known the
+disk is ready to pivot; otherwise, the disk is probably still
+copying.  For now, this element only valid in output; it is
+rejected on input.  span class=sinceSince 0.9.12/span
+  /dd
   dtcodetarget/code/dt
   ddThe codetarget/code element controls the bus / device
 under which the disk is exposed to the guest
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 0cc04af..44f0e8c 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -772,6 +772,9 @@
 ref name=driver/
   /optional
   optional
+ref name='diskMirror'/
+  /optional
+  optional
 ref name=diskAuth/
   /optional
   ref name=target/
@@ -1013,9 +1016,7 @@
 /element
   /define
   !--
-  Disk may use a special driver for access. Currently this is
-  only defined for Xen for tap/aio and file, but will certainly be
-  extended in the future, and libvirt doesn't look for specific values.
+  Disk may use a special driver for access.
 --
   define name=driver
 element name=driver
@@ -3024,6 +3025,23 @@
   empty/
 /element
   /define
+  define name='diskMirror'
+element name='mirror'
+  attribute name='file'
+ref name='absFilePath'/
+  /attribute
+  optional
+attribute name='format'
+  ref name=genericName/
+/attribute
+  /optional
+  optional
+attribute name='ready'
+  valueyes/value
+/attribute
+  /optional
+/element
+  /define
   define name=diskAuth
 element name=auth
   attribute