Hello,
when i use libguestfs to ceph rbd by golang, but there has panic:
panic: runtime error: cgo argument has Go pointer to Go pointer
goroutine 1 [running]:
guestfs.(*Guestfs).Add_drive.func11(0xc000010028, 0xcda6a0, 0xc0000d6000, 0xc000090280)
/opt/gopath/src/guestfs/guestfs.go:1440 +0xc2
guestfs.(*Guestfs).Add_drive(0xc000010028, 0x7ffd4b5d67ff, 0xd, 0xc00008d9d8, 0x0)
/opt/gopath/src/guestfs/guestfs.go:1440 +0x1b2
main.OpenImage(0x7ffd4b5d67ff, 0xd, 0x0, 0x0, 0x42110b, 0x7c87e0, 0x4f41e0)
/opt/gopath/src/disk/disk.go:34 +0x371
main.resizeext4(0x7ffd4b5d67ff, 0xd, 0x0, 0x0)
/opt/gopath/src/disk/disk.go:677 +0x60
main.main()
/opt/gopath/src/disk/disk.go:970 +0x5e5
i found struct in guestfs.h
struct guestfs_add_drive_opts_argv {
...
char *const *server;
...
}
so i make a daemon to test. has the same error. how could i to use libguestfs to connect
ceph rbd use golang interface.
package main
/*
#include <stdio.h>
#include <string.h>
struct t_server {
const char *protocol;
char *const *addr;
};
void show(struct t_server *optargs) {
if (optargs->protocol == NULL){
printf("protocol is null \n");
}
printf("proto is %s\n", optargs->protocol);
int num = strlen(*optargs->addr)-1;
int i = 0;
for(i=0;i<num;i++){
printf("%s\n",optargs->addr[i]);
}
}
*/
import "C"
import (
"unsafe"
)
func main(){
c_optargs := C.struct_t_server{}
c_optargs.protocol = C.CString("test")
serverlist := []string{"aaa", "bbb", "ccc"}
var buf []*C.char
for i, _ := range serverlist {
buf = append(buf, (*C.char)(unsafe.Pointer(C.CString(serverlist[i]))))
}
buf = append(buf, (*C.char)(unsafe.Pointer(nil)))
c_optargs.addr = &buf[0]
C.show(&c_optargs)
}