@@ -479,13 +479,13 @@ public KVMStoragePool createStoragePool(String name, String host, int port,
479479 // if anyone is, undefine the pool so we can define it as requested.
480480 // This should be safe since a pool in use can't be removed, and no
481481 // volumes are affected by unregistering the pool with libvirt.
482- s_logger .debug ("Didn't find an existing storage pool " + name
482+ s_logger .debug ("Didn't find an existing storage pool " + name
483483 + " by UUID, checking for pools with duplicate paths" );
484484
485485 try {
486486 String [] poolnames = conn .listStoragePools ();
487487 for (String poolname : poolnames ) {
488- s_logger .debug ("Checking path of existing pool " + poolname
488+ s_logger .debug ("Checking path of existing pool " + poolname
489489 + " against pool we want to create" );
490490 StoragePool p = conn .storagePoolLookupByName (poolname );
491491 LibvirtStoragePoolDef pdef = getStoragePoolDef (conn , p );
@@ -503,7 +503,7 @@ public KVMStoragePool createStoragePool(String name, String host, int port,
503503 }
504504 }
505505 } catch (LibvirtException e ) {
506- s_logger .error ("Failure in attempting to see if an existing storage pool might "
506+ s_logger .error ("Failure in attempting to see if an existing storage pool might "
507507 + "be using the path of the pool to be created:" + e );
508508 }
509509
@@ -546,14 +546,14 @@ public KVMStoragePool createStoragePool(String name, String host, int port,
546546 pool .setCapacity (sp .getInfo ().capacity );
547547 pool .setUsed (sp .getInfo ().allocation );
548548 pool .setAvailable (sp .getInfo ().available );
549-
549+
550550 return pool ;
551551 } catch (LibvirtException e ) {
552552 String error = e .toString ();
553553 if (error .contains ("Storage source conflict" )) {
554554 throw new CloudRuntimeException ("A pool matching this location already exists in libvirt, "
555- + " but has a different UUID/Name. Cannot create new pool without first "
556- + " removing it. Check for inactive pools via 'virsh pool-list --all'. "
555+ + " but has a different UUID/Name. Cannot create new pool without first "
556+ + " removing it. Check for inactive pools via 'virsh pool-list --all'. "
557557 + error );
558558 } else {
559559 throw new CloudRuntimeException (error );
@@ -824,7 +824,7 @@ public KVMPhysicalDisk createDiskFromTemplate(KVMPhysicalDisk template,
824824 if ((srcPool .getSourceHost ().equals (destPool .getSourceHost ())) && (srcPool .getSourceDir ().equals (destPool .getSourceDir ()))) {
825825 /* We are on the same Ceph cluster, but we require RBD format 2 on the source image */
826826 s_logger .debug ("Trying to perform a RBD clone (layering) since we are operating in the same storage pool" );
827-
827+
828828 Rados r = new Rados (srcPool .getAuthUserName ());
829829 r .confSet ("mon_host" , srcPool .getSourceHost () + ":" + srcPool .getSourcePort ());
830830 r .confSet ("key" , srcPool .getAuthSecret ());
@@ -894,7 +894,7 @@ public KVMPhysicalDisk createDiskFromTemplate(KVMPhysicalDisk template,
894894
895895 sRbd .close (srcImage );
896896 dRbd .close (destImage );
897-
897+
898898 rSrc .ioCtxDestroy (sIO );
899899 rDest .ioCtxDestroy (dIO );
900900 }
@@ -965,12 +965,21 @@ public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name,
965965 for Secondary Storage
966966 */
967967
968+ KVMStoragePool srcPool = disk .getPool ();
969+ PhysicalDiskFormat sourceFormat = disk .getFormat ();
970+ String sourcePath = disk .getPath ();
971+
968972 KVMPhysicalDisk newDisk ;
969973 if (destPool .getType () != StoragePoolType .RBD ) {
970974 if (disk .getFormat () == PhysicalDiskFormat .TAR ) {
971975 newDisk = destPool .createPhysicalDisk (name , PhysicalDiskFormat .DIR , disk .getVirtualSize ());
972976 } else {
973- newDisk = destPool .createPhysicalDisk (name , disk .getVirtualSize ());
977+ /* If the source device is on a RBD storage pool force the new disk to the same format (RAW) */
978+ if (srcPool .getType () != StoragePoolType .RBD ) {
979+ newDisk = destPool .createPhysicalDisk (name , disk .getVirtualSize ());
980+ } else {
981+ newDisk = destPool .createPhysicalDisk (name , sourceFormat , disk .getVirtualSize ());
982+ }
974983 }
975984 } else {
976985 newDisk = new KVMPhysicalDisk (destPool .getSourceDir () + "/" + name , name , destPool );
@@ -979,10 +988,7 @@ public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name,
979988 newDisk .setVirtualSize (disk .getSize ());
980989 }
981990
982- KVMStoragePool srcPool = disk .getPool ();
983991 String destPath = newDisk .getPath ();
984- String sourcePath = disk .getPath ();
985- PhysicalDiskFormat sourceFormat = disk .getFormat ();
986992 PhysicalDiskFormat destFormat = newDisk .getFormat ();
987993
988994 QemuImg qemu = new QemuImg ();
@@ -1116,11 +1122,7 @@ public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name,
11161122 srcPool .getAuthSecret (),
11171123 sourcePath ));
11181124 srcFile .setFormat (sourceFormat );
1119- destFile = new QemuImgFile (KVMPhysicalDisk .RBDStringBuilder (destPool .getSourceHost (),
1120- destPool .getSourcePort (),
1121- destPool .getAuthUserName (),
1122- destPool .getAuthSecret (),
1123- destPath ));
1125+ destFile = new QemuImgFile (destPath );
11241126 destFile .setFormat (destFormat );
11251127
11261128 try {
0 commit comments