> -----Original Message-----
> From: Paul Durrant <xadimg...@gmail.com>
> Sent: 21 May 2020 16:26
> To: 'Julien Grall' <jul...@xen.org>; xen-devel@lists.xenproject.org
> Cc: 'Paul Durrant' <pdurr...@amazon.com>; 'Ian Jackson' 
> <ian.jack...@eu.citrix.com>; 'Wei Liu'
> <w...@xen.org>; 'Andrew Cooper' <andrew.coop...@citrix.com>; 'George Dunlap' 
> <george.dun...@citrix.com>;
> 'Jan Beulich' <jbeul...@suse.com>; 'Stefano Stabellini' 
> <sstabell...@kernel.org>
> Subject: RE: [PATCH v4 4/5] common/domain: add a domain context record for 
> shared_info...
> 
> > -----Original Message-----
> [snip]
> > > diff --git a/xen/common/domain.c b/xen/common/domain.c
> > > index 7cc9526139..14e96c3bc2 100644
> > > --- a/xen/common/domain.c
> > > +++ b/xen/common/domain.c
> > > @@ -33,6 +33,7 @@
> > >   #include <xen/xenoprof.h>
> > >   #include <xen/irq.h>
> > >   #include <xen/argo.h>
> > > +#include <xen/save.h>
> > >   #include <asm/debugger.h>
> > >   #include <asm/p2m.h>
> > >   #include <asm/processor.h>
> > > @@ -1649,6 +1650,64 @@ int continue_hypercall_on_cpu(
> > >       return 0;
> > >   }
> > >
> > > +static int save_shared_info(const struct domain *d, struct 
> > > domain_context *c,
> > > +                            bool dry_run)
> > > +{
> > > +    struct domain_shared_info_context ctxt = {
> > > +#ifdef CONFIG_COMPAT
> > > +        .flags = has_32bit_shinfo(d) ? DOMAIN_SAVE_32BIT_SHINFO : 0,
> > > +#endif
> > > +        .buffer_size = sizeof(shared_info_t),
> > > +    };
> > > +    size_t hdr_size = offsetof(typeof(ctxt), buffer);
> > > +    int rc;
> > > +
> > > +    rc = DOMAIN_SAVE_BEGIN(SHARED_INFO, c, 0);
> > > +    if ( rc )
> > > +        return rc;
> > > +
> > > +    rc = domain_save_data(c, &ctxt, hdr_size);
> > > +    if ( rc )
> > > +        return rc;
> > > +
> > > +    rc = domain_save_data(c, d->shared_info, ctxt.buffer_size);
> > > +    if ( rc )
> > > +        return rc;
> > > +
> > > +    return domain_save_end(c);
> > > +}
> > > +
> > > +static int load_shared_info(struct domain *d, struct domain_context *c)
> > > +{
> > > +    struct domain_shared_info_context ctxt;
> > > +    size_t hdr_size = offsetof(typeof(ctxt), buffer);
> > > +    unsigned int i;
> > > +    int rc;
> > > +
> > > +    rc = DOMAIN_LOAD_BEGIN(SHARED_INFO, c, &i);
> > > +    if ( rc || i ) /* expect only a single instance */
> > > +        return rc;
> >
> > This will return 0 if there is multiple instance. Is it intended?
> >
> 
> No, it ought to be an error... probably ENOENT.

Actually I think ENXIO might be better... ENOENT tends to imply something is 
missing rather than unexpected.

  Paul


Reply via email to