Skip to contentSkip to conversation

spapr: add host Linux version information to device tree

PATCH In review [email protected] 4 participants 7 messages Jul 18, 2014 – Jul 28, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spapr: add host Linux version information to device tree

It may prove useful know which Linux distribution version the host machine is running when an issue in the guest arises but a user cannot access the host.

---
 hw/ppc/spapr.c       |  8 +++++++
 target-ppc/kvm.c     | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 target-ppc/kvm_ppc.h |  6 +++++
 3 files changed, 76 insertions(+)
hw/ppc/spapr.c +8 -0
index 6b48a26..391d47a 100644
@@ -375,6 +375,14 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
     _FDT((fdt_property_string(fdt, "vm,uuid", buf)));
     g_free(buf);
 
+    /*
+     * Add info to the guest FDT to tell it what linux the host is
+     */
+    if (kvmppc_get_linux_host(&buf)) {
+        _FDT((fdt_property_string(fdt, "linux,host", buf)));
+        g_free(buf);
+    }
+
     _FDT((fdt_property_cell(fdt, "#address-cells", 0x2)));
     _FDT((fdt_property_cell(fdt, "#size-cells", 0x2)));
 
target-ppc/kvm.c +62 -0

68 lines not on this page · raw message

target-ppc/kvm_ppc.h +6 -0
index 2e0224c..92a71f7 100644
@@ -21,6 +21,7 @@ uint32_t kvmppc_get_vmx(void);
 uint32_t kvmppc_get_dfp(void);
 bool kvmppc_get_host_model(char **buf);
 bool kvmppc_get_host_serial(char **buf);
+bool kvmppc_get_linux_host(char **buf);
 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);
@@ -72,6 +73,11 @@ static inline bool kvmppc_get_host_serial(char **buf)
     return false;
 }
 
+static inline bool kvmppc_get_linux_host(char **buf)
+{
+    return false;
+}
+
 static inline uint64_t kvmppc_get_clockfreq(void)
 {
     return 0;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 16 lines · On 07/17/2014 10:31 PM, [email protected] wrote:

It may prove useful know which Linux distribution version the host machine is running when an issue in the guest arises but a user cannot access the host.

---
 hw/ppc/spapr.c       |  8 +++++++
 target-ppc/kvm.c     | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 target-ppc/kvm_ppc.h |  6 +++++
 3 files changed, 76 insertions(+)
hw/ppc/spapr.c +0 -0
index 6b48a26..391d47a 100644

hw/ppc/spapr.c static void *spapr_create_fdt_skel(hwaddr initrd_base, · line 384

Quoted 10 lines
hw/ppc/spapr.c +7 -0
@@ -375,6 +375,14 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
     _FDT((fdt_property_string(fdt, "vm,uuid", buf)));
     g_free(buf);
 
+    /*
+     * Add info to the guest FDT to tell it what linux the host is
+     */
+    if (kvmppc_get_linux_host(&buf)) {
+        _FDT((fdt_property_string(fdt, "linux,host", buf)));
+        g_free(buf);
+    }

Ouch. What does this do for migration? By exposing it to the guest, you have made it part of the guest ABI, and now you have limited yourself to migrate only when the destination host is identical to the source if you don't want to risk breaking the guest. Without this, it seems feasible to migrate from a machine on an older host to another machine on a newer host.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#2 lore raw
Quoted 20 lines · Eric Blake
Quoted 19 lines · On 07/17/2014 10:31 PM, [email protected] wrote:

It may prove useful know which Linux distribution version the host machine is running when an issue in the guest arises but a user cannot access the host.

---
  hw/ppc/spapr.c       |  8 +++++++
  target-ppc/kvm.c     | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++
  target-ppc/kvm_ppc.h |  6 +++++
  3 files changed, 76 insertions(+)
hw/ppc/spapr.c +0 -0
index 6b48a26..391d47a 100644
@@ -375,6 +375,14 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
      _FDT((fdt_property_string(fdt, "vm,uuid", buf)));
      g_free(buf);
 
Quoted 13 lines

hw/ppc/spapr.c static void *spapr_create_fdt_skel(hwaddr initrd_base, · line 384

Quoted 7 lines
hw/ppc/spapr.c +7 -0
+    /*
+     * Add info to the guest FDT to tell it what linux the host is
+     */
+    if (kvmppc_get_linux_host(&buf)) {
+        _FDT((fdt_property_string(fdt, "linux,host", buf)));
+        g_free(buf);
+    }

Ouch. What does this do for migration? By exposing it to the guest, you have made it part of the guest ABI, and now you have limited yourself to migrate only when the destination host is identical to the source if you don't want to risk breaking the guest. Without this, it seems feasible to migrate from a machine on an older host to another machine on a newer host.

sPAPR has a mechanism to inject a "post-migration" interrupt into the guest and provide a device tree diff. That way we can change these host specific values on the fly after migration happened.

Maybe it makes sense to hold off these host specific device tree chunks until after we have that mechanism implemented though.

Alex

author
#3 lore raw
Quoted 37 lines · Alexander Graf
Quoted 26 lines · Eric Blake
Quoted 25 lines · On 07/17/2014 10:31 PM, [email protected] wrote:

It may prove useful know which Linux distribution version the host machine is running when an issue in the guest arises but a user cannot access the host.

---
  hw/ppc/spapr.c       |  8 +++++++
  target-ppc/kvm.c     | 62 
++++++++++++++++++++++++++++++++++++++++++++++++++++
  target-ppc/kvm_ppc.h |  6 +++++
  3 files changed, 76 insertions(+)
hw/ppc/spapr.c +4 -0
index 6b48a26..391d47a 100644
@@ -375,6 +375,14 @@ static void *spapr_create_fdt_skel(hwaddr 
 initrd_base,
      _FDT((fdt_property_string(fdt, "vm,uuid", buf)));
      g_free(buf);
  +    /*
+     * Add info to the guest FDT to tell it what linux the host is
+     */
+    if (kvmppc_get_linux_host(&buf)) {
+        _FDT((fdt_property_string(fdt, "linux,host", buf)));
Quoted 8 lines

hw/ppc/spapr.c static void *spapr_create_fdt_skel(hwaddr initrd_base, · line 384

Quoted 2 lines
hw/ppc/spapr.c +2 -0
+        g_free(buf);
+    }

Ouch. What does this do for migration? By exposing it to the guest, you have made it part of the guest ABI, and now you have limited yourself to migrate only when the destination host is identical to the source if you don't want to risk breaking the guest. Without this, it seems feasible to migrate from a machine on an older host to another machine on a newer host.

Quoted 3 lines

sPAPR has a mechanism to inject a "post-migration" interrupt into the guest and provide a device tree diff. That way we can change these host specific values on the fly after migration happened.

Maybe it makes sense to hold off these host specific device tree chunks until after we have that mechanism implemented though.

Indeed and the ability to do this is in the kernel but it had not been implemented in qemu yet. Probably not worth doing just for this patch but having this does open the doors to quite a few other things, I'll investigate.

Cyril

Quoted 3 lines

Alex

#4 lore raw
In reply to [email protected]
Quoted 16 lines · On 18.07.14 06:31, [email protected] wrote:

It may prove useful know which Linux distribution version the host machine is running when an issue in the guest arises but a user cannot access the host.

---
  hw/ppc/spapr.c       |  8 +++++++
  target-ppc/kvm.c     | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++
  target-ppc/kvm_ppc.h |  6 +++++
  3 files changed, 76 insertions(+)
hw/ppc/spapr.c +0 -0
index 6b48a26..391d47a 100644

hw/ppc/spapr.c static void *spapr_create_fdt_skel(hwaddr initrd_base, · line 382

Quoted 8 lines
hw/ppc/spapr.c +5 -0
@@ -375,6 +375,14 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
      _FDT((fdt_property_string(fdt, "vm,uuid", buf)));
      g_free(buf);
 
+    /*
+     * Add info to the guest FDT to tell it what linux the host is
+     */
+    if (kvmppc_get_linux_host(&buf)) {
+        _FDT((fdt_property_string(fdt, "linux,host", buf)));

Is this even specified in sPAPR?

Quoted 13 lines
hw/ppc/spapr.c +3 -0
+        g_free(buf);
+    }
+
      _FDT((fdt_property_cell(fdt, "#address-cells", 0x2)));
      _FDT((fdt_property_cell(fdt, "#size-cells", 0x2)));
 
target-ppc/kvm.c +0 -0
index 8c9e79c..95e0970 100644
@@ -1415,6 +1415,68 @@ bool kvmppc_get_host_model(char **value)
      return g_file_get_contents("/proc/device-tree/model", value, NULL, NULL);
  }

target-ppc/kvm.c bool kvmppc_get_host_model(char **value) · line 1426

Quoted 10 lines
target-ppc/kvm.c +9 -0
 
+bool kvmppc_get_linux_host(char **value)
+{
+    FILE *f;
+    int i;
+    char line[512];
+    const char *names[] = {"NAME", "VERSION", "BUILD_ID"};
+    bool names_found[ARRAY_SIZE(names)] = { 0 };
+    GString *output = NULL;
+    f = fopen("/etc/os-release", "r");

A few comments:

1) Why would anyone care?
2) I'm not sure KVM is the right decision maker on whether we want
this exposed or not. After all, the files you read here are available on an x86 host just as well
3) Use glib functions to read files

Alex

#5 lore raw
Quoted 14 lines · Alexander Graf
Quoted 12 lines · On 18.07.14 06:31, [email protected] wrote:

It may prove useful know which Linux distribution version the host machine is running when an issue in the guest arises but a user cannot access the host.

---
  hw/ppc/spapr.c       |  8 +++++++
  target-ppc/kvm.c     | 62
++++++++++++++++++++++++++++++++++++++++++++++++++++
  target-ppc/kvm_ppc.h |  6 +++++
  3 files changed, 76 insertions(+)
Quoted 14 lines

hw/ppc/spapr.c static void *spapr_create_fdt_skel(hwaddr initrd_base, · line 381

Quoted 12 lines
hw/ppc/spapr.c +4 -0
index 6b48a26..391d47a 100644
@@ -375,6 +375,14 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
      _FDT((fdt_property_string(fdt, "vm,uuid", buf)));
      g_free(buf);
  +    /*
+     * Add info to the guest FDT to tell it what linux the host is
+     */
+    if (kvmppc_get_linux_host(&buf)) {
+        _FDT((fdt_property_string(fdt, "linux,host", buf)));

Is this even specified in sPAPR?

PAPR does not know about any "linux,xxx" properties.

Quoted 26 lines
Quoted 13 lines
hw/ppc/spapr.c +3 -0
+        g_free(buf);
+    }
+
      _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 8c9e79c..95e0970 100644

target-ppc/kvm.c +0 -0
@@ -1415,6 +1415,68 @@ bool kvmppc_get_host_model(char **value)
      return g_file_get_contents("/proc/device-tree/model", value, NULL,
 NULL);

target-ppc/kvm.c bool kvmppc_get_host_model(char **value) · line 1426

Quoted 10 lines
target-ppc/kvm.c +8 -0
  }
  +bool kvmppc_get_linux_host(char **value)
+{
+    FILE *f;
+    int i;
+    char line[512];
+    const char *names[] = {"NAME", "VERSION", "BUILD_ID"};
+    bool names_found[ARRAY_SIZE(names)] = { 0 };
+    GString *output = NULL;
+    f = fopen("/etc/os-release", "r");

A few comments:

Quoted 1 line

1) Why would anyone care?

Useful debug info when the host is not reachable.

Quoted 2 lines

2) I'm not sure KVM is the right decision maker on whether we want this
exposed or not.

Good point, there is no reason not to show this info in TCG.

Quoted 2 lines

After all, the files you read here are available on an x86 host just as well

Does qemu-x86 has any way to pass information like this to the guest?

Quoted 6 lines

3) Use glib functions to read files

Alex

Signature · 1 line
Alexey
#6 lore raw
Quoted 72 lines

Am 28.07.2014 um 08:47 schrieb Alexey Kardashevskiy <[email protected]>:

Quoted 15 lines · Alexander Graf
Quoted 14 lines · On 18.07.14 06:31, [email protected] wrote:

It may prove useful know which Linux distribution version the host machine is running when an issue in the guest arises but a user cannot access the host.

---
 hw/ppc/spapr.c       |  8 +++++++
 target-ppc/kvm.c     | 62
++++++++++++++++++++++++++++++++++++++++++++++++++++
 target-ppc/kvm_ppc.h |  6 +++++
 3 files changed, 76 insertions(+)
Quoted 14 lines

hw/ppc/spapr.c static void *spapr_create_fdt_skel(hwaddr initrd_base, · line 381

Quoted 12 lines
hw/ppc/spapr.c +4 -0
index 6b48a26..391d47a 100644
@@ -375,6 +375,14 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
     _FDT((fdt_property_string(fdt, "vm,uuid", buf)));
     g_free(buf);
 +    /*
+     * Add info to the guest FDT to tell it what linux the host is
+     */
+    if (kvmppc_get_linux_host(&buf)) {
+        _FDT((fdt_property_string(fdt, "linux,host", buf)));

Is this even specified in sPAPR?

PAPR does not know about any "linux,xxx" properties.

Quoted 26 lines
Quoted 13 lines
hw/ppc/spapr.c +3 -0
+        g_free(buf);
+    }
+
     _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 8c9e79c..95e0970 100644

target-ppc/kvm.c +0 -0
@@ -1415,6 +1415,68 @@ bool kvmppc_get_host_model(char **value)
     return g_file_get_contents("/proc/device-tree/model", value, NULL,
 NULL);

target-ppc/kvm.c bool kvmppc_get_host_model(char **value) · line 1426

Quoted 10 lines
target-ppc/kvm.c +8 -0
 }
 +bool kvmppc_get_linux_host(char **value)
+{
+    FILE *f;
+    int i;
+    char line[512];
+    const char *names[] = {"NAME", "VERSION", "BUILD_ID"};
+    bool names_found[ARRAY_SIZE(names)] = { 0 };
+    GString *output = NULL;
+    f = fopen("/etc/os-release", "r");

A few comments:

Quoted 1 line

1) Why would anyone care?

Useful debug info when the host is not reachable.

Quoted 2 lines

2) I'm not sure KVM is the right decision maker on whether we want this
exposed or not.

Quoted 6 lines

Good point, there is no reason not to show this info in TCG.

Quoted 2 lines

After all, the files you read here are available on an x86 host just as well

Does qemu-x86 has any way to pass information like this to the guest?

Yes and no. It has fw_cfg where we could put it and it has DSST generation where we could also put it I guess. Just like here, there's no standardized way to expose it though.

Alex

Quoted 10 lines
Quoted 6 lines

3) Use glib functions to read files

Alex

Signature · 1 line
Alexey