summaryrefslogtreecommitdiff
path: root/xenstoreclient
diff options
context:
space:
mode:
authorWei Xie <xiewei.fire@gmail.com>2018-03-22 14:50:11 +0800
committerCheng Zhang <cheng.zhang@citrix.com>2018-03-22 14:50:11 +0800
commit1ea5634256b9a30dde3f86bfce08e4269899b884 (patch)
tree28f83ce6566c1f2881e4daa4c97b5f6617ed1182 /xenstoreclient
parent6219ce6418c7a9bae6ceb11c73a17314a984b7c7 (diff)
downloadvyos-xe-guest-utilities-1ea5634256b9a30dde3f86bfce08e4269899b884.tar.gz
vyos-xe-guest-utilities-1ea5634256b9a30dde3f86bfce08e4269899b884.zip
Add SRIOV VF Supportv7.10.0
* CP-26664: Add SRIOV VF IP collection (#49) - Add support for xenstore-ls Signed-off-by: Wei Xie <wei.xie@citrix.com> * CP-25986: Add xenstore-list command Signed-off-by: Deli Zhang <Deli.Zhang@citrix.com> * CP-27273: Enhance the printing format of guest_utilities.xs_list for HCL using. (#51) Signed-off-by: Wei Xie <wei.xie@citrix.com>
Diffstat (limited to 'xenstoreclient')
-rw-r--r--xenstoreclient/xenstore.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/xenstoreclient/xenstore.go b/xenstoreclient/xenstore.go
index 5112c40..571481a 100644
--- a/xenstoreclient/xenstore.go
+++ b/xenstoreclient/xenstore.go
@@ -63,6 +63,7 @@ type XenStoreClient interface {
Close() error
DO(packet *Packet) (*Packet, error)
Read(path string) (string, error)
+ List(path string) ([]string, error)
Mkdir(path string) error
Rm(path string) error
Write(path string, value string) error
@@ -281,6 +282,25 @@ func (xs *XenStore) Read(path string) (string, error) {
return string(resp.Value), nil
}
+func (xs *XenStore) List(path string) ([]string, error) {
+ v := []byte(path + "\x00")
+ req := &Packet{
+ OpCode: XS_DIRECTORY,
+ Req: 0,
+ TxID: xs.tx,
+ Length: uint32(len(v)),
+ Value: v,
+ }
+ resp, err := xs.DO(req)
+ if err != nil {
+ return []string{}, err
+ }
+ subItems := strings.Split(
+ string(bytes.Trim(resp.Value, "\x00")), "\x00")
+
+ return subItems, nil
+}
+
func (xs *XenStore) Mkdir(path string) error {
v := []byte(path + "\x00")
req := &Packet{
@@ -507,6 +527,10 @@ func (xs *CachedXenStore) Read(path string) (string, error) {
return xs.xs.Read(path)
}
+func (xs *CachedXenStore) List(path string) ([]string, error) {
+ return xs.xs.List(path)
+}
+
func (xs *CachedXenStore) Mkdir(path string) error {
return xs.xs.Mkdir(path)
}