Decouple logs from seconday VM index.

As the primary VM gets given ID 0, the secondary index becomes off by
one. This could be patched where it is logged but it is also more
convenient for debugging if the name give to the VM is logged.

We don't have a way to log a memiter and the precision syntax is not
supported by dlog. We don't particularly want a fully fledged printf and
this is only used in one place at the moment so the print is done
manually. If we improve dlog in future, this can be updated.

Change-Id: I8192f9ab970438e150f82de0e4437ac3d37143cb
diff --git a/src/load.c b/src/load.c
index 0e45aba..cad62c9 100644
--- a/src/load.c
+++ b/src/load.c
@@ -228,7 +228,7 @@
 		    struct boot_params_update *update)
 {
 	struct memiter it;
-	struct memiter str;
+	struct memiter name;
 	uint64_t mem;
 	uint64_t cpu;
 	uint32_t count;
@@ -258,15 +258,22 @@
 
 	for (count = 0;
 	     memiter_parse_uint(&it, &mem) && memiter_parse_uint(&it, &cpu) &&
-	     memiter_parse_str(&it, &str) && count < MAX_VMS;
+	     memiter_parse_str(&it, &name) && count < MAX_VMS;
 	     count++) {
 		struct memiter kernel;
 		paddr_t secondary_mem_begin;
 		paddr_t secondary_mem_end;
 		ipaddr_t secondary_entry;
+		const char *p;
 
-		if (!memiter_find_file(cpio, &str, &kernel)) {
-			dlog("Unable to load kernel for vm %u\n", count);
+		dlog("Loading ");
+		for (p = name.next; p != name.limit; ++p) {
+			dlog("%c", *p);
+		}
+		dlog("\n");
+
+		if (!memiter_find_file(cpio, &name, &kernel)) {
+			dlog("Unable to load kernel\n");
 			continue;
 		}
 
@@ -274,28 +281,25 @@
 		mem = (mem + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
 
 		if (mem < kernel.limit - kernel.next) {
-			dlog("Kernel is larger than available memory for vm "
-			     "%u\n",
-			     count);
+			dlog("Kernel is larger than available memory\n");
 			continue;
 		}
 
 		if (!carve_out_mem_range(
 			    mem_ranges_available, params->mem_ranges_count, mem,
 			    &secondary_mem_begin, &secondary_mem_end)) {
-			dlog("Not enough memory for vm %u (%u bytes)\n", count,
-			     mem);
+			dlog("Not enough memory (%u bytes)\n", mem);
 			continue;
 		}
 
 		if (!copy_to_unmapped(secondary_mem_begin, kernel.next,
 				      kernel.limit - kernel.next)) {
-			dlog("Unable to copy kernel for vm %u\n", count);
+			dlog("Unable to copy kernel\n");
 			continue;
 		}
 
 		if (!vm_init(&secondary_vm[count], count + 1, cpu)) {
-			dlog("Unable to initialise vm %u\n", count);
+			dlog("Unable to initialise VM\n");
 			continue;
 		}
 
@@ -313,7 +317,7 @@
 					MM_MODE_R | MM_MODE_W | MM_MODE_X |
 						MM_MODE_NOINVALIDATE,
 					&secondary_entry)) {
-			dlog("Unable to initialise memory for vm %u\n", count);
+			dlog("Unable to initialise memory\n");
 			continue;
 		}
 
@@ -324,7 +328,7 @@
 			return false;
 		}
 
-		dlog("Loaded VM%u with %u vcpus, entry at 0x%x\n", count, cpu,
+		dlog("Loaded with %u vcpus, entry at 0x%x\n", cpu,
 		     pa_addr(secondary_mem_begin));
 
 		vm_start_vcpu(&secondary_vm[count], 0, secondary_entry, 0);