Last active
November 9, 2015 12:45
-
-
Save wido/30457cbe66e3965f00de to your computer and use it in GitHub Desktop.
libvirt-java Qemu Guest Agent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.libvirt.Connect; | |
import org.libvirt.Domain; | |
import org.libvirt.LibvirtException; | |
public class GuestAgent { | |
public static void main(String argv[]) { | |
Connect conn = null; | |
try { | |
conn = new Connect("qemu+tcp://[::1]/system"); | |
Domain testDomain = conn.domainLookupByName("guest-agent"); | |
String result = testDomain.qemuAgentCommand("{\"execute\":\"guest-network-get-interfaces\"}", 2, 0); | |
System.out.println(result); | |
} catch (LibvirtException e) { | |
System.out.println("Failed to execute command: " + e.getMessage()); | |
} catch (Exception e) { | |
System.out.println(e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment