Find the answer to your Linux question:
Results 1 to 1 of 1
Hello I am working on a little CGI App. And this part converts. Well should convert a Vmware image to a qemu cow hard drive file. I used the following ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,429

    qemu convert error..


    Hello I am working on a little CGI App.
    And this part converts. Well should convert a Vmware image to a qemu cow hard drive file.

    I used the following snipper for example:
    Code:
    $ for i in `ls *[0-9].vmdk`; do qemu-img convert -f vmdk $i -O qcow ${i/vmdk/qcow} ; done && cat *.qcow >> debian.img
    That I stole from kj's blog From Vmware to QEMU

    That turned into:

    Code:
    ...
    open IMAGE_FILE, "+>IMAGE.qcow" || $sys->p_log("Unable to open als file: $!");
      foreach(@files)
      {
        my $file = $loc ."/". $_;
        $sys->p_log("Processing: $file\n");
        if ($file =~ m/([0-9]*)\.vmdk$/)
        { #
          $sys->p_log("Converting $file..\n");
          my $ret = qx!qemu-img convert -f vmdk $file -O qcow $1!;
          $sys->p_log("Converting Done, returned: $ret\n");
          $sys->p_log("Opening $1 with read-only support.\n");
          sub log_die { $sys->p_log("Unable to open file: $1"); die; } 
          open QCOW, "<$1" || log_die($!);
            $sys->p_log("File Opened: $1\n");
            while (<QCOW>){ print IMAGE_FILE $file; }
            $sys->p_log("Write done, next\n");
          close QCOW;
        }
      }
    close IMAGE_FILE;
    ...
    That snipper...
    It looks like it works fine... When you look at the logs:

    Code:
    Wed Nov 18 13:37:36 2009 Processing: /var/autofs/misc/cdrom/.
    Wed Nov 18 13:37:36 2009 Processing: /var/autofs/misc/cdrom/..
    Wed Nov 18 13:37:36 2009 Processing: /var/autofs/misc/cdrom/vmware.log
    Wed Nov 18 13:37:36 2009 Processing: /var/autofs/misc/cdrom/Windows XP Professional.nvram
    Wed Nov 18 13:37:36 2009 Processing: /var/autofs/misc/cdrom/Windows XP Professional.vmdk
    Wed Nov 18 13:37:36 2009 Converting /var/autofs/misc/cdrom/Windows XP Professional.vmdk..
    Wed Nov 18 13:37:36 2009 Converting Done, returned:
    Wed Nov 18 13:37:36 2009 Opening  with read-only support.
    Wed Nov 18 13:37:36 2009 File Opened:
    Wed Nov 18 13:37:36 2009 Write done, next
    Wed Nov 18 13:37:36 2009 Processing: /var/autofs/misc/cdrom/Windows XP Professional.vmsd
    Wed Nov 18 13:37:36 2009 Processing: /var/autofs/misc/cdrom/Windows XP Professional.vmx
    Wed Nov 18 13:37:36 2009 Processing: /var/autofs/misc/cdrom/Windows XP Professional.vmx.lck
    Wed Nov 18 13:37:36 2009 Processing: /var/autofs/misc/cdrom/Windows XP Professional.vmxf
    Wed Nov 18 13:37:36 2009 Processing: /var/autofs/misc/cdrom/Windows XP Professional-f001.vmdk
    Wed Nov 18 13:37:36 2009 Converting /var/autofs/misc/cdrom/Windows XP Professional-f001.vmdk..
    Wed Nov 18 13:37:36 2009 Converting Done, returned:
    Wed Nov 18 13:37:36 2009 Opening 001 with read-only support.
    Wed Nov 18 13:37:36 2009 File Opened: 001
    Wed Nov 18 13:37:36 2009 Write done, next
    Wed Nov 18 13:37:36 2009 Processing: /var/autofs/misc/cdrom/Windows XP Professional-f002.vmdk
    Wed Nov 18 13:37:36 2009 Converting /var/autofs/misc/cdrom/Windows XP Professional-f002.vmdk..
    Wed Nov 18 13:37:36 2009 Converting Done, returned:
    Wed Nov 18 13:37:36 2009 Opening 002 with read-only support.
    Wed Nov 18 13:37:36 2009 File Opened: 002
    Wed Nov 18 13:37:36 2009 Write done, next
    Wed Nov 18 13:37:36 2009 Success!
    However it doesnt even write the file that it should create.
    So, I tried to do this by hand:

    Code:
    [root@system http]# qemu-img convert -f vmdk -O qcow "/var/autofs/misc/cdrom/Windows XP Professional-f001.vmdk" 001
    qemu-img: Could not open '/var/autofs/misc/cdrom/Windows XP Professional-f001.vmdk'
    [root@system http]# ls -alh /var/autofs/misc/cdrom/
    total 3.1G
    dr-xr-xr-x 3 4294967295 4294967295  904 2009-11-18 10:53 .
    drwxr-xr-x 5 root       root          0 2009-11-18 11:41 ..
    -r-xr-xr-x 1 4294967295 4294967295 2.0G 2009-11-18 10:50 Windows XP Professional-f001.vmdk
    -r-xr-xr-x 1 4294967295 4294967295 1.1G 2009-11-18 10:50 Windows XP Professional-f002.vmdk
    -r-xr-xr-x 1 4294967295 4294967295 8.5K 2009-11-18 10:50 Windows XP Professional.nvram
    -r-xr-xr-x 1 4294967295 4294967295  508 2009-11-18 10:49 Windows XP Professional.vmdk
    -r-xr-xr-x 1 4294967295 4294967295    0 2009-11-18 10:03 Windows XP Professional.vmsd
    -r-xr-xr-x 1 4294967295 4294967295 2.0K 2009-11-18 10:24 Windows XP Professional.vmx
    dr-xr-xr-x 2 4294967295 4294967295  100 2009-11-18 10:03 Windows XP Professional.vmx.lck
    -r-xr-xr-x 1 4294967295 4294967295  278 2009-11-18 10:03 Windows XP Professional.vmxf
    -r-xr-xr-x 1 4294967295 4294967295 456K 2009-11-18 10:50 vmware.log
    And now I am more then confused.
    Can anyone help me with this issue?

    Thanks
    Last edited by RobinVossen; 11-18-2009 at 01:30 PM.
    New Users, please read this..
    Google first, then ask..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •