[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 4/5] common/domain: add a domain context record for shared_info...



Hi,

On 21/05/2020 17:00, Paul Durrant wrote:
-----Original Message-----
From: Paul Durrant <xadimgnik@xxxxxxxxx>
Sent: 21 May 2020 16:26
To: 'Julien Grall' <julien@xxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx
Cc: 'Paul Durrant' <pdurrant@xxxxxxxxxx>; 'Ian Jackson' 
<ian.jackson@xxxxxxxxxxxxx>; 'Wei Liu'
<wl@xxxxxxx>; 'Andrew Cooper' <andrew.cooper3@xxxxxxxxxx>; 'George Dunlap' 
<george.dunlap@xxxxxxxxxx>;
'Jan Beulich' <jbeulich@xxxxxxxx>; 'Stefano Stabellini' <sstabellini@xxxxxxxxxx>
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.

ENXIO could work. Another one would be E2BIG.

I don't have a preference.

Cheers,

--
Julien Grall



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.