2

so I'm currently doing my thesis and a part of it is to communicate with KVM (Kernel Based Virtual Machine). I was already able to establish a connection through the use of the libvirt Java Binding. The virtual machine i created in KVM (centostest) is already up and running, however i want to shut it down but i got the following errors:

libvir: Domain error : operation virDomainShutdown forbidden for read only access org.libvirt.LibvirtException: operation virDomainShutdown forbidden for read only access at org.libvirt.ErrorHandler.processError(ErrorHandler.java:33) at org.libvirt.Connect.processError(Connect.java:1322) at org.libvirt.Domain.processError(Domain.java:830) at org.libvirt.Domain.shutdown(Domain.java:972) at Main.testkvm(Main.java:31) at Main.main(Main.java:16)

Below is a portion of the code:

Connect conn;
    try {
        conn = new Connect("qemu:///system", true);
        Domain testDomain = conn.domainLookupByName("centostest");
        testDomain.shutdown();

    } catch (LibvirtException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

Any suggestions?

joanna
  • 117
  • 1
  • 4
  • 12

1 Answers1

1

You are using read-only connection. Try this:

conn = new Connect("qemu:///system", false);
Cyb.org
  • 101
  • 1
  • 3