diff --git a/src/vmm/LibVirtDriverKVM.cc b/src/vmm/LibVirtDriverKVM.cc
index af9f96cc2b..88b7e6d4ac 100644
--- a/src/vmm/LibVirtDriverKVM.cc
+++ b/src/vmm/LibVirtDriverKVM.cc
@@ -40,7 +40,7 @@ static void do_network_hosts(ofstream& file,
{
if (cg_host.empty())
{
- file << "'/>" << endl;
+ file << "/>" << endl;
return;
}
@@ -49,7 +49,7 @@ static void do_network_hosts(ofstream& file,
hosts = one_util::split(cg_host, ' ');
- file << "'>" << endl;
+ file << ">" << endl;
for (it = hosts.begin(); it != hosts.end(); it++)
{
@@ -60,23 +60,23 @@ static void do_network_hosts(ofstream& file,
continue;
}
- file << "\t\t\t\t" << endl;
+ file << "/>" << endl;
}
file << "\t\t\t" << endl;
@@ -222,9 +222,8 @@ int LibVirtDriver::deployment_description_kvm(
// Starting XML document
// ------------------------------------------------------------------------
- file << ""
+ file << ""
<< endl;
// ------------------------------------------------------------------------
@@ -246,7 +245,7 @@ int LibVirtDriver::deployment_description_kvm(
if (!vcpu.empty())
{
- file << "\t" << vcpu << "" << endl;
+ file << "\t" << one_util::escape_xml(vcpu) << "" << endl;
}
//Every process gets 1024 shares by default (cgroups), scale this with CPU
@@ -303,11 +302,11 @@ int LibVirtDriver::deployment_description_kvm(
get_default("OS", "MACHINE", machine);
}
- file << "\t\thvm" << endl;
@@ -351,11 +350,11 @@ int LibVirtDriver::deployment_description_kvm(
if ( !kernel.empty() )
{
- file << "\t\t" << kernel << "" << endl;
+ file << "\t\t" << one_util::escape_xml(kernel) << "\n";
if ( !initrd.empty() )
{
- file << "\t\t" << initrd << "" << endl;
+ file << "\t\t" << one_util::escape_xml(initrd) << "\n";
}
if ( !root.empty() )
@@ -365,19 +364,21 @@ int LibVirtDriver::deployment_description_kvm(
if (!kernel_cmd.empty())
{
- file << "\t\t" << kernel_cmd << "" << endl;
+ file << "\t\t" << one_util::escape_xml(kernel_cmd)
+ << "\n";
}
}
else if ( !bootloader.empty() )
{
- file << "\t\t" << bootloader << "" << endl;
+ file << "\t\t" << one_util::escape_xml(bootloader)
+ << "\n";
}
boots = one_util::split(boot, ',');
for (vector::const_iterator it=boots.begin(); it!=boots.end(); it++)
{
- file << "\t\t" << endl;
+ file << "\t\t\n";
}
file << "\t" << endl;
@@ -394,7 +395,8 @@ int LibVirtDriver::deployment_description_kvm(
emulator_path = "/usr/bin/kvm";
}
- file << "\t\t" << emulator_path << "" << endl;
+ file << "\t\t" << one_util::escape_xml(emulator_path)
+ << "\n";
// ------------------------------------------------------------------------
// Disks
@@ -508,33 +510,38 @@ int LibVirtDriver::deployment_description_kvm(
if ( type == "BLOCK" )
{
- file << "\t\t" << endl
- << "\t\t\t" << endl;
+ ostringstream dev;
+
+ dev << vm->get_remote_system_dir() << "/disk." << disk_id;
+
+ file << "\t\t\n"
+ << "\t\t\t\n";
}
else if ( type == "ISCSI" )
{
file << "\t\t" << endl;
- file << "\t\t\t" << endl
- << "\t\t\t\t" << endl
- << "\t\t\t" << endl;
+ file << "\t\t\t\n"
+ << "\t\t\t\t\n"
+ << "\t\t\t\n";
}
}
else if ( type == "RBD" || type == "RBD_CDROM" || disk_type == "RBD" )
@@ -548,39 +555,44 @@ int LibVirtDriver::deployment_description_kvm(
file << "\t\t" << endl;
}
- file << "\t\t\tget_oid() << "-" << disk_id;
+ rbd_name << "-" << vm->get_oid() << "-" << disk_id;
}
+ file << one_util::escape_xml_attr(rbd_name);
+
do_network_hosts(file, ceph_host, "", CEPH_DEFAULT_PORT);
if ( !ceph_secret.empty() && !ceph_user.empty())
{
- file << "\t\t\t" << endl
- << "\t\t\t\t" << endl
- << "\t\t\t" << endl;
+ file << "\t\t\t\n"
+ << "\t\t\t\t\n"
+ << "\t\t\t\n";
}
}
else if ( type == "SHEEPDOG" || type == "SHEEPDOG_CDROM" )
@@ -594,13 +606,19 @@ int LibVirtDriver::deployment_description_kvm(
file << "\t\t" << endl;
}
- file << "\t\t\tget_oid() << "-" << disk_id;
+ sheep_name << "-" << vm->get_oid() << "-" << disk_id;
}
+ file << one_util::escape_xml_attr(sheep_name);
+
do_network_hosts(file, sheepdog_host, "tcp", -1);
}
else if ( type == "GLUSTER" || type == "GLUSTER_CDROM" )
@@ -614,36 +632,49 @@ int LibVirtDriver::deployment_description_kvm(
file << "\t\t" << endl;
}
- file << "\t\t\tget_oid() << "/disk." << disk_id;
+ gluster_name << vm->get_oid() << "/disk." << disk_id;
}
else
{
- file << one_util::split(source, '/').back();
+ gluster_name << one_util::split(source, '/').back();
}
+ file << one_util::escape_xml_attr(gluster_name);
+
do_network_hosts(file, gluster_host, "tcp", GLUSTER_DEFAULT_PORT);
}
else if ( type == "CDROM" )
{
- file << "\t\t" << endl
- << "\t\t\t" << endl;
+ ostringstream cd_name;
+
+ cd_name << vm->get_remote_system_dir() << "/disk." << disk_id;
+
+ file << "\t\t\n"
+ << "\t\t\t\n";
}
else
{
- file << "\t\t" << endl
- << "\t\t\t" << endl;
+ ostringstream fname;
+
+ fname << vm->get_remote_system_dir() << "/disk." << disk_id;
+
+ file << "\t\t\n"
+ << "\t\t\t\n";
}
// ---- target device to map the disk ----
- file << "\t\t\t" << endl;
+ file << "\t\t\t\n";
// ---- readonly attribute for the disk ----
@@ -654,48 +685,48 @@ int LibVirtDriver::deployment_description_kvm(
// ---- Image Format using qemu driver ----
- file << "\t\t\t" << endl;
@@ -710,38 +741,44 @@ int LibVirtDriver::deployment_description_kvm(
if ( !total_bytes_sec.empty() )
{
- file << "\t\t\t\t" << total_bytes_sec
- << "" << endl;
+ file << "\t\t\t\t"
+ << one_util::escape_xml(total_bytes_sec)
+ << "\n";
}
if ( !read_bytes_sec.empty() )
{
- file << "\t\t\t\t" << read_bytes_sec
- << "" << endl;
+ file << "\t\t\t\t"
+ << one_util::escape_xml(read_bytes_sec)
+ << "\n";
}
if ( !write_bytes_sec.empty() )
{
- file << "\t\t\t\t" << write_bytes_sec
- << "" << endl;
+ file << "\t\t\t\t"
+ << one_util::escape_xml(write_bytes_sec)
+ << "\n";
}
if ( !total_iops_sec.empty() )
{
- file << "\t\t\t\t" << total_iops_sec
- << "" << endl;
+ file << "\t\t\t\t"
+ << one_util::escape_xml(total_iops_sec)
+ << "\n";
}
if ( !read_iops_sec.empty() )
{
- file << "\t\t\t\t" << read_iops_sec
- << "" << endl;
+ file << "\t\t\t\t"
+ << one_util::escape_xml(read_iops_sec)
+ << "\n";
}
if ( !write_iops_sec.empty() )
{
- file << "\t\t\t\t" << write_iops_sec
- << "" << endl;
+ file << "\t\t\t\t"
+ << one_util::escape_xml(write_iops_sec)
+ << "\n";
}
file << "\t\t\t" << endl;
@@ -764,17 +801,18 @@ int LibVirtDriver::deployment_description_kvm(
if ( !target.empty() )
{
- file << "\t\t" << endl;
+ ostringstream fname;
- file << "\t\t\t" << endl;
+ fname << vm->get_remote_system_dir() << "/disk." << disk_id;
- file << "\t\t\t" << endl;
- file << "\t\t\t" << endl;
-
- file << "\t\t\t" << endl;
-
- file << "\t\t" << endl;
+ file << "\t\t\n"
+ << "\t\t\t\n"
+ << "\t\t\t\n"
+ << "\t\t\t\n"
+ << "\t\t\t\n"
+ << "\t\t\n";
}
else
{
@@ -824,22 +862,26 @@ int LibVirtDriver::deployment_description_kvm(
file << "\t\t\t" << endl;
}
- file << "\t\t\t" << endl;
+ file << "\t\t\t\n";
}
if( !mac.empty() )
{
- file << "\t\t\t" << endl;
+ file << "\t\t\t\n";
}
if( !target.empty() )
{
- file << "\t\t\t" << endl;
+ file << "\t\t\t\n";
}
if( !script.empty() )
{
- file << "\t\t\t" << endl;
+ file << "\t\t\t\n";
}
string * the_model = 0;
@@ -855,7 +897,8 @@ int LibVirtDriver::deployment_description_kvm(
if (the_model != 0)
{
- file << "\t\t\t" << endl;
+ file << "\t\t\t\n";
}
if (!ip.empty() )
@@ -873,10 +916,11 @@ int LibVirtDriver::deployment_description_kvm(
if ( the_filter != 0 )
{
- file <<"\t\t\t"<" << endl;
- file << "\t\t\t" << endl;
+ file << "\t\t\t\n"
+ << "\t\t\t\t\n"
+ << "\t\t\t\n";
}
}
@@ -900,26 +944,26 @@ int LibVirtDriver::deployment_description_kvm(
if ( type == "vnc" || type == "spice" )
{
- file << "\t\t" << endl;
@@ -953,11 +997,11 @@ int LibVirtDriver::deployment_description_kvm(
if ( !type.empty() )
{
- file << "\t\t" << endl;
@@ -985,17 +1029,17 @@ int LibVirtDriver::deployment_description_kvm(
continue;
}
- file << "\t\t";
- file << endl;
- file << "\t\t\t" << endl;
+ file << "\t\t\n";
- file << "\t\t\t\t" << endl;
+ file << "\t\t\t\n";
+ file << "\t\t\t\t\n";
+ file << "\t\t\t\n";
- file << "\t\t\t" << endl;
file << "\t\t" << endl;
}
@@ -1104,10 +1148,11 @@ int LibVirtDriver::deployment_description_kvm(
// ------------------------------------------------------------------------
// Metadata used by drivers
// ------------------------------------------------------------------------
- file << "\t" << endl;
- file << "\t\t" << vm->get_remote_system_dir() <<
- "" << endl;
- file << "\t" << endl;
+ file << "\t\n"
+ << "\t\t"
+ << one_util::escape_xml(vm->get_remote_system_dir())
+ << "\n"
+ << "\t\n";
file << "" << endl;