MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / main

Function main

cloud-hypervisor/src/bin/ch-remote.rs:1154–1286  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1152}
1153
1154fn main() {
1155 env_logger::init();
1156 let app = Command::new("ch-remote")
1157 .author(env!("CARGO_PKG_AUTHORS"))
1158 .version(env!("BUILD_VERSION"))
1159 .about("Remotely control a cloud-hypervisor VMM.")
1160 .arg_required_else_help(true)
1161 .subcommand_required(true)
1162 .args(get_cli_args())
1163 .subcommands(get_cli_commands_sorted());
1164
1165 let matches = app.get_matches();
1166
1167 let mut target_api = match (
1168 matches.get_one::<String>("api-socket"),
1169 #[cfg(feature = "dbus_api")]
1170 matches.get_one::<String>("dbus-service-name"),
1171 #[cfg(feature = "dbus_api")]
1172 matches.get_one::<String>("dbus-object-path"),
1173 ) {
1174 #[cfg(not(feature = "dbus_api"))]
1175 (Some(api_sock),) => TargetApi::HttpApi(
1176 UnixStream::connect(api_sock).unwrap_or_else(|e| {
1177 error!("Error opening HTTP socket: {e}");
1178 process::exit(1)
1179 }),
1180 PhantomData,
1181 ),
1182 #[cfg(feature = "dbus_api")]
1183 (Some(api_sock), None, None) => TargetApi::HttpApi(
1184 UnixStream::connect(api_sock).unwrap_or_else(|e| {
1185 error!("Error opening HTTP socket: {e}");
1186 process::exit(1)
1187 }),
1188 PhantomData,
1189 ),
1190 #[cfg(feature = "dbus_api")]
1191 (None, Some(dbus_name), Some(dbus_path)) => TargetApi::DBusApi(
1192 DBusApi1ProxyBlocking::new_connection(
1193 dbus_name,
1194 dbus_path,
1195 matches.get_flag("dbus-system-bus"),
1196 )
1197 .map_err(Error::DBusApiClient)
1198 .unwrap_or_else(|e| {
1199 error!("Error creating D-Bus proxy: {e}");
1200 process::exit(1)
1201 }),
1202 ),
1203 #[cfg(feature = "dbus_api")]
1204 (Some(_), Some(_) | None, Some(_) | None) => {
1205 error!(
1206 "`api-socket` and (dbus-service-name or dbus-object-path) are mutually exclusive"
1207 );
1208 process::exit(1);
1209 }
1210 _ => {
1211 error!(

Callers

nothing calls this directly

Calls 8

newFunction · 0.85
get_cli_argsFunction · 0.85
get_cli_commands_sortedFunction · 0.85
DBusApiClass · 0.85
cli_print_error_chainFunction · 0.85
argsMethod · 0.80
do_commandMethod · 0.80
versionMethod · 0.45

Tested by

no test coverage detected