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

Re: [PATCH v4 8/9] tools: add example application to initialize dom0less PV drivers



On 01.04.22 16:04, Julien Grall wrote:
Hi Juergen,

On 01/04/2022 14:52, Juergen Gross wrote:
On 01.04.22 15:35, Julien Grall wrote:
Hi Juergen,

On 01/04/2022 11:46, Juergen Gross wrote:
On 01.04.22 12:21, Julien Grall wrote:
Hi,

I have posted some comments in v3 after you sent this version. Please have a look.

On 01/04/2022 01:38, Stefano Stabellini wrote:
+static int init_domain(struct xs_handle *xsh, libxl_dominfo *info)
+{
+    struct xc_interface_core *xch;
+    libxl_uuid uuid;
+    uint64_t xenstore_evtchn, xenstore_pfn;
+    int rc;
+
+    printf("Init dom0less domain: %u\n", info->domid);
+    xch = xc_interface_open(0, 0, 0);
+
+    rc = xc_hvm_param_get(xch, info->domid, HVM_PARAM_STORE_EVTCHN,
+                          &xenstore_evtchn);
+    if (rc != 0) {
+        printf("Failed to get HVM_PARAM_STORE_EVTCHN\n");
+        return 1;
+    }
+
+    /* Alloc xenstore page */
+    if (alloc_xs_page(xch, info, &xenstore_pfn) != 0) {
+        printf("Error on alloc magic pages\n");
+        return 1;
+    }
+
+    rc = xc_dom_gnttab_seed(xch, info->domid, true,
+                            (xen_pfn_t)-1, xenstore_pfn, 0, 0);
+    if (rc)
+        err(1, "xc_dom_gnttab_seed");
+
+    libxl_uuid_generate(&uuid);
+    xc_domain_sethandle(xch, info->domid, libxl_uuid_bytearray(&uuid));
+
+    rc = gen_stub_json_config(info->domid, &uuid);
+    if (rc)
+        err(1, "gen_stub_json_config");
+
+    /* Now everything is ready: set HVM_PARAM_STORE_PFN */
+    rc = xc_hvm_param_set(xch, info->domid, HVM_PARAM_STORE_PFN,
+                          xenstore_pfn);

On patch #1, you told me you didn't want to allocate the page in Xen because it wouldn't be initialized by Xenstored. But this is what we are doing here.

Xenstore (at least the C variant) is only using the fixed grant ref
GNTTAB_RESERVED_XENSTORE, so it doesn't need the page to be advertised
to the guest. And the mapping is done only when the domain is being
introduced to Xenstore.

And we don't expect the guest to use the grant entry to find the xenstore page?


This would be a problem if Linux is still booting and hasn't yet call xenbus_probe_initcall().

I understand we need to have the page setup before raising the event channel. I don't think we can allow Xenstored to set the HVM_PARAM (it may run in a domain with less privilege). So I think we may need to create a separate command to kick the client (not great).

Juergen, any thoughts?

I think it should work like that:

- setup the grant via xc_dom_gnttab_seed()
- introduce the domain to Xenstore
- call xc_hvm_param_set()

When the guest is receiving the event, it should wait for the xenstore
page to appear.
IIUC, this would mean the guest would need to do some sort of busy loop until the xenstore page to appear.

Looking for it every second or so would be enough.

This is a better than a busy loop but not by much. I would argue a design that requires to poll after receiving an interrupt is broken.


If so, this doesn't sound great to me. I think it would be better to have a flag in the page to indicate whether the page is not ready.

Xenstored could then clear the flag before raising the event channel.

Hmm, the "connection" field could be used for that.

I thought about the field but the description doesn't entirely match what we want. In particular, the spec says only the guest should set the value to 1 (i.e. reconnect). Maybe this could be relaxed?


It would mean, though, that e.g. libxl would need to initialize the
page accordingly before calling xs_introduce()

libxl only create domain paused. So I don't think it would be necessary to update it.

Maybe not libxl, but whoever is calling xc_dom_gnttab_seed(),
xc_hvm_param_set() and/or xs_introduce() needs to set the field, in
order to have an effect of Xenstore resetting it.


Juergen

Attachment: OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


 


Rackspace

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