diff options
author | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2015-12-19 09:12:30 +0000 |
---|---|---|
committer | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2015-12-19 09:12:30 +0000 |
commit | 59449295211e2581ec4e073c8f8902fe2f7c04d5 (patch) | |
tree | e8afa4ab42ce7a82dcdc34935bbd178d326a43c8 /sys/dev/pv | |
parent | e39a063aa46c3f0760b04c6a37313b140a0fb7a3 (diff) |
Add xs_setprop to set device properties
Diffstat (limited to 'sys/dev/pv')
-rw-r--r-- | sys/dev/pv/xenstore.c | 31 | ||||
-rw-r--r-- | sys/dev/pv/xenvar.h | 3 |
2 files changed, 32 insertions, 2 deletions
diff --git a/sys/dev/pv/xenstore.c b/sys/dev/pv/xenstore.c index 89d7c006150..9af70ec5f2c 100644 --- a/sys/dev/pv/xenstore.c +++ b/sys/dev/pv/xenstore.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xenstore.c,v 1.7 2015/12/12 21:07:45 reyk Exp $ */ +/* $OpenBSD: xenstore.c,v 1.8 2015/12/19 09:12:29 mikeb Exp $ */ /* * Copyright (c) 2015 Mike Belopuhov @@ -810,3 +810,32 @@ xs_getprop(struct xen_attach_args *xa, const char *property, char *value, return (0); } + +int +xs_setprop(struct xen_attach_args *xa, const char *property, char *value, + int size) +{ + struct xen_softc *sc = xa->xa_parent; + struct xs_transaction xst; + struct iovec iov, *iovp = &iov; + char path[128]; + int error, iov_cnt; + + if (!property) + return (-1); + + memset(&xst, 0, sizeof(xst)); + xst.xst_id = 0; + xst.xst_sc = sc->sc_xs; + if (cold) + xst.xst_flags = XST_POLL; + + iov.iov_base = value; + iov.iov_len = size; + iov_cnt = 1; + + snprintf(path, sizeof(path), "%s/%s", xa->xa_node, property); + if ((error = xs_cmd(&xst, XS_WRITE, path, &iovp, &iov_cnt)) != 0) + return (error); + return (0); +} diff --git a/sys/dev/pv/xenvar.h b/sys/dev/pv/xenvar.h index 2f1ff1e65d9..bb07c772958 100644 --- a/sys/dev/pv/xenvar.h +++ b/sys/dev/pv/xenvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: xenvar.h,v 1.12 2015/12/12 21:07:45 reyk Exp $ */ +/* $OpenBSD: xenvar.h,v 1.13 2015/12/19 09:12:29 mikeb Exp $ */ /* * Copyright (c) 2015 Mike Belopuhov @@ -111,6 +111,7 @@ struct xs_transaction { int xs_cmd(struct xs_transaction *, int, const char *, struct iovec **, int *); int xs_getprop(struct xen_attach_args *, const char *, char *, int); +int xs_setprop(struct xen_attach_args *, const char *, char *, int); void xs_resfree(struct xs_transaction *, struct iovec *, int); #endif /* _XENVAR_H_ */ |