[libvirt] [PATCH v2.1] qemu_capabilities: introduce QEMU_CAPS_SD_CARD to probe sd-card drivers

Chen Hanxiao posted 1 patch 115 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1488800430-19547-1-git-send-email-chen_han_xiao@126.com
docs/news.xml                | 9 +++++++++
src/qemu/qemu_capabilities.c | 9 +++++++--
src/qemu/qemu_capabilities.h | 1 +
3 files changed, 17 insertions(+), 2 deletions(-)

[libvirt] [PATCH v2.1] qemu_capabilities: introduce QEMU_CAPS_SD_CARD to probe sd-card drivers

Posted by Chen Hanxiao 115 weeks ago
From: Chen Hanxiao <chenhanxiao@gmail.com>

This patch introduces QEMU_CAPS_SD_CARD for probing
whether qemu support SD card by:

{"execute": "device-list-properties",
    "arguments":{"typename":"sd-card"}}

It will be helpful for apps which used
cmd 'virsh domcaps` etc.

Also helpful for:
https://bugzilla.redhat.com/show_bug.cgi?id=1387218

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
---
v2:
   rebased on upstream
v2.1:
   add doc/news.xml description
   rebased on upstream

 docs/news.xml                | 9 +++++++++
 src/qemu/qemu_capabilities.c | 9 +++++++--
 src/qemu/qemu_capabilities.h | 1 +
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/docs/news.xml b/docs/news.xml
index 584c9af..b218463 100644
--- a/docs/news.xml
+++ b/docs/news.xml
@@ -26,6 +26,15 @@
           don't start it with unsupported features.
         </description>
       </change>
+      <change>
+          <summary>
+            qemu_capabilities: introduce QEMU_CAPS_SD_CARD to probe sd-card drivers
+        </summary>
+        <description>
+          The new QEMU capability flag will allow libvirt to probe sd-card
+          drivers.
+        </description>
+      </change>
     </section>
     <section title="Bug fixes">
       <change/>
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 5694d0b..1828b30 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -359,6 +359,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
               "query-cpu-model-expansion", /* 245 */
               "virtio-net.host_mtu",
               "spice-rendernode",
+              "sd-card",
     );
 
 
@@ -1626,6 +1627,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
     { "ivshmem-plain", QEMU_CAPS_DEVICE_IVSHMEM_PLAIN },
     { "ivshmem-doorbell", QEMU_CAPS_DEVICE_IVSHMEM_DOORBELL },
     { "vhost-scsi", QEMU_CAPS_DEVICE_VHOST_SCSI },
+    { "sd-card", QEMU_CAPS_SD_CARD },
 };
 
 static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBalloon[] = {
@@ -5425,8 +5427,7 @@ virQEMUCapsFillDomainDeviceDiskCaps(virQEMUCapsPtr qemuCaps,
     VIR_DOMAIN_CAPS_ENUM_SET(disk->bus,
                              VIR_DOMAIN_DISK_BUS_IDE,
                              VIR_DOMAIN_DISK_BUS_SCSI,
-                             VIR_DOMAIN_DISK_BUS_VIRTIO,
-                             /* VIR_DOMAIN_DISK_BUS_SD */);
+                             VIR_DOMAIN_DISK_BUS_VIRTIO);
 
     /* PowerPC pseries based VMs do not support floppy device */
     if (!ARCH_IS_PPC64(qemuCaps->arch) ||
@@ -5435,6 +5436,10 @@ virQEMUCapsFillDomainDeviceDiskCaps(virQEMUCapsPtr qemuCaps,
 
     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_USB_STORAGE))
         VIR_DOMAIN_CAPS_ENUM_SET(disk->bus, VIR_DOMAIN_DISK_BUS_USB);
+
+    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SD_CARD))
+        VIR_DOMAIN_CAPS_ENUM_SET(disk->bus, VIR_DOMAIN_DISK_BUS_SD);
+
     return 0;
 }
 
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index cc9f46e..decca12 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -394,6 +394,7 @@ typedef enum {
     QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION, /* qmp query-cpu-model-expansion */
     QEMU_CAPS_VIRTIO_NET_HOST_MTU, /* virtio-net-*.host_mtu */
     QEMU_CAPS_SPICE_RENDERNODE, /* -spice rendernode */
+    QEMU_CAPS_SD_CARD, /* -sd SD-card.img */
 
     QEMU_CAPS_LAST /* this must always be the last item */
 } virQEMUCapsFlags;
-- 
2.7.4


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v2.1] qemu_capabilities: introduce QEMU_CAPS_SD_CARD to probe sd-card drivers

