unikraft / app-redis

Redis on Unikraft
5 stars 12 forks source link

Running Redis with Custom Config File #4

Closed FredrikBakken closed 2 years ago

FredrikBakken commented 2 years ago

Hi,

I have successfully gotten the Redis application up and running according to the documentation, but I am having some issues when trying to run it with a custom configuration file. I have added a new directory to the root path of the ~.unikraft/apps/app-redis directory, named redis_files. Within this directory, I have placed my custom Redis configuration file named redis.conf.

Within the menuconfig, I enabled the usage of vfscore and selected 9PFS (set the name of the Default root device to fs0).

My launch commands looks like this:

sudo qemu-system-x86_64 \
    -netdev bridge,id=en0,br=virbr0 \
    -device virtio-net-pci,netdev=en0 \
    -fsdev local,id=myid,security_model=none,path=redis_files \
    -device virtio-9p-pci,fsdev=myid,mount_tag=fs0,disable-modern=on,disable-legacy=off \
    -kernel build/app-redis_kvm-x86_64 \
    -append "/redis.conf --" \
    -append "netdev.ipv4_addr=172.44.0.2 netdev.ipv4_gw_addr=172.44.0.1 netdev.ipv4_subnet_mask=255.255.255.0 --" \
    -cpu host \
    -enable-kvm \
    -m 100M \
    -nographic

Which launches the application with the following output into the terminal:

SeaBIOS (version 1.13.0-1ubuntu1.1)

iPXE (http://ipxe.org) 00:03.0 CA00 PCI2.10 PnP PMM+0638C780+062CC780 CA00

Booting from ROM..0: Set IPv4 address 172.44.0.2 mask 255.255.255.0 gw 172.44.0.1
en0: Added
en0: Interface is up
Powered by
o.   .o       _ _               __ _
Oo   Oo  ___ (_) | __ __  __ _ ' _) :_
oO   oO ' _ `| | |/ /  _)' _` | |_|  _)
oOo oOO| | | | |   (| | | (_) |  _) :_
 OoOoO ._, ._:_:_,\_._,  .__,_:_, \___)
                   Tethys 0.5.0~b8be82b
1:C 23 Feb 2022 22:12:40.010 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 23 Feb 2022 22:12:40.012 # Redis version=5.0.6, bits=64, commit=c5ee3442, modified=1, pid=1, just started
1:C 23 Feb 2022 22:12:40.015 # Warning: no config file specified, using the default config. In order to specify a config file use build/app-redis_kvm-x86_64 /path/to/redis.cof
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 5.0.6 (c5ee3442/1) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 1
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

1:M 23 Feb 2022 22:12:40.070 # Server initialized
1:M 23 Feb 2022 22:12:40.074 * Ready to accept connections

This makes me think that the custom config file is not appended as it prints the following message: Warning: no config file specified, using the default config. In order to specify a config file use build/app-redis_kvm-x86_64 /path/to/redis.cof

The Redis CLI works as normal:

$ ./redis-cli -h 172.44.0.2 -p 6379
172.44.0.2:6379> 

While curl is still refused:

$ curl 172.44.0.2  6379
curl: (7) Failed to connect to 172.44.0.2 port 80: Connection refused

Any suggestions for how to successfully load a custom Redis.conf file into the unikernel?

FredrikBakken commented 2 years ago

Update from my side. I changed the git branches for unikraft, pthread-embedded, newlib, lwip, and redis to stable and used the qemu-guest command from USoC21 to make it load the configuration file as wanted:

qemu-guest \
    -k ./build/redis_kvm-x86_64 \
    -a "/redis.conf" \
    -b kraft0 \
    -e ./redis_files

The terminal output no longer shows the warning message: Warning: no config file specified, using the default config. In order to specify a config file use build/app-redis_kvm-x86_64 /path/to/redis.cof:

SeaBIOS (version 1.13.0-1ubuntu1.1)

iPXE (http://ipxe.org) 00:02.0 C100 PCI2.10 PnP PMM+03F8C800+03ECC800 C100

Booting from ROM...
en1: Added
en1: Interface is up
Powered by
o.   .o       _ _               __ _
Oo   Oo  ___ (_) | __ __  __ _ ' _) :_
oO   oO ' _ `| | |/ /  _)' _` | |_|  _)
oOo oOO| | | | |   (| | | (_) |  _) :_
 OoOoO ._, ._:_:_,\_._,  .__,_:_, \___)
                    Dione 0.6.0~6a2069e
1:C 24 Feb 2022 18:04:57.013 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 24 Feb 2022 18:04:57.015 # Redis version=5.0.6, bits=64, commit=c5ee3442, modified=1, pid=1, just started
1:C 24 Feb 2022 18:04:57.017 # Configuration loaded
1:M 24 Feb 2022 18:04:57.021 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 5.0.6 (c5ee3442/1) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 1
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

1:M 24 Feb 2022 18:04:57.058 # Server initialized
1:M 24 Feb 2022 18:04:57.059 * Ready to accept connections
en1: Set IPv4 address 172.44.0.76 mask 255.255.255.0 gw 172.44.0.1

However, I am still not able to execute curl:

$ curl 172.44.0.76 6379
curl: (7) Failed to connect to 172.44.0.76 port 80: Connection refused
curl: (28) Failed to connect to 6379 port 80: Connection timed out

But, I guess that should not be possible anyways?

Note to myself... need to read up further on what is possible and impossible with Redis.

telnet works as I want it to :)

telnet 172.44.0.76 6379
Trying 172.44.0.76...
Connected to 172.44.0.76.
Escape character is '^]'.
ping
+PONG