Unable to migrate a vm

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!
I've attached my code
The error I got was:
run:
Domain:hda2 id 11 running hvm
libvir: Domain error : operation virDomainMigrate forbidden for read only access
exception FOUR caught:org.libvirt.LibvirtException: operation virDomainMigrate 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 virDomainMigrate forbidden for read only access
str1:operation %s forbidden for read only access
str2:virDomainMigrate
str3:null
int1:-1
int2:-1

BUILD SUCCESSFUL (total time: 9 seconds)


PLEASE help me. I've been stuck with it for three days!

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Migrate.java
 *
 * Created on 4 Jun, 2011, 1:00:04 AM
 */

package src.test.java;

import java.util.logging.Level;
import java.util.logging.Logger;
import org.libvirt.Connect;
import org.libvirt.Domain;
import org.libvirt.LibvirtException;

/**
 *
 * @author pre
 */
public class Migrate extends javax.swing.JFrame {

    /** Creates new form Migrate */
    public Migrate() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        vmname123 = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jButton1.setText("Cancel");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Migrate");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jLabel2.setText("Name of VM");

        jLabel1.setText("Migrate Virtual Machine");

        vmname123.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vmname123ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(95, 95, 95)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 113, Short.MAX_VALUE)
                                .addComponent(vmname123, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel1)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(211, 211, 211)
                        .addComponent(jButton2)
                        .addGap(43, 43, 43)
                        .addComponent(jButton1)))
                .addGap(88, 88, 88))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(76, 76, 76)
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(vmname123, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(272, 272, 272)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton1))
                .addGap(29, 29, 29))
        );

        pack();
    }// </editor-fold>

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        System.exit(0);
}

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        Connect conn=null;
        Connect conn1=null;
        Connect conn2=null;
        Domain testDomain = null;

        //connect to host vm
        try{
            conn = new Connect("qemu:///system", true);
        } catch (LibvirtException e){
            System.out.println("exception ONE caught:"+e);
            System.out.println(e.getError());
        }
        //get the domain in host vm
        try {
            testDomain = conn.domainLookupByName(vmname123.getText());
        } 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:" + testDomain.getName() + " id " +
                               testDomain.getID() + " running " +
                               testDomain.getOSType());
        } catch (LibvirtException e1){
            System.out.println("exception THREE caught: "+e1);
            System.out.println(e1.getError());
        }

        //connect to the guest vm
         try{
             conn1 = new Connect("qemu+ssh://root@10.129.54.254/system", true);
             //conn2 = new Connect("qemu+ssh://root@10.129.54.254/system", true);
             Domain migrate1;
             migrate1 = testDomain.migrate(conn1,1,null,"tcp://root@10.129.54.254:49155",0);
        }catch (LibvirtException e2){
            System.out.println("exception FOUR caught:"+e2);
            System.out.println(e2.getError());
             
    }
     
        //migrate the host to guest
        /*try{
            Domain d1;
            migrate = testDomain.migrate(conn1,1, "hda2","tcp://root@10.129.54.254:49155",0);
        }catch (LibvirtException e3){
            System.out.println("exception five caught:"+e3);
            System.out.println(e3.getError());
        }*/
    }
private void vmname123ActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:
}


    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Migrate().setVisible(true);
            }
        });


    }
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JTextField vmname123;
    // End of variables declaration





    

[Index of Archives]     [Virt Tools]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux