mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
xen: write information about supported backends
Add a Xenstore directory for each supported pv backend. This will allow Xen tools to decide which backend type to use in case there are multiple possibilities. The information is added under /local/domain/<backend-domid>/device-model/<domid>/backends before the "running" state is written to Xenstore. Using a directory for each backend enables us to add parameters for specific backends in the future. This interface is documented in the Xen source repository in the file docs/misc/qemu-backends.txt In order to reuse the Xenstore directory creation already present in hw/xen/xen_devconfig.c move the related functions to hw/xen/xen_backend.c where they fit better. Signed-off-by: Juergen Gross <jgross@suse.com> Acked-by: Anthony PERARD <anthony.perard@citrix.com> Reviewed-by: Wei Liu <wei.liu2@citrix.com> Message-id: 1463062421-613-3-git-send-email-jgross@suse.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
9432e53a5b
commit
637c53ffcb
3 changed files with 67 additions and 50 deletions
|
@ -42,11 +42,36 @@ struct xs_handle *xenstore = NULL;
|
|||
const char *xen_protocol;
|
||||
|
||||
/* private */
|
||||
struct xs_dirs {
|
||||
char *xs_dir;
|
||||
QTAILQ_ENTRY(xs_dirs) list;
|
||||
};
|
||||
static QTAILQ_HEAD(xs_dirs_head, xs_dirs) xs_cleanup =
|
||||
QTAILQ_HEAD_INITIALIZER(xs_cleanup);
|
||||
|
||||
static QTAILQ_HEAD(XenDeviceHead, XenDevice) xendevs = QTAILQ_HEAD_INITIALIZER(xendevs);
|
||||
static int debug = 0;
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
static void xenstore_cleanup_dir(char *dir)
|
||||
{
|
||||
struct xs_dirs *d;
|
||||
|
||||
d = g_malloc(sizeof(*d));
|
||||
d->xs_dir = dir;
|
||||
QTAILQ_INSERT_TAIL(&xs_cleanup, d, list);
|
||||
}
|
||||
|
||||
void xen_config_cleanup(void)
|
||||
{
|
||||
struct xs_dirs *d;
|
||||
|
||||
QTAILQ_FOREACH(d, &xs_cleanup, list) {
|
||||
xs_rm(xenstore, 0, d->xs_dir);
|
||||
}
|
||||
}
|
||||
|
||||
int xenstore_write_str(const char *base, const char *node, const char *val)
|
||||
{
|
||||
char abspath[XEN_BUFSIZE];
|
||||
|
@ -75,6 +100,30 @@ char *xenstore_read_str(const char *base, const char *node)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int xenstore_mkdir(char *path, int p)
|
||||
{
|
||||
struct xs_permissions perms[2] = {
|
||||
{
|
||||
.id = 0, /* set owner: dom0 */
|
||||
}, {
|
||||
.id = xen_domid,
|
||||
.perms = p,
|
||||
}
|
||||
};
|
||||
|
||||
if (!xs_mkdir(xenstore, 0, path)) {
|
||||
xen_be_printf(NULL, 0, "xs_mkdir %s: failed\n", path);
|
||||
return -1;
|
||||
}
|
||||
xenstore_cleanup_dir(g_strdup(path));
|
||||
|
||||
if (!xs_set_permissions(xenstore, 0, path, perms, 2)) {
|
||||
xen_be_printf(NULL, 0, "xs_set_permissions %s: failed\n", path);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xenstore_write_int(const char *base, const char *node, int ival)
|
||||
{
|
||||
char val[12];
|
||||
|
@ -726,6 +775,20 @@ err:
|
|||
|
||||
int xen_be_register(const char *type, struct XenDevOps *ops)
|
||||
{
|
||||
char path[50];
|
||||
int rc;
|
||||
|
||||
if (ops->backend_register) {
|
||||
rc = ops->backend_register();
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(path, sizeof(path), "device-model/%u/backends/%s", xen_domid,
|
||||
type);
|
||||
xenstore_mkdir(path, XS_PERM_NONE);
|
||||
|
||||
return xenstore_scan(type, xen_domid, ops);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue