• E
    blockjob: use stable disk string in job event · 1bfe73a1
    Eric Blake 提交于
    When the block job event was first added, it was for block pull,
    where the active layer of the disk remains the same name.  It was
    also in a day where we only cared about local files, and so we
    always had a canonical absolute file name.  But two things have
    changed since then: we now have network disks, where determining
    a single absolute string does not really make sense; and we have
    two-phase jobs (copy and active commit) where the name of the
    active layer changes between the first event (ready, on the old
    name) and second (complete, on the pivoted name).
    
    Adam Litke reported that having an unstable string between events
    makes life harder for clients.  Furthermore, all of our API that
    operate on a particular disk of a domain accept multiple strings:
    not only the absolute name of the active layer, but also the
    destination device name (such as 'vda').  As this latter name is
    stable, even for network sources, it serves as a better string
    to supply in block job events.
    
    But backwards-compatibility demands that we should not change the
    name handed to users unless they explicitly request it.  Therefore,
    this patch adds a new event, BLOCK_JOB_2 (alas, I couldn't think of
    any nicer name - but at least Migrate2 and Migrate3 are precedent
    for a number suffix).  We must double up on emitting both old-style
    and new-style events according to what clients have registered for
    (see also how IOError and IOErrorReason emits double events, but
    there the difference was a larger struct rather than changed
    meaning of one of the struct members).
    
    Unfortunately, adding a new event isn't something that can easily
    be broken into pieces, so the commit is rather large.
    
    * include/libvirt/libvirt.h.in (virDomainEventID): Add a new id
    for VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2.
    (virConnectDomainEventBlockJobCallback): Document new semantics.
    * src/conf/domain_event.c (_virDomainEventBlockJob): Rename field,
    to ensure we catch all clients.
    (virDomainEventBlockJobNew): Add parameter.
    (virDomainEventBlockJobDispose)
    (virDomainEventBlockJobNewFromObj)
    (virDomainEventBlockJobNewFromDom)
    (virDomainEventDispatchDefaultFunc): Adjust clients.
    (virDomainEventBlockJob2NewFromObj)
    (virDomainEventBlockJob2NewFromDom): New functions.
    * src/conf/domain_event.h: Add new prototypes.
    * src/libvirt_private.syms (domain_event.h): Export new functions.
    * src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Generate two
    different events.
    * src/qemu/qemu_process.c (qemuProcessHandleBlockJob): Likewise.
    * src/remote/remote_protocol.x
    (remote_domain_event_block_job_2_msg): New struct.
    (REMOTE_PROC_DOMAIN_EVENT_BLOCK_JOB_2): New RPC.
    * src/remote/remote_driver.c
    (remoteDomainBuildEventBlockJob2): New handler.
    (remoteEvents): Register new event.
    * daemon/remote.c (remoteRelayDomainEventBlockJob2): New handler.
    (domainEventCallbacks): Register new event.
    * tools/virsh-domain.c (vshEventCallbacks): Likewise.
    (vshEventBlockJobPrint): Adjust client.
    * src/remote_protocol-structs: Regenerate.
    Signed-off-by: NEric Blake <eblake@redhat.com>
    1bfe73a1
virsh-domain.c 327.1 KB