[libvirt] [PATCH 3/3] qemu: Disallow concurrent block jobs on a single disk

Peter Krempa pkrempa at redhat.com
Mon Mar 16 10:19:32 UTC 2015


On Fri, Mar 13, 2015 at 13:36:13 -0600, Eric Blake wrote:
> On 03/13/2015 10:25 AM, Peter Krempa wrote:
> > While qemu may be prepared to do this libvirt is not. Forbid the block
> > ops until we fix our code.
> > ---
> >  src/conf/domain_conf.h |  1 +
> >  src/qemu/qemu_domain.c | 23 +++++++++++++++++++++++
> >  src/qemu/qemu_domain.h |  2 ++
> >  src/qemu/qemu_driver.c | 28 +++++++++++++---------------
> >  4 files changed, 39 insertions(+), 15 deletions(-)
> > 
> > diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
> > index ea463cb..6f2df46 100644
> > --- a/src/conf/domain_conf.h
> > +++ b/src/conf/domain_conf.h
> > @@ -664,6 +664,7 @@ struct _virDomainDiskDef {
> >      int tray_status; /* enum virDomainDiskTray */
> >      int removable; /* enum virTristateSwitch */
> > 
> > +    bool blockjob;
> 
> Might be worth a FIXME comment acknowledging that a bool will be
> insufficient when we update our code to support parallel jobs.

Ok, I'll add a note.

> 
> > +
> > +bool
> > +qemuDomainDiskBlockJobIsActive(virDomainDiskDefPtr disk)
> > +{
> > +    if (disk->mirror) {
> > +        virReportError(VIR_ERR_BLOCK_COPY_ACTIVE,
> > +                       _("disk '%s' already in active block job"),
> > +                       disk->dst);
> > +
> > +        return true;
> > +    }
> > +
> > +    if (disk->blockjob) {
> > +        virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
> > +                       _("disk '%s' already in active block job"),
> > +                       disk->dst);
> > +        return true;
> > +    }
> 
> Shorter as 'if (disk->mirror || disk->blockjob)', up to you if you want
> to compress the common code.

The errors have different error codes and I wanted to avoid a ternary
operator.

> 
> ACK.  Looks like you have correctly locked out blockpull, blockcopy, and
> blockcommit as the three jobs that are all mutually exclusive according
> to our current abilities.

Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150316/b7dbcdbf/attachment-0001.sig>


More information about the libvir-list mailing list