mirror of
https://gitlab.com/marcandre.lureau/qemu-display.git
synced 2025-02-06 18:49:30 +00:00
demo: teach to connect to a different bus
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
cbe0cf891c
commit
5f0279eb1f
@ -25,6 +25,7 @@ struct App {
|
||||
#[derive(Debug, Default)]
|
||||
struct AppOptions {
|
||||
vm_name: Option<String>,
|
||||
address: Option<String>,
|
||||
list: bool,
|
||||
}
|
||||
|
||||
@ -39,6 +40,14 @@ impl App {
|
||||
"VM name",
|
||||
Some("VM-NAME"),
|
||||
);
|
||||
app.add_main_option(
|
||||
"address",
|
||||
glib::Char(b'a' as _),
|
||||
glib::OptionFlags::NONE,
|
||||
glib::OptionArg::String,
|
||||
"D-Bus bus address",
|
||||
None,
|
||||
);
|
||||
app.add_main_option(
|
||||
"list",
|
||||
glib::Char(0),
|
||||
@ -64,6 +73,9 @@ impl App {
|
||||
println!("Version: {}", env!("CARGO_PKG_VERSION"));
|
||||
return 0;
|
||||
}
|
||||
if let Some(arg) = opt.lookup_value("address", None) {
|
||||
app_opt.address = arg.get::<String>();
|
||||
}
|
||||
if opt.lookup_value("list", None).is_some() {
|
||||
app_opt.list = true;
|
||||
}
|
||||
@ -96,7 +108,12 @@ impl App {
|
||||
let app_clone = app_clone.clone();
|
||||
let opt_clone = opt.clone();
|
||||
MainContext::default().spawn_local(async move {
|
||||
let conn = zbus::ConnectionBuilder::session()
|
||||
let builder = if let Some(addr) = &opt_clone.borrow().address {
|
||||
zbus::ConnectionBuilder::address(addr.as_str())
|
||||
} else {
|
||||
zbus::ConnectionBuilder::session()
|
||||
};
|
||||
let conn = builder
|
||||
.unwrap()
|
||||
.internal_executor(false)
|
||||
.build()
|
||||
|
Loading…
x
Reference in New Issue
Block a user