All of lore.kernel.org
 help / color / mirror / Atom feed
From: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Paul Durrant <paul@xen.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Richard Henderson <richard.henderson@linaro.org>,
	Eduardo Habkost <eduardo@habkost.net>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Anthony Perard <anthony.perard@citrix.com>,
	"open list:X86 Xen CPUs" <xen-devel@lists.xenproject.org>
Subject: [PATCH v1 3/7] xen: xenstore: add possibility to preserve owner
Date: Fri, 10 Nov 2023 20:42:22 +0000	[thread overview]
Message-ID: <20231110204207.2927514-4-volodymyr_babchuk@epam.com> (raw)
In-Reply-To: <20231110204207.2927514-1-volodymyr_babchuk@epam.com>

Add option to preserve owner when creating an entry in Xen Store. This
may be needed in cases when Qemu is working as device model in a
domain that is Domain-0, e.g. in driver domain.

"owner" parameter for qemu_xen_xs_create() function can have special
value XS_PRESERVE_OWNER, which will make specific implementation to
get original owner of an entry and pass it back to
set_permissions() call.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
---
 hw/i386/kvm/xen_xenstore.c       | 18 ++++++++++++++++++
 hw/xen/xen-operations.c          | 12 ++++++++++++
 include/hw/xen/xen_backend_ops.h |  2 ++
 3 files changed, 32 insertions(+)

diff --git a/hw/i386/kvm/xen_xenstore.c b/hw/i386/kvm/xen_xenstore.c
index 660d0b72f9..7b894a9884 100644
--- a/hw/i386/kvm/xen_xenstore.c
+++ b/hw/i386/kvm/xen_xenstore.c
@@ -1572,6 +1572,24 @@ static bool xs_be_create(struct qemu_xs_handle *h, xs_transaction_t t,
         return false;
     }
 
+    if (owner == XS_PRESERVE_OWNER) {
+        GList *perms;
+        char letter;
+
+        err = xs_impl_get_perms(h->impl, 0, t, path, &perms);
+        if (err) {
+            errno = err;
+            return false;
+        }
+
+        if (sscanf(perms->data, "%c%u", &letter, &owner) != 2) {
+            errno = EFAULT;
+            g_list_free_full(perms, g_free);
+            return false;
+        }
+        g_list_free_full(perms, g_free);
+    }
+
     perms_list = g_list_append(perms_list,
                                xs_perm_as_string(XS_PERM_NONE, owner));
     perms_list = g_list_append(perms_list,
diff --git a/hw/xen/xen-operations.c b/hw/xen/xen-operations.c
index e00983ec44..1df59b3c08 100644
--- a/hw/xen/xen-operations.c
+++ b/hw/xen/xen-operations.c
@@ -300,6 +300,18 @@ static bool libxenstore_create(struct qemu_xs_handle *h, xs_transaction_t t,
         return false;
     }
 
+    if (owner == XS_PRESERVE_OWNER) {
+        struct xs_permissions *tmp;
+        unsigned int num;
+
+        tmp = xs_get_permissions(h->xsh, 0, path, &num);
+        if (tmp == NULL) {
+            return false;
+        }
+        perms_list[0].id = tmp[0].id;
+        free(tmp);
+    }
+
     return xs_set_permissions(h->xsh, t, path, perms_list,
                               ARRAY_SIZE(perms_list));
 }
diff --git a/include/hw/xen/xen_backend_ops.h b/include/hw/xen/xen_backend_ops.h
index 90cca85f52..273e414559 100644
--- a/include/hw/xen/xen_backend_ops.h
+++ b/include/hw/xen/xen_backend_ops.h
@@ -266,6 +266,8 @@ typedef uint32_t xs_transaction_t;
 #define XS_PERM_READ  0x01
 #define XS_PERM_WRITE 0x02
 
+#define XS_PRESERVE_OWNER        0xFFFE
+
 struct xenstore_backend_ops {
     struct qemu_xs_handle *(*open)(void);
     void (*close)(struct qemu_xs_handle *h);
-- 
2.42.0


  parent reply	other threads:[~2023-11-10 21:36 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-10 20:42 [PATCH v1 0/7] xen-arm: add support for virtio-pci Volodymyr Babchuk
2023-11-10 20:42 ` [PATCH v1 1/7] xen-block: Do not write frontend nodes Volodymyr Babchuk
2023-11-11 10:55   ` David Woodhouse
2023-11-11 13:43     ` Andrew Cooper
2023-11-11 20:18       ` David Woodhouse
2023-11-11 21:51         ` Andrew Cooper
2023-11-11 22:22           ` David Woodhouse
2023-11-14 21:32             ` Volodymyr Babchuk
2023-11-14 21:54               ` David Woodhouse
2023-11-12 20:29   ` Paul Durrant
2023-11-10 20:42 ` Volodymyr Babchuk [this message]
2023-11-11 11:01   ` [PATCH v1 3/7] xen: xenstore: add possibility to preserve owner David Woodhouse
2023-11-12 21:18     ` David Woodhouse
2023-11-13 13:02       ` Volodymyr Babchuk
2023-11-13 13:00     ` Volodymyr Babchuk
2023-11-12 20:43   ` Paul Durrant
2023-11-10 20:42 ` [PATCH v1 2/7] xen-bus: Do not destroy frontend/backend directories Volodymyr Babchuk
2023-11-12 21:57   ` David Woodhouse
2023-11-10 20:42 ` [PATCH v1 6/7] xen_arm: Set mc->max_cpus to GUEST_MAX_VCPUS in xen_arm_init() Volodymyr Babchuk
2023-11-10 20:42 ` [PATCH v1 4/7] xen_pvdev: Do not assume Dom0 when creating a directrory Volodymyr Babchuk
2023-11-12 21:12   ` David Woodhouse
2023-11-15  0:22     ` Volodymyr Babchuk
2023-11-10 20:42 ` [PATCH v1 5/7] xen-bus: Set offline if backend's state is XenbusStateClosed Volodymyr Babchuk
2023-11-11 11:42   ` David Woodhouse
2023-11-12 20:37   ` Paul Durrant
2023-11-10 20:42 ` [PATCH v1 7/7] xen_arm: Add basic virtio-pci support Volodymyr Babchuk
2023-11-12 22:11   ` David Woodhouse
2023-11-13 12:01     ` Volodymyr Babchuk

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=20231110204207.2927514-4-volodymyr_babchuk@epam.com \
    --to=volodymyr_babchuk@epam.com \
    --cc=anthony.perard@citrix.com \
    --cc=dwmw2@infradead.org \
    --cc=eduardo@habkost.net \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=paul@xen.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=sstabellini@kernel.org \
    --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 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.