From bea73f0caa62e43ec7c9df12f463d380380287e5 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Fri, 22 Jun 2012 15:34:51 +0200 Subject: [PATCH 1/4] Feature #1312: Remove BUS from the vmm KVM attach_disk script --- src/vmm_mad/remotes/kvm/attach_disk | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/vmm_mad/remotes/kvm/attach_disk b/src/vmm_mad/remotes/kvm/attach_disk index 42a36141ab..a447ba7ce5 100755 --- a/src/vmm_mad/remotes/kvm/attach_disk +++ b/src/vmm_mad/remotes/kvm/attach_disk @@ -40,14 +40,12 @@ while IFS= read -r -d '' element; do done < <($XPATH $DISK_XPATH/DRIVER \ $DISK_XPATH/TYPE \ $DISK_XPATH/READONLY \ - $DISK_XPATH/BUS \ $DISK_XPATH/CACHE) DRIVER="${XPATH_ELEMENTS[0]:-$DEFAULT_TYPE}" TYPE="${XPATH_ELEMENTS[1]}" READONLY="${XPATH_ELEMENTS[2]}" -BUS="${XPATH_ELEMENTS[3]}" -CACHE="${XPATH_ELEMENTS[4]}" +CACHE="${XPATH_ELEMENTS[3]}" TYPE=$(echo "$TYPE"|tr A-Z a-z) @@ -68,7 +66,6 @@ cdrom) esac [ -n "$CACHE" ] && CACHE="cache='$CACHE'" -[ -n "$BUS" ] && BUS="bus='$BUS'" if [ "$READONLY" = "YES" ]; then READONLY="" @@ -82,7 +79,7 @@ cat < $ATTACH_FILE - + $READONLY EOF From d5cb78a1d844db2d29122a729645699ed277efb7 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Fri, 22 Jun 2012 15:33:45 +0200 Subject: [PATCH 2/4] Feature #1312: Remove BUS attribute from sunstone templates, images, hotplugging --- src/sunstone/public/js/plugins/images-tab.js | 12 -------- .../public/js/plugins/templates-tab.js | 30 +------------------ src/sunstone/public/js/plugins/vms-tab.js | 1 - 3 files changed, 1 insertion(+), 42 deletions(-) diff --git a/src/sunstone/public/js/plugins/images-tab.js b/src/sunstone/public/js/plugins/images-tab.js index dc55758419..c52d9e51e1 100644 --- a/src/sunstone/public/js/plugins/images-tab.js +++ b/src/sunstone/public/js/plugins/images-tab.js @@ -98,15 +98,6 @@ var create_image_tmpl = \
'+tr("Prefix for the emulated device this image will be mounted at. For instance, “hd”, “sd”. If omitted, the default value is the one defined in oned.conf (installation default is “hd”).")+'
\ \ -
\ - \ - \ -
'+tr("Type of disk device to emulate.")+'
\ -
\
\ \ \ @@ -909,9 +900,6 @@ function setupCreateImageDialog(){ img_json["DEV_PREFIX"] = dev_prefix; } - var bus = $('#img_bus',this).val(); - img_json["BUS"] = bus; - var driver = $('#img_driver',this).val(); if (driver.length) img_json["DRIVER"] = driver; diff --git a/src/sunstone/public/js/plugins/templates-tab.js b/src/sunstone/public/js/plugins/templates-tab.js index ef1fb7a7a5..5b97595544 100644 --- a/src/sunstone/public/js/plugins/templates-tab.js +++ b/src/sunstone/public/js/plugins/templates-tab.js @@ -188,7 +188,7 @@ var create_template_tmpl = '
\ \ \ \
\ @@ -211,12 +211,6 @@ var create_template_tmpl = '
\
'+tr("Name of the image to use")+'
\ \
\ -
\ - \ - \ -
'+tr("Type of disk device to emulate: ide, scsi")+'
\ -
\
\ \ \ @@ -1020,7 +1014,6 @@ function setupCreateTemplateDialog(){ //empty selects $('select#BOOT',section_os_boot).empty(); $('select#TYPE',section_disks).empty(); - $('select#BUS',section_disks).empty(); //hide options about boot method $('div#kernel_bootloader',section_os_boot).show(); @@ -1082,7 +1075,6 @@ function setupCreateTemplateDialog(){ //KVM particularities: // * Add custom disk types // * Add custom boot options - // * Add custom bus options // * Show boot options // * Set the raw type to kvm // * Show the inputs and graphics section @@ -1108,13 +1100,6 @@ function setupCreateTemplateDialog(){ $('select#BOOT',section_os_boot).parent().show(); $('select#boot_method option#no_boot',section_os_boot).html(tr("Driver default")); - var bus_opts = - '\ - \ - '; - - $('select#BUS',section_disks).html(bus_opts); - $('input#TYPE', section_raw).val("kvm"); $(section_inputs).show(); @@ -1130,7 +1115,6 @@ function setupCreateTemplateDialog(){ // XEN particularities: // * Add custom disk types // * Remove driver default boot method - // * Add custom bus types // * Set the raw section to XEN // * Show the graphics section @@ -1146,12 +1130,6 @@ function setupCreateTemplateDialog(){ $('select#boot_method option#no_boot',section_os_boot).html(tr("Please choose")); - var bus_opts = - '\ - '; - - $('select#BUS',section_disks).html(bus_opts); - $('input#TYPE', section_raw).val("xen"); }; @@ -1165,7 +1143,6 @@ function setupCreateTemplateDialog(){ //VMWARE particularities // * Add custom disk types // * Hide boot method field - // * Add custom bus types // * Set the raw type to vmware var type_opts = @@ -1177,11 +1154,6 @@ function setupCreateTemplateDialog(){ $('div#kernel_bootloader',section_os_boot).hide(); - var bus_opts = - '\ - '; - - $('select#BUS',section_disks).html(bus_opts); $('input#TYPE', section_raw).val("vmware"); }; diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js index 8782c478ac..f4e353b01c 100644 --- a/src/sunstone/public/js/plugins/vms-tab.js +++ b/src/sunstone/public/js/plugins/vms-tab.js @@ -1249,7 +1249,6 @@ function hotpluggingOps(){ } disk_obj.IMAGE_ID = $('select[name="IMAGE_ID"]',this).val(); disk_obj.DEV_PREFIX = $('input[name="DEV_PREFIX"]',this).val(); - disk_obj.BUS = 'scsi'; break; case "volatile": disk_obj.SIZE = $('input[name="SIZE"]',this).val(); From 256a63f9e66a062fb333b0fc0b27de6437440b28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 22 Jun 2012 15:37:42 +0200 Subject: [PATCH 3/4] Feature #1312: Remove BUS attribute form core --- include/Image.h | 1 - src/image/Image.cc | 9 --------- 2 files changed, 10 deletions(-) diff --git a/include/Image.h b/include/Image.h index 064ec94664..687ae1960e 100644 --- a/include/Image.h +++ b/include/Image.h @@ -394,7 +394,6 @@ public: /** * Modifies the given disk attribute adding the following attributes: * * SOURCE: the file-path. - * * BUS: will only be set if the Image's definition includes it. * * TARGET: will only be set if the Image's definition includes it. * * @param disk attribute for the VM template diff --git a/src/image/Image.cc b/src/image/Image.cc index d64ef4844c..a3d830a9d7 100644 --- a/src/image/Image.cc +++ b/src/image/Image.cc @@ -426,7 +426,6 @@ int Image::disk_attribute( VectorAttribute * disk, ImageType& img_type, string& dev_prefix) { - string bus; string target; string driver; string disk_attr_type; @@ -434,17 +433,14 @@ int Image::disk_attribute( VectorAttribute * disk, ostringstream iid; img_type = type; - bus = disk->vector_value("BUS"); target = disk->vector_value("TARGET"); driver = disk->vector_value("DRIVER"); dev_prefix = disk->vector_value("DEV_PREFIX"); iid << oid; - string template_bus; string template_target; string template_driver; - get_template_attribute("BUS", template_bus); get_template_attribute("TARGET", template_target); get_template_attribute("DRIVER", template_driver); @@ -468,11 +464,6 @@ int Image::disk_attribute( VectorAttribute * disk, disk->replace("IMAGE_ID", iid.str()); disk->replace("SOURCE", source); - if (bus.empty() && !template_bus.empty()) //BUS in Image, not in DISK - { - disk->replace("BUS",template_bus); - } - if (driver.empty() && !template_driver.empty())//DRIVER in Image,not in DISK { disk->replace("DRIVER",template_driver); From a26fad7fe510269ba3072e9e67a936c6b1440cd0 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 22 Jun 2012 17:00:35 +0200 Subject: [PATCH 4/4] feature #1312: Add DEV_PREFIX to all disk types. Remove BUS from Libvirt drivers --- src/image/Image.cc | 4 +++- src/image/ImagePool.cc | 17 +++++++++++------ src/vmm/LibVirtDriverKVM.cc | 14 +------------- src/vmm/LibVirtDriverVMware.cc | 19 ++++++++----------- 4 files changed, 23 insertions(+), 31 deletions(-) diff --git a/src/image/Image.cc b/src/image/Image.cc index a3d830a9d7..589ac46679 100644 --- a/src/image/Image.cc +++ b/src/image/Image.cc @@ -454,7 +454,9 @@ int Image::disk_attribute( VectorAttribute * disk, if (dev_prefix.empty())//Removed from image template, get it again { dev_prefix = ImagePool::default_dev_prefix(); - } + } + + disk->replace("DEV_PREFIX", dev_prefix); } //--------------------------------------------------------------------------- diff --git a/src/image/ImagePool.cc b/src/image/ImagePool.cc index 281ad6dde3..2e1a706e5b 100644 --- a/src/image/ImagePool.cc +++ b/src/image/ImagePool.cc @@ -296,16 +296,21 @@ int ImagePool::disk_attribute(VectorAttribute * disk, transform(type.begin(),type.end(),type.begin(),(int(*)(int))toupper); - if ( type == "SWAP" || type == "FS" ) - { - dev_prefix = _default_dev_prefix; - img_type = Image::DATABLOCK; - } - else + if ( type != "SWAP" && type != "FS" ) { error_str = "Unknown disk type " + type; return -1; } + + img_type = Image::DATABLOCK; + dev_prefix = disk->vector_value("DEV_PREFIX"); + + if ( dev_prefix.empty() ) //DEV_PEFIX not in DISK, get default + { + dev_prefix = _default_dev_prefix; + + disk->replace("DEV_PREFIX", dev_prefix); + } } if ( img != 0 ) diff --git a/src/vmm/LibVirtDriverKVM.cc b/src/vmm/LibVirtDriverKVM.cc index 1859b5862c..c64caa3ddc 100644 --- a/src/vmm/LibVirtDriverKVM.cc +++ b/src/vmm/LibVirtDriverKVM.cc @@ -304,7 +304,6 @@ int LibVirtDriver::deployment_description_kvm( type = disk->vector_value("TYPE"); target = disk->vector_value("TARGET"); ro = disk->vector_value("READONLY"); - bus = disk->vector_value("BUS"); driver = disk->vector_value("DRIVER"); cache = disk->vector_value("CACHE"); disk->vector_value_str("DISK_ID", disk_id); @@ -354,18 +353,7 @@ int LibVirtDriver::deployment_description_kvm( // ---- target device to map the disk ---- - file << "\t\t\t" << endl; - } - else - { - file << "/>" << endl; - } + file << "\t\t\t" << endl; // ---- readonly attribute for the disk ---- diff --git a/src/vmm/LibVirtDriverVMware.cc b/src/vmm/LibVirtDriverVMware.cc index 61fd36b7da..0f4609145c 100644 --- a/src/vmm/LibVirtDriverVMware.cc +++ b/src/vmm/LibVirtDriverVMware.cc @@ -50,7 +50,6 @@ int LibVirtDriver::deployment_description_vmware( string type = ""; string target = ""; - string bus = ""; string ro = ""; string source = ""; string datastore = ""; @@ -197,7 +196,6 @@ int LibVirtDriver::deployment_description_vmware( type = disk->vector_value("TYPE"); target = disk->vector_value("TARGET"); ro = disk->vector_value("READONLY"); - bus = disk->vector_value("BUS"); source = disk->vector_value("SOURCE"); driver = disk->vector_value("DRIVER"); disk->vector_value_str("DISK_ID", disk_id); @@ -224,6 +222,8 @@ int LibVirtDriver::deployment_description_vmware( transform(type.begin(),type.end(),type.begin(),(int(*)(int))toupper); } + // ---- Disk type and source for the image ---- + if ( type == "BLOCK" ) { file << "\t\t" << endl; @@ -243,16 +243,11 @@ int LibVirtDriver::deployment_description_vmware( << "/disk." << disk_id << "/disk.vmdk'/>" << endl; } - file << "\t\t\t" << endl; - } - else - { - file << "/>" << endl; - } + file << "\t\t\t" << endl; + + // ---- Image Format using qemu driver ---- if ( !driver.empty() ) { @@ -267,6 +262,8 @@ int LibVirtDriver::deployment_description_vmware( } } + // ---- readonly attribute for the disk ---- + if (readonly) { file << "\t\t\t" << endl;