Re: [PATCH 1/3] qemu: agent: Store CCW address in qemuAgentDiskInfo if provided by the guest

2020-12-10 Thread Michal Privoznik

On 11/25/20 12:06 PM, Thomas Huth wrote:

Newer versions of the QEMU guest agent will provide the CCW address
of devices on s390x. Store this information in the qemuAgentDiskInfo
so that we can use this later.

We also map the CSSID 0 from the guest to the value 0xfe on the host,
see https://www.qemu.org/docs/master/system/s390x/css.html for details.

Signed-off-by: Thomas Huth 
---
  src/qemu/qemu_agent.c | 11 +++
  src/qemu/qemu_agent.h |  2 ++
  2 files changed, 13 insertions(+)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 230253d404..d7ad20376c 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -1868,6 +1868,7 @@ qemuAgentGetFSInfoFillDisks(virJSONValuePtr jsondisks,
  for (i = 0; i < fsinfo->ndisks; i++) {
  virJSONValuePtr jsondisk = virJSONValueArrayGet(jsondisks, i);
  virJSONValuePtr pci;
+virJSONValuePtr ccw;
  qemuAgentDiskInfoPtr disk;
  const char *val;
  
@@ -1916,6 +1917,16 @@ qemuAgentGetFSInfoFillDisks(virJSONValuePtr jsondisks,

  GET_DISK_ADDR(pci, >pci_controller.bus, "bus");
  GET_DISK_ADDR(pci, >pci_controller.slot, "slot");
  GET_DISK_ADDR(pci, >pci_controller.function, "function");
+
+if ((ccw = virJSONValueObjectGet(jsondisk, "ccw-address"))) {
+disk->has_ccw_address = true;
+GET_DISK_ADDR(ccw, >ccw_addr.cssid, "cssid");
+if (disk->ccw_addr.cssid == 0)  /* Guest CSSID 0 is 0xfe on host */
+disk->ccw_addr.cssid = 0xfe;
+GET_DISK_ADDR(ccw, >ccw_addr.ssid, "ssid");
+GET_DISK_ADDR(ccw, >ccw_addr.devno, "devno");
+}
+
  #undef GET_DISK_ADDR
  }
  
diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h

index 7cbab489ec..37b482f3b2 100644
--- a/src/qemu/qemu_agent.h
+++ b/src/qemu/qemu_agent.h
@@ -77,6 +77,8 @@ struct _qemuAgentDiskInfo {
  unsigned int target;
  unsigned int unit;
  char *devnode;
+bool has_ccw_address;
+virDomainDeviceCCWAddress ccw_addr;
  };
  
  typedef struct _qemuAgentFSInfo qemuAgentFSInfo;




I needed to rebase this, because earlier I've merged a patch from 
Marc-Andre that moved the internals of qemuAgentGetFSInfoFillDisks() 
into a separate function.


Reviewed-by: Michal Privoznik 

Michal



Re: [PATCH 1/3] qemu: agent: Store CCW address in qemuAgentDiskInfo if provided by the guest

2020-11-27 Thread Cornelia Huck
On Wed, 25 Nov 2020 12:06:46 +0100
Thomas Huth  wrote:

> Newer versions of the QEMU guest agent will provide the CCW address
> of devices on s390x. Store this information in the qemuAgentDiskInfo
> so that we can use this later.
> 
> We also map the CSSID 0 from the guest to the value 0xfe on the host,
> see https://www.qemu.org/docs/master/system/s390x/css.html for details.
> 
> Signed-off-by: Thomas Huth 
> ---
>  src/qemu/qemu_agent.c | 11 +++
>  src/qemu/qemu_agent.h |  2 ++
>  2 files changed, 13 insertions(+)
> 

(...)

> @@ -1916,6 +1917,16 @@ qemuAgentGetFSInfoFillDisks(virJSONValuePtr jsondisks,
>  GET_DISK_ADDR(pci, >pci_controller.bus, "bus");
>  GET_DISK_ADDR(pci, >pci_controller.slot, "slot");
>  GET_DISK_ADDR(pci, >pci_controller.function, "function");
> +
> +if ((ccw = virJSONValueObjectGet(jsondisk, "ccw-address"))) {
> +disk->has_ccw_address = true;
> +GET_DISK_ADDR(ccw, >ccw_addr.cssid, "cssid");
> +if (disk->ccw_addr.cssid == 0)  /* Guest CSSID 0 is 0xfe on host 
> */
> +disk->ccw_addr.cssid = 0xfe;

This will be true for any guest that doesn't support MCSS-E. I don't
see any MCSS-E enablement coming up in the foreseeable future (in fact,
I get the impression that this feature is rather dead, and QEMU remains
the only implementation anyway), so this should be fine.

> +GET_DISK_ADDR(ccw, >ccw_addr.ssid, "ssid");
> +GET_DISK_ADDR(ccw, >ccw_addr.devno, "devno");
> +}
> +
>  #undef GET_DISK_ADDR
>  }
>  

(...)



[PATCH 1/3] qemu: agent: Store CCW address in qemuAgentDiskInfo if provided by the guest

2020-11-25 Thread Thomas Huth
Newer versions of the QEMU guest agent will provide the CCW address
of devices on s390x. Store this information in the qemuAgentDiskInfo
so that we can use this later.

We also map the CSSID 0 from the guest to the value 0xfe on the host,
see https://www.qemu.org/docs/master/system/s390x/css.html for details.

Signed-off-by: Thomas Huth 
---
 src/qemu/qemu_agent.c | 11 +++
 src/qemu/qemu_agent.h |  2 ++
 2 files changed, 13 insertions(+)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 230253d404..d7ad20376c 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -1868,6 +1868,7 @@ qemuAgentGetFSInfoFillDisks(virJSONValuePtr jsondisks,
 for (i = 0; i < fsinfo->ndisks; i++) {
 virJSONValuePtr jsondisk = virJSONValueArrayGet(jsondisks, i);
 virJSONValuePtr pci;
+virJSONValuePtr ccw;
 qemuAgentDiskInfoPtr disk;
 const char *val;
 
@@ -1916,6 +1917,16 @@ qemuAgentGetFSInfoFillDisks(virJSONValuePtr jsondisks,
 GET_DISK_ADDR(pci, >pci_controller.bus, "bus");
 GET_DISK_ADDR(pci, >pci_controller.slot, "slot");
 GET_DISK_ADDR(pci, >pci_controller.function, "function");
+
+if ((ccw = virJSONValueObjectGet(jsondisk, "ccw-address"))) {
+disk->has_ccw_address = true;
+GET_DISK_ADDR(ccw, >ccw_addr.cssid, "cssid");
+if (disk->ccw_addr.cssid == 0)  /* Guest CSSID 0 is 0xfe on host */
+disk->ccw_addr.cssid = 0xfe;
+GET_DISK_ADDR(ccw, >ccw_addr.ssid, "ssid");
+GET_DISK_ADDR(ccw, >ccw_addr.devno, "devno");
+}
+
 #undef GET_DISK_ADDR
 }
 
diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h
index 7cbab489ec..37b482f3b2 100644
--- a/src/qemu/qemu_agent.h
+++ b/src/qemu/qemu_agent.h
@@ -77,6 +77,8 @@ struct _qemuAgentDiskInfo {
 unsigned int target;
 unsigned int unit;
 char *devnode;
+bool has_ccw_address;
+virDomainDeviceCCWAddress ccw_addr;
 };
 
 typedef struct _qemuAgentFSInfo qemuAgentFSInfo;
-- 
2.18.4