Add information to the XML conf file telling how to use it.
authorRichard W.M. Jones <rjones@redhat.com>
Sat, 2 Feb 2008 15:54:47 +0000 (15:54 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Sat, 2 Feb 2008 15:54:47 +0000 (15:54 +0000)
virt-p2v.ml

index 1dd3dfc..e507ed2 100755 (executable)
@@ -1372,14 +1372,32 @@ MAC address:  %s"
       name :: memory :: vcpu :: extras @ [devices]
     ) in
 
-  let xml = Xml.to_string_fmt xml in
-  let xml_len = String.length xml in
-  eprintf "length of configuration file is %d bytes\n%!" xml_len;
-
-  let (sock,_) as conn = do_connect conf_filename (Int64.of_int xml_len) in
-  (* In OCaml this actually loops calling write(2) *)
-  ignore (write sock xml 0 xml_len);
-  do_disconnect conn;
+  (* Convert XML configuration file to a string, then send it to the
+   * remote server.
+   *)
+  let () =
+    let xml = Xml.to_string_fmt xml in
+
+    let conn_arg =
+      match state.hypervisor with
+      | Some Xen | None -> ""
+      | Some QEMU | Some KVM -> " -c qemu:///system" in
+    let xml = sprintf "\
+<!--
+  This is a libvirt configuration file.
+
+  To start the domain, do:
+    virsh%s define %s
+    virsh%s start %s
+-->\n\n" conn_arg conf_filename conn_arg hostname ^ xml in
+
+    let xml_len = String.length xml in
+    eprintf "length of configuration file is %d bytes\n%!" xml_len;
+
+    let (sock,_) as conn = do_connect conf_filename (Int64.of_int xml_len) in
+    (* In OCaml this actually loops calling write(2) *)
+    ignore (write sock xml 0 xml_len);
+    do_disconnect conn in
 
   (* Send the device snapshots to the remote host. *)
   (* XXX This code should be made more robust against both network