Re: [PATCH v12 2/7] QIOChannelSocket: Implement io_writev zero copy flag & io_flush for CONFIG_LINUX

2022-05-07 Thread Peter Xu
On Fri, May 06, 2022 at 10:57:54PM -0300, Leonardo Bras wrote:
> diff --git a/io/channel-socket.c b/io/channel-socket.c
> index 05c425abb8..f03a068f25 100644
> --- a/io/channel-socket.c
> +++ b/io/channel-socket.c
> @@ -25,9 +25,18 @@
>  #include "io/channel-watch.h"
>  #include "trace.h"
>  #include "qapi/clone-visitor.h"
> +#ifdef CONFIG_LINUX
> +#include 
> +#include 
> +
> +#if (defined(MSG_ZEROCOPY) && defined(SO_ZEROCOPY))
> +#define QEMU_MSG_ZEROCOPY
> +#endif
> +#endif
>  
>  #define SOCKET_MAX_FDS 16
>  
> +

This line can be dropped when merge.

>  SocketAddress *
>  qio_channel_socket_get_local_address(QIOChannelSocket *ioc,
>   Error **errp)

This does look nicer, imho. :)

Thanks!

-- 
Peter Xu




[PATCH 2/2] hw/nvme: support smart AEN

2022-05-07 Thread zhenwei pi
Support smart AEN on controller side, if the guest side enables this
feature, after injecting smart critical warning, also raise AER.

This can be tested by:
virsh qemu-monitor-command vm '{ "execute": "qom-set", "arguments":
  { "path": "/machine/peripheral/nvme0",
  "property": "smart_critical_warning", "value":1 } }'

Signed-off-by: zhenwei pi 
---
 hw/nvme/ctrl.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index 03760ddeae..8236a746c8 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -6707,6 +6707,7 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice 
*pci_dev)
 NvmeIdCtrl *id = >id_ctrl;
 uint8_t *pci_conf = pci_dev->config;
 uint64_t cap = ldq_le_p(>bar.cap);
+uint32_t supported_oaes;
 
 id->vid = cpu_to_le16(pci_get_word(pci_conf + PCI_VENDOR_ID));
 id->ssvid = cpu_to_le16(pci_get_word(pci_conf + PCI_SUBSYSTEM_VENDOR_ID));
@@ -6716,7 +6717,13 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice 
*pci_dev)
 
 id->cntlid = cpu_to_le16(n->cntlid);
 
-id->oaes = cpu_to_le32(NVME_OAES_NS_ATTR);
+supported_oaes = NVME_OAES_SMART_SPARE | NVME_OAES_SMART_TEMPERATURE |
+ NVME_OAES_SMART_RELIABILITY |
+ NVME_OAES_SMART_MEDIA_READ_ONLY |
+ NVME_OAES_SMART_FAILED_VOLATILE_MEDIA |
+ NVME_OAES_SMART_PMR_UNRELIABLE |
+ NVME_OAES_NS_ATTR;
+id->oaes = cpu_to_le32(supported_oaes);
 id->ctratt |= cpu_to_le32(NVME_CTRATT_ELBAS);
 
 id->rab = 6;
-- 
2.20.1




[PATCH 0/2] hw/nvme: support smart AEN

2022-05-07 Thread zhenwei pi
Hi,
In this series, firstly introduce smart related bits of aen cfg, then
support this in oaes.

Linux guest does not support this currently, I also send a series to
enable smart AEN:
https://lore.kernel.org/lkml/20220507065026.260306-1-pizhen...@bytedance.com/T/#t

Test the two series together, works fine.

Zhenwei Pi (2):
  hw/nvme: introduce smart bits of aen cfg
  hw/nvme: support smart AEN

 hw/nvme/ctrl.c   | 9 -
 include/block/nvme.h | 8 +++-
 2 files changed, 15 insertions(+), 2 deletions(-)

-- 
2.20.1




[PATCH 1/2] hw/nvme: introduce smart bits of aen cfg

2022-05-07 Thread zhenwei pi
According to NVM Express v1.4, Section 5.21.1.11 (Asynchronous Event
Configuration), introduce bit 0 ~ bit 5.

Signed-off-by: zhenwei pi 
---
 include/block/nvme.h | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/block/nvme.h b/include/block/nvme.h
index 3737351cc8..d92912f9ad 100644
--- a/include/block/nvme.h
+++ b/include/block/nvme.h
@@ -1122,7 +1122,13 @@ typedef struct NvmeIdCtrlNvm {
 } NvmeIdCtrlNvm;
 
 enum NvmeIdCtrlOaes {
-NVME_OAES_NS_ATTR   = 1 << 8,
+NVME_OAES_SMART_SPARE = NVME_SMART_SPARE,
+NVME_OAES_SMART_TEMPERATURE   = NVME_SMART_TEMPERATURE,
+NVME_OAES_SMART_RELIABILITY   = NVME_SMART_RELIABILITY,
+NVME_OAES_SMART_MEDIA_READ_ONLY   = NVME_SMART_MEDIA_READ_ONLY,
+NVME_OAES_SMART_FAILED_VOLATILE_MEDIA = NVME_SMART_FAILED_VOLATILE_MEDIA,
+NVME_OAES_SMART_PMR_UNRELIABLE= NVME_SMART_PMR_UNRELIABLE,
+NVME_OAES_NS_ATTR = 1 << 8,
 };
 
 enum NvmeIdCtrlCtratt {
-- 
2.20.1