@@ -487,32 +487,46 @@ def make_parser():
487
487
)
488
488
489
489
g_remote = parser .add_argument_group (title = "Remote Console" )
490
- cli_srv_choices = ["console" , "ssh" ]
491
490
492
491
g_remote .add_argument (
493
- "--server " ,
492
+ "--console " ,
494
493
action = "store" ,
495
- const = cli_srv_choices [0 ],
496
494
nargs = "?" ,
497
- choices = cli_srv_choices ,
498
- help = "Enable a server to communicate later from the host to the device using '--client'. "
495
+ type = int ,
496
+ const = 2222 ,
497
+ metavar = "PORT" ,
498
+ help = "Enable a server to communicate later from the host using '--console-client'. "
499
499
+ "By default, a simple console will be offered using a VSOCK connection, and 'socat' for the proxy."
500
500
)
501
501
502
502
g_remote .add_argument (
503
- "--client" ,
503
+ "--console- client" ,
504
504
action = "store" ,
505
- const = cli_srv_choices [0 ],
506
505
nargs = "?" ,
507
- choices = cli_srv_choices ,
508
- help = "Connect to a VM launched with the '--server' option for a remote control." ,
506
+ type = int ,
507
+ const = 2222 ,
508
+ metavar = "PORT" ,
509
+ help = "Connect to a VM launched with the '--console' option for a remote control." ,
509
510
)
510
511
511
512
g_remote .add_argument (
512
- "--port " ,
513
+ "--ssh " ,
513
514
action = "store" ,
515
+ nargs = "?" ,
514
516
type = int ,
515
- help = "Unique port to communicate with a VM." ,
517
+ const = 2222 ,
518
+ metavar = "PORT" ,
519
+ help = "Enable SSH server to communicate later from the host to using '--ssh-client'."
520
+ )
521
+
522
+ g_remote .add_argument (
523
+ "--ssh-client" ,
524
+ action = "store" ,
525
+ nargs = "?" ,
526
+ type = int ,
527
+ const = 2222 ,
528
+ metavar = "PORT" ,
529
+ help = "Connect to a VM launched with the '--ssh' option for a remote control." ,
516
530
)
517
531
518
532
g_remote .add_argument (
@@ -992,23 +1006,35 @@ def _get_virtme_net_mac_address(self, args):
992
1006
else :
993
1007
self .virtme_param ["net_mac_address" ] = ""
994
1008
995
- def _get_virtme_server (self , args ):
996
- if args .server is not None :
997
- self .virtme_param ["server" ] = "--server " + args .server
1009
+ def _get_virtme_console (self , args ):
1010
+ if args .console is not None and args .ssh is not None :
1011
+ arg_fail ('--console cannot be used with --ssh' , show_usage = False )
1012
+
1013
+ if args .console is not None :
1014
+ self .virtme_param ["console" ] = f"--server console --port { args .console } "
998
1015
else :
999
- self .virtme_param ["server" ] = ""
1016
+ self .virtme_param ["console" ] = ""
1017
+
1018
+ def _get_virtme_console_client (self , args ):
1019
+ if args .console_client is not None :
1020
+ self .virtme_param ["console_client" ] = f"--client console --port { args .console_client } "
1021
+ else :
1022
+ self .virtme_param ["console_client" ] = ""
1023
+
1024
+ def _get_virtme_ssh (self , args ):
1025
+ if args .console is not None and args .ssh is not None :
1026
+ arg_fail ('--console cannot be used with --ssh' , show_usage = False )
1000
1027
1001
- def _get_virtme_client (self , args ):
1002
- if args .client is not None :
1003
- self .virtme_param ["client" ] = "--client " + args .client
1028
+ if args .ssh is not None :
1029
+ self .virtme_param ["ssh" ] = f"--server ssh --port { args .ssh } "
1004
1030
else :
1005
- self .virtme_param ["client " ] = ""
1031
+ self .virtme_param ["ssh " ] = ""
1006
1032
1007
- def _get_virtme_port (self , args ):
1008
- if args .port is not None :
1009
- self .virtme_param ["port " ] = "--port " + str ( args .port )
1033
+ def _get_virtme_ssh_client (self , args ):
1034
+ if args .ssh_client is not None :
1035
+ self .virtme_param ["ssh_client " ] = f "--client ssh --port { args .ssh_client } "
1010
1036
else :
1011
- self .virtme_param ["port " ] = ""
1037
+ self .virtme_param ["ssh_client " ] = ""
1012
1038
1013
1039
def _get_virtme_remote_cmd (self , args ):
1014
1040
if args .remote_cmd is not None :
@@ -1190,9 +1216,10 @@ def run(self, args):
1190
1216
self ._get_virtme_mods (args )
1191
1217
self ._get_virtme_network (args )
1192
1218
self ._get_virtme_net_mac_address (args )
1193
- self ._get_virtme_server (args )
1194
- self ._get_virtme_client (args )
1195
- self ._get_virtme_port (args )
1219
+ self ._get_virtme_console (args )
1220
+ self ._get_virtme_console_client (args )
1221
+ self ._get_virtme_ssh (args )
1222
+ self ._get_virtme_ssh_client (args )
1196
1223
self ._get_virtme_remote_cmd (args )
1197
1224
self ._get_virtme_disk (args )
1198
1225
self ._get_virtme_sound (args )
@@ -1234,9 +1261,10 @@ def run(self, args):
1234
1261
+ f'{ self .virtme_param ["mods" ]} '
1235
1262
+ f'{ self .virtme_param ["network" ]} '
1236
1263
+ f'{ self .virtme_param ["net_mac_address" ]} '
1237
- + f'{ self .virtme_param ["server" ]} '
1238
- + f'{ self .virtme_param ["client" ]} '
1239
- + f'{ self .virtme_param ["port" ]} '
1264
+ + f'{ self .virtme_param ["console" ]} '
1265
+ + f'{ self .virtme_param ["console_client" ]} '
1266
+ + f'{ self .virtme_param ["ssh" ]} '
1267
+ + f'{ self .virtme_param ["ssh_client" ]} '
1240
1268
+ f'{ self .virtme_param ["remote_cmd" ]} '
1241
1269
+ f'{ self .virtme_param ["disk" ]} '
1242
1270
+ f'{ self .virtme_param ["sound" ]} '
0 commit comments