Connect conn=null;
Connect conn1=null;
Connect conn2=null;
Domain testDomain1 = null;
//connect to host vm
try{
conn = new Connect("qemu:///system", true);
System.out.println("exception ONE:");
} catch (LibvirtException e){
System.out.println("exception ONE caught:"+e);
System.out.println(e.getError());
}
//get the domain in host vm
try {
testDomain1 = conn.domainLookupByName("hda1");
System.out.println("exception TWO:");
} catch (LibvirtException ex) {
System.out.println("exception TWO CAUGHT");
//Logger.getLogger(Migrate.class.getName()).log(Level.SEVERE, null, ex);
}
//check if domain is running
try{
System.out.println("Domain:" + testDomain1.getName() + " id " +
testDomain1.getID() + " running " +
testDomain1.getOSType());
System.out.println("exception THREE:");
} catch (LibvirtException e1){
System.out.println("exception THREE caught: "+e1);
System.out.println(e1.getError());
}
/*try{
Domain migrate1;
System.out.println("done with ssh");
System.out.println("exception FOUR:");
}catch (LibvirtException e2){
System.out.println("exception FOUR caught:"+e2);
System.out.println(e2.getError());
}*/
try{
testDomain1.destroy();
System.out.println("Destroyed"+testDomain1);
}
catch(LibvirtException e4){
System.out.println("exception FOUR caught: "+e4);
System.out.println(e4.getError());
}
exception ONE:
exception TWO:
Domain:test id 1 running linux
exception THREE:
libvir: Domain error : operation virDomainDestroy forbidden for read only access
exception FOUR caught: org.libvirt.LibvirtException: operation virDomainDestroy forbidden for read only access
level:VIR_ERR_ERROR
code:VIR_ERR_OPERATION_DENIED
domain:VIR_FROM_DOM
hasConn:false
hasDom:false
hasNet:false
message:operation virDomainDestroy forbidden for read only access
str1:operation %s forbidden for read only access
str2:virDomainDestroy
str3:null
int1:-1
int2:-1
BUILD SUCCESSFUL (total time: 23 minutes 38 seconds)