public Connect retrieveQemuConnection(final String qemuURI) throws LibvirtException { return new Connect(qemuURI); }
public boolean isHostSecured() { // Test for host certificates final File confFile = PropertiesUtil.findConfigFile(KeyStoreUtils.AGENT_PROPSFILE); if (confFile == null || !confFile.exists() || !Paths.get(confFile.getParent(), KeyStoreUtils.CERT_FILENAME).toFile().exists()) { return false; } // Test for libvirt TLS configuration try { new Connect(String.format("qemu+tls://%s/system", _privateIp)); } catch (final LibvirtException ignored) { return false; } return true; } }
static public Connect getConnection(String hypervisorURI) throws LibvirtException { s_logger.debug("Looking for libvirtd connection at: " + hypervisorURI); Connect conn = s_connections.get(hypervisorURI); if (conn == null) { s_logger.info("No existing libvirtd connection found. Opening a new one"); conn = new Connect(hypervisorURI, false); s_logger.debug("Successfully connected to libvirt at: " + hypervisorURI); s_connections.put(hypervisorURI, conn); } else { try { conn.getVersion(); } catch (LibvirtException e) { s_logger.error("Connection with libvirtd is broken: " + e.getMessage()); s_logger.debug("Opening a new libvirtd connection to: " + hypervisorURI); conn = new Connect(hypervisorURI, false); s_connections.put(hypervisorURI, conn); } } return conn; }
/** * Connects to the KVM host * * @param url the url of the host * @return the connection object * @throws LibvirtException if the connection fails */ private Connect connectToKVM(String url) throws LibvirtException { ConnectAuth ca = new ConnectAuthDefault(); return new Connect(url, ca, 0); }
/** Create a connection to libvirt in a thread safe manner. */ public static Connect getConnection(String libvirtURL, boolean readOnly) { connectLock.lock(); try { return new Connect(libvirtURL, readOnly); } catch (LibvirtException e) { throw new LibvirtRuntimeException("Unable to connect to " + libvirtURL, e); } finally { connectLock.unlock(); } } }
Connect connect = new Connect(url, false); newRegistration = bundleContext.registerService( Connect.class.getName(), connect, properties);
/** * * @param connectType * @param vmName * @param autoDestroy * @throws LibvirtException */ private VMInstanceProvider(ConnectType connectType) throws VMMgmtException { try { conn = new Connect(connectType.getValue()); // prevent libvirt error messages from cluttering the console: conn.setConnectionErrorCallback(new Libvirt.VirErrorCallback() { @Override public void errorCallback(Pointer userData, virError error) { } }); } catch (LibvirtException ex) { throw new VMMgmtException(ex); } }