mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
hw/xen: Add xenstore wire implementation and implementation stubs
This implements the basic wire protocol for the XenStore commands, punting all the actual implementation to xs_impl_* functions which all just return errors for now. Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Reviewed-by: Paul Durrant <paul@xen.org>
This commit is contained in:
@@ -9,6 +9,7 @@ i386_kvm_ss.add(when: 'CONFIG_XEN_EMU', if_true: files(
|
||||
'xen_evtchn.c',
|
||||
'xen_gnttab.c',
|
||||
'xen_xenstore.c',
|
||||
'xenstore_impl.c',
|
||||
))
|
||||
|
||||
i386_ss.add_all(when: 'CONFIG_KVM', if_true: i386_kvm_ss)
|
||||
|
||||
@@ -3,3 +3,18 @@ kvm_xen_unmap_pirq(int pirq, int gsi) "pirq %d gsi %d"
|
||||
kvm_xen_get_free_pirq(int pirq, int type) "pirq %d type %d"
|
||||
kvm_xen_bind_pirq(int pirq, int port) "pirq %d port %d"
|
||||
kvm_xen_unmask_pirq(int pirq, char *dev, int vector) "pirq %d dev %s vector %d"
|
||||
xenstore_error(unsigned int id, unsigned int tx_id, const char *err) "req %u tx %u err %s"
|
||||
xenstore_read(unsigned int tx_id, const char *path) "tx %u path %s"
|
||||
xenstore_write(unsigned int tx_id, const char *path) "tx %u path %s"
|
||||
xenstore_mkdir(unsigned int tx_id, const char *path) "tx %u path %s"
|
||||
xenstore_directory(unsigned int tx_id, const char *path) "tx %u path %s"
|
||||
xenstore_directory_part(unsigned int tx_id, const char *path, unsigned int offset) "tx %u path %s offset %u"
|
||||
xenstore_transaction_start(unsigned int new_tx) "new_tx %u"
|
||||
xenstore_transaction_end(unsigned int tx_id, bool commit) "tx %u commit %d"
|
||||
xenstore_rm(unsigned int tx_id, const char *path) "tx %u path %s"
|
||||
xenstore_get_perms(unsigned int tx_id, const char *path) "tx %u path %s"
|
||||
xenstore_set_perms(unsigned int tx_id, const char *path) "tx %u path %s"
|
||||
xenstore_watch(const char *path, const char *token) "path %s token %s"
|
||||
xenstore_unwatch(const char *path, const char *token) "path %s token %s"
|
||||
xenstore_reset_watches(void) ""
|
||||
xenstore_watch_event(const char *path, const char *token) "path %s token %s"
|
||||
|
||||
+863
-8
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* QEMU Xen emulation: The actual implementation of XenStore
|
||||
*
|
||||
* Copyright © 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Authors: David Woodhouse <dwmw2@infradead.org>, Paul Durrant <paul@xen.org>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
|
||||
#include "xen_xenstore.h"
|
||||
#include "xenstore_impl.h"
|
||||
|
||||
struct XenstoreImplState {
|
||||
};
|
||||
|
||||
int xs_impl_read(XenstoreImplState *s, unsigned int dom_id,
|
||||
xs_transaction_t tx_id, const char *path, GByteArray *data)
|
||||
{
|
||||
/*
|
||||
* The data GByteArray shall exist, and will be freed by caller.
|
||||
* Just g_byte_array_append() to it.
|
||||
*/
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
int xs_impl_write(XenstoreImplState *s, unsigned int dom_id,
|
||||
xs_transaction_t tx_id, const char *path, GByteArray *data)
|
||||
{
|
||||
/*
|
||||
* The data GByteArray shall exist, will be freed by caller. You are
|
||||
* free to use g_byte_array_steal() and keep the data.
|
||||
*/
|
||||
return ENOSYS;
|
||||
}
|
||||
|
||||
int xs_impl_directory(XenstoreImplState *s, unsigned int dom_id,
|
||||
xs_transaction_t tx_id, const char *path,
|
||||
uint64_t *gencnt, GList **items)
|
||||
{
|
||||
/*
|
||||
* The items are (char *) to be freed by caller. Although it's consumed
|
||||
* immediately so if you want to change it to (const char *) and keep
|
||||
* them, go ahead and change the caller.
|
||||
*/
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
int xs_impl_transaction_start(XenstoreImplState *s, unsigned int dom_id,
|
||||
xs_transaction_t *tx_id)
|
||||
{
|
||||
return ENOSYS;
|
||||
}
|
||||
|
||||
int xs_impl_transaction_end(XenstoreImplState *s, unsigned int dom_id,
|
||||
xs_transaction_t tx_id, bool commit)
|
||||
{
|
||||
return ENOSYS;
|
||||
}
|
||||
|
||||
int xs_impl_rm(XenstoreImplState *s, unsigned int dom_id,
|
||||
xs_transaction_t tx_id, const char *path)
|
||||
{
|
||||
return ENOSYS;
|
||||
}
|
||||
|
||||
int xs_impl_get_perms(XenstoreImplState *s, unsigned int dom_id,
|
||||
xs_transaction_t tx_id, const char *path, GList **perms)
|
||||
{
|
||||
/*
|
||||
* The perms are (char *) in the <perm-as-string> wire format to be
|
||||
* freed by the caller.
|
||||
*/
|
||||
return ENOSYS;
|
||||
}
|
||||
|
||||
int xs_impl_set_perms(XenstoreImplState *s, unsigned int dom_id,
|
||||
xs_transaction_t tx_id, const char *path, GList *perms)
|
||||
{
|
||||
/*
|
||||
* The perms are (const char *) in the <perm-as-string> wire format.
|
||||
*/
|
||||
return ENOSYS;
|
||||
}
|
||||
|
||||
int xs_impl_watch(XenstoreImplState *s, unsigned int dom_id, const char *path,
|
||||
const char *token, xs_impl_watch_fn fn, void *opaque)
|
||||
{
|
||||
/*
|
||||
* When calling the callback @fn, note that the path should
|
||||
* precisely match the relative path that the guest provided, even
|
||||
* if it was a relative path which needed to be prefixed with
|
||||
* /local/domain/${domid}/
|
||||
*/
|
||||
return ENOSYS;
|
||||
}
|
||||
|
||||
int xs_impl_unwatch(XenstoreImplState *s, unsigned int dom_id,
|
||||
const char *path, const char *token,
|
||||
xs_impl_watch_fn fn, void *opaque)
|
||||
{
|
||||
/* Remove the watch that matches all four criteria */
|
||||
return ENOSYS;
|
||||
}
|
||||
|
||||
int xs_impl_reset_watches(XenstoreImplState *s, unsigned int dom_id)
|
||||
{
|
||||
return ENOSYS;
|
||||
}
|
||||
|
||||
XenstoreImplState *xs_impl_create(void)
|
||||
{
|
||||
return g_new0(XenstoreImplState, 1);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* QEMU Xen emulation: The actual implementation of XenStore
|
||||
*
|
||||
* Copyright © 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Authors: David Woodhouse <dwmw2@infradead.org>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
|
||||
#ifndef QEMU_XENSTORE_IMPL_H
|
||||
#define QEMU_XENSTORE_IMPL_H
|
||||
|
||||
typedef uint32_t xs_transaction_t;
|
||||
|
||||
#define XBT_NULL 0
|
||||
|
||||
typedef struct XenstoreImplState XenstoreImplState;
|
||||
|
||||
XenstoreImplState *xs_impl_create(void);
|
||||
|
||||
/*
|
||||
* These functions return *positive* error numbers. This is a little
|
||||
* unconventional but it helps to keep us honest because there is
|
||||
* also a very limited set of error numbers that they are permitted
|
||||
* to return (those in xsd_errors).
|
||||
*/
|
||||
|
||||
int xs_impl_read(XenstoreImplState *s, unsigned int dom_id,
|
||||
xs_transaction_t tx_id, const char *path, GByteArray *data);
|
||||
int xs_impl_write(XenstoreImplState *s, unsigned int dom_id,
|
||||
xs_transaction_t tx_id, const char *path, GByteArray *data);
|
||||
int xs_impl_directory(XenstoreImplState *s, unsigned int dom_id,
|
||||
xs_transaction_t tx_id, const char *path,
|
||||
uint64_t *gencnt, GList **items);
|
||||
int xs_impl_transaction_start(XenstoreImplState *s, unsigned int dom_id,
|
||||
xs_transaction_t *tx_id);
|
||||
int xs_impl_transaction_end(XenstoreImplState *s, unsigned int dom_id,
|
||||
xs_transaction_t tx_id, bool commit);
|
||||
int xs_impl_rm(XenstoreImplState *s, unsigned int dom_id,
|
||||
xs_transaction_t tx_id, const char *path);
|
||||
int xs_impl_get_perms(XenstoreImplState *s, unsigned int dom_id,
|
||||
xs_transaction_t tx_id, const char *path, GList **perms);
|
||||
int xs_impl_set_perms(XenstoreImplState *s, unsigned int dom_id,
|
||||
xs_transaction_t tx_id, const char *path, GList *perms);
|
||||
|
||||
/* This differs from xs_watch_fn because it has the token */
|
||||
typedef void(xs_impl_watch_fn)(void *opaque, const char *path,
|
||||
const char *token);
|
||||
int xs_impl_watch(XenstoreImplState *s, unsigned int dom_id, const char *path,
|
||||
const char *token, xs_impl_watch_fn fn, void *opaque);
|
||||
int xs_impl_unwatch(XenstoreImplState *s, unsigned int dom_id,
|
||||
const char *path, const char *token, xs_impl_watch_fn fn,
|
||||
void *opaque);
|
||||
int xs_impl_reset_watches(XenstoreImplState *s, unsigned int dom_id);
|
||||
|
||||
#endif /* QEMU_XENSTORE_IMPL_H */
|
||||
Reference in New Issue
Block a user