All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean Guyader <jean.guyader@citrix.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH 2/3] qemu: xenstore-domains
Date: Thu, 16 Jul 2009 14:27:42 +0100	[thread overview]
Message-ID: <20090716132742.GC16500@citrix.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 54 bytes --]

Signed-off-by: Jean Guyader <jean.guyader@citrix.com>

[-- Attachment #2: xenstore-domains.patch --]
[-- Type: text/plain, Size: 3431 bytes --]

diff --git a/qemu-xen.h b/qemu-xen.h
index 09d0539..5e30c61 100644
--- a/qemu-xen.h
+++ b/qemu-xen.h
@@ -96,6 +96,11 @@ int xenstore_unsubscribe_from_hotplug_status(struct xs_handle *handle,
 typedef void (*xenstore_callback) (const char *path, void *opaque);
 int xenstore_watch_new_callback(const char *path, xenstore_callback fptr, void *opaque);
 
+char *xenstore_dom_read(int domid, const char *key, unsigned int *len);
+int xenstore_dom_write(int domid, const char *key, const char *value);
+void xenstore_dom_watch(int domid, const char *key, xenstore_callback ftp, void *opaque);
+void xenstore_dom_chmod(int domid, const char *key, const char *perms);
+
  /* `danger' means that this parameter, variable or function refers to
   * an area of xenstore which is writeable by the guest and thus must
   * not be trusted by qemu code.  For variables containing xenstore
diff --git a/xenstore.c b/xenstore.c
index df5d940..1ad6dc9 100644
--- a/xenstore.c
+++ b/xenstore.c
@@ -1462,3 +1462,103 @@ void xenstore_store_serial_port_info(int i, CharDriverState *chr,
     if (i == 0) /* serial 0 is also called the console */
         store_dev_info(devname, domid, chr, "/console");
 }
+
+char *xenstore_dom_read(int domid, const char *key, unsigned int *len)
+{
+    char *buf = NULL, *path = NULL, *value = NULL;
+
+    if (xsh == NULL)
+        goto out;
+
+    path = xs_get_domain_path(xsh, domid);
+    if (path == NULL) {
+        fprintf(logfile, "xs_get_domain_path(%d): error\n", domid);
+        goto out;
+    }
+
+    pasprintf(&buf, "%s/%s", path, key);
+    value = xs_read(xsh, XBT_NULL, buf, len);
+    if (value == NULL) {
+        fprintf(logfile, "xs_read(%s): read error\n", buf);
+        goto out;
+    }
+
+ out:
+    free(path);
+    free(buf);
+    return value;
+}
+
+void xenstore_dom_watch(int domid, const char *key, xenstore_callback fptr, void *opaque)
+{
+    char *buf = NULL, *path = NULL;
+    int rc = -1;
+
+    if (xsh == NULL)
+        goto out;
+
+    path = xs_get_domain_path(xsh, domid);
+    if (path == NULL) {
+        fprintf(logfile, "xs_get_domain_path: error\n");
+        goto out;
+    }
+
+    pasprintf(&buf, "%s/%s", path, key);
+    xenstore_watch_new_callback(buf, fptr, opaque);
+
+ out:
+    free(path);
+    free(buf);
+}
+
+void xenstore_dom_chmod(int domid, const char *key, const char *perms)
+{
+    char *buf = NULL, *path = NULL;
+    int rc = -1;
+	struct xs_permissions p;
+
+    if (xsh == NULL)
+        goto out;
+
+    path = xs_get_domain_path(xsh, domid);
+    if (path == NULL) {
+        fprintf(logfile, "xs_get_domain_path: error\n");
+        goto out;
+    }
+
+    pasprintf(&buf, "%s/%s", path, key);
+
+	xs_strings_to_perms(&p, 1, perms);
+	xs_set_permissions(xsh, XBT_NULL, buf, &p, 1);
+
+ out:
+    free(path);
+    free(buf);
+}
+
+int xenstore_dom_write(int domid, const char *key, const char *value)
+{
+    char *buf = NULL, *path = NULL;
+    int rc = -1;
+
+    if (xsh == NULL)
+        goto out;
+
+    path = xs_get_domain_path(xsh, domid);
+    if (path == NULL) {
+        fprintf(logfile, "xs_get_domain_path: error\n");
+        goto out;
+    }
+
+    pasprintf(&buf, "%s/%s", path, key);
+    rc = xs_write(xsh, XBT_NULL, buf, value, strlen(value));
+    if (rc == 0) {
+        fprintf(logfile, "xs_write(%s, %s): write error\n", buf, key);
+        goto out;
+    }
+
+ out:
+    free(path);
+    free(buf);
+    return rc;
+}

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

                 reply	other threads:[~2009-07-16 13:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20090716132742.GC16500@citrix.com \
    --to=jean.guyader@citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.