Skip to contentSkip to conversation

spapr: add uuid/host details to device tree

PATCH In review Nikunj A Dadhania 1 participant 1 message Jun 27, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 spapr: add uuid/host details to device tree

Useful for identifying the guest/host uniquely within the guest. Adding following properties to the guest root node.

vm,uuid - uuid of the guest
host-model - Host model number
host-serial - Host machine serial number
hypervisor type - Tells its "kvm"

---
 hw/ppc/spapr.c       | 19 +++++++++++++++++++
 target-ppc/kvm.c     | 44 +++++++++++++++++++++++++++++++++++++++++++-
 target-ppc/kvm_ppc.h | 12 ++++++++++++
 3 files changed, 74 insertions(+), 1 deletion(-)
hw/ppc/spapr.c +19 -0
index a8ba916..33f77d2 100644
@@ -319,6 +319,7 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
     QemuOpts *opts = qemu_opts_find(qemu_find_opts("smp-opts"), NULL);
     unsigned sockets = opts ? qemu_opt_get_number(opts, "sockets", 0) : 0;
     uint32_t cpus_per_socket = sockets ? (smp_cpus / sockets) : 1;
+    char char_buf[512];
 
     add_str(hypertas, "hcall-pft");
     add_str(hypertas, "hcall-term");
@@ -348,6 +349,24 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
     _FDT((fdt_property_string(fdt, "model", "IBM pSeries (emulated by qemu)")));
     _FDT((fdt_property_string(fdt, "compatible", "qemu,pseries")));
 
+    if (kvm_enabled()) {
+        _FDT((fdt_property_string(fdt, "hypervisor", "kvm")));
+    }
+
+    /*
+     * Add info to guest to indentify which host is it being run on
+     * and what is the uuid of the guest
+     */
+    memset(char_buf, 0, sizeof(char_buf));
+    if (!kvmppc_get_host_model(char_buf, sizeof(char_buf))) {
+        _FDT((fdt_property_string(fdt, "host-model", char_buf)));
+        memset(char_buf, 0, sizeof(char_buf));
+    }
+    if (!kvmppc_get_host_serial(char_buf, sizeof(char_buf))) {
+        _FDT((fdt_property_string(fdt, "host-serial", char_buf)));
+    }
+    _FDT((fdt_property(fdt, "vm,uuid", qemu_uuid, 16)));
+
     _FDT((fdt_property_cell(fdt, "#address-cells", 0x2)));
     _FDT((fdt_property_cell(fdt, "#size-cells", 0x2)));
 
target-ppc/kvm.c +43 -1

56 lines not on this page · raw message

target-ppc/kvm_ppc.h +12 -0
index 1118122..6fa3314 100644
@@ -19,6 +19,8 @@ uint32_t kvmppc_get_tbfreq(void);
 uint64_t kvmppc_get_clockfreq(void);
 uint32_t kvmppc_get_vmx(void);
 uint32_t kvmppc_get_dfp(void);
+int32_t kvmppc_get_host_model(char *buf, int buf_len);
+int32_t kvmppc_get_host_serial(char *buf, int buf_len);
 int kvmppc_get_hasidle(CPUPPCState *env);
 int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len);
 int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level);
@@ -60,6 +62,16 @@ static inline uint32_t kvmppc_get_tbfreq(void)
     return 0;
 }
 
+static inline int32_t kvmppc_get_host_model(char *buf, int buf_len)
+{
+    return 0;
+}
+
+static inline int32_t kvmppc_get_host_serial(char *buf, int buf_len)
+{
+    return 0;
+}
+
 static inline uint64_t kvmppc_get_clockfreq(void)
 {
     return 0;
Signature · 1 line
1.8.3.1