• E
    blockcommit: require base below top · 3e3c6ff1
    Eric Blake 提交于
    The block commit code looks for an explicit base file relative
    to the discovered top file; so for a chain of:
      base <- snap1 <- snap2 <- snap3
    and a command of:
      virsh blockcommit $dom vda --base snap2 --top snap1
    we got a sane message (here from libvirt 1.0.5):
    error: invalid argument: could not find base 'snap2' below 'snap1' in chain for 'vda'
    
    Meanwhile, recent refactoring has slightly reduced the quality of the
    libvirt error messages, by losing the phrase 'below xyz':
    error: invalid argument: could not find image 'snap2' in chain for 'snap3'
    
    But we had a one-off, where we were not excluding the top file
    itself in searching for the base; thankfully qemu still reports
    the error, but the quality is worse:
      virsh blockcommit $dom vda --base snap2 --top snap2
    error: internal error unable to execute QEMU command 'block-commit': Base '/snap2' not found
    
    Fix the one-off in blockcommit by changing the semantics of name
    lookup - if a starting point is specified, then the result must
    be below that point, rather than including that point.  The only
    other call to chain lookup was blockpull code, which was already
    forcing the lookup to omit the active layer and only needs a
    tweak to use the new semantics.
    
    This also fixes the bug exposed in the testsuite, where when doing
    a lookup pinned to an intermediate point in the chain, we were
    unable to return the name of the parent also in the chain.
    
    * src/util/virstoragefile.c (virStorageFileChainLookup): Change
    semantics for non-NULL startFrom.
    * src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Adjust caller,
    to keep existing semantics.
    * tests/virstoragetest.c (mymain): Adjust to expose new semantics.
    Signed-off-by: NEric Blake <eblake@redhat.com>
    3e3c6ff1
virstoragefile.c 53.9 KB