* [Qemu-devel] [PATCH 1/3] spapr: add uuid/host details to device tree
@ 2014-06-10 7:56 Nikunj A Dadhania
2014-06-11 8:21 ` [Qemu-devel] [Qemu-ppc] " Alexey Kardashevskiy
0 siblings, 1 reply; 3+ messages in thread
From: Nikunj A Dadhania @ 2014-06-10 7:56 UTC (permalink / raw)
To: qemu-devel; +Cc: aik, qemu-ppc, agraf, nikunj
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"
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
---
hw/ppc/spapr.c | 19 +++++++++++++++++++
target-ppc/kvm.c | 42 ++++++++++++++++++++++++++++++++++++++++++
target-ppc/kvm_ppc.h | 12 ++++++++++++
3 files changed, 73 insertions(+)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 57e9578..ff37319 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -313,6 +313,7 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
uint32_t interrupt_server_ranges_prop[] = {0, cpu_to_be32(smp_cpus)};
int i, smt = kvmppc_smt_threads();
unsigned char vec5[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x80};
+ char char_buf[512];
fdt = g_malloc0(FDT_MAX_SIZE);
_FDT((fdt_create(fdt, FDT_MAX_SIZE)));
@@ -331,6 +332,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)));
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 8ff1777..8cb090d 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -1353,6 +1353,48 @@ uint32_t kvmppc_get_tbfreq(void)
return retval;
}
+int32_t kvmppc_get_host_serial(char *value, int len)
+{
+ FILE *f;
+ int ret = -1;
+ char line[512];
+
+ memset(line, 0, sizeof(line));
+ f = fopen("/proc/device-tree/system-id", "r");
+ if (!f) {
+ return ret;
+ }
+
+ if(fgets(line, sizeof(line), f)) {
+ snprintf(value, len, "IBM,%s", line);
+ ret = 0;
+ }
+ fclose(f);
+
+ return ret;
+}
+
+int32_t kvmppc_get_host_model(char *value, int len)
+{
+ FILE *f;
+ int ret = -1;
+ char line[512];
+
+ memset(line, 0, sizeof(line));
+ f = fopen("/proc/device-tree/model", "r");
+ if (!f) {
+ return ret;
+ }
+
+ if(fgets(line, sizeof(line), f)) {
+ snprintf(value, len, "IBM,%s", line);
+ ret = 0;
+ }
+ fclose(f);
+
+ return ret;
+}
+
/* Try to find a device tree node for a CPU with clock-frequency property */
static int kvmppc_find_cpu_dt(char *buf, int buf_len)
{
diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h
index ff077ec..6ed7edd 100644
--- a/target-ppc/kvm_ppc.h
+++ b/target-ppc/kvm_ppc.h
@@ -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);
@@ -56,6 +58,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;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH 1/3] spapr: add uuid/host details to device tree
2014-06-10 7:56 [Qemu-devel] [PATCH 1/3] spapr: add uuid/host details to device tree Nikunj A Dadhania
@ 2014-06-11 8:21 ` Alexey Kardashevskiy
2014-06-12 8:00 ` Nikunj A Dadhania
0 siblings, 1 reply; 3+ messages in thread
From: Alexey Kardashevskiy @ 2014-06-11 8:21 UTC (permalink / raw)
To: Nikunj A Dadhania, qemu-devel; +Cc: qemu-ppc, aik
On 06/10/2014 05:56 PM, Nikunj A Dadhania wrote:
> 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"
>
> Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
> ---
> hw/ppc/spapr.c | 19 +++++++++++++++++++
> target-ppc/kvm.c | 42 ++++++++++++++++++++++++++++++++++++++++++
> target-ppc/kvm_ppc.h | 12 ++++++++++++
> 3 files changed, 73 insertions(+)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 57e9578..ff37319 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -313,6 +313,7 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
> uint32_t interrupt_server_ranges_prop[] = {0, cpu_to_be32(smp_cpus)};
> int i, smt = kvmppc_smt_threads();
> unsigned char vec5[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x80};
> + char char_buf[512];
>
> fdt = g_malloc0(FDT_MAX_SIZE);
> _FDT((fdt_create(fdt, FDT_MAX_SIZE)));
> @@ -331,6 +332,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()) {
s/if/if / here and after.
You did not run checkpatch.pl, did you? :)
> + _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)));
>
> diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
> index 8ff1777..8cb090d 100644
> --- a/target-ppc/kvm.c
> +++ b/target-ppc/kvm.c
> @@ -1353,6 +1353,48 @@ uint32_t kvmppc_get_tbfreq(void)
> return retval;
> }
>
> +int32_t kvmppc_get_host_serial(char *value, int len)
> +{
> + FILE *f;
> + int ret = -1;
> + char line[512];
> +
> + memset(line, 0, sizeof(line));
> + f = fopen("/proc/device-tree/system-id", "r");
> + if (!f) {
> + return ret;
> + }
> +
> + if(fgets(line, sizeof(line), f)) {
> + snprintf(value, len, "IBM,%s", line);
> + ret = 0;
> + }
> + fclose(f);
> +
> + return ret;
> +}
> +
> +int32_t kvmppc_get_host_model(char *value, int len)
> +{
> + FILE *f;
> + int ret = -1;
> + char line[512];
> +
> + memset(line, 0, sizeof(line));
> + f = fopen("/proc/device-tree/model", "r");
> + if (!f) {
> + return ret;
> + }
> +
> + if(fgets(line, sizeof(line), f)) {
> + snprintf(value, len, "IBM,%s", line);
> + ret = 0;
> + }
> + fclose(f);
> +
> + return ret;
> +}
> +
> /* Try to find a device tree node for a CPU with clock-frequency property */
> static int kvmppc_find_cpu_dt(char *buf, int buf_len)
> {
> diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h
> index ff077ec..6ed7edd 100644
> --- a/target-ppc/kvm_ppc.h
> +++ b/target-ppc/kvm_ppc.h
> @@ -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);
> @@ -56,6 +58,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;
>
--
Alexey
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH 1/3] spapr: add uuid/host details to device tree
2014-06-11 8:21 ` [Qemu-devel] [Qemu-ppc] " Alexey Kardashevskiy
@ 2014-06-12 8:00 ` Nikunj A Dadhania
0 siblings, 0 replies; 3+ messages in thread
From: Nikunj A Dadhania @ 2014-06-12 8:00 UTC (permalink / raw)
To: Alexey Kardashevskiy, qemu-devel; +Cc: qemu-ppc, aik
Alexey Kardashevskiy <aik@ozlabs.ru> writes:
> On 06/10/2014 05:56 PM, Nikunj A Dadhania wrote:
>> 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"
>>
>> Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
>> ---
>> hw/ppc/spapr.c | 19 +++++++++++++++++++
>> target-ppc/kvm.c | 42 ++++++++++++++++++++++++++++++++++++++++++
>> target-ppc/kvm_ppc.h | 12 ++++++++++++
>> 3 files changed, 73 insertions(+)
>>
>> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
>> index 57e9578..ff37319 100644
>> --- a/hw/ppc/spapr.c
>> +++ b/hw/ppc/spapr.c
>> @@ -313,6 +313,7 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
>> uint32_t interrupt_server_ranges_prop[] = {0, cpu_to_be32(smp_cpus)};
>> int i, smt = kvmppc_smt_threads();
>> unsigned char vec5[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x80};
>> + char char_buf[512];
>>
>> fdt = g_malloc0(FDT_MAX_SIZE);
>> _FDT((fdt_create(fdt, FDT_MAX_SIZE)));
>> @@ -331,6 +332,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()) {
>
> s/if/if / here and after.
>
> You did not run checkpatch.pl, did you? :)
Nope, will fix it.
Nikunj
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-06-12 8:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-10 7:56 [Qemu-devel] [PATCH 1/3] spapr: add uuid/host details to device tree Nikunj A Dadhania
2014-06-11 8:21 ` [Qemu-devel] [Qemu-ppc] " Alexey Kardashevskiy
2014-06-12 8:00 ` Nikunj A Dadhania
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.