Posted by Pavel Hrdina 115 weeks ago
On Mon, Mar 06, 2017 at 07:40:30PM +0800, Chen Hanxiao wrote:
> From: Chen Hanxiao <chenhanxiao@gmail.com>
> 
> This patch introduces QEMU_CAPS_SD_CARD for probing
> whether qemu support SD card by:
> 
> {"execute": "device-list-properties",
>     "arguments":{"typename":"sd-card"}}
> 
> It will be helpful for apps which used
> cmd 'virsh domcaps` etc.
> 
> Also helpful for:
> https://bugzilla.redhat.com/show_bug.cgi?id=1387218
> 
> Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
> ---
> v2:
>    rebased on upstream
> v2.1:
>    add doc/news.xml description
>    rebased on upstream
> 
>  docs/news.xml                | 9 +++++++++
>  src/qemu/qemu_capabilities.c | 9 +++++++--
>  src/qemu/qemu_capabilities.h | 1 +
>  3 files changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/docs/news.xml b/docs/news.xml
> index 584c9af..b218463 100644
> --- a/docs/news.xml
> +++ b/docs/news.xml
> @@ -26,6 +26,15 @@
>            don't start it with unsupported features.
>          </description>
>        </change>
> +      <change>
> +          <summary>
> +            qemu_capabilities: introduce QEMU_CAPS_SD_CARD to probe sd-card drivers
> +        </summary>
> +        <description>
> +          The new QEMU capability flag will allow libvirt to probe sd-card
> +          drivers.
> +        </description>
> +      </change>
>      </section>
>      <section title="Bug fixes">
>        <change/>
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index 5694d0b..1828b30 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -359,6 +359,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
>                "query-cpu-model-expansion", /* 245 */
>                "virtio-net.host_mtu",
>                "spice-rendernode",
> +              "sd-card",
>      );
>  
>  
> @@ -1626,6 +1627,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
>      { "ivshmem-plain", QEMU_CAPS_DEVICE_IVSHMEM_PLAIN },
>      { "ivshmem-doorbell", QEMU_CAPS_DEVICE_IVSHMEM_DOORBELL },
>      { "vhost-scsi", QEMU_CAPS_DEVICE_VHOST_SCSI },
> +    { "sd-card", QEMU_CAPS_SD_CARD },
>  };
>  
>  static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBalloon[] = {
> @@ -5425,8 +5427,7 @@ virQEMUCapsFillDomainDeviceDiskCaps(virQEMUCapsPtr qemuCaps,
>      VIR_DOMAIN_CAPS_ENUM_SET(disk->bus,
>                               VIR_DOMAIN_DISK_BUS_IDE,
>                               VIR_DOMAIN_DISK_BUS_SCSI,
> -                             VIR_DOMAIN_DISK_BUS_VIRTIO,
> -                             /* VIR_DOMAIN_DISK_BUS_SD */);
> +                             VIR_DOMAIN_DISK_BUS_VIRTIO);
>  
>      /* PowerPC pseries based VMs do not support floppy device */
>      if (!ARCH_IS_PPC64(qemuCaps->arch) ||
> @@ -5435,6 +5436,10 @@ virQEMUCapsFillDomainDeviceDiskCaps(virQEMUCapsPtr qemuCaps,
>  
>      if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_USB_STORAGE))
>          VIR_DOMAIN_CAPS_ENUM_SET(disk->bus, VIR_DOMAIN_DISK_BUS_USB);
> +
> +    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SD_CARD))
> +        VIR_DOMAIN_CAPS_ENUM_SET(disk->bus, VIR_DOMAIN_DISK_BUS_SD);
> +
>      return 0;
>  }
>  
> diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
> index cc9f46e..decca12 100644
> --- a/src/qemu/qemu_capabilities.h
> +++ b/src/qemu/qemu_capabilities.h
> @@ -394,6 +394,7 @@ typedef enum {
>      QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION, /* qmp query-cpu-model-expansion */
>      QEMU_CAPS_VIRTIO_NET_HOST_MTU, /* virtio-net-*.host_mtu */
>      QEMU_CAPS_SPICE_RENDERNODE, /* -spice rendernode */
> +    QEMU_CAPS_SD_CARD, /* -sd SD-card.img */

The caps name should be QEMU_CAPS_DEVICE_SD_CARD and the comment should be
"-device sd-card".

There is however another issue with the SD_CARD support.  It currently works
only if the machine type provides implicit sd-bus and sd device which is
only ARM arch and not even all machine types.

For example on x86 arch we need to add -device sdhci-pci to provide SD bus
and for each SD disk we need to add a pair of:

    -drive file=/path,bus=sd,id=drive-sdN,...
    -device sd-card,id=sdN,drive=drive-sdN,...

to make the sd-card work, but this logic is not implemented so we
shouldn't report that the SD bus is available.

We could report SD bus only for ARM but the one machine type "virt" which
will be mostly used these days doesn't have implicit sd-bus and we need to
add some SD controller.

Pavel

>      QEMU_CAPS_LAST /* this must always be the last item */
>  } virQEMUCapsFlags;
> -- 
> 2.7.4
> 
> 
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list