From: Henry Wang <xin.wang2@amd.com>
To: <xen-devel@lists.xenproject.org>
Cc: Vikram Garhwal <fnu.vikram@xilinx.com>,
Anthony PERARD <anthony.perard@citrix.com>,
Stewart Hildebrand <stewart.hildebrand@amd.com>,
Stefano Stabellini <stefano.stabellini@xilinx.com>,
Henry Wang <xin.wang2@amd.com>
Subject: [PATCH 12/15] get_overlay: remove domU overlay
Date: Wed, 24 Apr 2024 11:34:46 +0800 [thread overview]
Message-ID: <20240424033449.168398-13-xin.wang2@amd.com> (raw)
In-Reply-To: <20240424033449.168398-1-xin.wang2@amd.com>
From: Vikram Garhwal <fnu.vikram@xilinx.com>
Retrieve 4 new parameters from xenstore: overlay name, type, whether it
is a partial overlay and operation. Operation can be "add" or "remove".
Add correspond to existing mode of operation. Remove introduces support
for removing an overlay from a domU.
Signed-off-by: Vikram Garhwal <fnu.vikram@xilinx.com>
Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
Signed-off-by: Henry Wang <xin.wang2@amd.com>
---
tools/helpers/get_overlay.c | 132 +++++++++++++++++++++++++++++++++---
1 file changed, 123 insertions(+), 9 deletions(-)
diff --git a/tools/helpers/get_overlay.c b/tools/helpers/get_overlay.c
index ca3007570e..daa697ca04 100644
--- a/tools/helpers/get_overlay.c
+++ b/tools/helpers/get_overlay.c
@@ -66,6 +66,33 @@ retry_transaction:
snprintf(ref, sizeof(ref), "%s", "not_ready");
snprintf(buf, sizeof(buf), "%s/sender-status", xs_base);
+ if (!xs_write(xs, xs_trans, buf, ref, strlen(ref)))
+ goto fail_xs_transaction;
+ if (!xs_set_permissions(xs, xs_trans, buf, perms, 2))
+ goto fail_xs_transaction;
+
+ /* Create overlay-name node. */
+ snprintf(ref, sizeof(ref), "%s", "overlay_node");
+ snprintf(buf, sizeof(buf), "%s/overlay-name", xs_base);
+
+ if (!xs_write(xs, xs_trans, buf, ref, strlen(ref)))
+ goto fail_xs_transaction;
+ if (!xs_set_permissions(xs, xs_trans, buf, perms, 2))
+ goto fail_xs_transaction;
+
+ /* Create overlay-type node. */
+ snprintf(ref, sizeof(ref), "%s", "type");
+ snprintf(buf, sizeof(buf), "%s/overlay-type", xs_base);
+
+ if (!xs_write(xs, xs_trans, buf, ref, strlen(ref)))
+ goto fail_xs_transaction;
+ if (!xs_set_permissions(xs, xs_trans, buf, perms, 2))
+ goto fail_xs_transaction;
+
+ /* Create overlay-partial node. */
+ snprintf(ref, sizeof(ref), "%d", 0);
+ snprintf(buf, sizeof(buf), "%s/overlay-partial", xs_base);
+
if (!xs_write(xs, xs_trans, buf, ref, strlen(ref)))
goto fail_xs_transaction;
if (!xs_set_permissions(xs, xs_trans, buf, perms, 2))
@@ -174,7 +201,7 @@ static bool wait_for_status(struct xs_handle *xs, int fd, char *status_path,
}
static bool write_page_ref(struct xs_handle *xs, uint32_t *page_ref,
- uint32_t num_pages, char *path)
+ uint32_t num_pages, const char *path)
{
xs_transaction_t xs_trans = XBT_NULL;
char buf[128];
@@ -249,12 +276,69 @@ retry_transaction:
return true;
}
+static char *get_overlay_ops(struct xs_handle *xs, const char *xs_path)
+{
+ char buf[128];
+ char *ref = NULL;
+ unsigned int len;
+
+ snprintf(buf, sizeof(buf), "%s/overlay-operation", xs_path);
+
+ ref = xs_read(xs, XBT_NULL, buf, &len);
+
+ return ref;
+}
+static char *get_overlay_name(struct xs_handle *xs, const char *xs_path)
+{
+ char buf[128];
+ char *ref = NULL;
+ unsigned int len;
+
+ snprintf(buf, sizeof(buf), "%s/overlay-name", xs_path);
+
+ ref = xs_read(xs, XBT_NULL, buf, &len);
+
+ return ref;
+}
+
+static char *get_overlay_type(struct xs_handle *xs, const char *xs_path)
+{
+ char buf[128];
+ char *ref = NULL;
+ unsigned int len;
+
+ snprintf(buf, sizeof(buf), "%s/overlay-type", xs_path);
+
+ ref = xs_read(xs, XBT_NULL, buf, &len);
+
+ return ref;
+}
+
+static bool get_overlay_partial(struct xs_handle *xs, const char *xs_path)
+{
+ char buf[128];
+ char *ref = NULL;
+ unsigned int len;
+
+ snprintf(buf, sizeof(buf), "%s/overlay-partial", xs_path);
+
+ ref = xs_read(xs, XBT_NULL, buf, &len);
+
+ if (ref) {
+ bool is_partial = atoi(ref);
+ free(ref);
+ return is_partial;
+ }
+
+ return false;
+}
+
int main(int argc, char **argv)
{
void *buffer = NULL;
int domain ;
uint32_t *page_refs = NULL;
- FILE *fptr;
+ FILE *fptr = NULL;
int dtbo_size = 0;
const char *path = "data/overlay";
char receiver_status_path[64] = { };
@@ -263,7 +347,11 @@ int main(int argc, char **argv)
int rc = 0;
int fd = 0;
uint32_t num_pages = 0;
- xengntshr_handle *gntshr;
+ xengntshr_handle *gntshr = NULL;
+ char *overlay_ops = NULL;
+ char *name = NULL;
+ char *type = NULL;
+ bool is_partial = false;
if (argc < 2) {
fprintf(stderr,"Please enter domain_id.\n");
@@ -357,16 +445,33 @@ int main(int argc, char **argv)
goto out;
}
- if ((fptr = fopen("overlay.dtbo","wb")) == NULL) {
- fprintf(stderr,"Error! opening file");
+ overlay_ops = get_overlay_ops(xs, path);
+ name = get_overlay_name(xs, path);
+ type = get_overlay_type(xs, path);
+ is_partial = get_overlay_partial(xs, path);
+
+ if (overlay_ops == NULL || name == NULL || type == NULL)
goto out;
- }
- printf("Writing to file overlay.dtbo.\n");
+ printf("%s %s %s", overlay_ops, name, type);
+ if (is_partial)
+ printf(" %d", is_partial);
+
+ printf("\n");
- fwrite(buffer, dtbo_size, 1, fptr);
+ if (!strcmp(overlay_ops, "add")) {
- printf("Done writing to file overlay.dtbo \n");
+ if ((fptr = fopen("overlay.dtbo","wb")) == NULL) {
+ fprintf(stderr,"Error! opening file");
+ goto out;
+ }
+
+ printf("Writing to file overlay.dtbo.\n");
+
+ fwrite(buffer, dtbo_size, 1, fptr);
+
+ printf("Done writing to file overlay.dtbo \n");
+ }
out:
if (fptr)
@@ -375,6 +480,15 @@ out:
if (page_refs)
free(page_refs);
+ if (overlay_ops)
+ free(overlay_ops);
+
+ if (name)
+ free(name);
+
+ if (type)
+ free(type);
+
if (xs) {
close(fd);
--
2.34.1
next prev parent reply other threads:[~2024-04-24 3:44 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-24 3:34 [PATCH 00/15] Remaining patches for dynamic node programming using overlay dtbo Henry Wang
2024-04-24 3:34 ` [PATCH 01/15] xen/commom/dt-overlay: Fix missing lock when remove the device Henry Wang
2024-04-24 5:58 ` Jan Beulich
2024-04-24 6:02 ` Henry Wang
2024-04-24 3:34 ` [PATCH 02/15] xen/arm/gic: Enable interrupt assignment to running VM Henry Wang
2024-04-24 12:58 ` Julien Grall
2024-04-25 7:06 ` Henry Wang
2024-04-25 14:28 ` Julien Grall
2024-04-30 3:50 ` Henry Wang
2024-04-30 20:13 ` Julien Grall
2024-05-06 8:32 ` Henry Wang
2024-05-07 21:54 ` Julien Grall
2024-05-08 7:49 ` Henry Wang
2024-05-08 20:46 ` Julien Grall
2024-05-09 15:31 ` Henry Wang
2024-05-10 8:54 ` Julien Grall
2024-05-11 7:29 ` Henry Wang
2024-05-11 8:22 ` Julien Grall
2024-05-11 8:35 ` Henry Wang
2024-04-24 3:34 ` [PATCH 03/15] xen/arm: Always enable IOMMU Henry Wang
2024-04-24 13:03 ` Julien Grall
2024-04-25 1:02 ` Henry Wang
2024-04-24 3:34 ` [PATCH 04/15] tools/libs/light: " Henry Wang
2024-05-01 13:47 ` Anthony PERARD
2024-05-06 3:17 ` Henry Wang
2024-04-24 3:34 ` [PATCH 05/15] tools/libs/light: Increase nr_spi to 160 Henry Wang
2024-05-01 13:58 ` Anthony PERARD
2024-05-06 5:17 ` Henry Wang
2024-05-07 14:35 ` Julien Grall
2024-05-08 0:46 ` Henry Wang
2024-04-24 3:34 ` [PATCH 06/15] rangeset: Move struct range and struct rangeset to headerfile Henry Wang
2024-04-24 6:22 ` Jan Beulich
2024-04-25 0:47 ` Henry Wang
2024-04-24 3:34 ` [PATCH 07/15] xen/overlay: Enable device tree overlay assignment to running domains Henry Wang
2024-04-24 6:05 ` Jan Beulich
2024-04-29 3:36 ` Henry Wang
2024-04-29 6:43 ` Jan Beulich
2024-04-29 17:34 ` Julien Grall
2024-04-30 4:00 ` Henry Wang
2024-04-30 9:47 ` Julien Grall
2024-05-06 5:26 ` Henry Wang
2024-05-02 18:02 ` Stefano Stabellini
2024-05-06 3:14 ` Henry Wang
2024-04-24 3:34 ` [PATCH 08/15] tools: Add domain_id and expert mode for overlay operations Henry Wang
2024-05-01 14:46 ` Anthony PERARD
2024-05-06 5:51 ` Henry Wang
2024-04-24 3:34 ` [PATCH 09/15] tools/libs/light: Modify dtbo to domU linux dtbo format Henry Wang
2024-05-01 15:09 ` Anthony PERARD
2024-05-06 5:40 ` Henry Wang
2024-04-24 3:34 ` [PATCH 10/15] tools/xl: Share overlay with domU Henry Wang
2024-04-24 3:34 ` [PATCH 11/15] tools/helpers: Add get_overlay Henry Wang
2024-04-24 6:08 ` Jan Beulich
2024-04-25 0:43 ` Henry Wang
2024-04-26 1:45 ` Stewart Hildebrand
2024-04-26 1:48 ` Henry Wang
2024-04-24 3:34 ` Henry Wang [this message]
2024-04-24 3:34 ` [PATCH 13/15] xl/overlay: add remove operation to xenstore Henry Wang
2024-04-24 3:34 ` [PATCH 14/15] add a domU script to fetch overlays and applying them to linux Henry Wang
2024-04-24 6:16 ` Jan Beulich
2024-04-25 0:54 ` Henry Wang
2024-04-25 6:46 ` Jan Beulich
2024-04-25 7:06 ` Henry Wang
2024-04-24 3:34 ` [PATCH 15/15] docs: add device tree overlay documentation Henry Wang
2024-04-24 6:29 ` [PATCH 00/15] Remaining patches for dynamic node programming using overlay dtbo Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240424033449.168398-13-xin.wang2@amd.com \
--to=xin.wang2@amd.com \
--cc=anthony.perard@citrix.com \
--cc=fnu.vikram@xilinx.com \
--cc=stefano.stabellini@xilinx.com \
--cc=stewart.hildebrand@amd.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).