Making a connection to Qemu using Libvirt Java API
Problem statement:
Create a connection to Qemu. Done by the call-conn1 = new Connect("qemu+ssh://login_name@IP/system", false). This is done in one class (connect.java).
Create new VMs on the above machine at the IP. Done by the function call 开发者_JS百科create() in ANOTHER class (create.java)
Doubt: 1. When I run the above program, every time I want to create a VM, I have to create an object of connect.java . Is there any way I could make just ONE connection to Qemu and proceed with my operations (create.suspend) on the VMs running on it? I'm using Swing to create the UI everytime the user wants to create/suspend a VM.
All I had to do to solve this was to create a Global connect variable which connected to the KVM/Xen Hypervisor and pass it to the Swing application I was calling inside this class. One important thing which I'd found out was by default, only 20 connections could ba made to any hypervisor using Libvirt. hence the global variable.
精彩评论